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

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