git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git_inetd_server: run git-http-backend using inetd
@ 2014-07-17 21:28 Kyle J. McKay
  2014-07-17 22:10 ` Jonathan Nieder
  0 siblings, 1 reply; 13+ messages in thread
From: Kyle J. McKay @ 2014-07-17 21:28 UTC (permalink / raw)
  To: Git mailing list

===========
What is it?
===========
I have created a script (POSIX sh compatible) that allows running git- 
http-backend via inetd or similar service (it makes it like git-http- 
backend had a --inet option just like git-daemon does).

This allows the Git smart HTTP protocol to be served without needing  
to run a standard web server (assuming inetd, xinetd, launchd or  
similar is already available).

It is available at [1] with a GPL license.

====
Why?
====
I have several machines/virtual machines that need to be able to fetch  
from a central Git repository without authentication (several of them  
are test platforms and are therefore not trusted and typing a password  
on every fetch is a non-starter as some of the fetches are  
automated).  I also don't want to have to run a web server just to  
serve Git fetches.

Of course you say, "why not use git daemon for that?"  Well, I was (in  
--inetd mode), but it has a serious problem and until recently I  
didn't know the cause.

Talking to a git-daemon server works great for my FreeBSD, Darwin,  
cygwin, msysgit platforms, but it's terrible for my Linux platforms.

On the Linux platforms every git fetch would hang for at least 15  
seconds before starting the fetch.  I just wrote that off as some odd  
configuration issue I was going to have to live with (although it only  
happened with Git and not web browsing or curl fetches).  It's killer  
though when fetching a project with lots of submodules as each one has  
the delay.

Recently though, I discovered the cause.  While I don't actually run  
Debian itself, all my Linux platforms are Debian offspring (Ubuntu,  
Raspbian, Linux Mint, etc.).  The problem is in the Debian git package  
[2] specifically the "0010-transport-optionally-honor-DNS-SRV- 
records.diff" patch located in the Debian diffs file [3].

The 0010 patch makes "git://host/..." fetches first try to fetch a git  
SRV record from DNS.  This patch has a compile time option to enable  
it, but once baked in it cannot be turned off at runtime and the  
binary packages for my distributions all have it turned on and baked  
in.  And none of these distributions have a visible "WARNING: Git has  
patches that may cause it to behave oddly, violate RFC standards and/ 
or experience unexpected delays."

It so happens that my internal network is setup using mDNS [4] (on  
Linux/FreeBSD by installing Avahi and nss-mdns packages).

When I then try to fetch using a "git://host/..." URL where "host" is  
an mDNS host name, the 0010 patch causes git to attempt to lookup a  
DNS SRV record on the non-mDNS regular DNS service (a violation of RFC  
6762 [4] section 22) and this is what has to time out before the real  
fetch can start.

Since the patch does not try to lookup an SRV record for "http:// 
host/..." URLs, switching from git: to http: for fetches eliminates  
the problem.  However, git-http-backend does not have any of the -- 
daemon or --inetd related options that git-daemon does.  Hence the  
git_inetd_server.sh script [1] that provides the equivalent of a -- 
inetd option for git-http-backend.

I have since discovered that the 0010 patch behavior can be bypassed  
by explicitly including a port number in the git: URLs.  So instead of  
"git://example.local/repo.git" using "git://example.local:9418/ 
repo.git" avoids the delaying SRV lookup.  This is highly unintuitive  
since omitting the default port for a scheme should not change its  
behavior (according to RFC 3986 [5] section 3.2.3 the port should be  
omitted by producers and normalizers if it's the same as the scheme's  
default port).  In any case, unless git_inetd_server.sh can be run on  
the default http port (80), the resulting http: URLs are no more  
convenient than the git: URLs with an explicit port.

Nonetheless, others may find this script helpful as it allows the Git  
smart (and non-smart) HTTP protocol to be served without needing to  
run a standard web server so I decided to share it.

--Kyle

=====
Links
=====
[1] https://github.com/mackyle/git_inetd_server
[2] https://packages.debian.org/wheezy/git
[3] http://ftp.de.debian.org/debian/pool/main/g/git/git_1.7.10.4-1+wheezy1.diff.gz
[4] RFC 6762 http://tools.ietf.org/html/rfc6762
[5] RFC 3986 http://tools.ietf.org/html/rfc3986

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-07-20 15:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-17 21:28 git_inetd_server: run git-http-backend using inetd Kyle J. McKay
2014-07-17 22:10 ` Jonathan Nieder
2014-07-17 23:38   ` Kyle J. McKay
2014-07-18  2:22     ` Jonathan Nieder
2014-07-18  6:48       ` Kyle J. McKay
2014-07-18 17:16         ` Jonathan Nieder
2014-07-19  0:08           ` Kyle J. McKay
2014-07-19  0:19             ` Jonathan Nieder
2014-07-19  1:54               ` Kyle J. McKay
2014-07-19  6:21   ` Torsten Bögershausen
2014-07-19 17:06     ` Jonathan Nieder
2014-07-20  6:10       ` Torsten Bögershausen
2014-07-20 15:25         ` Torsten Bögershausen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).