diff --git a/adapter/appspawn_sandbox.cpp b/adapter/appspawn_sandbox.cpp index 1e92b9e88e5b4629867b546174285354a63cf617..9ae7bc9431122a03f36e70f8642f0fa309801f2a 100644 --- a/adapter/appspawn_sandbox.cpp +++ b/adapter/appspawn_sandbox.cpp @@ -110,28 +110,9 @@ void RegisterAppSandbox(struct AppSpawnContent_ *content, AppSpawnClient *client } } -static void MatchSandbox(AppSpawnClientExt *appProperty) -{ - if (appProperty == nullptr) { - return; - } - if (strcmp("system_basic", appProperty->property.apl) == 0) { - EnterSandbox("priv-app"); - } else if (strcmp("normal", appProperty->property.apl) == 0) { - EnterSandbox("app"); - } else if (strcmp("system_core ", appProperty->property.apl) == 0) { - EnterSandbox("app"); - } else { - APPSPAWN_LOGE("AppSpawnServer::Failed to match appspawn sandbox %s", appProperty->property.apl); - EnterSandbox("app"); - } -} - int32_t SetAppSandboxProperty(struct AppSpawnContent_ *content, AppSpawnClient *client) { APPSPAWN_CHECK(client != NULL, return -1, "Invalid appspwn client"); AppSpawnClientExt *appProperty = (AppSpawnClientExt *)client; - MatchSandbox(appProperty); - return SandboxUtils::SetAppSandboxProperty(&appProperty->property); } diff --git a/standard/appspawn_process.c b/standard/appspawn_process.c index c17718b3595f637eb9852da9186f1afd1be5118a..695e1604105514fed07dfbee204b28714a44970a 100644 --- a/standard/appspawn_process.c +++ b/standard/appspawn_process.c @@ -382,5 +382,7 @@ void SetContentFunction(AppSpawnContent *content) content->setAppSandbox = SetAppSandboxProperty; content->setAppAccessToken = SetAppAccessToken; content->coldStartApp = ColdStartApp; +#ifdef APPSPAWN_SUPPORT_SANDBOX content->registerAppSandbox = RegisterAppSandbox; +#endif } diff --git a/util/src/sandbox_utils.cpp b/util/src/sandbox_utils.cpp index 564bb9a40cd9718e3290e6faa506648f5348119a..cd3cf164702cdd4a529331b819dfb5520e3c51ee 100644 --- a/util/src/sandbox_utils.cpp +++ b/util/src/sandbox_utils.cpp @@ -516,12 +516,13 @@ bool SandboxUtils::CheckAppSandboxSwitchStatus(const ClientSocket::AppProperty * int32_t SandboxUtils::SetAppSandboxProperty(const ClientSocket::AppProperty *appProperty) { std::string sandboxPackagePath = "/mnt/sandbox/"; + mkdir(sandboxPackagePath.c_str(), FILE_MODE); const std::string bundleName = appProperty->bundleName; sandboxPackagePath += bundleName; - int rc = 0; + mkdir(sandboxPackagePath.c_str(), FILE_MODE); // add pid to a new mnt namespace - rc = unshare(CLONE_NEWNS); + int rc = unshare(CLONE_NEWNS); if (rc) { HiLog::Error(LABEL, "unshare failed, packagename is %{public}s", bundleName.c_str()); return rc;