diff options
author | Roland McGrath <roland@gnu.org> | 2001-06-16 20:22:14 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-06-16 20:22:14 +0000 |
commit | a2529808d1aaf878eb6fff54ab491bd3d47db894 (patch) | |
tree | 426a3711fbb7be96251412ca626976c1246439a8 /libiohelp/iouser-create.c | |
parent | 93054f14cb52bfd576e4ecfdcf0bc1c468e4cbbf (diff) | |
download | hurd-a2529808d1aaf878eb6fff54ab491bd3d47db894.tar.gz hurd-a2529808d1aaf878eb6fff54ab491bd3d47db894.tar.bz2 hurd-a2529808d1aaf878eb6fff54ab491bd3d47db894.zip |
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.
Diffstat (limited to 'libiohelp/iouser-create.c')
-rw-r--r-- | libiohelp/iouser-create.c | 90 |
1 files changed, 84 insertions, 6 deletions
diff --git a/libiohelp/iouser-create.c b/libiohelp/iouser-create.c index fab77787..c67cff77 100644 --- a/libiohelp/iouser-create.c +++ b/libiohelp/iouser-create.c @@ -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; +} |