tags:

views:

22

answers:

1

I want to give anyone full access to a specific folder (+sub-folders +files in it). I tried that code:

f = "c:\test" #... which is the folder

#vars
sidWorld = win32security.CreateWellKnownSid(win32security.WinWorldSid, None)
worldRights = win32file.FILE_ALL_ACCESS

#get DACL
fileSecDesc = win32security.GetNamedSecurityInfo( \
    f, win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION)
fileDacl = fileSecDesc.GetSecurityDescriptorDacl()

#add rights
fileDacl.AddAccessAllowedAce( win32security.ACL_REVISION, worldRights, sidWorld )

win32security.SetNamedSecurityInfo( \
    f, win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION, \
    None, None, fileDacl, None )

Problem is, it isn't shown as full access, i think because of the missing inheritance (I also need inheritance). I cannot figure out how to solve this.

Any idea what I'm missing? Thanks, best regards, Florian Lagg.

A: 

Got it after a break: it's so easy:

#vars
sidWorld = win32security.CreateWellKnownSid(win32security.WinWorldSid, None)
worldRights = win32file.FILE_ALL_ACCESS
flags = win32security.OBJECT_INHERIT_ACE| \
    win32security.CONTAINER_INHERIT_ACE

#get DACL
fileSecDesc = win32security.GetNamedSecurityInfo( \
    f, win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION)
fileDacl = fileSecDesc.GetSecurityDescriptorDacl()

#add rights
fileDacl.AddAccessAllowedAceEx( \
    win32security.ACL_REVISION_DS, \
    flags, \
    worldRights, \
    sidWorld)

win32security.SetNamedSecurityInfo( \
    f, win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION, \
    None, None, fileDacl, None )

Therefore: SOLVED! Thanks anyway!

Florian Lagg