summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_tty.c
diff options
context:
space:
mode:
authormbr <mbr@FreeBSD.org>2006-09-23 14:44:14 +0000
committermbr <mbr@FreeBSD.org>2006-09-23 14:44:14 +0000
commit35537661a5a12e34fee8a553cd22fc044352974b (patch)
tree16e267dd080cf4a82e8df9a801c23c96b526d61b /sys/kern/tty_tty.c
parent98bfdf3a78586aa410625c6677d0977862ea27a8 (diff)
downloadFreeBSD-src-35537661a5a12e34fee8a553cd22fc044352974b.zip
FreeBSD-src-35537661a5a12e34fee8a553cd22fc044352974b.tar.gz
If /dev/tty gets opened after your controlling terminal has been revoked
you can't call tty_clone afterwords. OpenBSD and NetBSD both fail the open call in that case, so we should do so as well. This can be done in ctty_clone by returning with *dev==NULL. Admittedly this causes open to return ENOENT, instead of ENXIO as on the other BSDs, but this way requires the least touching of code. Submitted by: Nate Eldredge <nge@cs.hmc.edu> PR: 83375 MFC: 1 week
Diffstat (limited to 'sys/kern/tty_tty.c')
-rw-r--r--sys/kern/tty_tty.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c
index 5a99d25..b83f924 100644
--- a/sys/kern/tty_tty.c
+++ b/sys/kern/tty_tty.c
@@ -64,7 +64,11 @@ ctty_clone(void *arg, struct ucred *cred, char *name, int namelen,
*dev = ctty;
else if (curthread->td_proc->p_session->s_ttyvp == NULL)
*dev = ctty;
- else
+ else if (curthread->td_proc->p_session->s_ttyvp->v_type == VBAD ||
+ curthread->td_proc->p_session->s_ttyvp->v_rdev == NULL) {
+ /* e.g. s_ttyvp was revoked */
+ return;
+ } else
*dev = curthread->td_proc->p_session->s_ttyvp->v_rdev;
dev_ref(*dev);
}
OpenPOWER on IntegriCloud