Blame SOURCES/firewalld-0.4.4.6-firewall-offline-cmd-Don-t-require-root-for-help-out.patch

843f86
From 75f06cb4139f6f00dfe952eac84ff31d3db014cb Mon Sep 17 00:00:00 2001
843f86
From: Phil Sutter <psutter@redhat.com>
843f86
Date: Thu, 14 Sep 2017 12:05:09 +0200
843f86
Subject: [PATCH 5/5] firewall-offline-cmd: Don't require root for help output
843f86
843f86
Allow unprivileged users to retrieve help output.
843f86
843f86
Fixes: RHBZ#1445214
843f86
Signed-off-by: Phil Sutter <psutter@redhat.com>
843f86
---
843f86
 src/firewall-offline-cmd | 12 +++++++++---
843f86
 1 file changed, 9 insertions(+), 3 deletions(-)
843f86
843f86
diff --git a/src/firewall-offline-cmd b/src/firewall-offline-cmd
843f86
index 1b4550830b7bb..fccfb7251c4f5 100755
843f86
--- a/src/firewall-offline-cmd
843f86
+++ b/src/firewall-offline-cmd
843f86
@@ -43,9 +43,10 @@ from firewall.core.io.helper import helper_reader
843f86
 from firewall.command import FirewallCommand
843f86
 
843f86
 # check for root user
843f86
-if os.getuid() != 0:
843f86
-    sys.stderr.write("You need to be root to run %s.\n" % sys.argv[0])
843f86
-    sys.exit(-1)
843f86
+def assert_root():
843f86
+    if os.getuid() != 0:
843f86
+        sys.stderr.write("You need to be root to run %s.\n" % sys.argv[0])
843f86
+        sys.exit(-1)
843f86
 
843f86
 SYSTEM_CONFIG_FIREWALL = config.SYSCONFIGDIR + '/system-config-firewall'
843f86
 
843f86
@@ -775,6 +776,8 @@ if len(sys.argv) > 1 and \
843f86
     if a.help:
843f86
         __usage()
843f86
         sys.exit(0)
843f86
+    else:
843f86
+        assert_root()
843f86
     if a.quiet:
843f86
         # it makes no sense to use --quiet with these options
843f86
         a.quiet = False
843f86
@@ -809,6 +812,7 @@ elif len(sys.argv) > 1:
843f86
         args = aux_args[:i+1] # all but not <args>
843f86
         args.append(joinArgs(aux_args[i+1:])) # add <args> as one arg
843f86
 else:
843f86
+    assert_root()
843f86
     # migrate configuration from SYSTEM_CONFIG_FIREWALL
843f86
     args = read_sysconfig_args()
843f86
     if not args:
843f86
@@ -1020,6 +1024,8 @@ if a.help:
843f86
     __usage()
843f86
     sys.exit(0)
843f86
 
843f86
+assert_root()
843f86
+
843f86
 zone = a.zone
843f86
 fw = Firewall_test()
843f86
 fw.start()
843f86
-- 
843f86
2.13.1
843f86