Re: [PATCH v4 11/15] daemon: report connection from root-process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Oct 17, 2010 at 6:43 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Erik Faye-Lund <kusmabite@xxxxxxxxx> writes:
>
>>> Hmm, loginfo() calls logreport() and adds the process information as
>>> necessary to the output.  Wouldn't this patch give the pid information
>>> twice?
>>>
>>
>> Close, but not quite. logreport() reports the current PID, while this
>> call to loginfo reports the PID of the child process. So two
>> non-identical PIDs are reported.
>
> I know that; I was questioning if that change to the log output is really
> what we want.  I do not deeply care myself, but people with scripts that
> read logs might.
>

I could do something like this, but then we lose the port information.
Perhaps I could add a REMOTE_PORT environment variable to solve that?

diff --git a/daemon.c b/daemon.c
index 589bd04..3d18899 100644
--- a/daemon.c
+++ b/daemon.c
@@ -522,6 +522,10 @@ static int execute(void)
 {
 	static char line[1000];
 	int pktlen, len, i;
+	char *addr = getenv("REMOTE_ADDR");
+
+	if (addr)
+		loginfo("Connection from %s", addr);

 	alarm(init_timeout ? init_timeout : timeout);
 	pktlen = packet_read_line(0, line, sizeof(line));
@@ -702,11 +706,8 @@ static void handle(int incoming, struct sockaddr
*addr, socklen_t addrlen)

 	if (start_command(&cld))
 		logerror("unable to fork");
-	else {
-		loginfo("[%"PRIuMAX"] Connection from %s:%d",
-		    (uintmax_t)cld.pid, addrstr, port);
+	else
 		add_child(&cld, addr, addrlen);
-	}
 	close(incoming);
 }
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]