git-daemon: set REMOTE_ADDR to client address
This allows hooks like pre-receive to look at the client's IP address. Of course the IP address can't be used to get strong security; git-daemon isn't the right thing to use if you need that. However, basic IP address checking can be good enough in some situations. REMOTE_ADDR is the same environment variable used to communicate the client's address to CGI scripts. Signed-off-by: Joey Hess <joey@kitenet.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Joey Hess committed
Oct 24, 2008 at 01:48 UTC
53ffb878a94c3eae7c7f57e05568aedcfb77e57f
2 files changed
+13
Documentation/git-daemon.txt
+9
@@ -270,6 +270,15 @@ selectively enable/disable services per repository::
270
----------------------------------------------------------------
271
272
273
+ENVIRONMENT
274
+-----------
275
+'git-daemon' will set REMOTE_ADDR to the IP address of the client
276
+that connected to it, if the IP address is available. REMOTE_ADDR will
277
+be available in the environment of hooks called when
278
+services are performed.
279
+
280
+
281
+
282
Author
283
------
284
Written by Linus Torvalds <torvalds@osdl.org>, YOSHIFUJI Hideaki
daemon.c
+4
@@ -537,6 +537,10 @@ static int execute(struct sockaddr *addr)
537
#endif
538
}
539
loginfo("Connection from %s:%d", addrbuf, port);
540
+ setenv("REMOTE_ADDR", addrbuf, 1);
541
+ }
542
+ else {
543
+ unsetenv("REMOTE_ADDR");
544
}
545
546
alarm(init_timeout ? init_timeout : timeout);