Merge PR #37190 into master

* refs/pull/37190/head:
	mon/MonCap: check profile_grants too while checking caps

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2020-09-18 17:27:09 -07:00
commit 22b3d48fa0
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
2 changed files with 14 additions and 5 deletions

View File

@ -195,13 +195,22 @@ struct MonCap {
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;
}
}

View File

@ -112,7 +112,7 @@ struct MonSession : public RefCountedObject {
}
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() {