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") {
+ 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);
namespace {
const char kSystemShareGroupName[] = "system_share";
-const char kDataDir[] = "data";
-const char kSharedDataDir[] = "shared/data";
+const std::vector<const char*> kDataDirEntries = {
+ {"data"},
+ {"shared/data"},
+ {"cache"},
+};
bool GrantPermission755(const bf::path& path) {
auto permission = bf::perms::owner_all |
}
bf::perms prms = bf::add_perms | bf::group_write | bf::set_gid_on_exe;
- bf::path data = pkg_path / kDataDir;
- if (!ci::SetOwnership(data, uid, *gid)) {
- LOG(ERROR) << "Failed to change owner: " << data
- << "(" << uid << ", " << *gid << ")";
- return false;
- }
- if (!ci::SetDirPermissions(data, prms)) {
- LOG(ERROR) << "Failed to change permission: " << data
- << std::oct << prms;
- return false;
- }
- bf::path shareddata = pkg_path / kSharedDataDir;
- if (!bf::exists(shareddata))
- return true;
- if (!ci::SetOwnership(shareddata, uid, *gid)) {
- LOG(ERROR) << "Failed to change owner: " << shareddata
- << "(" << uid << ", " << *gid << ")";
- return false;
- }
- if (!ci::SetDirPermissions(shareddata, prms)) {
- LOG(ERROR) << "Failed to change permission: " << shareddata
- << std::oct << prms;
- return false;
+ for (auto& entry : kDataDirEntries) {
+ bf::path path = pkg_path / entry;
+ if (!bf::exists(path))
+ continue;
+ if (!ci::SetOwnership(path, uid, *gid)) {
+ LOG(ERROR) << "Failed to change owner: " << path
+ << "(" << uid << ", " << *gid << ")";
+ return false;
+ }
+ if (!ci::SetDirPermissions(path, prms)) {
+ LOG(ERROR) << "Failed to change permission: " << path
+ << std::oct << prms;
+ return false;
+ }
}
return true;