if (!*argv) {
if (stat(tty, &sb))
err(MESG_EXIT_FAILURE, _("stat of %s failed"), tty);
+ if (!S_ISCHR(sb.st_mode))
+ errx(MESG_EXIT_FAILURE, _("%s: not a character device"), tty);
if (sb.st_mode & (S_IWGRP | S_IWOTH)) {
puts(_("is y"));
return IS_ALLOWED;
err(MESG_EXIT_FAILURE, _("cannot open %s"), tty);
if (fstat(fd, &sb))
err(MESG_EXIT_FAILURE, _("stat of %s failed"), tty);
+ if (!S_ISCHR(sb.st_mode))
+ errx(MESG_EXIT_FAILURE, _("%s: not a character device"), tty);
switch (rpmatch(argv[0])) {
case RPMATCH_YES:
warn("%s", tty);
return 1;
}
+ if (!S_ISCHR(s.st_mode)) {
+ if (showerror)
+ warnx(_("%s: not a character device"), tty);
+ return 1;
+ }
if (getuid() == 0) /* root can always write */
*tty_writeable = 1;
else {