From owner-svn-src-head@FreeBSD.ORG Mon Jun 15 19:17:53 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7D1051065674; Mon, 15 Jun 2009 19:17:53 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5135A8FC1F; Mon, 15 Jun 2009 19:17:53 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5FJHrhJ098875; Mon, 15 Jun 2009 19:17:53 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5FJHr3U098873; Mon, 15 Jun 2009 19:17:53 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200906151917.n5FJHr3U098873@svn.freebsd.org> From: Ed Schouten Date: Mon, 15 Jun 2009 19:17:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r194256 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jun 2009 19:17:54 -0000 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);