Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sandbox:master commit in: libsandbox/
Date: Sun, 18 Feb 2018 21:32:38
Message-Id: 1518462327.1b0f7b0d035a10ba172b659abbe425c8523bdb96.mgorny@gentoo
1 commit: 1b0f7b0d035a10ba172b659abbe425c8523bdb96
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Mon Feb 12 18:14:07 2018 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Mon Feb 12 19:05:27 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=1b0f7b0d
7
8 Disable environment propagation if sandbox is disabled
9
10 Do not enforce restoring sandbox variables in the environment if sandbox
11 is explicitly disabled. This makes it possible to set SANDBOX_ON=0
12 and then unset LD_PRELOAD without having to resort to ugly hacks to
13 prevent sandbox from restoring itself.
14
15 The only limitation is that if user sets SANDBOX_ON=0 first, then wipes
16 the environment, he will no longer be able to reenable sandbox via doing
17 SANDBOX_ON=1. However, it is rather unlikely that such a thing would
18 need to happen in real use.
19
20 Bug: https://bugs.gentoo.org/592750
21
22 libsandbox/libsandbox.c | 5 +++++
23 1 file changed, 5 insertions(+)
24
25 diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
26 index c126aa1..9ef13b1 100644
27 --- a/libsandbox/libsandbox.c
28 +++ b/libsandbox/libsandbox.c
29 @@ -1142,6 +1142,11 @@ char **sb_check_envp(char **envp, size_t *mod_cnt, bool insert)
30 char *found_vars[num_vars];
31 size_t found_var_cnt;
32
33 + /* If sandbox is explicitly disabled, do not propagate the vars
34 + * and just return user's envp */
35 + if (!sbcontext.on)
36 + return envp;
37 +
38 /* First figure out how many vars are already in the env */
39 found_var_cnt = 0;
40 memset(found_vars, 0, sizeof(found_vars));