"Middle Fork GIS" <middlefork...@gmail.com> wrote in message news:943c8e0b0909231216t1c590b14u453855718352...@mail.gmail.com... >I have just learned how to use the win32security module (within Windows, of > course) to determine file ownership. When running against local drives or > windows shares, this works fine, as shown in the following code (Python > 2.4/2.5 with PyWin extensions): > > import win32security > file = 'c:/temp/test.txt' > #Using the win32security module get ownership information > ownerSecurity= > win32security.GetFileSecurity(file,win32security.OWNER_SECURITY_INFORMATION) > ownerSID = ownerSecurity.GetSecurityDescriptorOwner () > owner,domain,type = win32security.LookupAccountSid (None, ownerSID) > print "File %s is owned by %s\\%s" % (file,domain,owner) > > > However, when I run this against a file on an SMB mounted file system (the > server is AIX Unix),the following error is raised: > > > File > "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", > line 325, in RunScript > exec codeObject in __main__.__dict__ > > File "C:\scripts\testfileinfo.py", line 17, in ? > ownerSecurity= > win32security.GetFileSecurity(file,win32security.OWNER_SECURITY_INFORMATION) > > MemoryError: allocating SECURITY_DESCRIPTOR > > ============================ > > Interestingly, searching the G**gle for the string > "MemoryError: allocating SECURITY_DESCRIPTOR" results in only two primary > hits, back to 2003, which look like this: > >> Anyone have any ideas on what the problem might be here (M: is a >> Win98 shared disk space - command was issued from a PythonWin >> session running on a Win 2000 machine): >> >> >>> GetFileSecurity("M:\\autoexec.bat", OWNER_SECURITY_INFORMATION) >> Traceback (most recent call last): >> File "<interactive input>", line 1, in ? >> MemoryError: allocating SECURITY_DESCRIPTOR >> >>Win95,98,ME use the FAT32 filesystem. This has absolutely no ACL or >>permission capabilities on it. Win NT, 2K, XP use NTFS by default, >>which allows ACLS. > > Any insights would be greatly appreciated. > > Steve Walker > middleforkgis aht gmail.com >
If I remember correctly, GetFileSecurity can work unpredictably with file systems that don't support ACL's. Try using win32security.GetNamedSecurityInfo instead. Roger -- http://mail.python.org/mailman/listinfo/python-list