blob: e5ef2c1b647a01df674ecaa185294e98fe65b252 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#!/bin/sh
# Script generates entries for pkg-plist.
# Do not use it directly. Use the following command instead:
#
# make MAINTAINER_MODE=yes clean plist
OSSEC_TYPE=$1
OSSEC_HOME=$2
PLIST=$3
WORKDIR=$4
STAGEDIR=$5
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"
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"
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"
local full_path="${STAGEDIR}${OSSEC_HOME}${path}"
if [ -z "${command}" ]; then
command="@"
if [ -d "${full_path}" ]; then
command="@dir"
fi
fi
local user=`stat -f "%Su" "${full_path}"`
if [ "${user}" = "${USER}" ]; then
user=""
fi
local group=`stat -f "%Sg" "${full_path}"`
if [ "${group}" = "${GROUP}" ]; then
group=""
fi
local mode=`stat -f "%p" "${full_path}" | tail -c 5`
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}"
print_path
done_paths=""
while read line; do
if ! contains "${skip_lines}" "${line}"; then
path=""
case ${line} in
"@dir %%OSSEC_HOME%%"*)
path=`echo "${line}" | sed -e "s|@dir %%OSSEC_HOME%%||g"`
;;
"%%OSSEC_HOME%%"*)
path=`echo "${line}" | sed -e "s|%%OSSEC_HOME%%||g"`
;;
"%%"*)
unchanged_lines="${unchanged_lines}${NL}${line}"
;;
esac
if [ -n "${path}" ]; then
segments=`echo "${path}" | tr "/" "\n"`
path=""
for segment in ${segments}; do
path="${path}/${segment}"
if contains "${skip_paths}" "${path}"; then
break
fi
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}"
fi
fi
done
fi
fi
done < "${WORKDIR}/.staged-plist"
unchanged_lines="${unchanged_lines}${NL}${fixed_lines}"
for line in ${unchanged_lines}; do
echo "${line}" >> "${PLIST}"
done
|