From de83613424d3fb99cf067af2bae2f2a397cd3361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A8=8A=E6=99=AF=E4=B9=90?= Date: Mon, 23 Sep 2024 16:05:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9appspawn=20=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E8=A7=A3=E9=94=81=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 樊景乐 --- modules/sandbox/appspawn_sandbox.c | 10 +++++----- modules/sandbox/sandbox_utils.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/sandbox/appspawn_sandbox.c b/modules/sandbox/appspawn_sandbox.c index 6195193d..8803ef86 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 d8f1c35e..b2344cbe 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; } -- Gitee