kubitron / redmine_git_hosting

A ChiliProject/Redmine plugin which makes configuring your own git hosting easy.
78 stars 15 forks source link

find: missing argument to `-execdir' #1

Closed incorvia closed 12 years ago

incorvia commented 12 years ago

Hey Kubitron, I'm still having issues.. I seem to have the permissions worked out, but it's still not updating the view.. so I tried running:

ruby script/runner "Repository.fetch_changesets" -e production

from the rails root but get:

find: missing argument to `-execdir'

Am I doing something wrong here? Just in case I messed something up.. I removed the whole redming_git_hosting plugin and recloned it.. then ran the database rake again.. but still getting that.. any ideas?

incorvia commented 12 years ago

btw that error comes up in the console.. the production log for that same request shows:

Processing RepositoriesController#show (for 71.184.181.23 at 2012-01-21 21:23:59) [GET] Parameters: {"action"=>"show", "id"=>"kdot", "controller"=>"repositories"} Rendering template within layouts/base Rendering repositories/show Completed in 48ms (View: 35, DB: 1) | 200 OK [http://hq.jamfoundry.com/projects/kdot/repository] Starting Contact plugin for RedMine Executing RESYNC_ALL operation on gitolite configuration Fetching changes from gitolite-admin repository to /tmp/redmine_git_hosting/git/gitolite-admin Creating MD5 digests for Redmine Git Hosting hook Digest for post-receive.redmine_gitolite.rb: 08e9b3cf99fa6285331ccdcef8b9a0d3 "post-receive" is alreay present but it's not ours! Setting up hooks for project 'jamfoundry' (in gitolite repository at 'repositories/jamfoundry.git') Setting up hooks for project 'kdot' (in gitolite repository at 'repositories/kdot.git')

kubitron commented 12 years ago

Ok. If you are willing to work with me, I would like to figure out what is happening with your configuration. First, did you fix the sudo problems? What was the issue?

Second, that error about "execdir" comes from the last commit that I installed to resync hooks. It is curious why it doesn't work (and I want to figure it out), but that line is purely an optimization. As you see, the error is ignored. The problem is that the ";" is being ignored in that command and we should figure out why. But later.

The real problem is the complaint that the '"post-receive" hook is already present but not ours'. That is why your views are not being updated. Did you try to install your own gitolite hook? (you mentioned that in the other thread). At the moment, this plugin does not support foreign hooks. That is a flaw that others have mentioned (on the other fork), but I haven't tried to do anything about it yet.

incorvia commented 12 years ago

Ok so I feel a bit damned if I do, damned if I don't... I am using RVM and was trying to use this fix listed here: https://github.com/ericpaulbishop/redmine_git_hosting/issues/125

Without this fix, when I push to my git repository, I get an error that says:

remote: /usr/bin/env: ruby: No such file or directory error: cannot run hooks/post-receive: No such file or directory

With the fix listed, I receive no such error.. however, as mentioned when I go to the admin panel, there is a warning as it says that the post-receive hook is not ours.... I'm totally at a loss as to how to get this to work otherwise... I switched it back to the original for the purpose of our conversation and the admin recognizes it correctly but I get that error on push...

As for the other issue with the semi-colon.. that still persists.. and I'm open to working with you on that...

incorvia commented 12 years ago

Oh I forgot to mention about the other issues, the sudo problems.. that eventually fixed itself.. I don't know why.. I think I just hit 'apply' on the config screen.. and it just started working.. which was odd cause i was going to and leaving that page without editing anything... so idk...

kubitron commented 12 years ago

Hm... One thing at a time. You may be having a path problem with ruby. Hold on for a moment.

I just uploaded a patch on my "testing" branch. See if that fixes the problem... (do a git pull, then 'git checkout testing'). Does that fix the weird semicolon error? The other version worked for me as well, but perhaps this syntax is better...

(see if it fixes the semcolon problem, not the path problem).

incorvia commented 12 years ago

Ok I ran the script/runner with perl debugger enabled in the run_as_git_user file.. in your current version with two slashes.. the value of $command right before fail is: find repositories/ -type d -name '*.git' -prune -print -execdir git config -f {}/config --get-regexp hooks.redmine_gitolite \;

The version with one slash fails with: find repositories/ -type d -name '*.git' -prune -print -execdir git config -f {}/config --get-regexp hooks.redmine_gitolite ;

and lastly when I switch to my git user and run: find repositories/ -type d -name '*.git' -prune -print -execdir git config -f {}/config --get-regexp hooks.redmine_gitolite \;

it succeeds...

kubitron commented 12 years ago

Um.... I changed more than what you said. Did you try my actual file? The line is now:

 lines = %x[#{GitHosting.git_user_runner} "find #{GitHosting.repository_base} -type d -name '*.git' -prune -print -execdir git config -f {}/config --get-regexp hooks.redmine_gitolite \\;"].chomp.split("\n")

Notice the change in ' <=> " and the . This seems to work for me as well as the original.

However, your system probably has something like /var/log/secure. This will show how the command ends up translated. For instance, on my system, I get:

    Jan 21 12:18:17 kubi sudo:   apache : TTY=unknown ; PWD=/source/tessellation/test-site/redmine/public ; USER=git-tess ; COMMAND=/bin/sh -c eval find\ repositories\/\ -type\ d\ -name\ \'\*\.git\'\ -prune\ -print\ -execdir\ git\ config\ -f\ \{\}\/config\ --get-regexp\ hooks\.redmine_gitolite\ \\\;

with the new code. What do you get?

I'm beginning to think that there is something a bit strange about your configuration....

Tell me again what your setup is? Do you have a separate user for gitolite or not? Is your redmine installation always running? (note that the view update hook talks to redmine via a special URL to get the update to happen...). As for ruby not being found, that is because it is not in the path of the git user (gitolite). How did you set up the "git" user? Which shell does it have? If it has, for instance, /bin/sh, you could try putting the rvm setup in .bashrc, instead of .profile as suggested in that bug:

~git/.bashrc:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

Note that this assumes that the git user has rvm installed. This is an important point: the hook which informs redmine runs as the git user. Thus, the git user is the one that needs ruby in that instance....

kubitron commented 12 years ago

Also -- are you running binaries out of /tmp? Have you altered my code to do that? I'd like to avoid getting too far from my version of the plugin in order to help with the debugging.

incorvia commented 12 years ago

For the non-rvm issue.. I got it to fun with the following code:

https://gist.github.com/1654015

incorvia commented 12 years ago

@kubitron no.. I was using your binaries in your folder.. sorry.. I got confused. because there was a relic there from a past installation.. the code I showed above is based on the binaries in the folder you made...

kubitron commented 12 years ago

But -- did you try my newer version of the code instead? Note that, by swapping ' and ", I potentially got rid of the issues with respect to " that you did by removing some lines from the run_as_git_user code.

I am a little hesitant to just change the sudo code (it is from the original plugin) without a lot of testing.

kubitron commented 12 years ago

Can you find the log file that I mentioned in my previous comment? I want to know how the command we are talking about is translated in your system... (including with the version of the file on the testing branch).

incorvia commented 12 years ago

I did try it yes.. I just verified again by deleting the plugin.. pulling the code, switching to the testing branch.. and the error came back....

I don't seem to have that log file:

https://gist.github.com/1654076

kubitron commented 12 years ago

Which version of linux/unix are you running? Look in /var/log/messages or /var/log/syslog to see if there is a log message from sudo..... Actually, looking at your list, I bet it is in /var/log/auth.log

Even simpler, try looking for sudo in any log file:

grep sudo /var/log/*

incorvia commented 12 years ago

Ok, I just re-ran the command so these should be the lines you are looking for:

https://gist.github.com/1654119

I hope that helps!

incorvia commented 12 years ago

Oh sorry, I'm running Ubuntu 10.10

kubitron commented 12 years ago

Well, it confuses me, be cause it looks like you are not (1) using the original binary (un modified) and (2) not using the version of the git_adapter_hooks.rb file from my testing branch.... (note the fact that there is a ";" on the line you sent is telling, because that is what was in my exported version, not on the testing branch). Are you sure that you are using the new file?

incorvia commented 12 years ago

I believe I am to make sure I deleted the tmp folder.. then here is the complete sequence I just did:

https://gist.github.com/1654174

You can see at the end the corresponding new log entries...

kubitron commented 12 years ago

Hm.... I think that perhaps you are getting the redmine "testing" branch.

Make sure to cd into "redmine_git_hosting" before doing "git checkout testing".

Then try (from same directory):

git log

The first entry should be:

Date:   Sat Jan 21 10:58:25 2012 -0800

    See if this fixes problem from incorvia

If it isn't, then something else is wrong. Also, look in lib/git_hosting.rb to see if the execdir line is different.... (should be what I showed above:)

lines = %x[#{GitHosting.git_user_runner} "find #{GitHosting.repository_base} -type d -name '*.git' -prune -print -execdir git config -f {}/config --get-regexp hooks.redmine_gitolite \\;"].chomp.split("\n")

Note how there is a " before find and the end is \;"

incorvia commented 12 years ago

It does seem weird.. I see that it looked like the old code so I did it again.. here in the middle I verified that the code contained the double backslash without editing it...

https://gist.github.com/1654223

You can see in this one.. that it looks like (at least in theory) to produce the corred output of => \;
Somehow this still fails though as you can see..

kubitron commented 12 years ago

Ok. Good. At least we have some sanity. I believe that this might be an escaping problem. First, what do you get from:

sudo -V

(only looking for the version). I'm assuming that it is something like 1.7.2 or the like.

Second, try modifying the run_as_git_command to add an extra two slashes before quotes as follows (look at last exec line):

#!/usr/bin/perl

my $command = join(" ", @ARGV);

my $user = `whoami`;
chomp $user;
if ($user eq "git-tess")
{
        exec("cd ~ ; $command");
}
else
{
        $command =~ s/\\/\\\\/g;
        $command =~ s/"/\\"/g;
        exec("sudo -u git-tess -i eval \\\"$command\\\"");
}

Does the execdir command work now? (what does your log file look like)?

You are using an "old" version of sudo, which Eric found has different escaping properties from the newer one. Although he put correction code in for one of the scripts, he didn't do it for others. Hopefully this is an easy fix... Unfortunately, I don't have an Ubuntu installation to try this on....

incorvia commented 12 years ago

:-) Sorry, for the hassle... I should add.. thanks to your insights about RVM, I was able to get it working... I added my ruby-1.9.3 version to the .bashrc.. I also just linked the full path in the post-receive hook to that same version (not sure which of these two fixed it).. but then installed the required gems on that version of ruby.. and now it works.. I didn't really understand that it was using a different version of ruby over on the git side, so your comments enabled me to link that up properly it seems....

As for this:

sudo -V returns: Sudo version 1.7.2p7

I'll make those fixes and report back...

incorvia commented 12 years ago

I agree it's an escaping problem.. that's why I attempted to fix it the way I did.. it seemed to work, but I trust your judgement if it didn't seem like the best solution :)

This returns:

Gem::Specification#installation_path called from /home/kevin/.rvm/gems/ruby-1.8.7-p352@redmine/gems/rails-2.3.14/lib/rails/vendor_gem_source_index.rb:93. -bash: -c: line 0: unexpected EOF while looking for matching `"' -bash: -c: line 1: syntax error: unexpected end of file sh: ": not found

The log returned:

https://gist.github.com/1654490

incorvia commented 12 years ago

I'd be happy just to upgrade sudo if you thought that was an easier fix.. if you'd rather search down this problem, I'm happy to help.

kubitron commented 12 years ago

Did you miss one of the " at the end of the line? (There are two). Also, could you send me the other lines around the sudo line from your log? I'm curious about other sudos with this code.

At any rate. Thanks for your patience. I would say to (1) go back to your original solution that worked for you. Perhaps that is the right fix for this. We are clearly going backwards (perhaps I'll find a system that I can work on later). (2) For a close to the RVM issue, see if you can get it to work with only the .bashrc path enhancements, rather than altering the actual hook.

incorvia commented 12 years ago

I double checked.. this is the line I have: exec("sudo -u git -i eval \"$command\""); <- there are three slashes on each side.. github is escaping one gives the error above... the surrounding lines are as follows:

https://gist.github.com/1654557

For the RVM issue, no, it stopped working.. so I guess that line wasn't actually influencing it (for me at that time). It seems that altering the hook line is what made it work for me.. there must be another way but not sure what it would be...

kubitron commented 12 years ago

Ok. Sorry for the delay. I had something that called me away.

I managed to find a machine with an old version of Sudo, so that I can see how it behaves. As a result, I've pushed a new testing branch. If you are willing, I would like to see if that fixes the ';' (so that I can close out this bug). My main constraint is not to break "older" installations -- so this commit provides the least change in behavior from previous scripts (even though the right thing would be a cleanup of the script, I don't have enough testing bandwidth to go back to old installations).

Just go into the redmine_git_hosting directory (in the testing branch) and do a "git pull". The new run_as_git_user script for an old version of sudo (yours) should now look like:

#!/usr/bin/perl

my $command = join(" ", @ARGV);

my $user = `whoami`;
chomp $user;
if ($user eq "git-tess")
{
        exec("cd ~ ; $command");
}
else
{
        $command =~ s/\\/\\\\/g;
        $command =~ s/\\\\;/\\\\\\;/g;
        $command =~ s/"/\\"/g;
        exec("sudo -u apache -i eval \"$command\"");
}

The only difference from a stock installation is the second replace line. Also, the command line was altered a bit (use -exec to work on a wider number of installations).

p.s. Make sure that the new scripts get built before you look to see what they look like..... (i.e. run it once).

incorvia commented 12 years ago

I think I did it.. i deleted the whole plugin.. then repulled .. cd into the dir.. switch to testing.. ran the rake.. it asked me for my git password it seemed.. entered that.. then it gave the same error.. then went and looked at the code and it was this:

    #!/usr/bin/perl

    my $command = join(" ", @ARGV);

    my $user = `whoami`;
    chomp $user;
    if ($user eq "git")
        {
            exec("cd ~ ; $command");
}
else
    {
            $command =~ s/\\/\\\\/g;
            $command =~ s/\\\\;/\\\\\\;/g;
            $command =~ s/"/\\"/g;
            exec("sudo -u git -i eval \"$command\"");
    }

It doesn't have your word 'apache in the 4th line but it seemed ot be the same elsewhere

kubitron commented 12 years ago

Hm... Now that is surprising. Did you restart the webserver?

Can you send me the log file?

p.s. You can easily quote code here by putting

 on the line before it and 
after (I did it for your previous comment).

incorvia commented 12 years ago

Urg this is such a night mare for me.. now it's saying that my hook isn't installed and I don't have sudo priviledges to run either git or whatever.. anyways.. I did restart the server.. and here is quite a bit of the most recent log

/var/log/auth.log:Jan 24 05:28:35 foundry sudo:    kevin : no tty present and no askpass program specified ; TTY=unknown ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval cat - > ~/.gitolite/hooks/common/post-receive
/var/log/auth.log:Jan 24 05:28:35 foundry sudo:    kevin : no tty present and no askpass program specified ; TTY=unknown ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval gl-setup
/var/log/auth.log:Jan 24 05:28:36 foundry sudo:    kevin : no tty present and no askpass program specified ; TTY=unknown ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval test -r ~/.gitolite/hooks/common/post-receive
/var/log/auth.log:Jan 24 05:28:36 foundry sudo:    kevin : no tty present and no askpass program specified ; TTY=unknown ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval cat - > ~/.gitolite/hooks/common/post-receive
/var/log/auth.log:Jan 24 05:28:36 foundry sudo:    kevin : no tty present and no askpass program specified ; TTY=unknown ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval gl-setup
/var/log/auth.log:Jan 24 05:28:36 foundry sudo:    kevin : no tty present and no askpass program specified ; TTY=unknown ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval sudo -nu kevin echo yes
/var/log/auth.log:Jan 24 05:28:36 foundry sudo:    kevin : no tty present and no askpass program specified ; TTY=unknown ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval echo yes
/var/log/auth.log:Jan 24 05:28:55 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--version\" \"--no-color\" 
/var/log/auth.log:Jan 24 05:28:55 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir\" \"repositories/mbti.git\" \"log\" \"--no-color\" \"--encoding=UTF-8\" \"--raw\" \"--date=iso\" \"--pretty=fuller\" \"--parents\" \"--reverse\" \"11e154ae243488e30a8ee266be9b816aa20c6340..master\" 
/var/log/auth.log:Jan 24 05:28:56 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval test -r ~/.gitolite/hooks/common/post-receive
/var/log/auth.log:Jan 24 05:28:56 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval bash
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval cat ~/.gitolite/hooks/common/post-receive
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval find repositories/ -type d -name "*.git" -prune -print
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval test -r recycle_bin/
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"config\" \"-f\" \".gitconfig\" \"--get-regexp\" \"hooks.redmine_gitolite\" 
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval find repositories/ -type d -name "*.git" -prune -print -execdir git config -f {}/config --get-regexp hooks.redmine_gitolite \\;
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir=repositories/jamfoundry.git\" \"config\" \"hooks.redmine_gitolite.key\" \"VTKFEWBPOXJWGLMHETQBKRYXTKJLIGHBSPOPMNLPHJFJURFPYDSQEMDNRLELQCAVHCKDQHXPDAKVEEKGDMGRDJOQUQQCNWRM\" 
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir=repositories/jamfoundry.git\" \"config\" \"hooks.redmine_gitolite.projectid\" \"jamfoundry\" 
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir=repositories/newsleaf.git\" \"config\" \"hooks.redmine_gitolite.key\" \"CBDFTRMCVFQJXYNCEJMKOOJMKNYVEYMPUHUQARYYUTBHHUHUKJTQSREXJIFCUXHATBGKERVNKSODPJGXAQQYRVQMMTCY\" 
/var/log/auth.log:Jan 24 05:28:57 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir=repositories/newsleaf.git\" \"config\" \"hooks.redmine_gitolite.projectid\" \"newsleaf\" 
/var/log/auth.log:Jan 24 05:28:58 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir=repositories/mbti.git\" \"config\" \"hooks.redmine_gitolite.key\" \"FIEWNWDGANMWESSVYNIMAIQTLLEBHAQUVOMVMERMFBEDLKQQKMKIJSLBIPHSOBVAUXHPCGHVMHCIMINONLLNSHDVNHNKCMCTAF\" 
/var/log/auth.log:Jan 24 05:28:58 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir=repositories/mbti.git\" \"config\" \"hooks.redmine_gitolite.projectid\" \"mbti\" 
/var/log/auth.log:Jan 24 05:28:58 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir=repositories/kdot.git\" \"config\" \"hooks.redmine_gitolite.key\" \"BFNUEHAIEIDUXTDLEOAFBYEGSPCBFGKNSHNYUUGTMHUKJGMVSYOFFLTFHCLNSDLIQCBFVWQODOSC\" 
/var/log/auth.log:Jan 24 05:28:58 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=git ; COMMAND=/bin/bash -c eval git \"--git-dir=repositories/kdot.git\" \"config\" \"hooks.redmine_gitolite.projectid\" \"kdot\" 
/var/log/auth.log:Jan 24 05:29:12 foundry sudo:    kevin : TTY=pts/1 ; PWD=/home/kevin/redmine ; USER=root ; COMMAND=/bin/grep sudo /var/log/alternatives.log /var/log/apache2 /var/log/apt /var/log/auth.log /var/log/boot /var/log/btmp /var/log/daemon.log /var/log/debug /var/log/dmesg /var/log/dpkg.log /var/log/faillog /var/log/fontconfig.log /var/log/fsck /var/log/kern.log /var/log/lastlog /var/log/lpr.log /var/log/mail.err /var/log/mail.info /var/log/mail.log /var/log/mail.warn /var/log/messages /var/log/mongodb /var/log/mongodb.log /var/log/mysql /var/log/mysql.err /var/log/mysql.log /var/log/news /var/log/passenger-analytics /var/log/postgresql /var/log/pycentral.log /var/log/redis.log /var/log/samba /var/log/syslog /var/log/user.log /var/log/vsftpd.log /var/log/wtmp
/var/log/dpkg.log:2011-09-15 06:45:45 upgrade sudo 1.7.2p7-1ubuntu2 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:45 status half-configured sudo 1.7.2p7-1ubuntu2
/var/log/dpkg.log:2011-09-15 06:45:45 status unpacked sudo 1.7.2p7-1ubuntu2
/var/log/dpkg.log:2011-09-15 06:45:45 status half-installed sudo 1.7.2p7-1ubuntu2
/var/log/dpkg.log:2011-09-15 06:45:45 status half-installed sudo 1.7.2p7-1ubuntu2
/var/log/dpkg.log:2011-09-15 06:45:45 status unpacked sudo 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:45 status unpacked sudo 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:58 configure sudo 1.7.2p7-1ubuntu2.1 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:58 status unpacked sudo 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:58 status unpacked sudo 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:58 status unpacked sudo 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:58 status unpacked sudo 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:58 status half-configured sudo 1.7.2p7-1ubuntu2.1
/var/log/dpkg.log:2011-09-15 06:45:58 status installed sudo 1.7.2p7-1ubuntu2.1
incorvia commented 12 years ago

I just rebooted the whole server, same outcome :-| Thanks for the

 tip.. i knew there had to be a way heh

incorvia commented 12 years ago

I feel like just upgrading sudo at this point

kubitron commented 12 years ago

Sigh. Sorry so painful. I was able to reproduce your problem. I actually wrote a ruby script on this old machine and saw your problem.

So, Try #3 (and then I'll leave you alone). Pull again. Binary looks like this:

#!/usr/bin/perl

my $command = join(" ", @ARGV);

my $user = `whoami`;
chomp $user;
if ($user eq "git-tess")
{
        exec("cd ~ ; $command");
}
else
{
        $command =~ s/\\/\\\\/g;
        $command =~ s/(\\\\;)/"$1"/g;
        $command =~ s/"/\\"/g;
        exec("sudo -u git -i eval \"$command\"");
}

Also, note that I decided to go with "-exec" to be more likely compatible with other folks.

REALLY SORRY!

incorvia commented 12 years ago

When I do this, it doesn't come up with the error:

#!/usr/bin/perl

my $command = join(" ", @ARGV);

my $user = `whoami`;
chomp $user;
if ($user eq "git")
{
        exec("cd ~ ; $command");
}
else
{
        $command =~ s/;/'\\;'/g;
        exec("sudo -u git -i eval \"$command\"");
}

and

lines = %x[#{GitHosting.git_user_runner} "find #{GitHosting.repository_base} -type d -name '*.git' -prune -print -exec git config -f {}/config --get-regexp hooks.redmine_gitolite \;"].chomp.split("\n")
kubitron commented 12 years ago

Yes, but -- did you try the final change that I suggested? Note that I am trying not to change the %x[] expression any more, because I want that to work properly with the more up-to-date system...

I really appreciate your playing with this. Just try pulling the "testing" branch again...

incorvia commented 12 years ago

I did try that, it didn't work

incorvia commented 12 years ago

Oh wait... it does work, yeah sorry, idk what happened there.. it does work.. cleaned out the copy and reinstalled it.. and it certainly does work.. you can close this issue heh.. can I open a ticket for my other issues? :) heh

kubitron commented 12 years ago

Yeah! Finally.

Just to make sure -- we are on the same page -- does your run_as_git_user script look like the one I quoted a few comments back? And, does the line in git_adapter_hooks.rb like this?

lines = %x[#{GitHosting.git_user_runner} 'find #{GitHosting.repository_base} -type d -name "*.git" -prune -print -exec git config -f {}/config --get-regexp hooks.redmine_gitolite \\;'].chomp.split("\n")
kubitron commented 12 years ago

p.s. You can certainly post your other issue.

incorvia commented 12 years ago

yep, it looks just like that ;-)