Repository : http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master
commit 8341ed523b652bdd91e43782d8d63542996c730b Author: Daniel Kopecek dkopecek@redhat.com Date: Mon Oct 6 14:01:15 2014 +0200
Store the kernel module name in UString
CMakeLists.txt | 2 ++ src/Daemon/Backends/Linux/KernelModule.cpp | 13 +++++++++---- src/Daemon/Backends/Linux/KernelModule.hpp | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt index c832928..90c5357 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,8 @@ add_executable(test_kernelmodule src/Daemon/Backends/Linux/KernelModule.cpp src/Common/Utility.cpp)
+target_link_libraries(test_kernelmodule ${GLIBMM_LIBRARIES}) + # Compile test: iptables add_executable(test_iptables tests/iptables/test_iptables.cpp diff --git a/src/Daemon/Backends/Linux/KernelModule.cpp b/src/Daemon/Backends/Linux/KernelModule.cpp index 594f76e..bc24f3d 100644 --- a/src/Daemon/Backends/Linux/KernelModule.cpp +++ b/src/Daemon/Backends/Linux/KernelModule.cpp @@ -29,7 +29,7 @@ namespace firewalld KernelModule::KernelModule(const char *name, bool unload_on_unref) { _unload_on_unref = unload_on_unref; - _name = name; + _name = UString(name);
char regexp_cstr[256]; if (snprintf(regexp_cstr, sizeof regexp_cstr, "^%s\s\+", name) >= sizeof regexp_cstr) { @@ -39,7 +39,7 @@ namespace firewalld LOG(FATAL) << "BUG: Cannot compile regex: " << regexp_cstr; }
- if (runCommand(MODINFO_PATH, _name) != EXIT_SUCCESS) { + if (runCommand(MODINFO_PATH, name) != EXIT_SUCCESS) { _module_exists = false; } else { _module_exists = true; @@ -60,7 +60,7 @@ namespace firewalld if (!_module_exists) { return false; } - return runCommand(MODPROBE_PATH, _name) == EXIT_SUCCESS ? true : false; + return runCommand(MODPROBE_PATH, _name.c_str()) == EXIT_SUCCESS ? true : false; }
bool KernelModule::unload() @@ -68,7 +68,7 @@ namespace firewalld if (!_module_exists) { return false; } - return runCommand(MODPROBE_PATH, "-r", _name) == EXIT_SUCCESS ? true : false; + return runCommand(MODPROBE_PATH, "-r", _name.c_str()) == EXIT_SUCCESS ? true : false; }
bool KernelModule::matchInProcModules() const @@ -95,4 +95,9 @@ namespace firewalld return matchInProcModules(); }
+ const UString& KernelModule::name() const + { + return _name; + } + } /* namespace firewalld */ diff --git a/src/Daemon/Backends/Linux/KernelModule.hpp b/src/Daemon/Backends/Linux/KernelModule.hpp index 880e10f..481f42d 100644 --- a/src/Daemon/Backends/Linux/KernelModule.hpp +++ b/src/Daemon/Backends/Linux/KernelModule.hpp @@ -19,6 +19,7 @@ #ifndef FIREWALLD_KERNELMODULE_HPP #define FIREWALLD_KERNELMODULE_HPP
+#include "Common/Types.hpp" #include <regex.h>
namespace firewalld @@ -32,7 +33,7 @@ namespace firewalld { bool _module_exists; bool _unload_on_unref; - const char *_name; + UString _name; ::regex_t _regexp; bool matchInProcModules() const; public: @@ -41,6 +42,7 @@ namespace firewalld bool load(); bool unload(); bool isLoaded() const; + const UString& name() const; };
} /* namespace firewalld */
firewalld-recode@lists.fedorahosted.org