diff --git a/modules/sandbox/appspawn_sandbox.c b/modules/sandbox/appspawn_sandbox.c index 6195193d2b05d994b5c75b8b7cd1999898d51ce2..8803ef86b00bced00f255fc538aeed3290f4310a 100644 --- a/modules/sandbox/appspawn_sandbox.c +++ b/modules/sandbox/appspawn_sandbox.c @@ -525,7 +525,7 @@ static int DoSandboxNodeMount(const SandboxContext *context, const SandboxSectio return 0; } -static bool IsUnlockStatus(uint32_t uid) +static bool IsUnlockStatus(uint32_t uid, const char *bundleName) { const int userIdBase = UID_BASE; uid = uid / userIdBase; @@ -534,11 +534,11 @@ static bool IsUnlockStatus(uint32_t uid) } const char rootPath[] = "/data/app/el2/"; - const char basePath[] = "/base"; - size_t allPathSize = strlen(rootPath) + strlen(basePath) + 1 + USER_ID_SIZE; + const char basePath[] = "/base/"; + size_t allPathSize = strlen(rootPath) + strlen(basePath) + 1 + USER_ID_SIZE + strlen(bundleName); char *path = (char *)malloc(sizeof(char) * allPathSize); APPSPAWN_CHECK(path != NULL, return true, "Failed to malloc path"); - int len = sprintf_s(path, allPathSize, "%s%u%s", rootPath, uid, basePath); + int len = sprintf_s(path, allPathSize, "%s%u%s%s", rootPath, uid, basePath, bundleName); APPSPAWN_CHECK(len > 0 && ((size_t)len < allPathSize), free(path); return true, "Failed to get base path"); if (access(path, F_OK) == 0) { @@ -599,7 +599,7 @@ static void MountDirToShared(const SandboxContext *context, AppSpawnSandboxCfg * { const char rootPath[] = "/mnt/sandbox/"; AppSpawnMsgDacInfo *info = (AppSpawnMsgDacInfo *)GetSpawningMsgInfo(context, TLV_DAC_INFO); - if (info == NULL || IsUnlockStatus(info->uid)) { + if (info == NULL || context->bundleName == NULL || IsUnlockStatus(info->uid, context->bundleName)) { return; } diff --git a/modules/sandbox/sandbox_utils.cpp b/modules/sandbox/sandbox_utils.cpp index d8f1c35eaa5e9984d0c08d7237304d35632c79a0..b2344cbeea806ee7adfb800b238869155aa5795b 100644 --- a/modules/sandbox/sandbox_utils.cpp +++ b/modules/sandbox/sandbox_utils.cpp @@ -1776,7 +1776,7 @@ int32_t SetAppSandboxProperty(AppSpawnMgr *content, AppSpawningCtx *property) #define DIR_MODE 0711 #ifndef APPSPAWN_SANDBOX_NEW -static bool IsUnlockStatus(uint32_t uid) +static bool IsUnlockStatus(uint32_t uid, const char *bundleName) { const int userIdBase = 200000; uid = uid / userIdBase; @@ -1785,11 +1785,11 @@ static bool IsUnlockStatus(uint32_t uid) } const char rootPath[] = "/data/app/el2/"; - const char basePath[] = "/base"; - size_t allPathSize = strlen(rootPath) + strlen(basePath) + 1 + USER_ID_SIZE; + const char basePath[] = "/base/"; + size_t allPathSize = strlen(rootPath) + strlen(basePath) + 1 + USER_ID_SIZE + strlen(bundleName); char *path = reinterpret_cast(malloc(sizeof(char) * allPathSize)); APPSPAWN_CHECK(path != NULL, return true, "Failed to malloc path"); - int len = sprintf_s(path, allPathSize, "%s%u%s", rootPath, uid, basePath); + int len = sprintf_s(path, allPathSize, "%s%u%s%s", rootPath, uid, basePath, bundleName); APPSPAWN_CHECK(len > 0 && ((size_t)len < allPathSize), return true, "Failed to get base path"); if (access(path, F_OK) == 0) { @@ -1868,7 +1868,7 @@ static void MountDirToShared(const AppSpawningCtx *property) string sourcePath = "/data/app/el1/bundle/public/" + string(bundleName); MountDir(property, rootPath, sourcePath.c_str(), el1Path); - if (IsUnlockStatus(info->uid)) { + if (IsUnlockStatus(info->uid, bundleName)) { return; }