diff options
Diffstat (limited to 'src/chpst.c')
-rw-r--r-- | src/chpst.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/chpst.c b/src/chpst.c index ae07e36..9df2fb6 100644 --- a/src/chpst.c +++ b/src/chpst.c @@ -61,30 +61,40 @@ const char *lock =0; const char *root =0; unsigned int lockdelay; -void suidgid(char *user, unsigned int dogrp) { +void suidgid(char *user, unsigned int ext) { struct uidgid ugid; - if (! uidgid_get(&ugid, user, dogrp)) { - if (dogrp) + if (ext) { + if (! uidgids_get(&ugid, user)) { + if (*user == ':') + fatalx("invalid uid/gids", user +1); + else fatalx("unknown user/group", user); + } + } else + if (! uidgid_get(&ugid, user)) fatalx("unknown account", user); - } if (setgroups(ugid.gids, ugid.gid) == -1) fatal("unable to setgroups"); if (setgid(*ugid.gid) == -1) fatal("unable to setgid"); if (prot_uid(ugid.uid) == -1) fatal("unable to setuid"); } -void euidgid(char *user, unsigned int dogrp) { +void euidgid(char *user, unsigned int ext) { struct uidgid ugid; char bufnum[FMT_ULONG]; - if (! uidgid_get(&ugid, user, dogrp)) { - if (dogrp) + if (ext) { + if (! uidgids_get(&ugid, user)) { + if (*user == ':') + fatalx("invalid uid/gids", user +1); + else fatalx("unknown user/group", user); + } + } else + if (! uidgid_get(&ugid, user)) fatalx("unknown account", user); - } bufnum[fmt_ulong(bufnum, *ugid.gid)] =0; if (! pathexec_env("GID", bufnum)) die_nomem(); bufnum[fmt_ulong(bufnum, ugid.uid)] =0; |