diff options
Diffstat (limited to 'cpp/src/qpid/acl/AclPlugin.cpp')
-rw-r--r-- | cpp/src/qpid/acl/AclPlugin.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/cpp/src/qpid/acl/AclPlugin.cpp b/cpp/src/qpid/acl/AclPlugin.cpp index a025354f13..e4d721ea44 100644 --- a/cpp/src/qpid/acl/AclPlugin.cpp +++ b/cpp/src/qpid/acl/AclPlugin.cpp @@ -21,9 +21,9 @@ #include "qpid/broker/Broker.h" #include "qpid/Plugin.h" #include "qpid/Options.h" -#include "qpid/shared_ptr.h" #include "qpid/log/Statement.h" +#include <boost/shared_ptr.hpp> #include <boost/utility/in_place_factory.hpp> namespace qpid { @@ -36,13 +36,11 @@ using namespace std; * New boost allows a shared_ptr but that's not compatible with old boost. */ struct AclOptions : public Options { - AclValues& values; + AclValues& values; AclOptions(AclValues& v) : Options("ACL Options"), values(v) { addOptions() - ("no-enforce-acl", optValue(values.noEnforce), "Do not enforce ACL") - ("acl-file", optValue(values.aclFile, "FILE"), "The policy file to load from, loaded from data dir") - ; + ("acl-file", optValue(values.aclFile, "FILE"), "The policy file to load from, loaded from data dir"); } }; @@ -51,20 +49,25 @@ struct AclPlugin : public Plugin { AclValues values; AclOptions options; boost::intrusive_ptr<Acl> acl; - + AclPlugin() : options(values) {} Options* getOptions() { return &options; } void init(broker::Broker& b) { - if (values.noEnforce){ - QPID_LOG(info, "ACL Disabled, no ACL checking being done."); - return; - } - if (acl) throw Exception("ACL plugin cannot be initialized twice in one process."); - std::ostringstream oss; - oss << b.getDataDir().getPath() << "/" << values.aclFile; - values.aclFile = oss.str(); + if (values.aclFile.empty()){ + QPID_LOG(info, "Policy file not specified. ACL Disabled, no ACL checking being done!"); + return; + } + + if (acl) throw Exception("ACL plugin cannot be initialized twice in one process."); + + if (values.aclFile.at(0) != '/' && !b.getDataDir().getPath().empty()) { + std::ostringstream oss; + oss << b.getDataDir().getPath() << "/" << values.aclFile; + values.aclFile = oss.str(); + } + acl = new Acl(values, b); b.setAcl(acl.get()); b.addFinalizer(boost::bind(&AclPlugin::shutdown, this)); @@ -89,5 +92,5 @@ static AclPlugin instance; // Static initialization. // For test purposes. boost::intrusive_ptr<Acl> getGlobalAcl() { return instance.acl; } - + }} // namespace qpid::acl |