initial commit
[glibc.git] / debian / patches / hurd-i386 / proc_reauth.diff
1 Index: glibc-2.31/hurd/hurdsig.c
2 ===================================================================
3 --- glibc-2.31.orig/hurd/hurdsig.c
4 +++ glibc-2.31/hurd/hurdsig.c
5 @@ -1580,28 +1580,53 @@ _hurdsig_init (const int *intarray, size
6 static void
7 reauth_proc (mach_port_t new)
8 {
9 - mach_port_t ref, ignore;
10 + error_t err;
11 + mach_port_t ref, newproc;
12
13 ref = __mach_reply_port ();
14 - if (! HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC],
15 + err = HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC],
16 __proc_reauthenticate (port, ref,
17 - MACH_MSG_TYPE_MAKE_SEND)
18 - || __auth_user_authenticate (new, ref,
19 - MACH_MSG_TYPE_MAKE_SEND,
20 - &ignore))
21 - && ignore != MACH_PORT_NULL)
22 - __mach_port_deallocate (__mach_task_self (), ignore);
23 + MACH_MSG_TYPE_MAKE_SEND));
24 + if (err)
25 + {
26 + __mach_port_destroy (__mach_task_self (), ref);
27 + return;
28 + }
29 +
30 + err = __auth_user_authenticate (new, ref,
31 + MACH_MSG_TYPE_MAKE_SEND,
32 + &newproc);
33 __mach_port_destroy (__mach_task_self (), ref);
34 + if (err)
35 + return;
36 +
37 + if (newproc == MACH_PORT_NULL)
38 + {
39 + /* Old versions of the proc server did not recreate the process
40 + port when reauthenticating, and passed MACH_PORT_NULL through
41 + the auth server. That must be what we're dealing with. */
42 +
43 + /* Set the owner of the process here too. */
44 + __mutex_lock (&_hurd_id.lock);
45 + if (!_hurd_check_ids ())
46 + HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC],
47 + __proc_setowner (port,
48 + (_hurd_id.gen.nuids
49 + ? _hurd_id.gen.uids[0] : 0),
50 + !_hurd_id.gen.nuids));
51 + __mutex_unlock (&_hurd_id.lock);
52 +
53 + return;
54 + }
55 +
56 + err = __proc_reauthenticate_complete (newproc);
57 + if (err)
58 + {
59 + __mach_port_deallocate (__mach_task_self (), newproc);
60 + return;
61 + }
62
63 - /* Set the owner of the process here too. */
64 - __mutex_lock (&_hurd_id.lock);
65 - if (!_hurd_check_ids ())
66 - HURD_PORT_USE (&_hurd_ports[INIT_PORT_PROC],
67 - __proc_setowner (port,
68 - (_hurd_id.gen.nuids
69 - ? _hurd_id.gen.uids[0] : 0),
70 - !_hurd_id.gen.nuids));
71 - __mutex_unlock (&_hurd_id.lock);
72 + _hurd_port_set (&_hurd_ports[INIT_PORT_PROC], newproc);
73
74 (void) &reauth_proc; /* Silence compiler warning. */
75 }
76 Index: glibc-2.31/sysdeps/mach/hurd/spawni.c
77 ===================================================================
78 --- glibc-2.31.orig/sysdeps/mach/hurd/spawni.c
79 +++ glibc-2.31/sysdeps/mach/hurd/spawni.c
80 @@ -651,11 +651,29 @@ retry:
81 ref, MACH_MSG_TYPE_MAKE_SEND,
82 &newproc);
83 __mach_port_destroy (__mach_task_self (), ref);
84 - if (!err)
85 - {
86 - __mach_port_deallocate (__mach_task_self (), proc);
87 - proc = newproc;
88 - }
89 + if (err)
90 + goto out;
91 + if (newproc == MACH_PORT_NULL)
92 + {
93 + /* Old versions of the proc server did not recreate the process
94 + port when reauthenticating, and passed MACH_PORT_NULL through
95 + the auth server. That must be what we're dealing with. Just
96 + keep the existing proc port in this case. */
97 + }
98 + else
99 + {
100 + err = __proc_reauthenticate_complete (newproc);
101 + if (err)
102 + {
103 + __mach_port_deallocate (__mach_task_self (), newproc);
104 + goto out;
105 + }
106 + else
107 + {
108 + __mach_port_deallocate (__mach_task_self (), proc);
109 + proc = newproc;
110 + }
111 + }
112
113 if (!err)
114 err = reauthenticate (INIT_PORT_CRDIR, &rcrdir);