summaryrefslogtreecommitdiff
path: root/libshouldbeinlibc
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2021-06-09 15:41:58 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-10 22:17:08 +0200
commit5710aaa670a14cbbe4da0e8fe64314a55f14a015 (patch)
tree5a76113134f56b3e481c8019684fc1300d9e5d3f /libshouldbeinlibc
parentb6c6e41a0d94740f4ecce9afdafa0c17348ce4c0 (diff)
Make proc_reauthenticate () recreate proc port
And add proc_complete_reauthentication ()
Diffstat (limited to 'libshouldbeinlibc')
-rw-r--r--libshouldbeinlibc/exec-reauth.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/libshouldbeinlibc/exec-reauth.c b/libshouldbeinlibc/exec-reauth.c
index cd217e02..71e41b8b 100644
--- a/libshouldbeinlibc/exec-reauth.c
+++ b/libshouldbeinlibc/exec-reauth.c
@@ -60,22 +60,24 @@ exec_reauth (auth_t auth, int secure, int must_reauth,
err = auth_user_authenticate (auth, ref, MACH_MSG_TYPE_MAKE_SEND,
&newport);
mach_port_mod_refs (mach_task_self (), ref, MACH_PORT_RIGHT_RECEIVE, -1);
+ /* If they gave us nothing, make sure not to proceed. */
+ if (!err && newport == MACH_PORT_NULL)
+ err = KERN_INVALID_ARGUMENT;
if (err)
- {
- if (must_reauth)
- return err;
- /* Nothing Happens. */
- }
- else
- {
- if (isproc)
- mach_port_deallocate (mach_task_self (), newport);
- else
- {
- mach_port_deallocate (mach_task_self (), *port);
- *port = newport;
- }
- }
+ return must_reauth ? err : 0;
+
+ if (isproc)
+ {
+ err = proc_complete_reauthentication (newport);
+ if (err)
+ {
+ mach_port_deallocate (mach_task_self (), newport);
+ return must_reauth ? err : 0;
+ }
+ }
+
+ mach_port_deallocate (mach_task_self (), *port);
+ *port = newport;
}
return 0;
}