libselinux:  Only use /data/security policy if all files are present.

Otherwise if we have a matching selinux_version but only a subset of
the expected policy files (sepolicy, *_contexts) under /data/security,
then we'll fail when attempting to open the missing files.

This does not check that mac_permissions.xml is present as that is only
opened and used by SELinuxMMAC, not by libselinux, but we should likely
change SELinuxMMAC to do the same.

The alternative would be to change the logic for opening each policy
file to fall back to the / policy if the /data/security policy is missing,
as we used to do before the /data/security support was first disabled and
then reworked to check selinux_version.  Then it would be valid once again
to merely push a sepolicy file or any other individual file with a
selinux_version file to /data/security/current without needing to copy
the rest of the files if they were unchanged.  That is how we used to
support pushing a policy with dontaudit rules stripped,
http://seandroid.bitbucket.org/AddressingHiddenDenials.html

I have updated those instructions to specify that all files must be
copied but it is a bit more cumbersome to do so.

Change-Id: I60f7ac1f6fa714c0b827a1edd008da172ef1c991
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
1 file changed
tree: 7f2731251bfd7c8333a8b08849c77cf029850f3e
  1. include/
  2. src/
  3. Android.mk
  4. NOTICE