diff options
author | ed <ed@FreeBSD.org> | 2010-01-04 20:59:52 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2010-01-04 20:59:52 +0000 |
commit | 74b0526bbe6326adb72e26dabfe79ab1fe00ca4b (patch) | |
tree | 1eba0ba44627857020e0992392e2861b5b457b44 | |
parent | 40024ff7c3bf948cb45283aec877bd552ee934d7 (diff) | |
download | FreeBSD-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
-rw-r--r-- | sys/kern/tty.c | 22 | ||||
-rw-r--r-- | sys/kern/tty_compat.c | 10 | ||||
-rw-r--r-- | sys/kern/tty_pts.c | 2 | ||||
-rw-r--r-- | sys/sys/tty.h | 5 |
4 files changed, 26 insertions, 13 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); } diff --git a/sys/kern/tty_compat.c b/sys/kern/tty_compat.c index 00764b8..6dce01d 100644 --- a/sys/kern/tty_compat.c +++ b/sys/kern/tty_compat.c @@ -180,7 +180,8 @@ ttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) /*ARGSUSED*/ int -tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, struct thread *td) +tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, int fflag, + struct thread *td) { switch (com) { case TIOCSETP: @@ -196,7 +197,7 @@ tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, struct thread *td) term = tp->t_termios; if ((error = ttsetcompat(tp, &com, data, &term)) != 0) return error; - return tty_ioctl(tp, com, &term, td); + return tty_ioctl(tp, com, &term, fflag, td); } case TIOCGETP: { struct sgttyb *sg = (struct sgttyb *)data; @@ -255,12 +256,13 @@ tty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, struct thread *td) int ldisczero = 0; return (tty_ioctl(tp, TIOCSETD, - *(int *)data == 2 ? (caddr_t)&ldisczero : data, td)); + *(int *)data == 2 ? (caddr_t)&ldisczero : data, + fflag, td)); } case OTIOCCONS: *(int *)data = 1; - return (tty_ioctl(tp, TIOCCONS, data, td)); + return (tty_ioctl(tp, TIOCCONS, data, fflag, td)); default: return (ENOIOCTL); diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 26946f5..632175b 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -379,7 +379,7 @@ ptsdev_ioctl(struct file *fp, u_long cmd, void *data, /* Just redirect this ioctl to the slave device. */ tty_lock(tp); - error = tty_ioctl(tp, cmd, data, td); + error = tty_ioctl(tp, cmd, data, fp->f_flag, td); tty_unlock(tp); if (error == ENOIOCTL) error = ENOTTY; diff --git a/sys/sys/tty.h b/sys/sys/tty.h index b60de6f..c594e11 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -182,9 +182,10 @@ void tty_wakeup(struct tty *tp, int flags); int tty_checkoutq(struct tty *tp); int tty_putchar(struct tty *tp, char c); -int tty_ioctl(struct tty *tp, u_long cmd, void *data, struct thread *td); -int tty_ioctl_compat(struct tty *tp, u_long cmd, caddr_t data, +int tty_ioctl(struct tty *tp, u_long cmd, void *data, int fflag, struct thread *td); +int tty_ioctl_compat(struct tty *tp, u_long cmd, caddr_t data, + int fflag, struct thread *td); void tty_init_console(struct tty *tp, speed_t speed); void tty_flush(struct tty *tp, int flags); void tty_hiwat_in_block(struct tty *tp); |