This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 2daf029577f5f8f12ce276bc2b51915b43741fbf
Author: Brian Neradt <[email protected]>
AuthorDate: Wed Feb 4 16:47:15 2026 -0600

    Fix header_rewrite run-plugin relative path resolution (#12855)
    
    The plugin factory was not initialized when header_rewrite was used
    only as a remap plugin without a geo database. This caused run-plugin
    with relative paths to fail because there were no search directories
    configured. Now initHRWLibraries() is always called in
    TSRemapNewInstance().
    
    Added a test to the header_rewrite bundle to verify run-plugin works
    with relative paths in remap mode.
    
    (cherry picked from commit 981f4499273e6280db22e9d2dd172a4f6c245f29)
---
 plugins/header_rewrite/header_rewrite.cc           | 13 ++++++-----
 .../header_rewrite/rules/run_plugin.conf           | 25 ++++++++++++++++++++++
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/plugins/header_rewrite/header_rewrite.cc 
b/plugins/header_rewrite/header_rewrite.cc
index 91ac9a7f4c..d1f4ad16ed 100644
--- a/plugins/header_rewrite/header_rewrite.cc
+++ b/plugins/header_rewrite/header_rewrite.cc
@@ -501,15 +501,18 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, 
char * /* errbuf ATS_UNUSE
     }
   }
 
-  if (!geoDBpath.empty()) {
-    if (geoDBpath.find('/') != 0) {
-      geoDBpath = std::string(TSConfigDirGet()) + '/' + geoDBpath;
-    }
+  if (!geoDBpath.empty() && !geoDBpath.starts_with('/')) {
+    geoDBpath = std::string(TSConfigDirGet()) + '/' + geoDBpath;
+  }
 
+  if (!geoDBpath.empty()) {
     Dbg(pi_dbg_ctl, "Remap geo db %s", geoDBpath.c_str());
-    std::call_once(initHRWLibs, [&geoDBpath]() { initHRWLibraries(geoDBpath); 
});
   }
 
+  // Always initialize the plugin factory, even if no geo DB is specified. This
+  // is needed for run-plugin to work with relative paths.
+  std::call_once(initHRWLibs, [&geoDBpath]() { initHRWLibraries(geoDBpath); });
+
   RulesConfig *conf = new RulesConfig;
 
   for (int i = optind; i < argc; ++i) {
diff --git a/tests/gold_tests/pluginTest/header_rewrite/rules/run_plugin.conf 
b/tests/gold_tests/pluginTest/header_rewrite/rules/run_plugin.conf
new file mode 100644
index 0000000000..af55270d00
--- /dev/null
+++ b/tests/gold_tests/pluginTest/header_rewrite/rules/run_plugin.conf
@@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Test run-plugin operator with a relative plugin path.
+# This verifies that the plugin factory is properly initialized when
+# header_rewrite is used as a remap plugin without a geo database.
+# We use multiplexer.so because with no arguments it creates an empty
+# instance and just returns TSREMAP_NO_REMAP, allowing the request to
+# proceed normally to the backend.
+cond %{REMAP_PSEUDO_HOOK}
+  run-plugin multiplexer.so

Reply via email to