w and hidepid=2 option for procfs
Currently, 'w' does not work correctly for the non-root users if procfs is mounted with hidepid=2 option (i.e., if other users' processes are invisible to the user, which may be desirable for security reasons).
I checked that on RHEL-like systems with kernel 3.10.x on x86_64.
To reproduce the issue, one can set hidepid=2 for /proc in /etc/fstab and log in to the system via SSH (as a non-root user), then run 'w'. 'w' shows nothing about the user's processes in this case.
As far as I can see, this is because of the check for the stale info. 'w' tries to find the login process for a given user. If it fails, it considers the info abount that user's processes stale and reports nothing about these.
However, the login process ('sshd: username [priv]') is still owned by root in this case and is therefore invisible to the user. So 'w' considers all the user's processes stale and ignores these.
How critical is the issue with the stale info anyway? What if we just remove the check for that (like this: eshatokhin/procps@091c4d50).
With that patch, 'w' seems to work OK.