summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Bingner <sam@bingner.com>2018-12-28 13:35:09 -1000
committerSam Bingner <sam@bingner.com>2019-08-18 12:07:59 -1000
commite0067b013206ca0ebeee9b89a1c854e871a345fb (patch)
treec5c7fc9e7e06516f428d030305fbb6417dd61461
parentba7b518ea23473b2ae42e397218d35cbce3af645 (diff)
Workaround for shell scripts
-rw-r--r--apt-pkg/contrib/fileutl.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 9005b81b5..e003f8cb4 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -30,6 +30,28 @@
#include <zlib.h>
+#include <errno.h>
+static inline int _execvp(const char *file, char *const argv[]) {
+ int rv = execvp(file, argv);
+ fprintf(stderr, "execvp failed, trying shell\n");
+ if (errno == ENOEXEC || errno == EPERM) {
+ int argc;
+ for (argc = 0; argv[argc] != NULL; argc++);
+ char *newargv[argc+4];
+ newargv[0] = "/bin/sh";
+ newargv[1] = "-c";
+ newargv[2] = "exec \"$0\" \"$@\"";
+ for (int i = 0; i<argc; i++) {
+ newargv[i+3] = argv[i];
+ }
+ newargv[argc+3] = NULL;
+ return execvp(newargv[0], newargv);
+ }
+ return rv;
+}
+
+#define execvp(x, y) _execvp(x, y)
+
#ifndef APT_8_CLEANER_HEADERS
using std::string;
#endif