mirror of
https://github.com/nginx/nginx.git
synced 2026-11-19 06:36:09 +00:00
Core: working_directory validation
Some checks are pending
buildbot / buildbot (push) Waiting to run
Some checks are pending
buildbot / buildbot (push) Waiting to run
Previously, an invalid working_directory was only detected on worker process startup: if chdir() failed, worker processes exited and were not respawned, while "nginx -t" reported success. Now the directory is checked during configuration parsing. Note that this doesn't cover insufficient permissions for worker processes.
This commit is contained in:
parent
0e20f1fb0f
commit
80f0b3b840
1 changed files with 16 additions and 0 deletions
|
|
@ -1232,9 +1232,25 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
|
|||
|
||||
|
||||
if (ccf->working_directory.len) {
|
||||
ngx_file_info_t fi;
|
||||
|
||||
if (ngx_conf_full_name(cycle, &ccf->working_directory, 0) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_file_info(ccf->working_directory.data, &fi) == NGX_FILE_ERROR) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
||||
ngx_file_info_n " \"%s\" failed",
|
||||
ccf->working_directory.data);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (!ngx_is_dir(&fi)) {
|
||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
||||
"\"%s\" is not a directory",
|
||||
ccf->working_directory.data);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue