@matheusbsbs / matheus-bagliano / commits / b2741f63d4
Fork 0

Have git-cvsserver call hooks/update before really altering the ref

git-cvsserver is analogous to git-receive-pack; a checking from a cvs client to a central server is like a git-push from a working repository. Therefore it's nice to use the same access control (and email sending) that a receive-pack would perform. This patch tests for an executable update hook; if it is it is run with the ref being updated and the old and new hashes as normal. If the update hook returns an error code the update is aborted and the ref is never updated. The cvsserver returns "error 1" to the client to signal there was an EPERM error. Signed-off-by: Andy Parkins <andyparkins@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Andy Parkins committed Feb 13, 2007 at 15:12 UTC b2741f63d43a17ce9dafd1f97614bd6dbba72887
1 file changed +15
git-cvsserver.perl
+15
@@ -1171,6 +1171,21 @@ sub req_ci
1171 exit;
1172 }
1173
1174 + # Check that this is allowed, just as we would with a receive-pack
1175 + my @cmd = ( $ENV{GIT_DIR}.'hooks/update', "refs/heads/$state->{module}",
1176 + $parenthash, $commithash );
1177 + if( -x $cmd[0] ) {
1178 + unless( system( @cmd ) == 0 )
1179 + {
1180 + $log->warn("Commit failed (update hook declined to update ref)");
1181 + print "error 1 Commit failed (update hook declined)\n";
1182 + close LOCKFILE;
1183 + unlink($lockfile);
1184 + chdir "/";
1185 + exit;
1186 + }
1187 + }
1188 +
1189 print LOCKFILE $commithash;
1190
1191 $updater->update();