Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I found the solution following http://stackoverflow.com/questions/3817478/setting-up-git-server-on-windows-with-git-http-backend-exe and http://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.

share|improve this answer
    
Good catch. +1. I never had to set explicitly REMOTE_USER in all my Apache-Git config (for gitolite, or gitweb, or cgit, ...): github.com/VonC/compileEverything/blob/master/apache/…, probably because I didn't had to redirect to a cgi (issues.apache.org/bugzilla/show_bug.cgi?id=38325) –  VonC Sep 28 '12 at 12:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.