|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| apex/ | | 15-Dec-2024 | - | 462 | 377 |
| build/ | | 15-Dec-2024 | - | 4,074 | 2,986 |
| compat/ | | 15-Dec-2024 | - | 588 | 509 |
| contexts/ | | 15-Dec-2024 | - | 1,895 | 1,753 |
| flagging/ | | 15-Dec-2024 | - | 84 | 74 |
| mac_permissions/ | | 15-Dec-2024 | - | 99 | 89 |
| microdroid/ | | 15-Dec-2024 | - | 10,545 | 9,195 |
| private/ | | 15-Dec-2024 | - | 47,608 | 42,064 |
| public/ | | 15-Dec-2024 | - | 7,148 | 6,572 |
| reqd_mask/ | | 14-Jan-2024 | - | 1,085 | 886 |
| tests/ | | 15-Dec-2024 | - | 2,944 | 2,092 |
| tools/ | | 15-Dec-2024 | - | 5,669 | 4,307 |
| vendor/ | | 15-Dec-2024 | - | 1,170 | 832 |
| .gitignore | D | 14-Jan-2024 | 11 | 3 | 2 |
| Android.bp | D | 15-Dec-2024 | 27.6 KiB | 955 | 877 |
| Android.mk | D | 15-Dec-2024 | 20.2 KiB | 561 | 361 |
| CleanSpec.mk | D | 14-Jan-2024 | 7.2 KiB | 123 | 61 |
| METADATA | D | 14-Jan-2024 | 128 | 5 | 4 |
| MODULE_LICENSE_PUBLIC_DOMAIN | D | 14-Jan-2024 | 0 | | |
| NOTICE | D | 14-Jan-2024 | 1 KiB | 22 | 19 |
| OWNERS | D | 15-Dec-2024 | 172 | 10 | 9 |
| PREUPLOAD.cfg | D | 15-Dec-2024 | 251 | 9 | 7 |
| README.apps.md | D | 15-Dec-2024 | 2.5 KiB | 58 | 46 |
| README.md | D | 14-Jan-2024 | 5.8 KiB | 118 | 94 |
| TEST_MAPPING | D | 15-Dec-2024 | 846 | 30 | 29 |
| treble_sepolicy_tests_for_release.mk | D | 15-Dec-2024 | 3.8 KiB | 82 | 62 |
README.apps.md
1The policy defines multiple types and attributes for apps. This document is a
2high-level overview of these. For further details on each type, refer to their
3specific files in the public/ and private/ directories.
4
5## appdomain
6In general, all apps will have the `appdomain` attribute. You can think of
7`appdomain` as any app started by Zygote. The macro `app_domain()` should be
8used to define a type that is considered an app (see public/te_macros).
9
10## untrusted_app
11Third-party apps (for example, installed from the Play Store), targeting the
12most recent SDK version will be typed as `untrusted_app`. This is the default
13domain for apps, unless a more specific criteria applies.
14
15When an app is targeting a previous SDK version, it may have the
16`untrusted_app_xx` type where xx is the targetSdkVersion. For instance, an app
17with `targetSdkVersion = 32` in its manifest will be typed as `untrusted_app_32`.
18Not all targetSdkVersion have a specific type, some version are skipped when no
19differences were introduced (see public/untrusted_app.te for more details).
20
21The `untrusted_app_all` attribute can be used to reference all the types
22described in this section (that is, `untrusted_app`, `untrusted_app_30`,
23`untrusted_app_32`, etc.).
24
25## isolated_app
26Apps may be restricted when using isolatedProcess=true in their manifest. In
27this case, they will be assigned the `isolated_app` type. A similar type
28`isolated_compute_app` exist for some restricted services.
29
30Both types `isolated_app` and `isolated_compute_app` are grouped under the
31attribute `isolated_app_all`.
32
33## ephemeral_app
34Apps that are run without installation. These are apps deployed for example via
35Google Play Instant. These are more constrained than `untrusted_app`.
36
37## sdk_sandbox
38SDK runtime apps, installed as part of the Privacy Sandbox project. These are
39sandboxed to limit their communication channels.
40
41## platform_app
42Apps that are signed with the platform key. These are installed within the
43system or vendor image. com.android.systemui is an example of an app running
44with this type.
45
46## system_app
47Apps pre-installed on a device, signed by the platform key and running with the
48system UID. com.android.settings is an example of an app running with this
49type.
50
51## priv_app
52Apps shipped as part of the device and installed in one of the
53`/{system,vendor,product}/priv-app` directories.
54com.google.android.apps.messaging is an example of an app running as priv_app.
55Permissions for these apps need to be explicitly granted, see
56https://source.android.com/docs/core/permissions/perms-allowlist for more
57details.
58
README.md
1# Android SEPolicy
2
3This directory contains the core Android SELinux policy configuration.
4It defines the domains and types for the AOSP services and apps common to
5all devices. Device-specific policy should be placed under a
6separate `device/<vendor>/<board>/sepolicy` subdirectory and linked
7into the policy build as described below.
8
9## Policy Generation
10
11Additional, per device, policy files can be added into the
12policy build. These files should have each line including the
13final line terminated by a newline character (`0x0A`). This
14will allow files to be concatenated and processed whenever
15the `m4`(1) macro processor is called by the build process.
16Adding the newline will also make the intermediate text files
17easier to read when debugging build failures. The sets of file,
18service and property contexts files will automatically have a
19newline inserted between each file as these are common failure
20points.
21
22These device policy files can be configured through the use of
23the `BOARD_VENDOR_SEPOLICY_DIRS` variable. This variable should be set
24in the BoardConfig.mk file in the device or vendor directories.
25
26`BOARD_VENDOR_SEPOLICY_DIRS` contains a list of directories to search
27for additional policy files. Order matters in this list.
28For example, if you have 2 instances of widget.te files in the
29`BOARD_VENDOR_SEPOLICY_DIRS` search path, then the first one found (at the
30first search dir containing the file) will be concatenated first.
31Reviewing `out/target/product/<device>/obj/ETC/vendor_sepolicy.conf_intermediates/vendor_sepolicy.conf`
32will help sort out ordering issues.
33
34Example `BoardConfig.mk` Usage:
35From the Tuna device `BoardConfig.mk`, `device/samsung/tuna/BoardConfig.mk`
36
37 BOARD_VENDOR_SEPOLICY_DIRS += device/samsung/tuna/sepolicy
38
39Alongside vendor sepolicy dirs, OEMs can also amend the public and private
40policy of the product and system_ext partitions:
41
42 SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS += device/acme/roadrunner-sepolicy/systemext/public
43 SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += device/acme/roadrunner-sepolicy/systemext/private
44 PRODUCT_PUBLIC_SEPOLICY_DIRS += device/acme/roadrunner-sepolicy/product/public
45 PRODUCT_PRIVATE_SEPOLICY_DIRS += device/acme/roadrunner-sepolicy/product/private
46
47The old `BOARD_PLAT_PUBLIC_SEPOLICY_DIR` and `BOARD_PLAT_PRIVATE_SEPOLICY_DIR`
48variables have been deprecated in favour of `SYSTEM_EXT_*`.
49
50Additionally, OEMs can specify `BOARD_SEPOLICY_M4DEFS` to pass arbitrary `m4`
51definitions during the build. A definition consists of a string in the form
52of `macro-name=value`. Spaces must **NOT** be present. This is useful for building modular
53policies, policy generation, conditional file paths, etc. It is supported in
54the following file types:
55* All `*.te` and SELinux policy files as passed to `checkpolicy`
56* `file_contexts`
57* `service_contexts`
58* `property_contexts`
59* `keys.conf`
60
61Example BoardConfig.mk Usage:
62
63 BOARD_SEPOLICY_M4DEFS += btmodule=foomatic \
64 btdevice=/dev/gps
65
66## SPECIFIC POLICY FILE INFORMATION
67
68### mac_permissions.xml
69The `mac_permissions.xml` file is used for controlling the mmac solutions
70as well as mapping a public base16 signing key with an arbitrary seinfo
71string. Details of the files contents can be found in a comment at the
72top of that file. The seinfo string, previously mentioned, is the same string
73that is referenced in seapp_contexts.
74
75It is important to note the final processed version of this file
76is stripped of comments and whitespace. This is to preserve space on the
77system.img. If one wishes to view it in a more human friendly format,
78the `tidy` or `xmllint` command will assist you.
79
80### insertkeys.py
81Is a helper script for mapping arbitrary tags in the signature stanzas of
82`mac_permissions.xml` to public keys found in pem files. This script takes
83a `mac_permissions.xml` file(s) and configuration file in order to operate.
84Details of the configuration file (`keys.conf`) can be found in the subsection
85keys.conf. This tool is also responsible for stripping the comments and
86whitespace during processing.
87
88### keys.conf
89The `keys.conf` file is used for controlling the mapping of "tags" found in
90the `mac_permissions.xml` signature stanzas with actual public keys found in
91pem files. The configuration file is processed via `m4`.
92
93The script allows for mapping any string contained in `TARGET_BUILD_VARIANT`
94with specific path to a pem file. Typically `TARGET_BUILD_VARIANT` is either
95user, eng or userdebug. Additionally, one can specify "ALL" to map a path to
96any string specified in `TARGET_BUILD_VARIANT`. All tags are matched verbatim
97and all options are matched lowercase. The options are **tolowered** automatically
98for the user, it is convention to specify tags and options in all uppercase
99and tags start with @. The option arguments can also use environment variables
100via the familiar `$VARIABLE` syntax. This is often useful for setting a location
101to ones release keys.
102
103Often times, one will need to integrate an application that was signed by a separate
104organization and may need to extract the pem file for the `insertkeys/keys.conf` tools.
105Extraction of the public key in the pem format is possible via `openssl`. First you need
106to unzip the apk, once it is unzipped, `cd` into the `META_INF` directory and then execute
107
108 openssl pkcs7 -inform DER -in CERT.RSA -out CERT.pem -outform PEM -print_certs
109
110On some occasions `CERT.RSA` has a different name, and you will need to adjust for that.
111After extracting the pem, you can rename it, and configure `keys.conf` and
112`mac_permissions.xml` to pick up the change. You **MUST** open the generated pem file in a text
113editor and strip out anything outside the opening and closing scissor lines. Failure to do
114so **WILL** cause a compile time issue thrown by insertkeys.py
115
116**NOTE:** The pem files are base64 encoded and `PackageManagerService`, `mac_permissions.xml`
117 and `setool` all use base16 encodings.
118