Custom Search

[PATCH] Drop iptables-save comments and chain counters from iptables inventory.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


---
 func/minion/modules/iptables/__init__.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/func/minion/modules/iptables/__init__.py b/func/minion/modules/iptables/__init__.py
index db11a23..ccc7645 100644
--- a/func/minion/modules/iptables/__init__.py
+++ b/func/minion/modules/iptables/__init__.py
@@ -12,6 +12,7 @@
 # our modules
 from func.minion.modules import func_module
 from func.minion.modules.iptables.common import *
+import re
 
 IPTABLES_SAVE_FILE = "/etc/sysconfig/iptables"
 
@@ -111,7 +112,19 @@ class Iptables(func_module.FuncModule):
         return call_if_policy("INPUT", "DROP", "-I OUTPUT -d %s -j ACCEPT" % ip)
 
     def inventory(self):
-        return self.dump()
+        raw = self.dump()
+        output = ""
+        for line in raw.splitlines():
+            # Drop commentlines:
+            if re.search("^#", line):
+                continue
+            # Null chain counters:
+            if re.search("^:.*$", line):
+                nulled = re.sub('(^:.*)\[\d*:\d*\](.*$)', r'\1[0:0]\2', line)
+                output = output + nulled + "\n"
+                continue
+            output = output + line + "\n"
+        return output
 
     def dump(self, counters=False):
         """
-- 
1.7.1

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list


[Home]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Red Hat 9 Bible]     [Fedora Bible]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

Powered by Linux

Google
  Web www.spinics.net