예제 #1
0
파일: lfcCmd.py 프로젝트: mapa17/PeggyVine
    def getacl(path):
        # print("Get acl for %s" % path)
        acl = {}
        # Default value
        acl["owner_perm"] = "???"
        acl["owner"] = "unknown"
        acl["group_perm"] = "???"
        acl["group"] = "unknown"
        acl["others_perm"] = "???"

        acls_list = lfc.lfc_getacl(path)
        for i in acls_list:
            try:
                # print "type %d" % i.a_type
                if i.a_type == 1:  # User permissions
                    acl["owner_perm"] = lfcCmd._numToPermString(i.a_perm)
                    acl["owner"] = lfcCmd._getusrbyuid(i.a_id)

                elif i.a_type == 3:  # Group permissions
                    acl["group_perm"] = lfcCmd._numToPermString(i.a_perm)
                    acl["group"] = lfcCmd._getgrpbygid(i.a_id)

                elif i.a_type == 6:  # others permissions
                    acl["others_perm"] = lfcCmd._numToPermString(i.a_perm)

            except Exception, e:
                pass
예제 #2
0
파일: getacl.py 프로젝트: mapa17/PeggyVine
#!/usr/bin/python

import sys
import traceback
import os

sys.path.append( os.environ["LCG_LOCATION"] )
import lfc2 as lfc

"""
# Using the lfc_getacl to get ACL entries for a file/directory
"""

if len(sys.argv) < 2:
        print "Syntax: %s <LFC_path>" % sys.argv[0]
        sys.exit(-1)

file = sys.argv[1]

try:
        acls_list = lfc.lfc_getacl(file)
except Exception:
        traceback.print_exc()
        sys.exit(1)

print "Found %s entries for %s" % (len(acls_list), file)
for i in acls_list:
        print "User/Group ID: %d" % i.a_id
        print "ACL Type : %d" % i.a_type
        print "Permissions : %d\n" % i.a_perm