diff --git a/appdata-sandbox.json b/appdata-sandbox.json index 043b888d59de5fda9ae4924acb38923ca78422b5..b6e263884b17fb9799c2abde6b8fa5e1983cb55c 100755 --- a/appdata-sandbox.json +++ b/appdata-sandbox.json @@ -750,7 +750,7 @@ "sandbox-flags": [ "bind", "rec" ] }, { - "src-path": "/mnt/sandbox///mnt/storage/Users", + "src-path": "/mnt/sandbox///mnt/storage/Users", "sandbox-path": "/storage/Users", "sandbox-flags-customized": [ "MS_NODEV"], "dac-override-sensitive": "true", @@ -764,7 +764,7 @@ "check-action-status": "false" }, { - "src-path": "/mnt/sandbox///mnt/storage/userExternal", + "src-path": "/mnt/sandbox///mnt/storage/userExternal", "sandbox-path": "/storage/userExternal", "sandbox-flags-customized": [ "MS_NODEV" ], "dac-override-sensitive": "true", @@ -781,7 +781,7 @@ "sandbox-flags": [ "bind", "rec" ] }, { - "src-path": "/mnt/sandbox///mnt/storage/Users", + "src-path": "/mnt/sandbox///mnt/storage/Users", "sandbox-path": "/storage/Users", "sandbox-flags-customized": [ "MS_NODEV"], "dac-override-sensitive": "true", diff --git a/modules/sandbox/sandbox_utils.cpp b/modules/sandbox/sandbox_utils.cpp index 777da7a5c3c4827652fa5ee5cf20fd3edd3c5cd7..edd51f0274c77345876861043bcc2bfd25e22774 100644 --- a/modules/sandbox/sandbox_utils.cpp +++ b/modules/sandbox/sandbox_utils.cpp @@ -84,6 +84,7 @@ namespace { const std::string g_packageName = ""; const std::string g_packageNameIndex = ""; const std::string g_variablePackageName = ""; + const std::string g_clonePackageName = ""; const std::string g_arkWebPackageName = ""; const std::string g_hostUserId = ""; const std::string g_sandBoxDir = "/mnt/sandbox/"; @@ -573,6 +574,25 @@ static std::string ReplaceHostUserId(const AppSpawningCtx *appProperty, const st return tmpSandboxPath; } +static std::string ReplaceClonePackageName(const AppSpawningCtx *appProperty, const std::string &path) +{ + std::string tmpSandboxPath = path; + AppSpawnMsgBundleInfo *bundleInfo = + reinterpret_cast(GetAppProperty(appProperty, TLV_BUNDLE_INFO)); + APPSPAWN_CHECK(bundleInfo != NULL, return "", "No bundle info in msg %{public}s", GetBundleName(appProperty)); + + std::string tmpBundlePath = bundleInfo->bundleName; + std::ostringstream variablePackageName; + if (CheckAppSpawnMsgFlag(appProperty->message, TLV_MSG_FLAGS, APP_FLAGS_CLONE_ENABLE)) { + variablePackageName << "+clone-" << bundleInfo->bundleIndex << "+" << bundleInfo->bundleName; + tmpBundlePath = variablePackageName.str(); + } + + tmpSandboxPath = replace_all(tmpSandboxPath, g_variablePackageName, tmpBundlePath); + APPSPAWN_LOGV("tmpSandboxPath %{public}s", tmpSandboxPath.c_str()); + return tmpSandboxPath; +} + string SandboxUtils::ConvertToRealPath(const AppSpawningCtx *appProperty, std::string path) { AppSpawnMsgBundleInfo *info = @@ -605,6 +625,10 @@ string SandboxUtils::ConvertToRealPath(const AppSpawningCtx *appProperty, std::s path = ReplaceVariablePackageName(appProperty, path); } + if (path.find(g_clonePackageName) != std::string::npos) { + path = ReplaceClonePackageName(appProperty, path); + } + if (path.find(g_arkWebPackageName) != std::string::npos) { path = replace_all(path, g_arkWebPackageName, getArkWebPackageName()); APPSPAWN_LOGV(