3

I'm writing a web UI for repo management on a server to avoid having to clone gitolite-admin, editing the conf and keydir file and then pushing.

The admin just logs in the web app, gets a list of all repos and permissions for each and from there he can add new repos, SSH keys for users, etc.

I searched for a Python module that does everything for me but the best thing I could find was https://github.com/smailq/gitolite-manager/blob/master/gitolite_manager/gitolite.py and it's far from completion so I've written a Python script that can parse and edit permissions in the gitolite.conf file, adds/removes SSH keys and adds/removes new repos in the repositories directory.

I wanted to avoid having to clone gitolite-admin, edit and push it because that would mean creating a SSH key for Apache, adding that key to the gitolite admin, etc. A lot of hassle from an installation and distribution point of view.

I logged in as git and ran ~git/bin/gitolite compile and the conf was compiled ok, everything went as expected, permissions for repositories were OK.

The problem arose when I tried running the compile command as root or the Apache user.

I got these error messages:

root@debian:/home/git/bin# ./gitolite compile
FATAL: errors found but logfile could not be created
FATAL: /root/.gitolite/logs/gitolite-2014-05.log: No such file or directory
FATAL: die      chdir /root/.gitolite failed: No such file or directory<<newline>>


www-data@debian:/home/git/bin$ ./gitolite compile
FATAL: errors found but logfile could not be created
FATAL: /var/www/.gitolite/logs/gitolite-2014-05.log: No such file or directory
FATAL: die      chdir /var/www/.gitolite failed: No such file or directory<<newline>>

It seems to me that gitolite uses the home dir of whichever user is running the command.

I've tried setting the environment variables GL_BINDIR, GL_REPO_BASE, GL_ADMIN_BASE to point to the proper directories but no luck:

root@debian:/home/git/bin# export GL_BINDIR=/home/git/bin/
root@debian:/home/git/bin# export GL_REPO_BASE=/home/git/repositories/
root@debian:/home/git/bin# export GL_ADMIN_BASE=/home/git/.gitolite
root@debian:/home/git/bin# ./gitolite compile
FATAL: errors found but logfile could not be created
FATAL: /root/.gitolite/logs/gitolite-2014-05.log: No such file or directory
FATAL: die      chdir /root/.gitolite failed: No such file or directory<<newline>>

Is there any way, without modifying the gitolite code, to run the compile as another user other than git?

1 Answer 1

1

After talking to gitolite's author I found a solution:

I added this to sudoers as a test:

yoshi ALL=(git) NOPASSWD: /home/git/bin/gitolite

and running these commands worked as expected:

yoshi@debian ~ $ sudo -u git /home/git/bin/gitolite compile

Initialized empty Git repository in /home/git/repositories/testrepo.git/

yoshi@debian ~ $ sudo -u git /home/git/bin/gitolite trigger POST_COMPILE
yoshi@debian ~ $

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .