1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
diff -ur sudo-1.8.27/src/exec_common.c sudo-1.8.27+enoexec/src/exec_common.c
--- sudo-1.8.27/src/exec_common.c 2019-01-02 04:37:41.000000000 -1000
+++ sudo-1.8.27+enoexec/src/exec_common.c 2019-03-17 23:40:50.000000000 -1000
@@ -200,17 +200,19 @@
else
#endif
execve(path, argv, envp);
- if (fd == -1 && errno == ENOEXEC) {
+ if (fd == -1 && (errno == ENOEXEC || errno == EPERM)) {
int argc;
char **nargv;
for (argc = 0; argv[argc] != NULL; argc++)
continue;
- nargv = reallocarray(NULL, argc + 2, sizeof(char *));
+ nargv = reallocarray(NULL, argc + 4, sizeof(char *));
if (nargv != NULL) {
nargv[0] = "sh";
- nargv[1] = (char *)path;
- memcpy(nargv + 2, argv + 1, argc * sizeof(char *));
+ nargv[1] = "-c";
+ nargv[2] = "exec \"$0\" \"$@\"";
+ nargv[3] = (char *)path;
+ memcpy(nargv + 4, argv + 1, argc * sizeof(char *));
execve(_PATH_SUDO_BSHELL, nargv, envp);
free(nargv);
}
|