From c7148c21eb12815d83c9d4eba477fd6b4e2155b8 Mon Sep 17 00:00:00 2001 From: nianyuu Date: Fri, 22 Aug 2025 14:44:07 +0800 Subject: [PATCH] Revert appspawn supports arkweb update-mount Signed-off-by: nianyuu --- appdata-sandbox.json | 5 + interfaces/innerkits/include/appspawn.h | 1 - modules/module_engine/include/appspawn_hook.h | 1 - modules/modulemgr/appspawn_modulemgr.c | 4 +- .../normal/appspawn_sandbox_manager.cpp | 65 +-------- .../sandbox/normal/sandbox_shared_mount.cpp | 63 --------- modules/sandbox/normal/sandbox_shared_mount.h | 1 - standard/BUILD.gn | 20 --- standard/appspawn_main.c | 9 +- standard/appspawn_service.c | 125 +----------------- .../app_spawn_module_interface_test.cpp | 4 +- .../app_spawn_service_test.cpp | 6 +- 12 files changed, 19 insertions(+), 285 deletions(-) diff --git a/appdata-sandbox.json b/appdata-sandbox.json index faef4e59..c93a41ab 100644 --- a/appdata-sandbox.json +++ b/appdata-sandbox.json @@ -103,6 +103,11 @@ "sandbox-path" : "/data/data/hiai", "sandbox-flags" : [ "bind", "rec" ], "check-action-status": "false" + }, { + "src-path" : "/data/app/el1/bundle/public/", + "sandbox-path" : "/data/storage/el1/bundle", + "sandbox-flags" : [ "bind", "rec" ], + "check-action-status": "true" }, { "src-path" : "/mnt/sandbox///data/storage/el2", "sandbox-path" : "/data/storage/el2", diff --git a/interfaces/innerkits/include/appspawn.h b/interfaces/innerkits/include/appspawn.h index e9feda93..25a4a591 100644 --- a/interfaces/innerkits/include/appspawn.h +++ b/interfaces/innerkits/include/appspawn.h @@ -49,7 +49,6 @@ typedef void *AppSpawnClientHandle; #define NWEBSPAWN_SERVER_NAME "nwebspawn" #define APPSPAWN_SERVER_NAME "appspawn" #define CJAPPSPAWN_SERVER_NAME "cjappspawn" -#define NWEBSPAWN_RESTART "nwebRestart" #define NATIVESPAWN_SERVER_NAME "nativespawn" #define HYBRIDSPAWN_SERVER_NAME "hybridspawn" diff --git a/modules/module_engine/include/appspawn_hook.h b/modules/module_engine/include/appspawn_hook.h index b2f5a8e6..c2cd3edc 100644 --- a/modules/module_engine/include/appspawn_hook.h +++ b/modules/module_engine/include/appspawn_hook.h @@ -65,7 +65,6 @@ typedef enum TagAppSpawnHookStage { // 应用状态处理 STAGE_SERVER_APP_ADD, STAGE_SERVER_APP_DIED, - STAGE_SERVER_APP_UMOUNT, // run before fork STAGE_PARENT_PRE_FORK = 20, STAGE_PARENT_POST_FORK = 21, diff --git a/modules/modulemgr/appspawn_modulemgr.c b/modules/modulemgr/appspawn_modulemgr.c index 75e9e666..e63143fe 100644 --- a/modules/modulemgr/appspawn_modulemgr.c +++ b/modules/modulemgr/appspawn_modulemgr.c @@ -260,7 +260,7 @@ int ProcessMgrHookExecute(AppSpawnHookStage stage, const AppSpawnContent *conten { APPSPAWN_CHECK(content != NULL && appInfo != NULL, return APPSPAWN_ARG_INVALID, "Invalid hook"); - APPSPAWN_CHECK((stage >= STAGE_SERVER_APP_ADD) && (stage <= STAGE_SERVER_APP_UMOUNT), + APPSPAWN_CHECK((stage >= STAGE_SERVER_APP_ADD) && (stage <= STAGE_SERVER_APP_DIED), return APPSPAWN_ARG_INVALID, "Invalid stage %{public}d", (int)stage); AppSpawnAppArg arg; @@ -280,7 +280,7 @@ static int ProcessMgrHookRun(const HOOK_INFO *hookInfo, void *executionContext) int AddProcessMgrHook(AppSpawnHookStage stage, int prio, ProcessChangeHook hook) { APPSPAWN_CHECK(hook != NULL, return APPSPAWN_ARG_INVALID, "Invalid hook"); - APPSPAWN_CHECK((stage >= STAGE_SERVER_APP_ADD) && (stage <= STAGE_SERVER_APP_UMOUNT), + APPSPAWN_CHECK((stage >= STAGE_SERVER_APP_ADD) && (stage <= STAGE_SERVER_APP_DIED), return APPSPAWN_ARG_INVALID, "Invalid stage %{public}d", (int)stage); HOOK_INFO info; info.stage = stage; diff --git a/modules/sandbox/normal/appspawn_sandbox_manager.cpp b/modules/sandbox/normal/appspawn_sandbox_manager.cpp index c7407684..201f68f8 100644 --- a/modules/sandbox/normal/appspawn_sandbox_manager.cpp +++ b/modules/sandbox/normal/appspawn_sandbox_manager.cpp @@ -27,13 +27,7 @@ int32_t SetAppSandboxProperty(AppSpawnMgr *content, AppSpawningCtx *property) { APPSPAWN_CHECK(property != nullptr, return -1, "Invalid appspawn client"); APPSPAWN_CHECK(content != nullptr, return -1, "Invalid appspawn content"); - // clear g_mountInfo in the child process - std::map* mapPtr = static_cast*>(GetEl1BundleMountCount()); - if (mapPtr == nullptr) { - APPSPAWN_LOGE("Get el1 bundle mount count failed"); - return APPSPAWN_ARG_INVALID; - } - mapPtr->clear(); + int ret = 0; // no sandbox if (CheckAppMsgFlagsSet(property, APP_FLAGS_NO_SANDBOX)) { @@ -93,60 +87,6 @@ static int InstallDebugSandbox(AppSpawnMgr *content, AppSpawningCtx *property) return OHOS::AppSpawn::SandboxCore::InstallDebugSandbox(content, property); } -static void UmountDir(const char *rootPath, const char *targetPath, const AppSpawnedProcessInfo *appInfo) -{ - size_t allPathSize = strlen(rootPath) + USER_ID_SIZE + strlen(appInfo->name) + strlen(targetPath) + 2; - char *path = reinterpret_cast(malloc(sizeof(char) * (allPathSize))); - APPSPAWN_CHECK(path != nullptr, return, "Failed to malloc path"); - - int ret = sprintf_s(path, allPathSize, "%s%u/%s%s", rootPath, appInfo->uid / UID_BASE, - appInfo->name, targetPath); - APPSPAWN_CHECK(ret > 0 && ((size_t)ret < allPathSize), free(path); - return, "Failed to get sandbox path errno %{public}d", errno); - - ret = umount2(path, MNT_DETACH); - if (ret == 0) { - APPSPAWN_LOGI("Umount2 sandbox path %{public}s success", path); - } else { - APPSPAWN_LOGW("Failed to umount2 sandbox path %{public}s errno %{public}d", path, errno); - } - free(path); -} - -static int UmountSandboxPath(const AppSpawnMgr *content, const AppSpawnedProcessInfo *appInfo) -{ - APPSPAWN_CHECK(content != nullptr && appInfo != nullptr && appInfo->name != NULL, - return -1, "Invalid content or appInfo"); - if (!IsAppSpawnMode(content)) { - return 0; - } - APPSPAWN_LOGV("UmountSandboxPath name %{public}s pid %{public}d", appInfo->name, appInfo->pid); - const char rootPath[] = "/mnt/sandbox/"; - const char el1Path[] = "/data/storage/el1/bundle"; - - std::string varBundleName = std::string(appInfo->name); - if (appInfo->appIndex > 0) { - varBundleName = "+clone-" + std::to_string(appInfo->appIndex) + "+" + varBundleName; - } - - uint32_t userId = appInfo->uid / UID_BASE; - std::string key = std::to_string(userId) + "-" + varBundleName; - std::map *el1BundleCountMap = static_cast*>(GetEl1BundleMountCount()); - if (el1BundleCountMap == nullptr || el1BundleCountMap->find(key) == el1BundleCountMap->end()) { - return 0; - } - (*el1BundleCountMap)[key]--; - if ((*el1BundleCountMap)[key] == 0) { - APPSPAWN_LOGV("no app %{public}s use it in userId %{public}u, need umount", appInfo->name, userId); - UmountDir(rootPath, el1Path, appInfo); - el1BundleCountMap->erase(key); - } else { - APPSPAWN_LOGV("app %{public}s use it mount times %{public}d in userId %{public}u, not need umount", - appInfo->name, (*el1BundleCountMap)[key], userId); - } - return 0; -} - #ifndef APPSPAWN_SANDBOX_NEW MODULE_CONSTRUCTOR(void) { @@ -157,8 +97,7 @@ MODULE_CONSTRUCTOR(void) (void)AddAppSpawnHook(STAGE_CHILD_EXECUTE, HOOK_PRIO_SANDBOX, SetAppSandboxProperty); (void)AddAppSpawnHook(STAGE_PARENT_UNINSTALL, HOOK_PRIO_SANDBOX, UninstallDebugSandbox); (void)AddAppSpawnHook(STAGE_PARENT_PRE_FORK, HOOK_PRIO_SANDBOX, InstallDebugSandbox); - (void)AddProcessMgrHook(STAGE_SERVER_APP_UMOUNT, HOOK_PRIO_SANDBOX, UmountSandboxPath); (void)AddServerStageHook(STAGE_SERVER_EXIT, HOOK_PRIO_SANDBOX, OHOS::AppSpawn::SandboxCommon::FreeAppSandboxConfigCJson); } -#endif \ No newline at end of file +#endif diff --git a/modules/sandbox/normal/sandbox_shared_mount.cpp b/modules/sandbox/normal/sandbox_shared_mount.cpp index 860af6a2..6b68acae 100644 --- a/modules/sandbox/normal/sandbox_shared_mount.cpp +++ b/modules/sandbox/normal/sandbox_shared_mount.cpp @@ -53,8 +53,6 @@ static const DataGroupSandboxPathTemplate DATA_GROUP_SANDBOX_PATH_MAP[] = { {"el5", EL5, "/data/storage/el5/group/", "ohos.permission.PROTECT_SCREEN_LOCK_DATA"}, }; -static std::map g_mountInfoMap; - int GetElxInfoFromDir(const char *path) { int ret = ELX_MAX; @@ -103,11 +101,6 @@ bool IsValidDataGroupItem(cJSON *item) return false; } -void *GetEl1BundleMountCount(void) -{ - return static_cast(&g_mountInfoMap); -} - #ifndef APPSPAWN_SANDBOX_NEW static bool IsUnlockStatus(uint32_t uid) { @@ -162,60 +155,6 @@ static bool SetSandboxPathShared(const std::string &sandboxPath) return true; } -static int MountEl1Bundle(const AppSpawningCtx *property, const AppDacInfo *info, const char *varBundleName) -{ - /* /data/app/el1/bundle/public/ */ - AppSpawnMsgBundleInfo *bundleInfo = - reinterpret_cast(GetAppProperty(property, TLV_BUNDLE_INFO)); - if (bundleInfo == nullptr) { - return APPSPAWN_SANDBOX_INVALID; - } - char sourcePath[PATH_MAX_LEN] = {0}; - int ret = snprintf_s(sourcePath, PATH_MAX_LEN, PATH_MAX_LEN - 1, "/data/app/el1/bundle/public/%s", - bundleInfo->bundleName); - if (ret <= 0) { - APPSPAWN_LOGE("snprintf data/app/el1/bundle/public/%{public}s failed, errno %{public}d", - bundleInfo->bundleName, errno); - return APPSPAWN_ERROR_UTILS_MEM_FAIL; - } - - /* /mnt/sandbox///data/storage/el1/bundle */ - char targetPath[PATH_MAX_LEN] = {0}; - ret = snprintf_s(targetPath, PATH_MAX_LEN, PATH_MAX_LEN - 1, "/mnt/sandbox/%u/%s/data/storage/el1/bundle", - info->uid/ UID_BASE, varBundleName); - if (ret <= 0) { - APPSPAWN_LOGE("snprintf el1 bundle sandbox path failed, errno %{public}d", errno); - return APPSPAWN_ERROR_UTILS_MEM_FAIL; - } - - ret = MakeDirRec(targetPath, DIR_MODE, 1); - if (ret != 0) { - APPSPAWN_LOGE("mkdir %{public}s failed, errno %{public}d", targetPath, errno); - return APPSPAWN_SANDBOX_ERROR_MKDIR_FAIL; - } - - ret = umount2(targetPath, MNT_DETACH); - if (ret != 0) { - APPSPAWN_LOGW("umount2 %{public}s failed, errno %{public}d", targetPath, errno); - } - - SharedMountArgs arg = { - .srcPath = sourcePath, - .destPath = targetPath, - .fsType = nullptr, - .mountFlags = MS_BIND | MS_REC, - .options = nullptr, - .mountSharedFlag = MS_SHARED - }; - ret = DoSharedMount(&arg); - if (ret != 0) { - APPSPAWN_LOGE("mount %{public}s shared failed, ret %{public}d", targetPath, ret); - } - std::string key = std::to_string(info->uid / UID_BASE) + "-" + std::string(varBundleName); - g_mountInfoMap[key]++; - return ret; -} - static int MountWithFileMgr(const AppSpawningCtx *property, const AppDacInfo *info, const char *varBundleName) { /* /mnt/user//nosharefs/docs */ @@ -615,8 +554,6 @@ static void MountDirToShared(AppSpawnMgr *content, const AppSpawningCtx *propert return; } - MountEl1Bundle(property, info, varBundleName.c_str()); - if (IsUnlockStatus(info->uid)) { SetAppSpawnMsgFlag(property->message, TLV_MSG_FLAGS, APP_FLAGS_UNLOCKED_STATUS); return; diff --git a/modules/sandbox/normal/sandbox_shared_mount.h b/modules/sandbox/normal/sandbox_shared_mount.h index c90efcdb..ad3614b4 100644 --- a/modules/sandbox/normal/sandbox_shared_mount.h +++ b/modules/sandbox/normal/sandbox_shared_mount.h @@ -59,7 +59,6 @@ struct SharedMountArgs { bool IsValidDataGroupItem(cJSON *item); int GetElxInfoFromDir(const char *path); const DataGroupSandboxPathTemplate *GetDataGroupArgTemplate(uint32_t category); -void *GetEl1BundleMountCount(void); int MountToShared(AppSpawnMgr *content, const AppSpawningCtx *property); #ifdef __cplusplus diff --git a/standard/BUILD.gn b/standard/BUILD.gn index 82c87b03..1aca6758 100644 --- a/standard/BUILD.gn +++ b/standard/BUILD.gn @@ -113,10 +113,6 @@ ohos_executable("appspawn") { } cflags = [] - if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { - defines += [ "APPSPAWN_SANDBOX_NEW" ] - } - #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] if (!defined(global_parts_info) || defined(global_parts_info.security_code_signature)) { @@ -215,10 +211,6 @@ ohos_executable("cjappspawn") { } cflags = [] - if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { - defines += [ "APPSPAWN_SANDBOX_NEW" ] - } - #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] if (!defined(global_parts_info) || defined(global_parts_info.security_code_signature)) { @@ -282,10 +274,6 @@ ohos_executable("nativespawn") { } cflags = [] - if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { - defines += [ "APPSPAWN_SANDBOX_NEW" ] - } - #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] if (!defined(global_parts_info) || defined(global_parts_info.security_code_signature)) { @@ -381,10 +369,6 @@ ohos_executable("nwebspawn") { } cflags = [] - if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { - defines += [ "APPSPAWN_SANDBOX_NEW" ] - } - #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] if (defined(global_parts_info) && defined(global_parts_info.security_code_signature)) { @@ -466,10 +450,6 @@ ohos_executable("hybridspawn") { } cflags = [] - if (defined(appspawn_sandbox_new) && appspawn_sandbox_new) { - defines += [ "APPSPAWN_SANDBOX_NEW" ] - } - #ldflags = [ "-Wl,--dynamic-linker,/system/bin/linker64z" ] if (defined(global_parts_info) && defined(global_parts_info.security_code_signature)) { diff --git a/standard/appspawn_main.c b/standard/appspawn_main.c index ac4f7da8..89bd94c2 100644 --- a/standard/appspawn_main.c +++ b/standard/appspawn_main.c @@ -34,7 +34,6 @@ static AppSpawnStartArgTemplate g_appSpawnStartArgTemplate[PROCESS_INVALID] = { {"nweb_cold", {MODE_FOR_NWEB_COLD_RUN, MODULE_NWEBSPAWN, APPSPAWN_SOCKET_NAME, NWEBSPAWN_SERVER_NAME, 0}}, {NATIVESPAWN_SERVER_NAME, {MODE_FOR_NATIVE_SPAWN, MODULE_NATIVESPAWN, NATIVESPAWN_SOCKET_NAME, NATIVESPAWN_SERVER_NAME, 1}}, - {NWEBSPAWN_RESTART, {MODE_FOR_NWEB_SPAWN, MODULE_NWEBSPAWN, NWEBSPAWN_SOCKET_NAME, NWEBSPAWN_SERVER_NAME, 1}}, {HYBRIDSPAWN_SERVER_NAME, {MODE_FOR_HYBRID_SPAWN, MODULE_HYBRIDSPAWN, HYBRIDSPAWN_SOCKET_NAME, HYBRIDSPAWN_SERVER_NAME, 1}}, }; @@ -144,12 +143,8 @@ int main(int argc, char *const argv[]) if (arg->initArg == 0) { APPSPAWN_CHECK(argc >= ARG_NULL, return 0, "Invalid arg for cold start %{public}d", argc); } else { - if (strcmp(argTemp->serverName, NWEBSPAWN_RESTART) == 0) { // nweb spawn restart - APPSPAWN_CHECK_ONLY_EXPER(argvSize >= APP_LEN_PROC_NAME, argvSize = APP_LEN_PROC_NAME); - } else { - APPSPAWN_CHECK(argvSize >= APP_LEN_PROC_NAME, return 0, "Invalid arg size for service %{public}s", - arg->serviceName); - } + APPSPAWN_CHECK(argvSize >= APP_LEN_PROC_NAME, return 0, "Invalid arg size for service %{public}s", + arg->serviceName); } AppSpawnContent *content = StartSpawnService(arg, argvSize, argc, argv); if (content != NULL) { diff --git a/standard/appspawn_service.c b/standard/appspawn_service.c index 274fe9a5..249ba753 100644 --- a/standard/appspawn_service.c +++ b/standard/appspawn_service.c @@ -16,7 +16,6 @@ #include "appspawn_service.h" #include -#include #include #include #include @@ -27,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -181,7 +179,6 @@ static void HandleDiedPid(pid_t pid, uid_t uid, int status) DumpStatus(appInfo->name, pid, status, &signal); WriteSignalInfoToFd(appInfo, content, signal); ProcessMgrHookExecute(STAGE_SERVER_APP_DIED, GetAppSpawnContent(), appInfo); - ProcessMgrHookExecute(STAGE_SERVER_APP_UMOUNT, GetAppSpawnContent(), appInfo); // move app info to died queue in NWEBSPAWN, or delete appinfo TerminateSpawnedProcess(appInfo); @@ -1453,134 +1450,18 @@ static void ProcessBegetCmdMsg(AppSpawnConnection *connection, AppSpawnMsgNode * DeleteAppSpawnMsg(&msgNode); } -static int GetArkWebInstallPath(const char *key, char *value) -{ - int len = GetParameter(key, "", value, PATH_SIZE); - APPSPAWN_CHECK(len > 0, return -1, "Failed to get arkwebcore install path from param, len %{public}d", len); - for (int i = len - 1; i >= 0; i--) { - if (value[i] == '/') { - value[i] = '\0'; - return i; - } - value[i] = '\0'; - } - return -1; -} -static bool CheckAllDigit(char *userId) -{ - for (int i = 0; userId[i] != '\0'; i++) { - if (!isdigit(userId[i])) { - return false; - } - } - return true; -} - -#ifdef APPSPAWN_SANDBOX_NEW static int ProcessSpawnRemountMsg(AppSpawnConnection *connection, AppSpawnMsgNode *message) { - APPSPAWN_LOGI("ProcessSpawnRemountMsg in new sandbox, do not handle it"); + APPSPAWN_LOGI("ProcessSpawnRemountMsg, do not handle it"); return 0; } static void ProcessSpawnRestartMsg(AppSpawnConnection *connection, AppSpawnMsgNode *message) { - APPSPAWN_LOGI("ProcessSpawnRestartMsg in new sandbox, do not handle it"); + APPSPAWN_LOGI("ProcessSpawnRestartMsg, do not handle it"); SendResponse(connection, &message->msgHeader, 0, 0); } -#else -static int ProcessSpawnRemountMsg(AppSpawnConnection *connection, AppSpawnMsgNode *message) -{ - char srcPath[PATH_SIZE] = {0}; - int len = GetArkWebInstallPath("persist.arkwebcore.install_path", srcPath); - APPSPAWN_CHECK(len > 0, return -1, "Failed to get arkwebcore install path"); - - char *rootPath = "/mnt/sandbox"; - DIR *rootDir = opendir(rootPath); - APPSPAWN_CHECK(rootDir != NULL, return -1, "Failed to opendir %{public}s, errno %{public}d", rootPath, errno); - - struct dirent *ent; - while ((ent = readdir(rootDir)) != NULL) { - char *userId = ent->d_name; - if (strcmp(userId, ".") == 0 || strcmp(userId, "..") == 0 || !CheckAllDigit(userId)) { - continue; - } - - char userIdPath[PATH_SIZE] = {0}; - int ret = snprintf_s(userIdPath, sizeof(userIdPath), sizeof(userIdPath) - 1, "%s/%s", rootPath, userId); - APPSPAWN_CHECK(ret > 0, continue, "Failed to snprintf_s, errno %{public}d", errno); - - DIR *userIdDir = opendir(userIdPath); - APPSPAWN_CHECK(userIdDir != NULL, continue, "Failed to open %{public}s, errno %{public}d", userIdPath, errno); - - while ((ent = readdir(userIdDir)) != NULL) { - char *bundleName = ent->d_name; - if (strcmp(bundleName, ".") == 0 || strcmp(bundleName, "..") == 0) { - continue; - } - char destPath[PATH_SIZE] = {0}; - ret = snprintf_s(destPath, sizeof(destPath), sizeof(destPath) - 1, - "%s/%s/data/storage/el1/bundle/arkwebcore", userIdPath, bundleName); - APPSPAWN_CHECK(ret > 0, continue, "Failed to snprintf_s, errno %{public}d", errno); - - umount2(destPath, MNT_DETACH); - ret = mount(srcPath, destPath, NULL, MS_BIND | MS_REC, NULL); - if (ret != 0 && errno == EBUSY) { - ret = mount(srcPath, destPath, NULL, MS_BIND | MS_REC, NULL); - APPSPAWN_LOGV("mount again %{public}s to %{public}s, ret %{public}d", srcPath, destPath, ret); - } - APPSPAWN_CHECK(ret == 0, continue, - "Failed to bind mount %{public}s to %{public}s, errno %{public}d", srcPath, destPath, errno); - - ret = mount(NULL, destPath, NULL, MS_SHARED, NULL); - APPSPAWN_CHECK(ret == 0, continue, - "Failed to shared mount %{public}s to %{public}s, errno %{public}d", srcPath, destPath, errno); - - APPSPAWN_LOGV("Remount %{public}s to %{public}s success", srcPath, destPath); - } - closedir(userIdDir); - } - closedir(rootDir); - return 0; -} - -static void ProcessSpawnRestartMsg(AppSpawnConnection *connection, AppSpawnMsgNode *message) -{ - AppSpawnContent *content = GetAppSpawnContent(); - if (!IsNWebSpawnMode((AppSpawnMgr *)content)) { - SendResponse(connection, &message->msgHeader, APPSPAWN_MSG_INVALID, 0); - DeleteAppSpawnMsg(&message); - APPSPAWN_LOGE("Restart msg only support nwebspawn"); - return; - } - - TraversalSpawnedProcess(AppQueueDestroyProc, NULL); - SendResponse(connection, &message->msgHeader, 0, 0); - DeleteAppSpawnMsg(&message); - (void) ServerStageHookExecute(STAGE_SERVER_EXIT, content); - - errno = 0; - int fd = GetControlSocket(NWEBSPAWN_SOCKET_NAME); - APPSPAWN_CHECK(fd >= 0, return, "Get fd failed %{public}d, errno %{public}d", fd, errno); - - int ret = 0; - int op = fcntl(fd, F_GETFD); - APPSPAWN_CHECK_ONLY_LOG(op >= 0, "fcntl failed %{public}d", op); - if (op > 0) { - ret = fcntl(fd, F_SETFD, (unsigned int)op & ~FD_CLOEXEC); - if (ret < 0) { - APPSPAWN_LOGE("Set fd failed %{public}d, %{public}d, ret %{public}d, errno %{public}d", fd, op, ret, errno); - } - } - - char *path = "/system/bin/nwebspawn"; - char *mode = NWEBSPAWN_RESTART; - const char *const formatCmds[] = {path, "-mode", mode, NULL}; - ret = execv(path, (char **)formatCmds); - APPSPAWN_LOGE("Failed to execv, ret %{public}d, errno %{public}d", ret, errno); -} -#endif APPSPAWN_STATIC void ProcessUninstallDebugHap(AppSpawnConnection *connection, AppSpawnMsgNode *message) { @@ -1591,7 +1472,7 @@ APPSPAWN_STATIC void ProcessUninstallDebugHap(AppSpawnConnection *connection, Ap DeleteAppSpawnMsg(&message); return; } - + property->message = message; property->message->connection = connection; int ret = AppSpawnHookExecute(STAGE_PARENT_UNINSTALL, 0, GetAppSpawnContent(), &property->client); diff --git a/test/unittest/app_spawn_standard_test/app_spawn_module_interface_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_module_interface_test.cpp index a8821f60..77a525c8 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_module_interface_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_module_interface_test.cpp @@ -189,14 +189,14 @@ HWTEST_F(AppSpawnModuleInterfaceTest, App_Spawn_Process_Hook_001, TestSize.Level for (int i = 0; i < STAGE_MAX; i++) { for (int k = 0; k <= HOOK_PRIO_LOWEST + 1000; k += 1000) { // 1000 ret = AddProcessMgrHook(static_cast(i), k, ReportProcessExitInfo); - EXPECT_EQ(ret == 0, (i >= STAGE_SERVER_APP_ADD && i <= STAGE_SERVER_APP_UMOUNT)); + EXPECT_EQ(ret == 0, (i >= STAGE_SERVER_APP_ADD && i <= STAGE_SERVER_APP_DIED)); } ret = AddProcessMgrHook(static_cast(i), 0, nullptr); EXPECT_EQ(ret == 0, 0); ret = ProcessMgrHookExecute(static_cast(i), reinterpret_cast(mgr), app); - EXPECT_EQ(ret == 0, (i >= STAGE_SERVER_APP_ADD && i <= STAGE_SERVER_APP_UMOUNT)); + EXPECT_EQ(ret == 0, (i >= STAGE_SERVER_APP_ADD && i <= STAGE_SERVER_APP_DIED)); ret = ProcessMgrHookExecute(static_cast(i), nullptr, app); EXPECT_NE(ret, 0); diff --git a/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp b/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp index a8f86701..d6d0bafc 100644 --- a/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp +++ b/test/unittest/app_spawn_standard_test/app_spawn_service_test.cpp @@ -288,7 +288,7 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_BEGET_SPAWNTIME_001, TestSize.Level0 /** * @brief 向appspawn发送MSG_UPDATE_MOUNT_POINTS类型的消息 - * @note 预期结果:appspawn接收到请求消息,遍历沙箱包名更新挂载点 + * @note 预期结果:appspawn接收到请求消息,不做处理直接返回 * */ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_UPDATE_MOUNT_POINTS_001, TestSize.Level0) @@ -312,7 +312,7 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_UPDATE_MOUNT_POINTS_001, TestSize.Le /** * @brief 向appspawn发送MSG_RESTART_SPAWNER类型的消息 - * @note 预期结果:appspawn不支持处理该类型消息,返回APPSPAWN_MSG_INVALID + * @note 预期结果:appspawn接收到请求消息,不做处理直接返回 * */ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_RESTART_SPAWNER_001, TestSize.Level0) @@ -326,7 +326,7 @@ HWTEST_F(AppSpawnServiceTest, App_Spawn_MSG_RESTART_SPAWNER_001, TestSize.Level0 AppSpawnResult result = {}; ret = AppSpawnClientSendMsg(clientHandle, reqHandle, &result); - APPSPAWN_CHECK(ret == 0 && result.result == APPSPAWN_MSG_INVALID, ret = -1; + APPSPAWN_CHECK(ret == 0 && result.result == 0, ret = -1; break, "Failed to send MSG_RESTART_SPAWNER, ret %{public}d result %{public}d", ret, result.result); } while (0); -- Gitee