[nginx] Rewrite: fixed "if" with relative file names.
Maxim Dounin
mdounin at mdounin.ru
Tue May 26 01:00:23 UTC 2026
details: http://freenginx.org/hg/nginx/rev/da5c3e04fa8b
branches:
changeset: 9531:da5c3e04fa8b
user: Maxim Dounin <mdounin at mdounin.ru>
date: Tue May 26 03:19:57 2026 +0300
description:
Rewrite: fixed "if" with relative file names.
Previously, relative file names in "if" were not specifically handled
and therefore resolved from the process current working directory,
leading to changes in behaviour depending on the current directory
during startup. This also differs from the expected behaviour of paths
used in the configuration, which are expected to be resolved either from
prefix or from configuration prefix.
The fix is to use ngx_get_full_name() in ngx_http_script_file_code(),
so relative paths, if used, are resolved from prefix.
diffstat:
src/http/ngx_http_script.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diffs (18 lines):
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -1606,6 +1606,14 @@ ngx_http_script_file_code(ngx_http_scrip
r = e->request;
+ if (ngx_get_full_name(r->pool, (ngx_str_t *) &ngx_cycle->prefix, &path)
+ != NGX_OK)
+ {
+ e->ip = ngx_http_script_exit;
+ e->status = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ return;
+ }
+
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http script file op %p \"%V\"", (void *) code->op, &path);
More information about the nginx-devel
mailing list