diff options
author | Andreas Schwab <schwab@suse.de> | 2017-09-06 17:29:29 +0200 |
---|---|---|
committer | Andreas Schwab <schwab@suse.de> | 2017-09-19 16:19:14 +0200 |
commit | 43ffc53a352a67672210c9dd4959f6c6b7407e60 (patch) | |
tree | fb92e7e211583667cd6ffcff331e167eccffb9e7 /sysdeps/unix/sysv/linux/fexecve.c | |
parent | a5dcc87e77cf711bca320e8506a4d4fef25bf4f4 (diff) | |
download | glibc-43ffc53a352a67672210c9dd4959f6c6b7407e60.tar glibc-43ffc53a352a67672210c9dd4959f6c6b7407e60.tar.gz glibc-43ffc53a352a67672210c9dd4959f6c6b7407e60.tar.bz2 glibc-43ffc53a352a67672210c9dd4959f6c6b7407e60.zip |
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.
Diffstat (limited to 'sysdeps/unix/sysv/linux/fexecve.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/fexecve.c | 15 |
1 files changed, 15 insertions, 0 deletions
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 <stddef.h> #include <stdio.h> #include <unistd.h> +#include <fcntl.h> #include <sys/stat.h> +#include <sysdep.h> +#include <sys/syscall.h> +#include <kernel-features.h> + /* 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; } |