From a6f1defa7fb6f736975c7473110d3b84058a3d23 Mon Sep 17 00:00:00 2001 From: Papoteur Date: Thu, 14 Apr 2022 21:46:47 +0200 Subject: Change function for calling iptables. - get rid of ResourceWarning: subprocess xx is still running --- src/msec/tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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()) -- cgit v1.2.1