aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-06-15 22:30:56 -0300
committerAnna (navi) Figueiredo Gomes <navi@vlhl.dev>2023-10-19 10:56:54 +0200
commit0c69c923f7daaeaf327a063b31135e51d696d391 (patch)
tree319a5cb038b2e8f5125a364b33f0abb656159e4a /src/shared
parent249a920b64f87217b8ba5f9b0b3f1bacdd1e189f (diff)
misc.c: use userenv_whitelist in the env filtering
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/misc.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/shared/misc.c b/src/shared/misc.c
index 11393d33..b6001d77 100644
--- a/src/shared/misc.c
+++ b/src/shared/misc.c
@@ -67,6 +67,19 @@ static const char *const env_whitelist[] = {
NULL
};
+#ifdef RC_USER_SERVICES
+/* Needed for local user services to be found */
+static const char *const userenv_whitelist[] = {
+ "HOME",
+ "XDG_RUNTIME_DIR",
+ "XDG_CONFIG_HOME",
+ "XDG_CACHE_HOME",
+ "RC_USER_SERVICES",
+ "RC_PAM_STARTING",
+ "RC_PAM_STOPPING",
+};
+#endif
+
void
env_filter(void)
{
@@ -80,17 +93,6 @@ env_filter(void)
/* Add the user defined list of vars */
env_allow = rc_stringlist_split(rc_conf_value("rc_env_allow"), " ");
-#ifdef RC_USER_SERVICES
- /* Needed for local user services to be found */
- if (rc_is_user()) {
- rc_stringlist_addu(env_allow, "HOME");
- rc_stringlist_addu(env_allow, "XDG_RUNTIME_DIR");
- rc_stringlist_addu(env_allow, "XDG_CONFIG_HOME");
- rc_stringlist_addu(env_allow, "RC_USER_SERVICES");
- rc_stringlist_addu(env_allow, "RC_PAM_STARTING");
- rc_stringlist_addu(env_allow, "RC_PAM_STOPPING");
- }
-#endif
/*
* If '*' is an entry in rc_env_allow, do nothing as we are to pass
* through all environment variables.
@@ -119,6 +121,18 @@ env_filter(void)
if (env_whitelist[i])
continue;
+#ifdef RC_USER_SERVICES
+ if (rc_is_user() ) {
+ for (i = 0; userenv_whitelist[i]; i++) {
+ if (strcmp(userenv_whitelist[i], env->value) == 0)
+ break;
+ }
+
+ if (env_whitelist[i])
+ continue;
+ }
+#endif
+
/* Check our user defined list */
if (rc_stringlist_find(env_allow, env->value))
continue;