From a63bfb300dc7a2ecacf7be5afa7709b4a6a9c948 Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Thu, 28 Feb 2019 11:15:58 -0800 Subject: [PATCH] Update StorageManagerService.mkdirs to translate sandboxed paths. Fixes: 124407202 Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java Change-Id: I75e8b5ec47258e19b3ae1ea2e465966ed20ce152 --- .../com/android/server/StorageManagerService.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java index ada3947477de6..a0b47d5a4b7e3 100644 --- a/services/core/java/com/android/server/StorageManagerService.java +++ b/services/core/java/com/android/server/StorageManagerService.java @@ -2961,7 +2961,9 @@ class StorageManagerService extends IStorageManager.Stub @Override public void mkdirs(String callingPkg, String appPath) { - final int userId = UserHandle.getUserId(Binder.getCallingUid()); + final int callingPid = Binder.getCallingPid(); + final int callingUid = Binder.getCallingUid(); + final int userId = UserHandle.getUserId(callingUid); final UserEnvironment userEnv = new UserEnvironment(userId); final String propertyName = "sys.user." + userId + ".ce_available"; @@ -2979,7 +2981,7 @@ class StorageManagerService extends IStorageManager.Stub // Validate that reported package name belongs to caller final AppOpsManager appOps = (AppOpsManager) mContext.getSystemService( Context.APP_OPS_SERVICE); - appOps.checkPackage(Binder.getCallingUid(), callingPkg); + appOps.checkPackage(callingUid, callingPkg); File appFile = null; try { @@ -2998,11 +3000,13 @@ class StorageManagerService extends IStorageManager.Stub appPath = appPath + "/"; } + final String systemPath = translateAppToSystem(appPath, callingPid, callingUid); + try { - mVold.mkdirs(appPath); + mVold.mkdirs(systemPath); return; } catch (Exception e) { - throw new IllegalStateException("Failed to prepare " + appPath + ": " + e); + throw new IllegalStateException("Failed to prepare " + systemPath + ": " + e); } }