how does fuser report on sockets as non-root user?

1k views Asked by At

I'm trying to use fuser to find the pids of processes I own which have certain TCP ports open.

In the fuser man page it says:

... The most common time this problem occurs is when looking for TCP or UDP sockets when running fuser as a non-root user. In this case fuser will report no access. ...

However, on my Ubuntu box, fuser does report sockets open for processes that I own, e.g.:

perl -MIO::Socket 'IO::Socket::INET->new(Listen => 10, LocalPort => 3000)' &

fuser -n tcp 3000

Question: how are things set up to allow this to happen? Is it a kernel config option?

Thanks!

Note: the question is: how are some linux distros configured so that fuser will report processes owning sockets when fuser is run as a normal user? One one Ubuntu distro "fuser -n tcp 3000" will report a process if I own the process, yet on another linux distro (I think Centos) it won't report the process even if I own it.

1

There are 1 answers

2
Nikolai Fetissov On

fuser goes through the /proc file system (proc(5)) working through the /proc/[pid]/fd/ directory and checking the file descriptors. Processes owned by you have corresponding /proc entries again owned by you. This allows you to check your processes, but not others.

One very useful tool to see what given program is doing is strace(1). For example, you can see what system calls, and with what arguments, are done by the fuser:

~$ strace fuser -n tcp 3000