1

I am following this tutorial to setup gitolite and at some point the following ScriptAliasMatch is used:

ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
/var/www/bin/gitolite-suexec-wrapper.sh/$1

And the target script starts with

USER=$1

So I am guessing this is used to forward the user name from apache to the suexec script (which indeed requires it). But I cannot see how this is done. The ScriptAliasMatch documentation makes me think that the /$1 will be replaced by the first matching group of the regexp before it. For me it captures from (?x)^/(.* to ))$ so there is nothing about a user here.

My underlying problem is that USER is empty in my script so I get no authorizations in gitolite. I give my username to apache via a basic authentication:

<Location />
   # Crowd auth 
   AuthType Basic
   AuthName "Git repositories"
   ...
   Require valid-user
</Location>

defined just under the previous ScriptAliasMatch.

So I am really wondering how this is supposed to work and what part of the mechanism I missed so that I don't retrieve the user in my script.

jolivier
  • 141
  • 1
  • 9

1 Answers1

1

I found the solution following https://stackoverflow.com/questions/3817478/setting-up-git-server-on-windows-with-git-http-backend-exe and https://stackoverflow.com/questions/8021167/git-debian-apache-and-smart-http which was to add the

SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

to my apache configuration and use $REMOTE_USER in my script which contains indeed the authenticated user name. I'm really wondering how the sample in the tutorial is supposed to work.

jolivier
  • 141
  • 1
  • 9
  • Good catch. +1. I never had to set explicitly `REMOTE_USER` in all my Apache-Git config (for gitolite, or gitweb, or cgit, ...): https://github.com/VonC/compileEverything/blob/master/apache/env.conf.tpl, probably because I didn't had to redirect to a cgi (https://issues.apache.org/bugzilla/show_bug.cgi?id=38325) – VonC Sep 28 '12 at 12:30