aboutsummaryrefslogtreecommitdiff
path: root/runit/uidgid.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-10-05 22:50:22 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-10-05 22:50:22 +0000
commitde59c0f58fa5dc75b753f94da61be92bfa0935ec (patch)
treefea308471e3d73fb6770ff6e4cda23da53b65bec /runit/uidgid.c
parent01c27fc5ac89b07821a5430880d771e3c993c1c1 (diff)
downloadbusybox-de59c0f58fa5dc75b753f94da61be92bfa0935ec.tar.gz
httpd: add -u user[:grp] support
Diffstat (limited to 'runit/uidgid.c')
-rw-r--r--runit/uidgid.c63
1 files changed, 0 insertions, 63 deletions
diff --git a/runit/uidgid.c b/runit/uidgid.c
deleted file mode 100644
index a8fec409d..000000000
--- a/runit/uidgid.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <sys/types.h>
-#include <pwd.h>
-#include <grp.h>
-#include "uidgid.h"
-
-static unsigned str_chr(const char *s, int c)
-{
- const char *t = s;
- while (t[0] && t[0] != (char)c)
- t++;
- return t - s;
-}
-
-
-unsigned uidgid_get(struct uidgid *u, char *ug, unsigned dogrp) {
- char *g = 0;
- struct passwd *pwd = 0;
- struct group *gr = 0;
- int i, d = 0;
-
- if (dogrp)
- d = str_chr(ug, ':');
- if (ug[d] == ':') {
- ug[d] = 0;
- g = ug + d + 1;
- }
- pwd = getpwnam(ug);
- if (!pwd) {
- if (g) ug[d] = ':';
- return 0;
- }
- if (g) {
- ug[d] = ':';
- for (i = 0; i < 60; ++i) {
- d = str_chr(g, ':');
- if (g[d] == ':') {
- g[d] = 0;
- gr = getgrnam(g);
- if (!gr) {
- g[d] = ':';
- return 0;
- }
- g[d] = ':';
- u->gid[i] = gr->gr_gid;
- g += d+1;
- }
- else {
- gr = getgrnam(g);
- if (!gr) return 0;
- u->gid[i++] = gr->gr_gid;
- break;
- }
- }
- u->gid[i] = 0;
- u->gids = i;
- }
- if (!g) {
- u->gid[0] = pwd->pw_gid;
- u->gids = 1;
- }
- u->uid = pwd->pw_uid;
- return 1;
-}