This section details the specific SE for Android policy configuration files (i.e. those not used by 'standard' Linux based SELinux) as they were in April '13. Where those files are used to compute contexts using the SE for Android libselinux functions, those functions are also described with examples.

+

This section details the specific SE for Android policy configuration files (i.e. those not used by 'standard' Linux based SELinux). Where those files are used to compute contexts using the SE for Android <tt>libselinux</tt> functions, those functions are also described with examples.

As this project is continually being enhanced, it is recommended that the official project wiki is checked for the latest enhancements at [[SEforAndroid | SEforAndroid]]

As this project is continually being enhanced, it is recommended that the official project wiki is checked for the latest enhancements at [[SEforAndroid | SEforAndroid]]

-

== SELinux MAC Files ==

+

== SELinux MAC Configuration Files ==

=== seapp_contexts File ===

=== seapp_contexts File ===

This file is loaded and sorted into memory automatically on first use of one of the following SE for Android libselinux functions that are called by the SE for Android enabled services:

This file is loaded and sorted into memory automatically on first use of one of the following SE for Android libselinux functions that are called by the SE for Android enabled services:

Line 378:

Line 378:

</pre>

</pre>

-

== Install MMAC File ==

-

The <tt>mac_permissions.xml</tt> file is used to configure install-time MMAC policy and provides two main functions:

-

# x.509 certificate to <tt>seinfo</tt> string mapping so that Zygote spawns the application in the correct domain. See the [[#Computing a Process Context | Computing a Process Context]] section for how this is achieved using information also contained in the <tt>seapp_contexts</tt> file.

-

# Install-time MMAC permission checking.

-

It is important to note that all third party apps will be subject to the <tt><nowiki><default></nowiki></tt> install MAC policy defined in this file. This is a requirement of AOSP in that all third party apps must be treated alike (i.e. distinctions can only be made between system apps and third party apps and among the system apps, not between two different third party apps). The current <tt><nowiki><default></nowiki></tt> package policy is as follows:

+

== Install MMAC Configuration File ==

+

The <tt>mac_permissions.xml</tt> file is used to configure Install MMAC policy and provides two main functions:

+

# x.509 certificate to <tt>seinfo</tt> string mapping so that Zygote spawns the application in the correct domain. See the [[#Computing a Process Context | Computing a Process Context]] section for how this is achieved using information also contained in the <tt>seapp_contexts</tt> file (AOSP and SEAndroid).

+

# Install MMAC permission checking (SEAndroid only).

+

It is important to note that all third party apps will be subject to the <tt><nowiki><default></nowiki></tt> install MMAC policy defined in this file. This is a requirement of AOSP in that all third party apps must be treated alike (i.e. distinctions can only be made between system apps and third party apps and among the system apps, not between two different third party apps).

+

+

An example AOSP <tt>mac_permissions.xml</tt> file that also shows the <tt><nowiki><default></nowiki></tt> entry is:

The <tt><nowiki><signer signature=</nowiki></tt> entry may have the public base16 signing key present in the string or it may have an entry starting with <tt>@</tt>, then a keyword as shown that allows the key to be extracted from a pem file as discussed in the [[#insertkeys.py | insertkeys.py]] section:

+

The <tt><nowiki><signer signature=</nowiki></tt> entry may have the public base16 signing key present in the string or it may have an entry starting with <tt>@</tt> then a keyword (e.g <tt>@PLATFORM</tt>) that will signify that the key is to be extracted from a pem file as discussed in the <tt>[[#insertkeys.py | insertkeys.py]]</tt> section:

<pre>

<pre>

<!-- Platform dev key in AOSP -->

<!-- Platform dev key in AOSP -->

Line 411:

Line 444:

</pre>

</pre>

-

If a base16 key is required, it can be extracted from a package using the <tt>setool</tt> utility as described in the [[#setool | setool]] section.

+

If a base16 key is required, it can be extracted from a package using the <tt>setool</tt> utility as described in the <tt>[[#setool | setool]]</tt> section.

==== Policy Rules ====

==== Policy Rules ====

-

The following rules have been extracted from the source <tt>mac_permissions.xml</tt> file:

+

The following rules have been extracted from the SEAndroid <tt>mac_permissions.xml</tt> file:

* A signature is a hex encoded X.509 certificate and is required for each signer tag.

* A signature is a hex encoded X.509 certificate and is required for each signer tag.

Line 444:

Line 477:

** If none of the cases apply then the app is denied.

** If none of the cases apply then the app is denied.

-

An edited form of the default <tt>mac_permissions.xml</tt> file is as follows:

+

An edited form of an SEAndroid <tt>mac_permissions.xml</tt> file is as follows:

<pre>

<pre>

<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8"?>

Line 501:

Line 534:

-

== Intent MAC Files ==

+

== Intent MMAC Configuration Files ==

-

There are two configuration files to support intent MAC, they are:

+

There are two configuration files to support Intent MMAC, they are:

-

:: <tt>intent_mac.xml</tt> - This defines the intents that will be allowed between each source and destination. The source and destination may be package names or <tt><nowiki><type></nowiki></tt> entries defined in the <tt>mmac_types.xml</tt> file that will allow intents to be managed on a package, signature and/or permissions basis. There is also an optional <tt><nowiki><allow-all></nowiki></tt> section.

+

:: <tt>intent_mac.xml</tt> - This defines the intents that will be allowed between each source and destination. The source and destination may be package names or <tt><nowiki><type name</nowiki></tt> entries defined in the <tt>mmac_types.xml</tt> file (see [[Using Type or Package Names | Using Type or Package Names]] below on implementing these). There is also an optional <tt><nowiki><allow-all></nowiki></tt> section.

# An intent filter that specifies actions (intents) and the types (defined in <tt>mmac_types.xml</tt>) that can be either the source or destination of the action.

+

# <tt><nowiki><intent></nowiki></tt> filters that specify actions (intents) allowed between their source and destination, additional optional entries may also be added that refine the intent. The source and destination entries may be defined in the <tt>[[#mmac_types.xml File|mmac_types.xml]]</tt> file.

-

# An <tt><nowiki><allow-all></nowiki></tt> entry.

+

# <tt><nowiki><allow-all></nowiki></tt> that will allow all intents from the source to destination entries.

-

Currently the build process does not support multiple <tt>intent_mac.xml</tt> files, however this will probably change.

-

==== Intent Filter Entry ====

+

All <tt>intent_mac.xml</tt> file entries are between <tt><nowiki><policy></nowiki></tt> tags:

-

The entries are defined below with:

+

-

* The <tt><nowiki><action name="" /></nowiki></tt> entry will define the intent.

+

-

* The <tt>src=</tt> and <tt>dst=</tt> entries may be package names or 'type names' that are further defined in the <tt>mmac_types.xml</tt> file.

+

-

* The <tt>srcctx=</tt> entry if defined will be matched against the app process source context.

+

<pre>

<pre>

<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8"?>

-

<policy> <!-- Start intent_mac.xml entries -->

+

<policy>

+

......

+

</policy>

+

</pre>

-

<intent> <!-- Starts a new intent filter -->

+

The build process supports additional device specific <tt>intent_mac.xml</tt> files as described in the [[NB_SEforAndrooid_1#Building the Policy|Building the Policy]] section.

-

<filter>

+

-

<action name="" /> <!-- Only one entry allowed-->

+

-

<!-- or-->

+

-

<category name="" /> <!-- Multiple entries allowed -->

+

-

</filter>

+

-

<allow <!-- Multiple entries allowed -->

+

-

name="" <!-- Rule name -->

+

-

srcctx="" <!-- Source context to be matched -->

+

-

src="" <!-- Source <type> entry or package name -->

+

-

dst="" <!-- Destination <type> entry or package name -->

+

-

</allow>

+

-

</intent>

+

-

</policy> <!-- End entries -->

+

==== Intent Filter Entry ====

-

</pre>

+

Each intent entry is as follows:

-

An example entry is:

+

* <tt><nowiki><intent></nowiki></tt> start tag.

+

** <tt><nowiki><filter></nowiki></tt> start tag. The entries that follow would generally be obtained from the appropriate package manifest that describe the intent and its parameters.

** One or more <tt><nowiki><allow</nowiki></tt> entries that consist of the following:

+

*** An optional rule <tt>name=</tt> entry that will be displayed in debug logs.

+

*** Optional <tt>src=</tt> and <tt>dst=</tt> references for the allowed intents. These entries are generally <tt><nowiki><type name=""</nowiki></tt> entries defined in the <tt>mmac_types.xml</tt> file, however they may also be package names, see the [[Using Type or Package Names | Using Type or Package Names]] section for further details. Note: It is recommended that both <tt>src=</tt> and <tt>dst=</tt> entries are specified. Not specifying either of them or the <tt>dst=</tt> will allow the intent to 'anywhere'. The only exception should be when source context matching is used.

+

*** An optional <tt>srcctx=</tt> entry that will be matched against the source app process context.

+

** <tt>/></tt> The <tt>allow</tt> end tag.

+

* <tt><nowiki></intent></nowiki></tt> end tag.

+

+

Example entries are:

<pre>

<pre>

<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8"?>

-

<policy>

<policy>

<intent>

<intent>

<filter>

<filter>

-

<action name="android.bluetooth.adapter.action.LOCAL_NAME_CHANGED"/>

+

<action name="android.intent.action.CALL_PRIVILEGED"/>

+

<data scheme="tel"/>

+

<data scheme="voicemail"/>

</filter>

</filter>

-

<allow src="bluetooth" dst="settings"/>

+

<allow src="contacts_app" dst="telephony_app"/>

-

<allow src="bluetooth" dst="android"/>

+

</intent>

-

<allow src="bluetooth" dst="settings"/>

+

+

<intent>

+

<filter>

+

<action name="android.intent.action.VIEW"/>

+

<data mimeType="vnd.android.cursor.dir/calls" />

+

</filter>

+

<allow src="telephony_app" dst="contacts_app"/>

</intent>

</intent>

</policy>

</policy>

</pre>

</pre>

-

==== Allow-all Entry ====

+

==== allow-all Entry ====

-

The entries are defined below with:

+

An <tt><nowiki><allow-all></nowiki></tt> entry consists of:

-

* The <tt>src=</tt> and <tt>dst=</tt> entries are generally package names as all intents will be allowed, however they may be 'type names' that are further defined in the <tt>mmac_types.xml</tt> file.

+

* <tt><nowiki><allow-all></nowiki></tt> start tag.

-

* The <tt>srcctx=</tt> entry if defined will be matched against the app process source context.

+

** Zero of more <tt><nowiki><allow</nowiki></tt> entries that consist of the following:

+

*** An optional rule <tt>name=</tt> entry that will be displayed in debug logs.

+

*** Optional <tt>src</tt> and <tt>dst</tt> references of the allowed intents. These entries are generally package names to allow all intents to flow between them, however they may be <tt><nowiki><type name=""</nowiki></tt> entries defined in the <tt>mmac_types.xml</tt> file, see the [[Using Type or Package Names | Using Type or Package Names]] section for further details.

+

*** An optional <tt>srcctx</tt> entry that will be matched against the source app process context.

3) Set the <tt>persist.mac_applyNameTypes</tt> permission to <tt>true</tt>, as this enables package names to be automatically be added as <tt><nowiki><type name=</nowiki></tt> entries as the policy is loaded.

+

<pre>

+

adb shell su 0 setprop persist.mac_applyNameTypes 1

</pre>

</pre>

=== mmac_types.xml File ===

=== mmac_types.xml File ===

-

The build process supports additional <tt>mmac_types.xml</tt> files to allow devices to specify their specific entries as described in the [[NB_SEforAndroid_1#Building the Policy| Building the Policy]] section that will also expand any signatures.

+

The <tt>mmac_types.xml</tt> file contains the <tt><nowiki><type></nowiki></tt> entries that provide the source / destination references for the package and/or permissions rules used by the <tt>intent_mac.xml</tt> file. All entries are between <tt><nowiki><policy></nowiki></tt> tags:

-

+

-

The entries are defined below with:

+

-

* The <tt><nowiki><type name="" /></nowiki></tt> entry defines the 'type name' entry that will be referenced by the <tt>intent_mac.xml</tt> file <tt>src=""</tt> and <tt>dst=""</tt> entries. The entry will define signatures, package names and or permissions.

+

-

* The <tt><nowiki><signature value="" /></nowiki></tt> entries may be the key as extracted by setool (but it will need to be copied from the output produced by [[#setool | setool]]), or use the <tt>"@.."</tt> show in the example below, this will then be generated as a part of the build process by [[#insertkeys.py | insertkeys.py]].

+

-

* The <tt>srcctx=</tt> entry if defined will be matched against the app process source context.

+

<pre>

<pre>

<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8"?>

-

<types> <!--Start entries -->

+

<policy>

+

......

+

</policy>

+

</pre>

-

<type name="" /> <!-- The type entries 'name' -->

+

The build process supports additional device specific <tt>mmac_types.xml</tt> files as described in the [[NB_SEforAndroid_1#Building the Policy|Building the Policy]] section.

-

<signature value="" /> <!-- Multiple entries allowed -->

+

-

<package value="" /> <!-- Multiple entries allowed -->

+

-

<permission value="" /> <!-- Rule name -->

+

-

</type>

+

-

</types> <!-- End entries -->

+

Each <tt>mmac_types.xml</tt> file entry is as follows:

-

</pre>

+

+

* <tt><nowiki><type name="" ></nowiki></tt> entry that defines the name that will be referenced by the <tt>intent_mac.xml</tt> file <tt>src=""</tt> and <tt>dst=""</tt> entries.

** Zero or more <tt><nowiki><signature value="" /></nowiki></tt> entries. These may be the key as extracted by <tt>setool</tt> (but it will need to be copied here from the <tt>[[#setool|setool]]</tt> output), or the <tt>"@.."</tt> format as shown in the example below, the signature will then be automatically generated as part of the build process by <tt>[[#insertkeys.py|insertkeys.py]}</tt> as described in [[NB_SEforAndroid_1#Building the Policy| Building the Policy]] section. It is recommended that a signature is always present.

# <tt><nowiki><attribute></nowiki></tt> entries that assign a common name to multiple <tt><nowiki><type></nowiki></tt> entries.

+

# <tt><nowiki><allow-content></nowiki></tt> entries that define the source, target and permissions to allow access to content.

+

+

All entries are between <tt><nowiki><policy></nowiki></tt> tags:

+

<pre>

+

<?xml version="1.0" encoding="utf-8"?>

+

<policy>

+

......

+

</policy>

</pre>

</pre>

-

== Revoke Permissions File ==

+

The build process supports additional device specific <tt>content_provider.xml</tt> files as described in the [[NB_SEforAndroid_1#Building the Policy| Building the Policy]] section.

-

The <tt>revoke_permissions.xml</tt> file is used to configure revoked permissions. The build process does not currently support additional files. The <tt>revoke_permissions.xml</tt> file entries are as follows:

+

+

=== Package <type> Entries ===

+

Each <tt>content_provider.xml</tt> file package type entry is as follows:

+

+

* <tt><nowiki><type name="" component="package" ></nowiki></tt> entry. The <tt>name</tt> entry defines the name that will be referenced by the attribute <tt><nowiki><type></nowiki></tt> and/or <tt><nowiki><allow></nowiki></tt> source entry. The <tt>component</tt> entry specifies this as a package entry (other entries may be supported later).

** Zero or more <tt><nowiki><signature value="" /></nowiki></tt> entries. These may be the key as extracted by <tt>setool</tt> (but it will need to be copied here from the <tt>[[#setool|setool]]</tt> output), or the <tt>"@.."</tt> format as shown in the example below, the signature will then be automatically generated as part of the build process by <tt>[[#insertkeys.py|insertkeys.py]]</tt> as described in [[NB_SEforAndroid_1#Building the Policy| Building the Policy]] section.

When computing access to content the following precedence rules apply to package type entries:

+

+

# Signature defined over signature not defined.

+

# Package name defined over package name not defined.

+

# Permission set defined over permission set not defined.

+

+

There is no distinction between a stanza that has more signatures than another. They are considered of equal precedence.

+

+

Example entries are:

<pre>

<pre>

<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8"?>

-

<revoke-policy> <!-- Start entries -->

+

<policy>

+

<type name="platform" component="package">

+

<signature value="@PLATFORM"/>

+

</type>

-

<package name="" /> <!-- Package containing permissions to revoke -->

+

<type name="shared" component="package">

-

<revoke-permission="" /> <!-- Multiple entries allowed -->

+

<signature value="@SHARED"/>

-

</package>

+

</type>

-

<revoke-policy> <!-- End entries -->

+

<type name="release" component="package">

+

<signature value="@RELEASE"/>

+

</type>

+

+

<type name="media" component="package">

+

signature value="@MEDIA"/>

+

</type>

+

+

<type name="defualt_package" component="package">

+

</type>

+

+

<type name="demo_resolver_package" component="package">

+

<package value="com.example.resolvecontent" />

+

<permission value="com.se4android.contentprovider.READ" />

+

<permission value="com.se4android.contentprovider.WRITE" />

+

</type>

+

</policy>

</pre>

</pre>

+

+

=== Provider <type> Entries ===

+

Each <tt>content_provider.xml</tt> file provider type entry is as follows:

+

+

* <tt><nowiki><type name="" ></nowiki></tt> entry. The <tt>name</tt> entry defines the name that will be referenced by the attribute <tt><nowiki><type></nowiki></tt> and/or <tt><nowiki><allow></nowiki></tt> destination entries.

** Zero or more <tt><nowiki><signature value="" /></nowiki></tt> entries. These may be the key as extracted by <tt>setool</tt> (but it will need to be copied here from the <tt>[[#setool|setool]]</tt> output), or the <tt>"@.."</tt> format as shown in the example below, the signature will then be automatically generated as part of the build process by <tt>[[#insertkeys.py|insertkeys.py]]</tt> as described in [[NB_SEforAndroid_1#Building the Policy| Building the Policy]] section. It is recommended that a signature is always present.

+

** Zero or more <tt><nowiki><export-read value="" /></nowiki></tt> entries defining the read protection level (<tt>protectionLevel=</tt> in manifest). These are defined as <tt>normal</tt>, <tt>dangerous</tt>, <tt>signature</tt> or <tt>signatureOrSystem</tt>).

** Zero or more <tt><nowiki><attribute name="" ></nowiki></tt> entries. The <tt>name=</tt> entry defines the group name used to reference all the <tt><nowiki><type></nowiki></tt> entries. The <tt>name=</tt> may then be used in <tt><nowiki><allow></nowiki></tt> <tt>source=</tt> (for groups of package types) or <tt>destination=</tt> (for groups of content types) entries.

+

*** Zero or more <tt><nowiki><type name="" /></nowiki></tt> entries. The <tt>name=</tt> entry refers to a package or content type entry.

** Zero of more <tt><nowiki><allow</nowiki></tt> entries that consist of the following:

+

*** A <tt>source=""</tt> reference to a package type entry.

+

*** A <tt>destination=""</tt> reference to a content type entry.

+

*** A <tt>permission=""</tt> entry stating that the <tt>source=</tt> reference may use (<tt>use</tt>), read (<tt>r</tt>), write (<tt>w</tt>) or read/write (<tt>rw</tt>) the <tt>destination=</tt> content provider. Each permission is separated by a semi-colon (<tt><nowiki>;</nowiki></tt>). The <tt>use</tt> permission is required to obtain a handle to the content provider, but does not provide read or write capability. Read, Write, or Read-Write imply the <tt>use</tt> permission.

The <tt>insertkeys.py</tt> utility is used during the build process to insert signing keys into multiple <tt>mac_permissions.xml</tt> and <tt>mmac_types.xml</tt> files. The keys are obtained from <tt>pem</tt> files and the entries to be replaced start with an <tt>@</tt> followed by a keyword. The <tt>external/sepolicy/keys.conf</tt> file contains corresponding entries that allow mapping of <tt>pem</tt> files to signatures as discussed in the [[#keys.conf | keys.conf]] section.

+

The <tt>insertkeys.py</tt> utility is used during the build process to insert signing keys into multiple <tt>mac_permissions.xml</tt>, <tt>mmac_types.xml</tt> and <tt>content_provider.xml</tt> files. The keys are obtained from <tt>pem</tt> files and the entries to be replaced start with an <tt>@</tt> followed by a keyword. The <tt>external/sepolicy/keys.conf</tt> file contains corresponding entries that allow mapping of <tt>pem</tt> files to signatures as discussed in the [[#keys.conf | keys.conf]] section.

Note that <tt>pem</tt> files are base64 encoded however the Android Package Manager Service uses base16 encodings. Therefore <tt>insertkeys.py</tt> and <tt>setool</tt> will generate base16 encodings for the <tt>mac_permissions.xml</tt> and <tt>mmac_types.xml</tt> files.

Note that <tt>pem</tt> files are base64 encoded however the Android Package Manager Service uses base16 encodings. Therefore <tt>insertkeys.py</tt> and <tt>setool</tt> will generate base16 encodings for the <tt>mac_permissions.xml</tt> and <tt>mmac_types.xml</tt> files.

Line 723:

Line 983:

<tt>insertkeys.py</tt> will also strip the files of comments and whitespace to preserve space on the <tt>system.img</tt>. To view the output file in a more human friendly format the <tt>tidy</tt> or <tt>xmllint</tt> command can be used.

<tt>insertkeys.py</tt> will also strip the files of comments and whitespace to preserve space on the <tt>system.img</tt>. To view the output file in a more human friendly format the <tt>tidy</tt> or <tt>xmllint</tt> command can be used.

-

<tt>insertkeys.py -h</tt> will give the following output:

+

<tt>insertkeys.py -h</tt> will give the following output for 4.3 (4.2 does not have the <tt>-d</tt> option):

This tool allows one to configure an automatic inclusion of signing keys into the mac_permission.xml file(s) from the pem files.

This tool allows one to configure an automatic inclusion of signing keys into the mac_permission.xml file(s) from the pem files.

Line 738:

Line 998:

-t TARGET_BUILD_VARIANT, --target-build-variant=TARGET_BUILD_VARIANT

-t TARGET_BUILD_VARIANT, --target-build-variant=TARGET_BUILD_VARIANT

Specify the TARGET_BUILD_VARIANT, defaults to eng

Specify the TARGET_BUILD_VARIANT, defaults to eng

+

-d KEY_DIRECTORY, --key-directory

+

Specify a parent directory for keys

</pre>

</pre>

Line 751:

Line 1,013:

<tt>insertkeys.py</tt> allows for mapping any string contained in <tt>TARGET_BUILD_VARIANT</tt> with a specific path to a <tt>pem</tt> file. Typically <tt>TARGET_BUILD_VARIANT</tt> is either <tt>user</tt>, <tt>eng</tt> or <tt>userdebug</tt>. Additionally "<tt>ALL</tt>" may be specified to map a path to any string specified in <tt>TARGET_BUILD_VARIANT</tt>. All tags are matched verbatim and all options are matched lowercase. The options are "<tt>tolowered</tt>" automatically for the user, it is convention to specify tags and options in all uppercase and tags start with <tt>@</tt>.

<tt>insertkeys.py</tt> allows for mapping any string contained in <tt>TARGET_BUILD_VARIANT</tt> with a specific path to a <tt>pem</tt> file. Typically <tt>TARGET_BUILD_VARIANT</tt> is either <tt>user</tt>, <tt>eng</tt> or <tt>userdebug</tt>. Additionally "<tt>ALL</tt>" may be specified to map a path to any string specified in <tt>TARGET_BUILD_VARIANT</tt>. All tags are matched verbatim and all options are matched lowercase. The options are "<tt>tolowered</tt>" automatically for the user, it is convention to specify tags and options in all uppercase and tags start with <tt>@</tt>.

-

An example <tt>keys.conf</tt> file is as follows:

+

An example <tt>keys.conf</tt> file for AOSP 4.3 is as follows (note that the path is now supplied by the <tt>-d</tt> option when calling <tt>insertkeys.py</tt> in the <tt>external/sepolicy/Android.mk</tt> file):

<pre>

<pre>

-

<nowiki>#</nowiki>

+

#

-

<nowiki># Maps an arbitrary tag [TAGNAME] with the string contents found in</nowiki>

+

# Maps an arbitrary tag [TAGNAME] with the string contents found in

-

<nowiki># TARGET_BUILD_VARAINT. Common convention is to start TAGNAME with an @ and</nowiki>

+

# TARGET_BUILD_VARAINT. Common convention is to start TAGNAME with an @ and

-

<nowiki># name it after the base file name of the pem file.</nowiki>

+

# name it after the base file name of the pem file.

-

<nowiki>#</nowiki>

+

#

-

<nowiki># Each tag (section) then allows one to specify any string found in</nowiki>

+

# Each tag (section) then allows one to specify any string found in

-

<nowiki># TARGET_BUILD_VARIANT. Typically this is user, eng, and userdebug. Another</nowiki>

+

# TARGET_BUILD_VARIANT. Typically this is user, eng, and userdebug. Another

-

<nowiki># option is to use ALL which will match ANY TARGET_BUILD_VARAINT string.</nowiki>

+

# option is to use ALL which will match ANY TARGET_BUILD_VARAINT string.

-

<nowiki>#</nowiki>

+

#

-

<nowiki>[@PLATFORM]</nowiki>

+

[@PLATFORM]

-

ALL : build/target/product/security/platform.x509.pem

+

ALL : platform.x509.pem

-

<nowiki>[@MEDIA]</nowiki>

+

[@MEDIA]

-

ALL : build/target/product/security/media.x509.pem

+

ALL : media.x509.pem

-

<nowiki>[@SHARED]</nowiki>

+

[@SHARED]

-

ALL : build/target/product/security/shared.x509.pem

+

ALL : shared.x509.pem

-

<nowiki># Example of ALL TARGET_BUILD_VARIANTS</nowiki>

+

# Example of ALL TARGET_BUILD_VARIANTS

-

<nowiki>[@RELEASE]</nowiki>

+

[@RELEASE]

-

ENG : build/target/product/security/testkey.x509.pem

+

ENG : testkey.x509.pem

-

USER : build/target/product/security/testkey.x509.pem

+

USER : testkey.x509.pem

-

USERDEBUG : build/target/product/security/testkey.x509.pem

+

USERDEBUG : testkey.x509.pem

+

</pre>

+

+

The following is an example entry that will use a device specific key for release 4.3 during the build process:

+

<pre>

+

[@NET_APPS]

+

ALL : $ANDROID_BUILD_TOP/device/demo_vendor/demo_device/security/net_apps.x509.pem

+

</pre>

+

+

Should the build fail because of keys.conf entries, check that the following patch is installed:

The following text has been extracted from an email that describes this new 4.3 feature:

+

New code has been released that allow for policy reloading via Android's new UpdateConfig mechanism. Android 4.3 has brought a new set of OTA update hooks for various policy files including some of the SELinux ones. This is a way forward with reloadable policy support and as such have updated the SEAdmin project (master and seandroid-4.3 branches) with a new but limited reload option as well as updated the sepolicy project (seandroid and seandroid-4.3 branches) with new tooling. Some things to note:

+

* In order for SEAdmin to reload policy there is a required format imposed by the backed ConfigUpdate code. A new signed policy 'bundle' and metadata file are required; the bundle being a packed version of various selinux policy files. Because of this new format, a new tool called buildsebundle has been developed that will help with the construction of such files. It is not built as standard, therefore need to 'make buildsebundle' first and then see the help menu below along with an example.

+

* buildsebundle actually outputs a zip file containing the packed bundle and metadata file. The zip file isn't a direct requirement for the ConfigUpdate code but merely serves as a convenient packaging format to deliver both files to the device. This zip file will need to be pushed to /sdcard for SEAdmin to reload it.

+

* There is a requirement that the resulting bundle be signed for integrity purposes. The buildsebundle tool will help with this but a few caveats are in order. The backend code on the phone requires that an approved OTA cert already be loaded into the Settings secure database to verify the incoming reload request. This means that the cert on the phone must match the key fed the buildsebundle tool. SEAdmin has been changed to insert a key by first reading the entries in otacerts.zip on boot. The otacerts.zip file will include the correct testkey/releasekey when building the system image.

+

* There is no support for reloading mac_permissions.xml via this new reload mechanism. This is a limitation of the back end code which only supports reloading file_contexts, sepolicy, property_contexts and seapp_contexts policy files. The previous option for reloading mac_permissions.xml remains supported in the SEAdmin app however. The project will also continue to support the SEAdmin app as the ConfigUpdate code doesn't presently offer the abilities to switch to enforcing mode or toggle booleans.

+

* AOSP code for the new update mechanism can be found at: <tt>frameworks/base/services/java/com/android/server/updates/*</tt> .

+

* Since the ConfigUpdate code seems to still be under development, the SEAndroid project will most likely move in-step with that code in order to bring ideas together whenever possible. So, updates to both the SEAdmin and sepolicy tooling are possible in the future.

The <tt>setool</tt> utility is not used during the build process and is intended only to produce 'starter' entries for the <tt>mac_permissions.xml</tt> file.

+

The <tt>setool</tt> utility is not used during the build process and is intended only to produce 'starter' entries for the <tt>mac_permissions.xml</tt> file. It is not supplied in AOSP.

The entries produced will generally have to be modified because currently:

The entries produced will generally have to be modified because currently:

-

# If multiple packages are given each with the same signature, a separate entry will be generated for each package. If added to the <tt>mac_permissions.xml</tt> file only the first entry will be used by the Install-time MMAC process (therefore the packages need to be consolidated into on entry).

+

# If multiple packages are given each with the same signature, a separate entry will be generated for each package. If added to the <tt>mac_permissions.xml</tt> file only the first entry will be used by the Install MMAC process (therefore the packages need to be consolidated into on entry).

-

# <tt>setool</tt> will generate (<tt>--build</tt>) entries for third party apps, however it should not as they will be ignored by the install-time MMAC.

+

# <tt>setool</tt> will generate (<tt>--build</tt>) entries for third party apps, however it should not as they will be ignored by the Install MMAC.

# <tt>setool</tt> will check (<tt>--policy</tt>) third party apps against the full <tt>mac_permissions.xml</tt> policy, however it should not, it should only check them against the <tt><nowiki><default></nowiki></tt> entries only.

# <tt>setool</tt> will check (<tt>--policy</tt>) third party apps against the full <tt>mac_permissions.xml</tt> policy, however it should not, it should only check them against the <tt><nowiki><default></nowiki></tt> entries only.

Line 815:

Line 1,129:

</pre>

</pre>

-

The following are examples of using <tt>setool</tt>, however, note that they will not produce a valid policy for third party apps.

+

The following are examples of using <tt>setool</tt>:

-

+

-

Assuming in Android project directory (<tt>$PREFIX</tt>) and there is a "<tt>demo</tt>" directory present, run <tt>setool</tt> to extract the package info and generate white list entries from a package (any package will suffice for the example):

Policy File Configuration Details

This section details the specific SE for Android policy configuration files (i.e. those not used by 'standard' Linux based SELinux). Where those files are used to compute contexts using the SE for Android libselinux functions, those functions are also described with examples.

As this project is continually being enhanced, it is recommended that the official project wiki is checked for the latest enhancements at SEforAndroid

SELinux MAC Configuration Files

seapp_contexts File

This file is loaded and sorted into memory automatically on first use of one of the following SE for Android libselinux functions that are called by the SE for Android enabled services:

Computing a Directory Context

To compute an app package directory context the selinux_android_setfilecon2 function is called that will use the parameters passed, plus the contents of the seapp_contexts file. The function parameters are:

property_contexts File

This file holds property names and their contexts that will be applied by SELinux when applications are loaded. The property names reflect the 'white list' of Android property entries that are also built into the system (see system/core/init/property_service.c and init.c) however there are also additional property entries for applications that require specific contexts to be set.

The build process supports additional seapp_contexts files to allow devices to specify their specific entries as described in the Building the Policy section.

When selabel_open(3) is called specifying this file it will be read into memory and sorted using qsort(3), subsequent calls using selabel_lookup(3) will then retrieve the appropriate context.

Each line within the property contexts file is as follows:

property_key context

Where:

property_key

The key used to obtain the context that may contain '*' for wildcard matching.

Install MMAC Configuration File

The mac_permissions.xml file is used to configure Install MMAC policy and provides two main functions:

x.509 certificate to seinfo string mapping so that Zygote spawns the application in the correct domain. See the Computing a Process Context section for how this is achieved using information also contained in the seapp_contexts file (AOSP and SEAndroid).

Install MMAC permission checking (SEAndroid only).

It is important to note that all third party apps will be subject to the <default> install MMAC policy defined in this file. This is a requirement of AOSP in that all third party apps must be treated alike (i.e. distinctions can only be made between system apps and third party apps and among the system apps, not between two different third party apps).

An example AOSP mac_permissions.xml file that also shows the <default> entry is:

The build process supports additional mac_permissions.xml files to allow devices to specify their specific entries as described in the Building the Policy section.

Signature Entries

The <signer signature= entry may have the public base16 signing key present in the string or it may have an entry starting with @ then a keyword (e.g @PLATFORM) that will signify that the key is to be extracted from a pem file as discussed in the insertkeys.py section:

If a base16 key is required, it can be extracted from a package using the setool utility as described in the setool section.

Policy Rules

The following rules have been extracted from the SEAndroid mac_permissions.xml file:

A signature is a hex encoded X.509 certificate and is required for each signer tag.

A <signer signature="" > element may have multiple child elements:

allow-permission : produces a set of maximal allowed permissions (whitelist).

deny-permission : produces a blacklist of permissions to deny.

allow-all : a wildcard tag that will allow every permission requested.

package : a complex tag which itself defines allow, deny, and wildcard sub elements for a specific package name protected by the signature.

Zero or more global <package name=""> tags are allowed. These tags allow a policy to be set outside any signature for specific package names.

Unknown tags at any level are skipped.

Zero or more signer tags are allowed.

Zero or more package tags are allowed per signer tag.

A <package name=""> tag may not contain another <package name=""> tag. If found, it's skipped.

A <default> tag is allowed that can contain install policy for all apps not signed with a previously listed cert and not having a per package global policy.

When multiple sub elements appear for a tag the following logic is used to ultimately determine the type of enforcement:

A blacklist is used if at least one deny-permission tag is found

A whitelist is used if not a blacklist and at least one allow-permission tag is found

A wildcard (accept all permission) policy is used if not a blacklist and not a whitelist and at least one allow-all tag is present.

If a <package name=""> sub element is found then that sub element's policy is used according to the above logic and overrides any signature global policy type.

In order for a policy stanza to be enforced at least one of the above situations must apply. Meaning, empty signer, default or package tags will not be accepted.

Each signer / default / global package tag is allowed to contain one <seinfo value=""/> tag. This tag represents additional information that each application can use in setting a SELinux security context on the eventual process. Any <seinfo value=""/> tag found as a child of a <package name=""> tag which is protected (sub element of signer or the default tag) is ignored. It's possible that multiple seinfo tags are relevant for one application. In the event that this happens, the seinfo tag that will be applied is the one for which the corresponding policy stanza is used in the policy decision.

Strict enforcing of any xml stanza is not enforced in most cases. This mainly applies to duplicate tags which are allowed. In the event that a tag already exists, the original tag is replaced.

There are also no checks on the validity of permission names. Although valid android permissions are expected, nothing prevents unknowns.

Enforcement decisions:

All signatures used to sign an application are checked for policy according to signer tags. Only one of the signature policies has to pass however.

In the event that none of the signature policies pass, or none even match, then a global package policy is sought. If found, this policy mediates the install.

The default tag is consulted last if needed.

A local package policy always overrides any parent policy.

If none of the cases apply then the app is denied.

An edited form of an SEAndroid mac_permissions.xml file is as follows:

Intent MMAC Configuration Files

There are two configuration files to support Intent MMAC, they are:

intent_mac.xml - This defines the intents that will be allowed between each source and destination. The source and destination may be package names or <type name entries defined in the mmac_types.xml file (see Using Type or Package Names below on implementing these). There is also an optional <allow-all> section.

intent_mac.xml File

The file supports two optional types of entry:

<intent> filters that specify actions (intents) allowed between their source and destination, additional optional entries may also be added that refine the intent. The source and destination entries may be defined in the mmac_types.xml file.

<allow-all> that will allow all intents from the source to destination entries.

All intent_mac.xml file entries are between <policy> tags:

<?xml version="1.0" encoding="utf-8"?>
<policy>
......
</policy>

The build process supports additional device specific intent_mac.xml files as described in the Building the Policy section.

Intent Filter Entry

Each intent entry is as follows:

<intent> start tag.

<filter> start tag. The entries that follow would generally be obtained from the appropriate package manifest that describe the intent and its parameters.

Optional src= and dst= references for the allowed intents. These entries are generally <type name="" entries defined in the mmac_types.xml file, however they may also be package names, see the Using Type or Package Names section for further details. Note: It is recommended that both src= and dst= entries are specified. Not specifying either of them or the dst= will allow the intent to 'anywhere'. The only exception should be when source context matching is used.

An optional srcctx= entry that will be matched against the source app process context.

allow-all Entry

An <allow-all> entry consists of:

<allow-all> start tag.

Zero of more <allow entries that consist of the following:

An optional rule name= entry that will be displayed in debug logs.

Optional src and dst references of the allowed intents. These entries are generally package names to allow all intents to flow between them, however they may be <type name="" entries defined in the mmac_types.xml file, see the Using Type or Package Names section for further details.

An optional srcctx entry that will be matched against the source app process context.

3) Set the persist.mac_applyNameTypes permission to true, as this enables package names to be automatically be added as <type name= entries as the policy is loaded.

adb shell su 0 setprop persist.mac_applyNameTypes 1

mmac_types.xml File

The mmac_types.xml file contains the <type> entries that provide the source / destination references for the package and/or permissions rules used by the intent_mac.xml file. All entries are between <policy> tags:

<?xml version="1.0" encoding="utf-8"?>
<policy>
......
</policy>

The build process supports additional device specific mmac_types.xml files as described in the Building the Policy section.

Each mmac_types.xml file entry is as follows:

<type name="" > entry that defines the name that will be referenced by the intent_mac.xml file src="" and dst="" entries.

Zero or more package value="" entries containing package names.

Zero or more <signature value="" /> entries. These may be the key as extracted by setool (but it will need to be copied here from the setool output), or the "@.." format as shown in the example below, the signature will then be automatically generated as part of the build process by [[#insertkeys.py|insertkeys.py]} as described in Building the Policy section. It is recommended that a signature is always present.

<attribute> entries that assign a common name to multiple <type> entries.

<allow-content> entries that define the source, target and permissions to allow access to content.

All entries are between <policy> tags:

<?xml version="1.0" encoding="utf-8"?>
<policy>
......
</policy>

The build process supports additional device specific content_provider.xml files as described in the Building the Policy section.

Package <type> Entries

Each content_provider.xml file package type entry is as follows:

<type name="" component="package" > entry. The name entry defines the name that will be referenced by the attribute <type> and/or <allow> source entry. The component entry specifies this as a package entry (other entries may be supported later).

Zero or more <package value="" /> entries defining the package name.

Zero or more <signature value="" /> entries. These may be the key as extracted by setool (but it will need to be copied here from the setool output), or the "@.." format as shown in the example below, the signature will then be automatically generated as part of the build process by insertkeys.py as described in Building the Policy section.

Zero or more <permission value="" /> entries defining the permissions.

</type> end tag.

When computing access to content the following precedence rules apply to package type entries:

Signature defined over signature not defined.

Package name defined over package name not defined.

Permission set defined over permission set not defined.

There is no distinction between a stanza that has more signatures than another. They are considered of equal precedence.

Zero or more <signature value="" /> entries. These may be the key as extracted by setool (but it will need to be copied here from the setool output), or the "@.." format as shown in the example below, the signature will then be automatically generated as part of the build process by insertkeys.py as described in Building the Policy section. It is recommended that a signature is always present.

Zero or more <export-read value="" /> entries defining the read protection level (protectionLevel= in manifest). These are defined as normal, dangerous, signature or signatureOrSystem).

Attribute Entries

The content_provider.xml file attribute entries consist of:

<attributes> start tag.

Zero or more <attribute name="" > entries. The name= entry defines the group name used to reference all the <type> entries. The name= may then be used in <allow>source= (for groups of package types) or destination= (for groups of content types) entries.

Zero or more <type name="" /> entries. The name= entry refers to a package or content type entry.

A permission="" entry stating that the source= reference may use (use), read (r), write (w) or read/write (rw) the destination= content provider. Each permission is separated by a semi-colon (;). The use permission is required to obtain a handle to the content provider, but does not provide read or write capability. Read, Write, or Read-Write imply the use permission.

Policy Build Tools

This section covers the policy build tools located at external/sepolicy/tools. They are checkfc, checkseapp and insertkeys.py. There is also setool that is not used as part of the build process but generates mac_permissions.xml entries from packages.

checkfc

The checkfc utility is used during the build process to validate the file_contexts and property_contexts files against policy. If validation fails checkfc will exit with an error.

checkseapp

The checkseapp utility is used during the build process to validate the seapp_contexts file against policy. If validation fails checkseapp will exit with an error. checkseapp also consolidates matching entries and outputs the valid file stripped of comments.

insertkeys.py

The insertkeys.py utility is used during the build process to insert signing keys into multiple mac_permissions.xml, mmac_types.xml and content_provider.xml files. The keys are obtained from pem files and the entries to be replaced start with an @ followed by a keyword. The external/sepolicy/keys.conf file contains corresponding entries that allow mapping of pem files to signatures as discussed in the keys.conf section.

Note that pem files are base64 encoded however the Android Package Manager Service uses base16 encodings. Therefore insertkeys.py and setool will generate base16 encodings for the mac_permissions.xml and mmac_types.xml files.

insertkeys.py will also strip the files of comments and whitespace to preserve space on the system.img. To view the output file in a more human friendly format the tidy or xmllint command can be used.

insertkeys.py -h will give the following output for 4.3 (4.2 does not have the -d option):

Usage: insertkeys.py [options] CONFIG_FILE MAC_PERMISSIONS_FILE [MAC_PERMISSIONS_FILE...]
This tool allows one to configure an automatic inclusion of signing keys into the mac_permission.xml file(s) from the pem files.
If multiple mac_permission.xml files are included then they are unioned to produce a final version.
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-v, --verbose Print internal operations to stdout
-o FILE, --output=FILE Specify an output file, default is stdout
-c DIR, --cwd=DIR Specify a root (CWD) directory to run this from, itchdirs' AFTER loading the config file
-t TARGET_BUILD_VARIANT, --target-build-variant=TARGET_BUILD_VARIANT
Specify the TARGET_BUILD_VARIANT, defaults to eng
-d KEY_DIRECTORY, --key-directory
Specify a parent directory for keys

An example command that takes two mac_permission.xml files inserts the signatures and concatenates them into a single file is:

keys.conf

The keys.conf file is used by insertkeys.py for mapping the "@..." tags in mac_permissions.xml and mmac_types.xml signature entries with public keys found in pem files. The configuration file can be used in BOARD_SEPOLICY_UNION and BOARD_SEPOLICY_REPLACE variables and is processed via m4 macros.

insertkeys.py allows for mapping any string contained in TARGET_BUILD_VARIANT with a specific path to a pem file. Typically TARGET_BUILD_VARIANT is either user, eng or userdebug. Additionally "ALL" may be specified to map a path to any string specified in TARGET_BUILD_VARIANT. All tags are matched verbatim and all options are matched lowercase. The options are "tolowered" automatically for the user, it is convention to specify tags and options in all uppercase and tags start with @.

An example keys.conf file for AOSP 4.3 is as follows (note that the path is now supplied by the -d option when calling insertkeys.py in the external/sepolicy/Android.mk file):

#
# Maps an arbitrary tag [TAGNAME] with the string contents found in
# TARGET_BUILD_VARAINT. Common convention is to start TAGNAME with an @ and
# name it after the base file name of the pem file.
#
# Each tag (section) then allows one to specify any string found in
# TARGET_BUILD_VARIANT. Typically this is user, eng, and userdebug. Another
# option is to use ALL which will match ANY TARGET_BUILD_VARAINT string.
#
[@PLATFORM]
ALL : platform.x509.pem
[@MEDIA]
ALL : media.x509.pem
[@SHARED]
ALL : shared.x509.pem
# Example of ALL TARGET_BUILD_VARIANTS
[@RELEASE]
ENG : testkey.x509.pem
USER : testkey.x509.pem
USERDEBUG : testkey.x509.pem

The following is an example entry that will use a device specific key for release 4.3 during the build process:

buildsebundle

The following text has been extracted from an email that describes this new 4.3 feature:
New code has been released that allow for policy reloading via Android's new UpdateConfig mechanism. Android 4.3 has brought a new set of OTA update hooks for various policy files including some of the SELinux ones. This is a way forward with reloadable policy support and as such have updated the SEAdmin project (master and seandroid-4.3 branches) with a new but limited reload option as well as updated the sepolicy project (seandroid and seandroid-4.3 branches) with new tooling. Some things to note:

In order for SEAdmin to reload policy there is a required format imposed by the backed ConfigUpdate code. A new signed policy 'bundle' and metadata file are required; the bundle being a packed version of various selinux policy files. Because of this new format, a new tool called buildsebundle has been developed that will help with the construction of such files. It is not built as standard, therefore need to 'make buildsebundle' first and then see the help menu below along with an example.

buildsebundle actually outputs a zip file containing the packed bundle and metadata file. The zip file isn't a direct requirement for the ConfigUpdate code but merely serves as a convenient packaging format to deliver both files to the device. This zip file will need to be pushed to /sdcard for SEAdmin to reload it.

There is a requirement that the resulting bundle be signed for integrity purposes. The buildsebundle tool will help with this but a few caveats are in order. The backend code on the phone requires that an approved OTA cert already be loaded into the Settings secure database to verify the incoming reload request. This means that the cert on the phone must match the key fed the buildsebundle tool. SEAdmin has been changed to insert a key by first reading the entries in otacerts.zip on boot. The otacerts.zip file will include the correct testkey/releasekey when building the system image.

There is no support for reloading mac_permissions.xml via this new reload mechanism. This is a limitation of the back end code which only supports reloading file_contexts, sepolicy, property_contexts and seapp_contexts policy files. The previous option for reloading mac_permissions.xml remains supported in the SEAdmin app however. The project will also continue to support the SEAdmin app as the ConfigUpdate code doesn't presently offer the abilities to switch to enforcing mode or toggle booleans.

AOSP code for the new update mechanism can be found at: frameworks/base/services/java/com/android/server/updates/* .

Since the ConfigUpdate code seems to still be under development, the SEAndroid project will most likely move in-step with that code in order to bring ideas together whenever possible. So, updates to both the SEAdmin and sepolicy tooling are possible in the future.

buildsebundle -h will give the following output:

usage: buildsebundle -k <private key.pk8> [-v <version>] [-r <previous hash>] [-h] -- <file_contexts>
<property_contexts> <sepolicy> <seapp_contexts>
This script builds a selinux policy bundle and supporting metadata file capable of being loaded via
the ConfigUpdate mechanism. It takes a pkcs8 DER encoded RSA private key that is then used to sign
the bundle. For AOSP development you'll typically want to use the key from the source tree at
build/target/product/security/testkey.pk8. If building your own cert you should probably use at least
a key size of 1024 or greater. The bundle requires that seapp_contexts, file_contexts, property_contexts
and sepolicy files all be included and with those exact basenames. The built bundle will be written to
selinux_bundle.zip which will include the signature metadata file of the bundle.
OPTIONS:
-h Show this message.
-v Version of the built bundle. Defaults to 1.
-r Sha512 hash of the bundle to replace. Defaults to 'NONE'.

The following example (with policy files in cwd will produce an selinux_bundle.zip file containing two files update_bundle and update_bundle_metadata:

setool

The setool utility is not used during the build process and is intended only to produce 'starter' entries for the mac_permissions.xml file. It is not supplied in AOSP.

The entries produced will generally have to be modified because currently:

If multiple packages are given each with the same signature, a separate entry will be generated for each package. If added to the mac_permissions.xml file only the first entry will be used by the Install MMAC process (therefore the packages need to be consolidated into on entry).

setool will generate (--build) entries for third party apps, however it should not as they will be ignored by the Install MMAC.

setool will check (--policy) third party apps against the full mac_permissions.xml policy, however it should not, it should only check them against the <default> entries only.

Having said that, setool is still useful as it will generate the signature entries and extract the permissions.

setool --help will give the following output:

Usage: setool [flags] <--build|--policy> <apks>
Tool to help build and verify MMAC install policies.
apks List of apks to analyze, space separated. All supplied apks must
be absolute paths or relative to --apkdir (which defaults to the current directory).
--build Generate an MMAC style policy stanza. The resulting stanza can then be used as an entry in the mac_permissions.xml file.
whitelist
Policy entry that contains a white listing of all permissions. The stanza will contain the app's package tag within its
signer tag.
keys
Print a valid signer tag which contains the hex encoded X.509 cert of the app.
--policy Determine if supplied apks pass the supplied policy.
Flags:
--help Prints this message and exits.
--apkdir Directory to search for supplied apks (default to current directory).
--verbose Increase the amount of debug statements.
--outfile Dump all output to the given file (defaults to stdout).
--seinfo Create an seinfo tag for all generated policy stanzas.