使用 Posix 1e 在 Python 中检索默认 ACL [英] Retrieve Default ACL in Python Using Posix 1e

查看:34
本文介绍了使用 Posix 1e 在 Python 中检索默认 ACL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 posix 1e Python 模块我能够获取/设置文件的 ACL无需生成子进程并调用 getfacl/setfacl:

<预><代码>>>>导入posix1e>>>acl1 = posix1e.ACL(file="file.txt")>>>打印 acl1用户::rw-组::rw-其他::r--

我也可以应用一个默认的 ACL 并删除它:

path = '/some/other/path/'acl1.applyto(路径,posix1e.ACL_TYPE_DEFAULT)posix1e.delete_default(路径)

但是,我似乎不知道如何检索默认 ACL!有谁知道如何使用 posix 1e 模块来做到这一点?

解决方案

事实证明有一种方法可以做到这一点:

default_acl1 = posix1e.ACL(filedef="/some/other/path/")

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?

解决方案

Turns out there is a way to do this:

default_acl1 = posix1e.ACL(filedef="/some/other/path/") 

这篇关于使用 Posix 1e 在 Python 中检索默认 ACL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆