if (std::find(gids.begin(), gids.end(), caller_gid) == gids.end())
return false;
}
+
+ if (!match_path(target_path)) {
+ return false;
+ }
+
+ return true;
+}
+
+bool MDSCapMatch::match_path(const std::string &target_path) const
+{
if (path.length()) {
if (target_path.find(path) != 0)
return false;
target_path[path.length()] != '/')
return false;
}
+
return true;
}
+/**
+ * Is the client *potentially* able to access this path? Actual
+ * permission will depend on uids/modes in the full is_capable.
+ */
+bool MDSAuthCaps::path_capable(const std::string &inode_path) const
+{
+ for (const auto &i : grants) {
+ if (i.match.match_path(inode_path)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
/**
* For a given filesystem path, query whether this capability carries`
* authorization to read or write.
bool match(const std::string &target_path,
const int caller_uid,
const int caller_gid) const;
+
+ bool match_path(const std::string &target_path) const;
};
struct MDSCapGrant {
uid_t inode_uid, gid_t inode_gid, unsigned inode_mode,
uid_t uid, gid_t gid, unsigned mask,
uid_t new_uid, gid_t new_gid) const;
+ bool path_capable(const std::string &inode_path) const;
friend std::ostream &operator<<(std::ostream &out, const MDSAuthCaps &cap);
};