Re: connection in time_wait owned by root

Peter Benie (pjb1008@cam.ac.uk)
Sat, 3 Apr 1999 13:33:07 +0100


Q writes ("connection in time_wait owned by root"):
> It seem that a connection which is in the time_wait state is owned by
> root. Is this normal? Why is it like that?

The information about who did own the socket has been lost so it can't
print the correct uid. Having said that, printing -1 for 'no uid' in
/proc/net/tcp would be more helpful than 0.

> identd seems to return root for a connection in that state. I wonder if
> it should return anything at all...

No, it shouldn't; it should return NO_USER if the connection is not
established. Here's a patch for identd.

--- pidentd-2.7b3/src/kernel/linux.c.orig Sat Apr 3 12:57:49 1999
+++ pidentd-2.7b3/src/kernel/linux.c Sat Apr 3 13:01:09 1999
@@ -14,6 +14,7 @@
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/tcp.h>
#include <arpa/inet.h>

int k_open()
@@ -31,6 +32,7 @@
char buf[512];
struct in_addr myladdr, myraddr;
int mylport, myrport;
+ int state;

fport = ntohs(fport);
lport = ntohs(lport);
@@ -49,10 +51,11 @@
{
if (sscanf(buf,"%d: %lX:%x %lX:%x %x %lX:%lX %x:%lX %lx %d",
&dummy, &myladdr, &mylport, &myraddr, &myrport,
- &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
+ &state, &dummy, &dummy, &dummy, &dummy, &dummy,
uid) == 12)
{
- if (myladdr.s_addr==laddr->s_addr && mylport==lport &&
+ if (state==TCP_ESTABLISHED &&
+ myladdr.s_addr==laddr->s_addr && mylport==lport &&
myraddr.s_addr==faddr->s_addr && myrport==fport)
{
fclose(fp);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/