summaryrefslogtreecommitdiffstats
path: root/security/ossec-hids-local/scripts/plist.sh
diff options
context:
space:
mode:
Diffstat (limited to 'security/ossec-hids-local/scripts/plist.sh')
-rw-r--r--security/ossec-hids-local/scripts/plist.sh101
1 files changed, 53 insertions, 48 deletions
diff --git a/security/ossec-hids-local/scripts/plist.sh b/security/ossec-hids-local/scripts/plist.sh
index c08c5e1..e5ef2c1 100644
--- a/security/ossec-hids-local/scripts/plist.sh
+++ b/security/ossec-hids-local/scripts/plist.sh
@@ -11,18 +11,38 @@ PLIST=$3
WORKDIR=$4
STAGEDIR=$5
-staged_plist="${WORKDIR}/.staged-plist"
-fixed_lines=""
+fixed_lines="
+%%LUA%%@(,,0550) %%OSSEC_HOME%%/bin/ossec-lua
+%%LUA%%@(,,0550) %%OSSEC_HOME%%/bin/ossec-luac"
if [ "${OSSEC_TYPE}" != "agent" ]; then
- fixed_lines="${fixed_lines} %%MYSQL%%%%DOCSDIR%%/mysql.schema %%PGSQL%%%%DOCSDIR%%/postgresql.schema"
+ fixed_lines="${fixed_lines}
+%%MYSQL%%%%DOCSDIR%%/mysql.schema
+%%PGSQL%%%%DOCSDIR%%/postgresql.schema"
fi
-skip_lines="%%PORTDOCS%%%%DOCSDIR%%/mysql.schema %%PORTDOCS%%%%DOCSDIR%%/postgresql.schema"
-skip_paths="/etc/ossec.conf /etc/client.keys /logs/active-responses.log /logs/ossec.log /lua"
-sample_paths="/etc/local_internal_options.conf.sample"
-if [ "${OSSEC_TYPE}" == "agent" ]; then
- skip_paths="${skip_paths} /rules /agentless /.ssh"
+
+skip_lines="
+%%PORTDOCS%%%%DOCSDIR%%/mysql.schema
+%%PORTDOCS%%%%DOCSDIR%%/postgresql.schema"
+
+skip_paths="
+/etc/ossec.conf
+/etc/client.keys
+/logs/active-responses.log
+/logs/ossec.log
+/lua"
+if [ "${OSSEC_TYPE}" = "agent" ]; then
+ skip_paths="${skip_paths}
+/rules
+/agentless
+/.ssh"
fi
+sample_paths="
+/etc/local_internal_options.conf.sample"
+
+NL=$'\n'
+IFS=${NL}
+
print_path() {
local path="$1"
local command="$2"
@@ -34,15 +54,28 @@ print_path() {
fi
fi
local user=`stat -f "%Su" "${full_path}"`
- if [ "${user}" == "${USER}" ]; then
+ if [ "${user}" = "${USER}" ]; then
user=""
fi
local group=`stat -f "%Sg" "${full_path}"`
- if [ "${group}" == "${GROUP}" ]; then
+ if [ "${group}" = "${GROUP}" ]; then
group=""
fi
local mode=`stat -f "%p" "${full_path}" | tail -c 5`
- echo -e "${command}(${user},${group},${mode}) %%OSSEC_HOME%%${path}" >> "${PLIST}"
+ echo "${command}(${user},${group},${mode}) %%OSSEC_HOME%%${path}" >> "${PLIST}"
+}
+
+contains() {
+ local list="$1"
+ local word="$2"
+
+ for e in ${list}; do
+ if [ "${e}" = "${word}" ]; then
+ return 0
+ fi
+ done
+
+ return 1
}
echo -n > "${PLIST}"
@@ -51,16 +84,9 @@ print_path
done_paths=""
while read line; do
- skip_line=""
- for e in ${skip_lines}; do
- if [ "${e}" == "${line}" ]; then
- skip_line="${e}"
- break
- fi
- done
- if [ -z "${skip_line}" ]; then
+ if ! contains "${skip_lines}" "${line}"; then
path=""
- case $line in
+ case ${line} in
"@dir %%OSSEC_HOME%%"*)
path=`echo "${line}" | sed -e "s|@dir %%OSSEC_HOME%%||g"`
;;
@@ -68,7 +94,7 @@ while read line; do
path=`echo "${line}" | sed -e "s|%%OSSEC_HOME%%||g"`
;;
"%%"*)
- unchanged_lines="${unchanged_lines} ${line}"
+ unchanged_lines="${unchanged_lines}${NL}${line}"
;;
esac
if [ -n "${path}" ]; then
@@ -76,33 +102,12 @@ while read line; do
path=""
for segment in ${segments}; do
path="${path}/${segment}"
- skip_path=""
- for e in ${skip_paths}; do
- if [ "${e}" == "${path}" ]; then
- skip_path="${e}"
- break
- fi
- done
- if [ -n "${skip_path}" ]; then
+ if contains "${skip_paths}" "${path}"; then
break
fi
- done_path=""
- for e in ${done_paths}; do
- if [ "${e}" == "${path}" ]; then
- done_path="${e}"
- break
- fi
- done
- if [ -z "${done_path}" ]; then
- done_paths="${done_paths} ${path}"
- sample_path=""
- for e in ${sample_paths}; do
- if [ "${e}" == "${path}" ]; then
- sample_path="${e}"
- break
- fi
- done
- if [ -n "${sample_path}" ]; then
+ if ! contains "${done_paths}" "${path}"; then
+ done_paths="${done_paths}${NL}${path}"
+ if contains "${sample_paths}" "${path}"; then
print_path "${path}" @sample
else
print_path "${path}"
@@ -111,9 +116,9 @@ while read line; do
done
fi
fi
-done < "${staged_plist}"
+done < "${WORKDIR}/.staged-plist"
-unchanged_lines="${unchanged_lines} ${fixed_lines}"
+unchanged_lines="${unchanged_lines}${NL}${fixed_lines}"
for line in ${unchanged_lines}; do
echo "${line}" >> "${PLIST}"
done