indicated by the pid in struct utmpx [or ftpd hack], and the one that is
associated with the controlling tty, is in the foreground process group,
and has most cpu. If the second one exists, use that one, else use the first
one.
not need it since it can get the pid from the utmpx structure.
- If the line is not found, and the pid is present (from utmpx) use that to
determine the process information for that particular entry.
Get things right for tty names of length UT_LINESIZE. (FreeBSD PR 3638)
If the utmp login time is greater than the tty atime, use it to calculate
the idle time instead of the atime.
Fix -n with 16-chars hostnames (FreeBSD PR 11286).
Domain names are case insensitive.
__CONCAT("foo","bar");
actually works to concantate strings, it's because the preprocessor expands
it into "foo""bar" as separate strings, and then ANSI string concatenation
is performed on that. It's more straightforward to just use ANSI string
concatenation directly, and newer GCCs complain (rightly) about misuse
of token pasting.
process accordingly, so that w parses entries made by "ftpd -U" correctly
the new code is conditionalized upon define SUPPORT_FTPD_UTMP, turned
on by default in w(1)'s Makefile
This addresses bin/11095 by Daniel Hagerty.
- Fix the number of colmuns left for proc. args. Previously, an effect of
NUL was canceled implicitly, but now we must handle it explicitly.
- Fix the width for tty name.
and the top, and then set the effective gid back to kmem around the call to
kvm_openfiles(). this reduces the time group kmem is available.
- for those above that also allow this, setgid(getgid()) after the call to
kvm_openfiles() to fully revoke priviledges.
- some KNF
- use err(3) over fprintf(3) in some places
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
If there is a non-tty entry in utmp, w(1) will exit with an error.
However there are legitimate non-tty entries, for instance an xlogin via
xdm can be identified with the xlogin program. In this case there is an
entry with the display name as the ut_tty.