commit:     163a378b532c03c0199c489b6d829a84875e32c2
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  5 09:04:41 2021 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov  5 09:04:41 2021 +0000
URL:        https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=163a378b

sandbox: restore SANDBOX_INTRACTV variable

I incorrectly dropped this as unused a while back, but the bashrc hook
definitely still relies on it for checking portage settings.  I think
I got confused by the interaction with SANDBOX_TESTING.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 libsbutil/sbutil.h | 2 ++
 src/environ.c      | 6 +++++-
 src/sandbox.c      | 2 +-
 src/sandbox.h      | 2 +-
 4 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h
index 267f717..cf97179 100644
--- a/libsbutil/sbutil.h
+++ b/libsbutil/sbutil.h
@@ -57,6 +57,8 @@
 #define ENV_SANDBOX_METHOD     "SANDBOX_METHOD"
 #define ENV_SANDBOX_ON         "SANDBOX_ON"
 
+#define ENV_SANDBOX_INTRACTV   "SANDBOX_INTRACTV"
+
 #define ENV_SANDBOX_ACTIVE     "SANDBOX_ACTIVE"
 #define SANDBOX_ACTIVE         "armedandready"
 

diff --git a/src/environ.c b/src/environ.c
index ecff0dc..1535f06 100644
--- a/src/environ.c
+++ b/src/environ.c
@@ -241,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;
 
@@ -264,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);
@@ -295,6 +296,9 @@ 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");

diff --git a/src/sandbox.c b/src/sandbox.c
index ed0c7f6..063974d 100644
--- a/src/sandbox.c
+++ b/src/sandbox.c
@@ -255,7 +255,7 @@ int main(int argc, char **argv)
 
        /* Setup the child environment stuff.
         * XXX:  We free this in spawn_shell(). */
-       sandbox_environ = setup_environ(&sandbox_info);
+       sandbox_environ = setup_environ(&sandbox_info, print_debug);
        if (NULL == sandbox_environ)
                goto oom_error;
 

diff --git a/src/sandbox.h b/src/sandbox.h
index cdc1b9e..0c0430f 100644
--- a/src/sandbox.h
+++ b/src/sandbox.h
@@ -24,7 +24,7 @@ struct sandbox_info_t {
        char *home_dir;
 };
 
-extern char **setup_environ(struct sandbox_info_t *sandbox_info);
+extern char **setup_environ(struct sandbox_info_t *sandbox_info, bool 
interactive);
 
 extern bool sb_get_cnf_bool(const char *, bool);
 

Reply via email to