#include "include/ceph_assert.h"
+using std::list;
+using std::map;
+using std::ostream;
+using std::pair;
+using std::string;
+using std::vector;
+
+using ceph::bufferlist;
+using ceph::Formatter;
+
static inline bool is_not_alnum_space(char c)
{
return !(isalpha(c) || isdigit(c) || (c == '-') || (c == '_'));
}
-static string maybe_quote_string(const std::string& str)
+static std::string maybe_quote_string(const std::string& str)
{
if (find_if(str.begin(), str.end(), is_not_alnum_space) == str.end())
return str;
return string("\"") + str + string("\"");
}
-using std::ostream;
-using std::vector;
-
#define dout_subsys ceph_subsys_mon
ostream& operator<<(ostream& out, const mon_rwxa_t& p)
out << " command " << maybe_quote_string(m.command);
if (!m.command_args.empty()) {
out << " with";
- for (map<string,StringConstraint>::const_iterator p = m.command_args.begin();
+ for (auto p = m.command_args.begin();
p != m.command_args.end();
++p) {
switch (p->second.match_type) {
StringConstraint constraint(StringConstraint::MATCH_TYPE_PREFIX,
string("daemon-private/") + stringify(name) +
string("/"));
- string prefix = string("daemon-private/") + stringify(name) + string("/");
+ std::string prefix = string("daemon-private/") + stringify(name) + string("/");
profile_grants.push_back(MonCapGrant("config-key get", "key", constraint));
profile_grants.push_back(MonCapGrant("config-key put", "key", constraint));
profile_grants.push_back(MonCapGrant("config-key set", "key", constraint));
if (profile.length()) {
expand_profile(daemon_type, name);
mon_rwxa_t a;
- for (list<MonCapGrant>::const_iterator p = profile_grants.begin();
+ for (auto p = profile_grants.begin();
p != profile_grants.end(); ++p)
a = a | p->get_allowed(cct, daemon_type, name, s, c, c_args);
return a;
void MonCap::decode(bufferlist::const_iterator& bl)
{
- string s;
+ std::string s;
DECODE_START(4, bl);
decode(s, bl);
DECODE_FINISH(bl);
#define CEPH_MONCAP_H
#include <ostream>
-using std::ostream;
#include "include/types.h"
#include "common/entity_name.h"
}
};
-ostream& operator<<(ostream& out, const mon_rwxa_t& p);
+std::ostream& operator<<(std::ostream& out, const mon_rwxa_t& p);
struct StringConstraint {
enum MatchType {
};
MatchType match_type = MATCH_TYPE_NONE;
- string value;
+ std::string value;
StringConstraint() {}
- StringConstraint(MatchType match_type, string value)
+ StringConstraint(MatchType match_type, std::string value)
: match_type(match_type), value(value) {
}
};
-ostream& operator<<(ostream& out, const StringConstraint& c);
+std::ostream& operator<<(std::ostream& out, const StringConstraint& c);
struct MonCapGrant {
/*
std::string service;
std::string profile;
std::string command;
- map<std::string,StringConstraint> command_args;
+ std::map<std::string, StringConstraint> command_args;
// restrict by network
std::string network;
// explicit grants that a profile grant expands to; populated as
// needed by expand_profile() (via is_match()) and cached here.
- mutable list<MonCapGrant> profile_grants;
+ mutable std::list<MonCapGrant> profile_grants;
void expand_profile(int daemon_type, const EntityName& name) const;
void expand_profile_mon(const EntityName& name) const;
MonCapGrant() : allow(0) {}
// cppcheck-suppress noExplicitConstructor
MonCapGrant(mon_rwxa_t a) : allow(a) {}
- MonCapGrant(string s, mon_rwxa_t a) : service(std::move(s)), allow(a) {}
- // cppcheck-suppress noExplicitConstructor
- MonCapGrant(string c) : command(std::move(c)) {}
- MonCapGrant(string c, string a, StringConstraint co) : command(std::move(c)) {
+ MonCapGrant(std::string s, mon_rwxa_t a) : service(std::move(s)), allow(a) {}
+ // cppcheck-suppress noExplicitConstructor
+ MonCapGrant(std::string c) : command(std::move(c)) {}
+ MonCapGrant(std::string c, std::string a, StringConstraint co) : command(std::move(c)) {
command_args[a] = co;
}
EntityName name,
const std::string& service,
const std::string& command,
- const map<string,string>& command_args) const;
+ const std::map<std::string, std::string>& command_args) const;
bool is_allow_all() const {
return
}
};
-ostream& operator<<(ostream& out, const MonCapGrant& g);
+std::ostream& operator<<(std::ostream& out, const MonCapGrant& g);
struct MonCap {
- string text;
+ std::string text;
std::vector<MonCapGrant> grants;
MonCap() {}
explicit MonCap(const std::vector<MonCapGrant> &g) : grants(g) {}
- string get_str() const {
+ std::string get_str() const {
return text;
}
bool is_allow_all() const;
void set_allow_all();
- bool parse(const std::string& str, ostream *err=NULL);
+ bool parse(const std::string& str, std::ostream *err=NULL);
/**
* check if we are capable of something
bool is_capable(CephContext *cct,
int daemon_type,
EntityName name,
- const string& service,
- const string& command, const map<string,string>& command_args,
+ const std::string& service,
+ const std::string& command,
+ const std::map<std::string, std::string>& command_args,
bool op_may_read, bool op_may_write, bool op_may_exec,
const entity_addr_t& addr) const;
- void encode(bufferlist& bl) const;
- void decode(bufferlist::const_iterator& bl);
- void dump(Formatter *f) const;
- static void generate_test_instances(list<MonCap*>& ls);
+ void encode(ceph::buffer::list& bl) const;
+ void decode(ceph::buffer::list::const_iterator& bl);
+ void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<MonCap*>& ls);
};
WRITE_CLASS_ENCODER(MonCap)
-ostream& operator<<(ostream& out, const MonCap& cap);
+std::ostream& operator<<(std::ostream& out, const MonCap& cap);
#endif