+ "` file/directory");
}
+static void change_permissions(std::string_view path, mode_t mode)
+{
+ if (chmod(path.data(), mode) == -1)
+ throw std::system_error(errno, std::system_category(),
+ "Couldn't set owner/group permissions of the `"s
+ + path.data()
+ + "` file/directory");
+}
+
static void copy_ownership(std::string_view src_path, std::string_view dest_path)
{
struct stat info;
+ "` file/directory");
change_owner_and_group(dest_path, info.st_uid, info.st_gid);
+ change_permissions(dest_path, info.st_mode);
}
static std::string get_smack_label(std::string_view src_path, smack_label_type type)
}
// Last but not least - the `apps_rw` directory itself
- change_owner_and_group(apps_rw_dir, session_uid, main_dir_gid);
+ copy_ownership(home_dir + "/apps_rw", apps_rw_dir);
copy_smack_attributes(source_dir, apps_rw_dir);
// Copy + rename so that the replacement is atomic