mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
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.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user