Lines Matching defs:path

112     const char *g_srcPath = "src-path";
113 const char *g_sandBoxPath = "sandbox-path";
200 static void MakeDirRecursive(const std::string &path, mode_t mode)
202 size_t size = path.size();
209 size_t pathIndex = path.find_first_of('/', index);
211 std::string dir = path.substr(0, index);
219 static bool CheckDirRecursive(const std::string &path)
221 size_t size = path.size();
227 size_t pathIndex = path.find_first_of('/', index);
229 std::string dir = path.substr(0, index);
244 std::string path = file;
245 auto pos = path.find_last_of('/');
247 std::string dir = path.substr(0, pos);
378 static void MakeAtomicServiceDir(const AppSpawningCtx *appProperty, std::string path)
381 if (stat(path.c_str(), &st) == 0 && S_ISDIR(st.st_mode)) {
384 int ret = mkdir(path.c_str(), S_IRWXU);
385 APPSPAWN_CHECK(ret == 0, return, "mkdir %{public}s failed, errno %{public}d", path.c_str(), errno);
387 if (path.find("/database") != std::string::npos) {
388 ret = chmod(path.c_str(), S_IRWXU | S_IRWXG | S_ISGID);
389 } else if (path.find("/log") != std::string::npos) {
390 ret = chmod(path.c_str(), S_IRWXU | S_IRWXG);
392 APPSPAWN_CHECK(ret == 0, return, "chmod %{public}s failed, errno %{public}d", path.c_str(), errno);
400 hapFileInfo.pathNameOrig.push_back(path);
407 if ((path.find("/base") != std::string::npos) || (path.find("/database") != std::string::npos)) {
410 path.c_str(), hapFileInfo.apl.c_str(), ret);
415 if (path.find("/base") != std::string::npos) {
416 ret = chown(path.c_str(), dacInfo->uid, dacInfo->gid);
417 } else if (path.find("/database") != std::string::npos) {
418 ret = chown(path.c_str(), dacInfo->uid, APP_DATABASE_DIR_GID);
419 } else if (path.find("/log") != std::string::npos) {
420 ret = chown(path.c_str(), dacInfo->uid, APP_LOG_DIR_GID);
422 APPSPAWN_CHECK(ret == 0, return, "chown %{public}s failed, errno %{public}d", path.c_str(), errno);
426 static std::string ReplaceVariablePackageName(const AppSpawningCtx *appProperty, const std::string &path)
428 std::string tmpSandboxPath = path;
464 std::string atomicServicePath = path;
478 string SandboxUtils::ConvertToRealPath(const AppSpawningCtx *appProperty, std::string path)
486 if (path.find(g_packageNameIndex) != std::string::npos) {
491 path = replace_all(path, g_packageNameIndex, bundleNameWithIndex);
494 if (path.find(g_packageName) != std::string::npos) {
495 path = replace_all(path, g_packageName, info->bundleName);
498 if (path.find(g_userId) != std::string::npos) {
499 path = replace_all(path, g_userId, std::to_string(dacInfo->uid / UID_BASE));
502 if (path.find(g_variablePackageName) != std::string::npos) {
503 path = ReplaceVariablePackageName(appProperty, path);
506 if (path.find(g_arkWebPackageName) != std::string::npos) {
507 path = replace_all(path, g_arkWebPackageName, getArkWebPackageName());
509 "arkWeb sandbox, path %{public}s, package:%{public}s",
510 path.c_str(), getArkWebPackageName().c_str());
513 return path;
517 std::string path)
524 if (path.find(g_packageNameIndex) != std::string::npos) {
529 path = replace_all(path, g_packageNameIndex, bundleNameWithIndex);
532 if (path.find(g_packageName) != std::string::npos) {
533 path = replace_all(path, g_packageName, info->bundleName);
536 if (path.find(g_userId) != std::string::npos) {
538 path = replace_all(path, g_userId, "currentUser");
540 path = replace_all(path, g_userId, "currentUser");
545 return path;
648 // umount fuse path, make sure that sandbox path is not a mount point
1255 return -1, "MountAllHsp: path error");
1273 // bind mount "/" to /mnt/sandbox/<currentUserId>/<packageName> path
1308 APPSPAWN_CHECK(!CheckPath(libPhysicalPath), return -1, "MountAllGroup: path error");
1311 APPSPAWN_CHECK(lastPathSplitPos != std::string::npos, return -1, "MountAllGroup: path error");
1473 APPSPAWN_LOGE("fail to mount overlay path, src is %{public}s.", hapPath.c_str());
1548 APPSPAWN_CHECK(ret == 0, return ret, "chdir failed, packagename is %{public}s, path is %{public}s",
1553 APPSPAWN_CHECK(ret == 0, return ret, "chroot failed, path is %{public}s errno is %{public}d",
1704 APPSPAWN_CHECK(rc == 0, return rc, "chdir failed, packagename is %{public}s, path is %{public}s",
1709 APPSPAWN_CHECK(rc == 0, return rc, "chroot failed, path is %{public}s errno is %{public}d",
1750 std::string path = files->paths[i];
1751 std::string appPath = path + OHOS::AppSpawn::APP_JSON_CONFIG;
1757 std::string isolatedPath = path + OHOS::AppSpawn::APP_ISOLATED_JSON_CONFIG;
1822 char *path = reinterpret_cast<char *>(malloc(sizeof(char) * allPathSize));
1823 APPSPAWN_CHECK(path != NULL, return true, "Failed to malloc path");
1824 int len = sprintf_s(path, allPathSize, "%s%u%s%s", rootPath, uid, basePath, bundleName);
1825 APPSPAWN_CHECK(len > 0 && ((size_t)len < allPathSize), free(path);
1826 return true, "Failed to get base path");
1828 if (access(path, F_OK) == 0) {
1830 free(path);
1833 free(path);
1849 char *path = reinterpret_cast<char *>(malloc(sizeof(char) * (allPathSize)));
1850 APPSPAWN_CHECK(path != NULL, return, "Failed to malloc path");
1851 int len = sprintf_s(path, allPathSize, "%s%u/%s%s", rootPath, info->uid / userIdBase, bundleName, targetPath);
1852 APPSPAWN_CHECK(len > 0 && ((size_t)len < allPathSize), free(path);
1853 return, "Failed to get sandbox path");
1855 if (access(path, F_OK) == 0 && srcPath == nullptr) {
1856 free(path);
1860 MakeDirRec(path, DIR_MODE, 1);
1861 const char *sourcePath = (srcPath == nullptr) ? path : srcPath;
1863 int ret = umount2(path, MNT_DETACH);
1864 APPSPAWN_CHECK_ONLY_LOG(ret == 0, "Failed to umount path %{public}s, errno %{public}d", path, errno);
1867 if (mount(sourcePath, path, nullptr, MS_BIND | MS_REC, nullptr) != 0) {
1868 APPSPAWN_LOGI("bind mount %{public}s to %{public}s failed, error %{public}d", sourcePath, path, errno);
1869 free(path);
1872 if (mount(nullptr, path, nullptr, MS_SHARED, nullptr) != 0) {
1873 APPSPAWN_LOGI("mount path %{public}s to shared failed, errno %{public}d", path, errno);
1874 free(path);
1877 APPSPAWN_LOGI("mount path %{public}s to shared success", path);
1878 free(path);