Core: skipped path ownership changes during configuration testing.

When the "user" directive is in effect and "nginx -t" or "nginx -T" is run by a user different
  from the one nginx normally runs as (notably as root, while workers run as an unprivileged packager-provided user such as "nginx" or "www-data"), ngx_create_paths() changed the ownership of the
  temporary directories (proxy_temp, client_body_temp, etc.) to the configured user. This left the directories owned by the wrong user for the instance that is actually running, resulting in a permission
  mismatch.

Configuration testing is not expected to modify filesystem state, so ownership and permission changes are now skipped when ngx_test_config is set. Directories are still created as before.
This commit is contained in:
Gustavo Kennedy Renkel 2026-06-18 18:39:42 -03:00
parent ebd18ec181
commit 1571f10fad

View file

@ -614,7 +614,7 @@ ngx_create_paths(ngx_cycle_t *cycle, ngx_uid_t user)
}
}
if (user == (ngx_uid_t) NGX_CONF_UNSET_UINT) {
if (user == (ngx_uid_t) NGX_CONF_UNSET_UINT || ngx_test_config) {
continue;
}