From 6bdccacf02e82eb15efcd7aa95b88a3e389a7026 Mon Sep 17 00:00:00 2001 From: udo Date: Mon, 6 Jul 2026 20:35:09 +0000 Subject: [PATCH] fix cli unit document root resolution --- src/linux_fastcgi.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/linux_fastcgi.cpp b/src/linux_fastcgi.cpp index 4521d98..3dd16b6 100644 --- a/src/linux_fastcgi.cpp +++ b/src/linux_fastcgi.cpp @@ -312,7 +312,16 @@ bool cli_path_is_safe(String command) String cli_resolve_unit_path(Request& request, String command, String& document_root) { - document_root = first(request.params["DOCUMENT_ROOT"], cwd_get()); + document_root = trim(first(request.params["DOCUMENT_ROOT"], request.server ? request.server->config["HTTP_DOCUMENT_ROOT"] : String(""))); + if(document_root == "" && request.server) + { + String site_directory = trim(request.server->config["SITE_DIRECTORY"]); + String compiler_root = trim(request.server->config["COMPILER_SYS_PATH"]); + if(site_directory != "") + document_root = site_directory[0] == '/' ? site_directory : path_join(compiler_root, site_directory); + } + if(document_root == "") + document_root = cwd_get(); if(document_root.length() > 1 && document_root[document_root.length()-1] == '/') document_root.resize(document_root.length()-1);