set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
worker_rlimit_sigpending without super-user privileges testing
This commit is contained in:
parent
2fb58ed49e
commit
c2c3841c82
1 changed files with 30 additions and 30 deletions
|
@ -792,49 +792,49 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
|
|||
|
||||
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
||||
|
||||
if (geteuid() == 0) {
|
||||
if (priority && ccf->priority != 0) {
|
||||
if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||
"setpriority(%d) failed", ccf->priority);
|
||||
}
|
||||
if (priority && ccf->priority != 0) {
|
||||
if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"setpriority(%d) failed", ccf->priority);
|
||||
}
|
||||
}
|
||||
|
||||
if (ccf->rlimit_nofile != NGX_CONF_UNSET) {
|
||||
rlmt.rlim_cur = (rlim_t) ccf->rlimit_nofile;
|
||||
rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile;
|
||||
if (ccf->rlimit_nofile != NGX_CONF_UNSET) {
|
||||
rlmt.rlim_cur = (rlim_t) ccf->rlimit_nofile;
|
||||
rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile;
|
||||
|
||||
if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||
"setrlimit(RLIMIT_NOFILE, %i) failed",
|
||||
ccf->rlimit_nofile);
|
||||
}
|
||||
if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"setrlimit(RLIMIT_NOFILE, %i) failed",
|
||||
ccf->rlimit_nofile);
|
||||
}
|
||||
}
|
||||
|
||||
if (ccf->rlimit_core != NGX_CONF_UNSET_SIZE) {
|
||||
rlmt.rlim_cur = (rlim_t) ccf->rlimit_core;
|
||||
rlmt.rlim_max = (rlim_t) ccf->rlimit_core;
|
||||
if (ccf->rlimit_core != NGX_CONF_UNSET_SIZE) {
|
||||
rlmt.rlim_cur = (rlim_t) ccf->rlimit_core;
|
||||
rlmt.rlim_max = (rlim_t) ccf->rlimit_core;
|
||||
|
||||
if (setrlimit(RLIMIT_CORE, &rlmt) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||
"setrlimit(RLIMIT_CORE, %i) failed",
|
||||
ccf->rlimit_core);
|
||||
}
|
||||
if (setrlimit(RLIMIT_CORE, &rlmt) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"setrlimit(RLIMIT_CORE, %i) failed",
|
||||
ccf->rlimit_core);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RLIMIT_SIGPENDING
|
||||
if (ccf->rlimit_sigpending != NGX_CONF_UNSET) {
|
||||
rlmt.rlim_cur = (rlim_t) ccf->rlimit_sigpending;
|
||||
rlmt.rlim_max = (rlim_t) ccf->rlimit_sigpending;
|
||||
if (ccf->rlimit_sigpending != NGX_CONF_UNSET) {
|
||||
rlmt.rlim_cur = (rlim_t) ccf->rlimit_sigpending;
|
||||
rlmt.rlim_max = (rlim_t) ccf->rlimit_sigpending;
|
||||
|
||||
if (setrlimit(RLIMIT_SIGPENDING, &rlmt) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||
"setrlimit(RLIMIT_SIGPENDING, %i) failed",
|
||||
ccf->rlimit_sigpending);
|
||||
}
|
||||
if (setrlimit(RLIMIT_SIGPENDING, &rlmt) == -1) {
|
||||
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
||||
"setrlimit(RLIMIT_SIGPENDING, %i) failed",
|
||||
ccf->rlimit_sigpending);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (geteuid() == 0) {
|
||||
if (setgid(ccf->group) == -1) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||
"setgid(%d) failed", ccf->group);
|
||||
|
|
Loading…
Reference in a new issue