Ignore retcode on call to grep in selinux.py module

Fixes #43711

Returning an exit code of 1 is normal operation of grep when it does not
find a match. This will happen every time this function is called by
fcontext_policy_present to detirmine whether a selinux policy exists
before creating it. Ignoring the retcode will prevent it from emitting
an error when this happens.
This commit is contained in:
Wedge Jarrad 2017-09-23 17:38:51 -07:00
parent 47cd8723c6
commit 96c1ef48e6

View file

@ -463,7 +463,7 @@ def fcontext_get_policy(name, filetype=None, sel_type=None, sel_user=None, sel_l
cmd_kwargs['filetype'] = '[[:alpha:] ]+' if filetype is None else filetype_id_to_string(filetype)
cmd = 'semanage fcontext -l | egrep ' + \
"'^{filespec}{spacer}{filetype}{spacer}{sel_user}:{sel_role}:{sel_type}:{sel_level}$'".format(**cmd_kwargs)
current_entry_text = __salt__['cmd.shell'](cmd)
current_entry_text = __salt__['cmd.shell'](cmd, ignore_retcode=True)
if current_entry_text == '':
return None
ret = {}