bool SetDirectoryOwnerAndPermissions(const bf::path& subpath, uid_t uid,
gid_t gid) {
- bf::perms perms = bf::owner_read |
- bf::owner_write |
- bf::group_read;
- // symlink will be skipped
- if (bf::is_symlink(symlink_status(subpath)))
+ // symlink and non directory will be skipped
+ if (bf::is_symlink(symlink_status(subpath)) || !bf::is_directory(subpath))
return true;
- // non directory will be skipped
- bool result = true;
- if (bf::is_directory(subpath)) {
- perms |= bf::owner_exe | bf::group_exe | bf::others_read | bf::others_exe;
- if (subpath.filename() == "data" || subpath.filename() == "cache") {
- perms |= bf::group_write | bf::set_gid_on_exe;
- boost::optional<gid_t> system_share =
- ci::GetGidByGroupName(kSystemShareGroupName);
- if (!system_share)
- return false;
- gid = *system_share;
- }
- result = common_installer::SetDirOwnershipAndPermissions(subpath, perms,
- uid, gid);
+ bf::perms perms = bf::all_all ^ bf::group_write ^ bf::others_write;
+ if (subpath.filename() == "data" || subpath.filename() == "cache") {
+ perms |= bf::group_write | bf::set_gid_on_exe;
+ boost::optional<gid_t> system_share =
+ ci::GetGidByGroupName(kSystemShareGroupName);
+ if (!system_share)
+ return false;
+ gid = *system_share;
}
-
- return result;
+ return common_installer::SetDirOwnershipAndPermissions(subpath, perms,
+ uid, gid);
}
bool CreateDirectories(const bf::path& app_dir, const std::string& pkgid,
return true;
}
-
bool CopyUserDirectories(const std::string& pkgid) {
UserList list = ci::GetUserList();
for (auto l : list) {
manifest_x* manifest = context_->manifest_data.get();
bool shareddata = ShouldSupportLegacySharedDataDir(manifest->api_version);
- for (auto& priv : GListRange<privilege_x*>(manifest->privileges)) {
- if (!strcmp(priv->value, privileges::kPrivForSharedData)) {
- shareddata = true;
- break;
+ if (!shareddata) {
+ for (auto& priv : GListRange<privilege_x*>(manifest->privileges)) {
+ if (!strcmp(priv->value, privileges::kPrivForSharedData)) {
+ shareddata = true;
+ break;
+ }
}
}
}
bool ShouldCreateSharedDataDir(manifest_x* manifest) {
- bool shareddata = ci::ShouldSupportLegacySharedDataDir(manifest->api_version);
+ if (ci::ShouldSupportLegacySharedDataDir(manifest->api_version))
+ return true;
+
for (auto& priv : GListRange<privilege_x*>(manifest->privileges)) {
- if (!strcmp(priv->value, ci::privileges::kPrivForSharedData)) {
- shareddata = true;
- break;
- }
+ if (!strcmp(priv->value, ci::privileges::kPrivForSharedData))
+ return true;
}
- return shareddata;
+
+ return false;
}
} // namespace