diff options
author | Sitaram Chamarty <sitaram@atc.tcs.com> | 2012-01-26 06:12:15 +0530 |
---|---|---|
committer | Sitaram Chamarty <sitaram@atc.tcs.com> | 2012-01-26 07:29:03 +0530 |
commit | c59bf169426f34af4e5bd36e0b98925f253c24b1 (patch) | |
tree | 99b67918709a47987a710ea1745f854d1f62efcc | |
parent | (doc) move NAME/ details from example.conf to doc/gitolite.conf.mkd (diff) | |
download | gitolite-gentoo-c59bf169426f34af4e5bd36e0b98925f253c24b1.tar.gz gitolite-gentoo-c59bf169426f34af4e5bd36e0b98925f253c24b1.tar.bz2 gitolite-gentoo-c59bf169426f34af4e5bd36e0b98925f253c24b1.zip |
(minor) validate all role names, not just the first line!
If you use a role name that was not in GL_WILDREPOS_PERM_CATS, it will
get caught later when someone whom youhave given that role tries to
access the repo (look for another occurrence of the same error message
as this one).
So there's no access violation but it would be nice to be told upfront
that it won't work.
-rw-r--r-- | src/gitolite.pm | 2 | ||||
-rw-r--r-- | t/t63-perm-cats | 20 | ||||
-rwxr-xr-x | t/test-driver.sh | 2 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/gitolite.pm b/src/gitolite.pm index 011fb6f..a806aa5 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -400,7 +400,7 @@ sub get_set_perms # convert R and RW to the actual category names in the config file $perms =~ s/^\s*R /READERS /mg; $perms =~ s/^\s*RW /WRITERS /mg; - for my $g ($perms =~ /^\s*(\S+)/g) { + for my $g ($perms =~ /^\s*(\S+)/gm) { die "invalid permission category $g\n" unless $GL_WILDREPOS_PERM_CATS =~ /(^|\s)$g(\s|$)/; } print "New perms are:\n"; diff --git a/t/t63-perm-cats b/t/t63-perm-cats index 3565bfa..a928b50 100644 --- a/t/t63-perm-cats +++ b/t/t63-perm-cats @@ -1,5 +1,6 @@ -# vim: syn=sh: +# vim: ft=sh: # test gl-perms categories +tsh pwd || die '## tsh not installed?' for bc in 0 1 do @@ -111,15 +112,20 @@ do expect "W access for foo/u1/u1r1 DENIED to u2" name "add invalid category MANAGERS" - echo MANAGERS u2 | runlocal ssh u1 setperms foo/u1/u1r1 - expect "invalid permission category MANAGERS" + tsh " + ( echo READERS u6\; echo MANAGERS u2 ) | ssh u1 setperms foo/u1/u1r1; + !ok; /invalid permission category MANAGERS/ + " name "add u2 to now valid MANAGERS" echo "\$GL_WILDREPOS_PERM_CATS = 'READERS WRITERS MANAGERS';" | addrc - echo MANAGERS u2 | runlocal ssh u1 setperms foo/u1/u1r1 - notexpect "invalid permission category MANAGERS" - expect "New perms are:" - expect "MANAGERS u2" + tsh " + ( echo READERS u6\; echo MANAGERS u2 ) | ssh u1 setperms foo/u1/u1r1; + ok; !/invalid permission category MANAGERS/ + /New perms are:/ + /READERS u6/ + /MANAGERS u2/ + " runlocal git fetch runlocal git reset --hard origin/master diff --git a/t/test-driver.sh b/t/test-driver.sh index 5accdff..926ba2f 100755 --- a/t/test-driver.sh +++ b/t/test-driver.sh @@ -162,4 +162,4 @@ do done # this keeps changing as we add tests -echo 1..3157 +echo 1..3163 |