Commit Graph

90 Commits

Author SHA1 Message Date
kim
ad1ced00f0 Skip bracket processing if -n is used.
XXX: This could be improved to skip even more processing.
2020-08-01 17:53:38 +00:00
kim
45dca81a3d Restore ']' if not using a result from an address lookup. 2020-08-01 17:25:57 +00:00
kim
56befb6279 Handle hostname from DISPLAY="[2001:db8::dead:beef]:0" or similar. 2020-08-01 15:52:50 +00:00
kim
fb2e468db8 Don't overwrite host_buf as x might be pointing to wanted data in it 2020-07-04 23:30:31 +00:00
kim
f61899471d Remove local domain always, not just when looking up addresses 2020-06-30 15:02:55 +00:00
kim
98df278e6f Compute a value for domain before comparing against it 2020-06-30 14:57:25 +00:00
kre
d4305dc776 sysctl(KERN_BOPOTIME) started returning a struct timespec in 2009.
Update to match....    We're slow but we get there eventually!

NFC for any of these programs, struct timeval and struct timespec
are the same size, and only the tv_sec field of boottime is used,
and that's unchanged.
2018-10-30 21:15:09 +00:00
christos
83aa60eb00 if there is more than one : it is not an X display, it is a v6 address 2016-11-16 02:03:30 +00:00
dennis
61933bb52e Move enough additional 'w' code into 'uptime' to keep the latter
from double-counting utmp users.
2014-12-22 15:24:14 +00:00
mrg
4023260255 redo the previous; avoid a bunch of processing when running as "uptime",
and as a side effect, avoid any name lookups.
2014-12-03 06:12:19 +00:00
christos
3f1eb4e425 if doing uptime, don't bother resolving names. 2014-12-02 22:19:19 +00:00
joerg
a400a0406f struct member can't be null, if the pointer itself is valid. 2014-02-27 00:49:46 +00:00
dsl
dc210c7fbd Remove some pointless inclusions os sys/user.h 2014-02-19 20:42:14 +00:00
christos
f812b4b441 Expand ep->host to contain the final string that we are going to print
before computing the width of the host column.
2013-09-09 19:20:38 +00:00
christos
924cacedb8 Remove stale proc_compare code and use the shared one in libutil. 2011-10-21 02:26:09 +00:00
joerg
6818646ac8 Use __dead 2011-09-16 15:39:25 +00:00
lukem
c53da74354 Fix WARNS=4 issues 2009-04-14 07:37:31 +00:00
lukem
98e5374ccb Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
2008-07-21 14:19:20 +00:00
christos
aca1acfb3f Use the UTX sizes + 1 for the struct to save space.
Don't complain if pid == 0
2006-06-22 17:57:31 +00:00
rpaulo
caaefabc19 Don't print a warning about stale utmp{,x} entries if security.curtain
sysctl is equal to 1. We can still detect stale utmp entries if that
knob is off.
2005-09-15 00:58:49 +00:00
elad
cf3a38f563 Revert previous commit. I forgot we already do that. :) 2005-09-04 21:18:33 +00:00
elad
e93911118f Use sysctl to fetch process information if reading live kernel. 2005-09-04 19:02:08 +00:00
kim
077ff6605b One third of screen looks much better than half, for default maxhost. 2005-03-13 04:08:16 +00:00
kim
61f9450361 Make -w flag apply to the WHAT field also (command and args).
Use at most half of ttywidth for WHERE field (hostname) instead
of a hardcoded maximum width.  (XXX: this is still not a good
default for displays under 80 columns.  Should probably count
the width of all the other columns, using 8 for the WHAT field.)
2005-01-08 05:08:53 +00:00
christos
25c67c975f Fix usage, and call setprogname()! 2004-12-22 17:20:30 +00:00
christos
5df4136a03 PR/28751: Ed Ravin: Limit host field output by default to 35 characters so
that things don't wrap. Add -w flag to enable full output. Delete mention
of the old and not supported flags. This was 11 years ago, and very few
people even remember what these flags did.
2004-12-22 17:16:07 +00:00
christos
6b2a6f8a02 Be a bit more careful with errors; if you cannot find the pty to stat for
time, then report ? instead of the previous random contents of struct stat.
2004-11-19 13:17:06 +00:00
christos
280dbafe67 PR/28185: Brian Marcotte: w command broken when user specified 2004-11-11 00:09:07 +00:00
christos
c7ead5d42d Don't print just two characters for the tty; change the field width of the
tty to 7.
2004-11-10 16:58:10 +00:00
wiz
9b45ab8153 Remove superfluous max() macro.
Noted by Jeff Ito in PR 23932.
2004-01-03 01:18:14 +00:00
agc
89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
itojun
28f506f3a2 strlcpy 2003-07-12 13:57:49 +00:00
christos
0d2dc54013 keep track of the two proc entries significant to the utmp entry. The one
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.
2003-02-26 19:10:28 +00:00
fredb
1709947012 Print the command in parenthesis, if kvm_getargv2() returns no
arguments. This lets "xterm -e command" display as "(command)".
Reviewed by christos.
2003-02-26 19:01:54 +00:00
christos
8399be1bba keep track which entries are utmp and which are utmpx, so we can print
them on the stale message.
2003-02-26 15:04:10 +00:00
christos
c7d4de107a - Remove SUPPORT_FTPD_UTMP flag. Enable it only for utmp entries, utmpx does
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.
2003-02-26 15:01:09 +00:00
enami
b579228888 Fix whitespace usage. 2002-10-21 10:18:23 +00:00
enami
f594d61275 If utmpx support is enabled, use sockaddr field to get numeric address. 2002-10-21 10:10:26 +00:00
christos
b3ac19283d Make uptime show the correct number of users. 2002-09-16 04:02:21 +00:00
mycroft
2f85ba247c uptime(1) is NOT supposed to always say `1 user'. 2002-09-16 01:49:06 +00:00
christos
52f955bcfd fixed user miscounting. reported by kim. 2002-08-22 14:52:55 +00:00
christos
156b33bc4e skip blank entries. 2002-07-28 20:47:57 +00:00
christos
1e703dc185 add utmpx support. 2002-07-27 23:58:40 +00:00
enami
f7a77f5cca Fix whitespace usage. 2001-11-05 03:35:49 +00:00
cgd
a8ec668ddf convert to use getprogname() 2001-02-19 23:03:42 +00:00
mjl
3d418a4a73 ANSIfy. 2001-01-05 04:59:21 +00:00
mjl
96015e4766 (From FreeBSD)
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.
2001-01-05 04:54:53 +00:00
cgd
2af1e46eab __CONCAT does token pasting, not string concatnation. if something like:
__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.
2000-12-20 01:17:49 +00:00
jdolecek
f8031c2d6d add code to recognize special ftpd utmp entries and match corresponding
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.
2000-09-28 18:20:29 +00:00
christos
2120a34cd6 - Don't core dump when we have stale utmp entries; warn the user instead.
- Make this work again in single user when invoked as uptime and utmp is
  not present.
2000-08-21 00:19:06 +00:00