From owner-svn-src-head@freebsd.org Mon Mar 21 06:46:17 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CA1C1AD76E9; Mon, 21 Mar 2016 06:46:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 81AEB241; Mon, 21 Mar 2016 06:46:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2L6kGul055906; Mon, 21 Mar 2016 06:46:16 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2L6kGFq055904; Mon, 21 Mar 2016 06:46:16 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201603210646.u2L6kGFq055904@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 21 Mar 2016 06:46:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r297139 - head/lib/libthr/thread X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 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, 21 Mar 2016 06:46:17 -0000 Author: kib Date: Mon Mar 21 06:46:16 2016 New Revision: 297139 URL: https://svnweb.freebsd.org/changeset/base/297139 Log: From libthr, remove special and strange code to set up session and control terminal, activated when running with pid 1. It is application duty to handle this, and unsuspecting init replacements which are linked with libthr would be broken by this. The pre-resolving of getpid() is restored, just in case. Reviewed by: jilles Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Modified: head/lib/libthr/thread/thr_init.c head/lib/libthr/thread/thr_rtld.c Modified: head/lib/libthr/thread/thr_init.c ============================================================================== --- head/lib/libthr/thread/thr_init.c Mon Mar 21 06:40:54 2016 (r297138) +++ head/lib/libthr/thread/thr_init.c Mon Mar 21 06:46:16 2016 (r297139) @@ -305,7 +305,7 @@ _thread_init_hack(void) void _libpthread_init(struct pthread *curthread) { - int fd, first, dlopened; + int first, dlopened; /* Check if this function has already been called: */ if ((_thr_initial != NULL) && (curthread == NULL)) @@ -321,27 +321,6 @@ _libpthread_init(struct pthread *curthre memcpy(__thr_jtable, jmp_table, sizeof(jmp_table)); __thr_interpose_libc(); - /* - * Check for the special case of this process running as - * or in place of init as pid = 1: - */ - if ((_thr_pid = getpid()) == 1) { - /* - * Setup a new session for this process which is - * assumed to be running as root. - */ - if (setsid() == -1) - PANIC("Can't set session ID"); - if (revoke(_PATH_CONSOLE) != 0) - PANIC("Can't revoke console"); - if ((fd = __sys_openat(AT_FDCWD, _PATH_CONSOLE, O_RDWR)) < 0) - PANIC("Can't open console"); - if (setlogin("root") == -1) - PANIC("Can't set login to root"); - if (_ioctl(fd, TIOCSCTTY, (char *) NULL) == -1) - PANIC("Can't set controlling terminal"); - } - /* Initialize pthread private data. */ init_private(); Modified: head/lib/libthr/thread/thr_rtld.c ============================================================================== --- head/lib/libthr/thread/thr_rtld.c Mon Mar 21 06:40:54 2016 (r297138) +++ head/lib/libthr/thread/thr_rtld.c Mon Mar 21 06:46:16 2016 (r297139) @@ -227,6 +227,7 @@ _thr_rtld_init(void) _rtld_atfork_post(NULL); _malloc_prefork(); _malloc_postfork(); + getpid(); syscall(SYS_getpid); /* mask signals, also force to resolve __sys_sigprocmask PLT */