summary refs log tree commit diff
path: root/src/chpst.c
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2006-11-02 22:59:14 +0000
committerGerrit Pape <pape@smarden.org>2006-11-02 22:59:14 +0000
commita1bbb6ddcf9119220c509c2e6424cf6a5a20d984 (patch)
treee1691179493adeaa9e59410895afc47b50f2f704 /src/chpst.c
parentc09a0fe2d6721235b106745b03e2992f0d35fc24 (diff)
downloadrunit-a1bbb6ddcf9119220c509c2e6424cf6a5a20d984.tar.gz
runit-a1bbb6ddcf9119220c509c2e6424cf6a5a20d984.tar.xz
runit-a1bbb6ddcf9119220c509c2e6424cf6a5a20d984.zip
* chpst.c, uidgid.c, uidgid.h: support numerical uid gid through
    chpst -[u|U] :uid:gid...
  * man/chpst.8: adapt; clarify that users and groups are looked up in
    /etc/passwd and /etc/group only.
  * sv.c: properly wait for a service to be restarted on 'restart';
    support checks through -v for pause, cont, kill.
Diffstat (limited to 'src/chpst.c')
-rw-r--r--src/chpst.c26
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;