Revision 43763394 pithos/backends/lib/sqlite/permissions.py
b/pithos/backends/lib/sqlite/permissions.py | ||
---|---|---|
55 | 55 |
if not members: |
56 | 56 |
return |
57 | 57 |
feature = self.xfeature_create(path) |
58 |
if feature is None: |
|
59 |
return |
|
60 | 58 |
self.feature_setmany(feature, access, members) |
61 | 59 |
|
62 | 60 |
def access_set(self, path, permissions): |
... | ... | |
79 | 77 |
if access == READ and self.public_get(path) is not None: |
80 | 78 |
return True |
81 | 79 |
|
82 |
r = self.xfeature_inherit(path)
|
|
83 |
if not r:
|
|
80 |
feature = self.xfeature_get(path)
|
|
81 |
if not feature:
|
|
84 | 82 |
return False |
85 |
fpath, feature = r |
|
86 | 83 |
members = self.feature_get(feature, access) |
87 | 84 |
if member in members or '*' in members: |
88 | 85 |
return True |
... | ... | |
92 | 89 |
return False |
93 | 90 |
|
94 | 91 |
def access_inherit(self, path): |
95 |
"""Return the inherited or assigned (path, permissions) pair for path."""
|
|
92 |
"""Return the paths influencing the access for path."""
|
|
96 | 93 |
|
97 | 94 |
r = self.xfeature_inherit(path) |
98 | 95 |
if not r: |
99 |
return (path, {}) |
|
100 |
fpath, feature = r |
|
101 |
permissions = self.feature_dict(feature) |
|
102 |
if READ in permissions: |
|
103 |
permissions['read'] = permissions[READ] |
|
104 |
del(permissions[READ]) |
|
105 |
if WRITE in permissions: |
|
106 |
permissions['write'] = permissions[WRITE] |
|
107 |
del(permissions[WRITE]) |
|
108 |
return (fpath, permissions) |
|
109 |
|
|
110 |
def access_list(self, path): |
|
111 |
"""List all permission paths inherited by or inheriting from path.""" |
|
96 |
return [] |
|
97 |
|
|
98 |
def get_permissions(feature): |
|
99 |
permissions = self.feature_dict(feature) |
|
100 |
if READ in permissions: |
|
101 |
permissions['read'] = permissions[READ] |
|
102 |
del(permissions[READ]) |
|
103 |
if WRITE in permissions: |
|
104 |
permissions['write'] = permissions[WRITE] |
|
105 |
del(permissions[WRITE]) |
|
106 |
return permissions |
|
112 | 107 |
|
113 |
return [x[0] for x in self.xfeature_list(path) if x[0] != path] |
|
108 |
# Only keep path components. |
|
109 |
parts = path.rstrip('/').split('/') |
|
110 |
valid = [] |
|
111 |
for i in range(1, len(parts)): |
|
112 |
subp = '/'.join(parts[:i + 1]) |
|
113 |
valid.append(subp) |
|
114 |
valid.append(subp + '/') |
|
115 |
return [(x[0], get_permissions(x[1])) for x in r if x[0] in valid] |
|
114 | 116 |
|
115 | 117 |
def access_list_paths(self, member, prefix=None): |
116 | 118 |
"""Return the list of paths granted to member.""" |
Also available in: Unified diff