| 1 |
/* COVERAGE: execveat */ |
| 2 |
#define _GNU_SOURCE |
| 3 |
#include <unistd.h> |
| 4 |
#include <sys/syscall.h> |
| 5 |
#include <fcntl.h> |
| 6 |
#if !defined(SYS_execveat) && defined(__NR_execveat) |
| 7 |
#define SYS_execveat __NR_execveat |
| 8 |
#endif |
| 9 |
#include <sys/mman.h> |
| 10 |
|
| 11 |
#ifdef SYS_execveat |
| 12 |
static inline int |
| 13 |
__execveat(int dirfd, const char *filename, char *const argv[], |
| 14 |
char *const envp[], int flags) |
| 15 |
{ |
| 16 |
return syscall(SYS_execveat, dirfd, filename, argv, envp, flags); |
| 17 |
} |
| 18 |
#endif |
| 19 |
|
| 20 |
int main() |
| 21 |
{ |
| 22 |
#ifdef SYS_execveat |
| 23 |
mlockall(MCL_CURRENT); |
| 24 |
|
| 25 |
char *newargv[] = { "/bin/true", "a", "b", "cde", NULL }; |
| 26 |
char *newenv[] = { "FOO=10", "BAR=20", NULL }; |
| 27 |
|
| 28 |
/* Limit testing */ |
| 29 |
__execveat(-1, (char *)-1, NULL, NULL, 0); |
| 30 |
//staptest// [[[[execveat (-1, 0x[f]+, \[\], \[\], 0x0)!!!!ni_syscall ()]]]] = -NNNN |
| 31 |
|
| 32 |
__execveat(-1, "/bin/true", (char **)-1, NULL, 0); |
| 33 |
//staptest// [[[[execveat (-1, "/bin/true", \[0x[f]+\], \[\], 0x0)!!!!ni_syscall ()]]]] = -NNNN |
| 34 |
|
| 35 |
__execveat(-1, "/bin/true", NULL, (char **)-1, 0); |
| 36 |
//staptest// [[[[execveat (-1, "/bin/true", \[\], \[0x[f]+\], 0x0)!!!!ni_syscall ()]]]] = -NNNN |
| 37 |
|
| 38 |
__execveat(-1, "/bin/true", NULL, NULL, -1); |
| 39 |
//staptest// [[[[execveat (-1, "/bin/true", \[\], \[\], AT_[^ ]+|XXXX)!!!!ni_syscall ()]]]] = -NNNN |
| 40 |
|
| 41 |
__execveat(AT_FDCWD, "", NULL, NULL, 0); |
| 42 |
//staptest// [[[[execveat (AT_FDCWD, "", \[\], \[\], 0x0)!!!!ni_syscall ()]]]] = -NNNN |
| 43 |
|
| 44 |
/* Regular testing. */ |
| 45 |
__execveat(-1, newargv[0], newargv, newenv, 0); |
| 46 |
//staptest// [[[[execveat (-1, "/bin/true", \["/bin/true", "a", "b", "cde"\], \["FOO=10", "BAR=20"\], 0x0)!!!!ni_syscall ()]]]] = NNNN |
| 47 |
#endif |
| 48 |
|
| 49 |
return 0; |
| 50 |
} |
| 51 |
|