Page MenuHomeDevCentral

Salt patch to supersede egrep by grep -E

Authored By
dereckson
Aug 3 2024, 10:04
Size
1 KB
Referenced Files
None
Subscribers
None

Salt patch to supersede egrep by grep -E

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
)

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2073471
Default Alt Text
Salt patch to supersede egrep by grep -E (1 KB)

Event Timeline