1 |
/* Setuid reauthentication for exec |
/* Setuid reauthentication for exec |
2 |
|
|
3 |
Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc. |
Copyright (C) 1995,96,97,2002 Free Software Foundation, Inc. |
4 |
|
|
5 |
Written by Miles Bader <miles@gnu.ai.mit.edu>, |
Written by Miles Bader <miles@gnu.org>, |
6 |
from the original by Michael I. Bushnell p/BSG <mib@gnu.ai.mit.edu> |
from the original by Michael I. Bushnell p/BSG <mib@gnu.org> |
7 |
|
|
8 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
9 |
modify it under the terms of the GNU General Public License as |
modify it under the terms of the GNU General Public License as |
83 |
|
|
84 |
/* STEP 3: Attempt to create this new auth handle. */ |
/* STEP 3: Attempt to create this new auth handle. */ |
85 |
err = auth_makeauth (auth, &ports[INIT_PORT_AUTH], |
err = auth_makeauth (auth, &ports[INIT_PORT_AUTH], |
86 |
MACH_MSG_TYPE_COPY_SEND, 1, |
MACH_MSG_TYPE_COPY_SEND, 1, |
87 |
eff_uids->ids, eff_uids->num, |
eff_uids->ids, eff_uids->num, |
88 |
avail_uids->ids, avail_uids->num, |
avail_uids->ids, avail_uids->num, |
89 |
eff_gids->ids, eff_gids->num, |
eff_gids->ids, eff_gids->num, |
113 |
goto abandon_suid; |
goto abandon_suid; |
114 |
|
|
115 |
/* Trrrry again... */ |
/* Trrrry again... */ |
116 |
err = auth_makeauth (auth, 0, MACH_MSG_TYPE_COPY_SEND, 1, |
err = auth_makeauth (auth, 0, MACH_MSG_TYPE_COPY_SEND, 1, |
117 |
eff_uids->ids, eff_uids->num, |
eff_uids->ids, eff_uids->num, |
118 |
avail_uids->ids, avail_uids->num, |
avail_uids->ids, avail_uids->num, |
119 |
eff_gids->ids, eff_gids->num, |
eff_gids->ids, eff_gids->num, |
130 |
/* Re-authenticate the exec parameters. */ |
/* Re-authenticate the exec parameters. */ |
131 |
exec_reauth (newauth, _secure, 0, ports, num_ports, fds, num_fds); |
exec_reauth (newauth, _secure, 0, ports, num_ports, fds, num_fds); |
132 |
|
|
133 |
proc_setowner (ports[INIT_PORT_PROC], |
proc_setowner (ports[INIT_PORT_PROC], |
134 |
eff_uids->num > 0 ? eff_uids->ids[0] : 0, |
eff_uids->num > 0 ? eff_uids->ids[0] : 0, |
135 |
!eff_uids->num); |
!eff_uids->num); |
136 |
|
|
137 |
abandon_suid: |
abandon_suid: |
145 |
idvec_free (avail_gids); |
idvec_free (avail_gids); |
146 |
} |
} |
147 |
|
|
148 |
if (_secure && secure) |
if (secure) |
149 |
*secure = _secure; |
*secure = _secure; |
150 |
|
|
151 |
return err; |
return err; |