Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/sandbox:master commit in: src/
Date: Tue, 02 Nov 2021 04:28:21
Message-Id: 1635826433.116ca8fd5af908edad85095916585576aa19ec5f.vapier@gentoo
1 commit: 116ca8fd5af908edad85095916585576aa19ec5f
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Tue Nov 2 04:13:53 2021 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 2 04:13:53 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=116ca8fd
7
8 sandbox: add backwards compat interface hack
9
10 Portage runs commands through sandbox like:
11 $ sandbox "/usr/lib/portage/python3.9/ebuild.sh unpack"
12
13 That means we can't break the CLI without breaking portage and forcing
14 everyone to upgrade together. That'll be pretty disruptive for people,
15 so add a hack to detect this situation: if a single argument is passed
16 on the CLI, and it doesn't appear to be a file, then fallback to running
17 it through the shell. This keeps portage working while allowing the new
18 interface style to launch. If/when we can update portage to always use
19 the -c option, maybe we can drop this in the future. Or not ... it's
20 not exactly the worst hack for users.
21
22 Bug: https://bugs.gentoo.org/265907
23 Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>
24
25 src/sandbox.c | 9 +++++++++
26 1 file changed, 9 insertions(+)
27
28 diff --git a/src/sandbox.c b/src/sandbox.c
29 index 2d03dd4..ed0c7f6 100644
30 --- a/src/sandbox.c
31 +++ b/src/sandbox.c
32 @@ -260,6 +260,15 @@ int main(int argc, char **argv)
33 goto oom_error;
34
35 /* Setup bash argv */
36 + if (!opt_use_bash && argc == 2) {
37 + /* Backwards compatibility hack: if there's only one argument, and it
38 + * appears to be a shell command (not an absolute path to a program),
39 + * then fallback to running through the shell.
40 + */
41 + if (access(argv[1], X_OK))
42 + opt_use_bash = true;
43 + }
44 +
45 if (opt_use_bash || argc == 1) {
46 str_list_add_item_copy(argv_bash, "/bin/bash", oom_error);
47 str_list_add_item_copy(argv_bash, "-rcfile", oom_error);