gid_t gid,
const char* const label,
const char* const name) {
- auto ret = checkItem<NaivePolicyDb::PolicyOwn, ItemOwn>(bus_type, uid, gid, name, ItemType::OWN);
+ auto ret = checkItem<NaivePolicyDb::PolicyOwn, MatchItemOwn>(bus_type, uid, gid, name, ItemType::OWN);
return parseDecision(ret, uid, label);
}
return Decision::ANY;
}
-DecisionItem NaivePolicyChecker::checkPolicy(const NaivePolicyDb::PolicyOwn& policy, const ItemOwn& item) const
+DecisionItem NaivePolicyChecker::checkPolicy(const NaivePolicyDb::PolicyOwn& policy, const MatchItemOwn& item) const
{
- tslog::log_verbose("Checking policy for name: ", std::string(item.getName() ? item.getName() : "NULL"), "\n");
+ tslog::log_verbose("Checking policy for name: ", std::string(item.getName().empty() ? "NULL" : item.getName()), "\n");
return policy.getDecisionItem(item);
}
* \ingroup Implementation
*/
DecisionItem checkPolicy(const NaivePolicyDb::PolicyOwn& policy,
- const ItemOwn& item) const;
+ const MatchItemOwn& item) const;
/** Checks access policy for given item
* \param[in] policy Policy to check
ownership_tree.printTree();
}
-DecisionItem NaivePolicyDb::PolicyOwn::getDecisionItem(const ItemOwn& item) const
+DecisionItem NaivePolicyDb::PolicyOwn::getDecisionItem(const MatchItemOwn& item) const
{
return ownership_tree.getDecisionItem(item);
}
* \param[in] item Item to add to policy
*/
void addItem(ItemOwn* item);
- DecisionItem getDecisionItem(const ItemOwn& item) const;
+ DecisionItem getDecisionItem(const MatchItemOwn& item) const;
void printContent() const;
size_t getSize() const;
};
__root->add(tokens, item->getDecision(), item->isPrefix());
}
-DecisionItem OwnershipTree::getDecisionItem(const ItemOwn& item) const
+DecisionItem OwnershipTree::getDecisionItem(const MatchItemOwn& item) const
{
- if (item.getName() == nullptr) {
+ if (item.getName().length() == 0) {
return Decision::DENY;
}
- std::string name = item.getName();
- auto tokens = tokenize(name);
+ auto tokens = tokenize(item.getName());
return __root->getDecisionItem(tokens);
}
public:
OwnershipTree();
void addItem(ItemOwn* item);
- DecisionItem getDecisionItem(const ItemOwn& item) const;
+ DecisionItem getDecisionItem(const MatchItemOwn& item) const;
void printTree() const;
size_t getSize() const;
"), pref(" << item.__is_prefix << ")";
}
+std::ostream &operator<<(std::ostream& stream, const MatchItemOwn &item)
+{
+ return stream << (item._name.empty() ? "NULL" : item._name);
+}
+
std::ostream &operator<<(std::ostream& stream, const MatchItemSR &item)
{
stream << "matcher: services(";
};
std::ostream &operator<<(std::ostream& stream, const DecisionItem &di);
+ class MatchItemOwn {
+ private:
+ std::string _name;
+ public:
+ MatchItemOwn(const char *name) : _name(name) {}
+ const std::string &getName() const { return _name; }
+
+ friend std::ostream &operator<<(std::ostream& stream, const MatchItemOwn &item);
+ };
+ std::ostream &operator<<(std::ostream& stream, const MatchItemOwn &item);
+
/** Class contains info about ownership policy item */
class ItemOwn {
private: