40
40
the users belonging to the given groups. (User names must be separated by
43
All other sections names should be path names (starting with '/'), defining
44
the permissions for the given path. The options in those sections are user
45
names or group references (group name with a leading '@'), the corresponding
46
values are the permissions: 'rw', 'r' and '' (without the quotes) for
47
read-write, read-only and no access, respectively.
49
Only the options in the section with the longest matching name are evaluated.
50
The last relevant option for the user is used.
43
Right now only one section is supported [/], defining the permissions for the
44
repository. The options in those sections are user names or group references
45
(group name with a leading '@'), the corresponding values are the
46
permissions: 'rw', 'r' and '' (without the quotes)
47
for read-write, read-only and no access, respectively.
52
49
Sample bzr_access.conf::
56
53
devels = beta, gamma, delta
67
59
This allows you to set up a single SSH user, and customize the access based on
68
60
ssh key. Your ``.ssh/authorized_key`` file should look something like this::
131
123
self.groups[group] = set([ s.strip() for s in users.split(",")])
134
def permission(self, user, path):
126
def permission(self, user):
135
127
"""Determines the permission for a given user and a given path
136
128
:param user: user to look for.
137
:param path: path to look for.
138
129
:return: permission.
140
if not path.startswith("/"):
142
132
perm = PERM_DENIED
144
while not pathFound and path != "/":
145
print >>sys.stderr, "DEBUG:", path
146
pathFound = self.config.has_section(path)
148
options = reversed(self.config.options(path))
149
for option in options:
150
value = PERM_DICT.get(self.config.get(path, option),
152
if self._is_relevant(option, user):
155
path = os.path.dirname(path)
133
pathFound = self.config.has_section(configSection)
135
options = reversed(self.config.options(configSection))
136
for option in options:
137
value = PERM_DICT.get(self.config.get(configSection, option),
139
if self._is_relevant(option, user):
159
144
def _is_relevant(self, option, user):
160
145
"""Decides if a certain option is relevant for a given user.
225
210
error("Can't read config file.", EXIT_NOCONF)
227
212
# Determine permission and execute bzr with appropriate options
228
perm = accessMan.permission(user, directory)
229
absDir = os.path.join(repoRoot, directory)
230
command = [bzrExec] + BZR_OPTIONS + [absDir]
213
perm = accessMan.permission(user)
214
command = [bzrExec] + BZR_OPTIONS + [repoRoot]
231
215
if perm == PERM_READ:
232
216
# Nothing extra needed for readonly operations