@matheusbsbs / matheus-bagliano / commits / 226bccb9ad
Fork 0

cvsserver: Actually implement --export-all

Embarrassing bug number two in my options patch. Also enforce that --export-all is only ever used together with an explicit whitelist. Otherwise people might export every git repository on the whole system without realising. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Frank Lichtenheld committed Jun 15, 2007 at 03:01 UTC 226bccb9ad42441269507a2101b47424d7c9c477
3 files changed +25 -2
Documentation/git-cvsserver.txt
+2 -1
@@ -38,7 +38,8 @@ Prepend 'path' to requested CVSROOT
38 Don't allow recursing into subdirectories
39
40 --export-all::
41 -Don't check for `gitcvs.enabled` in config
41 +Don't check for `gitcvs.enabled` in config. You also have to specify a list
42 +of allowed directories (see below) if you want to use this option.
43
44 --version, -V::
45 Print version information and exit
git-cvsserver.perl
+7 -1
@@ -130,6 +130,11 @@ if (@ARGV) {
130 # everything else is a directory
131 $state->{allowed_roots} = [ @ARGV ];
132
133 +# don't export the whole system unless the users requests it
134 +if ($state->{'export-all'} && !@{$state->{allowed_roots}}) {
135 + die "--export-all can only be used together with an explicit whitelist\n";
136 +}
137 +
138 # if we are called with a pserver argument,
139 # deal with the authentication cat before entering the
140 # main loop
@@ -276,7 +281,8 @@ sub req_Root
281
282 my $enabled = ($cfg->{gitcvs}{$state->{method}}{enabled}
283 || $cfg->{gitcvs}{enabled});
279 - unless ($enabled && $enabled =~ /^\s*(1|true|yes)\s*$/i) {
284 + unless ($state->{'export-all'} ||
285 + ($enabled && $enabled =~ /^\s*(1|true|yes)\s*$/i)) {
286 print "E GITCVS emulation needs to be enabled on this repo\n";
287 print "E the repo config file needs a [gitcvs] section added, and the parameter 'enabled' set to 1\n";
288 print "E \n";
t/t9400-git-cvsserver-server.sh
+16
@@ -173,6 +173,22 @@ test_expect_success 'req_Root (base-path)' \
173 test_expect_failure 'req_Root failure (base-path)' \
174 'cat request-anonymous | git-cvsserver --strict-paths --base-path $WORKDIR pserver $SERVERDIR >log 2>&1'
175
176 +GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1
177 +
178 +test_expect_success 'req_Root (export-all)' \
179 + 'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 &&
180 + tail -n1 log | grep -q "^I LOVE YOU$"'
181 +
182 +test_expect_failure 'req_Root failure (export-all w/o whitelist)' \
183 + 'cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1
184 + || false'
185 +
186 +test_expect_success 'req_Root (everything together)' \
187 + 'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 &&
188 + tail -n1 log | grep -q "^I LOVE YOU$"'
189 +
190 +GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1
191 +
192 #--------------
193 # CONFIG TESTS
194 #--------------