summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-09-29 17:17:22 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-09-29 17:17:22 -0700
commitea7ee3f4d31b92828df005d021cf482f6332514a (patch)
treeed11714fecc0d80a440b9c20077da91bc01a3a8a /services
parent3ebb1ba50c9b98e5303eb21ed6fa488c3f9bd632 (diff)
parent8bd545ab4f7e75634c970b50ed15c20858d6ac0c (diff)
downloadframeworks_base-ea7ee3f4d31b92828df005d021cf482f6332514a.zip
frameworks_base-ea7ee3f4d31b92828df005d021cf482f6332514a.tar.gz
frameworks_base-ea7ee3f4d31b92828df005d021cf482f6332514a.tar.bz2
am 8bd545ab: am 212d81a0: Merge "Move all the permissions check up for unmount" into gingerbread
Merge commit '8bd545ab4f7e75634c970b50ed15c20858d6ac0c' * commit '8bd545ab4f7e75634c970b50ed15c20858d6ac0c': Move all the permissions check up for unmount
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/MountService.java35
1 files changed, 22 insertions, 13 deletions
diff --git a/services/java/com/android/server/MountService.java b/services/java/com/android/server/MountService.java
index e6c6953..ca8fc52 100644
--- a/services/java/com/android/server/MountService.java
+++ b/services/java/com/android/server/MountService.java
@@ -1464,11 +1464,6 @@ class MountService extends IMountService.Stub
mHandler.sendEmptyMessage(H_UNMOUNT_PM_DONE);
}
- private boolean isCallerOwnerOfPackageOrSystem(String packageName) {
- final int callerUid = Binder.getCallingUid();
- return isUidOwnerOfPackageOrSystem(packageName, callerUid);
- }
-
private boolean isUidOwnerOfPackageOrSystem(String packageName, int callerUid) {
if (callerUid == android.os.Process.SYSTEM_UID) {
return true;
@@ -1520,6 +1515,12 @@ class MountService extends IMountService.Stub
waitForReady();
warnOnNotMounted();
+ if (filename == null) {
+ throw new IllegalArgumentException("filename cannot be null");
+ } else if (token == null) {
+ throw new IllegalArgumentException("token cannot be null");
+ }
+
final ObbState obbState;
synchronized (mObbMounts) {
@@ -1546,6 +1547,12 @@ class MountService extends IMountService.Stub
}
public void unmountObb(String filename, boolean force, IObbActionListener token) {
+ if (filename == null) {
+ throw new IllegalArgumentException("filename cannot be null");
+ } else if (token == null) {
+ throw new IllegalArgumentException("token cannot be null");
+ }
+
final ObbState obbState;
synchronized (mObbMounts) {
@@ -1553,6 +1560,12 @@ class MountService extends IMountService.Stub
throw new IllegalArgumentException("OBB is not mounted");
}
obbState = mObbPathToStateMap.get(filename);
+
+ if (Binder.getCallingUid() != obbState.callerUid) {
+ throw new SecurityException("caller UID does not match original mount caller UID");
+ } else if (!token.asBinder().equals(obbState.token.asBinder())) {
+ throw new SecurityException("caller does not match original mount caller");
+ }
}
UnmountObbAction action = new UnmountObbAction(obbState, force);
@@ -1771,9 +1784,9 @@ class MountService extends IMountService.Stub
}
public void handleExecute() throws RemoteException, IOException {
- ObbInfo obbInfo = mContainerService.getObbInfo(mObbState.filename);
+ final ObbInfo obbInfo = mContainerService.getObbInfo(mObbState.filename);
if (obbInfo == null) {
- throw new IOException("Couldn't read OBB file");
+ throw new IOException("Couldn't read OBB file: " + mObbState.filename);
}
if (!isUidOwnerOfPackageOrSystem(obbInfo.packageName, mObbState.callerUid)) {
@@ -1846,13 +1859,9 @@ class MountService extends IMountService.Stub
}
public void handleExecute() throws RemoteException, IOException {
- ObbInfo obbInfo = mContainerService.getObbInfo(mObbState.filename);
+ final ObbInfo obbInfo = mContainerService.getObbInfo(mObbState.filename);
if (obbInfo == null) {
- throw new IOException("Couldn't read OBB file");
- }
-
- if (!isCallerOwnerOfPackageOrSystem(obbInfo.packageName)) {
- throw new IllegalArgumentException("Caller package does not match OBB file");
+ throw new IOException("Couldn't read OBB file: " + mObbState.filename);
}
int rc = StorageResultCode.OperationSucceeded;