usr.bin/who.c: Fix boot time checking

The boot time entry doesn't have a tty specified, so don't check it.
While here, make ttystat handle that case.

Approved by:	kevans (src)
Differential Revision:	https://reviews.freebsd.org/D34524
This commit is contained in:
Steve Wills 2022-03-12 11:48:24 -05:00
parent 5fc3cc2713
commit db11c57a6c

View File

@ -216,6 +216,8 @@ ttystat(char *line)
struct stat sb;
char ttybuf[MAXPATHLEN];
if (line == NULL)
return (0);
(void)snprintf(ttybuf, sizeof(ttybuf), "%s%s", _PATH_DEV, line);
if (stat(ttybuf, &sb) == 0) {
return (0);
@ -229,10 +231,11 @@ process_utmp(void)
struct utmpx *utx;
while ((utx = getutxent()) != NULL) {
if (((aflag || !bflag) && utx->ut_type == USER_PROCESS) ||
(bflag && utx->ut_type == BOOT_TIME))
if ((aflag || !bflag) && utx->ut_type == USER_PROCESS) {
if (ttystat(utx->ut_line) == 0)
row(utx);
} else if (bflag && utx->ut_type == BOOT_TIME)
row(utx);
}
}