From 18f67e1d301bd5f4ff888605a337de93fa1c7b1c Mon Sep 17 00:00:00 2001 From: wuchunbo Date: Sun, 16 Jan 2022 14:20:43 +0800 Subject: [PATCH] set app default umask to 0002, distributeddatamgr need group rw permissons of app database file Signed-off-by: wuchunbo --- src/appspawn_server.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/appspawn_server.cpp b/src/appspawn_server.cpp index 2acb6818..ea25bbdb 100644 --- a/src/appspawn_server.cpp +++ b/src/appspawn_server.cpp @@ -42,6 +42,8 @@ constexpr int32_t WAIT_DELAY_US = 100 * 1000; // 100ms constexpr int32_t GID_MEDIA = 1023; constexpr int32_t MAX_GIDS = 64; +constexpr mode_t APP_DEFAULT_MASK = 0002; + constexpr std::string_view BUNDLE_NAME_CAMERA("com.ohos.camera"); constexpr std::string_view BUNDLE_NAME_PHOTOS("com.ohos.photos"); constexpr std::string_view BUNDLE_NAME_MEDIA_LIBRARY("com.ohos.medialibrary.MediaLibraryDataA"); @@ -55,6 +57,11 @@ static constexpr HiLogLabel LABEL = {LOG_CORE, 0, "AppSpawnServer"}; extern "C" { #endif +static void SetUmask() +{ + umask(APP_DEFAULT_MASK); +} + static void SignalHandler([[maybe_unused]] int sig) { pid_t pid; @@ -422,6 +429,8 @@ bool AppSpawnServer::SetAppProcProperty(int connectFd, const ClientSocket::AppPr } #endif + SetUmask(); + ret = SetFileDescriptors(); if (FAILED(ret)) { NotifyResToParentProc(fd[1], ret); -- Gitee