1

Gitweb ignores the

SetEnv GIT_PROJECT_ROOT /path/to/user/git

Even though it works for git. I can clone and push to my repositories. If I enable gitweb, each user can see ALL of the users repositories, and the code inside.

How do I make separate Gitweb "pages" for each one of my users?

Beachhouse
  • 4,972
  • 3
  • 25
  • 39

1 Answers1

1

The answer here lies in the $per_request_config variable in the gitweb.conf file (usually located in /etc/gitweb.conf)

Assuming that /git/ is the root directory of your git repository, and each user has a directory in that folder, this will work for you:

our $per_request_config = sub {
        $projectroot = "/git/" . $cgi->remote_user;
};

Your apache Vhost config could look like this:

<VirtualHost *:443>
        SSLEngine on
        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP

        SSLCertificateFile      /ssl/mydomain.com.crt
        SSLCertificateKeyFile   /ssl/mydomain.com.key

        DocumentRoot /git/user
        ServerName user.mydomain.com

        SetEnv GIT_PROJECT_ROOT /git/user
        SetEnv GIT_HTTP_EXPORT_ALL

        <Directory />
          Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
          AuthType Basic
          AuthName "Private Git Access"
          AuthUserFile "/git/git-auth"
          Require valid-user
          AddHandler cgi-script .cgi
          DirectoryIndex gitweb.cgi
        </Directory>

        # This pattern matches git operations and passes them to http-backend
        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))$" /usr/libexec/git-core/git-http-backend/$1

</VirtualHost>

I found this to be the easiest way for me to manage git and users.

BUT, if you are following a more traditional model, you could link to a folder 'git' in each user's home directory.

our $per_request_config = sub {
        $projectroot = "/home/" . $cgi->remote_user . "/git/";
};
Beachhouse
  • 4,972
  • 3
  • 25
  • 39