mirror of
https://github.com/nginx/nginx.git
synced 2025-01-24 15:16:39 -06:00
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
worker_rlimit_sigpending without super-user privileges testing
This commit is contained in:
parent
966e2a5736
commit
4edb1d61e9
@ -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 New Issue
Block a user