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