3

I am trying to set up git in my server with smart http as the access mechanism. Due to some intergration problems we can not use any other mehtod and it has to be the http or the https methods.

So i followed a bunch of blogs/articles and managed to get the thing running.

However now even though clone and pull are working, the push operation is not working.

I have shared the relevant configs and the logs here.

Configs

Virtualhost apache

SetEnv GIT_PROJECT_ROOT /var/www/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /home/fsmk/domains/git.fsmk.org/cgi-bin/git-http-backend/
SetEnv REMOTE_USER=$REDIRECT_REMOTE_USER

<Directory "/usr/lib/git-core/">
  AllowOverride None
  Options +ExecCGI -Includes
  Order allow,deny
  Allow from all
</Directory>

<LocationMatch "^/git/.*$">
  AuthType Basic
  AuthName "Private Git Repositories on git.fsmk.org"
  AuthUserFile /etc/apache2/conf.d/git.passwd
  Require valid-user
</LocationMatch>

Suexec wrapper

#!/bin/bash
PATH_INFO=$SCRIPT_URL
export GIT_PROJECT_ROOT=/var/www/
export GIT_HTTP_EXPORT_ALL=true
/usr/lib/git-core/git-http-backend

Errors

Clone

This throws no errors. These are the apache access logs.

IP - - [05/Jun/2018:17:55:13 +0000] "GET /git/testrepo.git/info/refs?service=git-upload-pack HTTP/1.1" 401 610 "-" "git/2.17.1"
IP - TESTUSER [05/Jun/2018:17:55:29 +0000] "GET /git/testrepo.git/info/refs?service=git-upload-pack HTTP/1.1" 200 656 "-" "git/2.17.1"
IP - TESTUSER [05/Jun/2018:17:55:30 +0000] "POST /git/testrepo.git/git-upload-pack HTTP/1.1" 200 18662 "-" "git/2.17.1"

These are the git clone -v output on my client machine

Cloning into 'testrepo'&#x2026;
Username for 'http://git.fsmk.org': TESTUSER
Password for 'http://sohomPush@git.fsmk.org': 
Server supports multi<sub>ack</sub><sub>detailed</sub>
Server supports no-done
Server supports side-band-64k
Server supports ofs-delta
Server version is git/2.11.0
want 7c9a3fe7d59991e187ba99ee6e3ecb4fcb68d1be (refs/heads/master)
done
POST git-upload-pack (165 bytes)
remote: Counting objects: 55, done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 55 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (55/55), done.

Pull

No error on apache error log and suexec log. These are the apache access logs

IP- - [05/Jun/2018:17:58:29 +0000] "GET /git/testrepo.git/info/refs?service=git-upload-pack HTTP/1.1" 401 610 "-" "git/2.17.1"
IP - TESTUSER [05/Jun/2018:17:58:36 +0000] "GET /git/testrepo.git/info/refs?service=git-upload-pack HTTP/1.1" 200 656 "-" "git/2.17.1"

The output on the local client is also ordinary

Push (this is where the problem is)

No suexec error. These are the apache access logs.

IP - - [05/Jun/2018:18:03:51 +0000] "GET /git/testrepo.git/info/refs?service=git-receive-pack HTTP/1.1" 401 610 "-" "git/2.17.1"
IP - TESTUSER [05/Jun/2018:18:03:59 +0000] "GET /git/testrepo.git/info/refs?service=git-receive-pack HTTP/1.1" 200 539 "-" "git/2.17.1"

The pushing process hangs after POST line. This is the verbose push output on my client

Pushing to <http://git.fsmk.org/git/testrepo.git>
Username for 'http://git.fsmk.org': TESTUSER
Password for 'http://sohomPush@git.fsmk.org': 
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 240 bytes | 240.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0)
POST git-receive-pack (393 bytes)

(hangs)

This is what the apache error logs show after the push operation. It statys hanged indefinitely.

These are the apache error logs

[Tue Jun 05 18:09:00.134148 2018] [cgi:warn] [pid 5586] [client 45.124.158.238:51094] AH01220: Timeout waiting for output from CGI script /home/fsmk/domains/git.fsmk.org/cgi-bin/git-http-backend
[Tue Jun 05 18:09:00.134254 2018] [core:error] [pid 5586] (70007)The timeout specified has expired: [client IP:51094] AH00574: ap<sub>content</sub><sub>length</sub><sub>filter</sub>: apr<sub>bucket</sub><sub>read</sub>() failed

Note:

The change that I am pusing is very minimal. I just remove a file and commit it and push.

IP in the logs is a placeholder for my clients IP addess TESTUSER is the user that is being authenticated using htpasswd

Operaing System : Debian 9 (server), Arch (client)
Apache version : 2.4.5
Git vesion: 2.11.0 (server), 2.17.0 (client)

We are also using Virutalmin on the server.

Is there something I am missing on this problem ? Why is the push not working ?

Is there a better way to serve a single git repo over the internet using http/https ?

sohom154
  • 31
  • 3

1 Answers1

1

Chances are, git backend wasn't able to write to given directory, and then just hung (verify with ps -ef|grep git). This might have damaged the repo, so further pushes fail.

To make it work

1) entire directory tree has to be owned by git.www-data, and writable by group (chown -R git.www-data, chmod -R go+rw)

2) create empty repo (git init --bare) and then try to clone and push.

Yes, ssh is way better way to serve git repos.

jalmasi
  • 111
  • 2