diff -ur dpkg-1.18.25/lib/dpkg/command.c dpkg-1.18.25+iPhone/lib/dpkg/command.c --- dpkg-1.18.25/lib/dpkg/command.c 2018-03-21 18:29:34.000000000 -1000 +++ dpkg-1.18.25+iPhone/lib/dpkg/command.c 2019-03-29 22:10:21.000000000 -1000 @@ -18,6 +18,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -179,7 +180,24 @@ command_exec(struct command *cmd) { execvp(cmd->filename, (char * const *)cmd->argv); - ohshite(_("unable to execute %s (%s)"), cmd->name, cmd->filename); + if (errno == EPERM || errno == ENOEXEC) { + const char *shell; + if (access(DEFAULTSHELL, X_OK) == 0) { + shell = DEFAULTSHELL; + } else if (access("/etc/alternatives/sh", X_OK) == 0) { + shell = "/etc/alternatives/sh"; + } else if (access("/bin/bash", X_OK) == 0) { + shell = "/bin/bash"; + } else { + ohshite(_("unable to execute %s (%s): no shell!"), cmd->name, cmd->filename); + } + struct command newcmd; + command_init(&newcmd, shell, NULL); + command_add_args(&newcmd, shell, "-c", "\"$0\" \"$@\"", NULL); + command_add_argl(&newcmd, cmd->argv); + execvp(shell, (char * const *)newcmd.argv); + ohshite(_("unable to execute %s (%s)"), cmd->name, cmd->filename); + } }