diff options
author | ru <ru@FreeBSD.org> | 2002-04-03 10:56:59 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2002-04-03 10:56:59 +0000 |
commit | d8ffece3c4280cbeb3cd3b6334f604b16e0e6c66 (patch) | |
tree | 9b447dfa6bfea969fc320cd5c13abf0255b96726 /sys/kern/tty.c | |
parent | 0dbbe50955903ed143bea85061e98780e7fb4da4 (diff) | |
download | FreeBSD-src-d8ffece3c4280cbeb3cd3b6334f604b16e0e6c66.zip FreeBSD-src-d8ffece3c4280cbeb3cd3b6334f604b16e0e6c66.tar.gz |
Dike out a highly insecure UCONSOLE option.
TIOCCONS must be able to VOP_ACCESS() /dev/console to succeed.
Obtained from: OpenBSD
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r-- | sys/kern/tty.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 3b7739d..b698977 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -68,13 +68,13 @@ */ #include "opt_compat.h" -#include "opt_uconsole.h" #include <sys/param.h> #include <sys/systm.h> #include <sys/filio.h> #include <sys/lock.h> #include <sys/mutex.h> +#include <sys/namei.h> #include <sys/sx.h> #if defined(COMPAT_43) || defined(COMPAT_SUNOS) #include <sys/ioctl_compat.h> @@ -849,13 +849,23 @@ ttioctl(tp, cmd, data, flag) } case TIOCCONS: /* become virtual console */ if (*(int *)data) { + struct nameidata nid; + if (constty && constty != tp && ISSET(constty->t_state, TS_CONNECTED)) return (EBUSY); -#ifndef UCONSOLE - if ((error = suser(td)) != 0) + + /* Ensure user can open the real console. */ + NDINIT(&nid, LOOKUP, LOCKLEAF | FOLLOW, UIO_SYSSPACE, + "/dev/console", td); + if ((error = namei(&nid)) != 0) return (error); -#endif + NDFREE(&nid, NDF_ONLY_PNBUF); + error = VOP_ACCESS(nid.ni_vp, VREAD, td->td_ucred, td); + vput(nid.ni_vp); + if (error) + return (error); + constty = tp; } else if (tp == constty) constty = NULL; |