Chris PeBenito fedd3ca
1) Reference Policy make targets:
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
General Make targets:
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
install-src		Install the policy sources into
Chris PeBenito fedd3ca
			/etc/selinux/NAME/src/policy, where NAME is defined in
Chris PeBenito fedd3ca
			the Makefile.  If not defined, the TYPE, as defined in
Chris PeBenito fedd3ca
			the Makefile, is used.  The default NAME is refpolicy.
Chris PeBenito fedd3ca
			A pre-existing source policy will be moved to
Chris PeBenito fedd3ca
			/etc/selinux/NAME/src/policy.bak.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
conf			Regenerate policy.xml, and update/create modules.conf
Chris PeBenito fedd3ca
			and booleans.conf.  This should be done after adding
Chris PeBenito fedd3ca
			or removing modules, or after running the bare target.
Chris PeBenito fedd3ca
			If the configuration files exist, their settings will
Chris PeBenito fedd3ca
			be preserved.  This must be ran on policy sources that
Chris PeBenito fedd3ca
			are checked out from the CVS repository before they can
Chris PeBenito fedd3ca
			be used.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
clean			Delete all temporary files, compiled policies,
Chris PeBenito fedd3ca
			and file_contexts.  Configuration files are left intact.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
bare			Do the clean make target and also delete configuration
Chris PeBenito fedd3ca
			files, web page documentation, and policy.xml.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
html			Regenerate policy.xml and create web page documentation
Chris PeBenito fedd3ca
			in the doc/html directory.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
Make targets specific to modular (loadable modules) policies:
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
base			Compile and package the base module.  This is the
Chris PeBenito fedd3ca
			default target for modular policies.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
modules			Compile and package all Reference Policy modules
Chris PeBenito fedd3ca
			configured to be built as loadable modules.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
MODULENAME.pp		Compile and package the MODULENAME Reference Policy
Chris PeBenito fedd3ca
			module.
Chris PeBenito fedd3ca
Chris PeBenito c767b14
all			Compile and package the base module and all Reference
Chris PeBenito c767b14
			Policy modules configured to be built as loadable
Chris PeBenito c767b14
			modules.
Chris PeBenito c767b14
Chris PeBenito c767b14
install			Compile, package, and install the base module and
Chris PeBenito c767b14
			Reference Policy modules configured to be built as
Chris PeBenito c767b14
			loadable modules.
Chris PeBenito c767b14
Chris PeBenito c767b14
load			Compile, package, and install the base module and
Chris PeBenito c767b14
			Reference Policy modules configured to be built as
Chris PeBenito c767b14
			loadable modules, then insert them into the module
Chris PeBenito c767b14
			store.
Chris PeBenito c767b14
Chris PeBenito ea5333d
validate		Validate if the configured modules can successfully
Chris PeBenito ea5333d
			link and expand.
Chris PeBenito ea5333d
Chris PeBenito f65ca5f
install-headers		Install the policy headers into /usr/share/selinux/NAME.
Chris PeBenito f65ca5f
			The headers are sufficient for building a policy
Chris PeBenito f65ca5f
			module locally, without requiring the complete
Chris PeBenito f65ca5f
			Reference Policy sources.  The build.conf settings
Chris PeBenito f65ca5f
			for this policy configuration should be set before
Chris PeBenito f65ca5f
			using this target.
Chris PeBenito f65ca5f
Chris PeBenito fedd3ca
Make targets specific to monolithic policies:
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
policy			Compile a policy locally for development and testing.
Chris PeBenito fedd3ca
			This is the default target for monolithic policies.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
install			Compile and install the policy and file contexts.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
load			Compile and install the policy and file contexts, then
Chris PeBenito fedd3ca
			load the policy.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
enableaudit		Remove all dontaudit rules from policy.conf.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
relabel			Relabel the filesystem.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
checklabels		Check the labels on the filesystem, and report when
Chris PeBenito fedd3ca
			a file would be relabeled, but do not change its label.
Chris PeBenito fedd3ca
Chris PeBenito fedd3ca
restorelabels		Relabel the filesystem and report each file that is
Chris PeBenito fedd3ca
			relabeled.
Chris PeBenito 97749e2
Chris PeBenito 75c1c26
Chris PeBenito 75c1c26
2) Reference Policy Build Options (build.conf)
Chris PeBenito 75c1c26
Chris PeBenito 350b6ab
TYPE			String.  Available options are standard, mls, and mcs.
Chris PeBenito 766617f
			For a type enforcement only system, set standard.
Chris PeBenito 350b6ab
			This optionally enables multi-level security (MLS) or
Chris PeBenito 75c1c26
			multi-category security (MCS) features.  This option
Chris PeBenito 350b6ab
			controls enable_mls, and enable_mcs policy blocks.
Chris PeBenito 75c1c26
Chris PeBenito 75c1c26
NAME			String (optional).  Sets the name of the policy; the
Chris PeBenito 75c1c26
			NAME is used when installing files to e.g.,
Chris PeBenito 75c1c26
			/etc/selinux/NAME and /usr/share/selinux/NAME.  If not
Chris PeBenito 75c1c26
			set, the policy type (TYPE) is used.
Chris PeBenito 75c1c26
Chris PeBenito 75c1c26
DISTRO			String (optional).  Enable distribution-specific policy.
Chris PeBenito 75c1c26
			Available options are redhat, rhel4, gentoo, debian,
Chris PeBenito 75c1c26
			and suse.  This option controls distro_redhat,
Chris PeBenito 75c1c26
			distro_rhel4, distro_gentoo, distro_debian, and
Chris PeBenito 75c1c26
			distro_suse policy blocks.
Chris PeBenito 75c1c26
Chris PeBenito 75c1c26
MONOLITHIC		Boolean.  If set, a monolithic policy is built,
Chris PeBenito 75c1c26
			otherwise a modular policy is built.
Chris PeBenito 75c1c26
Chris PeBenito 75c1c26
DIRECT_INITRC		Boolean.  If set, sysadm will be allowed to directly
Chris PeBenito 75c1c26
			run init scripts, instead of requiring the run_init
Chris PeBenito 75c1c26
			tool.  This is a build option instead of a tunable since
Chris PeBenito 75c1c26
			role transitions do not work in conditional policy.
Chris PeBenito 75c1c26
			This option controls direct_sysadm_daemon policy
Chris PeBenito 75c1c26
			blocks.
Chris PeBenito 75c1c26
Chris PeBenito 75c1c26
OUTPUT_POLICY		Integer.  Set the version of the policy created when
Chris PeBenito 75c1c26
			building a monolithic policy.  This option has no effect
Chris PeBenito 75c1c26
			on modular policy.
Chris PeBenito 75c1c26
Chris PeBenito 766617f
UNK_PERMS		String.  Set the kernel behavior for handling of
Chris PeBenito 766617f
			permissions defined in the kernel but missing from the
Chris PeBenito 766617f
			policy.  The permissions can either be allowed, denied,
Chris PeBenito 766617f
			or the policy loading can be rejected.
Chris PeBenito 766617f
Chris PeBenito 296273a
UBAC			Boolean.  If set, the SELinux user will be used
Chris PeBenito 296273a
			additionally for approximate role separation.
Chris PeBenito 296273a
Chris PeBenito 766617f
MLS_SENS		Integer.  Set the number of sensitivities in the MLS
Chris PeBenito 766617f
			policy.  Ignored on standard and MCS policies.
Chris PeBenito 766617f
Chris PeBenito 766617f
MLS_CATS		Integer.  Set the number of categories in the MLS
Chris PeBenito 766617f
			policy.  Ignored on standard and MCS policies.
Chris PeBenito 766617f
Chris PeBenito 766617f
MCS_CATS		Integer.  Set the number of categories in the MCS
Chris PeBenito 766617f
			policy.  Ignored on standard and MLS policies.
Chris PeBenito 766617f
Chris PeBenito 75c1c26
QUIET			Boolean.  If set, the build system will only display
Chris PeBenito 75c1c26
			status messages and error messages.  This option has no
Chris PeBenito 75c1c26
			effect on policy.
Chris PeBenito 75c1c26
Chris PeBenito 75c1c26
Chris PeBenito 75c1c26
3) Reference Policy Files and Directories
Chris PeBenito 97749e2
All directories relative to the root of the Reference Policy sources directory.
Chris PeBenito 97749e2
Chris PeBenito 8e0ef1f
Makefile		General rules for building the policy.
Chris PeBenito 8e0ef1f
Chris PeBenito 35bb02a
Rules.modular		Makefile rules specific to building loadable module
Chris PeBenito 35bb02a
			policies.
Chris PeBenito 8e0ef1f
Chris PeBenito 35bb02a
Rules.monolithic	Makefile rules specific to building monolithic policies.
Chris PeBenito 8e0ef1f
Chris PeBenito 8e0ef1f
build.conf		Options which influence the building of the policy,
Chris PeBenito 350b6ab
			such as the policy type and distribution.
Chris PeBenito 8e0ef1f
Chris PeBenito 97749e2
config/appconfig-*	Application configuration files for all configurations
Chris PeBenito 97749e2
			of the Reference Policy (targeted/strict with or without
Chris PeBenito 97749e2
			MLS or MCS).  These are used by SELinux-aware programs.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
config/local.users	The file read by load policy for adding SELinux users
Chris PeBenito 97749e2
			to the policy on the fly.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
doc/html/*		This contains the contents of the in-policy XML
Chris PeBenito 97749e2
			documentation, presented in web page form.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
doc/policy.dtd		The doc/policy.xml file is validated against this DTD.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
doc/policy.xml		This file is generated/updated by the conf and html make
Chris PeBenito 97749e2
			targets.  It contains the complete XML documentation
Chris PeBenito 97749e2
			included in the policy.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
doc/templates/*		Templates used for documentation web pages.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
policy/booleans.conf	This file is generated/updated by the conf make target.
Chris PeBenito 97749e2
			It contains the booleans in the policy, and their
Chris PeBenito 97749e2
			default values.  If tunables are implemented as
Chris PeBenito 97749e2
			booleans, tunables will also be included.  This file
Chris PeBenito 97749e2
			will be installed as the /etc/selinux/NAME/booleans
Chris PeBenito 97749e2
			file.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
policy/constraints	This file defines additional constraints on permissions
Chris PeBenito 97749e2
			in the form of boolean expressions that must be
Chris PeBenito 97749e2
			satisfied in order for specified permissions to be
Chris PeBenito 97749e2
			granted.  These constraints are used to further refine
Chris PeBenito 97749e2
			the type enforcement rules and the role allow rules.
Chris PeBenito 97749e2
			Typically, these constraints are used to restrict
Chris PeBenito 97749e2
			changes in user identity or role to certain domains.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
policy/global_booleans	This file defines all booleans that have a global scope,
Chris PeBenito 97749e2
			their default value, and documentation.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
policy/global_tunables	This file defines all tunables that have a global scope,
Chris PeBenito 97749e2
			their default value, and documentation.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
policy/flask/initial_sids  This file has declarations for each initial SID.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
policy/flask/security_classes  This file has declarations for each security class.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
policy/flask/access_vectors  This file defines the access vectors.  Common
Chris PeBenito 97749e2
			prefixes for access vectors may be defined at the
Chris PeBenito 97749e2
			beginning of the file.  After the common prefixes are
Chris PeBenito 97749e2
			defined, an access vector may be defined for each
Chris PeBenito 97749e2
			security class.
Chris PeBenito 97749e2
Chris PeBenito 35bb02a
policy/mcs		The multi-category security (MCS) configuration.
Chris PeBenito 35bb02a
Chris PeBenito 35bb02a
policy/mls		The multi-level security (MLS) configuration.
Chris PeBenito 35bb02a
Chris PeBenito 97749e2
policy/modules/*	Each directory represents a layer in Reference Policy
Chris PeBenito 97749e2
			all of the modules are contained in one of these layers.
Chris PeBenito 97749e2
Chris PeBenito 97749e2
policy/modules.conf	This file contains a listing of available modules, and
Chris PeBenito 97749e2
			how they will be used when building Reference Policy. To
Chris PeBenito 97749e2
			prevent a module from  being used, set the module to
Chris PeBenito 97749e2
			"off".  For monolithic policies, modules set to "base"
Chris PeBenito 97749e2
			and "module" will be included in the policy.  For
Chris PeBenito 97749e2
			modular policies, modules set to "base"	will be included
Chris PeBenito 97749e2
			in the base module; those set to "module" will be
Chris PeBenito 97749e2
			compiled as individual loadable	modules.
Chris PeBenito 97749e2
Chris PeBenito 6259d8e
policy/rolemap		This file contains prefix and user domain type that
Chris PeBenito 6259d8e
			corresponds to each user role.  The contents of this
Chris PeBenito 6259d8e
			file will be used to expand the per-user domain
Chris PeBenito 6259d8e
			templates for each module.
Chris PeBenito 6259d8e
Chris PeBenito 97749e2
policy/support/*	Support macros.
Chris PeBenito 97749e2
Chris PeBenito 35bb02a
policy/users		This file defines the users included in the policy.
Chris PeBenito 35bb02a
Chris PeBenito 75c1c26
support/*		Tools used in the build process.
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
4) Building policy modules using Reference Policy headers:
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
The system must first have the Reference Policy headers installed, typically
Chris PeBenito f65ca5f
by the distribution.  Otherwise, the headers can be installed using the
Chris PeBenito f65ca5f
install-headers target from the full Reference Policy sources.
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
To set up a directory to build a local module, one must simply place a .te
Chris PeBenito f65ca5f
file in a directory.  A sample Makefile to use in the directory is the
Chris PeBenito f65ca5f
Makefile.example in the doc directory.  This may be installed in
Chris PeBenito f65ca5f
/usr/share/doc, under the directory for the distribution's policy. 
Chris PeBenito f65ca5f
Alternatively, the primary Makefile in the headers directory (typically
Chris PeBenito f65ca5f
/usr/share/selinux/NAME/Makefile) can be called directly, using make's -f
Chris PeBenito f65ca5f
option.
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
Larger projects can set up a structure of layers, just as in Reference
Chris PeBenito f65ca5f
Policy, by creating policy/modules/LAYERNAME directories.  Each layer also
Chris PeBenito f65ca5f
must have a metadata.xml file which is an XML file with a summary tag and
Chris PeBenito f65ca5f
optional desc (long description) tag.  This should describe the purpose of
Chris PeBenito f65ca5f
the layer.
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
Metadata.xml example:
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
<summary>ABC modules for the XYZ components.</summary>
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
Make targets for modules built from headers:
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
MODULENAME.pp		Compile and package the MODULENAME local module.
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
all			Compile and package the modules in the current
Chris PeBenito f65ca5f
			directory.
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
load			Compile and package the modules in the current
Chris PeBenito f65ca5f
			directory, then insert them into the module store.
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
refresh			Attempts to reinsert all modules that are currently
Chris PeBenito f65ca5f
			in the module store from the local and system module
Chris PeBenito f65ca5f
			packages.
Chris PeBenito f65ca5f
Chris PeBenito f65ca5f
xml			Build a policy.xml from the XML included with the
Chris PeBenito f65ca5f
			base policy headers and any XML in the modules in
Chris PeBenito f65ca5f
			the current directory.