Skip to content

Commit 3843662

Browse files
committed
shared/misc: allow globs in rc_env_allow
1 parent a5510be commit 3843662

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/shared/misc.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <ctype.h>
1919
#include <errno.h>
2020
#include <fcntl.h>
21+
#include <fnmatch.h>
2122
#include <limits.h>
2223
#ifdef HAVE_LINUX_CLOSE_RANGE_H
2324
# include <linux/close_range.h>
@@ -129,18 +130,22 @@ env_filter(void)
129130
}
130131

131132
TAILQ_FOREACH(env, env_list, entries) {
133+
RC_STRING *var;
134+
132135
/* Check the whitelist */
133136
if (env_allowed(env_allowlist, env->value))
134137
continue;
135138
if (rc_is_user() && env_allowed(usrenv_allowlist, env->value))
136139
continue;
137140

138141
/* Check our user defined list */
139-
if (rc_stringlist_find(env_allow, env->value))
140-
continue;
142+
TAILQ_FOREACH(var, env_allow, entries)
143+
if (fnmatch(var->value, env->value, FNM_NOESCAPE | FNM_PERIOD) == 0)
144+
goto next;
141145

142146
/* OK, not allowed! */
143147
unsetenv(env->value);
148+
next:;
144149
}
145150

146151
/* Now add anything missing from the profile */

0 commit comments

Comments
 (0)