summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libtrivfs/io-reauthenticate.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libtrivfs/io-reauthenticate.c b/libtrivfs/io-reauthenticate.c
index 9581720f..8deffa99 100644
--- a/libtrivfs/io-reauthenticate.c
+++ b/libtrivfs/io-reauthenticate.c
@@ -79,20 +79,23 @@ trivfs_S_io_reauthenticate (struct trivfs_protid *cred,
newcred->hook = cred->hook;
mutex_lock (&cred->po->cntl->lock);
-
newcred->po = cred->po;
newcred->po->refcnt++;
-
mutex_unlock (&cred->po->cntl->lock);
err = io_restrict_auth (newcred->po->cntl->underlying, &newcred->realnode,
gen_uids, genuidlen, gen_gids, gengidlen);
+ if (!err && trivfs_protid_create_hook)
+ {
+ err = (*trivfs_protid_create_hook) (newcred);
+ if (err)
+ mach_port_deallocate (mach_task_self (), newcred->realnode);
+ }
+
if (err)
+ /* Signal that the user destroy hook shouldn't be called on NEWCRED. */
newcred->realnode = MACH_PORT_NULL;
- if (trivfs_protid_create_hook)
- (*trivfs_protid_create_hook) (newcred);
-
if (gubuf != gen_uids)
vm_deallocate (mach_task_self (), (u_int) gen_uids,
genuidlen * sizeof (uid_t));
@@ -106,7 +109,7 @@ trivfs_S_io_reauthenticate (struct trivfs_protid *cred,
vm_deallocate (mach_task_self (), (u_int) aux_gids,
auxgidlen * sizeof (uid_t));
-
ports_port_deref (newcred);
- return 0;
+
+ return err;
}