`_get_extra_opts()` and `_get_branch_option()` were unnecessarily
quoting the value, causing it to be interpreted as a literal quote by
`subprocess.Popen()`.
Also, because there were separate helpers for repo options,
disableexcludes, branch options, and extra options, and specifically
because `_get_extra_opts()` parses *all* kwargs, any of the options from
the other helper funcs would end up being added to the command line
twice if `_get_extra_opts()` was used.
This commit consolidates all of the kwarg inspection and CLI opts
construction to a single helper function. It also adds unit tests to
make sure that we are formatting our commands properly.
Additionally, it makes a minor fix in `refresh_db()` which was not
accounted for when we changed the osmajorrelease grain to an integer in
2017.7.0.
'a' is not a valid filetype for semanage on Centos 6.
Since "a" (all files) is the default behavior of semanage, don't specify a `--ftype` when invoking semanage.
Closes#45825
The previous logic of matching the output of `semanage fcontext --list` did not
allow for filespecs that were longer than 49 characters. This was due to the
output of the semanage tool not conforming to the expected output.
We used to expect that the after the filespec would be at least two spaces.
However, with long filespecs there is only a single space separating it and the
next field (the file type).
This modifies the regular expression that we use to match the line to accept one
or more spaces as field delimeters.
However, this causes problems when we attempt to split the three fields into a
python dictionary. We cannot use the same logic as previously of using the field
delimeter as the file type field itself can contain a space. Instead we use a
separate regular expression to parse the line into its component parts.
Fixes#45784.
This sorting was done mainly for the benefit of the test suite, but
Python 3 will raise an error when you try to sort a mixture of int and
tuple types, so sorting breaks down when there are UDP ports.
Instead, this just leaves them as an unsorted list when passed to the
API, and the test suite does the sorting before the assertEqual.