Skip to content

Commit b59c060

Browse files
committed
Merge branch 'cb/cvsserver' into maint
"git cvsserver" had a long-standing bug in its authentication code, which has finally been corrected (it is unclear and is a separate question if anybody is seriously using it, though). * cb/cvsserver: Documentation: cleanup git-cvsserver git-cvsserver: protect against NULL in crypt(3) git-cvsserver: use crypt correctly to compare password hashes
2 parents c365967 + 4b81f69 commit b59c060

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

Documentation/git-cvsserver.txt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ looks like
9999

100100
------
101101

102-
Only anonymous access is provided by pserve by default. To commit you
102+
Only anonymous access is provided by pserver by default. To commit you
103103
will have to create pserver accounts, simply add a gitcvs.authdb
104104
setting in the config file of the repositories you want the cvsserver
105105
to allow writes to, for example:
@@ -114,21 +114,20 @@ The format of these files is username followed by the encrypted password,
114114
for example:
115115

116116
------
117-
myuser:$1Oyx5r9mdGZ2
118-
myuser:$1$BA)@$vbnMJMDym7tA32AamXrm./
117+
myuser:sqkNi8zPf01HI
118+
myuser:$1$9K7FzU28$VfF6EoPYCJEYcVQwATgOP/
119+
myuser:$5$.NqmNH1vwfzGpV8B$znZIcumu1tNLATgV2l6e1/mY8RzhUDHMOaVOeL1cxV3
119120
------
120121
You can use the 'htpasswd' facility that comes with Apache to make these
121-
files, but Apache's MD5 crypt method differs from the one used by most C
122-
library's crypt() function, so don't use the -m option.
122+
files, but only with the -d option (or -B if your system suports it).
123123

124-
Alternatively you can produce the password with perl's crypt() operator:
125-
-----
126-
perl -e 'my ($user, $pass) = @ARGV; printf "%s:%s\n", $user, crypt($user, $pass)' $USER password
127-
-----
124+
Preferably use the system specific utility that manages password hash
125+
creation in your platform (e.g. mkpasswd in Linux, encrypt in OpenBSD or
126+
pwhash in NetBSD) and paste it in the right location.
128127

129128
Then provide your password via the pserver method, for example:
130129
------
131-
cvs -d:pserver:someuser:somepassword <at> server/path/repo.git co <HEAD_name>
130+
cvs -d:pserver:someuser:somepassword@server:/path/repo.git co <HEAD_name>
132131
------
133132
No special setup is needed for SSH access, other than having Git tools
134133
in the PATH. If you have clients that do not accept the CVS_SERVER
@@ -138,7 +137,7 @@ Note: Newer CVS versions (>= 1.12.11) also support specifying
138137
CVS_SERVER directly in CVSROOT like
139138

140139
------
141-
cvs -d ":ext;CVS_SERVER=git cvsserver:user@server/path/repo.git" co <HEAD_name>
140+
cvs -d ":ext;CVS_SERVER=git cvsserver:user@server/path/repo.git" co <HEAD_name>
142141
------
143142
This has the advantage that it will be saved in your 'CVS/Root' files and
144143
you don't need to worry about always setting the correct environment
@@ -186,8 +185,8 @@ allowing access over SSH.
186185
+
187186
--
188187
------
189-
export CVSROOT=:ext:user@server:/var/git/project.git
190-
export CVS_SERVER="git cvsserver"
188+
export CVSROOT=:ext:user@server:/var/git/project.git
189+
export CVS_SERVER="git cvsserver"
191190
------
192191
--
193192
4. For SSH clients that will make commits, make sure their server-side
@@ -203,7 +202,7 @@ allowing access over SSH.
203202
`project-master` directory:
204203
+
205204
------
206-
cvs co -d project-master master
205+
cvs co -d project-master master
207206
------
208207

209208
[[dbbackend]]

git-cvsserver.perl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,11 @@
222222
open my $passwd, "<", $authdb or die $!;
223223
while (<$passwd>) {
224224
if (m{^\Q$user\E:(.*)}) {
225-
if (crypt($user, descramble($password)) eq $1) {
225+
my $hash = crypt(descramble($password), $1);
226+
if (defined $hash and $hash eq $1) {
226227
$auth_ok = 1;
227228
}
228-
};
229+
}
229230
}
230231
close $passwd;
231232

t/t9400-git-cvsserver-server.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ CVSWORK="$PWD/cvswork"
3636
CVS_SERVER=git-cvsserver
3737
export CVSROOT CVS_SERVER
3838

39+
if perl -e 'exit(1) if not defined crypt("", "cv")'
40+
then
41+
PWDHASH='lac2ItudM3.KM'
42+
else
43+
PWDHASH='$2b$10$t8fGvE/a9eLmfOLzsZme2uOa2QtoMYwIxq9wZA6aBKtF1Yb7FJIzi'
44+
fi
45+
3946
rm -rf "$CVSWORK" "$SERVERDIR"
4047
test_expect_success 'setup' '
4148
git config push.default matching &&
@@ -54,7 +61,7 @@ test_expect_success 'setup' '
5461
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
5562
GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" &&
5663
GIT_DIR="$SERVERDIR" git config gitcvs.authdb "$SERVERDIR/auth.db" &&
57-
echo cvsuser:cvGVEarMLnhlA > "$SERVERDIR/auth.db"
64+
echo "cvsuser:$PWDHASH" >"$SERVERDIR/auth.db"
5865
'
5966

6067
# note that cvs doesn't accept absolute pathnames

0 commit comments

Comments
 (0)