// capspec = * | r[w]
capspec = spaces >> (
- lit("*")[_val = MDSCapSpec(true, true, true)]
+ lit("*")[_val = MDSCapSpec(true, true, true, true)]
|
- (lit("rw"))[_val = MDSCapSpec(true, true, false)]
+ (lit("rwp"))[_val = MDSCapSpec(true, true, false, true)]
|
- (lit("r"))[_val = MDSCapSpec(true, false, false)]
+ (lit("rw"))[_val = MDSCapSpec(true, true, false, false)]
+ |
+ (lit("r"))[_val = MDSCapSpec(true, false, false, false)]
);
grant = lit("allow") >> (capspec >> match)[_val = phoenix::construct<MDSCapGrant>(_1, _2)];
if (i->match.match(inode_path, caller_uid, caller_gid) &&
i->spec.allows(mask & (MAY_READ|MAY_EXECUTE), mask & MAY_WRITE)) {
+ // Spec is non-allowing if caller asked for set pool but spec forbids it
+ if (mask & MAY_SET_POOL) {
+ if (!i->spec.allows_set_pool()) {
+ continue;
+ }
+ }
+
// check unix permissions?
if (i->match.uid == MDSCapMatch::MDS_AUTH_UID_ANY) {
return true;
void MDSAuthCaps::set_allow_all()
{
grants.clear();
- grants.push_back(MDSCapGrant(MDSCapSpec(true, true, true), MDSCapMatch()));
+ grants.push_back(MDSCapGrant(
+ MDSCapSpec(true, true, true, true),
+ MDSCapMatch()));
}
bool MDSAuthCaps::parse(CephContext *c, const std::string& str, ostream *err)
// Special case for legacy caps
if (str == "allow") {
grants.clear();
- grants.push_back(MDSCapGrant(MDSCapSpec(true, true, false), MDSCapMatch()));
+ grants.push_back(MDSCapGrant(MDSCapSpec(true, true, false, true), MDSCapMatch()));
return true;
}
MAY_WRITE = 2,
MAY_EXECUTE = 4,
MAY_CHOWN = 16,
- MAY_CHGRP = 32
+ MAY_CHGRP = 32,
+ MAY_SET_POOL = 64,
};
class CephContext;
struct MDSCapSpec {
bool read, write, any;
- MDSCapSpec() : read(false), write(false), any(false) {}
- MDSCapSpec(bool r, bool w, bool a) : read(r), write(w), any(a) {}
+ // True if the capability permits modifying the pool on file layouts
+ bool layout_pool;
+
+ MDSCapSpec() : read(false), write(false), any(false), layout_pool(false) {}
+ MDSCapSpec(bool r, bool w, bool a, bool lop)
+ : read(r), write(w), any(a), layout_pool(lop) {}
bool allow_all() const {
return any;
}
+
bool allows(bool r, bool w) const {
if (any)
return true;
return false;
return true;
}
+
+ bool allows_set_pool() const {
+ return layout_pool;
+ }
};
// conditions before we are allowed to do it