Lines Matching refs:appProperty
378 static void MakeAtomicServiceDir(const AppSpawningCtx *appProperty, std::string path)
396 reinterpret_cast<AppSpawnMsgDomainInfo *>(GetAppProperty(appProperty, TLV_DOMAIN_INFO));
397 APPSPAWN_CHECK(msgDomainInfo != NULL, return, "No domain info for %{public}s", GetProcessName(appProperty));
402 hapFileInfo.packageName = GetProcessName(appProperty);
404 if (CheckAppMsgFlagsSet(appProperty, APP_FLAGS_DEBUGGABLE)) {
413 AppSpawnMsgDacInfo *dacInfo = reinterpret_cast<AppSpawnMsgDacInfo *>(GetAppProperty(appProperty, TLV_DAC_INFO));
426 static std::string ReplaceVariablePackageName(const AppSpawningCtx *appProperty, const std::string &path)
430 reinterpret_cast<AppSpawnMsgBundleInfo *>(GetAppProperty(appProperty, TLV_BUNDLE_INFO));
431 APPSPAWN_CHECK(bundleInfo != NULL, return "", "No bundle info in msg %{public}s", GetBundleName(appProperty));
434 uint32_t flags = CheckAppSpawnMsgFlag(appProperty->message, TLV_MSG_FLAGS, APP_FLAGS_ATOMIC_SERVICE) ? 0x4 : 0;
436 flags = (CheckAppSpawnMsgFlag(appProperty->message, TLV_MSG_FLAGS, APP_FLAGS_CLONE_ENABLE) &&
438 flags |= CheckAppSpawnMsgFlag(appProperty->message, TLV_MSG_FLAGS, APP_FLAGS_EXTENSION_SANDBOX) ? 0x2 : 0;
440 GetAppSpawnMsgExtInfo(appProperty->message, MSG_EXT_NAME_APP_EXTENSION, NULL));
462 std::string accountId = SandboxUtils::GetExtraInfoByType(appProperty, MSG_EXT_NAME_ACCOUNT_ID);
466 MakeAtomicServiceDir(appProperty, atomicServicePath);
478 string SandboxUtils::ConvertToRealPath(const AppSpawningCtx *appProperty, std::string path)
481 reinterpret_cast<AppSpawnMsgBundleInfo *>(GetAppProperty(appProperty, TLV_BUNDLE_INFO));
482 AppSpawnMsgDacInfo *dacInfo = reinterpret_cast<AppSpawnMsgDacInfo *>(GetAppProperty(appProperty, TLV_DAC_INFO));
503 path = ReplaceVariablePackageName(appProperty, path);
516 std::string SandboxUtils::ConvertToRealPathWithPermission(const AppSpawningCtx *appProperty,
520 reinterpret_cast<AppSpawnMsgBundleInfo *>(GetAppProperty(appProperty, TLV_BUNDLE_INFO));
561 std::string SandboxUtils::GetSbxPathByConfig(const AppSpawningCtx *appProperty, nlohmann::json &config)
563 AppSpawnMsgDacInfo *dacInfo = reinterpret_cast<AppSpawnMsgDacInfo *>(GetAppProperty(appProperty, TLV_DAC_INFO));
570 std::string isolatedFlagText = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ? "isolated/" : "";
572 "/" + isolatedFlagText.c_str() + GetBundleName(appProperty);
578 sandboxRoot = ConvertToRealPath(appProperty, sandboxRoot);
583 APPSPAWN_LOGV("set sandbox-root to default rootapp name is %{public}s", GetBundleName(appProperty));
604 static bool CheckMountConfig(nlohmann::json &mntPoint, const AppSpawningCtx *appProperty,
612 "read mount config failed, app name is %{public}s", GetBundleName(appProperty));
615 reinterpret_cast<AppSpawnMsgDomainInfo *>(GetAppProperty(appProperty, TLV_DOMAIN_INFO));
616 APPSPAWN_CHECK(info != nullptr, return false, "Filed to get domain info %{public}s", GetBundleName(appProperty));
639 static int32_t DoDlpAppMountStrategy(const AppSpawningCtx *appProperty,
643 AppSpawnMsgDacInfo *dacInfo = reinterpret_cast<AppSpawnMsgDacInfo *>(GetAppProperty(appProperty, TLV_DAC_INFO));
685 static int32_t HandleSpecialAppMount(const AppSpawningCtx *appProperty,
688 std::string bundleName = GetBundleName(appProperty);
689 std::string processName = GetProcessName(appProperty);
695 return DoDlpAppMountStrategy(appProperty, srcPath, sandboxPath, fsType, mountFlags);
734 std::string SandboxUtils::GetSandboxOptions(const AppSpawningCtx *appProperty, nlohmann::json &config)
736 AppSpawnMsgDacInfo *dacInfo = reinterpret_cast<AppSpawnMsgDacInfo *>(GetAppProperty(appProperty, TLV_DAC_INFO));
750 void SandboxUtils::GetSandboxMountConfig(const AppSpawningCtx *appProperty, const std::string §ion,
754 mountConfig.optionsPoint = GetSandboxOptions(appProperty, mntPoint);
763 std::string SandboxUtils::GetSandboxPath(const AppSpawningCtx *appProperty, nlohmann::json &mntPoint,
769 sandboxPath = sandboxRoot + ConvertToRealPathWithPermission(appProperty, tmpSandboxPath);
771 sandboxPath = sandboxRoot + ConvertToRealPath(appProperty, tmpSandboxPath);
776 static bool CheckMountFlag(const AppSpawningCtx *appProperty, const std::string bundleName, nlohmann::json &appConfig)
779 if (((ConvertFlagStr(appConfig[g_flags].get<std::string>()) & GetAppMsgFlags(appProperty)) != 0) &&
787 int SandboxUtils::DoAllMntPointsMount(const AppSpawningCtx *appProperty,
790 std::string bundleName = GetBundleName(appProperty);
797 std::string sandboxRoot = GetSbxPathByConfig(appProperty, appConfig);
798 bool checkFlag = CheckMountFlag(appProperty, bundleName, appConfig);
804 if ((CheckMountConfig(mntPoint, appProperty, checkFlag) == false)) {
808 std::string srcPath = ConvertToRealPath(appProperty, mntPoint[g_srcPath].get<std::string>());
809 std::string sandboxPath = GetSandboxPath(appProperty, mntPoint, section, sandboxRoot);
811 GetSandboxMountConfig(appProperty, section, mntPoint, mountConfig);
816 int ret = HandleSpecialAppMount(appProperty, srcPath, sandboxPath, mountConfig.fsType, mountFlags);
837 int32_t SandboxUtils::DoAddGid(AppSpawningCtx *appProperty, nlohmann::json &appConfig,
840 std::string bundleName = GetBundleName(appProperty);
844 AppSpawnMsgDacInfo *dacInfo = reinterpret_cast<AppSpawnMsgDacInfo *>(GetAppProperty(appProperty, TLV_DAC_INFO));
861 int SandboxUtils::DoAllSymlinkPointslink(const AppSpawningCtx *appProperty, nlohmann::json &appConfig)
864 "maybe result sandbox launch failed app name is %{public}s", GetBundleName(appProperty));
867 std::string sandboxRoot = GetSbxPathByConfig(appProperty, appConfig);
876 APPSPAWN_LOGE("read symlink config failed, app name is %{public}s", GetBundleName(appProperty));
880 std::string targetName = ConvertToRealPath(appProperty, symPoint[g_targetName].get<std::string>());
881 std::string linkName = sandboxRoot + ConvertToRealPath(appProperty, symPoint[g_linkName].get<std::string>());
901 int32_t SandboxUtils::DoSandboxFilePrivateBind(const AppSpawningCtx *appProperty,
904 const char *bundleName = GetBundleName(appProperty);
908 DoAddGid((AppSpawningCtx *)appProperty, privateAppConfig[bundleName][0], "", g_privatePrefix);
909 return DoAllMntPointsMount(appProperty, privateAppConfig[bundleName][0], nullptr, g_privatePrefix);
915 int32_t SandboxUtils::DoSandboxFilePermissionBind(AppSpawningCtx *appProperty,
927 if (CheckAppPermissionFlagSet(appProperty, static_cast<uint32_t>(index))) {
928 DoAddGid(appProperty, permissionAppConfig[permission][0], permission.c_str(), g_permissionPrefix);
929 DoAllMntPointsMount(appProperty, permissionAppConfig[permission][0], permission.c_str(),
933 GetBundleName(appProperty), permission.c_str());
955 int32_t SandboxUtils::DoSandboxFilePrivateSymlink(const AppSpawningCtx *appProperty,
958 const char *bundleName = GetBundleName(appProperty);
961 return DoAllSymlinkPointslink(appProperty, privateAppConfig[bundleName][0]);
967 int32_t SandboxUtils::HandleFlagsPoint(const AppSpawningCtx *appProperty,
983 if ((GetAppMsgFlags(appProperty) & flag) != 0) {
984 return DoAllMntPointsMount(appProperty, flagPoint, nullptr, g_flagePoint);
987 APPSPAWN_LOGE("read flags config failed, app name is %{public}s", GetBundleName(appProperty));
994 int32_t SandboxUtils::DoSandboxFilePrivateFlagsPointHandle(const AppSpawningCtx *appProperty,
997 const char *bundleName = GetBundleName(appProperty);
1000 return HandleFlagsPoint(appProperty, privateAppConfig[bundleName][0]);
1006 int32_t SandboxUtils::DoSandboxFileCommonFlagsPointHandle(const AppSpawningCtx *appProperty,
1011 return HandleFlagsPoint(appProperty, commonConfig[g_appResources][0]);
1017 int32_t SandboxUtils::DoSandboxFileCommonBind(const AppSpawningCtx *appProperty, nlohmann::json &wholeConfig)
1023 ret = DoAllMntPointsMount(appProperty, commonConfig[g_appBase][0], nullptr, g_appBase);
1030 ret = DoAllMntPointsMount(appProperty, commonConfig[g_appResources][0], nullptr, g_appResources);
1036 int32_t SandboxUtils::DoSandboxFileCommonSymlink(const AppSpawningCtx *appProperty,
1043 ret = DoAllSymlinkPointslink(appProperty, commonConfig[g_appBase][0]);
1050 ret = DoAllSymlinkPointslink(appProperty, commonConfig[g_appResources][0]);
1056 int32_t SandboxUtils::SetPrivateAppSandboxProperty_(const AppSpawningCtx *appProperty,
1059 int ret = DoSandboxFilePrivateBind(appProperty, config);
1062 ret = DoSandboxFilePrivateSymlink(appProperty, config);
1065 ret = DoSandboxFilePrivateFlagsPointHandle(appProperty, config);
1071 int32_t SandboxUtils::SetPermissionAppSandboxProperty_(AppSpawningCtx *appProperty,
1074 int ret = DoSandboxFilePermissionBind(appProperty, config);
1080 int32_t SandboxUtils::SetRenderSandboxProperty(const AppSpawningCtx *appProperty,
1086 int32_t SandboxUtils::SetRenderSandboxPropertyNweb(const AppSpawningCtx *appProperty,
1089 SandboxConfigType type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ?
1095 int ret = DoAllMntPointsMount(appProperty, privateAppConfig[g_ohosRender][0], nullptr, g_ohosRender);
1097 GetBundleName(appProperty));
1098 ret = DoAllSymlinkPointslink(appProperty, privateAppConfig[g_ohosRender][0]);
1100 GetBundleName(appProperty));
1101 ret = HandleFlagsPoint(appProperty, privateAppConfig[g_ohosRender][0]);
1103 GetBundleName(appProperty));
1109 int32_t SandboxUtils::SetPrivateAppSandboxProperty(const AppSpawningCtx *appProperty)
1112 SandboxConfigType type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ?
1116 ret = SetPrivateAppSandboxProperty_(appProperty, config);
1122 static bool GetSandboxPrivateSharedStatus(const string &bundleName, AppSpawningCtx *appProperty)
1125 SandboxConfigType type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ?
1143 int32_t SandboxUtils::SetPermissionAppSandboxProperty(AppSpawningCtx *appProperty)
1146 SandboxConfigType type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ?
1150 ret = SetPermissionAppSandboxProperty_(appProperty, config);
1157 int32_t SandboxUtils::SetCommonAppSandboxProperty_(const AppSpawningCtx *appProperty,
1162 rc = DoSandboxFileCommonBind(appProperty, config);
1163 APPSPAWN_CHECK(rc == 0, return rc, "DoSandboxFileCommonBind failed, %{public}s", GetBundleName(appProperty));
1166 if (CheckAppSandboxSwitchStatus(appProperty) == true && (CheckTotalSandboxSwitchStatus(appProperty) == true)) {
1167 rc = DoSandboxFileCommonSymlink(appProperty, config);
1168 APPSPAWN_CHECK(rc == 0, return rc, "DoSandboxFileCommonSymlink failed, %{public}s", GetBundleName(appProperty));
1171 rc = DoSandboxFileCommonFlagsPointHandle(appProperty, config);
1177 int32_t SandboxUtils::SetCommonAppSandboxProperty(const AppSpawningCtx *appProperty,
1181 SandboxConfigType type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ?
1185 ret = SetCommonAppSandboxProperty_(appProperty, jsonConfig);
1190 ret = MountAllHsp(appProperty, sandboxPackagePath);
1193 ret = MountAllGroup(appProperty, sandboxPackagePath);
1197 reinterpret_cast<AppSpawnMsgDomainInfo *>(GetAppProperty(appProperty, TLV_DOMAIN_INFO));
1201 CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ACCESS_BUNDLE_DIR)) {
1216 std::string SandboxUtils::GetExtraInfoByType(const AppSpawningCtx *appProperty, const std::string &type)
1219 char *info = reinterpret_cast<char *>(GetAppPropertyExt(appProperty, type.c_str(), &len));
1226 int32_t SandboxUtils::MountAllHsp(const AppSpawningCtx *appProperty, std::string &sandboxPackagePath)
1229 string hspListInfo = GetExtraInfoByType(appProperty, HSPLIST_SOCKET_TYPE);
1245 GetBundleName(appProperty), static_cast<unsigned long>(bundles.size()));
1282 int32_t SandboxUtils::MountAllGroup(const AppSpawningCtx *appProperty, std::string &sandboxPackagePath)
1285 string dataGroupInfo = GetExtraInfoByType(appProperty, DATA_GROUP_SOCKET_TYPE);
1301 GetBundleName(appProperty), static_cast<unsigned long>(dataGroupIds.size()));
1317 if (CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX)) {
1327 int32_t SandboxUtils::DoSandboxRootFolderCreate(const AppSpawningCtx *appProperty,
1392 bool SandboxUtils::CheckTotalSandboxSwitchStatus(const AppSpawningCtx *appProperty)
1394 SandboxConfigType type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ?
1411 bool SandboxUtils::CheckAppSandboxSwitchStatus(const AppSpawningCtx *appProperty)
1414 SandboxConfigType type = CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ?
1422 if (privateAppConfig.find(GetBundleName(appProperty)) != privateAppConfig.end()) {
1423 nlohmann::json& appConfig = privateAppConfig[GetBundleName(appProperty)][0];
1445 int32_t SandboxUtils::SetOverlayAppSandboxProperty(const AppSpawningCtx *appProperty,
1449 if (!CheckAppMsgFlagsSet(appProperty, APP_FLAGS_OVERLAY)) {
1453 string overlayInfo = GetExtraInfoByType(appProperty, OVERLAY_SOCKET_TYPE);
1482 int32_t SandboxUtils::SetBundleResourceAppSandboxProperty(const AppSpawningCtx *appProperty,
1486 if (!CheckAppMsgFlagsSet(appProperty, APP_FLAGS_BUNDLE_RESOURCES)) {
1516 int32_t SandboxUtils::SetSandboxProperty(AppSpawningCtx *appProperty, std::string &sandboxPackagePath)
1519 const std::string bundleName = GetBundleName(appProperty);
1520 ret = SetCommonAppSandboxProperty(appProperty, sandboxPackagePath);
1524 ret = SetPrivateAppSandboxProperty(appProperty);
1528 ret = SetPermissionAppSandboxProperty(appProperty);
1532 ret = SetOverlayAppSandboxProperty(appProperty, sandboxPackagePath);
1536 ret = SetBundleResourceAppSandboxProperty(appProperty, sandboxPackagePath);
1567 static inline int EnableSandboxNamespace(AppSpawningCtx *appProperty, uint32_t sandboxNsFlags)
1570 APPSPAWN_CHECK(rc == 0, return rc, "unshare failed, packagename is %{public}s", GetBundleName(appProperty));
1574 APPSPAWN_CHECK(rc == 0, return rc, "Set new netnamespace failed %{public}s", GetBundleName(appProperty));
1579 int32_t SandboxUtils::SetPermissionWithParam(AppSpawningCtx *appProperty)
1591 (CheckAppPermissionFlagSet(appProperty, static_cast<uint32_t>(fileMgrIndex)) == 0)) {
1592 return SetAppPermissionFlags(appProperty, index);
1608 int32_t SandboxUtils::SetAppSandboxProperty(AppSpawningCtx *appProperty, uint32_t sandboxNsFlags)
1610 APPSPAWN_CHECK(appProperty != nullptr, return -1, "Invalid appspwn client");
1611 if (CheckBundleName(GetBundleName(appProperty)) != 0) {
1614 AppSpawnMsgDacInfo *dacInfo = reinterpret_cast<AppSpawnMsgDacInfo *>(GetAppProperty(appProperty, TLV_DAC_INFO));
1620 const std::string bundleName = GetBundleName(appProperty);
1621 bool sandboxSharedStatus = GetSandboxPrivateSharedStatus(bundleName, appProperty) ||
1622 (CheckAppPermissionFlagSet(appProperty, static_cast<uint32_t>(GetPermissionIndex(nullptr,
1624 sandboxPackagePath += CheckAppMsgFlagsSet(appProperty, APP_FLAGS_ISOLATED_SANDBOX_TYPE) ? "isolated/" : "";
1629 int rc = EnableSandboxNamespace(appProperty, sandboxNsFlags);
1632 if (SetPermissionWithParam(appProperty) != 0) {
1637 if ((CheckTotalSandboxSwitchStatus(appProperty) == false) ||
1638 (CheckAppSandboxSwitchStatus(appProperty) == false)) {
1641 rc = DoSandboxRootFolderCreate(appProperty, sandboxPackagePath);
1644 rc = SetSandboxProperty(appProperty, sandboxPackagePath);
1662 int32_t SandboxUtils::SetAppSandboxPropertyNweb(AppSpawningCtx *appProperty, uint32_t sandboxNsFlags)
1664 APPSPAWN_CHECK(appProperty != nullptr, return -1, "Invalid appspwn client");
1665 if (CheckBundleName(GetBundleName(appProperty)) != 0) {
1669 const std::string bundleName = GetBundleName(appProperty);
1670 bool sandboxSharedStatus = GetSandboxPrivateSharedStatus(bundleName, appProperty);
1675 int rc = EnableSandboxNamespace(appProperty, sandboxNsFlags);
1679 if ((CheckTotalSandboxSwitchStatus(appProperty) == false) ||
1680 (CheckAppSandboxSwitchStatus(appProperty) == false)) {
1683 rc = DoSandboxRootFolderCreate(appProperty, sandboxPackagePath);
1690 rc = SetRenderSandboxPropertyNweb(appProperty, sandboxPackagePath);
1694 rc = SetOverlayAppSandboxProperty(appProperty, sandboxPackagePath);
1698 rc = SetBundleResourceAppSandboxProperty(appProperty, sandboxPackagePath);