kubitron / redmine_git_hosting

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

pushes using smart HTTP via HTTPS don't work (Gitolite v3) #90

Open crocket opened 12 years ago

crocket commented 12 years ago

Pushes via gitolite itself work.

ruby : 1.9.3 redmine_git_hosting : the master chiliproject : 3.3.0 postgresql : 9.1.4 gitolite : 3.0.4

$ git remote -v origin https://admin@project.snowberry.me/replaybuffer.git (fetch) origin https://admin@project.snowberry.me/replaybuffer.git (push)

$ git push origin master Counting objects: 5, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 294 bytes, done. Total 3 (delta 1), reused 0 (delta 0) Password for 'https://admin@project.snowberry.me': remote: Empty compile time value given to use lib at hooks/update line 6 remote: Use of uninitialized value in require at hooks/update line 7. remote: Can't locate Gitolite/Hooks/Update.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.12.3/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.12.3 /usr/lib64/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.12.3 /usr/lib64/perl5/5.12.3/x86_64-linux-thread-multi /usr/lib64/perl5/5.12.3 /usr/lib64/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.10.1 /usr/lib64/perl5/vendor_perl .) at hooks/update line 7. remote: BEGIN failed--compilation aborted at hooks/update line 7. remote: error: hook declined to update refs/heads/master To https://admin@project.snowberry.me/replaybuffer.git ! [remote rejected] master -> master (hook declined) error: failed to push some refs to 'https://admin@project.snowberry.me/replaybuffer.git'

But Update.pm is located at /usr/libexec/gitolite/lib/Gitolite/Hooks/Update.pm The update hook is meant to be executed by gitolite-shell. In gitolite-shell, Update.pm is available.

What is the proper way to add /usr/libexec/gitolite to @INC?

kubitron commented 12 years ago

Um... Did you add a hook to gitolite? That is not how you get http to work with the plugin... You should be using the "http" URL given in the project or repository view. [Another way to say this -- there should be NO perl involved in the process].

Can you tell me exactly what you did? Also, can you tell me exactly what your web configuration is for Chili?

crocket commented 12 years ago

gitolite 3.0.4 has the update hook in ~git/.gitolite/hooks/common which is basically a perl script.

You should use gitolite 3 yourself.

kubitron commented 12 years ago

Well, at the moment, gitolite 3.x is not officially supported, however, I don't believe that is the issue.

The http path should be going through ChiliProject, not gitolite directly. You didn't say anything about your web configuration. Did you somehow configure http through gitolite? You shouldn't do that. There are routes in redmine_git_hosting to handle http access to repositories. Also, are you using Apache or ngnix, or what, exactly?

crocket commented 12 years ago

In /etc/httpd/httpd.conf,

LoadModule passenger_module /usr/lib64/ruby/gems/1.9.1/gems/passenger-3.0.17/ext/apache2/mod_passenger.so PassengerRoot /usr/lib64/ruby/gems/1.9.1/gems/passenger-3.0.17 PassengerRuby /usr/bin/ruby

NameVirtualHost 114.200.0.162:80 NameVirtualHost 114.200.0.162:443

Include /etc/httpd/sites-enabled/*

In /etc/httpd/sites-enabled/snowberry-chiliproject,

< VirtualHost 114.200.0.162:80 > ServerName project.snowberry.me DocumentRoot /misc/data/service/empty

Redirect / https://project.snowberry.me/

< /VirtualHost >

< VirtualHost 114.200.0.162:443 > ServerName project.snowberry.me DocumentRoot /misc/data/service/chiliproject/public

< Directory /misc/data/service/chiliproject/public > Options -MultiViews AllowOverride all

Order deny,allow
Allow from all

< /Directory >

ErrorLog /var/log/httpd/ssl_error_log CustomLog /var/log/httpd/ssl_access_log common env=!do_not_log

SSLEngine on SSLOptions StdEnvVars ExportCertData StrictRequire SSLCACertificateFile /etc/ssl/ca/ca.crt SSLCertificateFile /etc/ssl/ca/certs/snowberry.me.chain.crt SSLCertificateKeyFile /etc/ssl/ca/private/snowberry.me.key SSLProtocol TLSv1 SSLVerifyDepth 1 SSLVerifyClient none < /VirtualHost >

kubitron commented 12 years ago

Can you send me your Chili project log when you try to access a project via httpd? You should see the git_http_controller being called. If not, then it appears that your web server is bypassing directly to gitolite (which is not supposed to happen).

I'm not entirely sure I understand if this is a problem with the http access of repositories or general update of repositories. What happens if you use ssh to update your gitolite repositories (the normal mode for this plugin)? Does that work properly?

crocket commented 12 years ago

1) If I use ssh to update my gitolite repositories, there is no error.

2) I made a gitolite repository and added it to chiliproject.

:~/test# git remote -v origin http://admin@project.snowberry.me/test.git (fetch) origin https://admin@project.snowberry.me/test.git (push)

~/test# git push origin master Password: Counting objects: 6, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (6/6), 429 bytes, done. Total 6 (delta 0), reused 0 (delta 0) remote: Empty compile time value given to use lib at hooks/update line 6 remote: Use of uninitialized value in require at hooks/update line 7. remote: Can't locate Gitolite/Hooks/Update.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.12.3/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.12.3 /usr/lib64/perl5/vendor_perl/5.12.3/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.12.3 /usr/lib64/perl5/5.12.3/x86_64-linux-thread-multi /usr/lib64/perl5/5.12.3 /usr/lib64/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.10.1 /usr/lib64/perl5/vendor_perl .) at hooks/update line 7. remote: BEGIN failed--compilation aborted at hooks/update line 7. remote: error: hook declined to update refs/heads/master

Below is the chiliproject log.

Processing GitHttpController#index (for 114.200.0.162 at 2012-10-30 12:32:17) [GET] Parameters: {"service"=>"git-receive-pack", "prefix"=>"", "controller"=>"git_http", "action"=>"index", "repo_path"=>"test.git", "path"=>["info", "refs"]} Completed in 146ms (View: 1, DB: 9) | 200 OK [https://project.snowberry.me/test.git/info/refs?service=git-receive-pack]

Processing GitHttpController#index (for 114.200.0.162 at 2012-10-30 12:32:17) [POST] Parameters: {"prefix"=>"", "controller"=>"git_http", "action"=>"index", "repo_path"=>"test.git", "path"=>["git-receive-pack"]} Filter chain halted as [:authenticate] rendered_or_redirected. Completed in 21ms (View: 1, DB: 6) | 401 Unauthorized [https://project.snowberry.me/test.git/git-receive-pack]

Processing GitHttpController#index (for 114.200.0.162 at 2012-10-30 12:32:17) [POST] Parameters: {"prefix"=>"", "controller"=>"git_http", "action"=>"index", "repo_path"=>"test.git", "path"=>["git-receive-pack"]} Completed in 66ms (View: 2, DB: 11) | 200 OK [https://project.snowberry.me/test.git/git-receive-pack]

3) I deleted test.git from gitolite and chiliproject and created test repository with redmine_git_hosting.

~/test# git push origin master Password: Counting objects: 3, done. Writing objects: 100% (3/3), 212 bytes, done. Total 3 (delta 0), reused 0 (delta 0) error: RPC failed; result=52, HTTP code = 302 fatal: The remote end hung up unexpectedly fatal: The remote end hung up unexpectedly

Processing GitHttpController#index (for 114.200.0.162 at 2012-10-30 13:10:00) [GET] Parameters: {"service"=>"git-receive-pack", "prefix"=>"", "controller"=>"git_http", "action"=>"index", "repo_path"=>"test.git", "path"=>["info", "refs"]} Completed in 145ms (View: 1, DB: 9) | 200 OK [https://project.snowberry.me/test.git/info/refs?service=git-receive-pack]

Processing GitHttpController#index (for 114.200.0.162 at 2012-10-30 13:10:00) [POST] Parameters: {"prefix"=>"", "controller"=>"git_http", "action"=>"index", "repo_path"=>"test.git", "path"=>["git-receive-pack"]} Filter chain halted as [:authenticate] rendered_or_redirected. Completed in 21ms (View: 1, DB: 6) | 401 Unauthorized [https://project.snowberry.me/test.git/git-receive-pack]

And now I see weird files in chiliproject log directory. /misc/data/service/chiliproject/log# ls , [git-receive-pack]} index, production.log git_http, git-receive-pack, [info, test.git,

4) I tried to clone on a remote machine on the internet.

/tmp# git clone https://admin@project.snowberry.me/test.git Cloning into test... Password: error: while accessing https://admin@project.snowberry.me/test.git/info/refs

fatal: HTTP request failed

Why can't I clone a repository controlled by redmine_git_hosting in a remote machine?

kubitron commented 12 years ago

Have you tried running this with gitolite 2.x? As I said before (and as said in the README), this plugin doesn't officially support gitolite 3.x.

crocket commented 12 years ago

I haven't tried using gitolite 2, and I don't want to downgrade gitolite 3 to gitolite 2. Perhaps, invoking gitolite-shell would solve that perl hook problem.

Maybe, it's time to start making commits in support of gitolite 3.

kubitron commented 12 years ago

Yes. gitolite 3.x is on my roadmap. I'm not convinced that this is a gitolite 3.x problem yet, however. Can you tell me what is in these weird files in the log directory? Are they always created?

kubitron commented 12 years ago

(Actually, please do a controlled experiment -- remove weird files, try to push and see if they come back, then show what their contents are)...

Did you ever get cloning working in some form, or was that always broken?

When you pushed, were you asked for a password?

Also, have you tried cloning through http instead of https? (There are configuration problems that sometimes arise with https)?

kubitron commented 12 years ago

I'm going to increment version now, since there are several important patches on master. We will try to figure out this problem. It is pretty weird.

kubitron commented 12 years ago

There is one problem that we can perhaps fix. Tell me more about your gitolite installation. Did you add an update or post-update hook of your own? The redmine_git_hosting plugin invokes git with the "GL_BYPASS_UPDATE_HOOK" set to true to avoid running the update hook. In my gitolite 2.x installation, the update hook explicitly checks for this variable at the top and exits if it is set to true (this came standard -- I didn't change it). However, in your case, it appears that the update hook cannot run (and could not even check that environment variable to exit) because of missing libraries (or something) in the perl path for the gitolite installation. Is it possible that you either (1) added a bad update hook or (2) didn't quite install gitolite properly?

I haven't moved to gitolite 3.x yet because it is not available as an RPM in RedHat linux (I don't like to run with non-standard configurations on my main servers).

kubitron commented 12 years ago

I just looked and this variable is now gone from gitolite 3x. Also, it appears that none of the other forks of redmine_git_hosting work with gitolite 3.x yet. I know of several things that don't quite work properly with 3.0, now that I think of it.

As far as I can tell, gitolite 3x is not directly supported as a package by RedHat or Ubuntu. Haven't looked at other linux releases yet. Is there some reason that you are determined to use it? 2.x works quite well. In order to support 3.0, I will have to do some work. At the moment, my biggest feature request (and most important) is the Redmine 2.0 compatibility. I'll have to get to this later (very limited hacking time).

crocket commented 12 years ago

I installed gitolite in /usr/libexec/gitolite manually because http://sitaramc.github.com/gitolite/install.html#package recommended this directory as the installation path.

Since the above link says "The Gitolite subdirectory in /usr/libexec/gitolite/lib can stay right there, OR, if your distro policies don't allow that, can be put in any directory in perl's @INC path (such as /usr/share/perl5/vendor_perl).", I moved /usr/libexec/gitolite/lib/* to /usr/lib64/perl5/vendor_perl/5.12.3.

After that, old errors are gone, and I got new errors.

~/replaybuffer# git push Password: Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 278 bytes, done. Total 3 (delta 0), reused 0 (delta 0) remote: Empty compile time value given to use lib at hooks/update line 6 remote: WARNING: Use of uninitialized value $repo in concatenation (.) or string at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 180, line 1. remote: remote: WARNING: Use of uninitialized value $repo in concatenation (.) or string at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 180, line 1. remote: remote: WARNING: Use of uninitialized value $base2 in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 396, line 1. remote: remote: WARNING: Use of uninitialized value $base in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 396, line 1. remote: remote: WARNING: Use of uninitialized value $base in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 299, line 1. remote: remote: WARNING: Use of uninitialized value $base in pattern match (m//) at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 299, line 1. remote: remote: WARNING: Use of uninitialized value in hash slice at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Common.pm line 176, line 1. remote: remote: WARNING: Use of uninitialized value $repo in concatenation (.) or string at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 180, line 1. remote: remote: WARNING: Use of uninitialized value $repo in concatenation (.) or string at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 180, line 1. remote: remote: WARNING: Use of uninitialized value $base2 in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 396, line 1. remote: remote: WARNING: Use of uninitialized value $base in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 396, line 1. remote: remote: WARNING: Use of uninitialized value $base in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 299, line 1. remote: remote: WARNING: Use of uninitialized value $base in pattern match (m//) at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 299, line 1. remote: remote: WARNING: Use of uninitialized value in hash slice at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Common.pm line 176, line 1. remote: remote: WARNING: Use of uninitialized value $repo in concatenation (.) or string at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 180, line 1. remote: remote: WARNING: Use of uninitialized value $repo in concatenation (.) or string at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 180, line 1. remote: remote: WARNING: Use of uninitialized value $base2 in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 396, line 1. remote: remote: WARNING: Use of uninitialized value $base in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 396, line 1. remote: remote: WARNING: Use of uninitialized value $base in string eq at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 299, line 1. remote: remote: WARNING: Use of uninitialized value $base in pattern match (m//) at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 299, line 1. remote: remote: WARNING: Use of uninitialized value in hash slice at /usr/lib64/perl5/vendorperl/5.12.3/Gitolite/Common.pm line 176, line 1. remote: remote: WARNING: Use of uninitialized value $[2] in join or string at /usr/lib64/perl5/vendorperl/5.12.3/Gitolite/Common.pm line 42, line 1. remote: remote: WARNING: Use of uninitialized value $[3] in join or string at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Common.pm line 42, line 1. remote: remote: WARNING: Use of uninitialized value $repo in concatenation (.) or string at /usr/lib64/perl5/vendor_perl/5.12.3/Gitolite/Conf/Load.pm line 70, line 1. remote: remote: FATAL: invalid repo '' remote: error: hook declined to update refs/heads/master

I guess those errors occurred because redmine_git_hosting bypassed gitolite-shell.

If the versions of git differ on client and server, you can't clone a repository via smart HTTP from redmine_git_hosting. git versions need to be close in my experiences.