mirror of
https://github.com/clearlinux/uwsgi.git
synced 2026-09-06 05:31:44 +00:00
added --add-gid
This commit is contained in:
@@ -488,6 +488,31 @@ void uwsgi_as_root() {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
struct uwsgi_string_list *usl;
|
||||
size_t ags = 0;
|
||||
uwsgi_foreach(usl, uwsgi.additional_gids) ags++;
|
||||
if (ags > 0) {
|
||||
gid_t *ags_list = uwsgi_calloc(sizeof(gid_t) * ags);
|
||||
size_t g_pos = 0;
|
||||
uwsgi_foreach(usl, uwsgi.additional_gids) {
|
||||
ags_list[g_pos] = atoi(usl->value);
|
||||
if (!ags_list[g_pos]) {
|
||||
struct group *g = getgrnam(usl->value);
|
||||
if (g) {
|
||||
ags_list[g_pos] = g->gr_gid;
|
||||
}
|
||||
else {
|
||||
uwsgi_log("unable to find group %s\n", usl->value);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
g_pos++;
|
||||
}
|
||||
if (setgroups(ags, ags_list)) {
|
||||
uwsgi_error("setgroups()");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
int additional_groups = getgroups(0, NULL);
|
||||
if (additional_groups > 0) {
|
||||
gid_t *gids = uwsgi_calloc(sizeof(gid_t) * additional_groups);
|
||||
|
||||
@@ -287,6 +287,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
|
||||
{"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},
|
||||
{"add-gid", required_argument, 0, "add the specified group id to the process credentials", uwsgi_opt_add_string_list, &uwsgi.additional_gids, 0},
|
||||
{"immediate-uid", required_argument, 0, "setuid to the specified user/uid IMMEDIATELY", uwsgi_opt_set_immediate_uid, NULL, UWSGI_OPT_IMMEDIATE},
|
||||
{"immediate-gid", required_argument, 0, "setgid to the specified group/gid IMMEDIATELY", uwsgi_opt_set_immediate_gid, NULL, UWSGI_OPT_IMMEDIATE},
|
||||
{"no-initgroups", no_argument, 0, "disable additional groups set via initgroups()", uwsgi_opt_true, &uwsgi.no_initgroups, 0},
|
||||
|
||||
Reference in New Issue
Block a user