In wall and who, check that the utmp entry isn't stalled, as it is done in w.
Apparently with the new pts code stalled entries are printed, when they are not with the BSD ptys. Submitted by: Michal Mertl <mime at traveller dot cz>
This commit is contained in:
parent
c15ff0bc7b
commit
b457a3e19c
@ -81,6 +81,19 @@ int nobanner;
|
||||
int mbufsize;
|
||||
char *mbuf;
|
||||
|
||||
static int
|
||||
ttystat(char *line, int sz)
|
||||
{
|
||||
struct stat sb;
|
||||
char ttybuf[MAXPATHLEN];
|
||||
|
||||
(void)snprintf(ttybuf, sizeof(ttybuf), "%s%.*s", _PATH_DEV, sz, line);
|
||||
if (stat(ttybuf, &sb) == 0) {
|
||||
return (0);
|
||||
} else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -140,6 +153,8 @@ main(int argc, char *argv[])
|
||||
while (fread((char *)&utmp, sizeof(utmp), 1, fp) == 1) {
|
||||
if (!utmp.ut_name[0])
|
||||
continue;
|
||||
if (ttystat(utmp.ut_line, UT_LINESIZE) != 0)
|
||||
continue;
|
||||
if (grouplist) {
|
||||
ingroup = 0;
|
||||
strlcpy(username, utmp.ut_name, sizeof(utmp.ut_name));
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
@ -203,14 +204,31 @@ row(struct utmp *ut)
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
static int
|
||||
ttystat(char *line, int sz)
|
||||
{
|
||||
struct stat sb;
|
||||
char ttybuf[MAXPATHLEN];
|
||||
|
||||
(void)snprintf(ttybuf, sizeof(ttybuf), "%s%.*s", _PATH_DEV, sz, line);
|
||||
if (stat(ttybuf, &sb) == 0) {
|
||||
return (0);
|
||||
} else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void
|
||||
process_utmp(FILE *fp)
|
||||
{
|
||||
struct utmp ut;
|
||||
|
||||
while (fread(&ut, sizeof(ut), 1, fp) == 1)
|
||||
if (*ut.ut_name != '\0')
|
||||
row(&ut);
|
||||
while (fread(&ut, sizeof(ut), 1, fp) == 1) {
|
||||
if (*ut.ut_name == '\0')
|
||||
continue;
|
||||
if (ttystat(ut.ut_line, UT_LINESIZE) != 0)
|
||||
continue;
|
||||
row(&ut);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user