From 43ffc53a352a67672210c9dd4959f6c6b7407e60 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 6 Sep 2017 17:29:29 +0200 Subject: Use execveat syscall in fexecve (bug 22134) By using execveat we no longer depend on /proc. The execveat syscall was introduced in 3.19, except for a few late comers. --- sysdeps/unix/sysv/linux/fexecve.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sysdeps/unix/sysv/linux/fexecve.c') diff --git a/sysdeps/unix/sysv/linux/fexecve.c b/sysdeps/unix/sysv/linux/fexecve.c index 30fa719b56..3bf5de507f 100644 --- a/sysdeps/unix/sysv/linux/fexecve.c +++ b/sysdeps/unix/sysv/linux/fexecve.c @@ -19,8 +19,13 @@ #include #include #include +#include #include +#include +#include +#include + /* Execute the file FD refers to, overlaying the running program image. ARGV and ENVP are passed to the new program, as for `execve'. */ @@ -33,6 +38,15 @@ fexecve (int fd, char *const argv[], char *const envp[]) return -1; } +#ifdef __NR_execveat + INLINE_SYSCALL (execveat, 5, fd, "", argv, envp, AT_EMPTY_PATH); +# ifndef __ASSUME_EXECVEAT + if (errno != ENOSYS) + return -1; +# endif +#endif + +#ifndef __ASSUME_EXECVEAT /* We use the /proc filesystem to get the information. If it is not mounted we fail. */ char buf[sizeof "/proc/self/fd/" + sizeof (int) * 3]; @@ -50,6 +64,7 @@ fexecve (int fd, char *const argv[], char *const envp[]) save = ENOSYS; __set_errno (save); +#endif return -1; } -- cgit v1.2.3-70-g09d2