[PATCH] firewall-cmd: --list=all

Jiri Popelka jpopelka at redhat.com
Wed Mar 7 10:46:20 UTC 2012


examples:

(list all info about zone "home")
firewall-cmd --zone=home --list=all

(list all info about default zone)
firewall-cmd --list=all
---
 TODO             |    1 -
 src/firewall-cmd |   23 +++++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/TODO b/TODO
index ad00efd..4280f15 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,2 @@
-- firewall-cmd --list --zone=home
 - add documentation about all config files
 - add man pages
diff --git a/src/firewall-cmd b/src/firewall-cmd
index d7b1951..0aff6ed 100755
--- a/src/firewall-cmd
+++ b/src/firewall-cmd
@@ -51,7 +51,7 @@ def usage():
     --enable [--timeout=<seconds>] <masquerade>
     --disable <masquerade>
     --query <action> | <masquerade> 
-    --list=<action>
+    --list=<action> | all
   Action:
     --service=<service>
     --port=<port>[-<port>]/<protocol>
@@ -330,7 +330,7 @@ try:
                 elif mode == "query":
                     sys.exit(not fw.queryForwardPort(zone, port, protocol,
                                                      toport, toaddr))
-                    
+
         # block icmp
         elif action == "icmp-block":
             if mode == "list":
@@ -345,6 +345,25 @@ try:
             elif mode == "query":
                 sys.exit(not fw.queryIcmpBlock(zone, value))
 
+        elif (action == "all"):
+            if mode == "list":
+                print("zone: " + (zone if zone != "" else fw.getDefaultZone()))
+                l = fw.getInterfaces(zone)
+                if len(l) > 0:
+                    print("interfaces: " + ", ".join(l))
+                l = fw.getServices(zone)
+                if len(l) > 0:
+                    print("services: " + ", ".join(l))
+                l = fw.getPorts(zone)
+                if len(l) > 0:
+                    print("ports: " + ", ".join(["%s/%s" % (port[0], port[1]) for port in l]))
+                l = fw.getForwardPorts(zone)
+                if len(l) > 0:
+                    print("forward-ports: " + "\n".join(["port=%s:proto=%s:toport=%s:toaddr=%s" % (interface, port, protocol, toport, toaddr) for (port, protocol, toport, toaddr) in l]))
+                l = fw.getIcmpBlocks(zone)
+                if len(l) > 0:
+                    print("icmp-blocks: " + ", ".join(l))
+
 except dbus.DBusException, e:
     if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown':
         print("FirewallD is probably not running.")
-- 
1.7.7.6



More information about the firewalld-devel mailing list