{"thread":{"id":"21690","subject":"[PATCH/resend] CVS Server: Support reading base and roots from environment","startedAt":"2009-11-20T16:05:44Z","lastAt":"2009-12-30T20:12:55Z","messageCount":7,"participants":["Phil Miller","Junio C Hamano","Nanako Shiraishi"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"128027","messageId":"81f018ac0911200805g55bd1607u651334c1ed7f1303@mail.gmail.com","threadId":"21690","inReplyTo":null,"subject":"[PATCH/resend] CVS Server: Support reading base and roots from environment","fromName":"Phil Miller","fromEmail":"mille121@illinois.edu","sentAt":"2009-11-20T16:05:44Z","receivedAt":"2009-11-20T16:05:44Z","isPatch":true,"sender":{"key":"mille121@illinois.edu","avatar":"https://avatars.githubusercontent.com/u/126464?v=4"},"body":"The Gitosis single-account Git/ssh hosting system runs git commands\nthrough git-shell after confirming that the connecting user is\nauthorized to access the requested repository. This works well for\nupload-pack and receive-pack, which take a repository argument through\ngit-shell. This doesn't work so well for `cvs server', which is passed\nthrough literally, with no arguments. Allowing arguments risks\nsneaking in `--export-all', so that restriction should be maintained.\n\nDespite that, passing a list of repository roots is necessary for\nper-user access control by the hosting software, and passing a base\npath improves usability without weakening security. Thus,\ngit-cvsserver needs to come up with these values at runtime by some\nother means. Since git-shell preserves the environment for other\npurposes, the environment can carry these arguments as well.\n\nThus, modify git-cvsserver to read $GIT_CVSSERVER_{BASE_PATH,ROOTS} in\nthe absence of equivalent command line arguments.\n\nSigned-off-by: Phil Miller <mille121@illinois.edu>\n---\n git-cvsserver.perl |   21 ++++++++++++++++++++-\n 1 files changed, 20 insertions(+), 1 deletions(-)\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex 6dc45f5..9e58d2a 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -104,6 +104,7 @@ $log->info(\"--------------- STARTING -----------------\");\n my $usage =\n     \"Usage: git cvsserver [options] [pserver|server] [<directory> ...]\\n\".\n     \"    --base-path <path>  : Prepend to requested CVSROOT\\n\".\n+    \"                          Can be read from GIT_CVSSERVER_BASE_PATH\\n\".\n     \"    --strict-paths      : Don't allow recursing into subdirectories\\n\".\n     \"    --export-all        : Don't check for gitcvs.enabled in config\\n\".\n     \"    --version, -V       : Print version information and exit\\n\".\n@@ -111,7 +112,8 @@ my $usage =\n     \"\\n\".\n     \"<directory> ... is a list of allowed directories. If no directories\\n\".\n     \"are given, all are allowed. This is an additional restriction, gitcvs\\n\".\n-    \"access still needs to be enabled by the gitcvs.enabled config option.\\n\";\n+    \"access still needs to be enabled by the gitcvs.enabled config option.\\n\".\n+    \"Alternately, these directories may be specified in\nGIT_CVSSERVER_ROOTS.\\n\";\n\n my @opts = ( 'help|h|H', 'version|V',\n \t     'base-path=s', 'strict-paths', 'export-all' );\n@@ -148,6 +150,23 @@ if ($state->{'export-all'} &&\n!@{$state->{allowed_roots}}) {\n     die \"--export-all can only be used together with an explicit whitelist\\n\";\n }\n\n+# Environment handling for running under git-shell\n+if ($ENV{GIT_CVSSERVER_BASE_PATH}) {\n+    if ($state->{'base-path'}) {\n+\tdie \"Cannot specify base path both ways.\\n\";\n+    }\n+    my $base_path = $ENV{GIT_CVSSERVER_BASE_PATH};\n+    $state->{'base-path'} = $base_path;\n+    $log->debug(\"Picked up base path '$base_path' from environment.\\n\");\n+}\n+if ($ENV{GIT_CVSSERVER_ROOTS}) {\n+    if (@{$state->{allowed_roots}}) {\n+\tdie \"Cannot specify roots both ways: @ARGV\\n\";\n+    }\n+    my @allowed_root = split(',', $ENV{GIT_CVSSERVER_ROOTS});\n+    $state->{allowed_roots} = [ @allowed_root ];\n+}\n+\n # if we are called with a pserver argument,\n # deal with the authentication cat before entering the\n # main loop\n-- \n1.5.6.3\n"},{"id":"128053","messageId":"7vocmwvmvr.fsf@alter.siamese.dyndns.org","threadId":"21690","inReplyTo":"81f018ac0911200805g55bd1607u651334c1ed7f1303@mail.gmail.com","subject":"Re: [PATCH/resend] CVS Server: Support reading base and roots from environment","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-11-20T22:42:48Z","receivedAt":"2009-11-20T22:42:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Miller <mille121@illinois.edu> writes:\n\n> The Gitosis single-account Git/ssh hosting system runs git commands\n> through git-shell after confirming that the connecting user is\n> authorized to access the requested repository. This works well for\n> upload-pack and receive-pack, which take a repository argument through\n> git-shell. This doesn't work so well for `cvs server', which is passed\n> through literally, with no arguments. Allowing arguments risks\n> sneaking in `--export-all', so that restriction should be maintained.\n>\n> Despite that, passing a list of repository roots is necessary for\n> per-user access control by the hosting software, and passing a base\n> path improves usability without weakening security. Thus,\n> git-cvsserver needs to come up with these values at runtime by some\n> other means. Since git-shell preserves the environment for other\n> purposes, the environment can carry these arguments as well.\n>\n> Thus, modify git-cvsserver to read $GIT_CVSSERVER_{BASE_PATH,ROOTS} in\n> the absence of equivalent command line arguments.\n>\n> Signed-off-by: Phil Miller <mille121@illinois.edu>\n> ---\n\nThanks.\n\nAny comments from cvsserver users?\n\n>  git-cvsserver.perl |   21 ++++++++++++++++++++-\n>  1 files changed, 20 insertions(+), 1 deletions(-)\n>\n> diff --git a/git-cvsserver.perl b/git-cvsserver.perl\n> index 6dc45f5..9e58d2a 100755\n> --- a/git-cvsserver.perl\n> +++ b/git-cvsserver.perl\n> @@ -104,6 +104,7 @@ $log->info(\"--------------- STARTING -----------------\");\n>  my $usage =\n>      \"Usage: git cvsserver [options] [pserver|server] [<directory> ...]\\n\".\n>      \"    --base-path <path>  : Prepend to requested CVSROOT\\n\".\n> +    \"                          Can be read from GIT_CVSSERVER_BASE_PATH\\n\".\n>      \"    --strict-paths      : Don't allow recursing into subdirectories\\n\".\n>      \"    --export-all        : Don't check for gitcvs.enabled in config\\n\".\n>      \"    --version, -V       : Print version information and exit\\n\".\n> @@ -111,7 +112,8 @@ my $usage =\n>      \"\\n\".\n>      \"<directory> ... is a list of allowed directories. If no directories\\n\".\n>      \"are given, all are allowed. This is an additional restriction, gitcvs\\n\".\n> -    \"access still needs to be enabled by the gitcvs.enabled config option.\\n\";\n> +    \"access still needs to be enabled by the gitcvs.enabled config option.\\n\".\n> +    \"Alternately, these directories may be specified in\n> GIT_CVSSERVER_ROOTS.\\n\";\n\nWhen you introduce a single variable holding multiple values, you need to\ndocument how to cram the values into it.  Maybe such a detail isn't\nnecessary in this usage text, but definitely in the documentation.\n\nDocumentation/git-cvsserver.txt needs to be updated to describe the\nfeatures added by this patch.\n\nBy the way, this patch is line-wrapped.  Here, and...\n\n>  my @opts = ( 'help|h|H', 'version|V',\n>  \t     'base-path=s', 'strict-paths', 'export-all' );\n> @@ -148,6 +150,23 @@ if ($state->{'export-all'} &&\n> !@{$state->{allowed_roots}}) {\n\n... also here.\n\n>      die \"--export-all can only be used together with an explicit whitelist\\n\";\n>  }\n>\n> +# Environment handling for running under git-shell\n> +if ($ENV{GIT_CVSSERVER_BASE_PATH}) {\n\nIt probably is more kosher to say\n\n\tif (exists $ENV{...})\n\nas the base_path _could_ be '0' that evaluates to false.  When the path\ndoes not begin with a '/', what will it be relative to?  Do we want to\ndocument it (not a rhetorical question)?\n\n> +    if ($state->{'base-path'}) {\n> +\tdie \"Cannot specify base path both ways.\\n\";\n> +    }\n> +    my $base_path = $ENV{GIT_CVSSERVER_BASE_PATH};\n> +    $state->{'base-path'} = $base_path;\n> +    $log->debug(\"Picked up base path '$base_path' from environment.\\n\");\n> +}\n> +if ($ENV{GIT_CVSSERVER_ROOTS}) {\n> +    if (@{$state->{allowed_roots}}) {\n> +\tdie \"Cannot specify roots both ways: @ARGV\\n\";\n> +    }\n> +    my @allowed_root = split(',', $ENV{GIT_CVSSERVER_ROOTS});\n> +    $state->{allowed_roots} = [ @allowed_root ];\n\nEven though a comma is probably rare in pathname components, I do not know\nif this is good.\n\nHow much thought went into choosing comma for this purpose?  Is there a\nparticular reason you chose ',' as the separator?  That should be\ndocumented in the commit log message.\n\nLogical alternative choices are \"split at whitespace\" (mimics the way how\ncommand line argument splitting works) and \"colon\" (mimics the way how\n$PATH is split into component paths).\n\nIf a pathname component with whitespaces (Windows and Macs?) is not an\nissue, I would imagine \"split at whitespace\" is much more natural way to\nhandle this, but probably many people have \"My Programs\" and such.\n\nEspecially because it is hard, if not impossible, to have a pathname\ncomponent that contains a colon on Windows, I suspect that a colon is much\nrare compared to whitespaces and commas in the name of people's\ndirectories and files.  It might be better to split at colon like $PATH is\nhandled than using a comma, if you are not going to give any escape\nmechanism to .\n"},{"id":"130549","messageId":"20091230224108.6117@nanako3.lavabit.com","threadId":"21690","inReplyTo":"7vocmwvmvr.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/resend] CVS Server: Support reading base and roots from environment","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-12-30T13:41:08Z","receivedAt":"2009-12-30T13:41:08Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Junio, could you tell us what happened to this thread?\n\nPhil Miller's patch to help gitosis installation.  No response from\ngit-cvsserver users.\n"},{"id":"130565","messageId":"81f018ac0912300912g25887523g1bdf29fd6e31d011@mail.gmail.com","threadId":"21690","inReplyTo":"20091230224108.6117@nanako3.lavabit.com","subject":"Re: [PATCH/resend] CVS Server: Support reading base and roots from environment","fromName":"Phil Miller","fromEmail":"mille121@illinois.edu","sentAt":"2009-12-30T17:12:26Z","receivedAt":"2009-12-30T17:12:26Z","isPatch":true,"sender":{"key":"mille121@illinois.edu","avatar":"https://avatars.githubusercontent.com/u/126464?v=4"},"body":"On Wed, Dec 30, 2009 at 07:41, Nanako Shiraishi <nanako3@lavabit.com> wrote:\n> Junio, could you tell us what happened to this thread?\n>\n> Phil Miller's patch to help gitosis installation.  No response from\n> git-cvsserver users.\n\nI never resent with modifications as Junio requested. I've been busy\nwith some end-of-year close-out stuff, and actually wanted to\ndramatically simplify part of the patch before the resend. I'll do\nthat shortly.\n\nSince Gitosis wants to do repository-level access control before\nrunning any Git commands, I figured out a CVSROOT format that would\nlet it do this. Given that, there's only one repository that an\ninvocation of git-cvsserver should be allowed to access, and so the\nissue of \"list separator\" and so forth is moot. The resultant CVS\ncommand line looks something like\n\ncvs -d \":ext;CVS_SERVER=cvs\n'/path/to/module':charmgit/path/to/module.git\" co -d module\n\nNote that I have had to modify Gitosis to make this, and various other\nthings, work. I had wanted to clean up my work before announcing it,\nbut if it would help you now, it is publicly available from github\nnow:\n\ngit://github.com/PhilMiller/gitosis.git\n\nThe documentation hasn't been updated, but the recent history makes as\nleast some usage clear. I'll send more details in a follow-up.\n\nPhil\n"},{"id":"130574","messageId":"1262201731.30213.23.camel@phil-laptop","threadId":"21690","inReplyTo":"7vocmwvmvr.fsf@alter.siamese.dyndns.org","subject":"[PATCH/resend] CVS Server: Support reading base and roots from environment","fromName":"Phil Miller","fromEmail":"mille121@illinois.edu","sentAt":"2009-12-30T19:35:31Z","receivedAt":"2009-12-30T19:35:31Z","isPatch":true,"sender":{"key":"mille121@illinois.edu","avatar":"https://avatars.githubusercontent.com/u/126464?v=4"},"body":"The Gitosis single-account Git/ssh hosting system runs git commands\nthrough git-shell after confirming that the connecting user is\nauthorized to access the requested repository. This works well for\nupload-pack and receive-pack, which take a repository argument through\ngit-shell. This doesn't work so well for `cvs server', which is passed\nthrough literally, with no arguments. Allowing arguments risks\nsneaking in `--export-all', so that restriction should be maintained.\n\nDespite that, passing a repository root is necessary for per-user\naccess control by the hosting software, and passing a base path\nimproves usability without weakening security. Thus, git-cvsserver\nneeds to come up with these values at runtime by some other\nmeans. Since git-shell preserves the environment for other purposes,\nthe environment can carry these arguments as well.\n\nThus, modify git-cvsserver to read $GIT_CVSSERVER_{BASE_PATH,ROOT} in\nthe absence of equivalent command line arguments.\n\nSigned-off-by: Phil Miller <mille121@illinois.edu>\n---\nI believe this revision addresses all of your comments on the first submission.\n\nYour comment about cramming multiple values into one environment variable made\nme realize that more than one simply was unnecessary complexity, since gitosis\nexpects to authenticate access to a single repository anyway.\n\nI've not documented what GIT_CVSSERVER_BASE_PATH is relative to, because it\nbehaves identically to the --base-path command line argument. Documenting\nwhat that is relative to is a separate issue.\n\n Documentation/git-cvsserver.txt |   15 +++++++++++++++\n git-cvsserver.perl              |   22 +++++++++++++++++++++-\n 2 files changed, 36 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt\nindex 99a7c14..fbab295 100644\n--- a/Documentation/git-cvsserver.txt\n+++ b/Documentation/git-cvsserver.txt\n@@ -277,6 +277,21 @@ In `dbdriver` and `dbuser` you can use the following variables:\n \tIf no name can be determined, the\n \tnumeric uid is used.\n \n+ENVIRONMENT\n+-----------\n+\n+These variables obviate the need for command-line options in some\n+circumstances, allowing easier restricted usage through git-shell.\n+\n+GIT_CVSSERVER_BASE_PATH takes the place of the argument to --base-path.\n+\n+GIT_CVSSERVER_ROOT specifies a single-directory whitelist. The\n+repository must still be configured to allow access through\n+git-cvsserver, as described above.\n+\n+When these environment variables are set, the corresponding\n+command-line arguments may not be used.\n+\n Eclipse CVS Client Notes\n ------------------------\n \ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex 6dc45f5..f5b57b9 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -104,6 +104,7 @@ $log->info(\"--------------- STARTING -----------------\");\n my $usage =\n     \"Usage: git cvsserver [options] [pserver|server] [<directory> ...]\\n\".\n     \"    --base-path <path>  : Prepend to requested CVSROOT\\n\".\n+    \"                          Can be read from GIT_CVSSERVER_BASE_PATH\\n\".\n     \"    --strict-paths      : Don't allow recursing into subdirectories\\n\".\n     \"    --export-all        : Don't check for gitcvs.enabled in config\\n\".\n     \"    --version, -V       : Print version information and exit\\n\".\n@@ -111,7 +112,8 @@ my $usage =\n     \"\\n\".\n     \"<directory> ... is a list of allowed directories. If no directories\\n\".\n     \"are given, all are allowed. This is an additional restriction, gitcvs\\n\".\n-    \"access still needs to be enabled by the gitcvs.enabled config option.\\n\";\n+    \"access still needs to be enabled by the gitcvs.enabled config option.\\n\".\n+    \"Alternately, one directory may be specified in GIT_CVSSERVER_ROOT.\\n\";\n \n my @opts = ( 'help|h|H', 'version|V',\n \t     'base-path=s', 'strict-paths', 'export-all' );\n@@ -148,6 +150,24 @@ if ($state->{'export-all'} && !@{$state->{allowed_roots}}) {\n     die \"--export-all can only be used together with an explicit whitelist\\n\";\n }\n \n+# Environment handling for running under git-shell\n+if (exists $ENV{GIT_CVSSERVER_BASE_PATH}) {\n+    if ($state->{'base-path'}) {\n+\tdie \"Cannot specify base path both ways.\\n\";\n+    }\n+    my $base_path = $ENV{GIT_CVSSERVER_BASE_PATH};\n+    $state->{'base-path'} = $base_path;\n+    $log->debug(\"Picked up base path '$base_path' from environment.\\n\");\n+}\n+if (exists $ENV{GIT_CVSSERVER_ROOT}) {\n+    if (@{$state->{allowed_roots}}) {\n+\tdie \"Cannot specify roots both ways: @ARGV\\n\";\n+    }\n+    my $allowed_root = $ENV{GIT_CVSSERVER_ROOT};\n+    $state->{allowed_roots} = [ $allowed_root ];\n+    $log->debug(\"Picked up allowed root '$allowed_root' from environment.\\n\");\n+}\n+\n # if we are called with a pserver argument,\n # deal with the authentication cat before entering the\n # main loop\n-- \ndebian.1.6.6_rc2.1.7.gc3ed7\n"},{"id":"130577","messageId":"7vpr5wz1hb.fsf@alter.siamese.dyndns.org","threadId":"21690","inReplyTo":"81f018ac0912300912g25887523g1bdf29fd6e31d011@mail.gmail.com","subject":"Re: [PATCH/resend] CVS Server: Support reading base and roots from environment","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-12-30T19:49:20Z","receivedAt":"2009-12-30T19:49:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Miller <mille121@illinois.edu> writes:\n\n> I never resent with modifications as Junio requested. I've been busy\n> with some end-of-year close-out stuff, and actually wanted to\n> dramatically simplify part of the patch before the resend. I'll do\n> that shortly.\n> ...\n> The documentation hasn't been updated, but the recent history makes as\n> least some usage clear. I'll send more details in a follow-up.\n\nThanks Phil for status updates (and thanks Nana for prodding).\n"},{"id":"130580","messageId":"81f018ac0912301212l68ebd7y91004acc93d36779@mail.gmail.com","threadId":"21690","inReplyTo":"7vpr5wz1hb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/resend] CVS Server: Support reading base and roots from environment","fromName":"Phil Miller","fromEmail":"mille121@illinois.edu","sentAt":"2009-12-30T20:12:55Z","receivedAt":"2009-12-30T20:12:55Z","isPatch":true,"sender":{"key":"mille121@illinois.edu","avatar":"https://avatars.githubusercontent.com/u/126464?v=4"},"body":"The Gitosis single-account Git/ssh hosting system runs git commands\nthrough git-shell after confirming that the connecting user is\nauthorized to access the requested repository. This works well for\nupload-pack and receive-pack, which take a repository argument through\ngit-shell. This doesn't work so well for `cvs server', which is passed\nthrough literally, with no arguments. Allowing arguments risks\nsneaking in `--export-all', so that restriction should be maintained.\n\nDespite that, passing a repository root is necessary for per-user\naccess control by the hosting software, and passing a base path\nimproves usability without weakening security. Thus, git-cvsserver\nneeds to come up with these values at runtime by some other\nmeans. Since git-shell preserves the environment for other purposes,\nthe environment can carry these arguments as well.\n\nThus, modify git-cvsserver to read $GIT_CVSSERVER_{BASE_PATH,ROOT} in\nthe absence of equivalent command line arguments.\n\nSigned-off-by: Phil Miller <mille121@illinois.edu>\n---\nI believe this revision addresses all of your comments on the first submission.\n\nYour comment about cramming multiple values into one environment variable made\nme realize that more than one simply was unnecessary complexity, since gitosis\nexpects to authenticate access to a single repository anyway.\n\nI've not documented what GIT_CVSSERVER_BASE_PATH is relative to, because it\nbehaves identically to the --base-path command line argument. Documenting\nwhat that is relative to is a separate issue.\n\n Documentation/git-cvsserver.txt |   15 +++++++++++++++\n git-cvsserver.perl              |   22 +++++++++++++++++++++-\n 2 files changed, 36 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-cvsserver.txt b/Documentation/git-cvsserver.txt\nindex 99a7c14..fbab295 100644\n--- a/Documentation/git-cvsserver.txt\n+++ b/Documentation/git-cvsserver.txt\n@@ -277,6 +277,21 @@ In `dbdriver` and `dbuser` you can use the\nfollowing variables:\n \tIf no name can be determined, the\n \tnumeric uid is used.\n\n+ENVIRONMENT\n+-----------\n+\n+These variables obviate the need for command-line options in some\n+circumstances, allowing easier restricted usage through git-shell.\n+\n+GIT_CVSSERVER_BASE_PATH takes the place of the argument to --base-path.\n+\n+GIT_CVSSERVER_ROOT specifies a single-directory whitelist. The\n+repository must still be configured to allow access through\n+git-cvsserver, as described above.\n+\n+When these environment variables are set, the corresponding\n+command-line arguments may not be used.\n+\n Eclipse CVS Client Notes\n ------------------------\n\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex 6dc45f5..f5b57b9 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -104,6 +104,7 @@ $log->info(\"--------------- STARTING -----------------\");\n my $usage =\n     \"Usage: git cvsserver [options] [pserver|server] [<directory> ...]\\n\".\n     \"    --base-path <path>  : Prepend to requested CVSROOT\\n\".\n+    \"                          Can be read from GIT_CVSSERVER_BASE_PATH\\n\".\n     \"    --strict-paths      : Don't allow recursing into subdirectories\\n\".\n     \"    --export-all        : Don't check for gitcvs.enabled in config\\n\".\n     \"    --version, -V       : Print version information and exit\\n\".\n@@ -111,7 +112,8 @@ my $usage =\n     \"\\n\".\n     \"<directory> ... is a list of allowed directories. If no directories\\n\".\n     \"are given, all are allowed. This is an additional restriction, gitcvs\\n\".\n-    \"access still needs to be enabled by the gitcvs.enabled config option.\\n\";\n+    \"access still needs to be enabled by the gitcvs.enabled config option.\\n\".\n+    \"Alternately, one directory may be specified in GIT_CVSSERVER_ROOT.\\n\";\n\n my @opts = ( 'help|h|H', 'version|V',\n \t     'base-path=s', 'strict-paths', 'export-all' );\n@@ -148,6 +150,24 @@ if ($state->{'export-all'} &&\n!@{$state->{allowed_roots}}) {\n     die \"--export-all can only be used together with an explicit whitelist\\n\";\n }\n\n+# Environment handling for running under git-shell\n+if (exists $ENV{GIT_CVSSERVER_BASE_PATH}) {\n+    if ($state->{'base-path'}) {\n+\tdie \"Cannot specify base path both ways.\\n\";\n+    }\n+    my $base_path = $ENV{GIT_CVSSERVER_BASE_PATH};\n+    $state->{'base-path'} = $base_path;\n+    $log->debug(\"Picked up base path '$base_path' from environment.\\n\");\n+}\n+if (exists $ENV{GIT_CVSSERVER_ROOT}) {\n+    if (@{$state->{allowed_roots}}) {\n+\tdie \"Cannot specify roots both ways: @ARGV\\n\";\n+    }\n+    my $allowed_root = $ENV{GIT_CVSSERVER_ROOT};\n+    $state->{allowed_roots} = [ $allowed_root ];\n+    $log->debug(\"Picked up allowed root '$allowed_root' from environment.\\n\");\n+}\n+\n # if we are called with a pserver argument,\n # deal with the authentication cat before entering the\n # main loop\n-- \ndebian.1.6.6_rc2.1.7.gc3ed7\n"}]}