Is there a standard library module in Python 2.4 (Win32) that will
return directory permissions / ACLs (e.g. users, groups, and what
rights they have)?

Otherwise, I'm faced with sending "cacls dirName" commands via os.popen
as below, and then parsing and comparing the text output.

Basically, I'd like to compare what the ACLs a directory should have
against what the actual ACLs are.

Here's what I started with:

import os           # Cross-platform filesystem manipulation

rootDir = "S:\someRootDirectoryHere"

print "*** Printing DIRECTORY names beneath directory " + rootDir + "
***\n"
for dirpath, dirnames, filenames in os.walk(rootDir):
    for dirNm in dirnames:
        theDirPath = os.path.join(dirpath, dirNm)
        print '"' + theDirPath +'"'
        # cacls needs double-quotes around space-containing paths
        result = os.popen("cacls " + '"' + theDirPath + '"')
        # Print the security info (ACLs)for specified directory
        print result.read()

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to