From 516db4b3455ff9e198e85859785bcb2853dbd808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=BE=BE?= Date: Tue, 20 Aug 2024 12:41:57 +0800 Subject: [PATCH] =?UTF-8?q?codecheck=E4=BF=AE=E5=A4=8D+=E6=8C=82=E8=BD=BD?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王达 --- appdata-sandbox-isolated.json | 11 +++++++++-- modules/sandbox/sandbox_utils.cpp | 5 +---- standard/appspawn_service.c | 12 ++++++------ test/moduletest/appspawn_test_cmder.cpp | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/appdata-sandbox-isolated.json b/appdata-sandbox-isolated.json index 5558cec1..19a8b963 100644 --- a/appdata-sandbox-isolated.json +++ b/appdata-sandbox-isolated.json @@ -3,6 +3,7 @@ "top-sandbox-switch": "ON", "app-base": [{ "sandbox-ns-flags" : [ "net" ], + "sandbox-root" : "/mnt/sandbox/", "mount-paths" : [{ "src-path" : "/dev", "sandbox-path" : "/dev", @@ -94,8 +95,8 @@ "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }, { - "src-path" : "/data/app/el1/bundle/public/", - "sandbox-path" : "/data/app/el1/bundle/public/", + "src-path" : "/data/app/el1/bundle/public/", + "sandbox-path" : "/data/storage/el1/bundle", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" }], @@ -117,6 +118,12 @@ "check-action-status": "false" }] + }], + "app-resources" : [{ + "sandbox-root" : "/mnt/sandbox/", + "mount-paths" : [], + "flag-point" : [], + "symbol-links" : [] }] }] } diff --git a/modules/sandbox/sandbox_utils.cpp b/modules/sandbox/sandbox_utils.cpp index 92ae064e..9a9573de 100644 --- a/modules/sandbox/sandbox_utils.cpp +++ b/modules/sandbox/sandbox_utils.cpp @@ -488,11 +488,8 @@ string SandboxUtils::ConvertToRealPath(const AppSpawningCtx *appProperty, std::s path = replace_all(path, g_packageNameIndex, bundleNameWithIndex); } - const std::string bundleName = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ? "isolated/" - : "" + std::string(info->bundleName); - if (path.find(g_packageName) != std::string::npos) { - path = replace_all(path, g_packageName, bundleName.c_str()); + path = replace_all(path, g_packageName, info->bundleName); } if (path.find(g_userId) != std::string::npos) { diff --git a/standard/appspawn_service.c b/standard/appspawn_service.c index 61ff35b4..1383a2de 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -991,10 +991,10 @@ APPSPAWN_STATIC void AppSpawnArgSet(RunMode mode, AppSpawnStartArg *arg) return; } -APPSPAWN_STATIC void AppSpawnStartServiceEnd(pid_t nwebSpawnPid, pid_t NativeSpawnPid) +APPSPAWN_STATIC void AppSpawnStartServiceEnd(pid_t nwebSpawnPid, pid_t nativeSpawnPid) { AddSpawnedProcess(nwebSpawnPid, NWEBSPAWN_SERVER_NAME); - AddSpawnedProcess(NativeSpawnPid, NATIVESPAWN_SERVER_NAME); + AddSpawnedProcess(nativeSpawnPid, NATIVESPAWN_SERVER_NAME); SetParameter("bootevent.appspawn.started", "true"); } @@ -1002,7 +1002,7 @@ AppSpawnContent *StartSpawnService(const AppSpawnStartArg *startArg, uint32_t ar { APPSPAWN_CHECK(startArg != NULL && argv != NULL, return NULL, "Invalid start arg"); pid_t pid = 0; - pid_t NativeSpawnPid = 0; + pid_t nativeSpawnPid = 0; AppSpawnStartArg *arg = (AppSpawnStartArg *)startArg; APPSPAWN_LOGV("Start appspawn argvSize %{public}d mode %{public}d service %{public}s", argvSize, arg->mode, arg->serviceName); @@ -1011,8 +1011,8 @@ AppSpawnContent *StartSpawnService(const AppSpawnStartArg *startArg, uint32_t ar if (pid == 0) { AppSpawnArgSet(MODE_FOR_NWEB_SPAWN, arg); } else { - NativeSpawnPid = NativeSpawnLaunch(); - if (NativeSpawnPid == 0) { + nativeSpawnPid = NativeSpawnLaunch(); + if (nativeSpawnPid == 0) { AppSpawnArgSet(MODE_FOR_NATIVE_SPAWN, arg); } } @@ -1046,7 +1046,7 @@ AppSpawnContent *StartSpawnService(const AppSpawnStartArg *startArg, uint32_t ar #endif AddAppSpawnHook(STAGE_CHILD_PRE_RUN, HOOK_PRIO_LOWEST, AppSpawnClearEnv); if (arg->mode == MODE_FOR_APP_SPAWN) { - AppSpawnStartServiceEnd(pid, NativeSpawnPid); + AppSpawnStartServiceEnd(pid, nativeSpawnPid); } return content; } diff --git a/test/moduletest/appspawn_test_cmder.cpp b/test/moduletest/appspawn_test_cmder.cpp index 0aed8552..4b35c5ae 100644 --- a/test/moduletest/appspawn_test_cmder.cpp +++ b/test/moduletest/appspawn_test_cmder.cpp @@ -115,7 +115,7 @@ int AppSpawnTestCommander::ProcessArgs(int argc, char *const argv[]) if (strcmp(argv[i], "nwebspawn") == 0) { appSpawn_ = 0; } else if (strcmp(argv[i], "nativespawn") == 0) { - appSpawn_ = 2; + appSpawn_ = 2; // 2 is nwebspawn } else { appSpawn_ = 1; }