File: xattr.py

package info (click to toggle)
pysmbc 1.0.15.3-0.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 260 kB
  • ctags: 248
  • sloc: ansic: 2,031; python: 741; makefile: 24
file content (63 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python


SMB_POSIX_ACL_USER_OBJ=0x01
SMB_POSIX_ACL_USER=0x02
SMB_POSIX_ACL_GROUP_OBJ=0x04
SMB_POSIX_ACL_GROUP=0x08
SMB_POSIX_ACL_MASK=0x10
SMB_POSIX_ACL_OTHER=0x20


SMB_POSIX_ACL_READ=0x04
SMB_POSIX_ACL_WRITE=0x02
SMB_POSIX_ACL_EXECUTE=0x01

SMB_POSIX_ACL_HEADER_SIZE=6
SMB_POSIX_ACL_ENTRY_SIZE=10


rwx=0x001e01ff
x=0x001200a0
w=0x00120116
r=0x00120089

class SmbAcl():
    revision = None
    owner = None
    group = None
    acl = []

    def __init__(self, xattr_s=None):
        """ parse an acl into a SmbAcl object """
        if xattr_s:
            xattr_l = [ s[s.index(":")+1:] for s in xattr_s.split(",")]
            (self.revision, self.owner, self.group) = xattr_l[0:3]
            self.acl = xattr_l[3:]


    def __str__(self):
        ret = "REVISION:%s,OWNER:%s,GROUP:%s" % (self.revision,self.owner,self.group)
        for a in self.acl:
            ret = ret + ",ACL:%s" % a
        return ret

    @staticmethod
    def get_target(acl_s):
        return acl_s[0:acl_s.index(":")]

    @staticmethod
    def get_perm(acl_s):
        return acl_s[acl_s.index(":")+1:]

#
#import smbc
#
#c = smbc.Context(debug=1)
#cb = lambda se, sh, w, u, p: ("WORKGROUP","babel","b3nedetto")
#c.functionAuthData = cb
#
#print c.opendir("smb://localhost/share/Neffa").getdents()
#print c.getxattr("smb://localhost/share/Neffa", "system.nt_sec_desc.*")
#print c.getxattr("smb://localhost/share/Neffa", "s")
#