1 |
commit: 163a378b532c03c0199c489b6d829a84875e32c2 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Nov 5 09:04:41 2021 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Nov 5 09:04:41 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=163a378b |
7 |
|
8 |
sandbox: restore SANDBOX_INTRACTV variable |
9 |
|
10 |
I incorrectly dropped this as unused a while back, but the bashrc hook |
11 |
definitely still relies on it for checking portage settings. I think |
12 |
I got confused by the interaction with SANDBOX_TESTING. |
13 |
|
14 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
15 |
|
16 |
libsbutil/sbutil.h | 2 ++ |
17 |
src/environ.c | 6 +++++- |
18 |
src/sandbox.c | 2 +- |
19 |
src/sandbox.h | 2 +- |
20 |
4 files changed, 9 insertions(+), 3 deletions(-) |
21 |
|
22 |
diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h |
23 |
index 267f717..cf97179 100644 |
24 |
--- a/libsbutil/sbutil.h |
25 |
+++ b/libsbutil/sbutil.h |
26 |
@@ -57,6 +57,8 @@ |
27 |
#define ENV_SANDBOX_METHOD "SANDBOX_METHOD" |
28 |
#define ENV_SANDBOX_ON "SANDBOX_ON" |
29 |
|
30 |
+#define ENV_SANDBOX_INTRACTV "SANDBOX_INTRACTV" |
31 |
+ |
32 |
#define ENV_SANDBOX_ACTIVE "SANDBOX_ACTIVE" |
33 |
#define SANDBOX_ACTIVE "armedandready" |
34 |
|
35 |
|
36 |
diff --git a/src/environ.c b/src/environ.c |
37 |
index ecff0dc..1535f06 100644 |
38 |
--- a/src/environ.c |
39 |
+++ b/src/environ.c |
40 |
@@ -241,7 +241,7 @@ static void sb_setenv(char ***envp, const char *name, const char *val) |
41 |
|
42 |
/* We setup the environment child side only to prevent issues with |
43 |
* setting LD_PRELOAD parent side */ |
44 |
-char **setup_environ(struct sandbox_info_t *sandbox_info) |
45 |
+char **setup_environ(struct sandbox_info_t *sandbox_info, bool interactive) |
46 |
{ |
47 |
int have_ld_preload = 0; |
48 |
|
49 |
@@ -264,6 +264,7 @@ char **setup_environ(struct sandbox_info_t *sandbox_info) |
50 |
unsetenv(ENV_SANDBOX_MESSAGE_PATH); |
51 |
unsetenv(ENV_SANDBOX_WORKDIR); |
52 |
unsetenv(ENV_SANDBOX_ACTIVE); |
53 |
+ unsetenv(ENV_SANDBOX_INTRACTV); |
54 |
unsetenv(ENV_BASH_ENV); |
55 |
|
56 |
orig_ld_preload_envvar = getenv(ENV_LD_PRELOAD); |
57 |
@@ -295,6 +296,9 @@ char **setup_environ(struct sandbox_info_t *sandbox_info) |
58 |
sb_setenv(&new_environ, ENV_SANDBOX_LOG, sandbox_info->sandbox_log); |
59 |
sb_setenv(&new_environ, ENV_SANDBOX_DEBUG_LOG, sandbox_info->sandbox_debug_log); |
60 |
sb_setenv(&new_environ, ENV_SANDBOX_MESSAGE_PATH, sandbox_info->sandbox_message_path); |
61 |
+ /* Is this an interactive session? */ |
62 |
+ if (interactive) |
63 |
+ sb_setenv(&new_environ, ENV_SANDBOX_INTRACTV, "1"); |
64 |
/* Just set the these if not already set so that is_env_on() work */ |
65 |
if (!getenv(ENV_SANDBOX_VERBOSE)) |
66 |
sb_setenv(&new_environ, ENV_SANDBOX_VERBOSE, "1"); |
67 |
|
68 |
diff --git a/src/sandbox.c b/src/sandbox.c |
69 |
index ed0c7f6..063974d 100644 |
70 |
--- a/src/sandbox.c |
71 |
+++ b/src/sandbox.c |
72 |
@@ -255,7 +255,7 @@ int main(int argc, char **argv) |
73 |
|
74 |
/* Setup the child environment stuff. |
75 |
* XXX: We free this in spawn_shell(). */ |
76 |
- sandbox_environ = setup_environ(&sandbox_info); |
77 |
+ sandbox_environ = setup_environ(&sandbox_info, print_debug); |
78 |
if (NULL == sandbox_environ) |
79 |
goto oom_error; |
80 |
|
81 |
|
82 |
diff --git a/src/sandbox.h b/src/sandbox.h |
83 |
index cdc1b9e..0c0430f 100644 |
84 |
--- a/src/sandbox.h |
85 |
+++ b/src/sandbox.h |
86 |
@@ -24,7 +24,7 @@ struct sandbox_info_t { |
87 |
char *home_dir; |
88 |
}; |
89 |
|
90 |
-extern char **setup_environ(struct sandbox_info_t *sandbox_info); |
91 |
+extern char **setup_environ(struct sandbox_info_t *sandbox_info, bool interactive); |
92 |
|
93 |
extern bool sb_get_cnf_bool(const char *, bool); |