diff --git a/uwsgi.c b/uwsgi.c index 4f9e3bac..5f0355b3 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -2741,9 +2741,29 @@ void manage_opt(int i, char *optarg) { break; case LONG_ARGS_GID: uwsgi.gid = atoi(optarg); + if (!uwsgi.gid) { + struct group *ugroup = getgrnam(optarg); + if (ugroup) { + uwsgi.gid = ugroup->gr_gid ; + } + else { + uwsgi_log("group %s not found.\n", optarg); + exit(1); + } + } break; case LONG_ARGS_UID: uwsgi.uid = atoi(optarg); + if (!uwsgi.uid) { + struct passwd *upasswd = getpwnam(optarg); + if (upasswd) { + uwsgi.uid = upasswd->pw_uid ; + } + else { + uwsgi_log("user %s not found.\n", optarg); + exit(1); + } + } break; case LONG_ARGS_BINARY_PATH: uwsgi.binary_path = optarg; diff --git a/uwsgi.h b/uwsgi.h index bf654a85..524b74c2 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -19,6 +19,10 @@ #include +#include +#include + + #include // linux has not strlcpy