Re: Python linuxfs Modules

Lawrence D’Oliveiro <[email protected]> Wed, 18 Mar 2026 08:04:14 -0000 (UTC)
Newsgroups comp.lang.python
Organization A noiseless patient Spider
Message-ID <[email protected]>
On Tue, 17 Mar 2026 23:28:26 -0700, Paul Rubin wrote:

> There were a few things like this that were missing for years. I was
> going to suggest adding them to your modules, but it looks like
> they've finally made it to the Python world elsewhere.

Someone else had already done a wrapper for the ACL functions
<https://github.com/iustin/pylibacl>. However, I feel they expose too
much of the underlying libacl details -- for example, I don’t see the
point in separating a “permset” object from its associated ACL entry,
since the two are always tied together anyway. Also they have written
an extension module in C, whereas mine is a pure-Python implementation
using ctypes. As for what difference it makes, consider that they need
about 1800 lines of code, whereas I can provide equivalent
functionality in about half that.

Actually, I have a plan to go further. I have figured out that the
contents of an ACL can be expressed most naturally as a Python object
with the following components:

  * a user_access array, indexed by the USERCLASS enum (with values
    USER, GROUP and OTHER), with each value being a set of the PERM
    enum (with the expected values READ, WRITE and EXECUTE); put these
    together, and you get the usual *nix mode value.
  * two dictionaries, “users” and “groups”, keyed by user and group
    IDs respectively, with the values being sets of PERM as before.
    You have the usual Python dictionary operations to
    access/iterate/add/modify/remove entries in these -- no need
    to invent new API-specific ones.
  * a mask value, being yet another set of PERM.

Working at that level, it seems to me, would be easier than any simple
wrapper around libacl.