|
104 | 104 | my $usage =
|
105 | 105 | "Usage: git cvsserver [options] [pserver|server] [<directory> ...]\n".
|
106 | 106 | " --base-path <path> : Prepend to requested CVSROOT\n".
|
| 107 | + " Can be read from GIT_CVSSERVER_BASE_PATH\n". |
107 | 108 | " --strict-paths : Don't allow recursing into subdirectories\n".
|
108 | 109 | " --export-all : Don't check for gitcvs.enabled in config\n".
|
109 | 110 | " --version, -V : Print version information and exit\n".
|
110 | 111 | " --help, -h, -H : Print usage information and exit\n".
|
111 | 112 | "\n".
|
112 | 113 | "<directory> ... is a list of allowed directories. If no directories\n".
|
113 | 114 | "are given, all are allowed. This is an additional restriction, gitcvs\n".
|
114 |
| - "access still needs to be enabled by the gitcvs.enabled config option.\n"; |
| 115 | + "access still needs to be enabled by the gitcvs.enabled config option.\n". |
| 116 | + "Alternately, one directory may be specified in GIT_CVSSERVER_ROOT.\n"; |
115 | 117 |
|
116 | 118 | my @opts = ( 'help|h|H', 'version|V',
|
117 | 119 | 'base-path=s', 'strict-paths', 'export-all' );
|
|
148 | 150 | die "--export-all can only be used together with an explicit whitelist\n";
|
149 | 151 | }
|
150 | 152 |
|
| 153 | +# Environment handling for running under git-shell |
| 154 | +if (exists $ENV{GIT_CVSSERVER_BASE_PATH}) { |
| 155 | + if ($state->{'base-path'}) { |
| 156 | + die "Cannot specify base path both ways.\n"; |
| 157 | + } |
| 158 | + my $base_path = $ENV{GIT_CVSSERVER_BASE_PATH}; |
| 159 | + $state->{'base-path'} = $base_path; |
| 160 | + $log->debug("Picked up base path '$base_path' from environment.\n"); |
| 161 | +} |
| 162 | +if (exists $ENV{GIT_CVSSERVER_ROOT}) { |
| 163 | + if (@{$state->{allowed_roots}}) { |
| 164 | + die "Cannot specify roots both ways: @ARGV\n"; |
| 165 | + } |
| 166 | + my $allowed_root = $ENV{GIT_CVSSERVER_ROOT}; |
| 167 | + $state->{allowed_roots} = [ $allowed_root ]; |
| 168 | + $log->debug("Picked up allowed root '$allowed_root' from environment.\n"); |
| 169 | +} |
| 170 | + |
151 | 171 | # if we are called with a pserver argument,
|
152 | 172 | # deal with the authentication cat before entering the
|
153 | 173 | # main loop
|
|
0 commit comments