altarch-user / rpms / httpd

Forked from rpms/httpd 2 years ago
Clone

Blame SOURCES/httpd-2.4.6-r1811831.patch

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