From e0067b013206ca0ebeee9b89a1c854e871a345fb 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 9005b81b5..e003f8cb4 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -30,6 +30,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