When checking if a certain fs subcommand can and should be executed in
FSCommands.cc, check permissions in "profile_grants" too when the caps
for that entity contains a cap profile.
Fixes: https://tracker.ceph.com/issues/47423
Signed-off-by: Rishabh Dave <ridave@redhat.com>
return ret;
}
- bool fs_name_capable(string_view fs_name, __u8 mask) {
- for (auto& g: grants) {
+ bool fs_name_capable(const EntityName& ename, string_view fs_name,
+ __u8 mask) {
+ for (auto& g : grants) {
if (g.is_allow_all()) {
return true;
}
- if (g.fs_name.empty() || g.fs_name == fs_name) {
- if (mask & g.allow) {
+
+ if ((g.fs_name.empty() || g.fs_name == fs_name) && (mask & g.allow)) {
+ return true;
+ }
+
+ g.expand_profile(ename);
+ for (auto& pg : g.profile_grants) {
+ if ((pg.service == "fs" || pg.service == "mds") &&
+ (pg.fs_name.empty() || pg.fs_name == fs_name) &&
+ (pg.allow & mask)) {
return true;
}
}
}
bool fs_name_capable(string_view fsname, __u8 mask) {
- return caps.fs_name_capable(fsname, mask);
+ return caps.fs_name_capable(entity_name, fsname, mask);
}
const entity_addr_t& get_peer_socket_addr() {