Fix selinux.fcontext_policy_present for Centos 6

'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
This commit is contained in:
Philippe Pepiot 2018-02-01 18:19:32 +01:00 committed by rallytime
parent d20ff89414
commit 1916e5c4a4
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19

View file

@ -514,7 +514,9 @@ def fcontext_add_or_delete_policy(action, name, filetype=None, sel_type=None, se
if action not in ['add', 'delete']:
raise SaltInvocationError('Actions supported are "add" and "delete", not "{0}".'.format(action))
cmd = 'semanage fcontext --{0}'.format(action)
if filetype is not None:
# "semanage --ftype a" isn't valid on Centos 6,
# don't pass --ftype since "a" is the default filetype.
if filetype is not None and filetype != 'a':
_validate_filetype(filetype)
cmd += ' --ftype {0}'.format(filetype)
if sel_type is not None: