|
1 | 1 | # SELinux Reference Policy |
2 | 2 |
|
3 | | -## Make Targets |
4 | | - |
5 | | -### General Targets |
6 | | - |
7 | | -- **`install-src`**: Install policy sources into `/etc/selinux/NAME/src/policy`, where `NAME` is |
8 | | - defined in the Makefile. If unset, `TYPE` is used. The default `NAME` is `refpolicy`. A |
9 | | - pre-existing source policy is moved to `/etc/selinux/NAME/src/policy.bak`. |
10 | | -- **`conf`**: Regenerate `policy.xml` and update or create `modules.conf` and `booleans.conf`. Run |
11 | | - this after adding or removing modules, or after running `bare`. Existing configuration settings |
12 | | - are preserved. This must be run on policy sources checked out from the CVS repository before |
13 | | - they can be used. |
14 | | -- **`clean`**: Delete temporary files, compiled policies, and `file_contexts`. Configuration files |
15 | | - are left intact. |
16 | | -- **`bare`**: Run `clean` and also delete configuration files, web documentation, and `policy.xml`. |
17 | | -- **`html`**: Regenerate `policy.xml` and create web documentation in `doc/html`. |
18 | | - |
19 | | -### Modular Policy Targets |
20 | | - |
21 | | -- **`base`**: Compile and package the base module. This is the default modular policy target. |
22 | | -- **`modules`**: Compile and package all Reference Policy modules configured as loadable modules. |
23 | | -- **`MODULENAME.pp`**: Compile and package the `MODULENAME` Reference Policy module. |
24 | | -- **`all`**: Compile and package the base module and all modules configured as loadable modules. |
25 | | -- **`install`**: Compile, package, and install the base module and modules configured as loadable |
26 | | - modules. |
27 | | -- **`load`**: Compile, package, and install the base module and loadable modules, then insert them |
28 | | - into the module store. |
29 | | -- **`validate`**: Validate that the configured modules can successfully link and expand. |
30 | | -- **`install-headers`**: Install policy headers into `/usr/share/selinux/NAME`. The headers are |
31 | | - sufficient for building a policy module locally without the complete Reference Policy sources. |
32 | | - Set the `build.conf` options for this policy configuration before using this target. |
33 | | -- **`build-interface-db`**: Build the policy interface database with `sepolgen-ifgen`. This is |
34 | | - required for reference-style policy generation by `audit2allow --reference`. |
35 | | - |
36 | | -### Monolithic Policy Targets |
37 | | - |
38 | | -- **`policy`**: Compile a policy locally for development and testing. This is the default |
39 | | - monolithic policy target. |
40 | | -- **`install`**: Compile and install the policy and file contexts. |
41 | | -- **`load`**: Compile and install the policy and file contexts, then load the policy. |
42 | | -- **`enableaudit`**: Remove all `dontaudit` rules from `policy.conf`. |
43 | | -- **`relabel`**: Relabel the filesystem. |
44 | | -- **`checklabels`**: Check filesystem labels and report when a file would be relabeled without |
45 | | - changing its label. |
46 | | -- **`restorelabels`**: Relabel the filesystem and report each file that is relabeled. |
47 | | - |
48 | | -## Build Options |
49 | | - |
50 | | -The following options are set in `build.conf`. |
51 | | - |
52 | | -- **`TYPE`** (`String`): Available options are `standard`, `mls`, and `mcs`. For a |
53 | | - type-enforcement-only system, use `standard`. This optionally enables multi-level security |
54 | | - (MLS) or multi-category security (MCS) features and controls `enable_mls` and `enable_mcs` |
55 | | - policy blocks. |
56 | | -- **`NAME`** (`String`, optional): Set the policy name used when installing files under paths such |
57 | | - as `/etc/selinux/NAME` and `/usr/share/selinux/NAME`. If unset, the policy `TYPE` is used. |
58 | | -- **`DISTRO`** (`String`, optional): Enable distribution-specific policy. Available options are |
59 | | - `redhat`, `gentoo`, and `debian`. This controls the `distro_redhat`, `distro_gentoo`, and |
60 | | - `distro_debian` build-option policy blocks. |
61 | | -- **`MONOLITHIC`** (`Boolean`): Build a monolithic policy when set; otherwise, build a modular |
62 | | - policy. |
63 | | -- **`DIRECT_INITRC`** (`Boolean`): Allow `sysadm` to run init scripts directly instead of using |
64 | | - `run_init`. This is a build option rather than a tunable because role transitions do not work in |
65 | | - conditional policy. It controls `direct_sysadm_daemon` policy blocks. |
66 | | -- **`OUTPUT_POLICY`** (`Integer`): Set the policy version created by a monolithic build. This has |
67 | | - no effect on modular policy. |
68 | | -- **`OUTPUT_MODULE`** (`Integer`): Set the module policy version created by a modular build. This |
69 | | - has no effect on monolithic policy. |
70 | | -- **`UNK_PERMS`** (`String`): Set kernel behavior for permissions defined in the kernel but missing |
71 | | - from the policy. Permissions can be allowed (`allow`), denied (`deny`), or cause policy loading |
72 | | - to be rejected (`reject`). |
73 | | -- **`UBAC`** (`Boolean`): Also use the SELinux user for approximate role separation. |
74 | | -- **`SYSTEMD`** (`Boolean`): Assume systemd is the init process provider. |
75 | | -- **`MLS_SENS`** (`Integer`): Set the number of MLS sensitivities. Ignored for standard and MCS |
76 | | - policies. |
77 | | -- **`MLS_CATS`** (`Integer`): Set the number of MLS categories. Ignored for standard and MCS |
78 | | - policies. |
79 | | -- **`MCS_CATS`** (`Integer`): Set the number of MCS categories. Ignored for standard and MLS |
80 | | - policies. |
81 | | -- **`QUIET`** (`Boolean`): Display only status and error messages. This has no effect on policy. |
82 | | -- **`WERROR`** (`Boolean`): Treat warnings as errors. The build fails if warnings are encountered. |
83 | | - |
84 | | -## Files and Directories |
85 | | - |
86 | | -All paths are relative to the root of the Reference Policy source directory. |
87 | | - |
88 | | -- **`Makefile`**: General rules for building the policy. |
89 | | -- **`Rules.modular`**: Makefile rules for building loadable module policies. |
90 | | -- **`Rules.monolithic`**: Makefile rules for building monolithic policies. |
91 | | -- **`build.conf`**: Options that influence the policy build, such as policy type and distribution. |
92 | | -- **`config/appconfig-*`**: Application configuration files for all Reference Policy |
93 | | - configurations, including targeted or strict policy with or without MLS or MCS. SELinux-aware |
94 | | - programs use these files. |
95 | | -- **`config/local.users`**: File read when loading policy to add SELinux users to the policy. |
96 | | -- **`doc/html/*`**: In-policy XML documentation presented as web pages. |
97 | | -- **`doc/policy.dtd`**: DTD used to validate `doc/policy.xml`. |
98 | | -- **`doc/policy.xml`**: File generated or updated by `conf` and `html`. It contains the complete XML |
99 | | - documentation included in the policy. |
100 | | -- **`doc/templates/*`**: Templates used for documentation web pages. |
101 | | -- **`policy/booleans.conf`**: File generated or updated by `conf`. It contains policy booleans and |
102 | | - their default values. If tunables are implemented as booleans, tunables are also included. This |
103 | | - is installed as `/etc/selinux/NAME/booleans`. |
104 | | -- **`policy/constraints`**: Additional constraints on permissions, expressed as Boolean |
105 | | - expressions that must be satisfied for permissions to be granted. These constraints further |
106 | | - refine type-enforcement and role-allow rules and typically restrict user identity or role |
107 | | - changes to certain domains. |
108 | | -- **`policy/global_booleans`**: Global booleans, their default values, and documentation. |
109 | | -- **`policy/global_tunables`**: Global tunables, their default values, and documentation. |
110 | | -- **`policy/flask/initial_sids`**: Declarations for each initial SID. |
111 | | -- **`policy/flask/security_classes`**: Declarations for each security class. |
112 | | -- **`policy/flask/access_vectors`**: Access-vector definitions. Common prefixes may be defined at |
113 | | - the beginning of the file, followed by an access vector for each security class. |
114 | | -- **`policy/mcs`**: Multi-category security (MCS) configuration. |
115 | | -- **`policy/mls`**: Multi-level security (MLS) configuration. |
116 | | -- **`policy/modules/*`**: Layer directories containing all Reference Policy modules. |
117 | | -- **`policy/modules.conf`**: Available modules and how they are used when building Reference |
118 | | - Policy. Set a module to `off` to omit it. For monolithic policies, modules set to `base` or |
119 | | - `module` are included. For modular policies, modules set to `base` are included in the base |
120 | | - module and those set to `module` are compiled as individual loadable modules. |
121 | | -- **`policy/support/*`**: Support macros. |
122 | | -- **`policy/users`**: Users included in the policy. |
123 | | -- **`support/*`**: Tools used in the build process. |
124 | | - |
125 | | -## Building Modules Using Reference Policy Headers |
126 | | - |
127 | | -The system must first have the Reference Policy headers installed, typically by the distribution. |
128 | | -Otherwise, install the headers from the complete Reference Policy sources with the |
129 | | -`install-headers` target. |
130 | | - |
131 | | -To build a local module, place a `.te` file in a directory. Use `doc/Makefile.example` as the |
132 | | -Makefile. It may be installed under `/usr/share/doc` in the directory for the distribution's |
133 | | -policy. Alternatively, call the primary Makefile in the headers directory, typically |
134 | | -`/usr/share/selinux/NAME/Makefile`, directly with `make -f`. |
135 | | - |
136 | | -Larger projects can use layers like Reference Policy by creating `policy/modules/LAYERNAME` |
137 | | -directories. Each layer must have a `metadata.xml` file containing a `summary` tag and an optional |
138 | | -`desc` tag for a longer description. The metadata should describe the layer's purpose. |
139 | | - |
140 | | -Example `metadata.xml`: |
141 | | - |
142 | | -```xml |
143 | | -<summary>ABC modules for the XYZ components.</summary> |
144 | | -``` |
145 | | - |
146 | | -### Header-Based Module Targets |
147 | | - |
148 | | -- **`MODULENAME.pp`**: Compile and package the `MODULENAME` local module. |
149 | | -- **`all`**: Compile and package the modules in the current directory. |
150 | | -- **`load`**: Compile and package the modules in the current directory, then insert them into the |
151 | | - module store. |
152 | | -- **`refresh`**: Attempt to reinsert all modules currently in the module store from local and |
153 | | - system module packages. |
154 | | -- **`xml`**: Build a `policy.xml` from the XML included with the base policy headers and any XML in |
155 | | - the modules in the current directory. |
| 3 | +The SELinux Reference Policy project (refpolicy) is a complete SELinux |
| 4 | +policy that can be used as the system policy for a variety of systems |
| 5 | +and used as the basis for creating other policies. Reference Policy was |
| 6 | +originally based on the NSA example policy, but aims to accomplish many |
| 7 | +additional goals. |
| 8 | + |
| 9 | +The current release of Reference Policy is available from the |
| 10 | +[GitHub releases](https://github.com/SELinuxProject/refpolicy/releases) page. |
| 11 | + |
| 12 | +The project is always looking for policy developers interested in |
| 13 | +contributing. See the [getting started guide](doc/GETTING_STARTED.md) for |
| 14 | +more information on writing Reference Policy modules. |
| 15 | + |
| 16 | +For an in-depth discussion of Reference Policy concepts, see the |
| 17 | +[paper](http://selinuxsymposium.org/2006/papers/05-refpol.pdf) published |
| 18 | +at the 2006 SELinux Symposium. |
| 19 | + |
| 20 | +## Project Goals |
| 21 | + |
| 22 | +Security is the reason for existence for SELinux policies and must, |
| 23 | +therefore, always be the first priority. The common view of security as |
| 24 | +a binary state (secure or not secure) is not a sufficient goal for |
| 25 | +developing an SELinux policy. In reality, different systems have |
| 26 | +different requirements and purposes and corresponding differences in the |
| 27 | +meaning of secure. What is a fundamental security flaw on one system |
| 28 | +might be acceptable, or even the primary functionality, of another. The |
| 29 | +challenge for a system policy is to support as many of these differing |
| 30 | +security goals as is practical. To accomplish this Reference Policy will |
| 31 | +provide: |
| 32 | + |
| 33 | +- **Strong Modularity**: central to the design of the policy is strict |
| 34 | + modularity. Accesses to resources are abstracted, and implementation |
| 35 | + details are encapsulated in the module. |
| 36 | + |
| 37 | +- **Security Goals**: clearly stated security goals will be given for each |
| 38 | + component of the policy. This will allow policy developers to |
| 39 | + determine if a given component meets their security needs. |
| 40 | + |
| 41 | +- **Documentation**: the difficulty and complexity of creating SELinux |
| 42 | + policies has become the number one barrier to the adoption of |
| 43 | + SELinux. It also potentially reduces the security of the policies: a |
| 44 | + policy that is too complex to easily understand is difficult to make |
| 45 | + secure. See the `doc/` directory of the repository for more information. |
| 46 | + |
| 47 | +- **Development Tool Support**: In addition to documentation, |
| 48 | + Reference Policy aims to make improvements in this area, making |
| 49 | + policies easier to develop, understand, analyze, and verify by |
| 50 | + adding interface call backtraces which can be used for debugging and |
| 51 | + graphical development tools. |
| 52 | + |
| 53 | +- **Forward Looking**: Reference Policy aims to support a variety of |
| 54 | + policy configurations all from the same source tree. This is done |
| 55 | + through the addition of infrastructure for automatically handling |
| 56 | + the differences between monolithic and modular policies and the |
| 57 | + additional MLS fields to all policy statements that include contexts. |
| 58 | + |
| 59 | +- **Configurability**: configuration tools that allow the policy |
| 60 | + developer to make important security decisions including defining |
| 61 | + roles, configuring networking. |
| 62 | + |
| 63 | +- **Flexible Base Policy**: a base policy that protects the basic |
| 64 | + operating system and serves as a foundation to the rest of the |
| 65 | + policy. This base policy should be able to support a variety of |
| 66 | + application policies with differing security goals. |
| 67 | + |
| 68 | +- **Application Policy Variations**: application policy variations |
| 69 | + that make different security tradeoffs. For example, two Apache |
| 70 | + policies might be created, one that is for serving read-only static |
| 71 | + content that is severely restricted, and another that is appropriate |
| 72 | + for dynamic content. |
| 73 | + |
| 74 | +- **Multi-Level Security**: MLS is supported out-of-the-box without |
| 75 | + requiring destructive changes to the policy. It is possible to |
| 76 | + compile an MLS and non-MLS policy from the same policy files by |
| 77 | + switching a configuration option. |
| 78 | + |
| 79 | +## Contributing |
| 80 | + |
| 81 | +If you'd like to contribute, please see [how to contribute](doc/HOW_TO_CONTRIBUTE.md). |
0 commit comments