1. seandroid
  2. Untitled project
  3. frameworks/base

Commits

Robert Craig  committed f3ba51a

Pretty print MMAC debug statements.

signer tags and permission sets are just dumped to logcat
in one big blob. Rewrite code to pretty print these
instances.

  • Participants
  • Parent commits 62f8499
  • Branches seandroid

Comments (0)

Files changed (1)

File core/java/android/content/pm/SELinuxMMAC.java

View file
                     }
                     InstallPolicy type = determineInstallPolicyType(parser, true);
                     if (type != null) {
-                        if (DEBUG_POLICY_INSTALL)
-                            Slog.i(TAG, "<signer> tag: (" + cert + ") assigned "
-                                   + type);
+                        if (DEBUG_POLICY_INSTALL) {
+                            // Pretty print the cert
+                            int rowLength = 75;
+                            int certLength = cert.length();
+                            int rows = certLength / rowLength;
+                            Slog.i(TAG, "<signer> tag:");
+                            for (int j = 0; j <= rows; j++) {
+                                int start = rowLength * j;
+                                int rowEndIndex = (rowLength * j) + rowLength;
+                                int end = rowEndIndex < certLength ? rowEndIndex : certLength;
+                                Slog.i(TAG,  cert.substring(start, end));
+                            }
+                            Slog.i(TAG,  "    Assigned: " + type);
+                        }
 
                         SIG_POLICY.put(signature, type);
                     }
             StringBuilder out = new StringBuilder();
             out.append("[");
             if (policyPerms != null) {
-                out.append(TextUtils.join(",", new TreeSet<String>(policyPerms)));
+                out.append(TextUtils.join(",\n", new TreeSet<String>(policyPerms)));
             } else {
                 out.append("allow-all");
             }
                 return pkgPolicy.get(pkg.packageName).passedPolicyChecks(pkg);
             }
 
-            if (!policyPerms.containsAll(pkg.requestedPermissions)) {
-                Slog.w(TAG, MMAC_DENY + " Policy whitelist rejected package "
-                       + pkg.packageName + ". The maximal set is: " + toString());
-                return false;
+            Iterator itr = pkg.requestedPermissions.iterator();
+            while (itr.hasNext()) {
+                String perm = (String)itr.next();
+                if (!policyPerms.contains(perm)) {
+                    Slog.w(TAG, MMAC_DENY + " Policy whitelist rejected package "
+                           + pkg.packageName + ". The rejected permission is " + perm +
+                           " The maximal set allowed is: " + toString());
+                    return false;
+                }
             }
             return true;
         }
 
         @Override
         public String toString() {
-            return "allowed-permissions => " + super.toString();
+            return "allowed-permissions => \n" + super.toString();
         }
     }
 
 
         @Override
         public String toString() {
-            return "denied-permissions => " + super.toString();
+            return "denied-permissions => \n" + super.toString();
         }
     }