From c2c3841c823f1c245829fbccad78c0ec89e19c1a Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Wed, 15 Aug 2007 20:53:30 +0000 Subject: [PATCH] set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and worker_rlimit_sigpending without super-user privileges testing --- src/os/unix/ngx_process_cycle.c | 60 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index 90993966d..c7e2fd46d 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -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);