OSDN Git Service

Do not allow non-primary user to install certs
authorKenny Root <kroot@google.com>
Sun, 16 Sep 2012 21:01:43 +0000 (14:01 -0700)
committerKenny Root <kroot@google.com>
Sun, 16 Sep 2012 21:04:56 +0000 (14:04 -0700)
Change-Id: Iefc2970ae23d8ce7d30717add211c01cde251c8d

src/com/android/settings/CredentialStorage.java

index 07b1776..c737c7d 100644 (file)
@@ -25,6 +25,7 @@ import android.content.res.Resources;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.RemoteException;
+import android.os.UserHandle;
 import android.security.Credentials;
 import android.security.KeyChain.KeyChainConnection;
 import android.security.KeyChain;
@@ -104,17 +105,24 @@ public final class CredentialStorage extends Activity {
      */
     private int mRetriesRemaining = -1;
 
-    @Override protected void onResume() {
+    @Override
+    protected void onResume() {
         super.onResume();
 
+        if (UserHandle.myUserId() != UserHandle.USER_OWNER) {
+            Log.i(TAG, "Cannot install to CredentialStorage as non-primary user");
+            finish();
+            return;
+        }
+
         Intent intent = getIntent();
         String action = intent.getAction();
 
         if (ACTION_RESET.equals(action)) {
             new ResetDialog();
         } else {
-            if (ACTION_INSTALL.equals(action) &&
-                    "com.android.certinstaller".equals(getCallingPackage())) {
+            if (ACTION_INSTALL.equals(action)
+                    && "com.android.certinstaller".equals(getCallingPackage())) {
                 mInstallBundle = intent.getExtras();
             }
             // ACTION_UNLOCK also handled here in addition to ACTION_INSTALL