Only print entries for which ut_host points to a character device.

Now that we use utmpx, we more often have entries for which the ut_line
is left blank. To prevent us from returning struct stat for "/dev/",
check that the resulting stat structure belongs to a character device.
This commit is contained in:
ed 2011-07-05 14:12:48 +00:00
parent 6abbb93d5f
commit 384aa0c696

View File

@ -497,7 +497,7 @@ ttystat(char *line)
char ttybuf[MAXPATHLEN];
(void)snprintf(ttybuf, sizeof(ttybuf), "%s%s", _PATH_DEV, line);
if (stat(ttybuf, &sb) == 0) {
if (stat(ttybuf, &sb) == 0 && S_ISCHR(sb.st_mode)) {
return (&sb);
} else
return (NULL);