I need to create directories and files in a Samba share on Windows, from a Python script. I can (and do) also use .NET 3.5 from Python. I would like to create these directories and files with certain owners and permissions. Can I achieve this somehow?
views:
155answers:
1
+1
Q:
How to set file/directory ownership/permissions in a Samba share on Windows using Python/.NET?
A:
You can use CACLS.exe to display or modify Access Control Lists (ACLs) for files and folders. You can call this from Python with something like:
result = os.popen("cacls " + '"' + theDirPath + '"')
There is a good example of a Python script which sets up permissions here
lrussell
2010-02-10 19:46:55
Thanks, that was quick! Looking into cacls/icacls.
aknuds1
2010-02-10 20:05:45
I have now tried to set permissions in the samba share with icacls and cacls. The former crashes, while the latter says "Access is denied". The cacls command I supplied was: cacls \\sh\home-test-0\test /P "arvenk:R". This command should be OK, no?
aknuds1
2010-02-11 12:30:33