diff options
Diffstat (limited to 'libdiskfs/io-reauthenticate.c')
-rw-r--r-- | libdiskfs/io-reauthenticate.c | 63 |
1 files changed, 17 insertions, 46 deletions
diff --git a/libdiskfs/io-reauthenticate.c b/libdiskfs/io-reauthenticate.c index 9b065a3b..3c5da52d 100644 --- a/libdiskfs/io-reauthenticate.c +++ b/libdiskfs/io-reauthenticate.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994,95,96,2000,01 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -24,22 +24,14 @@ diskfs_S_io_reauthenticate (struct protid *cred, mach_port_t rend_port) { struct protid *newcred; - uid_t gubuf[20], ggbuf[20], aubuf[20], agbuf[20]; - uid_t *gen_uids, *gen_gids, *aux_uids, *aux_gids; - u_int genuidlen, gengidlen, auxuidlen, auxgidlen; error_t err; mach_port_t newright; + struct iouser *user; if (cred == 0) return EOPNOTSUPP; - genuidlen = gengidlen = auxuidlen = auxgidlen = 20; - gen_uids = gubuf; - gen_gids = ggbuf; - aux_uids = aubuf; - aux_gids = agbuf; - - /* This routine must carefully ignore EINTR because we + /* This routine must carefully ignore EINTR because we are a simpleroutine, so callers won't know to restart. */ mutex_lock (&cred->po->np->lock); @@ -52,44 +44,23 @@ diskfs_S_io_reauthenticate (struct protid *cred, return err; } - newright = ports_get_right (newcred); - err = mach_port_insert_right (mach_task_self (), newright, newright, - MACH_MSG_TYPE_MAKE_SEND); - assert_perror (err); - do - err = auth_server_authenticate (diskfs_auth_server_port, - rend_port, - MACH_MSG_TYPE_COPY_SEND, - newright, - MACH_MSG_TYPE_COPY_SEND, - &gen_uids, &genuidlen, - &aux_uids, &auxuidlen, - &gen_gids, &gengidlen, - &aux_gids, &auxgidlen); - while (err == EINTR); - mach_port_deallocate (mach_task_self (), rend_port); + newright = ports_get_send_right (newcred); + assert (newright != MACH_PORT_NULL); + + err = iohelp_reauth (&user, diskfs_auth_server_port, rend_port, + newright, 1); + if (! err) + { + diskfs_finish_protid (newcred, user); + iohelp_free_iouser (user); + mach_port_deallocate (mach_task_self (), rend_port); + } + mach_port_deallocate (mach_task_self (), newright); - - if (err) - diskfs_finish_protid (newcred, 0, 0, 0, 0); - else - diskfs_finish_protid (newcred, gen_uids, genuidlen, gen_gids, gengidlen); + mutex_unlock (&cred->po->np->lock); ports_port_deref (newcred); - if (gubuf != gen_uids) - vm_deallocate (mach_task_self (), (u_int) gen_uids, - genuidlen * sizeof (uid_t)); - if (ggbuf != gen_gids) - vm_deallocate (mach_task_self (), (u_int) gen_gids, - gengidlen * sizeof (uid_t)); - if (aubuf != aux_uids) - vm_deallocate (mach_task_self (), (u_int) aux_uids, - auxuidlen * sizeof (uid_t)); - if (agbuf != aux_gids) - vm_deallocate (mach_task_self (), (u_int) aux_gids, - auxgidlen * sizeof (uid_t)); - - return 0; + return err; } |