fixed loading incorrect files as configuration 59/173459/4
authorAleksy Barcz <a.barcz@partner.samsung.com>
Wed, 21 Mar 2018 15:24:57 +0000 (16:24 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 29 Mar 2018 12:31:55 +0000 (12:31 +0000)
Bugfix. libdbuspolicy should load only files with names ending with ".conf",
as dbus-daemon does. Added an incorrect configuration file as regression test.

Change-Id: I868c04d6475101abfe2ffcd551b8eb9ce9bf4305

src/internal/xml_parser.hpp
tests/default_deny/system.d/error.conf.a [new file with mode: 0644]

index 6eea72b..82480f3 100755 (executable)
@@ -22,6 +22,7 @@
 #define _XML_PARSER_HPP
 
 #include <set>
+#include <boost/algorithm/string/predicate.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/property_tree/ptree.hpp>
 #include <boost/property_tree/xml_parser.hpp>
@@ -100,7 +101,7 @@ namespace ldp_xml_parser
                                if ((dir = opendir(dname.c_str())) != NULL) {
                                        while ((ent = readdir(dir)) != NULL) {
                                                std::string s(ent->d_name);
-                                               if (s.find(".conf") != std::string::npos) {
+                                               if (boost::algorithm::ends_with(s, ".conf")) {
                                                        files.push_back(dname + std::string("/") + s);
                                                }
                                        }
diff --git a/tests/default_deny/system.d/error.conf.a b/tests/default_deny/system.d/error.conf.a
new file mode 100644 (file)
index 0000000..a76952c
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE busconfig PUBLIC
+          "-//tizen//DTD D-BUS Bus Configuration 1.0//EN"
+          "http://www.tizen.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+  <!-- this file shouldn't be loaded. The rule below interferes with other rules -->
+  <policy user="root">
+    <allow own="*"/>
+  </policy>
+</busconfig>