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