From 6ff13d9bd5b09dd85f853ba543bfe350b06d186f Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Fri, 28 Dec 2018 13:35:09 -1000 Subject: Workaround for shell scripts --- apt-pkg/contrib/fileutl.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 446120a3c..bb05239c9 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -31,6 +31,28 @@ #include +#include +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