3 self._perms = [0]*4
4 self.perm = perm
5 self.type = '-'
6 self.sanity()
7 self.parse()
8
10 return_value = False
11 other_permobj = UnixPermParser(other_perm)
12 for comp in range(0, 4):
13 if self._perms[comp] != other_permobj._perms[comp]:
14 return_value = True
15 return return_value
17 bits = 0
18 other_permobj = UnixPermParser(other_perm)
19 for comp in range(0, 4):
20 if self._perms[comp] == other_permobj._perms[comp]:
21 bits += 1
22 if bits == 4:
23 return True
24 return False
26 return ''.join(map(lambda x: '%s' % x, self._perms))
28 if len(self.perm) != 10:
29 raise UnixPermParserException, \
30 "%s isn't 10 bits long!" % self.perm
31 else:
32 for bit in range(0, 10):
33 if bit in (1, 4, 7):
34 if self.perm[bit] not in ('r', '-'):
35 raise UnixPermParserException, \
36 "Bit %s (%s) isn't r or -" % (bit, self.perm[bit])
37 elif bit in (2, 5, 8):
38 if self.perm[bit] not in ('w', '-'):
39 raise UnixPermParserException, \
40 "Bit %s (%s) isn't w or -" % (bit, self.perm[bit])
41 elif bit in (3, 6, 9):
42 if self.perm[bit] not in ('x', 's', 'S', 't', 'T', '-'):
43 raise UnixPermParserException, \
44 "Bit %s (%s) isn't x, s, S, t, T or -" % (bit, \
45 self.perm[bit])
46 elif bit == 0:
47 if self.perm[0] not in ('b', 'c', 'd', 'h', 'l', 'p', '-'):
48 raise UnixPermParserException, \
49 "Bit 0 (%s) isn't b, c, d, h, l, p, or -" % \
50 self.perm[0]
51 else:
52 self.type = self.perm[0]
53
55 tmp_perm = [self.perm[0], self.perm[1:4], self.perm[4:7], \
56 self.perm[7:]]
57 for x in range(1, 4):
58 for y in tmp_perm[x]:
59 if y == 'r': self._perms[x] += 4
60 if y == 'w': self._perms[x] += 2
61 if y == 'x': self._perms[x] += 1
62 if y in ('s', 'S') and x in (1, 2):
63 if x == 1: self._perms[0] += 4
64 if x == 2: self._perms[0] += 2
65 if y == 's': self._perms[x] += 1
66 if y in ('t', 'T') and x == 3:
67 self._perms[0] += 1
68 if y == 't': self._perms[3] += 1
69
71 executable = 0
72 for perm in self._perms:
73 if perm % 2:
74 executable += 1
75 return executable
76
78 if self.type == 'l':
79 return True
80
82 if self.type == 'd':
83 return True
84
87