|
|
4d71d0 |
From 9b8de9ce33e671a89ea8fd0b6e9c391c0b779726 Mon Sep 17 00:00:00 2001
|
|
|
4d71d0 |
From: Eric Garver <e@erig.me>
|
|
|
4d71d0 |
Date: Wed, 23 May 2018 14:35:10 -0400
|
|
|
4d71d0 |
Subject: [PATCH 3/5] firewall-offline-cmd: add --check-config option
|
|
|
4d71d0 |
|
|
|
4d71d0 |
(cherry picked from commit 749e64b74cff231585667417b37ff4f60af65dc0)
|
|
|
4d71d0 |
---
|
|
|
4d71d0 |
src/firewall-offline-cmd | 16 +++++++++++++++-
|
|
|
4d71d0 |
1 file changed, 15 insertions(+), 1 deletion(-)
|
|
|
4d71d0 |
|
|
|
4d71d0 |
diff --git a/src/firewall-offline-cmd b/src/firewall-offline-cmd
|
|
|
4d71d0 |
index 7f7c10739f77..13ecfadf4080 100755
|
|
|
4d71d0 |
--- a/src/firewall-offline-cmd
|
|
|
4d71d0 |
+++ b/src/firewall-offline-cmd
|
|
|
4d71d0 |
@@ -35,6 +35,7 @@ from firewall.errors import FirewallError
|
|
|
4d71d0 |
from firewall import config
|
|
|
4d71d0 |
from firewall.core.fw_test import Firewall_test
|
|
|
4d71d0 |
from firewall.functions import joinArgs, splitArgs
|
|
|
4d71d0 |
+from firewall.core.io.functions import check_config
|
|
|
4d71d0 |
from firewall.core.io.zone import zone_reader
|
|
|
4d71d0 |
from firewall.core.io.service import service_reader
|
|
|
4d71d0 |
from firewall.core.io.ipset import ipset_reader
|
|
|
4d71d0 |
@@ -62,6 +63,7 @@ General Options
|
|
|
4d71d0 |
-q, --quiet Do not print status messages
|
|
|
4d71d0 |
--system-config Path to firewalld system configuration
|
|
|
4d71d0 |
--default-config Path to firewalld default configuration
|
|
|
4d71d0 |
+ --check-config Check system and default configuration
|
|
|
4d71d0 |
|
|
|
4d71d0 |
Lokkit Compatibility Options
|
|
|
4d71d0 |
--migrate-system-config-firewall=<file>
|
|
|
4d71d0 |
@@ -532,6 +534,7 @@ parser_group_lokkit.add_argument("--block-icmp", metavar="<icmptype>", action='a
|
|
|
4d71d0 |
|
|
|
4d71d0 |
parser.add_argument("--system-config", metavar="path")
|
|
|
4d71d0 |
parser.add_argument("--default-config", metavar="path")
|
|
|
4d71d0 |
+parser.add_argument("--check-config", action="store_true")
|
|
|
4d71d0 |
|
|
|
4d71d0 |
parser_group_standalone = parser.add_mutually_exclusive_group()
|
|
|
4d71d0 |
parser_group_standalone.add_argument("-h", "--help",
|
|
|
4d71d0 |
@@ -970,7 +973,8 @@ cmd.set_verbose(a.verbose)
|
|
|
4d71d0 |
if not (options_standalone or options_ipset or \
|
|
|
4d71d0 |
options_lokkit or \
|
|
|
4d71d0 |
options_icmptype or options_service or options_helper or \
|
|
|
4d71d0 |
- options_permanent or options_direct or options_desc_xml_file):
|
|
|
4d71d0 |
+ options_permanent or options_direct or options_desc_xml_file or \
|
|
|
4d71d0 |
+ a.check_config):
|
|
|
4d71d0 |
cmd.fail(parser.format_usage() + "No option specified.")
|
|
|
4d71d0 |
|
|
|
4d71d0 |
if options_lokkit and (options_standalone or \
|
|
|
4d71d0 |
@@ -1035,6 +1039,16 @@ if a.system_config:
|
|
|
4d71d0 |
config.set_system_config_paths(a.system_config)
|
|
|
4d71d0 |
if a.default_config:
|
|
|
4d71d0 |
config.set_default_config_paths(a.default_config)
|
|
|
4d71d0 |
+if a.check_config:
|
|
|
4d71d0 |
+ try:
|
|
|
4d71d0 |
+ fw = Firewall_test()
|
|
|
4d71d0 |
+ fw.start()
|
|
|
4d71d0 |
+ check_config(fw)
|
|
|
4d71d0 |
+ except FirewallError as error:
|
|
|
4d71d0 |
+ cmd.print_and_exit("Configuration error: %s" % error, error.code)
|
|
|
4d71d0 |
+ except Exception as msg:
|
|
|
4d71d0 |
+ cmd.fail("Configuration error: %s" % msg)
|
|
|
4d71d0 |
+ sys.exit(0)
|
|
|
4d71d0 |
|
|
|
4d71d0 |
zone = a.zone
|
|
|
4d71d0 |
fw = Firewall_test()
|
|
|
4d71d0 |
--
|
|
|
4d71d0 |
2.16.3
|
|
|
4d71d0 |
|