问题
Using the posix 1e Python module I am able to get/set the ACL for a file without having to spawn a subprocess and call getfacl
/setfacl
:
>>> import posix1e
>>> acl1 = posix1e.ACL(file="file.txt")
>>> print acl1
user::rw-
group::rw-
other::r--
I can also apply a default ACL and delete it:
path = '/some/other/path/'
acl1.applyto(path, posix1e.ACL_TYPE_DEFAULT)
posix1e.delete_default(path)
However, I can not seem to work out how to retrieve the default ACL! Does anyone know how this can be done using the posix 1e module?
回答1:
Turns out there is a way to do this:
default_acl1 = posix1e.ACL(filedef="/some/other/path/")
来源:https://stackoverflow.com/questions/38855666/retrieve-default-acl-in-python-using-posix-1e