Blame SOURCES/0004-firewall-cmd-add-check-config-option.patch

e3f863
From c37c84f095d820cbd137a285e263075472934502 Mon Sep 17 00:00:00 2001
e3f863
From: Eric Garver <e@erig.me>
e3f863
Date: Thu, 31 May 2018 14:15:57 -0400
e3f863
Subject: [PATCH 4/5] firewall-cmd: add --check-config option
e3f863
e3f863
Fixes: rhbz 1477771
e3f863
(cherry picked from commit b071536beb7ef2c91adb79c7769a265fc74ab15f)
e3f863
---
e3f863
 doc/xml/firewalld.dbus.xml       | 11 +++++++++++
e3f863
 src/firewall-cmd                 |  6 +++++-
e3f863
 src/firewall/client.py           |  5 +++++
e3f863
 src/firewall/server/firewalld.py | 11 +++++++++++
e3f863
 4 files changed, 32 insertions(+), 1 deletion(-)
e3f863
e3f863
diff --git a/doc/xml/firewalld.dbus.xml b/doc/xml/firewalld.dbus.xml
e3f863
index f02edb173f6e..acdbb5fd6e00 100644
e3f863
--- a/doc/xml/firewalld.dbus.xml
e3f863
+++ b/doc/xml/firewalld.dbus.xml
e3f863
@@ -347,6 +347,17 @@
e3f863
 	      </para>
e3f863
             </listitem>
e3f863
           </varlistentry>
e3f863
+          <varlistentry id="FirewallD1.Methods.checkPermanentConfig">
e3f863
+            <term><methodname>checkPermanentConfig</methodname>() → Nothing</term>
e3f863
+            <listitem>
e3f863
+              <para>
e3f863
+                Run checks on the permanent configuration. This is most useful if changes were made manually to configuration files.
e3f863
+              </para>
e3f863
+              <para>
e3f863
+                Possible errors: any
e3f863
+              </para>
e3f863
+            </listitem>
e3f863
+          </varlistentry>
e3f863
           <varlistentry id="FirewallD1.Methods.setDefaultZone">
e3f863
             <term><methodname>setDefaultZone</methodname>(s: <parameter>zone</parameter>) → Nothing</term>
e3f863
             <listitem>
e3f863
diff --git a/src/firewall-cmd b/src/firewall-cmd
e3f863
index 1a864b32e819..b80115564e1b 100755
e3f863
--- a/src/firewall-cmd
e3f863
+++ b/src/firewall-cmd
e3f863
@@ -59,6 +59,7 @@ Status Options
e3f863
   --complete-reload    Reload firewall and lose state information
e3f863
   --runtime-to-permanent
e3f863
                        Create permanent from runtime configuration
e3f863
+  --check-config       Check permanent configuration for errors
e3f863
 
e3f863
 Log Denied Options
e3f863
   --get-log-denied     Print the log denied value
e3f863
@@ -484,6 +485,7 @@ parser_group_standalone.add_argument("--reload", action="store_true")
e3f863
 parser_group_standalone.add_argument("--complete-reload", action="store_true")
e3f863
 parser_group_standalone.add_argument("--runtime-to-permanent",
e3f863
                                      action="store_true")
e3f863
+parser_group_standalone.add_argument("--check-config", action="store_true")
e3f863
 parser_group_standalone.add_argument("--get-ipset-types", action="store_true")
e3f863
 parser_group_standalone.add_argument("--get-log-denied", action="store_true")
e3f863
 parser_group_standalone.add_argument("--set-log-denied", metavar="<value>")
e3f863
@@ -750,7 +752,7 @@ options_standalone = a.help or a.version or \
e3f863
     a.get_default_zone or a.set_default_zone or \
e3f863
     a.get_active_zones or a.get_ipset_types or \
e3f863
     a.get_log_denied or a.set_log_denied or \
e3f863
-    a.get_automatic_helpers or a.set_automatic_helpers
e3f863
+    a.get_automatic_helpers or a.set_automatic_helpers or a.check_config
e3f863
 
e3f863
 options_desc_xml_file = a.set_description or a.get_description or \
e3f863
                         a.set_short or a.get_short
e3f863
@@ -2039,6 +2041,8 @@ elif a.complete_reload:
e3f863
     fw.complete_reload()
e3f863
 elif a.runtime_to_permanent:
e3f863
     fw.runtimeToPermanent()
e3f863
+elif a.check_config:
e3f863
+    fw.checkPermanentConfig()
e3f863
 elif a.direct:
e3f863
     if a.passthrough:
e3f863
         if len(a.passthrough) < 2:
e3f863
diff --git a/src/firewall/client.py b/src/firewall/client.py
e3f863
index f90bbd78eb73..da45ceb5b964 100644
e3f863
--- a/src/firewall/client.py
e3f863
+++ b/src/firewall/client.py
e3f863
@@ -2760,6 +2760,11 @@ class FirewallClient(object):
e3f863
     def runtimeToPermanent(self):
e3f863
         self.fw.runtimeToPermanent()
e3f863
 
e3f863
+    @slip.dbus.polkit.enable_proxy
e3f863
+    @handle_exceptions
e3f863
+    def checkPermanentConfig(self):
e3f863
+        self.fw.checkPermanentConfig()
e3f863
+
e3f863
     @slip.dbus.polkit.enable_proxy
e3f863
     @handle_exceptions
e3f863
     def get_property(self, prop):
e3f863
diff --git a/src/firewall/server/firewalld.py b/src/firewall/server/firewalld.py
e3f863
index fc7422f12261..2cecc4771cb0 100644
e3f863
--- a/src/firewall/server/firewalld.py
e3f863
+++ b/src/firewall/server/firewalld.py
e3f863
@@ -42,6 +42,7 @@ from firewall.dbus_utils import dbus_to_python, \
e3f863
     command_of_sender, context_of_sender, uid_of_sender, user_of_uid, \
e3f863
     dbus_introspection_prepare_properties, \
e3f863
     dbus_introspection_add_properties
e3f863
+from firewall.core.io.functions import check_config
e3f863
 from firewall.core.io.zone import Zone
e3f863
 from firewall.core.io.ipset import IPSet
e3f863
 from firewall.core.io.service import Service
e3f863
@@ -336,6 +337,16 @@ class FirewallD(slip.dbus.service.Object):
e3f863
     def Reloaded(self):
e3f863
         log.debug1("Reloaded()")
e3f863
 
e3f863
+    @slip.dbus.polkit.require_auth(config.dbus.PK_ACTION_CONFIG)
e3f863
+    @dbus_service_method(config.dbus.DBUS_INTERFACE, in_signature='',
e3f863
+                         out_signature='')
e3f863
+    @dbus_handle_exceptions
e3f863
+    def checkPermanentConfig(self, sender=None): # pylint: disable=W0613
e3f863
+        """Check permanent configuration
e3f863
+        """
e3f863
+        log.debug1("checkPermanentConfig()")
e3f863
+        check_config(self.fw)
e3f863
+
e3f863
     # runtime to permanent
e3f863
 
e3f863
     @slip.dbus.polkit.require_auth(config.dbus.PK_ACTION_CONFIG)
e3f863
-- 
e3f863
2.16.3
e3f863