summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2001-06-16 20:23:09 +0000
committerRoland McGrath <roland@gnu.org>2001-06-16 20:23:09 +0000
commit487bba2f0cd506b4a79e1d92184a5f80d827954f (patch)
treef26a7bc5548e27603cdd3a239fec26490b2f8b4a
parenta2529808d1aaf878eb6fff54ab491bd3d47db894 (diff)
2001-04-01 Neal H Walfield <neal@cs.uml.edu>
* dir-lookup.c (diskfs_S_dir_lookup): Use iohelp_create_empty_iouser. * fsys-getfile.c (diskfs_S_fsys_getfile): Use iohelp_create_complex_iouser. * io-reauthenticate.c (diskfs_S_io_reauthenticate): Use new iohelp_reauth semantics. * io-restrict-auth.c (diskfs_S_io_restrict_auth): Use new iohelp_create_iouser semantics. * protid-make.c (diskfs_finish_protid): Use iohelp_create_simple_iouser and new iohelp_dup_iouse semantics. * trans-callback.c (_diskfs_translator_callback2_fn): Use iohelp_create_simple_iouser.
-rw-r--r--libdiskfs/dir-lookup.c14
-rw-r--r--libdiskfs/fsys-getfile.c16
-rw-r--r--libdiskfs/io-reauthenticate.c14
-rw-r--r--libdiskfs/io-restrict-auth.c48
-rw-r--r--libdiskfs/protid-make.c22
-rw-r--r--libdiskfs/trans-callback.c12
6 files changed, 78 insertions, 48 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 2cecc91d..3d749dd5 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -248,11 +248,15 @@ diskfs_S_dir_lookup (struct protid *dircred,
/* Create an unauthenticated port for DNP, and then
unlock it. */
- user = iohelp_create_iouser (make_idvec (), make_idvec ());
- error =
- diskfs_create_protid (diskfs_make_peropen (dnp, 0, dircred->po),
- user, &newpi);
- iohelp_free_iouser (user);
+ error = iohelp_create_empty_iouser (&user);
+ if (! error)
+ {
+ error =
+ diskfs_create_protid (diskfs_make_peropen (dnp, 0,
+ dircred->po),
+ user, &newpi);
+ iohelp_free_iouser (user);
+ }
if (error)
goto out;
diff --git a/libdiskfs/fsys-getfile.c b/libdiskfs/fsys-getfile.c
index 7d125304..efa0cdf0 100644
--- a/libdiskfs/fsys-getfile.c
+++ b/libdiskfs/fsys-getfile.c
@@ -1,6 +1,6 @@
/* Return the file for a given handle (for nfs server support)
- Copyright (C) 1997,99 Free Software Foundation, Inc.
+ Copyright (C) 1997,99,2001 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -39,7 +39,6 @@ diskfs_S_fsys_getfile (mach_port_t fsys,
struct node *node;
const union diskfs_fhandle *f;
struct protid *new_cred;
- struct idvec *uvec, *gvec;
struct iouser *user;
struct port_info *pt =
ports_lookup_port (diskfs_port_bucket, fsys, diskfs_control_class);
@@ -69,12 +68,13 @@ diskfs_S_fsys_getfile (mach_port_t fsys,
return ESTALE;
}
- uvec = make_idvec ();
- gvec = make_idvec ();
-
- idvec_set_ids (uvec, uids, nuids);
- idvec_set_ids (gvec, gids, ngids);
- user = iohelp_create_iouser (uvec, gvec);
+ err = iohelp_create_complex_iouser (&user, uids, nuids, gids, ngids);
+ if (err)
+ {
+ diskfs_nput (node);
+ ports_port_deref (pt);
+ return err;
+ }
flags = 0;
if (! fshelp_access (&node->dn_stat, S_IREAD, user))
diff --git a/libdiskfs/io-reauthenticate.c b/libdiskfs/io-reauthenticate.c
index eb564a26..fd427e20 100644
--- a/libdiskfs/io-reauthenticate.c
+++ b/libdiskfs/io-reauthenticate.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994,95,96,2000 Free Software Foundation, Inc.
+ 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
@@ -47,10 +47,14 @@ diskfs_S_io_reauthenticate (struct protid *cred,
newright = ports_get_send_right (newcred);
assert (newright != MACH_PORT_NULL);
- user = iohelp_reauth (diskfs_auth_server_port, rend_port, newright, 1);
- diskfs_finish_protid (newcred, user);
+ err = iohelp_reauth (&user, diskfs_auth_server_port, rend_port,
+ newright, 1);
+ if (! err)
+ {
+ diskfs_finish_protid (newcred, user);
+ iohelp_free_iouser (user);
+ }
- iohelp_free_iouser (user);
mach_port_deallocate (mach_task_self (), rend_port);
mach_port_deallocate (mach_task_self (), newright);
@@ -58,5 +62,5 @@ diskfs_S_io_reauthenticate (struct protid *cred,
ports_port_deref (newcred);
- return 0;
+ return err;
}
diff --git a/libdiskfs/io-restrict-auth.c b/libdiskfs/io-restrict-auth.c
index 691a59ed..8f8a97bd 100644
--- a/libdiskfs/io-restrict-auth.c
+++ b/libdiskfs/io-restrict-auth.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994, 1995, 1996 Free Software Foundation
+ Copyright (C) 1994,95,96,2001 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -39,7 +39,7 @@ diskfs_S_io_restrict_auth (struct protid *cred,
gid_t *gids,
u_int ngids)
{
- error_t err;
+ error_t err = 0;
struct idvec *uvec, *gvec;
struct iouser *user;
struct protid *newpi;
@@ -48,26 +48,52 @@ diskfs_S_io_restrict_auth (struct protid *cred,
if (!cred)
return EOPNOTSUPP;
- uvec = make_idvec ();
- gvec = make_idvec ();
-
if (idvec_contains (cred->user->uids, 0))
+ /* CRED has root access, and so may use any ids. */
{
- /* CRED has root access, and so may use any ids. */
- idvec_set_ids (uvec, uids, nuids);
- idvec_set_ids (gvec, gids, ngids);
+ err = iohelp_create_complex_iouser (&user, uids, nuids, gids, ngids);
+ if (err)
+ return err;
}
else
{
+ uvec = make_idvec ();
+ if (! uvec)
+ return ENOMEM;
+
+ gvec = make_idvec ();
+ if (! gvec)
+ {
+ idvec_free (uvec);
+ return ENOMEM;
+ }
+
/* Otherwise, use any of the requested ids that CRED already has. */
for (i = 0; i < cred->user->uids->num; i++)
if (listmember (uids, cred->user->uids->ids[i], nuids))
- idvec_add (uvec, cred->user->uids->ids[i]);
+ {
+ err = idvec_add (uvec, cred->user->uids->ids[i]);
+ if (err)
+ goto out;
+ }
for (i = 0; i < cred->user->gids->num; i++)
if (listmember (gids, cred->user->gids->ids[i], ngids))
- idvec_add (gvec, cred->user->gids->ids[i]);
+ {
+ idvec_add (gvec, cred->user->gids->ids[i]);
+ if (err)
+ goto out;
+ }
+
+ err = iohelp_create_iouser (&user, uvec, gvec);
+
+ if (err)
+ {
+ out:
+ idvec_free (uvec);
+ idvec_free (gvec);
+ return err;
+ }
}
- user = iohelp_create_iouser (uvec, gvec);
mutex_lock (&cred->po->np->lock);
err = diskfs_create_protid (cred->po, user, &newpi);
diff --git a/libdiskfs/protid-make.c b/libdiskfs/protid-make.c
index 8f45cfd5..9b78a37f 100644
--- a/libdiskfs/protid-make.c
+++ b/libdiskfs/protid-make.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994, 1995, 1996 Free Software Foundation
+ Copyright (C) 1994,95,96,2001 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -17,6 +17,7 @@
#include "priv.h"
#include <string.h>
+#include <assert.h>
/* Build and return in CRED a protid which has no user identification, for
peropen PO. The node PO->np must be locked. */
@@ -41,20 +42,17 @@ diskfs_start_protid (struct peropen *po, struct protid **cred)
void
diskfs_finish_protid (struct protid *cred, struct iouser *user)
{
+ error_t err;
+
if (!user)
- {
- uid_t zero = 0;
- /* Create one for root */
- user = iohelp_create_iouser (make_idvec (), make_idvec ());
- idvec_set_ids (user->uids, &zero, 1);
- idvec_set_ids (user->gids, &zero, 1);
- cred->user = user;
- }
+ err = iohelp_create_simple_iouser (&cred->user, 0, 0);
else
- cred->user = iohelp_dup_iouser (user);
+ err = iohelp_dup_iouser (&cred->user, user);
+ assert_perror (err);
- mach_port_move_member (mach_task_self (), cred->pi.port_right,
- diskfs_port_bucket->portset);
+ err = mach_port_move_member (mach_task_self (), cred->pi.port_right,
+ diskfs_port_bucket->portset);
+ assert_perror (err);
}
/* Create and return a protid for an existing peropen PO in CRED for USER.
diff --git a/libdiskfs/trans-callback.c b/libdiskfs/trans-callback.c
index 5923d265..73d551c3 100644
--- a/libdiskfs/trans-callback.c
+++ b/libdiskfs/trans-callback.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 96, 97, 98 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,97,98,2001 Free Software Foundation, Inc.
Written by Michael I. Bushnell.
This file is part of the GNU Hurd.
@@ -55,14 +55,12 @@ _diskfs_translator_callback2_fn (void *cookie1, void *cookie2,
struct node *np = cookie1;
struct protid *cred;
error_t err;
- struct idvec *uids, *gids;
struct iouser *user;
- uids = make_idvec ();
- gids = make_idvec ();
- idvec_set_ids (uids, &np->dn_stat.st_uid, 1);
- idvec_set_ids (gids, &np->dn_stat.st_gid, 1);
- user = iohelp_create_iouser (uids, gids);
+ err = iohelp_create_simple_iouser (&user, np->dn_stat.st_uid,
+ np->dn_stat.st_gid);
+ if (err)
+ return err;
err =
diskfs_create_protid (diskfs_make_peropen (np, flags, cookie2),