xref: /aosp_15_r20/external/selinux/secilc/docs/cil_sid_statements.md (revision 2d543d20722ada2425b5bdab9d0d1d29470e7bba)
1*2d543d20SAndroid Build Coastguard WorkerSID Statements
2*2d543d20SAndroid Build Coastguard Worker==============
3*2d543d20SAndroid Build Coastguard Worker
4*2d543d20SAndroid Build Coastguard Workersid
5*2d543d20SAndroid Build Coastguard Worker---
6*2d543d20SAndroid Build Coastguard Worker
7*2d543d20SAndroid Build Coastguard WorkerDeclares a new SID identifier in the current namespace.
8*2d543d20SAndroid Build Coastguard Worker
9*2d543d20SAndroid Build Coastguard Worker**Statement definition:**
10*2d543d20SAndroid Build Coastguard Worker
11*2d543d20SAndroid Build Coastguard Worker```secil
12*2d543d20SAndroid Build Coastguard Worker    (sid sid_id)
13*2d543d20SAndroid Build Coastguard Worker```
14*2d543d20SAndroid Build Coastguard Worker
15*2d543d20SAndroid Build Coastguard Worker**Where:**
16*2d543d20SAndroid Build Coastguard Worker
17*2d543d20SAndroid Build Coastguard Worker<table>
18*2d543d20SAndroid Build Coastguard Worker<colgroup>
19*2d543d20SAndroid Build Coastguard Worker<col width="25%" />
20*2d543d20SAndroid Build Coastguard Worker<col width="75%" />
21*2d543d20SAndroid Build Coastguard Worker</colgroup>
22*2d543d20SAndroid Build Coastguard Worker<tbody>
23*2d543d20SAndroid Build Coastguard Worker<tr class="odd">
24*2d543d20SAndroid Build Coastguard Worker<td align="left"><p><code>sid</code></p></td>
25*2d543d20SAndroid Build Coastguard Worker<td align="left"><p>The <code>sid</code> keyword.</p></td>
26*2d543d20SAndroid Build Coastguard Worker</tr>
27*2d543d20SAndroid Build Coastguard Worker<tr class="even">
28*2d543d20SAndroid Build Coastguard Worker<td align="left"><p><code>sid_id</code></p></td>
29*2d543d20SAndroid Build Coastguard Worker<td align="left"><p>The <code>sid</code> identifier.</p></td>
30*2d543d20SAndroid Build Coastguard Worker</tr>
31*2d543d20SAndroid Build Coastguard Worker</tbody>
32*2d543d20SAndroid Build Coastguard Worker</table>
33*2d543d20SAndroid Build Coastguard Worker
34*2d543d20SAndroid Build Coastguard Worker**Examples:**
35*2d543d20SAndroid Build Coastguard Worker
36*2d543d20SAndroid Build Coastguard WorkerThese examples show three [`sid`](cil_sid_statements.md#sid) declarations:
37*2d543d20SAndroid Build Coastguard Worker
38*2d543d20SAndroid Build Coastguard Worker```secil
39*2d543d20SAndroid Build Coastguard Worker    (sid kernel)
40*2d543d20SAndroid Build Coastguard Worker    (sid security)
41*2d543d20SAndroid Build Coastguard Worker    (sid igmp_packet)
42*2d543d20SAndroid Build Coastguard Worker```
43*2d543d20SAndroid Build Coastguard Worker
44*2d543d20SAndroid Build Coastguard Workersidorder
45*2d543d20SAndroid Build Coastguard Worker--------
46*2d543d20SAndroid Build Coastguard Worker
47*2d543d20SAndroid Build Coastguard WorkerDefines the order of [sid](#sid)'s. This is a mandatory statement when SIDs are defined. Multiple [`sidorder`](cil_sid_statements.md#sidorder) statements declared in the policy will form an ordered list.
48*2d543d20SAndroid Build Coastguard Worker
49*2d543d20SAndroid Build Coastguard Worker**Statement definition:**
50*2d543d20SAndroid Build Coastguard Worker
51*2d543d20SAndroid Build Coastguard Worker```secil
52*2d543d20SAndroid Build Coastguard Worker    (sidorder (sid_id ...))
53*2d543d20SAndroid Build Coastguard Worker```
54*2d543d20SAndroid Build Coastguard Worker
55*2d543d20SAndroid Build Coastguard Worker**Where:**
56*2d543d20SAndroid Build Coastguard Worker
57*2d543d20SAndroid Build Coastguard Worker<table>
58*2d543d20SAndroid Build Coastguard Worker<colgroup>
59*2d543d20SAndroid Build Coastguard Worker<col width="25%" />
60*2d543d20SAndroid Build Coastguard Worker<col width="75%" />
61*2d543d20SAndroid Build Coastguard Worker</colgroup>
62*2d543d20SAndroid Build Coastguard Worker<tbody>
63*2d543d20SAndroid Build Coastguard Worker<tr class="odd">
64*2d543d20SAndroid Build Coastguard Worker<td align="left"><p><code>sidorder</code></p></td>
65*2d543d20SAndroid Build Coastguard Worker<td align="left"><p>The <code>sidorder</code> keyword.</p></td>
66*2d543d20SAndroid Build Coastguard Worker</tr>
67*2d543d20SAndroid Build Coastguard Worker<tr class="even">
68*2d543d20SAndroid Build Coastguard Worker<td align="left"><p><code>sid_id</code></p></td>
69*2d543d20SAndroid Build Coastguard Worker<td align="left"><p>One or more <code>sid</code> identifiers.</p></td>
70*2d543d20SAndroid Build Coastguard Worker</tr>
71*2d543d20SAndroid Build Coastguard Worker</tbody>
72*2d543d20SAndroid Build Coastguard Worker</table>
73*2d543d20SAndroid Build Coastguard Worker
74*2d543d20SAndroid Build Coastguard Worker**Example:**
75*2d543d20SAndroid Build Coastguard Worker
76*2d543d20SAndroid Build Coastguard WorkerThis will produce an ordered list of "`kernel security unlabeled`"
77*2d543d20SAndroid Build Coastguard Worker
78*2d543d20SAndroid Build Coastguard Worker```secil
79*2d543d20SAndroid Build Coastguard Worker    (sid kernel)
80*2d543d20SAndroid Build Coastguard Worker    (sid security)
81*2d543d20SAndroid Build Coastguard Worker    (sid unlabeled)
82*2d543d20SAndroid Build Coastguard Worker    (sidorder (kernel security))
83*2d543d20SAndroid Build Coastguard Worker    (sidorder (security unlabeled))
84*2d543d20SAndroid Build Coastguard Worker```
85*2d543d20SAndroid Build Coastguard Worker
86*2d543d20SAndroid Build Coastguard Workersidcontext
87*2d543d20SAndroid Build Coastguard Worker----------
88*2d543d20SAndroid Build Coastguard Worker
89*2d543d20SAndroid Build Coastguard WorkerAssociates an SELinux security [context](#context) to a previously declared [`sid`](cil_sid_statements.md#sid) identifier.
90*2d543d20SAndroid Build Coastguard Worker
91*2d543d20SAndroid Build Coastguard Worker**Statement definition:**
92*2d543d20SAndroid Build Coastguard Worker
93*2d543d20SAndroid Build Coastguard Worker```secil
94*2d543d20SAndroid Build Coastguard Worker    (sidcontext sid_id context_id)
95*2d543d20SAndroid Build Coastguard Worker```
96*2d543d20SAndroid Build Coastguard Worker
97*2d543d20SAndroid Build Coastguard Worker**Where:**
98*2d543d20SAndroid Build Coastguard Worker
99*2d543d20SAndroid Build Coastguard Worker<table>
100*2d543d20SAndroid Build Coastguard Worker<colgroup>
101*2d543d20SAndroid Build Coastguard Worker<col width="25%" />
102*2d543d20SAndroid Build Coastguard Worker<col width="75%" />
103*2d543d20SAndroid Build Coastguard Worker</colgroup>
104*2d543d20SAndroid Build Coastguard Worker<tbody>
105*2d543d20SAndroid Build Coastguard Worker<tr class="odd">
106*2d543d20SAndroid Build Coastguard Worker<td align="left"><p><code>sidcontext</code></p></td>
107*2d543d20SAndroid Build Coastguard Worker<td align="left"><p>The <code>sidcontext</code> keyword.</p></td>
108*2d543d20SAndroid Build Coastguard Worker</tr>
109*2d543d20SAndroid Build Coastguard Worker<tr class="even">
110*2d543d20SAndroid Build Coastguard Worker<td align="left"><p><code>sid_id</code></p></td>
111*2d543d20SAndroid Build Coastguard Worker<td align="left"><p>A single previously declared <code>sid</code> identifier.</p></td>
112*2d543d20SAndroid Build Coastguard Worker</tr>
113*2d543d20SAndroid Build Coastguard Worker<tr class="odd">
114*2d543d20SAndroid Build Coastguard Worker<td align="left"><p><code>context_id</code></p></td>
115*2d543d20SAndroid Build Coastguard Worker<td align="left"><p>A previously declared <code>context</code> identifier or an anonymous security context (<code>user role type levelrange</code>), the range MUST be defined whether the policy is MLS/MCS enabled or not.</p></td>
116*2d543d20SAndroid Build Coastguard Worker</tr>
117*2d543d20SAndroid Build Coastguard Worker</tbody>
118*2d543d20SAndroid Build Coastguard Worker</table>
119*2d543d20SAndroid Build Coastguard Worker
120*2d543d20SAndroid Build Coastguard Worker**Examples:**
121*2d543d20SAndroid Build Coastguard Worker
122*2d543d20SAndroid Build Coastguard WorkerThis shows two named security context examples plus an anonymous context:
123*2d543d20SAndroid Build Coastguard Worker
124*2d543d20SAndroid Build Coastguard Worker```secil
125*2d543d20SAndroid Build Coastguard Worker    ; Two named context:
126*2d543d20SAndroid Build Coastguard Worker    (sid kernel)
127*2d543d20SAndroid Build Coastguard Worker    (context kernel_context (u r process low_low))
128*2d543d20SAndroid Build Coastguard Worker    (sidcontext kernel kernel_context)
129*2d543d20SAndroid Build Coastguard Worker
130*2d543d20SAndroid Build Coastguard Worker    (sid security)
131*2d543d20SAndroid Build Coastguard Worker    (context security_context (u object_r process low_low))
132*2d543d20SAndroid Build Coastguard Worker    (sidcontext security security_context)
133*2d543d20SAndroid Build Coastguard Worker
134*2d543d20SAndroid Build Coastguard Worker    ; An anonymous context:
135*2d543d20SAndroid Build Coastguard Worker    (sid unlabeled)
136*2d543d20SAndroid Build Coastguard Worker    (sidcontext unlabeled (u object_r ((s0) (s0))))
137*2d543d20SAndroid Build Coastguard Worker```
138