#include "internal.h"
#include "tslog.hpp"
+using namespace ldp_xml_parser;
+
static const char* get_str(const char* const szstr) {
return (szstr != NULL) ? szstr : "";
}
const char* const member,
int type)
{
- ldp_xml_parser::MatchItemSend matcher(interface, member, path, static_cast<ldp_xml_parser::MessageType>(type));
+ MatchItemSend matcher(interface, member, path, static_cast<MessageType>(type));
if (!matcher.addNames(destination)) {
tslog::log_verbose("Destination too long: ", destination, "\n");
return false;
int type)
{
int i = 0;
- ldp_xml_parser::MatchItemSend matcher(interface, member, path, static_cast<ldp_xml_parser::MessageType>(type));
+ MatchItemSend matcher(interface, member, path, static_cast<MessageType>(type));
if (destination)
while (destination[i]) {
matcher.addName(destination[i++]);
const char* const member,
int type)
{
- ldp_xml_parser::MatchItemReceive matcher(interface, member, path, static_cast<ldp_xml_parser::MessageType>(type));
+ MatchItemReceive matcher(interface, member, path, static_cast<MessageType>(type));
if (!matcher.addNames(sender)) {
tslog::log_verbose("Sender too long: ", sender, "\n");
return false;
int type)
{
int i = 0;
- ldp_xml_parser::MatchItemReceive matcher(interface, member, path, static_cast<ldp_xml_parser::MessageType>(type));
+ MatchItemReceive matcher(interface, member, path, static_cast<MessageType>(type));
if (sender)
while (sender[i]) {
matcher.addName(sender[i++]);
const char* const label,
const char* const service)
{
- return static_cast<int>(policy_checker().check(bus_type, user, group, label, service));
+ return static_cast<int>(policy_checker().check(bus_type, user, group, label, MatchItemOwn(service)));
}
return parseDecision(ret, uid, label);
}
+template <typename T>
DecisionResult NaivePolicyChecker::check(bool bus_type,
uid_t uid,
gid_t gid,
const char* const label,
- const char* const name) {
- auto ret = checkItem(bus_type, uid, gid, MatchItemOwn(name));
- return parseDecision(ret, uid, label);
-}
-
-DecisionResult NaivePolicyChecker::check(bool bus_type,
- uid_t uid,
- gid_t gid,
- const char* const label,
- MatchItemSend &matcher) {
- auto ret = checkItem(bus_type, uid, gid, matcher);
- return parseDecision(ret, uid, label);
-}
-
-DecisionResult NaivePolicyChecker::check(bool bus_type,
- uid_t uid,
- gid_t gid,
- const char* const label,
- MatchItemReceive &matcher) {
- auto ret = checkItem(bus_type, uid, gid, matcher);
+ const T &matchItem) {
+ auto ret = checkItem(bus_type, uid, gid, matchItem);
return parseDecision(ret, uid, label);
}
+template DecisionResult NaivePolicyChecker::check(bool, uid_t, gid_t, const char *, const MatchItemOwn &);
+template DecisionResult NaivePolicyChecker::check(bool, uid_t, gid_t, const char *, const MatchItemSend &);
+template DecisionResult NaivePolicyChecker::check(bool, uid_t, gid_t, const char *, const MatchItemReceive &);
template<typename T>
DecisionItem NaivePolicyChecker::checkItem(bool bus_type, uid_t uid, gid_t gid, const T& item) {
gid_t gid,
const char* const label);
- /** Checks ownership policy for given item
+ /** Checks send/receive/ownership policy for given item
* \param[in] bus_type Bus type (system/session)
* \param[in] uid User id
* \param[in] gid User group id
* \param[in] label User label
- * \param[in] name Name to own
+ * \param[in] matchItem MatchItem to check
* \return Returns deny=0, allow=1 or cynara error
* \ingroup Implementation
*/
+ template <typename T>
DecisionResult check(bool bus_type,
uid_t uid,
gid_t gid,
const char* const label,
- const char* const name);
-
- /** Checks send/receive policy for given item
- * \param[in] bus_type Bus type (system/session)
- * \param[in] uid User id
- * \param[in] gid User group id
- * \param[in] label User label
- * \param[in] matcher Structure with multiple names to check
- * \return Returns deny=0, allow=1 or cynara error
- * \ingroup Implementation
- */
- DecisionResult check(bool bus_type,
- uid_t uid,
- gid_t gid,
- const char* const label,
- MatchItemSend &matcher);
-
- DecisionResult check(bool bus_type,
- uid_t uid,
- gid_t gid,
- const char* const label,
- MatchItemReceive &matcher);
+ const T &matchItem);
};
}