Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Sun, 2 Sep 2018 00:04:55 -0400
From: Joseph Sible <josephcsible@...il.com>
To: musl@...ts.openwall.com
Subject: [PATCH] fexecve: implement in terms of execveat when it exists

This lets fexecve work even when /proc isn't mounted.
---
 src/process/fexecve.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/process/fexecve.c b/src/process/fexecve.c
index 6507b42..905487e 100644
--- a/src/process/fexecve.c
+++ b/src/process/fexecve.c
@@ -1,13 +1,20 @@
+#define _GNU_SOURCE
 #include <unistd.h>
 #include <errno.h>
+#include <fcntl.h>
+#include "syscall.h"

 void __procfdname(char *, unsigned);

 int fexecve(int fd, char *const argv[], char *const envp[])
 {
+#ifdef SYS_execveat
+       return syscall(SYS_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
+#else
        char buf[15 + 3*sizeof(int)];
        __procfdname(buf, fd);
        execve(buf, argv, envp);
        if (errno == ENOENT) errno = EBADF;
        return -1;
+#endif
 }
--
2.7.4

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.