selinux: add support for installing a dummy policy (v2)
authorSerge E. Hallyn <serue@us.ibm.com>
Tue, 26 Aug 2008 19:47:57 +0000 (14:47 -0500)
committerJames Morris <jmorris@namei.org>
Tue, 26 Aug 2008 22:54:08 +0000 (08:54 +1000)
commit93c06cbbf9fea5d5be1778febb7fa9ab1a74e5f5
treede0ba51a2901097b7ab28483a040dc6ee5c9bc7d
parent3f23d815c5049c9d7022226cec2242e384dd0b43
selinux: add support for installing a dummy policy (v2)

In August 2006 I posted a patch generating a minimal SELinux policy.  This
week, David P. Quigley posted an updated version of that as a patch against
the kernel.  It also had nice logic for auto-installing the policy.

Following is David's original patch intro (preserved especially
bc it has stats on the generated policies):

se interested in the changes there were only two significant
changes. The first is that the iteration through the list of classes
used NULL as a sentinel value. The problem with this is that the
class_to_string array actually has NULL entries in its table as place
holders for the user space object classes.

The second change was that it would seem at some point the initial sids
table was NULL terminated. This is no longer the case so that iteration
has to be done on array length instead of looking for NULL.

Some statistics on the policy that it generates:

The policy consists of 523 lines which contain no blank lines. Of those
523 lines 453 of them are class, permission, and initial sid
definitions. These lines are usually little to no concern to the policy
developer since they will not be adding object classes or permissions.
Of the remaining 70 lines there is one type, one role, and one user
statement. The remaining lines are broken into three portions. The first
group are TE allow rules which make up 29 of the remaining lines, the
second is assignment of labels to the initial sids which consist of 27
lines, and file system labeling statements which are the remaining 11.

In addition to the policy.conf generated there is a single file_contexts
file containing two lines which labels the entire system with base_t.

This policy generates a policy.23 binary that is 7920 bytes.

(then a few versions later...):

The new policy is 587 lines (stripped of blank lines) with 476 of those
lines being the boilerplate that I mentioned last time. The remaining
111 lines have the 3 lines for type, user, and role, 70 lines for the
allow rules (one for each object class including user space object
classes), 27 lines to assign types to the initial sids, and 11 lines for
file system labeling. The policy binary is 9194 bytes.

Changelog:

Aug 26: Added Documentation/SELinux.txt
Aug 26: Incorporated a set of comments by Stephen Smalley:
1. auto-setup SELINUXTYPE=dummy
2. don't auto-install if selinux is enabled with
non-dummy policy
3. don't re-compute policy version
4. /sbin/setfiles not /usr/sbin/setfiles
Aug 22: As per JMorris comments, made sure make distclean
cleans up the mdp directory.
Removed a check for file_contexts which is now
created in the same file as the check, making it
superfluous.

Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: David Quigley <dpquigl@tycho.nsa.gov>
Signed-off-by: James Morris <jmorris@namei.org>
Documentation/SELinux.txt [new file with mode: 0644]
scripts/Makefile
scripts/selinux/Makefile [new file with mode: 0644]
scripts/selinux/README [new file with mode: 0644]
scripts/selinux/install_policy.sh [new file with mode: 0644]
scripts/selinux/mdp/Makefile [new file with mode: 0644]
scripts/selinux/mdp/dbus_contexts [new file with mode: 0644]
scripts/selinux/mdp/mdp.c [new file with mode: 0644]