Retrieve Default ACL in Python Using Posix 1e

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 02:15:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!