[英]How do I modify file access control lists using python?
I have a script that does a whole bunch of file manipulation in python, but I'm running into trouble because I'm routinely encountering files that have ACL's set to things like "group: everyone deny delete". 我有一个脚本在python中执行一大堆文件操作,但是我遇到了麻烦,因为我经常遇到ACL设置为“group:everyone deny delete”之类的文件。
For other permission issues I've used os.chmod
to fix things, but can't find how to remove or modify ACL's using this, or other methods. 对于其他权限问题,我已经使用
os.chmod
来解决问题,但无法找到如何使用此方法或其他方法删除或修改ACL。
On macOS you can call directly chmod
: 在macOS上你可以直接调用
chmod
:
# exceptions:
# subprocess.CalledProcessError:
# Command '['chmod', '-h', '-a', 'everyone deny delete',
# '/Users/liviu/Music']' returned non-zero exit status 1
if 0:
subprocess.check_call(['chmod', '-h', '-a', 'everyone deny delete', os.path.expanduser('~/Music')])
proc = subprocess.Popen(['chmod', '-h', '+a', 'everyone deny delete', os.path.expanduser('~/Music')])
proc.communicate()
I suppose there's a command line equivalent on Unix-es . 我想在Unix-es上有一个等价的命令行。
Now Windows is a different story, but you can always count on PowerShell . 现在Windows是一个不同的故事,但你总是可以依靠PowerShell 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.