From 8a9e875a176e1a331f38de260167997804f17a64 Mon Sep 17 00:00:00 2001 From: zhangkaixiang Date: Wed, 23 Aug 2023 18:53:47 +0800 Subject: [PATCH] check authority when path don't contain bundle name Signed-off-by: zhangkaixiang --- interfaces/common/file_share_sandbox.json | 6 ------ interfaces/common/src/sandbox_helper.cpp | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/interfaces/common/file_share_sandbox.json b/interfaces/common/file_share_sandbox.json index 7d195ff1d..8a5b05901 100644 --- a/interfaces/common/file_share_sandbox.json +++ b/interfaces/common/file_share_sandbox.json @@ -44,12 +44,6 @@ }, { "sandbox-path" : "/storage/Share/", "src-path" : "/data/service/el1/public/storage_daemon/share/public/" - }, { - "sandbox-path" : "/Documents/", - "src-path" : "/mnt/hmdfs//account/merge_view/files/Documents/" - }, { - "sandbox-path" : "/Download/", - "src-path" : "/mnt/hmdfs//account/merge_view/files/Download/" } ] } \ No newline at end of file diff --git a/interfaces/common/src/sandbox_helper.cpp b/interfaces/common/src/sandbox_helper.cpp index 5354e2eb5..4f1b0ae1a 100644 --- a/interfaces/common/src/sandbox_helper.cpp +++ b/interfaces/common/src/sandbox_helper.cpp @@ -37,6 +37,10 @@ namespace { const string SANDBOX_JSON_FILE_PATH = "/etc/app_file_service/file_share_sandbox.json"; const std::string SHAER_PATH_HEAD = "/mnt/hmdfs/"; const std::string SHAER_PATH_MID = "/account/merge_view/files/"; + const string FILE_MANAGER_URI_HEAD = "/storage/"; + const string FILE_MANAGER_AUTHORITY = "docs"; + const string DLP_MANAGER_BUNDLE_NAME = "com.ohos.dlpmanager"; + const string FUSE_URI_HEAD = "/mnt/data/fuse"; const string BACKFLASH = "/"; const string MEDIA = "media"; const int ASSET_IN_BUCKET_NUM_MAX = 1000; @@ -238,6 +242,11 @@ int32_t SandboxHelper::GetPhysicalPath(const std::string &fileUri, const std::st return GetMediaPhysicalPath(sandboxPath, userId, physicalPath); } + if ((sandboxPath.find(FILE_MANAGER_URI_HEAD) == 0 && bundleName != FILE_MANAGER_AUTHORITY) || + (sandboxPath.find(FUSE_URI_HEAD) == 0 && bundleName != DLP_MANAGER_BUNDLE_NAME)) { + return -EINVAL; + } + string lowerPathTail = ""; string lowerPathHead = ""; -- Gitee