File: execveat.c

package info (click to toggle)
systemtap 4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,436 kB
  • sloc: cpp: 72,388; ansic: 58,430; xml: 47,797; exp: 40,417; sh: 10,793; python: 2,759; perl: 2,252; tcl: 1,305; makefile: 1,119; lisp: 105; java: 102; awk: 101; asm: 91; sed: 16
file content (48 lines) | stat: -rw-r--r-- 1,578 bytes parent folder | download | duplicates (2)
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
/* 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

#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
    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;
}