diff options
author | Mike Frysinger <vapier@gentoo.org> | 2012-12-27 01:28:17 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2013-02-24 23:05:05 -0500 |
commit | 97ea4d6d14ae90bd6371936fd6a718df0f62efba (patch) | |
tree | ea707ff91d0e1c0c38f499c9fa14c4f97dd52f7c /libsandbox/wrapper-funcs | |
parent | environ: merge is_env_{on,off} into a single file (diff) | |
download | sandbox-97ea4d6d14ae90bd6371936fd6a718df0f62efba.tar.gz sandbox-97ea4d6d14ae90bd6371936fd6a718df0f62efba.tar.bz2 sandbox-97ea4d6d14ae90bd6371936fd6a718df0f62efba.zip |
environ: add a new is_env_var helper for checking var names
This is laying the ground work for processing more vars in the
future than just LD_PRELOAD.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox/wrapper-funcs')
-rw-r--r-- | libsandbox/wrapper-funcs/__wrapper_exec.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libsandbox/wrapper-funcs/__wrapper_exec.c b/libsandbox/wrapper-funcs/__wrapper_exec.c index b7c7dfa..3ac936c 100644 --- a/libsandbox/wrapper-funcs/__wrapper_exec.c +++ b/libsandbox/wrapper-funcs/__wrapper_exec.c @@ -98,11 +98,11 @@ static char **_sb_check_envp(char **envp, bool is_environ) char *entry; char *ld_preload = NULL; char *old_ld_preload = NULL; - size_t count, ld_preload_eq_len; + size_t count, ld_preload_len; - ld_preload_eq_len = strlen(LD_PRELOAD_EQ); + ld_preload_len = strlen(ENV_LD_PRELOAD); str_list_for_each_item(envp, entry, count) { - if (strncmp(entry, LD_PRELOAD_EQ, ld_preload_eq_len)) + if (!is_env_var(entry, ENV_LD_PRELOAD, ld_preload_len)) continue; /* Check if we do not have to do anything */ @@ -122,18 +122,18 @@ static char **_sb_check_envp(char **envp, bool is_environ) /* Ok, we need to create our own envp, as we need to add LD_PRELOAD, * and we should not touch the user's envp. First we add LD_PRELOAD, * and just all the rest. */ - count = ld_preload_eq_len + (strlen(sandbox_lib) + 1) + - (old_ld_preload ? strlen(old_ld_preload) - ld_preload_eq_len + 1 : 0); + count = ld_preload_len + 1 + strlen(sandbox_lib) + 1 + + (old_ld_preload ? strlen(old_ld_preload) - ld_preload_len : 0); ld_preload = xmalloc(count * sizeof(char)); - snprintf(ld_preload, count, "%s%s%s%s", LD_PRELOAD_EQ, sandbox_lib, + snprintf(ld_preload, count, "%s=%s%s%s", ENV_LD_PRELOAD, sandbox_lib, (old_ld_preload) ? " " : "", - (old_ld_preload) ? old_ld_preload + ld_preload_eq_len : ""); + (old_ld_preload) ? old_ld_preload + ld_preload_len + 1 : ""); if (!is_environ) { str_list_add_item(my_env, ld_preload, error); str_list_for_each_item(envp, entry, count) { - if (strncmp(entry, LD_PRELOAD_EQ, ld_preload_eq_len)) { + if (!is_env_var(entry, ENV_LD_PRELOAD, ld_preload_len)) { str_list_add_item(my_env, entry, error); continue; } |