16cd6a6acSopenharmony_ciDefault Object Statements
26cd6a6acSopenharmony_ci=========================
36cd6a6acSopenharmony_ci
46cd6a6acSopenharmony_ciThese rules allow a default user, role, type and/or range to be used when computing a context for a new object. These require policy version 27 or 28 with kernels 3.5 or greater.
56cd6a6acSopenharmony_ci
66cd6a6acSopenharmony_cidefaultuser
76cd6a6acSopenharmony_ci-----------
86cd6a6acSopenharmony_ci
96cd6a6acSopenharmony_ciAllows the default user to be taken from the source or target context when computing a new context for the object [`class`](cil_class_and_permission_statements.md#class) identifier. Requires policy version 27.
106cd6a6acSopenharmony_ci
116cd6a6acSopenharmony_ci**Statement definition:**
126cd6a6acSopenharmony_ci
136cd6a6acSopenharmony_ci```secil
146cd6a6acSopenharmony_ci    (defaultuser class_id default)
156cd6a6acSopenharmony_ci```
166cd6a6acSopenharmony_ci
176cd6a6acSopenharmony_ci**Where:**
186cd6a6acSopenharmony_ci
196cd6a6acSopenharmony_ci<table>
206cd6a6acSopenharmony_ci<colgroup>
216cd6a6acSopenharmony_ci<col width="25%" />
226cd6a6acSopenharmony_ci<col width="75%" />
236cd6a6acSopenharmony_ci</colgroup>
246cd6a6acSopenharmony_ci<tbody>
256cd6a6acSopenharmony_ci<tr class="odd">
266cd6a6acSopenharmony_ci<td align="left"><p><code>defaultuser</code></p></td>
276cd6a6acSopenharmony_ci<td align="left"><p>The <code>defaultuser</code> keyword.</p></td>
286cd6a6acSopenharmony_ci</tr>
296cd6a6acSopenharmony_ci<tr class="even">
306cd6a6acSopenharmony_ci<td align="left"><p><code>class_id</code></p></td>
316cd6a6acSopenharmony_ci<td align="left"><p>A single previously declared <code>class</code> or <code>classmap</code> identifier, or a list of previously declared <code>class</code> or <code>classmap</code> identifiers enclosed within parentheses.</p></td>
326cd6a6acSopenharmony_ci</tr>
336cd6a6acSopenharmony_ci<tr class="odd">
346cd6a6acSopenharmony_ci<td align="left"><p><code>default</code></p></td>
356cd6a6acSopenharmony_ci<td align="left"><p>A keyword of either <code>source</code> or <code>target</code>.</p></td>
366cd6a6acSopenharmony_ci</tr>
376cd6a6acSopenharmony_ci</tbody>
386cd6a6acSopenharmony_ci</table>
396cd6a6acSopenharmony_ci
406cd6a6acSopenharmony_ci**Example:**
416cd6a6acSopenharmony_ci
426cd6a6acSopenharmony_ciWhen creating new `binder`, `property_service`, `zygote` or `memprotect` objects the [`user`](cil_user_statements.md#user) component of the new security context will be taken from the `source` context:
436cd6a6acSopenharmony_ci
446cd6a6acSopenharmony_ci```secil
456cd6a6acSopenharmony_ci    (class binder (impersonate call set_context_mgr transfer receive))
466cd6a6acSopenharmony_ci    (class property_service (set))
476cd6a6acSopenharmony_ci    (class zygote (specifyids specifyrlimits specifycapabilities specifyinvokewith specifyseinfo))
486cd6a6acSopenharmony_ci    (class memprotect (mmap_zero))
496cd6a6acSopenharmony_ci
506cd6a6acSopenharmony_ci    (classmap android_classes (android))
516cd6a6acSopenharmony_ci    (classmapping android_classes android (binder (all)))
526cd6a6acSopenharmony_ci    (classmapping android_classes android (property_service (set)))
536cd6a6acSopenharmony_ci    (classmapping android_classes android (zygote (not (specifycapabilities))))
546cd6a6acSopenharmony_ci
556cd6a6acSopenharmony_ci    (defaultuser (android_classes memprotect) source)
566cd6a6acSopenharmony_ci
576cd6a6acSopenharmony_ci    ; Will produce the following in the binary policy file:
586cd6a6acSopenharmony_ci    ;; default_user binder source;
596cd6a6acSopenharmony_ci    ;; default_user zygote source;
606cd6a6acSopenharmony_ci    ;; default_user property_service source;
616cd6a6acSopenharmony_ci    ;; default_user memprotect source;
626cd6a6acSopenharmony_ci```
636cd6a6acSopenharmony_ci
646cd6a6acSopenharmony_cidefaultrole
656cd6a6acSopenharmony_ci-----------
666cd6a6acSopenharmony_ci
676cd6a6acSopenharmony_ciAllows the default role to be taken from the source or target context when computing a new context for the object [`class`](cil_class_and_permission_statements.md#class) identifier. Requires policy version 27.
686cd6a6acSopenharmony_ci
696cd6a6acSopenharmony_ci```secil
706cd6a6acSopenharmony_ci    (defaultrole class_id default)
716cd6a6acSopenharmony_ci```
726cd6a6acSopenharmony_ci
736cd6a6acSopenharmony_ci**Where:**
746cd6a6acSopenharmony_ci
756cd6a6acSopenharmony_ci<table>
766cd6a6acSopenharmony_ci<colgroup>
776cd6a6acSopenharmony_ci<col width="25%" />
786cd6a6acSopenharmony_ci<col width="75%" />
796cd6a6acSopenharmony_ci</colgroup>
806cd6a6acSopenharmony_ci<tbody>
816cd6a6acSopenharmony_ci<tr class="odd">
826cd6a6acSopenharmony_ci<td align="left"><p><code>defaultrole</code></p></td>
836cd6a6acSopenharmony_ci<td align="left"><p>The <code>defaultrole</code> keyword.</p></td>
846cd6a6acSopenharmony_ci</tr>
856cd6a6acSopenharmony_ci<tr class="even">
866cd6a6acSopenharmony_ci<td align="left"><p><code>class_id</code></p></td>
876cd6a6acSopenharmony_ci<td align="left"><p>A single previously declared <code>class</code> or <code>classmap</code> identifier, or a list of previously declared <code>class</code> or <code>classmap</code> identifiers enclosed within parentheses.</p></td>
886cd6a6acSopenharmony_ci</tr>
896cd6a6acSopenharmony_ci<tr class="odd">
906cd6a6acSopenharmony_ci<td align="left"><p><code>default</code></p></td>
916cd6a6acSopenharmony_ci<td align="left"><p>A keyword of either <code>source</code> or <code>target</code>.</p></td>
926cd6a6acSopenharmony_ci</tr>
936cd6a6acSopenharmony_ci</tbody>
946cd6a6acSopenharmony_ci</table>
956cd6a6acSopenharmony_ci
966cd6a6acSopenharmony_ci**Example:**
976cd6a6acSopenharmony_ci
986cd6a6acSopenharmony_ciWhen creating new `binder`, `property_service` or `zygote` objects the [`role`](cil_role_statements.md#role) component of the new security context will be taken from the `target` context:
996cd6a6acSopenharmony_ci
1006cd6a6acSopenharmony_ci```secil
1016cd6a6acSopenharmony_ci    (class binder (impersonate call set_context_mgr transfer receive))
1026cd6a6acSopenharmony_ci    (class property_service (set))
1036cd6a6acSopenharmony_ci    (class zygote (specifyids specifyrlimits specifycapabilities specifyinvokewith specifyseinfo))
1046cd6a6acSopenharmony_ci
1056cd6a6acSopenharmony_ci    (defaultrole (binder property_service zygote) target)
1066cd6a6acSopenharmony_ci
1076cd6a6acSopenharmony_ci    ; Will produce the following in the binary policy file:
1086cd6a6acSopenharmony_ci    ;; default_role binder target;
1096cd6a6acSopenharmony_ci    ;; default_role zygote target;
1106cd6a6acSopenharmony_ci    ;; default_role property_service target;
1116cd6a6acSopenharmony_ci```
1126cd6a6acSopenharmony_ci
1136cd6a6acSopenharmony_cidefaulttype
1146cd6a6acSopenharmony_ci-----------
1156cd6a6acSopenharmony_ci
1166cd6a6acSopenharmony_ciAllows the default type to be taken from the source or target context when computing a new context for the object [`class`](cil_class_and_permission_statements.md#class) identifier. Requires policy version 28.
1176cd6a6acSopenharmony_ci
1186cd6a6acSopenharmony_ci**Statement definition:**
1196cd6a6acSopenharmony_ci
1206cd6a6acSopenharmony_ci```secil
1216cd6a6acSopenharmony_ci    (defaulttype class_id default)
1226cd6a6acSopenharmony_ci```
1236cd6a6acSopenharmony_ci
1246cd6a6acSopenharmony_ci**Where:**
1256cd6a6acSopenharmony_ci
1266cd6a6acSopenharmony_ci<table>
1276cd6a6acSopenharmony_ci<colgroup>
1286cd6a6acSopenharmony_ci<col width="25%" />
1296cd6a6acSopenharmony_ci<col width="75%" />
1306cd6a6acSopenharmony_ci</colgroup>
1316cd6a6acSopenharmony_ci<tbody>
1326cd6a6acSopenharmony_ci<tr class="odd">
1336cd6a6acSopenharmony_ci<td align="left"><p><code>defaulttype</code></p></td>
1346cd6a6acSopenharmony_ci<td align="left"><p>The <code>defaulttype</code> keyword.</p></td>
1356cd6a6acSopenharmony_ci</tr>
1366cd6a6acSopenharmony_ci<tr class="even">
1376cd6a6acSopenharmony_ci<td align="left"><p><code>class_id</code></p></td>
1386cd6a6acSopenharmony_ci<td align="left"><p>A single previously declared <code>class</code> or <code>classmap</code> identifier, or a list of previously declared <code>class</code> or <code>classmap</code> identifiers enclosed within parentheses.</p></td>
1396cd6a6acSopenharmony_ci</tr>
1406cd6a6acSopenharmony_ci<tr class="odd">
1416cd6a6acSopenharmony_ci<td align="left"><p><code>default</code></p></td>
1426cd6a6acSopenharmony_ci<td align="left"><p>A keyword of either <code>source</code> or <code>target</code>.</p></td>
1436cd6a6acSopenharmony_ci</tr>
1446cd6a6acSopenharmony_ci</tbody>
1456cd6a6acSopenharmony_ci</table>
1466cd6a6acSopenharmony_ci
1476cd6a6acSopenharmony_ci**Example:**
1486cd6a6acSopenharmony_ci
1496cd6a6acSopenharmony_ciWhen creating a new `socket` object, the [`type`](cil_type_statements.md#type) component of the new security context will be taken from the `source` context:
1506cd6a6acSopenharmony_ci
1516cd6a6acSopenharmony_ci```secil
1526cd6a6acSopenharmony_ci    (defaulttype socket source)
1536cd6a6acSopenharmony_ci```
1546cd6a6acSopenharmony_ci
1556cd6a6acSopenharmony_cidefaultrange
1566cd6a6acSopenharmony_ci------------
1576cd6a6acSopenharmony_ci
1586cd6a6acSopenharmony_ciAllows the default level or range to be taken from the source, target, or both contexts when computing a new context for the object [`class`](cil_class_and_permission_statements.md#class) identifier. Requires policy version 27. glblub as the default requires policy version 32.
1596cd6a6acSopenharmony_ci
1606cd6a6acSopenharmony_ci**Statement definition:**
1616cd6a6acSopenharmony_ci
1626cd6a6acSopenharmony_ci```secil
1636cd6a6acSopenharmony_ci    (defaultrange class_id default <range>)
1646cd6a6acSopenharmony_ci```
1656cd6a6acSopenharmony_ci
1666cd6a6acSopenharmony_ci**Where:**
1676cd6a6acSopenharmony_ci
1686cd6a6acSopenharmony_ci<table>
1696cd6a6acSopenharmony_ci<colgroup>
1706cd6a6acSopenharmony_ci<col width="25%" />
1716cd6a6acSopenharmony_ci<col width="75%" />
1726cd6a6acSopenharmony_ci</colgroup>
1736cd6a6acSopenharmony_ci<tbody>
1746cd6a6acSopenharmony_ci<tr class="odd">
1756cd6a6acSopenharmony_ci<td align="left"><p><code>defaultrange</code></p></td>
1766cd6a6acSopenharmony_ci<td align="left"><p>The <code>defaultrange</code> keyword.</p></td>
1776cd6a6acSopenharmony_ci</tr>
1786cd6a6acSopenharmony_ci<tr class="even">
1796cd6a6acSopenharmony_ci<td align="left"><p><code>class_id</code></p></td>
1806cd6a6acSopenharmony_ci<td align="left"><p>A single previously declared <code>class</code> or <code>classmap</code> identifier, or a list of previously declared <code>class</code> or <code>classmap</code> identifiers enclosed within parentheses.</p></td>
1816cd6a6acSopenharmony_ci</tr>
1826cd6a6acSopenharmony_ci<tr class="odd">
1836cd6a6acSopenharmony_ci<td align="left"><p><code>default</code></p></td>
1846cd6a6acSopenharmony_ci<td align="left"><p>A keyword of either <code>source</code>, <code>target</code>, or <code>glblub</code>.</p></td>
1856cd6a6acSopenharmony_ci</tr>
1866cd6a6acSopenharmony_ci<tr class="even">
1876cd6a6acSopenharmony_ci<td align="left"><p><code>range</code></p></td>
1886cd6a6acSopenharmony_ci<td align="left"><p>A keyword of either <code>low</code>, <code>high</code>, or <code>low-high</code>.</p></td>
1896cd6a6acSopenharmony_ci</tr>
1906cd6a6acSopenharmony_ci</tbody>
1916cd6a6acSopenharmony_ci</table>
1926cd6a6acSopenharmony_ci
1936cd6a6acSopenharmony_ci**Example:**
1946cd6a6acSopenharmony_ci
1956cd6a6acSopenharmony_ciWhen creating a new `file` object, the appropriate `range` component of the new security context will be taken from the `target` context:
1966cd6a6acSopenharmony_ci
1976cd6a6acSopenharmony_ci```secil
1986cd6a6acSopenharmony_ci    (defaultrange file target low_high)
1996cd6a6acSopenharmony_ci```
2006cd6a6acSopenharmony_ci
2016cd6a6acSopenharmony_ciMLS userspace object managers may need to compute the common parts of a range such that the object is created with the range common to the subject and containing object:
2026cd6a6acSopenharmony_ci
2036cd6a6acSopenharmony_ci```secil
2046cd6a6acSopenharmony_ci    (defaultrange db_table glblub)
2056cd6a6acSopenharmony_ci```
206