From d9a60219e9bd9120b3e2752f6cd2628da57917a4 Mon Sep 17 00:00:00 2001 From: David Murphy Date: Thu, 24 Oct 2024 09:33:34 -0600 Subject: [PATCH] Updated selinux commands and tests after reviewer comments, need the extra space --- salt/modules/selinux.py | 2 +- tests/pytests/unit/modules/test_selinux.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/salt/modules/selinux.py b/salt/modules/selinux.py index 0c4a0d108f2..f1c98f91702 100644 --- a/salt/modules/selinux.py +++ b/salt/modules/selinux.py @@ -616,7 +616,7 @@ def _fcontext_add_or_delete_policy( if "add" == action: # need to use --modify if context for name file exists, otherwise ValueError filespec = re.escape(name) - cmd = f"semanage fcontext -l | grep -E '{filespec}'" + cmd = f"semanage fcontext -l | grep -E '{filespec} '" current_entry_text = __salt__["cmd.shell"](cmd, ignore_retcode=True) if current_entry_text != "": action = "modify" diff --git a/tests/pytests/unit/modules/test_selinux.py b/tests/pytests/unit/modules/test_selinux.py index 5152b4910ab..0ceba06a134 100644 --- a/tests/pytests/unit/modules/test_selinux.py +++ b/tests/pytests/unit/modules/test_selinux.py @@ -401,7 +401,7 @@ def test_selinux_add_policy_regex(name, sel_type): ): selinux.fcontext_add_policy(name, sel_type=sel_type) filespec = re.escape(name) - expected_cmd_shell = f"semanage fcontext -l | grep -E '{filespec}'" + expected_cmd_shell = f"semanage fcontext -l | grep -E '{filespec} '" mock_cmd_shell.assert_called_once_with( expected_cmd_shell, ignore_retcode=True, @@ -433,7 +433,7 @@ def test_selinux_add_policy_shorter_path(name, sel_type): ): selinux.fcontext_add_policy(name, sel_type=sel_type) filespec = re.escape(name) - expected_cmd_shell = f"semanage fcontext -l | grep -E '{filespec}'" + expected_cmd_shell = f"semanage fcontext -l | grep -E '{filespec} '" mock_cmd_shell.assert_called_once_with( expected_cmd_shell, ignore_retcode=True,