[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: memory leak in dir-lookup found
From: |
Neal H Walfield |
Subject: |
Re: memory leak in dir-lookup found |
Date: |
Sat, 21 Apr 2001 11:00:55 +0200 |
User-agent: |
Mutt/1.3.15i |
On Sun, Apr 15, 2001 at 06:45:12PM -0400, Roland McGrath wrote:
> > I disagree, if we set *USER to NULL on failure, we get the same effect.
>
> Ok.
Here are the necessary changes, enjoy.
Index: exec/ChangeLog
===================================================================
RCS file: /home/neal/shared/CVS/hurd/exec/ChangeLog,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 ChangeLog
--- exec/ChangeLog 2001/04/19 12:40:34 1.1.1.1
+++ exec/ChangeLog 2001/04/21 08:16:07
@@ -1,3 +1,7 @@
+2001-04-01 Neal H Walfield <neal@cs.uml.edu>
+
+ * main.c (S_exec_init): Use iohelp_create_empty_iouser.
+
2001-02-12 Marcus Brinkmann <marcus@gnu.org>
* main.c: Change hurd version name from proc to exec.
Index: exec/main.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/exec/main.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 main.c
--- exec/main.c 2001/04/19 12:40:36 1.1.1.1
+++ exec/main.c 2001/04/21 08:16:07
@@ -1,6 +1,6 @@
/* GNU Hurd standard exec server, main program and server mechanics.
- Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 1999, 2000 Free Software
Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,97,98,99,2000,01 Free Software Foundation,
Inc.
Written by Roland McGrath.
This file is part of the GNU Hurd.
@@ -226,12 +226,13 @@
change. This will generate an immediate callback giving us the
initial boot-time canonical sets. */
{
+ struct iouser *user;
struct trivfs_protid *cred;
mach_port_t right;
- err = trivfs_open (fsys,
- iohelp_create_iouser (make_idvec (), make_idvec ()),
- 0, MACH_PORT_NULL, &cred);
+ err = iohelp_create_empty_iouser (&user);
+ assert_perror (err);
+ err = trivfs_open (fsys, user, 0, MACH_PORT_NULL, &cred);
assert_perror (err);
right = ports_get_send_right (cred);
Index: libdiskfs/ChangeLog
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libdiskfs/ChangeLog,v
retrieving revision 1.1.1.2
diff -u -u -r1.1.1.2 ChangeLog
--- libdiskfs/ChangeLog 2001/04/20 12:31:04 1.1.1.2
+++ libdiskfs/ChangeLog 2001/04/21 08:22:59
@@ -1,3 +1,19 @@
+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.
+
2001-04-14 Neal H Walfield <neal@cs.uml.edu>
* node-create.c (diskfs_create_node): If we fail, set *NEWNODE
Index: libdiskfs/dir-lookup.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libdiskfs/dir-lookup.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 dir-lookup.c
--- libdiskfs/dir-lookup.c 2001/04/19 12:40:48 1.1.1.1
+++ libdiskfs/dir-lookup.c 2001/04/21 08:16:07
@@ -248,11 +248,15 @@
/* 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;
Index: libdiskfs/fsys-getfile.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libdiskfs/fsys-getfile.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 fsys-getfile.c
--- libdiskfs/fsys-getfile.c 2001/04/19 12:40:51 1.1.1.1
+++ libdiskfs/fsys-getfile.c 2001/04/21 08:16:07
@@ -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 @@
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 @@
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))
Index: libdiskfs/io-reauthenticate.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libdiskfs/io-reauthenticate.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 io-reauthenticate.c
--- libdiskfs/io-reauthenticate.c 2001/04/19 12:40:53 1.1.1.1
+++ libdiskfs/io-reauthenticate.c 2001/04/21 08:16:07
@@ -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 @@
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 @@
ports_port_deref (newcred);
- return 0;
+ return err;
}
Index: libdiskfs/io-restrict-auth.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libdiskfs/io-restrict-auth.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 io-restrict-auth.c
--- libdiskfs/io-restrict-auth.c 2001/04/19 12:40:53 1.1.1.1
+++ libdiskfs/io-restrict-auth.c 2001/04/21 08:17:25
@@ -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 @@
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 @@
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);
Index: libdiskfs/protid-make.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libdiskfs/protid-make.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 protid-make.c
--- libdiskfs/protid-make.c 2001/04/19 12:40:56 1.1.1.1
+++ libdiskfs/protid-make.c 2001/04/21 08:16:08
@@ -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 @@
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.
Index: libdiskfs/trans-callback.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libdiskfs/trans-callback.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 trans-callback.c
--- libdiskfs/trans-callback.c 2001/04/19 12:40:56 1.1.1.1
+++ libdiskfs/trans-callback.c 2001/04/21 08:16:08
@@ -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 @@
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),
Index: libiohelp/ChangeLog
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libiohelp/ChangeLog,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 ChangeLog
--- libiohelp/ChangeLog 2001/04/19 12:41:01 1.1.1.1
+++ libiohelp/ChangeLog 2001/04/21 08:28:18
@@ -1,3 +1,20 @@
+2001-04-21 Neal H Walfield <neal@cs.uml.edu>
+
+ * iohelp.h (iohelp_create_iouser): Change declaration
+ such that as error_t is now returned and the iouser is
+ a parameter.
+ (iohelp_create_empty_iouser): New funtion.
+ (iohelp_create_simple_iouser): New function.
+ (iohelp_create_complex_iouser): New funtion.
+
+ * iouser-create.c (iohelp_create_iouser): Implement new
+ semantics.
+ (iohelp_create_empty_iouser): Implement new function.
+ (iohelp_create_simple_iouser): Implement new function.
+ (iohelp_create_complex_iouser): Implement new function.
+ * iouser-dup.c (iohelp_dup_iouser): Implement new semantics.
+ * iouser-reauth.c (iohelp_reauth): Implement new semantics.
+
1999-07-11 Thomas Bushnell, BSG <tb@mit.edu>
* return-buffer.c: Include <sys/mman.h>.
Index: libiohelp/iohelp.h
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libiohelp/iohelp.h,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 iohelp.h
--- libiohelp/iohelp.h 2001/04/19 12:41:02 1.1.1.1
+++ libiohelp/iohelp.h 2001/04/21 08:30:24
@@ -1,5 +1,5 @@
/* Library providing helper functions for io servers.
- Copyright (C) 1993, 94, 96, 98 Free Software Foundation, Inc.
+ Copyright (C) 1993,94,96,98,2001 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
@@ -75,24 +75,42 @@
void *hook; /* Never used by iohelp library */
};
-/* Return a copy of IOUSER. */
-struct iouser *iohelp_dup_iouser (struct iouser *iouser);
+/* Return a copy of IOUSER in CLONE. On error, *CLONE is set to NULL. */
+error_t iohelp_dup_iouser (struct iouser **clone, struct iouser *iouser);
/* Free a reference to IOUSER. */
void iohelp_free_iouser (struct iouser *iouser);
-/* Create a new IOUSER for the specified idvecs */
-struct iouser *iohelp_create_iouser (struct idvec *uids, struct idvec *gids);
+/* Create a new IOUSER in USER for the specified idvecs. On error, *USER
+ is set to NULL. */
+error_t iohelp_create_iouser (struct iouser **user, struct idvec *uids,
+ struct idvec *gids);
+
+/* Create a new IOUSER in USER for the specified arrays. On error, *USER
+ is set to NULL. */
+error_t iohelp_create_complex_iouser (struct iouser **user,
+ uid_t *uids, int nuids,
+ gid_t *gids, int ngids);
+
+/* Create a new IOUSER in USER for the specified uid and gid. On error,
+ *USER is set to NULL. */
+error_t iohelp_create_simple_iouser (struct iouser **user, uid_t uid,
+ gid_t gid);
+
+/* Create a new IOUSER in USER with no identity. On error, *USER is set
+ to NULL. */
+error_t iohelp_create_empty_iouser (struct iouser **user);
-/* Conduct a reauthentication transaction, returning a new iouser.
- AUTHSERVER is the I/O servers auth port. The rendezvous port
+/* Conduct a reauthentication transaction, returning a new iouser in
+ USER. AUTHSERVER is the I/O servers auth port. The rendezvous port
provided by the user is REND_PORT. If the transaction cannot be
completed, return zero, unless PERMIT_FAILURE is non-zero. If
PERMIT_FAILURE is nonzero, then should the transaction fail, return
an iouser that has no ids. The new port to be sent to the user is
- newright. */
-struct iouser *iohelp_reauth (auth_t authserver, mach_port_t rend_port,
- mach_port_t newright, int permit_failure);
+ newright. On error, *USER is set to NULL. */
+error_t iohelp_reauth (struct iouser **user, auth_t authserver,
+ mach_port_t rend_port, mach_port_t newright,
+ int permit_failure);
/* Puts data from the malloced buffer BUF, LEN bytes long, into RBUF & RLEN,
Index: libiohelp/iouser-create.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libiohelp/iouser-create.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 iouser-create.c
--- libiohelp/iouser-create.c 2001/04/19 12:41:02 1.1.1.1
+++ libiohelp/iouser-create.c 2001/04/21 08:26:35
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1996 Free Software Foundation
+ Copyright (C) 1996,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,17 +17,95 @@
#include "iohelp.h"
-struct iouser *
-iohelp_create_iouser (struct idvec *uids, struct idvec *gids)
+error_t
+iohelp_create_iouser (struct iouser **user, struct idvec *uids,
+ struct idvec *gids)
{
struct iouser *new;
- new = malloc (sizeof (struct iouser));
+ *user = new = malloc (sizeof (struct iouser));
if (!new)
- return 0;
+ return ENOMEM;
new->uids = uids;
new->gids = gids;
new->hook = 0;
- return new;
+
+ return 0;
}
+#define E(err) \
+ do { \
+ if (err) \
+ { \
+ *user = 0; \
+ if (! uids) \
+ return err; \
+ idvec_free (uids); \
+ if (! gids) \
+ return err; \
+ idvec_free (gids); \
+ return err; \
+ } \
+ } while (0)
+
+error_t
+iohelp_create_empty_iouser (struct iouser **user)
+{
+ struct idvec *uids, *gids;
+
+ uids = make_idvec ();
+ if (! uids)
+ E (ENOMEM);
+
+ gids = make_idvec ();
+ if (! gids)
+ E (ENOMEM);
+
+ E (iohelp_create_iouser (user, uids, gids));
+
+ return 0;
+}
+
+error_t
+iohelp_create_simple_iouser (struct iouser **user, uid_t uid, gid_t gid)
+{
+ struct idvec *uids, *gids;
+
+ uids = make_idvec ();
+ if (! uids)
+ E (ENOMEM);
+
+ gids = make_idvec ();
+ if (! gids)
+ E (ENOMEM);
+
+ E (idvec_add (uids, uid));
+ E (idvec_add (gids, gid));
+
+ E (iohelp_create_iouser (user, uids, gids));
+
+ return 0;
+}
+
+error_t
+iohelp_create_complex_iouser (struct iouser **user,
+ uid_t *uvec, int nuids,
+ gid_t *gvec, int ngids)
+{
+ struct idvec *uids, *gids;
+
+ uids = make_idvec ();
+ if (! uids)
+ E (ENOMEM);
+
+ gids = make_idvec ();
+ if (! gids)
+ E (ENOMEM);
+
+ E (idvec_set_ids (uids, uvec, nuids));
+ E (idvec_set_ids (gids, gvec, ngids));
+
+ E (iohelp_create_iouser (user, uids, gids));
+
+ return 0;
+}
Index: libiohelp/iouser-dup.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libiohelp/iouser-dup.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 iouser-dup.c
--- libiohelp/iouser-dup.c 2001/04/19 12:41:02 1.1.1.1
+++ libiohelp/iouser-dup.c 2001/04/21 08:27:13
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1996 Free Software Foundation
+ Copyright (C) 1996,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,21 +17,24 @@
#include "iohelp.h"
-struct iouser *
-iohelp_dup_iouser (struct iouser *iouser)
+error_t
+iohelp_dup_iouser (struct iouser **clone, struct iouser *iouser)
{
struct iouser *new;
error_t err = 0;
- new = malloc (sizeof (struct iouser));
+ *clone = new = malloc (sizeof (struct iouser));
if (!new)
- return 0;
+ return ENOMEM;
new->uids = make_idvec ();
new->gids = make_idvec ();
new->hook = 0;
if (!new->uids || !new->gids)
- goto lose;
+ {
+ err = ENOMEM;
+ goto lose;
+ }
err = idvec_set (new->uids, iouser->uids);
if (!err)
@@ -45,7 +48,9 @@
if (new->gids)
idvec_free (new->gids);
free (new);
- return 0;
+ *clone = 0;
+ return err;
}
- return new;
+
+ return 0;
}
Index: libiohelp/iouser-reauth.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libiohelp/iouser-reauth.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 iouser-reauth.c
--- libiohelp/iouser-reauth.c 2001/04/19 12:41:02 1.1.1.1
+++ libiohelp/iouser-reauth.c 2001/04/21 08:27:59
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1996, 1999 Free Software Foundation
+ Copyright (C) 1996,99,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
@@ -26,8 +26,9 @@
PERMIT_FAILURE is nonzero, then should the transaction fail, return
an iouser that has no ids. The new port to be sent to the user is
newright. */
-struct iouser *iohelp_reauth (auth_t authserver, mach_port_t rend_port,
- mach_port_t newright, int permit_failure)
+error_t iohelp_reauth (struct iouser **user,
+ auth_t authserver, mach_port_t rend_port,
+ mach_port_t newright, int permit_failure)
{
uid_t gubuf[20], ggbuf[20], aubuf[20], agbuf[20];
uid_t *gen_uids, *gen_gids, *aux_uids, *aux_gids;
@@ -35,9 +36,9 @@
error_t err;
struct iouser *new;
- new = malloc (sizeof (struct iouser));
+ *user = new = malloc (sizeof (struct iouser));
if (!new)
- return 0;
+ return ENOMEM;
new->uids = make_idvec ();
new->gids = make_idvec ();
@@ -48,7 +49,7 @@
if (new->gids)
idvec_free (new->gids);
free (new);
- return 0;
+ return ENOMEM;
}
genuidlen = gengidlen = auxuidlen = auxgidlen = 20;
@@ -96,7 +97,10 @@
idvec_free (new->uids);
idvec_free (new->gids);
free (new);
- return 0;
+ *user = 0;
+ return err;
}
- return new;
+
+ *user = new;
+ return 0;
}
Index: libnetfs/ChangeLog
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/ChangeLog,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 ChangeLog
--- libnetfs/ChangeLog 2001/04/19 12:41:02 1.1.1.1
+++ libnetfs/ChangeLog 2001/04/21 08:20:05
@@ -1,3 +1,25 @@
+2001-04-01 Neal H Walfield <neal@cs.uml.edu>
+
+ * dir-lookup.c (netfs_S_dir_lookup): Use
+ iohelp_create_empty_iouser. Use iohelp_dup_iouser
+ as per the new semantics.
+ * dir-mkfile.c (netfs_S_dir_mkfile): Use iohelp_dup_iouser
+ as per the new semantics.
+ * file-exec.c (netfs_S_file_exec): Likewise.
+ * file-reparent.c (netfs_S_file_reparent): Likewise.
+ * fsys-getroot.c (netfs_S_fsys_getroot): Use
+ iohelp_create_complex_iouser.
+ * fsys-syncfs.c (netfs_S_fsys_syncfs): Use
+ iohelp_create_simple_iouser.
+ * io-duplicate.c (netfs_S_io_duplicate): Use iohelp_dup_iouser
+ as per the new semantics.
+ * io-reauthenticate.c (netfs_S_io_reauthenticate): Use
+ iohelp_reauth as per the new semantics.
+ * io-restric-auth.c (netfs_S_io_restric_auth): Use
+ iohelp_create_complex_iouser. Check return values.
+ * trans-callback.c (_netfs_transcallback2_fn): Use
+ iohelp_create_simple_iouser.
+
2001-04-01 Roland McGrath <roland@frob.com>
* Makefile (FSYSSRCS): Add fsys-goaway.c.
Index: libnetfs/dir-lookup.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/dir-lookup.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 dir-lookup.c
--- libnetfs/dir-lookup.c 2001/04/19 12:41:03 1.1.1.1
+++ libnetfs/dir-lookup.c 2001/04/21 08:16:08
@@ -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 @@
char *nextname;
error_t error;
struct protid *newpi;
+ struct iouser *user;
if (!diruser)
return EOPNOTSUPP;
@@ -233,26 +234,38 @@
/* 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)
{
netfs_nrele (dnp);
@@ -362,8 +375,12 @@
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);
Index: libnetfs/dir-mkfile.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/dir-mkfile.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 dir-mkfile.c
--- libnetfs/dir-mkfile.c 2001/04/19 12:41:03 1.1.1.1
+++ libnetfs/dir-mkfile.c 2001/04/21 08:16:08
@@ -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 @@
{
error_t err;
struct node *np;
+ struct iouser *user;
struct protid *newpi;
mutex_lock (&diruser->po->np->lock);
@@ -37,15 +38,19 @@
{
/* 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;
}
Index: libnetfs/file-exec.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/file-exec.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 file-exec.c
--- libnetfs/file-exec.c 2001/04/19 12:41:04 1.1.1.1
+++ libnetfs/file-exec.c 2001/04/21 08:16:08
@@ -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 @@
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)
Index: libnetfs/file-reparent.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/file-reparent.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 file-reparent.c
--- libnetfs/file-reparent.c 2001/04/19 12:41:04 1.1.1.1
+++ libnetfs/file-reparent.c 2001/04/21 08:16:08
@@ -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 @@
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)
Index: libnetfs/fsys-getroot.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/fsys-getroot.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 fsys-getroot.c
--- libnetfs/fsys-getroot.c 2001/04/19 12:41:05 1.1.1.1
+++ libnetfs/fsys-getroot.c 2001/04/21 08:16:22
@@ -43,19 +43,15 @@
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;
Index: libnetfs/fsys-syncfs.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/fsys-syncfs.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 fsys-syncfs.c
--- libnetfs/fsys-syncfs.c 2001/04/19 12:41:05 1.1.1.1
+++ libnetfs/fsys-syncfs.c 2001/04/21 08:16:28
@@ -29,12 +29,11 @@
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;
Index: libnetfs/io-duplicate.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/io-duplicate.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 io-duplicate.c
--- libnetfs/io-duplicate.c 2001/04/19 12:41:06 1.1.1.1
+++ libnetfs/io-duplicate.c 2001/04/21 08:16:28
@@ -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 @@
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;
Index: libnetfs/io-reauthenticate.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/io-reauthenticate.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 io-reauthenticate.c
--- libnetfs/io-reauthenticate.c 2001/04/19 12:41:07 1.1.1.1
+++ libnetfs/io-reauthenticate.c 2001/04/21 08:16:29
@@ -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 @@
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 @@
mutex_unlock (&user->po->np->lock);
ports_port_deref (newpi);
- return 0;
+ return err;
}
Index: libnetfs/io-restrict-auth.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/io-restrict-auth.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 io-restrict-auth.c
--- libnetfs/io-restrict-auth.c 2001/04/19 12:41:07 1.1.1.1
+++ libnetfs/io-restrict-auth.c 2001/04/21 08:16:29
@@ -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.
@@ -40,39 +40,77 @@
gid_t *gids,
mach_msg_type_number_t ngids)
{
+ error_t err;
struct idvec *uvec, *gvec;
int i;
struct protid *newpi;
+ struct iouser *new_user;
if (!user)
return EOPNOTSUPP;
- uvec = make_idvec ();
- gvec = make_idvec ();
-
if (idvec_contains (user->user->uids, 0))
{
- idvec_set_ids (uvec, uids, nuids);
- idvec_set_ids (gvec, gids, ngids);
+ err = iohelp_create_complex_iouser (&new_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;
+ }
+
for (i = 0; i < user->user->uids->num; i++)
if (listmember (uids, user->user->uids->ids[i], nuids))
- idvec_add (uvec, user->user->uids->ids[i]);
+ {
+ err = idvec_add (uvec, user->user->uids->ids[i]);
+ if (err)
+ goto out;
+ }
for (i = 0; i < user->user->gids->num; i++)
if (listmember (gids, user->user->gids->ids[i], ngids))
- idvec_add (gvec, user->user->gids->ids[i]);
+ {
+ err = idvec_add (gvec, user->user->gids->ids[i]);
+ if (err)
+ goto out;
+ }
+
+ err = iohelp_create_iouser (&new_user, uvec, gvec);
+
+ if (err)
+ {
+ out:
+ idvec_free (uvec);
+ idvec_free (gvec);
+ return err;
+ }
}
mutex_lock (&user->po->np->lock);
- newpi = netfs_make_protid (user->po, iohelp_create_iouser (uvec, gvec));
- *newport = ports_get_right (newpi);
- mutex_unlock (&user->po->np->lock);
+ newpi = netfs_make_protid (user->po, new_user);
+ if (newpi)
+ {
+ *newport = ports_get_right (newpi);
+ mutex_unlock (&user->po->np->lock);
+ *newporttype = MACH_MSG_TYPE_MAKE_SEND;
+ }
+ else
+ {
+ mutex_unlock (&user->po->np->lock);
+ iohelp_free_iouser (new_user);
+ err = ENOMEM;
+ }
- *newporttype = MACH_MSG_TYPE_MAKE_SEND;
ports_port_deref (newpi);
- return 0;
+ return err;
}
Index: libnetfs/trans-callback.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libnetfs/trans-callback.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 trans-callback.c
--- libnetfs/trans-callback.c 2001/04/19 12:41:09 1.1.1.1
+++ libnetfs/trans-callback.c 2001/04/21 08:16:29
@@ -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 @@
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);
Index: libtrivfs/ChangeLog
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libtrivfs/ChangeLog,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 ChangeLog
--- libtrivfs/ChangeLog 2001/04/19 12:41:28 1.1.1.1
+++ libtrivfs/ChangeLog 2001/04/21 08:16:29
@@ -1,3 +1,16 @@
+2001-04-01 Neal H Walfield <neal@cs.uml.edu>
+
+ * dir-lookup.c (trivfs_S_dir_lookup): Use
+ iohelp_dup_iouser as per the new semantics.
+ * fsys-getroot.c (trivfs_S_fsys_getroot): Use
+ iohelp_create_complex_iouser.
+ * io-reauthenticate.c (trivfs_S_io_reauthenticate):
+ Use iohelp_reauth as per the new semantics.
+ * io-restrict-auth.c (trivfs_S_io_restrict_auth):
+ Use iohelp_create_complex_iouser. Check return values.
+ * trivfs_protid_dup (trivfs_protid_dup): Use iohelp_dup_iouser
+ as per the new semantics.
+
2000-03-17 Thomas Bushnell, BSG <tb@mit.edu>
* startup.c (trivfs_startup): Don't use MAKE_SEND in Hurd RPC.
Index: libtrivfs/dir-lookup.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libtrivfs/dir-lookup.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 dir-lookup.c
--- libtrivfs/dir-lookup.c 2001/04/19 12:41:29 1.1.1.1
+++ libtrivfs/dir-lookup.c 2001/04/21 08:16:29
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994, 1998, 1999 Free Software Foundation
+ Copyright (C) 1994,98,99,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
@@ -64,7 +64,12 @@
err = (*trivfs_check_open_hook) (cred->po->cntl, cred->user, flags);
if (!err)
{
- struct iouser *user = iohelp_dup_iouser (cred->user);
+ struct iouser *user;
+
+ err = iohelp_dup_iouser (&user, cred->user);
+ if (err)
+ return err;
+
err = trivfs_open (cred->po->cntl, user, flags,
cred->realnode, &newcred);
if (err)
Index: libtrivfs/fsys-getroot.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libtrivfs/fsys-getroot.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 fsys-getroot.c
--- libtrivfs/fsys-getroot.c 2001/04/19 12:41:32 1.1.1.1
+++ libtrivfs/fsys-getroot.c 2001/04/21 08:16:29
@@ -44,7 +44,6 @@
mach_port_t new_realnode;
struct trivfs_protid *cred;
struct iouser *user;
- struct idvec *uvec, *gvec;
if (!cntl)
return EOPNOTSUPP;
@@ -75,11 +74,9 @@
if (err)
return err;
- uvec = make_idvec ();
- gvec = make_idvec ();
- idvec_set_ids (uvec, uids, nuids);
- idvec_set_ids (gvec, gids, ngids);
- user = iohelp_create_iouser (uvec, gvec); /* XXX check return value? */
+ err = iohelp_create_complex_iouser (&user, uids, nuids, gids, ngids);
+ if (err)
+ return err;
/* Validate permissions. */
if (! trivfs_check_access_hook)
Index: libtrivfs/io-reauthenticate.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libtrivfs/io-reauthenticate.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 io-reauthenticate.c
--- libtrivfs/io-reauthenticate.c 2001/04/19 12:41:33 1.1.1.1
+++ libtrivfs/io-reauthenticate.c 2001/04/21 08:16:29
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1993,94,95,96,2000 Free Software Foundation, Inc.
+ Copyright (C) 1993,94,95,96,2000,01 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -51,13 +51,15 @@
newright = ports_get_send_right (newcred);
assert (newright != MACH_PORT_NULL);
- newcred->user = iohelp_reauth (auth, rendport, newright, 1);
- if (idvec_contains (newcred->user->uids, 0))
- newcred->isroot = 1;
-
+ err = iohelp_reauth (&newcred->user, auth, rendport, newright, 1);
mach_port_deallocate (mach_task_self (), rendport);
- mach_port_deallocate (mach_task_self (), newright);
mach_port_deallocate (mach_task_self (), auth);
+ if (err)
+ return err;
+
+ mach_port_deallocate (mach_task_self (), newright);
+ if (idvec_contains (newcred->user->uids, 0))
+ newcred->isroot = 1;
newcred->hook = cred->hook;
Index: libtrivfs/io-restrict-auth.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libtrivfs/io-restrict-auth.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 io-restrict-auth.c
--- libtrivfs/io-restrict-auth.c 2001/04/19 12:41:33 1.1.1.1
+++ libtrivfs/io-restrict-auth.c 2001/04/21 08:16:29
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation
+ Copyright (C) 1993,94,95,96,2001 Free Software Foundation
This file is part of the GNU Hurd.
@@ -44,7 +44,7 @@
uid_t *gids, u_int ngids)
{
int i;
- error_t err = 0;
+ error_t err;
struct trivfs_protid *newcred;
struct idvec *uvec, *gvec;
struct iouser *user;
@@ -52,26 +52,51 @@
if (!cred)
return EOPNOTSUPP;
- uvec = make_idvec ();
- gvec = make_idvec ();
-
- user = iohelp_create_iouser (uvec, gvec);
-
if (cred->isroot)
+ /* 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]);
+ {
+ err = 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;
+ }
}
err = ports_create_port (cred->po->cntl->protid_class,
@@ -89,7 +114,7 @@
newcred->po = cred->po;
newcred->po->refcnt++;
mutex_unlock (&cred->po->cntl->lock);
- if (cred->isroot && idvec_contains (uvec, 0))
+ if (cred->isroot && idvec_contains (user->uids, 0))
newcred->isroot = 1;
newcred->user = user;
newcred->hook = cred->hook;
Index: libtrivfs/protid-dup.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/libtrivfs/protid-dup.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 protid-dup.c
--- libtrivfs/protid-dup.c 2001/04/19 12:41:34 1.1.1.1
+++ libtrivfs/protid-dup.c 2001/04/21 08:16:30
@@ -1,6 +1,6 @@
/* Duplicate a protid
- Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1993,94,95,96,2001 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -42,7 +42,12 @@
new->isroot = cred->isroot;
- new->user = iohelp_dup_iouser (cred->user);
+ err = iohelp_dup_iouser (&new->user, cred->user);
+ if (err)
+ {
+ ports_port_deref (new);
+ return err;
+ }
new->realnode = cred->realnode;
mach_port_mod_refs (mach_task_self (), new->realnode,
Index: term/ChangeLog
===================================================================
RCS file: /home/neal/shared/CVS/hurd/term/ChangeLog,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 ChangeLog
--- term/ChangeLog 2001/04/19 12:42:39 1.1.1.1
+++ term/ChangeLog 2001/04/21 08:16:30
@@ -1,3 +1,8 @@
+2001-04-01 Neal H Walfield <neal@cs.uml.edu>
+
+ * user.c (S_termctty_open_terminal): Use
+ iohelp_create_empty_iouser.
+
2000-07-26 Mark Kettenis <kettenis@gnu.org>
* Makefile (HURDLIBS): Reorder libs such that the threads lib
Index: term/users.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/term/users.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 users.c
--- term/users.c 2001/04/19 12:42:39 1.1.1.1
+++ term/users.c 2001/04/21 08:16:53
@@ -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.
@@ -378,6 +378,7 @@
{
error_t err;
mach_port_t new_realnode;
+ struct iouser *user;
struct trivfs_protid *newcred;
struct port_info *pi = ports_lookup_port (term_bucket, arg, cttyid_class);
@@ -390,9 +391,9 @@
if (!err)
{
- err = trivfs_open (termctl,
- iohelp_create_iouser (make_idvec (), make_idvec ()),
- flags, new_realnode, &newcred);
+ err = iohelp_create_empty_iouser (&user);
+ if (! err)
+ err = trivfs_open (termctl, user, flags, new_realnode, &newcred);
if (!err)
{
*result = ports_get_right (newcred);
Index: trans/ChangeLog
===================================================================
RCS file: /home/neal/shared/CVS/hurd/trans/ChangeLog,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 ChangeLog
--- trans/ChangeLog 2001/04/19 12:42:42 1.1.1.1
+++ trans/ChangeLog 2001/04/21 08:16:30
@@ -1,3 +1,8 @@
+2001-04-01 Neal H Walfield <neal@cs.uml.edu>
+
+ * magic.c (trivfs_S_dir_lookup): Use iohelp_dup_iouser
+ as per the new semantics.
+
2001-02-28 Roland McGrath <roland@frob.com>
* streamio.c (trivfs_modify_stat): Fix inverted sense of tests
Index: trans/magic.c
===================================================================
RCS file: /home/neal/shared/CVS/hurd/trans/magic.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 magic.c
--- trans/magic.c 2001/04/19 12:42:42 1.1.1.1
+++ trans/magic.c 2001/04/21 08:16:30
@@ -214,7 +214,9 @@
/* Execute the open */
dotdot = (mach_port_t) cred->po->hook;
- user = iohelp_dup_iouser (cred->user);
+ err = iohelp_dup_iouser (&user, cred->user);
+ if (err)
+ return err;
err = magic_open (cred->po->cntl, user, dotdot, flags,
cred->realnode, &newcred);
if (err)
pgprHW1dq6mGj.pgp
Description: PGP signature