git: 329f3e8d8b54 - main - security/ossec-hids-*: fix broken config scripts

From: Palle Girgensohn <girgen_at_FreeBSD.org>
Date: Fri, 17 Jun 2022 08:28:26 UTC
The branch main has been updated by girgen:

URL: https://cgit.FreeBSD.org/ports/commit/?id=329f3e8d8b5441522a078c74e594a14651a00075

commit 329f3e8d8b5441522a078c74e594a14651a00075
Author:     Palle Girgensohn <girgen@FreeBSD.org>
AuthorDate: 2022-06-17 08:07:25 +0000
Commit:     Palle Girgensohn <girgen@FreeBSD.org>
CommitDate: 2022-06-17 08:28:22 +0000

    security/ossec-hids-*: fix broken config scripts
    
    - No binary changes
    - Replaced all 'sed' invocations with 'sed -E' and adjusted regexes accordingly
    
    PR:             256545
    Submitted by:   Dominik Lisiak (maintainer)
---
 security/ossec-hids-local-config/Makefile                     | 1 +
 security/ossec-hids-local-config/files/agent-conf.in          | 4 ++--
 security/ossec-hids-local-config/files/ossec-conf.in          | 6 +++---
 security/ossec-hids-local-config/scripts/plist.sh             | 4 ++--
 security/ossec-hids-local-config/scripts/template-to-agent.sh | 5 +++--
 security/ossec-hids-local-config/scripts/template-to-ossec.sh | 8 +++++---
 security/ossec-hids-local/files/ossec-hids.in                 | 2 +-
 security/ossec-hids-local/scripts/plist.sh                    | 4 ++--
 8 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/security/ossec-hids-local-config/Makefile b/security/ossec-hids-local-config/Makefile
index c021e6464248..fa4509d26524 100644
--- a/security/ossec-hids-local-config/Makefile
+++ b/security/ossec-hids-local-config/Makefile
@@ -1,3 +1,4 @@
+PORTREVISION?=	2
 PKGNAMESUFFIX?=	-${OSSEC_TYPE}-config
 COMMENT?=	Configuration manager for ossec-hids-${OSSEC_TYPE}
 OSSEC_TYPE?=	local
diff --git a/security/ossec-hids-local-config/files/agent-conf.in b/security/ossec-hids-local-config/files/agent-conf.in
index 673d0f668631..a1da79d894b5 100644
--- a/security/ossec-hids-local-config/files/agent-conf.in
+++ b/security/ossec-hids-local-config/files/agent-conf.in
@@ -8,7 +8,7 @@ agent_conf_files="${agent_conf_dir}/*.conf"
 
 select_elements() {
     local element="$1"
-    sed -n "/<${element}.*>/,/<\/${element}>/p"
+    sed -En "/<${element}.*>/,/<\/${element}>/p"
 }
 
 remove_comments() {
@@ -17,7 +17,7 @@ remove_comments() {
 }
 
 remove_empty_lines() {
-    sed '/^\s*$/d'
+    sed -E '/^[[:space:]]*$/d'
 }
 
 agent_conf() {
diff --git a/security/ossec-hids-local-config/files/ossec-conf.in b/security/ossec-hids-local-config/files/ossec-conf.in
index d28d238bc212..1afdb5466774 100644
--- a/security/ossec-hids-local-config/files/ossec-conf.in
+++ b/security/ossec-hids-local-config/files/ossec-conf.in
@@ -8,12 +8,12 @@ ossec_conf_files="${ossec_conf_dir}/*.conf"
 
 select_elements_content() {
     local element="$1"
-    sed -n "/<${element}>/,/<\/${element}>/{ /<${element}>/d; /<\/${element}>/d; p; }"
+    sed -En "/<${element}>/,/<\/${element}>/{ /<${element}>/d; /<\/${element}>/d; p; }"
 }
 
 remove_elements() {
     local element="$1"
-    sed -e "/<${element}>/,/<\/${element}>/d"
+    sed -E "/<${element}>/,/<\/${element}>/d"
 }
 
 remove_comments() {
@@ -22,7 +22,7 @@ remove_comments() {
 }
 
 remove_empty_lines() {
-    sed '/^\s*$/d'
+    sed -E '/^[[:space:]]*$/d'
 }
 
 ossec_conf() {
diff --git a/security/ossec-hids-local-config/scripts/plist.sh b/security/ossec-hids-local-config/scripts/plist.sh
index b1915c47ce7b..07fbcd5d4097 100644
--- a/security/ossec-hids-local-config/scripts/plist.sh
+++ b/security/ossec-hids-local-config/scripts/plist.sh
@@ -61,10 +61,10 @@ while read line; do
         path=""
         case ${line} in
             "@dir %%OSSEC_HOME%%"*)
-                path=`echo "${line}" | sed -e "s|@dir %%OSSEC_HOME%%||g"`
+                path=`echo "${line}" | sed -E 's|@dir %%OSSEC_HOME%%||g'`
                 ;;
             "%%OSSEC_HOME%%"*)
-                path=`echo "${line}" | sed -e "s|%%OSSEC_HOME%%||g"`
+                path=`echo "${line}" | sed -E 's|%%OSSEC_HOME%%||g'`
                 ;;
             "%%"*)
                 unchanged_lines="${unchanged_lines}${NL}${line}"
diff --git a/security/ossec-hids-local-config/scripts/template-to-agent.sh b/security/ossec-hids-local-config/scripts/template-to-agent.sh
index 3034b1fe1254..7c11b820f646 100644
--- a/security/ossec-hids-local-config/scripts/template-to-agent.sh
+++ b/security/ossec-hids-local-config/scripts/template-to-agent.sh
@@ -19,7 +19,8 @@ ossec_syscheck_bin_dirs="${ossec_prefix}/bin,${ossec_prefix}/active-response"
 ossec_syscheck_etc_dirs="${ossec_prefix}/etc"
 
 replace() {
-    sed -e 's|<template_config \(.*\)>|<agent_config \1>|' \
+    sed -E \
+        -e 's|<template_config (.*)>|<agent_config \1>|' \
         -e 's|</template_config>|</agent_config>|' \
         -e "s|%%OSSEC_SYSCHECK_BIN_DIRS%%|${ossec_syscheck_bin_dirs}|" \
         -e "s|%%OSSEC_SYSCHECK_ETC_DIRS%%|${ossec_syscheck_etc_dirs}|" \
@@ -27,7 +28,7 @@ replace() {
 }
 
 extract() {
-    sed -n '/^<agent_config .*>$/,/^<\/agent_config>$/p'
+    sed -En '/^<agent_config .*>$/,/^<\/agent_config>$/p'
 }
 
 replace | extract
diff --git a/security/ossec-hids-local-config/scripts/template-to-ossec.sh b/security/ossec-hids-local-config/scripts/template-to-ossec.sh
index 39334462a987..5ad322893370 100644
--- a/security/ossec-hids-local-config/scripts/template-to-ossec.sh
+++ b/security/ossec-hids-local-config/scripts/template-to-ossec.sh
@@ -24,13 +24,15 @@ fi
 
 replace() {
     if grep -q "<template_config>" "${ossec_file}"; then
-        sed -e 's|<template_config>|<ossec_config>|' \
+        sed -E \
+            -e 's|<template_config>|<ossec_config>|' \
             -e 's|</template_config>|</ossec_config>|' \
             -e "s|%%OSSEC_SYSCHECK_BIN_DIRS%%|${ossec_syscheck_bin_dirs}|" \
             -e "s|%%OSSEC_SYSCHECK_ETC_DIRS%%|${ossec_syscheck_etc_dirs}|" \
             "${ossec_file}"
     else
-        sed -e 's|<template_config .*os="FreeBSD".*>|<ossec_config>|' \
+        sed -E \
+            -e 's|<template_config .*os="FreeBSD".*>|<ossec_config>|' \
             -e 's|</template_config>|</ossec_config>|' \
             -e "s|%%OSSEC_SYSCHECK_BIN_DIRS%%|${ossec_syscheck_bin_dirs}|" \
             -e "s|%%OSSEC_SYSCHECK_ETC_DIRS%%|${ossec_syscheck_etc_dirs}|" \
@@ -39,7 +41,7 @@ replace() {
 }
 
 extract() {
-    sed -n '/^<ossec_config.*>$/,/^<\/ossec_config>$/p'
+    sed -En '/^<ossec_config.*>$/,/^<\/ossec_config>$/p'
 }
 
 replace | extract
diff --git a/security/ossec-hids-local/files/ossec-hids.in b/security/ossec-hids-local/files/ossec-hids.in
index 6c580f268b37..87783766b839 100644
--- a/security/ossec-hids-local/files/ossec-hids.in
+++ b/security/ossec-hids-local/files/ossec-hids.in
@@ -486,7 +486,7 @@ ossec_hids_fetch_config() {
             echo "${ossec_rc_path} reset_counter"
             echo "${ossec_rc_path} fetch_config"
             echo
-            echo "If this does't help, you need to reset counter on the server."
+            echo "If this doesn't help, you need to reset counter on the server."
             echo "If the server runs FreeBSD port of OSSEC, run:"
             echo "On the agent:"
             echo "${ossec_rc_path} reset_counter"
diff --git a/security/ossec-hids-local/scripts/plist.sh b/security/ossec-hids-local/scripts/plist.sh
index b1915c47ce7b..07fbcd5d4097 100644
--- a/security/ossec-hids-local/scripts/plist.sh
+++ b/security/ossec-hids-local/scripts/plist.sh
@@ -61,10 +61,10 @@ while read line; do
         path=""
         case ${line} in
             "@dir %%OSSEC_HOME%%"*)
-                path=`echo "${line}" | sed -e "s|@dir %%OSSEC_HOME%%||g"`
+                path=`echo "${line}" | sed -E 's|@dir %%OSSEC_HOME%%||g'`
                 ;;
             "%%OSSEC_HOME%%"*)
-                path=`echo "${line}" | sed -e "s|%%OSSEC_HOME%%||g"`
+                path=`echo "${line}" | sed -E 's|%%OSSEC_HOME%%||g'`
                 ;;
             "%%"*)
                 unchanged_lines="${unchanged_lines}${NL}${line}"