arrfab / rpms / httpd

Forked from rpms/httpd 5 years ago
Clone

Blame SOURCES/httpd-2.4.6-r1811831.patch

b19d6e
--- a/server/util_script.c  2017/10/11 14:41:00 1811830
b19d6e
+++ b/server/util_script.c  2017/10/11 14:48:55 1811831
b19d6e
@@ -92,9 +92,21 @@
b19d6e
     }
b19d6e
 }
b19d6e
 
b19d6e
-static void env2env(apr_table_t *table, const char *name)
b19d6e
+/* Sets variable @name in table @dest from r->subprocess_env if
b19d6e
+ * available, else from the environment, else from @fallback if
b19d6e
+ * non-NULL. */
b19d6e
+static void env2env(apr_table_t *dest, request_rec *r,
b19d6e
+                    const char *name, const char *fallback)
b19d6e
 {
b19d6e
-    add_unless_null(table, name, getenv(name));
b19d6e
+    const char *val;
b19d6e
+
b19d6e
+    val = apr_table_get(r->subprocess_env, name);
b19d6e
+    if (!val)
b19d6e
+        val = apr_pstrdup(r->pool, getenv(name));
b19d6e
+    if (!val)
b19d6e
+        val = apr_pstrdup(r->pool, fallback);
b19d6e
+    if (val)
b19d6e
+        apr_table_addn(dest, name, val);
b19d6e
 }
b19d6e
 
b19d6e
 AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t)
b19d6e
@@ -211,37 +223,29 @@
b19d6e
             add_unless_null(e, http2env(r, hdrs[i].key), hdrs[i].val);
b19d6e
     }
b19d6e
 
b19d6e
-    env_temp = apr_table_get(r->subprocess_env, "PATH");
b19d6e
-    if (env_temp == NULL) {
b19d6e
-        env_temp = getenv("PATH");
b19d6e
-    }
b19d6e
-    if (env_temp == NULL) {
b19d6e
-        env_temp = DEFAULT_PATH;
b19d6e
-    }
b19d6e
-    apr_table_addn(e, "PATH", apr_pstrdup(r->pool, env_temp));
b19d6e
-
b19d6e
+    env2env(e, r, "PATH", DEFAULT_PATH);
b19d6e
 #if defined(WIN32)
b19d6e
-    env2env(e, "SystemRoot");
b19d6e
-    env2env(e, "COMSPEC");
b19d6e
-    env2env(e, "PATHEXT");
b19d6e
-    env2env(e, "WINDIR");
b19d6e
+    env2env(e, r, "SystemRoot", NULL);
b19d6e
+    env2env(e, r, "COMSPEC", NULL);
b19d6e
+    env2env(e, r, "PATHEXT", NULL);
b19d6e
+    env2env(e, r, "WINDIR", NULL);
b19d6e
 #elif defined(OS2)
b19d6e
-    env2env(e, "COMSPEC");
b19d6e
-    env2env(e, "ETC");
b19d6e
-    env2env(e, "DPATH");
b19d6e
-    env2env(e, "PERLLIB_PREFIX");
b19d6e
+    env2env(e, r, "COMSPEC", NULL);
b19d6e
+    env2env(e, r, "ETC", NULL);
b19d6e
+    env2env(e, r, "DPATH", NULL);
b19d6e
+    env2env(e, r, "PERLLIB_PREFIX", NULL);
b19d6e
 #elif defined(BEOS)
b19d6e
-    env2env(e, "LIBRARY_PATH");
b19d6e
+    env2env(e, r, "LIBRARY_PATH", NULL);
b19d6e
 #elif defined(DARWIN)
b19d6e
-    env2env(e, "DYLD_LIBRARY_PATH");
b19d6e
+    env2env(e, r, "DYLD_LIBRARY_PATH", NULL);
b19d6e
 #elif defined(_AIX)
b19d6e
-    env2env(e, "LIBPATH");
b19d6e
+    env2env(e, r, "LIBPATH", NULL);
b19d6e
 #elif defined(__HPUX__)
b19d6e
     /* HPUX PARISC 2.0W knows both, otherwise redundancy is harmless */
b19d6e
-    env2env(e, "SHLIB_PATH");
b19d6e
-    env2env(e, "LD_LIBRARY_PATH");
b19d6e
+    env2env(e, r, "SHLIB_PATH", NULL);
b19d6e
+    env2env(e, r, "LD_LIBRARY_PATH", NULL);
b19d6e
 #else /* Some Unix */
b19d6e
-    env2env(e, "LD_LIBRARY_PATH");
b19d6e
+    env2env(e, r, "LD_LIBRARY_PATH", NULL);
b19d6e
 #endif
b19d6e
 
b19d6e
     apr_table_addn(e, "SERVER_SIGNATURE", ap_psignature("", r));