mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
hurd: Use the new __proc_reauthenticate_complete protocol
This commit is contained in:
committed by
Samuel Thibault
parent
96429bcc91
commit
a7aad6e2b7
@@ -1611,18 +1611,31 @@ _hurdsig_init (const int *intarray, size_t intarraysize)
|
|||||||
static void
|
static void
|
||||||
reauth_proc (mach_port_t new)
|
reauth_proc (mach_port_t new)
|
||||||
{
|
{
|
||||||
mach_port_t ref, ignore;
|
error_t err;
|
||||||
|
mach_port_t ref, newproc;
|
||||||
|
|
||||||
ref = __mach_reply_port ();
|
ref = __mach_reply_port ();
|
||||||
if (! HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC],
|
err = HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC],
|
||||||
__proc_reauthenticate (port, ref,
|
__proc_reauthenticate (port, ref,
|
||||||
MACH_MSG_TYPE_MAKE_SEND)
|
MACH_MSG_TYPE_MAKE_SEND));
|
||||||
|| __auth_user_authenticate (new, ref,
|
if (err)
|
||||||
MACH_MSG_TYPE_MAKE_SEND,
|
{
|
||||||
&ignore))
|
|
||||||
&& ignore != MACH_PORT_NULL)
|
|
||||||
__mach_port_deallocate (__mach_task_self (), ignore);
|
|
||||||
__mach_port_destroy (__mach_task_self (), ref);
|
__mach_port_destroy (__mach_task_self (), ref);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = __auth_user_authenticate (new, ref,
|
||||||
|
MACH_MSG_TYPE_MAKE_SEND,
|
||||||
|
&newproc);
|
||||||
|
__mach_port_destroy (__mach_task_self (), ref);
|
||||||
|
if (err)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (newproc == MACH_PORT_NULL)
|
||||||
|
{
|
||||||
|
/* Old versions of the proc server did not recreate the process
|
||||||
|
port when reauthenticating, and passed MACH_PORT_NULL through
|
||||||
|
the auth server. That must be what we're dealing with. */
|
||||||
|
|
||||||
/* Set the owner of the process here too. */
|
/* Set the owner of the process here too. */
|
||||||
__mutex_lock (&_hurd_id.lock);
|
__mutex_lock (&_hurd_id.lock);
|
||||||
@@ -1634,6 +1647,18 @@ reauth_proc (mach_port_t new)
|
|||||||
!_hurd_id.gen.nuids));
|
!_hurd_id.gen.nuids));
|
||||||
__mutex_unlock (&_hurd_id.lock);
|
__mutex_unlock (&_hurd_id.lock);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = __proc_reauthenticate_complete (newproc);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
__mach_port_deallocate (__mach_task_self (), newproc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hurd_port_set (&_hurd_ports[INIT_PORT_PROC], newproc);
|
||||||
|
|
||||||
(void) &reauth_proc; /* Silence compiler warning. */
|
(void) &reauth_proc; /* Silence compiler warning. */
|
||||||
}
|
}
|
||||||
text_set_element (_hurd_reauth_hook, reauth_proc);
|
text_set_element (_hurd_reauth_hook, reauth_proc);
|
||||||
|
@@ -679,11 +679,29 @@ retry:
|
|||||||
ref, MACH_MSG_TYPE_MAKE_SEND,
|
ref, MACH_MSG_TYPE_MAKE_SEND,
|
||||||
&newproc);
|
&newproc);
|
||||||
__mach_port_destroy (__mach_task_self (), ref);
|
__mach_port_destroy (__mach_task_self (), ref);
|
||||||
if (!err)
|
if (err)
|
||||||
|
goto out;
|
||||||
|
if (newproc == MACH_PORT_NULL)
|
||||||
|
{
|
||||||
|
/* Old versions of the proc server did not recreate the process
|
||||||
|
port when reauthenticating, and passed MACH_PORT_NULL through
|
||||||
|
the auth server. That must be what we're dealing with. Just
|
||||||
|
keep the existing proc port in this case. */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
err = __proc_reauthenticate_complete (newproc);
|
||||||
|
if (err)
|
||||||
|
{
|
||||||
|
__mach_port_deallocate (__mach_task_self (), newproc);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
__mach_port_deallocate (__mach_task_self (), proc);
|
__mach_port_deallocate (__mach_task_self (), proc);
|
||||||
proc = newproc;
|
proc = newproc;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!err)
|
if (!err)
|
||||||
err = reauthenticate (INIT_PORT_CRDIR, &rcrdir);
|
err = reauthenticate (INIT_PORT_CRDIR, &rcrdir);
|
||||||
|
Reference in New Issue
Block a user