From c7c5ad3265c0492fdb353c62284f22d16ed499f1 Mon Sep 17 00:00:00 2001 From: Adrian Szyndela Date: Wed, 6 Mar 2019 12:37:50 +0100 Subject: [PATCH] serialization: add missing method to serialized storage Change-Id: Ieb56be3dd3f303dca7c851c02757fe6ab5eb64ae --- src/internal/storage_backend_serialized.cpp | 10 ++++++++-- src/internal/storage_backend_serialized.hpp | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/internal/storage_backend_serialized.cpp b/src/internal/storage_backend_serialized.cpp index ae2b350..0590c4a 100644 --- a/src/internal/storage_backend_serialized.cpp +++ b/src/internal/storage_backend_serialized.cpp @@ -112,7 +112,7 @@ bool StorageBackendSerialized::StorageBackendSerializedImpl::init(const char *fi mmapGuard.dismiss(); file = GetFile(mem); - return true; + return file != nullptr; } bool StorageBackendSerialized::StorageBackendSerializedImpl::init(const FB::File *f) { @@ -258,6 +258,11 @@ ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemGroup(gid_ return getDecisionItemMaybeNull(item, pimpl->getPolicySet()->group()->LookupByKey(gid)); } +template +bool StorageBackendSerialized::existsPolicyForGroup(gid_t gid) const { + return pimpl->getPolicySet()->group()->LookupByKey(gid) != nullptr; +} + #define T_INSTANTIATION(T) \ template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemContextMandatory(const ldp_xml_parser::MatchItem##T &item) const; \ template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemContextDefault(const ldp_xml_parser::MatchItem##T &item) const; @@ -271,7 +276,8 @@ T_INSTANTIATION(Access) #define T_INSTANTIATION2(T) \ template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemUser(uid_t uid, const ldp_xml_parser::MatchItem##T &item) const; \ - template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemGroup(gid_t gid, const ldp_xml_parser::MatchItem##T &item) const; + template ldp_xml_parser::DecisionItem StorageBackendSerialized::getDecisionItemGroup(gid_t gid, const ldp_xml_parser::MatchItem##T &item) const; \ + template bool StorageBackendSerialized::existsPolicyForGroup(gid_t) const; T_INSTANTIATION2(Own) T_INSTANTIATION2(Send) diff --git a/src/internal/storage_backend_serialized.hpp b/src/internal/storage_backend_serialized.hpp index bf48dd7..2e5422d 100644 --- a/src/internal/storage_backend_serialized.hpp +++ b/src/internal/storage_backend_serialized.hpp @@ -31,6 +31,12 @@ public: ldp_xml_parser::DecisionItem getDecisionItemUser(uid_t uid, const T &item) const; template ldp_xml_parser::DecisionItem getDecisionItemGroup(gid_t gid, const T &item) const; + + // This works with T set to MatchItemOwn, MatchItemSend or MatchItemReceive + // This is needed for filtering mapGroups. Check NaivePolicyChecker. + template + bool existsPolicyForGroup(gid_t gid) const; + }; } -- 2.7.4