From 3632248b212af27b158b899d6156354dd32614ee Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 12 Aug 1995 01:06:32 +0000 Subject: (trivfs_S_io_reauthenticate): Allow trivfs_protid_create_hook to return an error code. --- libtrivfs/io-reauthenticate.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'libtrivfs') 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; } -- cgit v1.2.3