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