aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-11-02 00:13:53 -0400
committerMike Frysinger <vapier@gentoo.org>2021-11-02 00:13:53 -0400
commit116ca8fd5af908edad85095916585576aa19ec5f (patch)
treea8d039af13dfd3809a81f5719088c7b2c062393e
parentsandbox: delete now unused variable (diff)
downloadsandbox-116ca8fd5af908edad85095916585576aa19ec5f.tar.gz
sandbox-116ca8fd5af908edad85095916585576aa19ec5f.tar.bz2
sandbox-116ca8fd5af908edad85095916585576aa19ec5f.zip
sandbox: add backwards compat interface hackv2.29
Portage runs commands through sandbox like: $ sandbox "/usr/lib/portage/python3.9/ebuild.sh unpack" That means we can't break the CLI without breaking portage and forcing everyone to upgrade together. That'll be pretty disruptive for people, so add a hack to detect this situation: if a single argument is passed on the CLI, and it doesn't appear to be a file, then fallback to running it through the shell. This keeps portage working while allowing the new interface style to launch. If/when we can update portage to always use the -c option, maybe we can drop this in the future. Or not ... it's not exactly the worst hack for users. Bug: https://bugs.gentoo.org/265907 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--src/sandbox.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/sandbox.c b/src/sandbox.c
index 2d03dd4..ed0c7f6 100644
--- a/src/sandbox.c
+++ b/src/sandbox.c
@@ -260,6 +260,15 @@ int main(int argc, char **argv)
goto oom_error;
/* Setup bash argv */
+ if (!opt_use_bash && argc == 2) {
+ /* Backwards compatibility hack: if there's only one argument, and it
+ * appears to be a shell command (not an absolute path to a program),
+ * then fallback to running through the shell.
+ */
+ if (access(argv[1], X_OK))
+ opt_use_bash = true;
+ }
+
if (opt_use_bash || argc == 1) {
str_list_add_item_copy(argv_bash, "/bin/bash", oom_error);
str_list_add_item_copy(argv_bash, "-rcfile", oom_error);