use split

This commit is contained in:
Antonio J. Delgado 2025-01-31 15:56:43 +02:00
parent 00badd911c
commit 81049aa360

View file

@ -48,7 +48,7 @@ class SmtpdWatcher:
def _read_banned_ips(self):
ips = {}
result = subprocess.run(
['/usr/bin/fail2ban-client', 'get', 'postfix', 'banned'],
['/usr/bin/fail2ban-client', 'get', 'postfix', 'banned', '|', 'tr', '-d', '"][\',"'],
encoding='utf-8',
check=True,
capture_output=True,
@ -56,18 +56,18 @@ class SmtpdWatcher:
self._log.debug(
result.stdout
)
ips['postfix'] = json.loads(result.stdout)
ips['postfix'] = result.stdout.split(' ')
self._log.debug(
"Banned IPs in postfix jail: %s",
ips['postfix']
)
result = subprocess.run(
['/usr/bin/fail2ban-client', 'get', 'postfix-sasl', 'banned'],
['/usr/bin/fail2ban-client', 'get', 'postfix-sasl', 'banned', '|', 'tr', '-d', '"][\',"'],
encoding='utf-8',
check=True,
capture_output=True,
)
ips['postfix-sasl'] = json.loads(result.stdout)
ips['postfix-sasl'] = result.stdout.split(' ')
self._log.debug(
"Banned IPs in postfix-sasl jail: %s",
ips['postfix-sasl']