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 Schouten 2011-07-05 14:12:48 +00:00
parent 9acdfe6549
commit 21632754d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=223786

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);