mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-11 09:50:12 +00:00
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
This commit is contained in:
parent
6eced731e8
commit
b6751c3f87
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=297139
@ -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 *curthread)
|
||||
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();
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user