Page MenuHomeDevCentral
Paste P354

Salt patch to supersede egrep by grep -E
ActivePublic

Authored by dereckson on Aug 3 2024, 10:04.
Tags
None
Referenced Files
F3441495: Salt patch to supersede egrep by grep -E
Aug 3 2024, 10:04
Subscribers
None
diff --git a/modules/csf.py b/modules/csf.py
index 0f7a27c..5fd8b21 100644
--- a/modules/csf.py
+++ b/modules/csf.py
@@ -71,7 +71,7 @@ def exists(
ip, port, proto, direction, port_origin, ip_origin, comment
)
return _exists_with_port(method, rule)
- exists = __salt__["cmd.run_all"](f"egrep ^'{ip} +' /etc/csf/csf.{method}")
+ exists = __salt__["cmd.run_all"](f"grep -E ^'{ip} +' /etc/csf/csf.{method}")
return not bool(exists["retcode"])
diff --git a/modules/selinux.py b/modules/selinux.py
index 8201d87..8364141 100644
--- a/modules/selinux.py
+++ b/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 | egrep '{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"
@@ -762,7 +762,7 @@ def port_get_policy(name, sel_type=None, protocol=None, port=None):
"port": port,
}
cmd = (
- "semanage port -l | egrep "
+ "semanage port -l | grep -E "
+ "'^{sel_type}{spacer}{protocol}{spacer}((.*)*)[ ]{port}($|,)'".format(
**cmd_kwargs
)