summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.syscall/uid.c
blob: 6ccf8cdd0fba4a754220d26e069db8b6ba2d0c58 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
/* COVERAGE: getuid geteuid getgid getegid setuid setresuid getresuid setgid */
/* COVERAGE: setresgid getresgid setreuid setregid setfsuid setfsgid */
#define _GNU_SOURCE
#include <sys/types.h>
#include <unistd.h>
#include <sys/fsuid.h>

int main ()
{
  uid_t ruid, euid, suid;
  gid_t rgid, egid, sgid;

  ruid = getuid();
  //staptest// getuid () = NNNN
  
  euid = geteuid();
  //staptest// geteuid () = NNNN
  
  rgid = getgid();
  //staptest// getgid () = NNNN

  egid = getegid();
  //staptest// getegid () = NNNN



  setuid(4096);
  //staptest// setuid (4096) = NNNN

  seteuid(4097);
  //staptest// setresuid (-1, 4097, -1) = NNNN

  getresuid(&ruid, &euid, &suid);
  //staptest// getresuid (XXXX, XXXX, XXXX) = 0

  setgid(4098);
  //staptest// setgid (4098) = NNNN

  setegid(4099);
  //staptest// setresgid (-1, 4099, -1) = NNNN

  getresgid(&rgid, &egid, &sgid);
  //staptest// getresgid (XXXX, XXXX, XXXX) = 0

  setreuid(-1, 5000);
  //staptest// setreuid (NNNN, 5000) =

  setreuid(5001, -1);
  //staptest// setreuid (5001, NNNN) =

  setregid(-1, 5002);
  //staptest// setregid (NNNN, 5002) =

  setregid(5003, -1);
  //staptest// setregid (5003, NNNN) =

  setfsuid(5004);
  //staptest// setfsuid (5004) = 

  setfsgid(5005);
  //staptest// setfsgid (5005) =
  
  return 0;
}