提交 53ffb878 编写于 作者: J Joey Hess 提交者: Junio C Hamano

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: NJoey Hess <joey@kitenet.net>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 759ad19e
......@@ -270,6 +270,15 @@ selectively enable/disable services per repository::
----------------------------------------------------------------
ENVIRONMENT
-----------
'git-daemon' will set REMOTE_ADDR to the IP address of the client
that connected to it, if the IP address is available. REMOTE_ADDR will
be available in the environment of hooks called when
services are performed.
Author
------
Written by Linus Torvalds <torvalds@osdl.org>, YOSHIFUJI Hideaki
......
......@@ -537,6 +537,10 @@ static int execute(struct sockaddr *addr)
#endif
}
loginfo("Connection from %s:%d", addrbuf, port);
setenv("REMOTE_ADDR", addrbuf, 1);
}
else {
unsetenv("REMOTE_ADDR");
}
alarm(init_timeout ? init_timeout : timeout);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册