diff --git a/core/src/main/cpp/main/include/utils.h b/core/src/main/cpp/main/include/utils.h index 2525d8df..3e4cb660 100644 --- a/core/src/main/cpp/main/include/utils.h +++ b/core/src/main/cpp/main/include/utils.h @@ -58,4 +58,15 @@ namespace lspd { stat(path.c_str(), &sb); return {sb.st_uid, sb.st_gid}; } + + inline void recursive_permissions(const std::filesystem::path &p, + std::filesystem::perms prms, + std::filesystem::perm_options opts = std::filesystem::perm_options::replace) { + std::filesystem::permissions(p, prms, opts); + if (std::filesystem::is_directory(p)) { + for(auto &item : std::filesystem::recursive_directory_iterator(p)) { + std::filesystem::permissions(item.path(), prms, opts); + } + } + } } diff --git a/core/src/main/cpp/main/src/config_manager.cpp b/core/src/main/cpp/main/src/config_manager.cpp index 9b2101c7..1c4805ef 100644 --- a/core/src/main/cpp/main/src/config_manager.cpp +++ b/core/src/main/cpp/main/src/config_manager.cpp @@ -271,15 +271,15 @@ namespace lspd { if (!path_exists(log_path)) { fs::create_directories(log_path); } - fs::permissions(conf_path, fs::perms::owner_all | fs::perms::group_all | fs::perms::set_gid); - fs::permissions(log_path, fs::perms::owner_all | fs::perms::group_all | fs::perms::set_gid); + recursive_permissions(conf_path, fs::perms::owner_all | fs::perms::group_all | fs::perms::set_gid); + recursive_permissions(log_path, fs::perms::owner_all | fs::perms::group_all | fs::perms::set_gid); if (pkg_name == "android") uid = -1; path_chown(conf_path, uid, 1000u, true); path_chown(log_path, uid, 1000u, true); if (current_user_ == 0) { auto variant = GetMiscPath() / "variant"; fs::permissions(variant, fs::perms::owner_all | fs::perms::group_all); - chown(variant.c_str(), uid, 1000u); + path_chown(variant, uid, 1000u); } if (pkg_name == kPrimaryInstallerPkgName) {