diff options
author | Gerrit Pape <pape@smarden.org> | 2007-04-17 07:49:09 +0000 |
---|---|---|
committer | Gerrit Pape <pape@innominate.com> | 2007-04-17 07:49:09 +0000 |
commit | cf45c27c0b81d495e961ac83a8bbd9b6569047a7 (patch) | |
tree | 423d0f22e8ec954db6c1060d50463ac64bc5921b /src/uidgid.c | |
parent | 157727221652084a17037478826af086127a6956 (diff) | |
download | runit-cf45c27c0b81d495e961ac83a8bbd9b6569047a7.tar.gz runit-cf45c27c0b81d495e961ac83a8bbd9b6569047a7.tar.xz runit-cf45c27c0b81d495e961ac83a8bbd9b6569047a7.zip |
chpst.c, uidgid.c: improve error reporting if getpwnam() or getgrnam() fails
...cleanup.
Diffstat (limited to 'src/uidgid.c')
-rw-r--r-- | src/uidgid.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/uidgid.c b/src/uidgid.c index 718d7a9..befa754 100644 --- a/src/uidgid.c +++ b/src/uidgid.c @@ -42,10 +42,10 @@ unsigned int uidgids_get(struct uidgid *u, char *ug) { int i, d =0; if (*ug == ':') return(uidgids_set(u, ug +1)); - if (ug[(d =str_chr(ug, ':'))] == ':') { - ug[d] =0; - g =ug +d +1; - } + if (ug[(d =str_chr(ug, ':'))] == ':') { + ug[d] =0; + g =ug +d +1; + } if (! (pwd =getpwnam(ug))) { if (g) ug[d] =':'; return(0); } u->uid =pwd->pw_uid; if (! g) { @@ -53,22 +53,22 @@ unsigned int uidgids_get(struct uidgid *u, char *ug) { u->gids =1; return(1); } - ug[d] =':'; - for (i =0; i < 60; ++i) { - if (g[(d =str_chr(g, ':'))] == ':') { - g[d] =0; - if (! (gr =getgrnam(g))) { g[d] =':'; return(0); } - g[d] =':'; - u->gid[i] =gr->gr_gid; - g +=d +1; - } - else { - if (! (gr =getgrnam(g))) return(0); - u->gid[i++] =gr->gr_gid; - break; - } + ug[d] =':'; + for (i =0; i < 60; ++i) { + if (g[(d =str_chr(g, ':'))] == ':') { + g[d] =0; + if (! (gr =getgrnam(g))) { g[d] =':'; return(0); } + g[d] =':'; + u->gid[i] =gr->gr_gid; + g +=d +1; + } + else { + if (! (gr =getgrnam(g))) return(0); + u->gid[i++] =gr->gr_gid; + break; } - u->gid[i] =0; - u->gids =i; + } + u->gid[i] =0; + u->gids =i; return(1); } |