views:

155

answers:

1

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?

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
Thanks, that was quick! Looking into cacls/icacls.
aknuds1
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