简体   繁体   中英

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

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, eg:

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM