From 58a67df534cc5d94cc0f64de1d0a5ae26ce143b4 Mon Sep 17 00:00:00 2001 From: "roberto@oneiric64" Date: Sun, 29 Jan 2012 07:59:56 +0100 Subject: [PATCH] ported uid/gid to new api --- uwsgi.c | 18 ++++++++++++++++-- uwsgi.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/uwsgi.c b/uwsgi.c index 8d9c7905..333ecac8 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -149,9 +149,9 @@ static struct uwsgi_option uwsgi_base_options[] = { {"pidfile", required_argument, 0, "create pidfile (before privileges drop)", uwsgi_opt_set_str, &uwsgi.pidfile,0}, {"pidfile2", required_argument, 0, "create pidfile (after privileges drop)", uwsgi_opt_set_str, &uwsgi.pidfile2,0}, {"chroot", required_argument, 0, "chroot() to the specified directory", uwsgi_opt_set_str, &uwsgi.chroot,0}, + {"uid", required_argument, 0, "setuid to the specified user/uid", uwsgi_opt_set_uid, NULL, 0}, + {"gid", required_argument, 0, "setgid to the specified group/gid", uwsgi_opt_set_gid, NULL, 0}, /* - {"gid", required_argument, 0, LONG_ARGS_GID,0}, - {"uid", required_argument, 0, LONG_ARGS_UID,0}, #ifdef UWSGI_CAP {"cap", required_argument,0, LONG_ARGS_CAP,0}, #endif @@ -3295,6 +3295,20 @@ void uwsgi_opt_add_spooler(char *opt, char *directory, void *none) { } +void uwsgi_opt_set_uid(char *opt, char *value, void *none) { + + uwsgi.uid = atoi(value); + if (!uwsgi.uid) + uwsgi.uidname = value; +} + +void uwsgi_opt_set_gid(char *opt, char *value, void *none) { + + uwsgi.gid = atoi(value); + if (!uwsgi.gid) + uwsgi.gidname = value; +} + void uwsgi_opt_load_plugin(char *opt, char *value, void *none) { char *p = strtok(uwsgi_concat2(value, ""), ","); while (p != NULL) { diff --git a/uwsgi.h b/uwsgi.h index 061b275f..6cf1df64 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -2508,6 +2508,8 @@ void uwsgi_opt_load_yml(char *, char *, void *); void uwsgi_opt_set_umask(char *, char *, void *); void uwsgi_opt_add_spooler(char *, char *, void *); +void uwsgi_opt_set_uid(char *, char *, void *); +void uwsgi_opt_set_gid(char *, char *, void *); #ifdef UWSGI_AS_SHARED_LIBRARY int uwsgi_init(int, char **, char **);