This commit is contained in:
LoveSy 2021-01-31 14:03:44 +08:00
parent 06a33303c3
commit 05cafca292
2 changed files with 14 additions and 3 deletions

View File

@ -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);
}
}
}
}

View File

@ -271,15 +271,15 @@ namespace lspd {
if (!path_exists<true>(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) {