diff --git a/jail2ban/pfctl.py b/jail2ban/pfctl.py index 24f4448..0e062c5 100644 --- a/jail2ban/pfctl.py +++ b/jail2ban/pfctl.py @@ -9,12 +9,10 @@ def pfctl_cfg_read(anchor): cmd = [_SUDO, _PFCTL, '-a', anchor, '-sr'] logging.info('Running %s', cmd) - res = run(cmd, capture_output=True) + res = run(cmd, capture_output=True, check=True) - if res and res.stdout: - logging.info('Result: %s', res) - res.check_returncode() - return res.stdout.splitlines() + logging.info('Result: %s', res) + return res.stdout.splitlines() def pfctl_cfg_write(anchor, cfg): @@ -24,12 +22,11 @@ def pfctl_cfg_write(anchor, cfg): res = run(cmd, input=cfg, + check=True, capture_output=True) - if res: - logging.info('Result: %s', res) - res.check_returncode() - return res.stdout.splitlines() + logging.info('Result: %s', res) + return res.stdout.splitlines() def pfctl_table_op(anchor, **kwargs): @@ -40,9 +37,9 @@ def pfctl_table_op(anchor, **kwargs): logging.info('Running %s', cmd) - res = run([x for x in cmd if x is not None], capture_output=True) + res = run([x for x in cmd if x is not None], + capture_output=True, + check=True) - if res: - logging.debug(res) - res.check_returncode() - return res.stdout.splitlines() + logging.debug(res) + return res.stdout.splitlines()