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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
| #include <stdio.h>
| #include <stdarg.h>
| #include <sys/types.h>
|
| #include <sepol/policydb/avtab.h>
| #include <sepol/policydb/policydb.h>
|
|
| #define STACK_SIZE 16
| #define DEFAULT_LEVEL "systemlow"
| #define DEFAULT_OBJECT "object_r"
|
| // initial sid names aren't actually stored in the pp files, need to a have
| // a mapping, taken from the linux kernel
| static const char * const selinux_sid_to_str[] = {
| "null",
| "kernel",
| "security",
| "unlabeled",
| "fs",
| "file",
| "file_labels",
| "init",
| "any_socket",
| "port",
| "netif",
| "netmsg",
| "node",
| "igmp_packet",
| "icmp_socket",
| "tcp_socket",
| "sysctl_modprobe",
| "sysctl",
| "sysctl_fs",
| "sysctl_kernel",
| "sysctl_net",
| "sysctl_net_unix",
| "sysctl_vm",
| "sysctl_dev",
| "kmod",
| "policy",
| "scmp_packet",
| "devnull",
| };
|
| #define SELINUX_SID_SZ (sizeof(selinux_sid_to_str)/sizeof(selinux_sid_to_str[0]))
|
| static const char * const xen_sid_to_str[] = {
| "null",
| "xen",
| "dom0",
| "domio",
| "domxen",
| "unlabeled",
| "security",
| "ioport",
| "iomem",
| "irq",
| "device",
| "domU",
| "domDM",
| };
|
| #define XEN_SID_SZ (sizeof(xen_sid_to_str)/sizeof(xen_sid_to_str[0]))
|
| static const uint32_t avtab_flavors[] = {
| AVTAB_ALLOWED,
| AVTAB_AUDITALLOW,
| AVTAB_AUDITDENY,
| AVTAB_XPERMS_ALLOWED,
| AVTAB_XPERMS_AUDITALLOW,
| AVTAB_XPERMS_DONTAUDIT,
| AVTAB_TRANSITION,
| AVTAB_MEMBER,
| AVTAB_CHANGE,
| };
|
| #define AVTAB_FLAVORS_SZ (sizeof(avtab_flavors)/sizeof(avtab_flavors[0]))
|
| struct strs {
| char **list;
| unsigned num;
| size_t size;
| };
|
| __attribute__ ((format(printf, 1, 2)))
| void sepol_log_err(const char *fmt, ...);
| void sepol_indent(FILE *out, int indent);
| __attribute__ ((format(printf, 2, 3)))
| void sepol_printf(FILE *out, const char *fmt, ...);
|
| __attribute__ ((format(printf, 1, 3)))
| char *create_str(const char *fmt, int num, ...);
|
| int strs_init(struct strs **strs, size_t size);
| void strs_destroy(struct strs **strs);
| void strs_free_all(struct strs *strs);
| int strs_add(struct strs *strs, char *s);
| __attribute__ ((format(printf, 2, 4)))
| int strs_create_and_add(struct strs *strs, const char *fmt, int num, ...);
| char *strs_remove_last(struct strs *strs);
| int strs_add_at_index(struct strs *strs, char *s, unsigned index);
| char *strs_read_at_index(struct strs *strs, unsigned index);
| void strs_sort(struct strs *strs);
| unsigned strs_num_items(struct strs *strs);
| size_t strs_len_items(struct strs *strs);
| char *strs_to_str(struct strs *strs);
| void strs_write_each(struct strs *strs, FILE *out);
| void strs_write_each_indented(struct strs *strs, FILE *out, int indent);
| int hashtab_ordered_to_strs(char *key, void *data, void *args);
| int ebitmap_to_strs(struct ebitmap *map, struct strs *strs, char **val_to_name);
| char *ebitmap_to_str(struct ebitmap *map, char **val_to_name, int sort);
|
| int strs_stack_init(struct strs **stack);
| void strs_stack_destroy(struct strs **stack);
| int strs_stack_push(struct strs *stack, char *s);
| char *strs_stack_pop(struct strs *stack);
| int strs_stack_empty(struct strs *stack);
|
| int sort_ocontexts(struct policydb *pdb);
|
|