termux-packages/packages/rappel/missing-fexecve.patch

44 lines
1.0 KiB
Diff

diff -uNr rappel-dd45bfa000efb89357d5c80a3a77550b96dee499/ptrace.c rappel-dd45bfa000efb89357d5c80a3a77550b96dee499.mod/ptrace.c
--- rappel-dd45bfa000efb89357d5c80a3a77550b96dee499/ptrace.c 2020-09-18 06:37:45.000000000 +0000
+++ rappel-dd45bfa000efb89357d5c80a3a77550b96dee499.mod/ptrace.c 2020-11-05 19:35:22.347935876 +0000
@@ -7,6 +7,7 @@
#include <string.h>
#include <unistd.h>
+#include <sys/stat.h>
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -103,6 +104,31 @@
return ret;
}
+static int
+fexecve (int fd, char *const argv[], char *const envp[])
+{
+ if (fd < 0 || argv == NULL || envp == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ char buf[sizeof "/proc/self/fd/" + sizeof (int) * 3];
+ snprintf(buf, sizeof (buf), "/proc/self/fd/%d", fd);
+
+ execve(buf, argv, envp);
+
+ int save = errno;
+
+ struct stat st;
+ if (stat("/proc/self/fd", &st) != 0 && errno == ENOENT)
+ save = ENOSYS;
+
+ errno = save;
+
+ return -1;
+}
+
void ptrace_child(
const int exe_fd)
{