Date: Mon, 15 Jun 2009 19:17:53 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r194256 - head/sys/kern Message-ID: <200906151917.n5FJHr3U098873@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Mon Jun 15 19:17:52 2009 New Revision: 194256 URL: http://svn.freebsd.org/changeset/base/194256 Log: Make tcsetsid(3) work on revoked TTYs. Right now the only way to make tcsetsid(3)/TIOCSCTTY work, is by ensuring the session leader is dead. This means that an application that catches SIGHUPs and performs a sleep prevents us from assigning a new session leader. Change the code to make it work on revoked TTYs as well. This allows us to change init(8) to make the shutdown script run in a more clean environment. Modified: head/sys/kern/kern_exit.c head/sys/kern/tty.c Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Mon Jun 15 19:16:43 2009 (r194255) +++ head/sys/kern/kern_exit.c Mon Jun 15 19:17:52 2009 (r194256) @@ -309,7 +309,7 @@ exit1(struct thread *td, int rv) sp->s_ttyvp = NULL; SESS_UNLOCK(sp); - if (ttyvp != NULL) { + if (ttyvp != NULL && ttyvp->v_type != VBAD) { /* * Controlling process. * Signal foreground pgrp and revoke access to Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Mon Jun 15 19:16:43 2009 (r194255) +++ head/sys/kern/tty.c Mon Jun 15 19:17:52 2009 (r194256) @@ -1487,15 +1487,18 @@ tty_generic_ioctl(struct tty *tp, u_long } if (p->p_session->s_ttyvp != NULL || - (tp->t_session != NULL && tp->t_session->s_ttyvp != NULL)) { + (tp->t_session != NULL && tp->t_session->s_ttyvp != NULL && + tp->t_session->s_ttyvp->v_type != VBAD)) { /* * There is already a relation between a TTY and * a session, or the caller is not the session * leader. * * Allow the TTY to be stolen when the vnode is - * NULL, but the reference to the TTY is still - * active. + * invalid, but the reference to the TTY is + * still active. This allows immediate reuse of + * TTYs of which the session leader has been + * killed or the TTY revoked. */ sx_xunlock(&proctree_lock); return (EPERM);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906151917.n5FJHr3U098873>