Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
List overview
Download
firewalld-recode
----- 2024 -----
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
firewalld-recode@lists.fedorahosted.org
135 discussions
Start a n
N
ew thread
[firewalld-recode] master: Add support for loading configuration from a firewalld.conf file (063c8ea)
by mildew@fedoraproject.org
20 Aug '14
20 Aug '14
Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master >--------------------------------------------------------------- commit 063c8eaca504a65fc1c8a70977beb9368a95d537 Author: Daniel Kopecek <dkopecek(a)redhat.com> Date: Wed Aug 20 13:33:50 2014 +0200 Add support for loading configuration from a firewalld.conf file >--------------------------------------------------------------- firewalld.cpp | 78 +++++++++++++++++++- firewalld.hpp | 11 +++- firewalld_cli.cpp | 11 +++ firewalld_cli.hpp | 2 + .../zone/{getIcmpBlocks.cpp => getRichRules.cpp} | 7 +- firewalld_dbus/zone/methods.decl | 3 +- main.cpp | 3 +- 7 files changed, 102 insertions(+), 13 deletions(-) diff --git a/firewalld.cpp b/firewalld.cpp index 6beade7..9ee6257 100644 --- a/firewalld.cpp +++ b/firewalld.cpp @@ -88,11 +88,81 @@ namespace firewalld _glib_loop->quit(); } - void FirewallD::loadConfig() + void FirewallD::loadConfiguration(const UString& filepath) { - LOG(TRACE) << "Loading configuration"; - loadServiceDefinitions("./config/services/"); - loadZoneDefinitions("./config/zones/"); + LOG(INFO) << "Loading configuration from " << filepath; + std::ifstream config(filepath); + String config_line; + size_t config_line_num = 0; + + if (!config) { + LOG(ERROR) << "Unable to open the configuration file: " << filepath; + throw std::runtime_error("Unable to open the configuration file"); + } + + while(std::getline(config, config_line)) { + ++config_line_num; + size_t nv_separator = config_line.find_first_of("="); + + if (nv_separator == String::npos) { + continue; + } + + String name = trim(config_line.substr(0, nv_separator)); + String value = config_line.substr(nv_separator + 1); + + if (name[0] == '#') { + continue; + } + + processConfigurationNVPair(name, value, config_line_num); + } + + return; + } + + void FirewallD::processConfigurationNVPair(const String& name, const String& value, size_t line_num) + { + if (name == "DefaultZone") { + // + // Just assign the value here. Sanity checking is + // done after the definitions are loaded. + // + _fw.setDefaultZoneName(value); + return; + } + + if (name == "MinimalMark") { + return; + } + if (name == "CleanupOnExit") { + return; + } + if (name == "Lockdown") { + return; + } + if (name == "IPv6_rpfilter") { + return; + } + + if (name == "StaticDefinitionDirs" || name == "DefinitionDirs") { + tokenizeString(value, _definition_dirs, ":", /*trim_empty=*/true); + return; + } + + LOG(WARNING) << "Unknown name-value pair in configuration file: line " + << line_num << ": " << name << "=" << value; + } + + /** + * Load definitions from the directories specified in the configuration file. + */ + void FirewallD::loadDefinitions() + { + for(auto const& path : _definition_dirs) { + loadServiceDefinitions(path + "/services/"); + loadZoneDefinitions(path + "/zones/"); + } } void FirewallD::setPanicMode(bool panic_mode) diff --git a/firewalld.hpp b/firewalld.hpp index 58f42c0..ada40cf 100644 --- a/firewalld.hpp +++ b/firewalld.hpp @@ -37,7 +37,8 @@ namespace firewalld FirewallD(); void run(); void quit(); - void loadConfig(); + void loadConfiguration(const UString& filepath); + void loadDefinitions(); bool panicMode() const { return _panic_mode; } void setPanicMode(bool panic_mode); @@ -80,6 +81,11 @@ namespace firewalld */ void loadZoneDefinition(const String& filepath); + /** + * Process a name-value pair from the configuration file. + */ + void processConfigurationNVPair(const String& name, const String& value, size_t line_num); + void dbus_method_handle(const UString& name, const DBusParameters& parameters, DBusResultBuilder& result); @@ -104,6 +110,9 @@ namespace firewalld DBus _dbus; Firewall _fw; + UString _default_zone; + StringVector _definition_dirs; + // Defined services UStringKeyMap<Service*> _defined_services; UStringKeyMap<Zone*> _defined_zones; diff --git a/firewalld_cli.cpp b/firewalld_cli.cpp index 892d320..85b0c21 100644 --- a/firewalld_cli.cpp +++ b/firewalld_cli.cpp @@ -38,6 +38,7 @@ namespace firewalld no_pid = false; debug_level = 0; debug_gc = false; + config_path = "firewalld.conf"; // Define CLI options add_option_entry("nofork", @@ -54,6 +55,10 @@ namespace firewalld add_option_entry("debug-gc", "Does nothing. This option is here only for backward compatibility.", debug_gc); + add_option_entry("config", + "Load configuration from the specified file.", + SLOT(*this, &CLIOptionGroup::on_option_arg_string), + OptionEntry::FLAG_FILENAME); } bool CLIOptionGroup::on_option_arg_string(const ustring& option_name, @@ -81,6 +86,12 @@ namespace firewalld } } } + + if (option_name == "--config") { + config_path = value; + LOG(INFO) << "Config file is: " << config_path; + } + return true; } diff --git a/firewalld_cli.hpp b/firewalld_cli.hpp index c01c29c..c21f906 100644 --- a/firewalld_cli.hpp +++ b/firewalld_cli.hpp @@ -34,6 +34,8 @@ namespace firewalld bool no_pid; bool debug_gc; int debug_level; + UString config_path; + private: // Add a long option entry associated with a variable template<typename T> diff --git a/firewalld_dbus/zone/getIcmpBlocks.cpp b/firewalld_dbus/zone/getRichRules.cpp similarity index 85% copy from firewalld_dbus/zone/getIcmpBlocks.cpp copy to firewalld_dbus/zone/getRichRules.cpp index 453a1cb..6102675 100644 --- a/firewalld_dbus/zone/getIcmpBlocks.cpp +++ b/firewalld_dbus/zone/getRichRules.cpp @@ -22,7 +22,7 @@ namespace firewalld { - FIREWALLD_DBUS_METHOD(getIcmpBlocks) + FIREWALLD_DBUS_METHOD(getRichRules) { result.setTypeSignature("(as)"); @@ -31,10 +31,7 @@ namespace firewalld parameters.get(0, zone_name); try { - Zone* zone = _fw.getZone(zone_name); - UStringVector icmp_types; - zone->getICMPBlocks(icmp_types); - result = icmp_types; + result = UStringVector(); } catch(...) { result = UStringVector(); diff --git a/firewalld_dbus/zone/methods.decl b/firewalld_dbus/zone/methods.decl index 11876a2..aeb520b 100644 --- a/firewalld_dbus/zone/methods.decl +++ b/firewalld_dbus/zone/methods.decl @@ -46,5 +46,4 @@ FIREWALLD_DBUS_METHOD(getForwardPorts); //FIREWALLD_DBUS_METHOD(addRichRule) //FIREWALLD_DBUS_METHOD(removeRichRule) //FIREWALLD_DBUS_METHOD(queryRichRule) -//FIREWALLD_DBUS_METHOD(getRichRules) - +FIREWALLD_DBUS_METHOD(getRichRules); diff --git a/main.cpp b/main.cpp index e028933..5b15dd1 100644 --- a/main.cpp +++ b/main.cpp @@ -103,7 +103,8 @@ int main(int argc, char *argv[]) try { startSignalHandler(&firewalld); - firewalld.loadConfig(); + firewalld.loadConfiguration(option_grp.config_path); + firewalld.loadDefinitions(); firewalld.run(); stopSignalHandler(); } catch(...) {
1
0
0
0
[firewalld-recode] master: Set the c++11 and pthread flags in CMakeLists.txt, not in build.sh (edf4991)
by mildew@fedoraproject.org
20 Aug '14
20 Aug '14
Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master >--------------------------------------------------------------- commit edf49915a6cad2399fda5a93b7b066ff94c3069b Author: Daniel Kopecek <dkopecek(a)redhat.com> Date: Wed Aug 20 13:28:49 2014 +0200 Set the c++11 and pthread flags in CMakeLists.txt, not in build.sh >--------------------------------------------------------------- CMakeLists.txt | 2 ++ build.sh | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96a7f92..6d7656c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ include_directories(${GLIBMM_INCLUDE_DIRS}) include_directories(${GIOMM_INCLUDE_DIRS}) include_directories(${EXPAT_INCLUDE_DIRS}) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread") + # # Compile main components # diff --git a/build.sh b/build.sh index c264d3d..4e5c96e 100755 --- a/build.sh +++ b/build.sh @@ -1,12 +1,12 @@ #!/bin/sh set -e -o pipefail -BUILDDIR="build-$(uname -m)-$(uname -s)-$(id -u)" +BUILDDIR="_build" rm -rf "${BUILDDIR}" mkdir "${BUILDDIR}" pushd "${BUILDDIR}" -cmake -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_FLAGS:STRING="-std=c++11" .. +cmake -DCMAKE_BUILD_TYPE:STRING=Debug .. time make echo popd
1
0
0
0
[firewalld-recode] master: Use the loadConfig method to load configuration from the main loop (d75a119)
by mildew@fedoraproject.org
29 Jul '14
29 Jul '14
Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master >--------------------------------------------------------------- commit d75a11973d9efe3bc8dc45bd9ecad4c216c6a18d Author: Daniel Kopecek <dkopecek(a)redhat.com> Date: Tue Jul 29 10:01:36 2014 +0200 Use the loadConfig method to load configuration from the main loop >--------------------------------------------------------------- main.cpp | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/main.cpp b/main.cpp index f9948c1..e028933 100644 --- a/main.cpp +++ b/main.cpp @@ -103,6 +103,7 @@ int main(int argc, char *argv[]) try { startSignalHandler(&firewalld); + firewalld.loadConfig(); firewalld.run(); stopSignalHandler(); } catch(...) {
1
0
0
0
[firewalld-recode] master: Get information about the zones from the FirewallD class in the getZones D-Bus method (4f8397b)
by mildew@fedoraproject.org
28 Jul '14
28 Jul '14
Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master >--------------------------------------------------------------- commit 4f8397b9605c625a51390ed91cc1a02e942ef393 Author: Daniel Kopecek <dkopecek(a)redhat.com> Date: Mon Jul 28 18:12:53 2014 +0200 Get information about the zones from the FirewallD class in the getZones D-Bus method >--------------------------------------------------------------- firewalld_dbus/zone/getZones.cpp | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/firewalld_dbus/zone/getZones.cpp b/firewalld_dbus/zone/getZones.cpp index 826fdbe..1479e3c 100644 --- a/firewalld_dbus/zone/getZones.cpp +++ b/firewalld_dbus/zone/getZones.cpp @@ -26,7 +26,12 @@ namespace firewalld { result.setTypeSignature("(as)"); UStringVector zone_names; - _fw.getAllZoneNames(zone_names); + + for (auto const& map_entry : definedZones()) { + const UString& zone_name = map_entry.first; + zone_names.push_back(zone_name); + } + result = zone_names; return; }
1
0
0
0
[firewalld-recode] master: Added initial implementation of the loadConfig method (90b853d)
by mildew@fedoraproject.org
28 Jul '14
28 Jul '14
Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master >--------------------------------------------------------------- commit 90b853d6b30ecc35d4b85d2732fbd43614ae5d98 Author: Daniel Kopecek <dkopecek(a)redhat.com> Date: Mon Jul 28 18:09:29 2014 +0200 Added initial implementation of the loadConfig method >--------------------------------------------------------------- firewalld.cpp | 37 +++++++++++++++++++++++++++++++++++-- firewalld.hpp | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/firewalld.cpp b/firewalld.cpp index d2d4efb..6beade7 100644 --- a/firewalld.cpp +++ b/firewalld.cpp @@ -88,6 +88,13 @@ namespace firewalld _glib_loop->quit(); } + void FirewallD::loadConfig() + { + LOG(TRACE) << "Loading configuration"; + loadServiceDefinitions("./config/services/"); + loadZoneDefinitions("./config/zones/"); + } + void FirewallD::setPanicMode(bool panic_mode) { // Set the panic mode @@ -117,12 +124,38 @@ namespace firewalld } } - void FirewallD::loadServiceDefinitions() + void FirewallD::loadServiceDefinitions(const String& directory) { + LOG(TRACE) << "Loading Service definitions from " << directory; + loadFiles(directory, std::regex(".*\\.xml"/*"[a-zA-Z0-9]+\\.xml"*/), + &FirewallD::loadServiceDefinition, this); + return; } - void FirewallD::loadZoneDefinitions() + void FirewallD::loadZoneDefinitions(const String& directory) { + LOG(TRACE) << "Loading Zone definitions from " << directory; + loadFiles(directory, std::regex(".*\\.xml"/*"[a-zA-Z0-9]+\\.xml"*/), + &FirewallD::loadZoneDefinition, this); + return; + } + + void FirewallD::loadServiceDefinition(const String& filepath) + { + LOG(TRACE) << "Loading Service definition from " << filepath; + Service* service = new Service(); + service->initFromXML(filepath); + _defined_services[service->identifier()] = service; + return; + } + + void FirewallD::loadZoneDefinition(const String& filepath) + { + LOG(TRACE) << "Loading Zone definition from " << filepath; + Zone* zone = new Zone(); + zone->initFromXML(filepath); + _defined_zones[zone->identifier()] = zone; + return; } void FirewallD::dbus_method_handle(const ustring& name, const DBusParameters& parameters, DBusResultBuilder& result) diff --git a/firewalld.hpp b/firewalld.hpp index fdd4ad9..58f42c0 100644 --- a/firewalld.hpp +++ b/firewalld.hpp @@ -37,6 +37,7 @@ namespace firewalld FirewallD(); void run(); void quit(); + void loadConfig(); bool panicMode() const { return _panic_mode; } void setPanicMode(bool panic_mode); @@ -49,8 +50,35 @@ namespace firewalld static const FirewallD* instance(); protected: - void loadServiceDefinitions(); - void loadZoneDefinitions(); + /** + * Load Service object definitions from a directory. + * This functions looks for .xml files with service definitions + * inside the given directory. Only files with .xml extension + * are processed. Subdirectories aren't descended into. + */ + void loadServiceDefinitions(const String& directory); + + /** + * Load Zone object definitions from a directory. + * This functions looks for .xml files with zone definitions + * inside the given directory. Only files with .xml extension + * are processed. Subdirectories aren't descended into. + */ + void loadZoneDefinitions(const String& directory); + + /** + * Load a Service object from a file. + * This function read the contents of the given file + * and tries to parse it as a service definition. + */ + void loadServiceDefinition(const String& filepath); + + /** + * Load a Zone object from a file. + * This function read the contents of the given file + * and tries to parse it as a zone definition. + */ + void loadZoneDefinition(const String& filepath); void dbus_method_handle(const UString& name, const DBusParameters& parameters,
1
0
0
0
← Newer
1
...
11
12
13
14
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Results per page:
10
25
50
100
200