Skip to content

Repository not found when accessed through HTTPS #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sdinot opened this issue Jan 29, 2016 · 23 comments
Closed

Repository not found when accessed through HTTPS #568

sdinot opened this issue Jan 29, 2016 · 23 comments
Assignees
Labels

Comments

@sdinot
Copy link

sdinot commented Jan 29, 2016

Hi,

Summary:

URL displayed by Redmine:

SSH: ssh://[email protected]/orekit/orekit-main.git
HTTPS: https://[email protected]/git/orekit/orekit-main.git

Cloning attempts:

$ git clone ssh://[email protected]/orekit/orekit-main.git
=> Success
$ git clone https://[email protected]/git/orekit/orekit-main.git
=> Fail, repository not found
$ git clone https://[email protected]:git/orekit/orekit-main.git
=> Success

The difference between the second and the third tries is that "**/git/" was replaced by ":**git/"

What's wrong?

Detailed explanation:

I just deployed Redmine 3.2 and Redmine Git Hosting 1.2 plugin in a fresh Debian Jessie 8.3 VM, using Apache 2.4.10, PostgreSQL 9.4.5, Gitolite 3.6.1 and RVM 1.26.11:

Environment:
  Redmine version                3.2.0.stable
  Ruby version                   2.1.5-p273 (2014-11-13) [i686-linux]
  Rails version                  4.2.5
  Environment                    production
  Database adapter               PostgreSQL
SCM:
  Git                            2.1.4
  Filesystem                     
  Xitolite                       2.1.4
Redmine plugins:
  redmine_bootstrap_kit          0.2.4
  redmine_git_hosting            1.2.0

I configured SSH and HTTPS access:

SSH server domain: forge.example.net
HTTPS server domain: forge.example.net
Subdirectory for HTTP access: git/
Enable Smart HTTP mode for new repositories by default?: HTTPS Only
Redmine has RW access on all Gitolite repositories: Yes
Directory and URL structure for Redmine-managed repositories: Hierarchical

In the "Config Test" tab of the plugin configuration interface, all items are green.

I created a project named "orekit" and a repository named "orekit-main". Therefore, the interface offers the following access url:

SSH: ssh://[email protected]/orekit/orekit-main.git
HTTPS: https://[email protected]/git/orekit/orekit-main.git

So, I tried to clone this repository through the two protocols:

SSH attempt with offered url:

$ git clone ssh://[email protected]/orekit/orekit-main.git
Cloning into 'orekit-main'...
remote: Counting objects: 51656, done.
remote: Compressing objects: 100% (11199/11199), done.
remote: Total 51656 (delta 31731), reused 51645 (delta 31725)
Receiving objects: 100% (51656/51656), 32.70 MiB | 11.26 MiB/s, done.
Resolving deltas: 100% (31731/31731), done.
Checking connectivity... done.

/opt/gitolite/.gitolite/logs/gitolite-2016-01.log:

2016-01-29.21:58:42     2767    ssh     ARGV=redmine_sdinot_10  SOC=git-upload-pack '/orekit/orekit-main.git'   FROM=192.168.0.12
2016-01-29.21:58:42     2767    pre_git orekit/orekit-main      redmine_sdinot_10       R       any     refs/.*
2016-01-29.21:58:42     2767            system,git,shell,-c,git-upload-pack '/opt/gitolite/repositories/orekit/orekit-main.git'
2016-01-29.21:58:45     2767    END

HTTPS attempt with offered url:

$ git clone https://[email protected]/git/orekit/orekit-main.git
Cloning into 'orekit-main'...
remote: Not Found
fatal: repository 'https://[email protected]/git/orekit/orekit-main.git/' not found

/var/log/apache2/forge.example.net.access_ssl.log:

192.168.0.12 - - [29/Jan/2016:22:01:16 +0100] "GET /git/orekit/orekit-main.git/info/refs?service=git-upload-pack HTTP/1.1" 404 1916 "-" "git/2.5.0"

/opt/redmine/current/log/redmine.log:

I, [2016-01-29T22:01:16.269120 #1235]  INFO -- : Started GET "/git/orekit/orekit-main.git/info/refs?service=git-upload-pack" for 192.168.0.12 at 2016-01-29 22:01:16 +0100

HTTPS attempt with alternative to offered url ("**/git/" was replaced by ":**git/"):

$ git clone https://[email protected]:git/orekit/orekit-main.git
Cloning into 'orekit-main'...
remote: Counting objects: 51656, done.
remote: Compressing objects: 100% (11199/11199), done.
remote: Total 51656 (delta 31731), reused 51645 (delta 31725)
Receiving objects: 100% (51656/51656), 32.70 MiB | 8.25 MiB/s, done.
Resolving deltas: 100% (31731/31731), done.
Checking connectivity... done.

/var/log/apache2/forge.example.net.access_ssl.log:

192.168.0.12 - - [29/Jan/2016:22:03:06 +0100] "GET /orekit/orekit-main.git/info/refs?service=git-upload-pack HTTP/1.1" 200 2324 "-" "git/2.5.0"
192.168.0.12 - - [29/Jan/2016:22:03:07 +0100] "POST /orekit/orekit-main.git/git-upload-pack HTTP/1.1" 200 35274723 "-" "git/2.5.0"

/opt/redmine/current/log/redmine.log:

I, [2016-01-29T22:03:06.766854 #1235]  INFO -- : Started GET "/orekit/orekit-main.git/info/refs?service=git-upload-pack" for 192.168.0.12 at 2016-01-29 22:03:06 +0100
I, [2016-01-29T22:03:07.149621 #1235]  INFO -- : Started POST "/orekit/orekit-main.git/git-upload-pack" for 192.168.0.12 at 2016-01-29 22:03:07 +0100

I don't understand that is wrong in the configuration. :(

Thanks in advance for your help!

@sdinot
Copy link
Author

sdinot commented Jan 29, 2016

URL https://[email protected]/orekit/orekit-main.git (without the "git/" subdirectory) works too!

@sdinot
Copy link
Author

sdinot commented Feb 2, 2016

Any idea? :(

Considering that the url "https://<host>/<project>/<repo>.git" works but not the url "https://<host>/git/<project>/<repo>.git", it is as though the value of "http_server_subdir" was not taken into account.

@n-rodriguez
Copy link
Contributor

Considering that the url "https:////.git" works but not the url "https:///git//.git", it is as though the value of "http_server_subdir" was not taken into account.

This sounds like a bug... I don't have time to take a look on it for now and for the month coming.

@n-rodriguez n-rodriguez self-assigned this Feb 9, 2016
@n-rodriguez n-rodriguez added the bug label Feb 9, 2016
@baby-gnu
Copy link

+1 I just figure out this issue

The problem is that I want to increase the client_max_body_size in my nginx configuration file, but just for ^/git/.

@baby-gnu
Copy link

baby-gnu commented Jul 8, 2016

This one is really annoying, I can not upgrade my plugin without breaking every user clone URLs 😕.

@sdinot
Copy link
Author

sdinot commented Aug 4, 2016

Any news? :(

I just reproduced the issue with an instance of the last released version of Redmine (3.3.0) using the last released version of the plugin (1.2.1):

Plugin configuration:

SSH server domain: forge.example.net
HTTP server domain: forge.example.net
HTTPS server domain: forge.example.net
Subdirectory for HTTP access: git/
Enable Smart HTTP mode for new repositories by default? HTTPS Only

Try:
$ git clone ssh://[email protected]/project/project-main.git
=> Success
$ git clone https://[email protected]/git/project/project-main.git
=> Fail, repository not found

But it works if I empty the "Subdirectory for HTTP access" field:

$ git clone https://[email protected]/project/project-main.git
=> Success

@baby-gnu
Copy link

baby-gnu commented Oct 4, 2016

Hello,

I'm trying to look at this issue, it may be related to the Grack route:

# Enable SmartHTTP Grack support
mount Grack::Bundle.new({}), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]

in 0.6.3 it was:

    # SMART HTTP
    match ':repo_path/*git_params', :prefix => GitHostingConf.http_server_subdir, :repo_path => /([^\/]+\/)*?[^\/]+\.git/, :to => 'smart_http#index'

in 0.7.10 it was:

  # SMART HTTP
  match ':repo_path/*git_params', :prefix    => RedmineGitolite::ConfigRedmine.get_setting(:http_server_subdir),
                                  :repo_path => /([^\/]+\/)*?[^\/]+\.git/,
                                  :to        => 'smart_http#index',
                                  :via       => [:get, :post]

I don't know how to express the :prefix used before with the mount :-/

Regards.

@baby-gnu
Copy link

baby-gnu commented Oct 5, 2016

According to rails documentation mounting with at make the rake application receive requests at the root path.

So I think we should start with:

mount Grack::Bundle.new({}),
      at: (RedmineGitHosting::Config.http_server_subdir rescue '/'),
      constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) },
      via: [:get, :post]

so Grack will always handle requests at the root path.

Unfortunately, this is not sufficient, now I have the following in my logs:

NoMethodError (undefined method `chomp' for true:TrueClass):
  plugins/redmine_git_hosting/lib/grack/auth.rb:44:in `auth!'
  plugins/redmine_git_hosting/lib/grack/auth.rb:22:in `call'

Regards.

@baby-gnu
Copy link

baby-gnu commented Oct 5, 2016

In log/git_hosting.log I have

2016-10-05 13:36:20 +0200 [ERROR] Problems while getting SmartHttp params

I changed debug logging to error in lib/redmine_git_hosting/utils/exec.rb and now I have:

2016-10-05 13:47:34 +0200 [ERROR] Non-zero exit code pid 11845 exit 1 for `sudo -n -u git -i env GL_LIBDIR=/home/git/bin/lib/ GL_REPO=testing GL_USER= git --git-dir repositories/testing.git config http.uploadpack`
2016-10-05 13:47:34 +0200 [ERROR] Problems while getting SmartHttp params

@baby-gnu
Copy link

Any idea?

@baby-gnu
Copy link

Replying to myself, I finally found the answer, as git user I need to do

git config --global http.uploadpack /usr/lib/git-core/git-upload-pack

I think the plugin should try to default on several PATHes.

@baby-gnu
Copy link

And to push you need:

git config --global http.receivepack /usr/lib/git-core/git-receive-pack

@baby-gnu
Copy link

Now I can clone with #621 and the global git configuration set for user git but I can't push, I have the following error:

remote: Not Found
fatal: repository 'https://[email protected]/git/sandbox.git/' not found

I see nothing in logs except:

  • production.log
Started GET "/git/sandbox.git/info/refs?service=git-receive-pack" for 194.167.18.244 at 2016-11-24 02:35:15 +0100
Started GET "/git/sandbox.git/info/refs?service=git-receive-pack" for 194.167.18.244 at 2016-11-24 02:35:16 +0100
Started GET "/git/sandbox.git/info/refs?service=git-receive-pack" for 194.167.18.244 at 2016-11-24 02:35:20 +0100
  • nginx.log
MY_IP - - [24/Nov/2016:02:35:16 +0100] "GET /git/sandbox.git/info/refs?service=git-receive-pack HTTP/1.1" 401 0 "-" "git/2.10.2"
MY_IP - dad [24/Nov/2016:02:35:16 +0100] "GET /git/sandbox.git/info/refs?service=git-receive-pack HTTP/1.1" 401 0 "-" "git/2.10.2"
MY_IP - dad [24/Nov/2016:02:35:21 +0100] "GET /git/sandbox.git/info/refs?service=git-receive-pack HTTP/1.1" 404 9 "-" "git/2.10.2"

So, redmine return a 404 but even in debug mode git_hosting.log contains nothing :-/

According to sudo logs the latest command run is update-server-info:

nov. 24 02:37:53 server sudo[10223]:  redmine : TTY=unknown ; PWD=/home/redmine/redmine-3.3.1 ; USER=git ; COMMAND=/bin/bash -c env GL_LIBDIR=/home/git/bin/lib/ GL_REPO=sandbox GL_USER=redmine_dad_17 git --git-dir repositories/sandbox.git update-server-info

Do you have any hints?

@baby-gnu
Copy link

I found the push issue, it's due to the way https://github.com/jbox-web/grack (v0.2) works compared to https://github.com/gitlabhq/grack (v2.0.2).

The problem comes from get_config_setting.

Your older version requires:

  • git config http.uploadpack to be different than false, which is true when you set the path /usr/lib/git-core/git-upload-pack
  • git config http.receivepack to be equal to true, which is false when you set the path /usr/lib/git-core/git-receive-pack

The new code of has_access check if this is a string with the corresponding service name in it.

So for now I must configure as the following:

git config --global http.uploadpack /usr/lib/git-core/git-upload-pack
git config --global http.receivepack true

@n-rodriguez
Copy link
Contributor

Many thanks baby-gnu! i owe you a pack!

@n-rodriguez
Copy link
Contributor

@baby-gnu :

About http.upload-pack : actually the code has not really changed before and after the refactoring :

Here get_config_setting (v0.x )
Here config_setting (v2.x )

And
Here has_access (v0.x )
Here has_access (v2.x )

The biggest issue here was the prefix not set in the routes.rb file.
But you must restart Redmine after the change (and also check that SmartHTTP is enabled for the repository)

@baby-gnu
Copy link

baby-gnu commented Jan 2, 2017

Thanks for the note, for now it's working with

git config --global http.uploadpack /usr/lib/git-core/git-upload-pack
git config --global http.receivepack true

I think the new code will requires

git config --global http.uploadpack /usr/lib/git-core/git-upload-pack
git config --global http.receivepack /usr/lib/git-core/git-receive-pack

Regards.

@n-rodriguez
Copy link
Contributor

Well, this is weird because I don't need this to make it works...

@ahmedosama80
Copy link

#658
my Redmine is running in sub URI is it can cause such problem

[ERROR] Problems while getting SmartHttp params

NoMethodError (undefined method chomp' for true:TrueClass): plugins/redmine_git_hosting/lib/grack/auth.rb:44:inauth!'
plugins/redmine_git_hosting/lib/grack/auth.rb:22:in `call'

@mnencia
Copy link

mnencia commented May 19, 2017

I've just updated my installation to a new environment and I've had to execute the following command to make https clone/push working again.

git config --global http.uploadpack /usr/lib/git-core/git-upload-pack

@mnencia
Copy link

mnencia commented May 25, 2017

I've finally found what happened in my Redmine installation. One of the user uploaded an invalid SSH key that was breaking the gitolite config compilation.

2017-05-25.14:53:28    11490        system,gitolite trigger POST_COMPILE
2017-05-25.14:53:28    11490        system,/srv/git/bin/triggers/post-compile/ssh-authkeys,POST_COMPILE
2017-05-25.14:53:28    11490    warn    Use of uninitialized value $output in scalar chomp at /srv/git/bin/lib/Gitolite/Common.pm line 352.<<newline>>
2017-05-25.14:53:28    11490    warn    Use of uninitialized value $output in pattern match (m//) at /srv/git/bin/lib/Gitolite/Common.pm line 357.<<newline>>
2017-05-25.14:53:28    11490    warn    Use of uninitialized value $output in pattern match (m//) at /srv/git/bin/lib/Gitolite/Common.pm line 357.<<newline>>
2017-05-25.14:53:28    11490    warn    Use of uninitialized value $output in concatenation (.) or string at /srv/git/bin/triggers/post-compile/ssh-authkeys line 116.<<newline>>
2017-05-25.14:53:28    11490    die    fingerprinting failed for 'keydir/redmine_git_hosting/redmine_<REDACTED>_306/redmine_<REDACTED>_306.pub':
2017-05-25.14:53:28    11490        system() failed,/srv/git/bin/triggers/post-compile/ssh-authkeys,POST_COMPILE,-> 6400
2017-05-25.14:53:28    11490        system() failed,gitolite trigger POST_COMPILE,-> 6400
2017-05-25.14:53:28    11490    END

As result of that, the new repositories where created, but without the necessary git configuration values.
Once I've removed the bad key everything started working again even without the global http.uploadpack setting.

@ayanbon
Copy link

ayanbon commented Jul 9, 2019

Hi i am having problem cloning repo on termux

@PowerKiKi
Copy link
Collaborator

As discussed in #732 (comment), issues related to Redmine < 4.0 or severely outdated issues are being closed to help clean up the issue tracker.

If this issue is still relevant to you and you are running Redmine >= 4.0, please open a new issue including all new relevant information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants