diff options
author | Robert Craig <rpcraig@tycho.ncsc.mil> | 2014-09-02 07:16:52 -0400 |
---|---|---|
committer | Robert Craig <rpcraig@tycho.ncsc.mil> | 2014-09-02 12:50:29 -0400 |
commit | 99891156fc33bda869bb0df1d20e50e01411bab0 (patch) | |
tree | f9e56d13ad94c8fbffd220ee7244bbbb1c640737 | |
parent | 25d928f687408058f007051878574ea66691d9dc (diff) | |
download | base-99891156fc33bda869bb0df1d20e50e01411bab0.tar.gz |
Add testing api to SELinuxMMAC code.
Added needed api for local unit testing.
Change-Id: If52555ecb4f0e6bc06e153b6a17e2c706b11253e
Signed-off-by: rpcraig <rpcraig@tycho.ncsc.mil>
-rw-r--r-- | services/java/com/android/server/pm/SELinuxMMAC.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/services/java/com/android/server/pm/SELinuxMMAC.java b/services/java/com/android/server/pm/SELinuxMMAC.java index 81302b9e2169..98f299721c5d 100644 --- a/services/java/com/android/server/pm/SELinuxMMAC.java +++ b/services/java/com/android/server/pm/SELinuxMMAC.java @@ -137,6 +137,14 @@ public final class SELinuxMMAC { } public static boolean readInstallPolicy() { + return readInstallPolicy(MAC_PERMISSIONS); + } + + public static boolean readInstallPolicy(String macPermsPath) { + if (macPermsPath == null) { + throw new NullPointerException("mac_permissions.xml file path is null"); + } + // Temp structures to hold the rules while we parse the xml file. // We add all the rules together once we know there's no structural problems. HashMap<Signature, Policy> sigSeinfo = new HashMap<Signature, Policy>(); @@ -144,8 +152,8 @@ public final class SELinuxMMAC { FileReader policyFile = null; try { - policyFile = new FileReader(MAC_PERMISSIONS); - Slog.d(TAG, "Using policy file " + MAC_PERMISSIONS); + policyFile = new FileReader(macPermsPath); + Slog.d(TAG, "Using policy file " + macPermsPath); XmlPullParser parser = Xml.newPullParser(); parser.setInput(policyFile); @@ -190,10 +198,10 @@ public final class SELinuxMMAC { } } } catch (XmlPullParserException xpe) { - Slog.w(TAG, "Got exception parsing " + MAC_PERMISSIONS, xpe); + Slog.w(TAG, "Got exception parsing " + macPermsPath, xpe); return false; } catch (IOException ioe) { - Slog.w(TAG, "Got exception parsing " + MAC_PERMISSIONS, ioe); + Slog.w(TAG, "Got exception parsing " + macPermsPath, ioe); return false; } finally { IoUtils.closeQuietly(policyFile); |