Show More
@@ -145,16 +145,24 b' from mercurial.i18n import _' | |||||
145 | from mercurial import util, match |
|
145 | from mercurial import util, match | |
146 | import getpass, urllib, grp |
|
146 | import getpass, urllib, grp | |
147 |
|
147 | |||
148 | def _getusers(group): |
|
148 | def _getusers(ui, group): | |
|
149 | ||||
|
150 | # First, try to use group definition from section [acl.groups] | |||
|
151 | hgrcusers = ui.configlist('acl.groups', group) | |||
|
152 | if hgrcusers: | |||
|
153 | return hgrcusers | |||
|
154 | ||||
|
155 | ui.debug('acl: "%s" not defined in [acl.groups]\n' % group) | |||
|
156 | # If no users found in group definition, get users from OS-level group | |||
149 | return grp.getgrnam(group).gr_mem |
|
157 | return grp.getgrnam(group).gr_mem | |
150 |
|
158 | |||
151 | def _usermatch(user, usersorgroups): |
|
159 | def _usermatch(ui, user, usersorgroups): | |
152 |
|
160 | |||
153 | if usersorgroups == '*': |
|
161 | if usersorgroups == '*': | |
154 | return True |
|
162 | return True | |
155 |
|
163 | |||
156 | for ug in usersorgroups.replace(',', ' ').split(): |
|
164 | for ug in usersorgroups.replace(',', ' ').split(): | |
157 | if user == ug or ug.find('@') == 0 and user in _getusers(ug[1:]): |
|
165 | if user == ug or ug.find('@') == 0 and user in _getusers(ui, ug[1:]): | |
158 | return True |
|
166 | return True | |
159 |
|
167 | |||
160 | return False |
|
168 | return False | |
@@ -166,7 +174,7 b' def buildmatch(ui, repo, user, key):' | |||||
166 | return None |
|
174 | return None | |
167 |
|
175 | |||
168 | pats = [pat for pat, users in ui.configitems(key) |
|
176 | pats = [pat for pat, users in ui.configitems(key) | |
169 | if _usermatch(user, users)] |
|
177 | if _usermatch(ui, user, users)] | |
170 | ui.debug('acl: %s enabled, %d entries for user %s\n' % |
|
178 | ui.debug('acl: %s enabled, %d entries for user %s\n' % | |
171 | (key, len(pats), user)) |
|
179 | (key, len(pats), user)) | |
172 |
|
180 | |||
@@ -200,7 +208,7 b' def hook(ui, repo, hooktype, node=None, ' | |||||
200 |
|
208 | |||
201 | cfg = ui.config('acl', 'config') |
|
209 | cfg = ui.config('acl', 'config') | |
202 | if cfg: |
|
210 | if cfg: | |
203 | ui.readconfig(cfg, sections = ['acl.allow.branches', |
|
211 | ui.readconfig(cfg, sections = ['acl.groups', 'acl.allow.branches', | |
204 | 'acl.deny.branches', 'acl.allow', 'acl.deny']) |
|
212 | 'acl.deny.branches', 'acl.allow', 'acl.deny']) | |
205 |
|
213 | |||
206 | allowbranches = buildmatch(ui, None, user, 'acl.allow.branches') |
|
214 | allowbranches = buildmatch(ui, None, user, 'acl.allow.branches') |
@@ -28,7 +28,13 b' init_config()' | |||||
28 | { |
|
28 | { | |
29 | cat > fakegroups.py <<EOF |
|
29 | cat > fakegroups.py <<EOF | |
30 | from hgext import acl |
|
30 | from hgext import acl | |
31 | acl._getusers = lambda x: ["fred", "betty"] |
|
31 | def fakegetusers(ui, group): | |
|
32 | try: | |||
|
33 | return acl._getusersorig(ui, group) | |||
|
34 | except: | |||
|
35 | return ["fred", "betty"] | |||
|
36 | acl._getusersorig = acl._getusers | |||
|
37 | acl._getusers = fakegetusers | |||
32 | EOF |
|
38 | EOF | |
33 |
|
39 | |||
34 | rm -f acl.config |
|
40 | rm -f acl.config |
General Comments 0
You need to be logged in to leave comments.
Login now