git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [2/3] git-daemon: use getnameinfo to resolve hostname

From
JEJan Engelhardt <jengelh@medozas.de>
Date
Jan 14, 2009, 19:25 UTC
Message-ID
<alpine.LSU.2.00.0901142014380.24672@fbirervta.pbzchgretzou.qr>
In-Reply-To
<20090114122536.GA5939@coredump.intra.peff.net>
On Wednesday 2009-01-14 13:25, Jeff King wrote:
Show 13 quoted lines
>On Wed, Jan 14, 2009 at 11:48:38AM +0100, Jan Engelhardt wrote:
>
>> This is much shorter than inet_ntop'ing, and also translated
>> unresolvable addresses into a string.
>
>Er, doesn't this totally change the meaning of REMOTE_ADDR from an IP
>address to a hostname? That seems bad because:
>[...]
>  - people already have hooks that compare REMOTE_ADDR against an
>    address, so we are breaking their hooks
>[...]
>So at the very least, you should be adding REMOTE_HOST in _addition_ to
>REMOTE_ADDR, not instead of.

Good catch. It's always good to have someone else look through it. Changed, and below is the proposition as a non-mergable diff.

In case getnameinfo fails, the IP address from inet_ntop should be left in addrbuf, is not it?

And yeah, it does not have a flag to disable DNS resolution, but it's a draft for now.

---8<--- git-daemon: resolve source host's DNS

Try to resolve DNS addresses so that run_service() can print the name of the host from which the request originated. [addrbuf is passed to run_service as a result of patch 1/3]

---
 daemon.c |    4 ++++
 1 file changed, 4 insertions(+)
Index: git-1.6.1/daemon.c
===================================================================
--- git-1.6.1.orig/daemon.c
+++ git-1.6.1/daemon.c
@@ -530,6 +530,10 @@ static int execute(struct sockaddr *addr
 #endif
 		}
 		setenv("REMOTE_ADDR", addrbuf, 1);
+		getnameinfo(addr, (addr->sa_family == AF_INET6) ?
+			sizeof(struct sockaddr_in6) :
+			sizeof(struct sockaddr_in),
+			addrbuf, sizeof(addrbuf), NULL, 0, 0);
 	}
 	else {
 		unsetenv("REMOTE_ADDR");
Previous: Jay SoffianNext: Junio C Hamano
Message 11 of 13 in “git-daemon: single-line logs”
  1. 1/3 git-daemon: single-line logsJan Engelhardt, Jan 14, 2009
  2. 2/3 git-daemon: use getnameinfo to resolve hostnameJan Engelhardt, Jan 14, 2009
  3. 3/3 git-daemon: vhost supportJan Engelhardt, Jan 14, 2009
  4. Junio C HamanoJan 14, 2009
  5. Jan EngelhardtJan 14, 2009
  6. Junio C HamanoJan 14, 2009
  7. Jan EngelhardtJan 14, 2009
  8. Jeff KingJan 14, 2009
  9. Adeodato SimóJan 14, 2009
  10. Jay SoffianJan 14, 2009
  11. Jan EngelhardtJan 14, 2009
  12. Junio C HamanoJan 14, 2009
  13. Jan EngelhardtJan 14, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.