summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-01-04 20:59:52 +0000
committered <ed@FreeBSD.org>2010-01-04 20:59:52 +0000
commit74b0526bbe6326adb72e26dabfe79ab1fe00ca4b (patch)
tree1eba0ba44627857020e0992392e2861b5b457b44 /sys/kern/tty.c
parent40024ff7c3bf948cb45283aec877bd552ee934d7 (diff)
downloadFreeBSD-src-74b0526bbe6326adb72e26dabfe79ab1fe00ca4b.zip
FreeBSD-src-74b0526bbe6326adb72e26dabfe79ab1fe00ca4b.tar.gz
Make TIOCSTI work again.
It looks like I didn't implement this when I imported MPSAFE TTY. Applications like mail(1) still use this. I think it's conceptually bad. Tested by: Pete French <petefrench ticketswitch com> MFC after: 2 weeks
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 05b8a37..1928c1f 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -505,12 +505,12 @@ ttydev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
case TIOCSPGRP:
case TIOCSTART:
case TIOCSTAT:
+ case TIOCSTI:
case TIOCSTOP:
case TIOCSWINSZ:
#if 0
case TIOCSDRAINWAIT:
case TIOCSETD:
- case TIOCSTI:
#endif
#ifdef COMPAT_43TTY
case TIOCLBIC:
@@ -559,7 +559,7 @@ ttydev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
new->c_ospeed = old->c_ospeed;
}
- error = tty_ioctl(tp, cmd, data, td);
+ error = tty_ioctl(tp, cmd, data, fflag, td);
done: tty_unlock(tp);
return (error);
@@ -1350,7 +1350,8 @@ tty_flush(struct tty *tp, int flags)
}
static int
-tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
+tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
+ struct thread *td)
{
int error;
@@ -1677,17 +1678,26 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
case TIOCSTAT:
tty_info(tp);
return (0);
+ case TIOCSTI:
+ if ((fflag & FREAD) == 0 && priv_check(td, PRIV_TTY_STI))
+ return (EPERM);
+ if (!tty_is_ctty(tp, td->td_proc) &&
+ priv_check(td, PRIV_TTY_STI))
+ return (EACCES);
+ ttydisc_rint(tp, *(char *)data, 0);
+ ttydisc_rint_done(tp);
+ return (0);
}
#ifdef COMPAT_43TTY
- return tty_ioctl_compat(tp, cmd, data, td);
+ return tty_ioctl_compat(tp, cmd, data, fflag, td);
#else /* !COMPAT_43TTY */
return (ENOIOCTL);
#endif /* COMPAT_43TTY */
}
int
-tty_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
+tty_ioctl(struct tty *tp, u_long cmd, void *data, int fflag, struct thread *td)
{
int error;
@@ -1698,7 +1708,7 @@ tty_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td)
error = ttydevsw_ioctl(tp, cmd, data, td);
if (error == ENOIOCTL)
- error = tty_generic_ioctl(tp, cmd, data, td);
+ error = tty_generic_ioctl(tp, cmd, data, fflag, td);
return (error);
}
OpenPOWER on IntegriCloud