|
|
|
@ -157,6 +157,24 @@ liProc* li_proc_new(liServer *srv, gchar **args, gchar **env, uid_t uid, gid_t g
|
|
|
|
|
|
|
|
|
|
setsid();
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_GETRLIMIT
|
|
|
|
|
{
|
|
|
|
|
struct rlimit rlim;
|
|
|
|
|
if (rlim_core >= 0) {
|
|
|
|
|
rlim.rlim_cur = rlim.rlim_max = ((guint64) rlim_core >= RLIM_INFINITY) ? RLIM_INFINITY : (guint64) rlim_core;
|
|
|
|
|
if (0 != setrlimit(RLIMIT_CORE, &rlim)) {
|
|
|
|
|
ERROR(srv, "couldn't set 'max core file size': %s", g_strerror(errno));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (rlim_nofile >= 0) {
|
|
|
|
|
rlim.rlim_cur = rlim.rlim_max = ((guint64) rlim_nofile >= RLIM_INFINITY) ? RLIM_INFINITY : (guint64) rlim_nofile;
|
|
|
|
|
if (0 != setrlimit(RLIMIT_NOFILE, &rlim)) {
|
|
|
|
|
ERROR(srv, "couldn't set 'max filedescriptors': %s", g_strerror(errno));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (gid != (gid_t) -1) {
|
|
|
|
|
setgid(gid);
|
|
|
|
|
setgroups(0, NULL);
|
|
|
|
@ -183,23 +201,6 @@ liProc* li_proc_new(liServer *srv, gchar **args, gchar **env, uid_t uid, gid_t g
|
|
|
|
|
li_proc_free(proc);
|
|
|
|
|
return NULL;
|
|
|
|
|
default:
|
|
|
|
|
#ifdef HAVE_GETRLIMIT
|
|
|
|
|
{
|
|
|
|
|
struct rlimit rlim;
|
|
|
|
|
if (rlim_core >= 0) {
|
|
|
|
|
rlim.rlim_cur = rlim.rlim_max = ((guint64) rlim_core >= RLIM_INFINITY) ? RLIM_INFINITY : (guint64) rlim_core;
|
|
|
|
|
if (0 != setrlimit(RLIMIT_CORE, &rlim)) {
|
|
|
|
|
ERROR(srv, "couldn't set 'max core file size': %s", g_strerror(errno));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (rlim_nofile >= 0) {
|
|
|
|
|
rlim.rlim_cur = rlim.rlim_max = ((guint64) rlim_nofile >= RLIM_INFINITY) ? RLIM_INFINITY : (guint64) rlim_nofile;
|
|
|
|
|
if (0 != setrlimit(RLIMIT_NOFILE, &rlim)) {
|
|
|
|
|
ERROR(srv, "couldn't set 'max filedescriptors': %s", g_strerror(errno));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
proc->child_pid = pid;
|
|
|
|
|
li_error_pipe_activate(proc->epipe);
|
|
|
|
|
break;
|
|
|
|
|