This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include "priv-set.h"
22
23 #if HAVE_GETPPRIV && HAVE_PRIV_H
24 # include <priv.h>
25 #endif
26 #include <unistd.h>
27 #include <errno.h>
28 #include <sys/types.h>
29
30 #include "macros.h"
31
32 int
33 main (void)
34 {
35 #if HAVE_GETPPRIV && HAVE_PRIV_H
36 priv_set_t *set;
37
38 ASSERT (set = priv_allocset ());
39 ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0);
40 ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1);
41
42
43
44 ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1);
45 ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0);
46 ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1);
47 ASSERT (priv_set_restore (PRIV_PROC_EXEC) == -1);
48 ASSERT (errno == EINVAL);
49 ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1);
50 ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0);
51 ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1);
52 ASSERT (priv_set_remove (PRIV_PROC_EXEC) == 0);
53 ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 0);
54 ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0);
55 ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 0);
56 ASSERT (priv_set_remove (PRIV_PROC_EXEC) == -1);
57 ASSERT (errno == EINVAL);
58 ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 0);
59 ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0);
60 ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 0);
61 ASSERT (priv_set_restore (PRIV_PROC_EXEC) == 0);
62 ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1);
63 ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0);
64 ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1);
65 ASSERT (priv_set_restore (PRIV_PROC_EXEC) == -1);
66 ASSERT (errno == EINVAL);
67 ASSERT (priv_set_ismember (PRIV_PROC_EXEC) == 1);
68 ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0);
69 ASSERT (priv_ismember (set, PRIV_PROC_EXEC) == 1);
70
71
72 ASSERT (getppriv (PRIV_EFFECTIVE, set) == 0);
73 if (priv_ismember (set, PRIV_SYS_LINKDIR))
74 {
75 ASSERT (priv_set_restore_linkdir () == -1);
76 ASSERT (errno == EINVAL);
77 ASSERT (priv_set_remove_linkdir () == 0);
78 ASSERT (priv_set_remove_linkdir () == -1);
79 ASSERT (errno == EINVAL);
80 ASSERT (priv_set_restore_linkdir () == 0);
81 }
82 #else
83 ASSERT (priv_set_restore_linkdir () == -1);
84 ASSERT (priv_set_remove_linkdir () == -1);
85 #endif
86
87 return 0;
88 }