diff --git a/utils.c b/utils.c index 72eb2235..4d81be12 100644 --- a/utils.c +++ b/utils.c @@ -218,8 +218,59 @@ void internal_server_error(int fd, char *message) { void uwsgi_as_root() { +#ifdef __linux__ + char *cgroup_taskfile; + int i; + FILE *cgroup; + char *cgroup_opt; +#endif + if (!getuid()) { uwsgi_log("uWSGI running as root, you can use --uid/--gid/--chroot options\n"); + +#ifdef __linux__ + if (uwsgi.cgroup) { + cgroup_taskfile = uwsgi_concat2(uwsgi.cgroup, "/tasks"); + cgroup = fopen(cgroup_taskfile, "w"); + if (!cgroup) { + uwsgi_error("fopen"); + exit(1); + } + if (fprintf(cgroup, "%d\n", (int) getpid()) < 0) { + uwsgi_log( "could not set cgroup\n"); + exit(1); + } + fclose(cgroup); + free(cgroup_taskfile); + + for(i=0;i