From 9b593603218739f62dd86709c40bd7afb56e154a Mon Sep 17 00:00:00 2001 From: Aleksy Barcz Date: Wed, 21 Mar 2018 16:24:57 +0100 Subject: [PATCH] fixed loading incorrect files as configuration 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 | 3 ++- tests/default_deny/system.d/error.conf.a | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/default_deny/system.d/error.conf.a diff --git a/src/internal/xml_parser.hpp b/src/internal/xml_parser.hpp index 6eea72b..82480f3 100755 --- a/src/internal/xml_parser.hpp +++ b/src/internal/xml_parser.hpp @@ -22,6 +22,7 @@ #define _XML_PARSER_HPP #include +#include #include #include #include @@ -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 index 0000000..a76952c --- /dev/null +++ b/tests/default_deny/system.d/error.conf.a @@ -0,0 +1,9 @@ + + + + + + + -- 2.7.4