summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libnetfs/dir-lookup.c59
-rw-r--r--libnetfs/dir-mkfile.c23
-rw-r--r--libnetfs/file-exec.c34
-rw-r--r--libnetfs/file-reparent.c13
-rw-r--r--libnetfs/fsys-getroot.c10
-rw-r--r--libnetfs/fsys-syncfs.c7
-rw-r--r--libnetfs/io-duplicate.c11
-rw-r--r--libnetfs/io-reauthenticate.c8
-rw-r--r--libnetfs/trans-callback.c15
9 files changed, 109 insertions, 71 deletions
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index ed7853ec..6911f5ae 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,97,98,99,2000,01 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -48,6 +48,7 @@ netfs_S_dir_lookup (struct protid *diruser,
char *nextname;
error_t error;
struct protid *newpi;
+ struct iouser *user;
if (!diruser)
return EOPNOTSUPP;
@@ -233,25 +234,37 @@ netfs_S_dir_lookup (struct protid *diruser,
/* Create an unauthenticated port for DNP, and then
unlock it. */
- newpi =
- netfs_make_protid (netfs_make_peropen (dnp, 0, diruser->po),
- iohelp_create_iouser (make_idvec (),
- make_idvec ()));
- dirport = ports_get_send_right (newpi);
- ports_port_deref (newpi);
-
- error = fshelp_fetch_root (&np->transbox, diruser->po,
- dirport,
- diruser->user,
- lastcomp ? flags : 0,
- ((np->nn_stat.st_mode & S_IPTRANS)
- ? _netfs_translator_callback1
- : short_circuited_callback1),
- _netfs_translator_callback2,
- do_retry, retry_name, retry_port);
- /* fetch_root copies DIRPORT for success, so we always should
- deallocate our send right. */
- mach_port_deallocate (mach_task_self (), dirport);
+ error = iohelp_create_empty_iouser (&user);
+ if (! error)
+ {
+ newpi = netfs_make_protid (netfs_make_peropen (dnp, 0,
+ diruser->po),
+ user);
+ if (! newpi)
+ {
+ iohelp_free_iouser (user);
+ error = ENOMEM;
+ }
+ }
+
+ if (! error)
+ {
+ dirport = ports_get_send_right (newpi);
+ ports_port_deref (newpi);
+
+ error = fshelp_fetch_root (&np->transbox, diruser->po,
+ dirport,
+ diruser->user,
+ lastcomp ? flags : 0,
+ ((np->nn_stat.st_mode & S_IPTRANS)
+ ? _netfs_translator_callback1
+ : short_circuited_callback1),
+ _netfs_translator_callback2,
+ do_retry, retry_name, retry_port);
+ /* fetch_root copies DIRPORT for success, so we always should
+ deallocate our send right. */
+ mach_port_deallocate (mach_task_self (), dirport);
+ }
if (error != ENOENT)
{
@@ -362,8 +375,12 @@ netfs_S_dir_lookup (struct protid *diruser,
flags &= ~OPENONLY_STATE_MODES;
+ error = iohelp_dup_iouser (&user, diruser->user);
+ if (error)
+ goto out;
+
newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po),
- iohelp_dup_iouser (diruser->user));
+ user);
*retry_port = ports_get_right (newpi);
ports_port_deref (newpi);
diff --git a/libnetfs/dir-mkfile.c b/libnetfs/dir-mkfile.c
index abd8d0ad..16c5dd77 100644
--- a/libnetfs/dir-mkfile.c
+++ b/libnetfs/dir-mkfile.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,97,2001 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -28,6 +28,7 @@ netfs_S_dir_mkfile (struct protid *diruser, int flags, mode_t mode,
{
error_t err;
struct node *np;
+ struct iouser *user;
struct protid *newpi;
mutex_lock (&diruser->po->np->lock);
@@ -37,15 +38,19 @@ netfs_S_dir_mkfile (struct protid *diruser, int flags, mode_t mode,
{
/* the dir is now unlocked and NP is locked */
flags &= OPENONLY_STATE_MODES;
- newpi = netfs_make_protid (netfs_make_peropen (np, flags, diruser->po),
- iohelp_dup_iouser (diruser->user));
- *newfile = ports_get_right (newpi);
- *newfiletype = MACH_MSG_TYPE_MAKE_SEND;
- ports_port_deref (newpi);
+ err = iohelp_dup_iouser (&user, diruser->user);
+ if (! err)
+ {
+ newpi = netfs_make_protid (netfs_make_peropen (np, flags,
+ diruser->po),
+ user);
+ *newfile = ports_get_right (newpi);
+ *newfiletype = MACH_MSG_TYPE_MAKE_SEND;
+ ports_port_deref (newpi);
+ }
netfs_nput (np);
- return 0;
}
- else
- return err;
+
+ return err;
}
diff --git a/libnetfs/file-exec.c b/libnetfs/file-exec.c
index c5cd676c..4f9e5034 100644
--- a/libnetfs/file-exec.c
+++ b/libnetfs/file-exec.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1996,97,2000,01 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -122,19 +122,25 @@ netfs_S_file_exec (struct protid *cred,
if (! err)
{
- struct protid *newpi =
- netfs_make_protid (netfs_make_peropen (np, O_READ, cred->po),
- iohelp_dup_iouser (cred->user));
- right = ports_get_send_right (newpi);
- err = exec_exec (_netfs_exec,
- right, MACH_MSG_TYPE_COPY_SEND,
- task, flags, argv, argvlen, envp, envplen,
- fds, MACH_MSG_TYPE_COPY_SEND, fdslen,
- portarray, MACH_MSG_TYPE_COPY_SEND, portarraylen,
- intarray, intarraylen, deallocnames, deallocnameslen,
- destroynames, destroynameslen);
- mach_port_deallocate (mach_task_self (), right);
- ports_port_deref (newpi);
+ struct iouser *user;
+ struct protid *newpi;
+
+ err = iohelp_dup_iouser (&user, cred->user);
+ if (! err)
+ {
+ newpi = netfs_make_protid (netfs_make_peropen (np, O_READ, cred->po),
+ user);
+ right = ports_get_send_right (newpi);
+ err = exec_exec (_netfs_exec,
+ right, MACH_MSG_TYPE_COPY_SEND,
+ task, flags, argv, argvlen, envp, envplen,
+ fds, MACH_MSG_TYPE_COPY_SEND, fdslen,
+ portarray, MACH_MSG_TYPE_COPY_SEND, portarraylen,
+ intarray, intarraylen, deallocnames, deallocnameslen,
+ destroynames, destroynameslen);
+ mach_port_deallocate (mach_task_self (), right);
+ ports_port_deref (newpi);
+ }
}
if (! err)
diff --git a/libnetfs/file-reparent.c b/libnetfs/file-reparent.c
index 6397951e..396a0a6b 100644
--- a/libnetfs/file-reparent.c
+++ b/libnetfs/file-reparent.c
@@ -1,8 +1,8 @@
/* Reparent a file
- Copyright (C) 1997 Free Software Foundation
+ Copyright (C) 1997, 2001 Free Software Foundation
- Written by Miles Bader <miles@gnu.ai.mit.edu>
+ Written by Miles Bader <miles@gnu.org>
This file is part of the GNU Hurd.
@@ -26,18 +26,25 @@ error_t
netfs_S_file_reparent (struct protid *cred, mach_port_t parent,
mach_port_t *new_file, mach_msg_type_name_t *new_file_type)
{
+ error_t err;
struct node *node;
struct protid *new_cred;
+ struct iouser *user;
if (! cred)
return EOPNOTSUPP;
+ err = iohelp_dup_iouser (&user, cred->user);
+ if (err)
+ return err;
+
node = cred->po->np;
mutex_lock (&node->lock);
+
new_cred =
netfs_make_protid (netfs_make_peropen (node, cred->po->openstat, cred->po),
- iohelp_dup_iouser (cred->user));
+ user);
mutex_unlock (&node->lock);
if (new_cred)
diff --git a/libnetfs/fsys-getroot.c b/libnetfs/fsys-getroot.c
index 7572843c..247ef62a 100644
--- a/libnetfs/fsys-getroot.c
+++ b/libnetfs/fsys-getroot.c
@@ -43,19 +43,15 @@ netfs_S_fsys_getroot (mach_port_t cntl,
error_t err;
struct protid *newpi;
mode_t type;
- struct idvec *uvec, *gvec;
struct peropen peropen_context = { root_parent: dotdot };
if (!pt)
return EOPNOTSUPP;
ports_port_deref (pt);
- uvec = make_idvec ();
- gvec = make_idvec ();
- idvec_set_ids (uvec, uids, nuids);
- idvec_set_ids (gvec, gids, ngids);
-
- cred = iohelp_create_iouser (uvec, gvec);
+ err = iohelp_create_complex_iouser (&cred, uids, nuids, gids, ngids);
+ if (err)
+ return err;
flags &= O_HURD;
diff --git a/libnetfs/fsys-syncfs.c b/libnetfs/fsys-syncfs.c
index beeb942d..f57cb144 100644
--- a/libnetfs/fsys-syncfs.c
+++ b/libnetfs/fsys-syncfs.c
@@ -29,12 +29,11 @@ netfs_S_fsys_syncfs (mach_port_t cntl,
int children)
{
struct iouser *cred;
- uid_t root = 0;
error_t err;
- cred = iohelp_create_iouser (make_idvec (), make_idvec ());
- idvec_set_ids (cred->uids, &root, 1);
- idvec_set_ids (cred->gids, &root, 1);
+ err = iohelp_create_simple_iouser (&cred, 0, 0);
+ if (err)
+ return err;
err = netfs_attempt_syncfs (cred, wait);
iohelp_free_iouser (cred);
return err;
diff --git a/libnetfs/io-duplicate.c b/libnetfs/io-duplicate.c
index a41af9bf..ad374fc9 100644
--- a/libnetfs/io-duplicate.c
+++ b/libnetfs/io-duplicate.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,2001 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -26,11 +26,16 @@ netfs_S_io_duplicate (struct protid *user,
mach_port_t *newport,
mach_msg_type_name_t *newporttp)
{
+ error_t err;
struct protid *newpi;
+ struct iouser *clone;
+
+ err = iohelp_dup_iouser (&clone, user->user);
+ if (err)
+ return err;
mutex_lock (&user->po->np->lock);
- newpi = netfs_make_protid (user->po,
- iohelp_dup_iouser (user->user));
+ newpi = netfs_make_protid (user->po, clone);
*newport = ports_get_right (newpi);
mutex_unlock (&user->po->np->lock);
*newporttp = MACH_MSG_TYPE_MAKE_SEND;
diff --git a/libnetfs/io-reauthenticate.c b/libnetfs/io-reauthenticate.c
index 1791e8d9..3140499c 100644
--- a/libnetfs/io-reauthenticate.c
+++ b/libnetfs/io-reauthenticate.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995,96,2000 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,2000,01 Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
This file is part of the GNU Hurd.
@@ -24,6 +24,7 @@
error_t
netfs_S_io_reauthenticate (struct protid *user, mach_port_t rend_port)
{
+ error_t err;
struct protid *newpi;
mach_port_t newright;
@@ -36,7 +37,8 @@ netfs_S_io_reauthenticate (struct protid *user, mach_port_t rend_port)
newright = ports_get_send_right (newpi);
assert (newright != MACH_PORT_NULL);
- newpi->user = iohelp_reauth (netfs_auth_server_port, rend_port, newright, 1);
+ err = iohelp_reauth (&newpi->user, netfs_auth_server_port, rend_port,
+ newright, 1);
mach_port_deallocate (mach_task_self (), rend_port);
mach_port_deallocate (mach_task_self (), newright);
@@ -47,5 +49,5 @@ netfs_S_io_reauthenticate (struct protid *user, mach_port_t rend_port)
mutex_unlock (&user->po->np->lock);
ports_port_deref (newpi);
- return 0;
+ return err;
}
diff --git a/libnetfs/trans-callback.c b/libnetfs/trans-callback.c
index 8452b005..fc844c30 100644
--- a/libnetfs/trans-callback.c
+++ b/libnetfs/trans-callback.c
@@ -1,6 +1,6 @@
/* Callback functions for starting translators
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995,96,97,2001 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -51,17 +51,18 @@ _netfs_translator_callback2_fn (void *cookie1, void *cookie2, int flags,
mach_port_t *underlying,
mach_msg_type_name_t *underlying_type)
{
+ error_t err;
struct protid *cred;
- struct idvec *uids, *gids;
struct node *node = cookie1;
+ struct iouser *user;
- uids = make_idvec ();
- gids = make_idvec ();
- idvec_set_ids (uids, &node->nn_stat.st_uid, 1);
- idvec_set_ids (gids, &node->nn_stat.st_gid, 1);
+ err = iohelp_create_simple_iouser (&user, node->nn_stat.st_uid,
+ node->nn_stat.st_gid);
+ if (err)
+ return err;
cred = netfs_make_protid (netfs_make_peropen (node, flags, cookie2),
- iohelp_create_iouser (uids, gids));
+ user);
if (cred)
{
*underlying = ports_get_right (cred);