1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-07 08:26:10 +02:00

Merge branch 'pm/cvs-environ'

* pm/cvs-environ:
  CVS Server: Support reading base and roots from environment
This commit is contained in:
Junio C Hamano 2010-01-10 08:52:37 -08:00
commit df248216fd
2 changed files with 36 additions and 1 deletions

View File

@ -277,6 +277,21 @@ In `dbdriver` and `dbuser` you can use the following variables:
If no name can be determined, the If no name can be determined, the
numeric uid is used. numeric uid is used.
ENVIRONMENT
-----------
These variables obviate the need for command-line options in some
circumstances, allowing easier restricted usage through git-shell.
GIT_CVSSERVER_BASE_PATH takes the place of the argument to --base-path.
GIT_CVSSERVER_ROOT specifies a single-directory whitelist. The
repository must still be configured to allow access through
git-cvsserver, as described above.
When these environment variables are set, the corresponding
command-line arguments may not be used.
Eclipse CVS Client Notes Eclipse CVS Client Notes
------------------------ ------------------------

View File

@ -104,6 +104,7 @@
my $usage = my $usage =
"Usage: git cvsserver [options] [pserver|server] [<directory> ...]\n". "Usage: git cvsserver [options] [pserver|server] [<directory> ...]\n".
" --base-path <path> : Prepend to requested CVSROOT\n". " --base-path <path> : Prepend to requested CVSROOT\n".
" Can be read from GIT_CVSSERVER_BASE_PATH\n".
" --strict-paths : Don't allow recursing into subdirectories\n". " --strict-paths : Don't allow recursing into subdirectories\n".
" --export-all : Don't check for gitcvs.enabled in config\n". " --export-all : Don't check for gitcvs.enabled in config\n".
" --version, -V : Print version information and exit\n". " --version, -V : Print version information and exit\n".
@ -111,7 +112,8 @@
"\n". "\n".
"<directory> ... is a list of allowed directories. If no directories\n". "<directory> ... is a list of allowed directories. If no directories\n".
"are given, all are allowed. This is an additional restriction, gitcvs\n". "are given, all are allowed. This is an additional restriction, gitcvs\n".
"access still needs to be enabled by the gitcvs.enabled config option.\n"; "access still needs to be enabled by the gitcvs.enabled config option.\n".
"Alternately, one directory may be specified in GIT_CVSSERVER_ROOT.\n";
my @opts = ( 'help|h|H', 'version|V', my @opts = ( 'help|h|H', 'version|V',
'base-path=s', 'strict-paths', 'export-all' ); 'base-path=s', 'strict-paths', 'export-all' );
@ -148,6 +150,24 @@
die "--export-all can only be used together with an explicit whitelist\n"; die "--export-all can only be used together with an explicit whitelist\n";
} }
# Environment handling for running under git-shell
if (exists $ENV{GIT_CVSSERVER_BASE_PATH}) {
if ($state->{'base-path'}) {
die "Cannot specify base path both ways.\n";
}
my $base_path = $ENV{GIT_CVSSERVER_BASE_PATH};
$state->{'base-path'} = $base_path;
$log->debug("Picked up base path '$base_path' from environment.\n");
}
if (exists $ENV{GIT_CVSSERVER_ROOT}) {
if (@{$state->{allowed_roots}}) {
die "Cannot specify roots both ways: @ARGV\n";
}
my $allowed_root = $ENV{GIT_CVSSERVER_ROOT};
$state->{allowed_roots} = [ $allowed_root ];
$log->debug("Picked up allowed root '$allowed_root' from environment.\n");
}
# if we are called with a pserver argument, # if we are called with a pserver argument,
# deal with the authentication cat before entering the # deal with the authentication cat before entering the
# main loop # main loop