Skip to content

Commit 9a42c03

Browse files
peffgitster
authored andcommitted
shell: drop git-cvsserver support by default
The git-cvsserver script is old and largely unmaintained these days. But git-shell allows untrusted users to run it out of the box, significantly increasing its attack surface. Let's drop it from git-shell's list of internal handlers so that it cannot be run by default. This is not backwards compatible. But given the age and development activity on CVS-related parts of Git, this is likely to impact very few users, while helping many more (i.e., anybody who runs git-shell and had no intention of supporting CVS). There's no configuration mechanism in git-shell for us to add a boolean and flip it to "off". But there is a mechanism for adding custom commands, and adding CVS support here is fairly trivial. Let's document it to give guidance to anybody who really is still running cvsserver. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d4165b commit 9a42c03

File tree

3 files changed

+64
-14
lines changed

3 files changed

+64
-14
lines changed

Documentation/git-shell.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ EOF
7979
$ chmod +x $HOME/git-shell-commands/no-interactive-login
8080
----------------
8181

82+
To enable git-cvsserver access (which should generally have the
83+
`no-interactive-login` example above as a prerequisite, as creating
84+
the git-shell-commands directory allows interactive logins):
85+
86+
----------------
87+
$ cat >$HOME/git-shell-commands/cvs <<\EOF
88+
if ! test $# = 1 && test "$1" = "server"
89+
then
90+
echo >&2 "git-cvsserver only handles \"server\""
91+
exit 1
92+
fi
93+
exec git cvsserver server
94+
EOF
95+
$ chmod +x $HOME/git-shell-commands/cvs
96+
----------------
97+
8298
SEE ALSO
8399
--------
84100
ssh(1),

shell.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,6 @@ static int do_generic_cmd(const char *me, char *arg)
2525
return execv_git_cmd(my_argv);
2626
}
2727

28-
static int do_cvs_cmd(const char *me, char *arg)
29-
{
30-
const char *cvsserver_argv[3] = {
31-
"cvsserver", "server", NULL
32-
};
33-
34-
if (!arg || strcmp(arg, "server"))
35-
die("git-cvsserver only handles server: %s", arg);
36-
37-
setup_path();
38-
return execv_git_cmd(cvsserver_argv);
39-
}
40-
4128
static int is_valid_cmd_name(const char *cmd)
4229
{
4330
/* Test command contains no . or / characters */
@@ -134,7 +121,6 @@ static struct commands {
134121
{ "git-receive-pack", do_generic_cmd },
135122
{ "git-upload-pack", do_generic_cmd },
136123
{ "git-upload-archive", do_generic_cmd },
137-
{ "cvs", do_cvs_cmd },
138124
{ NULL },
139125
};
140126

t/t9400-git-cvsserver-server.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,4 +588,52 @@ test_expect_success 'cvs annotate' '
588588
test_cmp ../expect ../actual
589589
'
590590

591+
#------------
592+
# running via git-shell
593+
#------------
594+
595+
cd "$WORKDIR"
596+
597+
test_expect_success 'create remote-cvs helper' '
598+
write_script remote-cvs <<-\EOF
599+
exec git shell -c "cvs server"
600+
EOF
601+
'
602+
603+
test_expect_success 'cvs server does not run with vanilla git-shell' '
604+
(
605+
cd cvswork &&
606+
CVS_SERVER=$WORKDIR/remote-cvs &&
607+
export CVS_SERVER &&
608+
test_must_fail cvs log merge
609+
)
610+
'
611+
612+
test_expect_success 'configure git shell to run cvs server' '
613+
mkdir "$HOME"/git-shell-commands &&
614+
615+
write_script "$HOME"/git-shell-commands/cvs <<-\EOF &&
616+
if ! test $# = 1 && test "$1" = "server"
617+
then
618+
echo >&2 "git-cvsserver only handles \"server\""
619+
exit 1
620+
fi
621+
exec git cvsserver server
622+
EOF
623+
624+
# Should not be used, but part of the recommended setup
625+
write_script "$HOME"/git-shell-commands/no-interactive-login <<-\EOF
626+
echo Interactive login forbidden
627+
EOF
628+
'
629+
630+
test_expect_success 'cvs server can run with recommended config' '
631+
(
632+
cd cvswork &&
633+
CVS_SERVER=$WORKDIR/remote-cvs &&
634+
export CVS_SERVER &&
635+
cvs log merge
636+
)
637+
'
638+
591639
test_done

0 commit comments

Comments
 (0)