From 34cebc6831ed576ae1643c6813b1769679229081 Mon Sep 17 00:00:00 2001 From: Zheng Yongjun Date: Thu, 10 Feb 2022 14:46:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=BB=84=E5=8C=BAwargnar?= =?UTF-8?q?=E6=9D=BF=E5=AD=90=E4=B8=8D=E8=83=BD=E5=90=AF=E5=8A=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zheng Yongjun Change-Id: Ia5077fed884a88bf4389f9daa7d88dec7f419930 --- src/appspawn_server.cpp | 28 ++++++++++++++++++++++++++-- src/include/appspawn_server.h | 5 +++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp index 6a43dcd7..a6e42567 100644 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -563,6 +563,25 @@ void AppSpawnServer::DoAppSandboxMkdir(std::string sandboxPackagePath, const Cli mkdir(dirPath.c_str(), FILE_MODE); } +int32_t AppSpawnServer::DoSandboxRootFolderCreateAdapt(std::string sandboxPackagePath) +{ + int rc = mount(NULL, "/", NULL, MS_REC | MS_SLAVE, NULL); + if (rc) { + HiLog::Error(LABEL, "set propagation slave failed"); + return rc; + } + + // bind mount "/" to /mnt/sandbox/ path + // rootfs: to do more resouces bind mount here to get more strict resources constraints + rc = mount("/", sandboxPackagePath.c_str(), NULL, MS_BIND | MS_REC, NULL); + if (rc) { + HiLog::Error(LABEL, "mount bind / failed"); + return rc; + } + + return 0; +} + int32_t AppSpawnServer::DoSandboxRootFolderCreate(std::string sandboxPackagePath) { int rc = mount(NULL, "/", NULL, MS_REC | MS_SLAVE, NULL); @@ -642,9 +661,14 @@ int32_t AppSpawnServer::SetAppSandboxProperty(const ClientSocket::AppProperty *a return rc; } - rc = DoSandboxRootFolderCreate(sandboxPackagePath); + // to make wargnar work + if (access("/3rdmodem", F_OK) == 0) { + rc = DoSandboxRootFolderCreateAdapt(sandboxPackagePath); + } else { + rc = DoSandboxRootFolderCreate(sandboxPackagePath); + } if (rc) { - HiLog::Error(LABEL, "DoSandboxRootFolderCreate failed, packagename is %{public}s", appProperty->processName); + HiLog::Error(LABEL, "DoSandboxRootFolderCreate failed, %{public}s", appProperty->processName); return rc; } diff --git a/src/include/appspawn_server.h b/src/include/appspawn_server.h index d909a3e7..abef561a 100644 --- a/src/include/appspawn_server.h +++ b/src/include/appspawn_server.h @@ -127,6 +127,11 @@ private: */ int32_t DoSandboxRootFolderCreate(std::string sandboxPackagePath); + /** + * Create sandbox root folder file with wargnar device + */ + int32_t DoSandboxRootFolderCreateAdapt(std::string sandboxPackagePath); + /** * Do app sandbox original path mount common */ -- Gitee