Querying for ownership of file shared by Samba fails with "MemoryError: allocating SECURITY_DESCRIPTOR"

Middle Fork GIS middleforkgis at gmail.com
Wed Sep 23 21:16:28 CEST 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090923/c42e90b6/attachment.html>


More information about the Python-list mailing list