Project

General

Profile

accessing gitosis repositories with different user?

Added by Lars Fischer almost 14 years ago

Hello,

I'm running redmine on ubuntu 8.04 and would like to use git as scm.

I installed gitosis and created a new test repository. I also set up a new redmine test project and configured the redmine project git settings to the right folder. But when accessing the repository view in redmine, I get an error, that there is no entry or revision.

I think the reason is that redmine is running as user "nobody" with group "nogroup" and gitosis hosts the repositories as user "git".

Is this correct?

How can I permit redmine to read the repository? I think I can not create a ssh key for the user "nobody".

Regards,
Lars


Replies (11)

RE: accessing gitosis repositories with different user? - Added by Felix Schäfer almost 14 years ago

You won't need to create a new gitosis user for redmine because redmine needs file access to the repositories. I suppose you are using passenger to serve redmine, see the passenger documentation to learn more about what user passenger runs apps.

RE: accessing gitosis repositories with different user? - Added by Felix Schäfer almost 14 years ago

Felix Schäfer wrote:

what user passenger runs apps.

I meant "what user passenger rungs apps as".

RE: accessing gitosis repositories with different user? - Added by Lars Fischer almost 14 years ago

Hello Felix,

thank you for your answer.

I changed the owner of "config/environment.rb" to "git" to run redmine as user "git". I think this is working right: new uploaded files get also the owner "git"

But the other error still occurs.

I tried to access the git repository without the gitosis plugin:
- created a new project
- selected git as scm provider and set the needed directory to the local path of the gitosis repository (/home/git/repositories/testrepo.git). Is this right or do I have to clone the repo into an other folder and set the redmine path to this?

I if go to the redmine project repository view, I still get the error, that there is no entry/revision.

Regards,
Lars

RE: accessing gitosis repositories with different user? - Added by Felix Schäfer almost 14 years ago

You need a shallow (or empty, or whatever it is called in git jargon) copy of the repository, no matter where it is on the filesystem or how it was created. I'm not sure what the gitosis plugin does internally or if it even still works, but if you have problems with that, please contact the author of said plugin.

Things that might get in the way: you need auto-fetch turned on on the global repository settings for redmine to fetch changesets on viewing the repository view, the "redmine" user needs read access to the whole repository (and subsequently also for the path to there), the git executable needs to be in the path redmine gets when started. One thing that came to mind: you changed the user redmine is run as, make sure the 4 (?) directories redmine needs write access to (off the top of my head: redmine_dir/logs, redmine_dir/tmp, redmine_dir/files and redmine_dir/public/plugins) have correct permissions.

RE: accessing gitosis repositories with different user? - Added by Lars Fischer almost 14 years ago

You are right. I have to create a local bare repository as described in http://www.redmine.org/wiki/redmine/RedmineRepositories#Git-repository

I'm a git newbie: how can I create such a thing?
"git clone --bare /home/git/repositories/playground.git" results in an error:

git clone --bare /home/git/repositories/playground.git
Initialized empty Git repository in /usr/local/development/redmine/redmine_git_repositories/playground/
fatal: cannot clone empty repository

But the playground repository should not be empty. I made changes on the client and pushed them to the server.

For the moment: the whole redmine folder and everything under /home/git has "git" as owner.
I installed gitosis as described here: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
So I can not login as the git user and have to call the "git clone ..." wit my real user, but I won't put my private key to the server.

I'm confused.

Regards,
Lars

RE: accessing gitosis repositories with different user? - Added by Felix Schäfer almost 14 years ago

See if there really is something in /home/git/repositories/playground.git, and change into the directory and see if git show tells you stuff. I'm not sure why you need to make a bare copy to be honest, I think it should work with the repositories out of gitosis, but it seems your problem lies with an empty repository in gitosis to start with.

RE: accessing gitosis repositories with different user? - Added by Lars Fischer almost 14 years ago

I think its running now. You were right, the repository was empty. After pushing a file I was able to clone the bare repo:
- created a new user redmine with an own ssh key
- redmine is running with this user
- cloned a bare repository with this user and configured the redmine project setting to this repository

Redmine is now displaying the content of the bare repository.

But I could not run

sudo -u my_redmine_user -p secret perl -we '`cd /redmine/repositories/my_repo.git && git fetch && git reset --soft refs/remotes/origin/master`'

The user is added to the sudoers file, but I always get
Sorry, user redmine is not allowed to execute '/usr/bin/perl -we `cd /usr/local/development/redmine/redmine_git_repositories/playground.git && git fetch && git reset --soft refs/remotes/origin/master`' as redmine on [xyz]

Regards,
Lars

RE: accessing gitosis repositories with different user? - Added by Felix Schäfer almost 14 years ago

Again, I think you can access the gitosis repositories from redmine. Can't help you with the sudo thing though.

RE: accessing gitosis repositories with different user? - Added by Lars Fischer almost 14 years ago

Felix Schäfer wrote:

Again, I think you can access the gitosis repositories from redmine. Can't help you with the sudo thing though.

You are right again. Running redmine with the git user, I can configure the project repository settings directly to the gitosis repositories. And there is no need to use an additional hook. All pushed changes are visible in redmine.
This works great.

Thank you very much!

Regards,
Lars

RE: accessing gitosis repositories with different user? - Added by Panagiotis Kranidiotis about 13 years ago

My problem was the same. I am running gitosis and redmine in a debian server. I could see the commits but not the repository browser. The problem solved when i added user www-data to group git witch is the owner of local repositories.

    (1-11/11)