Split mac_permissions.xml into plat and non-plat components. am: b1cc4f8ca4
am: 2a7ce100b7
Change-Id: I9d0e0f824fdc26c64d41f97b370f7483b63b97c5
This commit is contained in:
@@ -59,8 +59,9 @@ public final class SELinuxMMAC {
|
|||||||
private static List<Policy> sPolicies = new ArrayList<>();
|
private static List<Policy> sPolicies = new ArrayList<>();
|
||||||
|
|
||||||
/** Path to MAC permissions on system image */
|
/** Path to MAC permissions on system image */
|
||||||
private static final File MAC_PERMISSIONS = new File(Environment.getRootDirectory(),
|
private static final File[] MAC_PERMISSIONS =
|
||||||
"/etc/security/mac_permissions.xml");
|
{ new File(Environment.getRootDirectory(), "/etc/security/plat_mac_permissions.xml"),
|
||||||
|
new File(Environment.getRootDirectory(), "/etc/security/nonplat_mac_permissions.xml") };
|
||||||
|
|
||||||
// Append privapp to existing seinfo label
|
// Append privapp to existing seinfo label
|
||||||
private static final String PRIVILEGED_APP_STR = ":privapp";
|
private static final String PRIVILEGED_APP_STR = ":privapp";
|
||||||
@@ -87,9 +88,10 @@ public final class SELinuxMMAC {
|
|||||||
|
|
||||||
FileReader policyFile = null;
|
FileReader policyFile = null;
|
||||||
XmlPullParser parser = Xml.newPullParser();
|
XmlPullParser parser = Xml.newPullParser();
|
||||||
|
for (int i = 0; i < MAC_PERMISSIONS.length; i++) {
|
||||||
try {
|
try {
|
||||||
policyFile = new FileReader(MAC_PERMISSIONS);
|
policyFile = new FileReader(MAC_PERMISSIONS[i]);
|
||||||
Slog.d(TAG, "Using policy file " + MAC_PERMISSIONS);
|
Slog.d(TAG, "Using policy file " + MAC_PERMISSIONS[i]);
|
||||||
|
|
||||||
parser.setInput(policyFile);
|
parser.setInput(policyFile);
|
||||||
parser.nextTag();
|
parser.nextTag();
|
||||||
@@ -113,23 +115,24 @@ public final class SELinuxMMAC {
|
|||||||
StringBuilder sb = new StringBuilder("Exception @");
|
StringBuilder sb = new StringBuilder("Exception @");
|
||||||
sb.append(parser.getPositionDescription());
|
sb.append(parser.getPositionDescription());
|
||||||
sb.append(" while parsing ");
|
sb.append(" while parsing ");
|
||||||
sb.append(MAC_PERMISSIONS);
|
sb.append(MAC_PERMISSIONS[i]);
|
||||||
sb.append(":");
|
sb.append(":");
|
||||||
sb.append(ex);
|
sb.append(ex);
|
||||||
Slog.w(TAG, sb.toString());
|
Slog.w(TAG, sb.toString());
|
||||||
return false;
|
return false;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Slog.w(TAG, "Exception parsing " + MAC_PERMISSIONS, ioe);
|
Slog.w(TAG, "Exception parsing " + MAC_PERMISSIONS[i], ioe);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
IoUtils.closeQuietly(policyFile);
|
IoUtils.closeQuietly(policyFile);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now sort the policy stanzas
|
// Now sort the policy stanzas
|
||||||
PolicyComparator policySort = new PolicyComparator();
|
PolicyComparator policySort = new PolicyComparator();
|
||||||
Collections.sort(policies, policySort);
|
Collections.sort(policies, policySort);
|
||||||
if (policySort.foundDuplicate()) {
|
if (policySort.foundDuplicate()) {
|
||||||
Slog.w(TAG, "ERROR! Duplicate entries found parsing " + MAC_PERMISSIONS);
|
Slog.w(TAG, "ERROR! Duplicate entries found parsing mac_permissions.xml files");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user