##// END OF EJS Templates
use ui.readsections in the acl extension
Alexis S. L. Carvalho -
r3436:f29989e9 default
parent child Browse files
Show More
@@ -1,124 +1,124
1 # acl.py - changeset access control for mercurial
1 # acl.py - changeset access control for mercurial
2 #
2 #
3 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
3 # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com>
4 #
4 #
5 # This software may be used and distributed according to the terms
5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7 #
7 #
8 # this hook allows to allow or deny access to parts of a repo when
8 # this hook allows to allow or deny access to parts of a repo when
9 # taking incoming changesets.
9 # taking incoming changesets.
10 #
10 #
11 # authorization is against local user name on system where hook is
11 # authorization is against local user name on system where hook is
12 # run, not committer of original changeset (since that is easy to
12 # run, not committer of original changeset (since that is easy to
13 # spoof).
13 # spoof).
14 #
14 #
15 # acl hook is best to use if you use hgsh to set up restricted shells
15 # acl hook is best to use if you use hgsh to set up restricted shells
16 # for authenticated users to only push to / pull from. not safe if
16 # for authenticated users to only push to / pull from. not safe if
17 # user has interactive shell access, because they can disable hook.
17 # user has interactive shell access, because they can disable hook.
18 # also not safe if remote users share one local account, because then
18 # also not safe if remote users share one local account, because then
19 # no way to tell remote users apart.
19 # no way to tell remote users apart.
20 #
20 #
21 # to use, configure acl extension in hgrc like this:
21 # to use, configure acl extension in hgrc like this:
22 #
22 #
23 # [extensions]
23 # [extensions]
24 # hgext.acl =
24 # hgext.acl =
25 #
25 #
26 # [hooks]
26 # [hooks]
27 # pretxnchangegroup.acl = python:hgext.acl.hook
27 # pretxnchangegroup.acl = python:hgext.acl.hook
28 #
28 #
29 # [acl]
29 # [acl]
30 # sources = serve # check if source of incoming changes in this list
30 # sources = serve # check if source of incoming changes in this list
31 # # ("serve" == ssh or http, "push", "pull", "bundle")
31 # # ("serve" == ssh or http, "push", "pull", "bundle")
32 #
32 #
33 # allow and deny lists have subtree pattern (default syntax is glob)
33 # allow and deny lists have subtree pattern (default syntax is glob)
34 # on left, user names on right. deny list checked before allow list.
34 # on left, user names on right. deny list checked before allow list.
35 #
35 #
36 # [acl.allow]
36 # [acl.allow]
37 # # if acl.allow not present, all users allowed by default
37 # # if acl.allow not present, all users allowed by default
38 # # empty acl.allow = no users allowed
38 # # empty acl.allow = no users allowed
39 # docs/** = doc_writer
39 # docs/** = doc_writer
40 # .hgtags = release_engineer
40 # .hgtags = release_engineer
41 #
41 #
42 # [acl.deny]
42 # [acl.deny]
43 # # if acl.deny not present, no users denied by default
43 # # if acl.deny not present, no users denied by default
44 # # empty acl.deny = all users allowed
44 # # empty acl.deny = all users allowed
45 # glob pattern = user4, user5
45 # glob pattern = user4, user5
46 # ** = user6
46 # ** = user6
47
47
48 from mercurial.demandload import *
48 from mercurial.demandload import *
49 from mercurial.i18n import gettext as _
49 from mercurial.i18n import gettext as _
50 from mercurial.node import *
50 from mercurial.node import *
51 demandload(globals(), 'getpass mercurial:util')
51 demandload(globals(), 'getpass mercurial:util')
52
52
53 class checker(object):
53 class checker(object):
54 '''acl checker.'''
54 '''acl checker.'''
55
55
56 def buildmatch(self, key):
56 def buildmatch(self, key):
57 '''return tuple of (match function, list enabled).'''
57 '''return tuple of (match function, list enabled).'''
58 if not self.ui.has_config(key):
58 if not self.ui.has_config(key):
59 self.ui.debug(_('acl: %s not enabled\n') % key)
59 self.ui.debug(_('acl: %s not enabled\n') % key)
60 return None, False
60 return None, False
61
61
62 thisuser = self.getuser()
62 thisuser = self.getuser()
63 pats = [pat for pat, users in self.ui.configitems(key)
63 pats = [pat for pat, users in self.ui.configitems(key)
64 if thisuser in users.replace(',', ' ').split()]
64 if thisuser in users.replace(',', ' ').split()]
65 self.ui.debug(_('acl: %s enabled, %d entries for user %s\n') %
65 self.ui.debug(_('acl: %s enabled, %d entries for user %s\n') %
66 (key, len(pats), thisuser))
66 (key, len(pats), thisuser))
67 if pats:
67 if pats:
68 match = util.matcher(self.repo.root, names=pats)[1]
68 match = util.matcher(self.repo.root, names=pats)[1]
69 else:
69 else:
70 match = util.never
70 match = util.never
71 return match, True
71 return match, True
72
72
73 def getuser(self):
73 def getuser(self):
74 '''return name of authenticated user.'''
74 '''return name of authenticated user.'''
75 return self.user
75 return self.user
76
76
77 def __init__(self, ui, repo):
77 def __init__(self, ui, repo):
78 self.ui = ui
78 self.ui = ui
79 self.repo = repo
79 self.repo = repo
80 self.user = getpass.getuser()
80 self.user = getpass.getuser()
81 cfg = self.ui.config('acl', 'config')
81 cfg = self.ui.config('acl', 'config')
82 if cfg:
82 if cfg:
83 self.ui.readconfig(cfg)
83 self.ui.readsections(cfg, 'acl.allow', 'acl.deny')
84 self.allow, self.allowable = self.buildmatch('acl.allow')
84 self.allow, self.allowable = self.buildmatch('acl.allow')
85 self.deny, self.deniable = self.buildmatch('acl.deny')
85 self.deny, self.deniable = self.buildmatch('acl.deny')
86
86
87 def skipsource(self, source):
87 def skipsource(self, source):
88 '''true if incoming changes from this source should be skipped.'''
88 '''true if incoming changes from this source should be skipped.'''
89 ok_sources = self.ui.config('acl', 'sources', 'serve').split()
89 ok_sources = self.ui.config('acl', 'sources', 'serve').split()
90 return source not in ok_sources
90 return source not in ok_sources
91
91
92 def check(self, node):
92 def check(self, node):
93 '''return if access allowed, raise exception if not.'''
93 '''return if access allowed, raise exception if not.'''
94 files = self.repo.changelog.read(node)[3]
94 files = self.repo.changelog.read(node)[3]
95 if self.deniable:
95 if self.deniable:
96 for f in files:
96 for f in files:
97 if self.deny(f):
97 if self.deny(f):
98 self.ui.debug(_('acl: user %s denied on %s\n') %
98 self.ui.debug(_('acl: user %s denied on %s\n') %
99 (self.getuser(), f))
99 (self.getuser(), f))
100 raise util.Abort(_('acl: access denied for changeset %s') %
100 raise util.Abort(_('acl: access denied for changeset %s') %
101 short(node))
101 short(node))
102 if self.allowable:
102 if self.allowable:
103 for f in files:
103 for f in files:
104 if not self.allow(f):
104 if not self.allow(f):
105 self.ui.debug(_('acl: user %s not allowed on %s\n') %
105 self.ui.debug(_('acl: user %s not allowed on %s\n') %
106 (self.getuser(), f))
106 (self.getuser(), f))
107 raise util.Abort(_('acl: access denied for changeset %s') %
107 raise util.Abort(_('acl: access denied for changeset %s') %
108 short(node))
108 short(node))
109 self.ui.debug(_('acl: allowing changeset %s\n') % short(node))
109 self.ui.debug(_('acl: allowing changeset %s\n') % short(node))
110
110
111 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
111 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
112 if hooktype != 'pretxnchangegroup':
112 if hooktype != 'pretxnchangegroup':
113 raise util.Abort(_('config error - hook type "%s" cannot stop '
113 raise util.Abort(_('config error - hook type "%s" cannot stop '
114 'incoming changesets') % hooktype)
114 'incoming changesets') % hooktype)
115
115
116 c = checker(ui, repo)
116 c = checker(ui, repo)
117 if c.skipsource(source):
117 if c.skipsource(source):
118 ui.debug(_('acl: changes have source "%s" - skipping\n') % source)
118 ui.debug(_('acl: changes have source "%s" - skipping\n') % source)
119 return
119 return
120
120
121 start = repo.changelog.rev(bin(node))
121 start = repo.changelog.rev(bin(node))
122 end = repo.changelog.count()
122 end = repo.changelog.count()
123 for rev in xrange(start, end):
123 for rev in xrange(start, end):
124 c.check(repo.changelog.node(rev))
124 c.check(repo.changelog.node(rev))
@@ -1,104 +1,109
1 #!/bin/sh
1 #!/bin/sh
2
2
3 do_push()
3 do_push()
4 {
4 {
5 user=$1
5 user=$1
6 shift
6 shift
7
7
8 echo "Pushing as user $user"
8 echo "Pushing as user $user"
9 echo 'hgrc = """'
9 echo 'hgrc = """'
10 sed -e 1,2d b/.hg/hgrc
10 sed -e 1,2d b/.hg/hgrc
11 echo '"""'
11 echo '"""'
12 if [ -e acl.config ]; then
12 if [ -e acl.config ]; then
13 echo 'acl.config = """'
13 echo 'acl.config = """'
14 cat acl.config
14 cat acl.config
15 echo '"""'
15 echo '"""'
16 fi
16 fi
17 LOGNAME=$user hg --cwd a --debug push ../b
17 LOGNAME=$user hg --cwd a --debug push ../b
18 hg --cwd b rollback
18 hg --cwd b rollback
19 hg --cwd b --quiet tip
19 hg --cwd b --quiet tip
20 echo
20 echo
21 }
21 }
22
22
23 hg init a
23 hg init a
24 cd a
24 cd a
25 mkdir foo foo/Bar quux
25 mkdir foo foo/Bar quux
26 echo 'in foo' > foo/file.txt
26 echo 'in foo' > foo/file.txt
27 echo 'in foo/Bar' > foo/Bar/file.txt
27 echo 'in foo/Bar' > foo/Bar/file.txt
28 echo 'in quux' > quux/file.py
28 echo 'in quux' > quux/file.py
29 hg add
29 hg add
30 hg ci -m 'add files' -d '1000000 0'
30 hg ci -m 'add files' -d '1000000 0'
31 echo >> foo/file.txt
31 echo >> foo/file.txt
32 hg ci -m 'change foo/file' -d '1000001 0'
32 hg ci -m 'change foo/file' -d '1000001 0'
33 echo >> foo/Bar/file.txt
33 echo >> foo/Bar/file.txt
34 hg ci -m 'change foo/Bar/file' -d '1000002 0'
34 hg ci -m 'change foo/Bar/file' -d '1000002 0'
35 echo >> quux/file.py
35 echo >> quux/file.py
36 hg ci -m 'change quux/file' -d '1000003 0'
36 hg ci -m 'change quux/file' -d '1000003 0'
37 hg tip --quiet
37 hg tip --quiet
38
38
39 cd ..
39 cd ..
40 hg clone -r 0 a b
40 hg clone -r 0 a b
41
41
42 echo '[extensions]' >> $HGRCPATH
42 echo '[extensions]' >> $HGRCPATH
43 echo 'hgext.acl =' >> $HGRCPATH
43 echo 'hgext.acl =' >> $HGRCPATH
44
44
45 config=b/.hg/hgrc
45 config=b/.hg/hgrc
46
46
47 echo
47 echo
48
48
49 echo 'Extension disabled for lack of a hook'
49 echo 'Extension disabled for lack of a hook'
50 do_push fred
50 do_push fred
51
51
52 echo '[hooks]' >> $config
52 echo '[hooks]' >> $config
53 echo 'pretxnchangegroup.acl = python:hgext.acl.hook' >> $config
53 echo 'pretxnchangegroup.acl = python:hgext.acl.hook' >> $config
54
54
55 echo 'Extension disabled for lack of acl.sources'
55 echo 'Extension disabled for lack of acl.sources'
56 do_push fred
56 do_push fred
57
57
58 echo 'No [acl.allow]/[acl.deny]'
58 echo 'No [acl.allow]/[acl.deny]'
59 echo '[acl]' >> $config
59 echo '[acl]' >> $config
60 echo 'sources = push' >> $config
60 echo 'sources = push' >> $config
61 do_push fred
61 do_push fred
62
62
63 echo 'Empty [acl.allow]'
63 echo 'Empty [acl.allow]'
64 echo '[acl.allow]' >> $config
64 echo '[acl.allow]' >> $config
65 do_push fred
65 do_push fred
66
66
67 echo 'fred is allowed inside foo/'
67 echo 'fred is allowed inside foo/'
68 echo 'foo/** = fred' >> $config
68 echo 'foo/** = fred' >> $config
69 do_push fred
69 do_push fred
70
70
71 echo 'Empty [acl.deny]'
71 echo 'Empty [acl.deny]'
72 echo '[acl.deny]' >> $config
72 echo '[acl.deny]' >> $config
73 do_push barney
73 do_push barney
74
74
75 echo 'fred is allowed inside foo/, but not foo/bar/ (case matters)'
75 echo 'fred is allowed inside foo/, but not foo/bar/ (case matters)'
76 echo 'foo/bar/** = fred' >> $config
76 echo 'foo/bar/** = fred' >> $config
77 do_push fred
77 do_push fred
78
78
79 echo 'fred is allowed inside foo/, but not foo/Bar/'
79 echo 'fred is allowed inside foo/, but not foo/Bar/'
80 echo 'foo/Bar/** = fred' >> $config
80 echo 'foo/Bar/** = fred' >> $config
81 do_push fred
81 do_push fred
82
82
83 echo 'barney is not mentioned => not allowed anywhere'
83 echo 'barney is not mentioned => not allowed anywhere'
84 do_push barney
84 do_push barney
85
85
86 echo 'barney is allowed everywhere'
86 echo 'barney is allowed everywhere'
87 echo '[acl.allow]' >> $config
87 echo '[acl.allow]' >> $config
88 echo '** = barney' >> $config
88 echo '** = barney' >> $config
89 do_push barney
89 do_push barney
90
90
91 echo 'wilma can change files with a .txt extension'
91 echo 'wilma can change files with a .txt extension'
92 echo '**/*.txt = wilma' >> $config
92 echo '**/*.txt = wilma' >> $config
93 do_push wilma
93 do_push wilma
94
94
95 echo 'file specified by acl.config does not exist'
95 echo 'file specified by acl.config does not exist'
96 echo '[acl]' >> $config
96 echo '[acl]' >> $config
97 echo 'config = ../acl.config' >> $config
97 echo 'config = ../acl.config' >> $config
98 do_push barney
98 do_push barney
99
99
100 echo 'betty is allowed inside foo/ by a acl.config file'
100 echo 'betty is allowed inside foo/ by a acl.config file'
101 echo '[acl.allow]' >> acl.config
101 echo '[acl.allow]' >> acl.config
102 echo 'foo/** = betty' >> acl.config
102 echo 'foo/** = betty' >> acl.config
103 do_push betty
103 do_push betty
104
104
105 echo 'acl.config can set only [acl.allow]/[acl.deny]'
106 echo '[hooks]' >> acl.config
107 echo 'changegroup.acl = false' >> acl.config
108 do_push barney
109
@@ -1,471 +1,517
1 adding foo/Bar/file.txt
1 adding foo/Bar/file.txt
2 adding foo/file.txt
2 adding foo/file.txt
3 adding quux/file.py
3 adding quux/file.py
4 3:911600dab2ae
4 3:911600dab2ae
5 requesting all changes
5 requesting all changes
6 adding changesets
6 adding changesets
7 adding manifests
7 adding manifests
8 adding file changes
8 adding file changes
9 added 1 changesets with 3 changes to 3 files
9 added 1 changesets with 3 changes to 3 files
10 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
10 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
11
11
12 Extension disabled for lack of a hook
12 Extension disabled for lack of a hook
13 Pushing as user fred
13 Pushing as user fred
14 hgrc = """
14 hgrc = """
15 """
15 """
16 pushing to ../b
16 pushing to ../b
17 searching for changes
17 searching for changes
18 common changesets up to 6675d58eff77
18 common changesets up to 6675d58eff77
19 adding changesets
19 adding changesets
20 add changeset ef1ea85a6374
20 add changeset ef1ea85a6374
21 add changeset f9cafe1212c8
21 add changeset f9cafe1212c8
22 add changeset 911600dab2ae
22 add changeset 911600dab2ae
23 adding manifests
23 adding manifests
24 adding file changes
24 adding file changes
25 adding foo/Bar/file.txt revisions
25 adding foo/Bar/file.txt revisions
26 adding foo/file.txt revisions
26 adding foo/file.txt revisions
27 adding quux/file.py revisions
27 adding quux/file.py revisions
28 added 3 changesets with 3 changes to 3 files
28 added 3 changesets with 3 changes to 3 files
29 rolling back last transaction
29 rolling back last transaction
30 0:6675d58eff77
30 0:6675d58eff77
31
31
32 Extension disabled for lack of acl.sources
32 Extension disabled for lack of acl.sources
33 Pushing as user fred
33 Pushing as user fred
34 hgrc = """
34 hgrc = """
35 [hooks]
35 [hooks]
36 pretxnchangegroup.acl = python:hgext.acl.hook
36 pretxnchangegroup.acl = python:hgext.acl.hook
37 """
37 """
38 pushing to ../b
38 pushing to ../b
39 searching for changes
39 searching for changes
40 common changesets up to 6675d58eff77
40 common changesets up to 6675d58eff77
41 adding changesets
41 adding changesets
42 add changeset ef1ea85a6374
42 add changeset ef1ea85a6374
43 add changeset f9cafe1212c8
43 add changeset f9cafe1212c8
44 add changeset 911600dab2ae
44 add changeset 911600dab2ae
45 adding manifests
45 adding manifests
46 adding file changes
46 adding file changes
47 adding foo/Bar/file.txt revisions
47 adding foo/Bar/file.txt revisions
48 adding foo/file.txt revisions
48 adding foo/file.txt revisions
49 adding quux/file.py revisions
49 adding quux/file.py revisions
50 added 3 changesets with 3 changes to 3 files
50 added 3 changesets with 3 changes to 3 files
51 calling hook pretxnchangegroup.acl: hgext.acl.hook
51 calling hook pretxnchangegroup.acl: hgext.acl.hook
52 acl: acl.allow not enabled
52 acl: acl.allow not enabled
53 acl: acl.deny not enabled
53 acl: acl.deny not enabled
54 acl: changes have source "push" - skipping
54 acl: changes have source "push" - skipping
55 rolling back last transaction
55 rolling back last transaction
56 0:6675d58eff77
56 0:6675d58eff77
57
57
58 No [acl.allow]/[acl.deny]
58 No [acl.allow]/[acl.deny]
59 Pushing as user fred
59 Pushing as user fred
60 hgrc = """
60 hgrc = """
61 [hooks]
61 [hooks]
62 pretxnchangegroup.acl = python:hgext.acl.hook
62 pretxnchangegroup.acl = python:hgext.acl.hook
63 [acl]
63 [acl]
64 sources = push
64 sources = push
65 """
65 """
66 pushing to ../b
66 pushing to ../b
67 searching for changes
67 searching for changes
68 common changesets up to 6675d58eff77
68 common changesets up to 6675d58eff77
69 adding changesets
69 adding changesets
70 add changeset ef1ea85a6374
70 add changeset ef1ea85a6374
71 add changeset f9cafe1212c8
71 add changeset f9cafe1212c8
72 add changeset 911600dab2ae
72 add changeset 911600dab2ae
73 adding manifests
73 adding manifests
74 adding file changes
74 adding file changes
75 adding foo/Bar/file.txt revisions
75 adding foo/Bar/file.txt revisions
76 adding foo/file.txt revisions
76 adding foo/file.txt revisions
77 adding quux/file.py revisions
77 adding quux/file.py revisions
78 added 3 changesets with 3 changes to 3 files
78 added 3 changesets with 3 changes to 3 files
79 calling hook pretxnchangegroup.acl: hgext.acl.hook
79 calling hook pretxnchangegroup.acl: hgext.acl.hook
80 acl: acl.allow not enabled
80 acl: acl.allow not enabled
81 acl: acl.deny not enabled
81 acl: acl.deny not enabled
82 acl: allowing changeset ef1ea85a6374
82 acl: allowing changeset ef1ea85a6374
83 acl: allowing changeset f9cafe1212c8
83 acl: allowing changeset f9cafe1212c8
84 acl: allowing changeset 911600dab2ae
84 acl: allowing changeset 911600dab2ae
85 rolling back last transaction
85 rolling back last transaction
86 0:6675d58eff77
86 0:6675d58eff77
87
87
88 Empty [acl.allow]
88 Empty [acl.allow]
89 Pushing as user fred
89 Pushing as user fred
90 hgrc = """
90 hgrc = """
91 [hooks]
91 [hooks]
92 pretxnchangegroup.acl = python:hgext.acl.hook
92 pretxnchangegroup.acl = python:hgext.acl.hook
93 [acl]
93 [acl]
94 sources = push
94 sources = push
95 [acl.allow]
95 [acl.allow]
96 """
96 """
97 pushing to ../b
97 pushing to ../b
98 searching for changes
98 searching for changes
99 common changesets up to 6675d58eff77
99 common changesets up to 6675d58eff77
100 adding changesets
100 adding changesets
101 add changeset ef1ea85a6374
101 add changeset ef1ea85a6374
102 add changeset f9cafe1212c8
102 add changeset f9cafe1212c8
103 add changeset 911600dab2ae
103 add changeset 911600dab2ae
104 adding manifests
104 adding manifests
105 adding file changes
105 adding file changes
106 adding foo/Bar/file.txt revisions
106 adding foo/Bar/file.txt revisions
107 adding foo/file.txt revisions
107 adding foo/file.txt revisions
108 adding quux/file.py revisions
108 adding quux/file.py revisions
109 added 3 changesets with 3 changes to 3 files
109 added 3 changesets with 3 changes to 3 files
110 calling hook pretxnchangegroup.acl: hgext.acl.hook
110 calling hook pretxnchangegroup.acl: hgext.acl.hook
111 acl: acl.allow enabled, 0 entries for user fred
111 acl: acl.allow enabled, 0 entries for user fred
112 acl: acl.deny not enabled
112 acl: acl.deny not enabled
113 acl: user fred not allowed on foo/file.txt
113 acl: user fred not allowed on foo/file.txt
114 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374
114 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374
115 abort: acl: access denied for changeset ef1ea85a6374
115 abort: acl: access denied for changeset ef1ea85a6374
116 transaction abort!
116 transaction abort!
117 rollback completed
117 rollback completed
118 no rollback information available
118 no rollback information available
119 0:6675d58eff77
119 0:6675d58eff77
120
120
121 fred is allowed inside foo/
121 fred is allowed inside foo/
122 Pushing as user fred
122 Pushing as user fred
123 hgrc = """
123 hgrc = """
124 [hooks]
124 [hooks]
125 pretxnchangegroup.acl = python:hgext.acl.hook
125 pretxnchangegroup.acl = python:hgext.acl.hook
126 [acl]
126 [acl]
127 sources = push
127 sources = push
128 [acl.allow]
128 [acl.allow]
129 foo/** = fred
129 foo/** = fred
130 """
130 """
131 pushing to ../b
131 pushing to ../b
132 searching for changes
132 searching for changes
133 common changesets up to 6675d58eff77
133 common changesets up to 6675d58eff77
134 adding changesets
134 adding changesets
135 add changeset ef1ea85a6374
135 add changeset ef1ea85a6374
136 add changeset f9cafe1212c8
136 add changeset f9cafe1212c8
137 add changeset 911600dab2ae
137 add changeset 911600dab2ae
138 adding manifests
138 adding manifests
139 adding file changes
139 adding file changes
140 adding foo/Bar/file.txt revisions
140 adding foo/Bar/file.txt revisions
141 adding foo/file.txt revisions
141 adding foo/file.txt revisions
142 adding quux/file.py revisions
142 adding quux/file.py revisions
143 added 3 changesets with 3 changes to 3 files
143 added 3 changesets with 3 changes to 3 files
144 calling hook pretxnchangegroup.acl: hgext.acl.hook
144 calling hook pretxnchangegroup.acl: hgext.acl.hook
145 acl: acl.allow enabled, 1 entries for user fred
145 acl: acl.allow enabled, 1 entries for user fred
146 acl: acl.deny not enabled
146 acl: acl.deny not enabled
147 acl: allowing changeset ef1ea85a6374
147 acl: allowing changeset ef1ea85a6374
148 acl: allowing changeset f9cafe1212c8
148 acl: allowing changeset f9cafe1212c8
149 acl: user fred not allowed on quux/file.py
149 acl: user fred not allowed on quux/file.py
150 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae
150 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae
151 abort: acl: access denied for changeset 911600dab2ae
151 abort: acl: access denied for changeset 911600dab2ae
152 transaction abort!
152 transaction abort!
153 rollback completed
153 rollback completed
154 no rollback information available
154 no rollback information available
155 0:6675d58eff77
155 0:6675d58eff77
156
156
157 Empty [acl.deny]
157 Empty [acl.deny]
158 Pushing as user barney
158 Pushing as user barney
159 hgrc = """
159 hgrc = """
160 [hooks]
160 [hooks]
161 pretxnchangegroup.acl = python:hgext.acl.hook
161 pretxnchangegroup.acl = python:hgext.acl.hook
162 [acl]
162 [acl]
163 sources = push
163 sources = push
164 [acl.allow]
164 [acl.allow]
165 foo/** = fred
165 foo/** = fred
166 [acl.deny]
166 [acl.deny]
167 """
167 """
168 pushing to ../b
168 pushing to ../b
169 searching for changes
169 searching for changes
170 common changesets up to 6675d58eff77
170 common changesets up to 6675d58eff77
171 adding changesets
171 adding changesets
172 add changeset ef1ea85a6374
172 add changeset ef1ea85a6374
173 add changeset f9cafe1212c8
173 add changeset f9cafe1212c8
174 add changeset 911600dab2ae
174 add changeset 911600dab2ae
175 adding manifests
175 adding manifests
176 adding file changes
176 adding file changes
177 adding foo/Bar/file.txt revisions
177 adding foo/Bar/file.txt revisions
178 adding foo/file.txt revisions
178 adding foo/file.txt revisions
179 adding quux/file.py revisions
179 adding quux/file.py revisions
180 added 3 changesets with 3 changes to 3 files
180 added 3 changesets with 3 changes to 3 files
181 calling hook pretxnchangegroup.acl: hgext.acl.hook
181 calling hook pretxnchangegroup.acl: hgext.acl.hook
182 acl: acl.allow enabled, 0 entries for user barney
182 acl: acl.allow enabled, 0 entries for user barney
183 acl: acl.deny enabled, 0 entries for user barney
183 acl: acl.deny enabled, 0 entries for user barney
184 acl: user barney not allowed on foo/file.txt
184 acl: user barney not allowed on foo/file.txt
185 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374
185 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374
186 abort: acl: access denied for changeset ef1ea85a6374
186 abort: acl: access denied for changeset ef1ea85a6374
187 transaction abort!
187 transaction abort!
188 rollback completed
188 rollback completed
189 no rollback information available
189 no rollback information available
190 0:6675d58eff77
190 0:6675d58eff77
191
191
192 fred is allowed inside foo/, but not foo/bar/ (case matters)
192 fred is allowed inside foo/, but not foo/bar/ (case matters)
193 Pushing as user fred
193 Pushing as user fred
194 hgrc = """
194 hgrc = """
195 [hooks]
195 [hooks]
196 pretxnchangegroup.acl = python:hgext.acl.hook
196 pretxnchangegroup.acl = python:hgext.acl.hook
197 [acl]
197 [acl]
198 sources = push
198 sources = push
199 [acl.allow]
199 [acl.allow]
200 foo/** = fred
200 foo/** = fred
201 [acl.deny]
201 [acl.deny]
202 foo/bar/** = fred
202 foo/bar/** = fred
203 """
203 """
204 pushing to ../b
204 pushing to ../b
205 searching for changes
205 searching for changes
206 common changesets up to 6675d58eff77
206 common changesets up to 6675d58eff77
207 adding changesets
207 adding changesets
208 add changeset ef1ea85a6374
208 add changeset ef1ea85a6374
209 add changeset f9cafe1212c8
209 add changeset f9cafe1212c8
210 add changeset 911600dab2ae
210 add changeset 911600dab2ae
211 adding manifests
211 adding manifests
212 adding file changes
212 adding file changes
213 adding foo/Bar/file.txt revisions
213 adding foo/Bar/file.txt revisions
214 adding foo/file.txt revisions
214 adding foo/file.txt revisions
215 adding quux/file.py revisions
215 adding quux/file.py revisions
216 added 3 changesets with 3 changes to 3 files
216 added 3 changesets with 3 changes to 3 files
217 calling hook pretxnchangegroup.acl: hgext.acl.hook
217 calling hook pretxnchangegroup.acl: hgext.acl.hook
218 acl: acl.allow enabled, 1 entries for user fred
218 acl: acl.allow enabled, 1 entries for user fred
219 acl: acl.deny enabled, 1 entries for user fred
219 acl: acl.deny enabled, 1 entries for user fred
220 acl: allowing changeset ef1ea85a6374
220 acl: allowing changeset ef1ea85a6374
221 acl: allowing changeset f9cafe1212c8
221 acl: allowing changeset f9cafe1212c8
222 acl: user fred not allowed on quux/file.py
222 acl: user fred not allowed on quux/file.py
223 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae
223 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae
224 abort: acl: access denied for changeset 911600dab2ae
224 abort: acl: access denied for changeset 911600dab2ae
225 transaction abort!
225 transaction abort!
226 rollback completed
226 rollback completed
227 no rollback information available
227 no rollback information available
228 0:6675d58eff77
228 0:6675d58eff77
229
229
230 fred is allowed inside foo/, but not foo/Bar/
230 fred is allowed inside foo/, but not foo/Bar/
231 Pushing as user fred
231 Pushing as user fred
232 hgrc = """
232 hgrc = """
233 [hooks]
233 [hooks]
234 pretxnchangegroup.acl = python:hgext.acl.hook
234 pretxnchangegroup.acl = python:hgext.acl.hook
235 [acl]
235 [acl]
236 sources = push
236 sources = push
237 [acl.allow]
237 [acl.allow]
238 foo/** = fred
238 foo/** = fred
239 [acl.deny]
239 [acl.deny]
240 foo/bar/** = fred
240 foo/bar/** = fred
241 foo/Bar/** = fred
241 foo/Bar/** = fred
242 """
242 """
243 pushing to ../b
243 pushing to ../b
244 searching for changes
244 searching for changes
245 common changesets up to 6675d58eff77
245 common changesets up to 6675d58eff77
246 adding changesets
246 adding changesets
247 add changeset ef1ea85a6374
247 add changeset ef1ea85a6374
248 add changeset f9cafe1212c8
248 add changeset f9cafe1212c8
249 add changeset 911600dab2ae
249 add changeset 911600dab2ae
250 adding manifests
250 adding manifests
251 adding file changes
251 adding file changes
252 adding foo/Bar/file.txt revisions
252 adding foo/Bar/file.txt revisions
253 adding foo/file.txt revisions
253 adding foo/file.txt revisions
254 adding quux/file.py revisions
254 adding quux/file.py revisions
255 added 3 changesets with 3 changes to 3 files
255 added 3 changesets with 3 changes to 3 files
256 calling hook pretxnchangegroup.acl: hgext.acl.hook
256 calling hook pretxnchangegroup.acl: hgext.acl.hook
257 acl: acl.allow enabled, 1 entries for user fred
257 acl: acl.allow enabled, 1 entries for user fred
258 acl: acl.deny enabled, 2 entries for user fred
258 acl: acl.deny enabled, 2 entries for user fred
259 acl: allowing changeset ef1ea85a6374
259 acl: allowing changeset ef1ea85a6374
260 acl: user fred denied on foo/Bar/file.txt
260 acl: user fred denied on foo/Bar/file.txt
261 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset f9cafe1212c8
261 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset f9cafe1212c8
262 abort: acl: access denied for changeset f9cafe1212c8
262 abort: acl: access denied for changeset f9cafe1212c8
263 transaction abort!
263 transaction abort!
264 rollback completed
264 rollback completed
265 no rollback information available
265 no rollback information available
266 0:6675d58eff77
266 0:6675d58eff77
267
267
268 barney is not mentioned => not allowed anywhere
268 barney is not mentioned => not allowed anywhere
269 Pushing as user barney
269 Pushing as user barney
270 hgrc = """
270 hgrc = """
271 [hooks]
271 [hooks]
272 pretxnchangegroup.acl = python:hgext.acl.hook
272 pretxnchangegroup.acl = python:hgext.acl.hook
273 [acl]
273 [acl]
274 sources = push
274 sources = push
275 [acl.allow]
275 [acl.allow]
276 foo/** = fred
276 foo/** = fred
277 [acl.deny]
277 [acl.deny]
278 foo/bar/** = fred
278 foo/bar/** = fred
279 foo/Bar/** = fred
279 foo/Bar/** = fred
280 """
280 """
281 pushing to ../b
281 pushing to ../b
282 searching for changes
282 searching for changes
283 common changesets up to 6675d58eff77
283 common changesets up to 6675d58eff77
284 adding changesets
284 adding changesets
285 add changeset ef1ea85a6374
285 add changeset ef1ea85a6374
286 add changeset f9cafe1212c8
286 add changeset f9cafe1212c8
287 add changeset 911600dab2ae
287 add changeset 911600dab2ae
288 adding manifests
288 adding manifests
289 adding file changes
289 adding file changes
290 adding foo/Bar/file.txt revisions
290 adding foo/Bar/file.txt revisions
291 adding foo/file.txt revisions
291 adding foo/file.txt revisions
292 adding quux/file.py revisions
292 adding quux/file.py revisions
293 added 3 changesets with 3 changes to 3 files
293 added 3 changesets with 3 changes to 3 files
294 calling hook pretxnchangegroup.acl: hgext.acl.hook
294 calling hook pretxnchangegroup.acl: hgext.acl.hook
295 acl: acl.allow enabled, 0 entries for user barney
295 acl: acl.allow enabled, 0 entries for user barney
296 acl: acl.deny enabled, 0 entries for user barney
296 acl: acl.deny enabled, 0 entries for user barney
297 acl: user barney not allowed on foo/file.txt
297 acl: user barney not allowed on foo/file.txt
298 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374
298 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset ef1ea85a6374
299 abort: acl: access denied for changeset ef1ea85a6374
299 abort: acl: access denied for changeset ef1ea85a6374
300 transaction abort!
300 transaction abort!
301 rollback completed
301 rollback completed
302 no rollback information available
302 no rollback information available
303 0:6675d58eff77
303 0:6675d58eff77
304
304
305 barney is allowed everywhere
305 barney is allowed everywhere
306 Pushing as user barney
306 Pushing as user barney
307 hgrc = """
307 hgrc = """
308 [hooks]
308 [hooks]
309 pretxnchangegroup.acl = python:hgext.acl.hook
309 pretxnchangegroup.acl = python:hgext.acl.hook
310 [acl]
310 [acl]
311 sources = push
311 sources = push
312 [acl.allow]
312 [acl.allow]
313 foo/** = fred
313 foo/** = fred
314 [acl.deny]
314 [acl.deny]
315 foo/bar/** = fred
315 foo/bar/** = fred
316 foo/Bar/** = fred
316 foo/Bar/** = fred
317 [acl.allow]
317 [acl.allow]
318 ** = barney
318 ** = barney
319 """
319 """
320 pushing to ../b
320 pushing to ../b
321 searching for changes
321 searching for changes
322 common changesets up to 6675d58eff77
322 common changesets up to 6675d58eff77
323 adding changesets
323 adding changesets
324 add changeset ef1ea85a6374
324 add changeset ef1ea85a6374
325 add changeset f9cafe1212c8
325 add changeset f9cafe1212c8
326 add changeset 911600dab2ae
326 add changeset 911600dab2ae
327 adding manifests
327 adding manifests
328 adding file changes
328 adding file changes
329 adding foo/Bar/file.txt revisions
329 adding foo/Bar/file.txt revisions
330 adding foo/file.txt revisions
330 adding foo/file.txt revisions
331 adding quux/file.py revisions
331 adding quux/file.py revisions
332 added 3 changesets with 3 changes to 3 files
332 added 3 changesets with 3 changes to 3 files
333 calling hook pretxnchangegroup.acl: hgext.acl.hook
333 calling hook pretxnchangegroup.acl: hgext.acl.hook
334 acl: acl.allow enabled, 1 entries for user barney
334 acl: acl.allow enabled, 1 entries for user barney
335 acl: acl.deny enabled, 0 entries for user barney
335 acl: acl.deny enabled, 0 entries for user barney
336 acl: allowing changeset ef1ea85a6374
336 acl: allowing changeset ef1ea85a6374
337 acl: allowing changeset f9cafe1212c8
337 acl: allowing changeset f9cafe1212c8
338 acl: allowing changeset 911600dab2ae
338 acl: allowing changeset 911600dab2ae
339 rolling back last transaction
339 rolling back last transaction
340 0:6675d58eff77
340 0:6675d58eff77
341
341
342 wilma can change files with a .txt extension
342 wilma can change files with a .txt extension
343 Pushing as user wilma
343 Pushing as user wilma
344 hgrc = """
344 hgrc = """
345 [hooks]
345 [hooks]
346 pretxnchangegroup.acl = python:hgext.acl.hook
346 pretxnchangegroup.acl = python:hgext.acl.hook
347 [acl]
347 [acl]
348 sources = push
348 sources = push
349 [acl.allow]
349 [acl.allow]
350 foo/** = fred
350 foo/** = fred
351 [acl.deny]
351 [acl.deny]
352 foo/bar/** = fred
352 foo/bar/** = fred
353 foo/Bar/** = fred
353 foo/Bar/** = fred
354 [acl.allow]
354 [acl.allow]
355 ** = barney
355 ** = barney
356 **/*.txt = wilma
356 **/*.txt = wilma
357 """
357 """
358 pushing to ../b
358 pushing to ../b
359 searching for changes
359 searching for changes
360 common changesets up to 6675d58eff77
360 common changesets up to 6675d58eff77
361 adding changesets
361 adding changesets
362 add changeset ef1ea85a6374
362 add changeset ef1ea85a6374
363 add changeset f9cafe1212c8
363 add changeset f9cafe1212c8
364 add changeset 911600dab2ae
364 add changeset 911600dab2ae
365 adding manifests
365 adding manifests
366 adding file changes
366 adding file changes
367 adding foo/Bar/file.txt revisions
367 adding foo/Bar/file.txt revisions
368 adding foo/file.txt revisions
368 adding foo/file.txt revisions
369 adding quux/file.py revisions
369 adding quux/file.py revisions
370 added 3 changesets with 3 changes to 3 files
370 added 3 changesets with 3 changes to 3 files
371 calling hook pretxnchangegroup.acl: hgext.acl.hook
371 calling hook pretxnchangegroup.acl: hgext.acl.hook
372 acl: acl.allow enabled, 1 entries for user wilma
372 acl: acl.allow enabled, 1 entries for user wilma
373 acl: acl.deny enabled, 0 entries for user wilma
373 acl: acl.deny enabled, 0 entries for user wilma
374 acl: allowing changeset ef1ea85a6374
374 acl: allowing changeset ef1ea85a6374
375 acl: allowing changeset f9cafe1212c8
375 acl: allowing changeset f9cafe1212c8
376 acl: user wilma not allowed on quux/file.py
376 acl: user wilma not allowed on quux/file.py
377 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae
377 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae
378 abort: acl: access denied for changeset 911600dab2ae
378 abort: acl: access denied for changeset 911600dab2ae
379 transaction abort!
379 transaction abort!
380 rollback completed
380 rollback completed
381 no rollback information available
381 no rollback information available
382 0:6675d58eff77
382 0:6675d58eff77
383
383
384 file specified by acl.config does not exist
384 file specified by acl.config does not exist
385 Pushing as user barney
385 Pushing as user barney
386 hgrc = """
386 hgrc = """
387 [hooks]
387 [hooks]
388 pretxnchangegroup.acl = python:hgext.acl.hook
388 pretxnchangegroup.acl = python:hgext.acl.hook
389 [acl]
389 [acl]
390 sources = push
390 sources = push
391 [acl.allow]
391 [acl.allow]
392 foo/** = fred
392 foo/** = fred
393 [acl.deny]
393 [acl.deny]
394 foo/bar/** = fred
394 foo/bar/** = fred
395 foo/Bar/** = fred
395 foo/Bar/** = fred
396 [acl.allow]
396 [acl.allow]
397 ** = barney
397 ** = barney
398 **/*.txt = wilma
398 **/*.txt = wilma
399 [acl]
399 [acl]
400 config = ../acl.config
400 config = ../acl.config
401 """
401 """
402 pushing to ../b
402 pushing to ../b
403 searching for changes
403 searching for changes
404 common changesets up to 6675d58eff77
404 common changesets up to 6675d58eff77
405 adding changesets
405 adding changesets
406 add changeset ef1ea85a6374
406 add changeset ef1ea85a6374
407 add changeset f9cafe1212c8
407 add changeset f9cafe1212c8
408 add changeset 911600dab2ae
408 add changeset 911600dab2ae
409 adding manifests
409 adding manifests
410 adding file changes
410 adding file changes
411 adding foo/Bar/file.txt revisions
411 adding foo/Bar/file.txt revisions
412 adding foo/file.txt revisions
412 adding foo/file.txt revisions
413 adding quux/file.py revisions
413 adding quux/file.py revisions
414 added 3 changesets with 3 changes to 3 files
414 added 3 changesets with 3 changes to 3 files
415 calling hook pretxnchangegroup.acl: hgext.acl.hook
415 calling hook pretxnchangegroup.acl: hgext.acl.hook
416 acl: acl.allow enabled, 1 entries for user barney
416 acl: acl.allow enabled, 1 entries for user barney
417 acl: acl.deny enabled, 0 entries for user barney
417 acl: acl.deny enabled, 0 entries for user barney
418 acl: allowing changeset ef1ea85a6374
418 acl: allowing changeset ef1ea85a6374
419 acl: allowing changeset f9cafe1212c8
419 acl: allowing changeset f9cafe1212c8
420 acl: allowing changeset 911600dab2ae
420 acl: allowing changeset 911600dab2ae
421 rolling back last transaction
421 rolling back last transaction
422 0:6675d58eff77
422 0:6675d58eff77
423
423
424 betty is allowed inside foo/ by a acl.config file
424 betty is allowed inside foo/ by a acl.config file
425 Pushing as user betty
425 Pushing as user betty
426 hgrc = """
426 hgrc = """
427 [hooks]
427 [hooks]
428 pretxnchangegroup.acl = python:hgext.acl.hook
428 pretxnchangegroup.acl = python:hgext.acl.hook
429 [acl]
429 [acl]
430 sources = push
430 sources = push
431 [acl.allow]
431 [acl.allow]
432 foo/** = fred
432 foo/** = fred
433 [acl.deny]
433 [acl.deny]
434 foo/bar/** = fred
434 foo/bar/** = fred
435 foo/Bar/** = fred
435 foo/Bar/** = fred
436 [acl.allow]
436 [acl.allow]
437 ** = barney
437 ** = barney
438 **/*.txt = wilma
438 **/*.txt = wilma
439 [acl]
439 [acl]
440 config = ../acl.config
440 config = ../acl.config
441 """
441 """
442 acl.config = """
442 acl.config = """
443 [acl.allow]
443 [acl.allow]
444 foo/** = betty
444 foo/** = betty
445 """
445 """
446 pushing to ../b
446 pushing to ../b
447 searching for changes
447 searching for changes
448 common changesets up to 6675d58eff77
448 common changesets up to 6675d58eff77
449 adding changesets
449 adding changesets
450 add changeset ef1ea85a6374
450 add changeset ef1ea85a6374
451 add changeset f9cafe1212c8
451 add changeset f9cafe1212c8
452 add changeset 911600dab2ae
452 add changeset 911600dab2ae
453 adding manifests
453 adding manifests
454 adding file changes
454 adding file changes
455 adding foo/Bar/file.txt revisions
455 adding foo/Bar/file.txt revisions
456 adding foo/file.txt revisions
456 adding foo/file.txt revisions
457 adding quux/file.py revisions
457 adding quux/file.py revisions
458 added 3 changesets with 3 changes to 3 files
458 added 3 changesets with 3 changes to 3 files
459 calling hook pretxnchangegroup.acl: hgext.acl.hook
459 calling hook pretxnchangegroup.acl: hgext.acl.hook
460 acl: acl.allow enabled, 1 entries for user betty
460 acl: acl.allow enabled, 1 entries for user betty
461 acl: acl.deny enabled, 0 entries for user betty
461 acl: acl.deny enabled, 0 entries for user betty
462 acl: allowing changeset ef1ea85a6374
462 acl: allowing changeset ef1ea85a6374
463 acl: allowing changeset f9cafe1212c8
463 acl: allowing changeset f9cafe1212c8
464 acl: user betty not allowed on quux/file.py
464 acl: user betty not allowed on quux/file.py
465 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae
465 error: pretxnchangegroup.acl hook failed: acl: access denied for changeset 911600dab2ae
466 abort: acl: access denied for changeset 911600dab2ae
466 abort: acl: access denied for changeset 911600dab2ae
467 transaction abort!
467 transaction abort!
468 rollback completed
468 rollback completed
469 no rollback information available
469 no rollback information available
470 0:6675d58eff77
470 0:6675d58eff77
471
471
472 acl.config can set only [acl.allow]/[acl.deny]
473 Pushing as user barney
474 hgrc = """
475 [hooks]
476 pretxnchangegroup.acl = python:hgext.acl.hook
477 [acl]
478 sources = push
479 [acl.allow]
480 foo/** = fred
481 [acl.deny]
482 foo/bar/** = fred
483 foo/Bar/** = fred
484 [acl.allow]
485 ** = barney
486 **/*.txt = wilma
487 [acl]
488 config = ../acl.config
489 """
490 acl.config = """
491 [acl.allow]
492 foo/** = betty
493 [hooks]
494 changegroup.acl = false
495 """
496 pushing to ../b
497 searching for changes
498 common changesets up to 6675d58eff77
499 adding changesets
500 add changeset ef1ea85a6374
501 add changeset f9cafe1212c8
502 add changeset 911600dab2ae
503 adding manifests
504 adding file changes
505 adding foo/Bar/file.txt revisions
506 adding foo/file.txt revisions
507 adding quux/file.py revisions
508 added 3 changesets with 3 changes to 3 files
509 calling hook pretxnchangegroup.acl: hgext.acl.hook
510 acl: acl.allow enabled, 1 entries for user barney
511 acl: acl.deny enabled, 0 entries for user barney
512 acl: allowing changeset ef1ea85a6374
513 acl: allowing changeset f9cafe1212c8
514 acl: allowing changeset 911600dab2ae
515 rolling back last transaction
516 0:6675d58eff77
517
General Comments 0
You need to be logged in to leave comments. Login now