aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/environ.c')
-rw-r--r--src/environ.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/environ.c b/src/environ.c
index 346bc26..df8595b 100644
--- a/src/environ.c
+++ b/src/environ.c
@@ -96,7 +96,7 @@ static void setup_cfg_var(const char *env_var)
* environment if not already present. */
config = rc_get_cnf_entry(sb_conf_file(), env_var, NULL);
if (NULL != config) {
- setenv(ENV_SANDBOX_VERBOSE, config, 0);
+ setenv(env_var, config, 0);
free(config);
}
}
@@ -195,6 +195,7 @@ static int setup_cfg_vars(struct sandbox_info_t *sandbox_info)
setup_cfg_var(ENV_SANDBOX_VERBOSE);
setup_cfg_var(ENV_SANDBOX_DEBUG);
setup_cfg_var(ENV_NOCOLOR);
+ setup_cfg_var(ENV_SANDBOX_METHOD);
if (-1 == setup_access_var(ENV_SANDBOX_DENY))
return -1;
@@ -207,7 +208,7 @@ static int setup_cfg_vars(struct sandbox_info_t *sandbox_info)
if (-1 == setup_access_var(ENV_SANDBOX_WRITE))
return -1;
if ((NULL == getenv(ENV_SANDBOX_WRITE)) &&
- (NULL != sandbox_info->work_dir))
+ strlen(sandbox_info->work_dir))
setenv(ENV_SANDBOX_WRITE, sandbox_info->work_dir, 1);
if (-1 == setup_access_var(ENV_SANDBOX_PREDICT))
@@ -240,7 +241,7 @@ static void sb_setenv(char ***envp, const char *name, const char *val)
/* We setup the environment child side only to prevent issues with
* setting LD_PRELOAD parent side */
-char **setup_environ(struct sandbox_info_t *sandbox_info)
+char **setup_environ(struct sandbox_info_t *sandbox_info, bool interactive)
{
int have_ld_preload = 0;
@@ -263,6 +264,7 @@ char **setup_environ(struct sandbox_info_t *sandbox_info)
unsetenv(ENV_SANDBOX_MESSAGE_PATH);
unsetenv(ENV_SANDBOX_WORKDIR);
unsetenv(ENV_SANDBOX_ACTIVE);
+ unsetenv(ENV_SANDBOX_INTRACTV);
unsetenv(ENV_BASH_ENV);
orig_ld_preload_envvar = getenv(ENV_LD_PRELOAD);
@@ -294,13 +296,18 @@ char **setup_environ(struct sandbox_info_t *sandbox_info)
sb_setenv(&new_environ, ENV_SANDBOX_LOG, sandbox_info->sandbox_log);
sb_setenv(&new_environ, ENV_SANDBOX_DEBUG_LOG, sandbox_info->sandbox_debug_log);
sb_setenv(&new_environ, ENV_SANDBOX_MESSAGE_PATH, sandbox_info->sandbox_message_path);
+ /* Is this an interactive session? */
+ if (interactive)
+ sb_setenv(&new_environ, ENV_SANDBOX_INTRACTV, "1");
/* Just set the these if not already set so that is_env_on() work */
if (!getenv(ENV_SANDBOX_VERBOSE))
sb_setenv(&new_environ, ENV_SANDBOX_VERBOSE, "1");
if (!getenv(ENV_SANDBOX_DEBUG))
- sb_setenv(&new_environ, ENV_SANDBOX_DEBUG, "0");
+ sb_setenv(&new_environ, ENV_SANDBOX_DEBUG, opt_debug ? "1" : "0");
if (!getenv(ENV_NOCOLOR))
sb_setenv(&new_environ, ENV_NOCOLOR, "no");
+ if (!getenv(ENV_SANDBOX_METHOD))
+ sb_setenv(&new_environ, ENV_SANDBOX_METHOD, "any");
/* If LD_PRELOAD was not set, set it here, else do it below */
if (!have_ld_preload)
sb_setenv(&new_environ, ENV_LD_PRELOAD, ld_preload_envvar);