salt/changelog/55262.fixed
Jonas Maurus 155197dd49
Fix #55262 (mixing of stderr and stdout in cmd.run return value leads to errors in iptables/nftables saved rules) (#58573)
* Fixing saltstack/salt#55262 by using cmd correctly

This commit attemts to fix saltstack/salt#55262 by ensuring that output
from stdout and stderr isn't mixed in `iptables.save`. It also changes
other invocations of `cmd.*` by using `cmd.run_stdout` and
`com.run_stderr` respectively to what the iptables function expects.

I found some other issues here, where for example `iptables.new_chain`
returns `True` when successful and `iptables.set_policy` returns `False`
when successful. But that's for a separate patch to fix.

* adding changelog entry

* run pre-commit hooks

* remove unused import

* update iptables.check to use stdout

* update tests

* explicitly use stdout for help output and version checking, too

* linting/blacken test_iptables

* add mocks for run_stdout and run_stderr where necessary

* blacken test_iptables again

* linting test_iptables

* empty commit to trigger PR rebuild to fix spurious error report

Co-authored-by: Megan Wilhite <megan.wilhite@gmail.com>
2021-08-26 14:19:38 -04:00

1 line
155 B
Text

Fixed bug #55262 where `salt.modules.iptables` would call `cmd.run` and receive and interpret interspersed `stdout` and `stderr` output from subprocesses.