aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2022-04-14 21:46:47 +0200
committerPapoteur <papoteur@mageia.org>2022-04-14 21:46:47 +0200
commita6f1defa7fb6f736975c7473110d3b84058a3d23 (patch)
treeccdd6a21fbba2039dfab6152ef6f58466e5be034
parentd7928e782dfc0edc4262389af4bbf6f602be22ed (diff)
downloadmsec-a6f1defa7fb6f736975c7473110d3b84058a3d23.tar
msec-a6f1defa7fb6f736975c7473110d3b84058a3d23.tar.gz
msec-a6f1defa7fb6f736975c7473110d3b84058a3d23.tar.bz2
msec-a6f1defa7fb6f736975c7473110d3b84058a3d23.tar.xz
msec-a6f1defa7fb6f736975c7473110d3b84058a3d23.zip
Change function for calling iptables.
- get rid of ResourceWarning: subprocess xx is still running
-rwxr-xr-xsrc/msec/tools.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/msec/tools.py b/src/msec/tools.py
index c9be55d..f62c1bc 100755
--- a/src/msec/tools.py
+++ b/src/msec/tools.py
@@ -8,6 +8,7 @@ import stat
import sys
import time
import locale
+import subprocess
# localization
import gettext
@@ -25,7 +26,8 @@ def find_firewall_info(log):
# read firewall settings
firewall_entries = []
try:
- data = os.popen("iptables -S").readlines()
+ p = subprocess.run(["iptables", "-S"], capture_output=True)
+ data = p.stdout
for l in data:
if l[:3] == "-A ":
firewall_entries.append(l.strip())