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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
#! /bin/sh
# postinst script for #PACKAGE#
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
#loading debconf module
. /usr/share/debconf/confmodule
#COMMON-FUNCTIONS#
case "$1" in
configure)
CLAMAVMILTERCONF=/etc/clamav/clamav-milter.conf
DEBROTATEFILE=/var/lib/clamav/clamav-milter.rotate.debconf
CLAMAVROTATEFILE=/etc/logrotate.d/clamav-milter
DEBCONFFILE=/var/lib/clamav/clamav-milter.conf
db_metaget clamav-milter/debconf value || true
if [ "$RET" = "true" ]; then
db_metaget clamav-milter/MilterSocket value || true
miltersocket="$RET"
db_metaget clamav-milter/FixStaleSocket value || true
fixstalesocket="$RET"
db_metaget clamav-milter/MilterSocketGroup value || true
miltersocketgrp="$RET"
db_metaget clamav-milter/MilterSocketMode value || true
miltersocketmode="$RET"
db_metaget clamav-milter/User value || true
user="$RET"
db_metaget clamav-milter/AddGroups value || true
addgroups="$RET"
db_metaget clamav-milter/ReadTimeout value || true
readtimeout="$RET"
db_metaget clamav-milter/Foreground value || true
foreground="$RET"
db_metaget clamav-milter/Chroot value || true
chroot="$RET"
db_metaget clamav-milter/PidFile value || true
pidfile="$RET"
db_metaget clamav-milter/TemporaryDirectory value || true
temporarydirectory="$RET"
db_metaget clamav-milter/ClamdSocket value || true
clamdsocket="$RET"
db_metaget clamav-milter/LocalNet value || true
localnet="$RET"
db_metaget clamav-milter/Whitelist value || true
whitelist="$RET"
db_metaget clamav-milter/OnInfected value || true
oninfected="$RET"
db_metaget clamav-milter/OnFail value || true
onfail="$RET"
db_metaget clamav-milter/RejectMsg value || true
rejectmsg="$RET"
db_metaget clamav-milter/AddHeader value || true
addheader="$RET"
db_metaget clamav-milter/LogFile value || true
logfile="$RET"
db_metaget clamav-milter/LogFileUnlock value || true
logfileunlock="$RET"
db_metaget clamav-milter/LogFileMaxSize value || true
logfilemaxsize="${RET}M"
db_metaget clamav-milter/LogTime value || true
logtime="$RET"
db_metaget clamav-milter/LogSyslog value || true
logsyslog="$RET"
db_metaget clamav-milter/LogFacility value || true
logfacility="$RET"
db_metaget clamav-milter/LogVerbose value || true
logverbose="$RET"
db_metaget clamav-milter/LogInfected value || true
loginfected="$RET"
db_metaget clamav-milter/MaxFileSize value || true
maxfilesize="`echo $RET | sed -e s/M//g`"
MaxFSize="${maxfilesize}M"
if [ -z "$logfile" ] || [ "$logfile" = 'none' ]; then
logsyslog=true
fi
if is_false $addheader; then
addheader=no
elif is_true $addheader; then
addheader=Replace
fi
slurp_config "$CLAMAVMILTERCONF"
echo "#Automatically Generated by clamav-milter postinst" > $DEBCONFFILE
echo "#To reconfigure clamav-milter run #dpkg-reconfigure clamav-milter" >> $DEBCONFFILE
echo "#Please read /usr/share/doc/clamav-base/README.Debian.gz for details" >> $DEBCONFFILE
[ -z "$MilterSocket" ] || [ "$MilterSocket" = 'true' ] && miltersocket="/var/run/clamav/clamav-milter.ctl"
[ -z "$FixStaleSocket" ] && fixstalesocket="true"
[ -z "$User" ] && user=clamav
[ -z "$AllowSupplementaryGroups" -o -n "$AddGroups" ] && AllowSupplementaryGroups=true
[ -z "$ReadTimeout" ] && readtimeout="120"
[ -z "$Foreground" ] && foreground="false"
[ -z "$PidFile" ] && pidfile="/var/run/clamav/clamav-milter.pid"
[ -z "$ClamdSocket" ] && clamdsocket="unix:/var/run/clamav/clamd.ctl"
[ -z "$OnClean" ] || [ "$OnClean" = 'true' ] && onclean="Accept"
[ -z "$OnInfected" ] && oninfected="Quarantine"
[ -z "$OnFail" ] && onfail="Defer"
[ -z "$AddHeader" ] && addheader="Replace"
[ -z "$LogSyslog" ] && logsyslog="false"
[ -z "$LogFacility" ] && logfacility="LOG_LOCAL6"
[ -z "$LogVerbose" ] && logverbose="false"
[ -z "$LogInfected" ] && loginfected="Off"
[ -z "$MaxFileSize" ] && MaxFSize="25M"
[ -z "$LogFile" ] && [ -z "$logfile" ] && is_false "$logsyslog" && logfile=/var/log/clamav/clamav-milter.log
[ -z "$miltersocketgrp" ] && [ -n "$MilterSocketGroup" ] && miltersocketgrp="$MilterSocketGroup"
[ -z "$miltersocketmode" ] && [ -n "$MilterSocketMode" ] && miltersocketmode="$MilterSocketGroup"
if [ -z "$allowsupplementarygroups" ] && [ -n "$AllowSupplementaryGroups" ]; then
allowsupplementarygroups="$AllowSupplementaryGroups"
fi
if [ -z "$onclean" ] && [ -n "$OnClean" ]; then
onclean="$OnClean"
fi
cat >> $DEBCONFFILE << EOF
MilterSocket $miltersocket
FixStaleSocket $fixstalesocket
User $user
AllowSupplementaryGroups $allowsupplementarygroups
ReadTimeout $readtimeout
Foreground $foreground
PidFile $pidfile
ClamdSocket $clamdsocket
OnClean $onclean
OnInfected $oninfected
OnFail $onfail
AddHeader $addheader
LogSyslog $logsyslog
LogFacility $logfacility
LogVerbose $logverbose
LogInfected $loginfected
MaxFileSize $MaxFSize
EOF
if [ -n "$SkipAuthenticated" ]; then
cat >> $DEBCONFFILE << EOF
SkipAuthenticated $SkipAuthenticated
EOF
fi
if [ -n "$chroot" ]; then
cat >> $DEBCONFFILE << EOF
Chroot $chroot
EOF
fi
if [ -n "$localnet" ]; then
cat >> $DEBCONFFILE << EOF
LocalNet $localnet
EOF
fi
if [ -n "$whitelist" ]; then
cat >> $DEBCONFFILE << EOF
Whitelist $whitelist
EOF
fi
if [ -n "$rejectmsg" ]; then
cat >> $DEBCONFFILE << EOF
RejectMsg $rejectmsg
EOF
fi
if [ -n "$temporarydirectory" ]; then
cat >> $DEBCONFFILE << EOF
TemporaryDirectory $temporarydirectory
EOF
else
cat >> $DEBCONFFILE << EOF
# TemporaryDirectory is not set to its default /tmp here to make overriding
# the default with environment variables TMPDIR/TMP/TEMP possible
EOF
fi
if [ -n "$logfile" ] && [ "$logfile" != 'none' ]; then
echo "LogFile $logfile" >> $DEBCONFFILE
echo "LogTime $logtime" >> $DEBCONFFILE
echo "LogFileUnlock $logfileunlock" >> $DEBCONFFILE
echo "LogFileMaxSize $logfilemaxsize" >> $DEBCONFFILE
fi
[ -n "$miltersocketgrp" ] && echo "MilterSocketGroup $miltersocketgrp" >> $DEBCONFFILE
[ -n "$miltersocketmode" ] && echo "MilterSocketMode $miltersocketmode" >> $DEBCONFFILE
[ -n "$ReportHostname" ] && echo "ReportHostname $ReportHostname" >> $DEBCONFFILE
[ -n "$VirusAction" ] && echo "VirusAction $VirusAction" >> $DEBCONFFILE
ucf_cleanup "$CLAMAVMILTERCONF"
ucf_upgrade_check "$CLAMAVMILTERCONF" "$DEBCONFFILE" /var/lib/ucf/cache/:etc:clamav:clamav-milter.conf
rm -f "$DEBCONFFILE"
if [ -n "$AddGroups" ]; then
for group in $AddGroups; do
id "$User" | grep -q "$group" || adduser "$User" "$group"
done
fi
else
ucf_cleanup "$CLAMAVMILTERCONF"
ucf_upgrade_check "$CLAMAVMILTERCONF" /usr/share/doc/clamav-milter/examples/clamav-milter.conf /var/lib/ucf/cache/:etc:clamav:clamav-milter.conf
fi
chmod 644 $CLAMAVMILTERCONF || true
chown root:root $CLAMAVMILTERCONF || true
if [ -n "$logfile" ] && [ "$logfile" != 'none' ]; then
if echo "$logfile" | grep -q '^/dev/'; then
make_logrotate=false
else
make_logrotate=true
fi
[ -n "$user" ] || user=clamav
if [ "$make_logrotate" = 'true' ]; then
echo "$logfile {" > $DEBROTATEFILE
echo " rotate 12" >> $DEBROTATEFILE
echo " weekly" >> $DEBROTATEFILE
echo " compress" >> $DEBROTATEFILE
echo " delaycompress" >> $DEBROTATEFILE
echo " create 640 $user adm" >> $DEBROTATEFILE
echo " postrotate" >> $DEBROTATEFILE
echo " /etc/init.d/clamav-milter restart > /dev/null" >> $DEBROTATEFILE
echo " endscript" >> $DEBROTATEFILE
echo " }" >> $DEBROTATEFILE
touch "$logfile"
chown "$user":adm "$logfile"
chmod 0640 "$logfile"
ucf_cleanup "$CLAMAVROTATEFILE"
ucf_upgrade_check "$CLAMAVROTATEFILE" "$DEBROTATEFILE" /var/lib/ucf/cache/:etc:logrotate.d:clamav-milter
rm -f $DEBROTATEFILE
else
if [ -e "$CLAMAVROTATEFILE" ]; then
echo "Disabling old logrotate script for clamav-milter"
mv "$CLAMAVROTATEFILE" "$CLAMAVROTATEFILE".dpkg-old
ucf -p "$CLAMAVROTATEFILE"
fi
fi
else
if [ -e "$CLAMAVROTATEFILE" ]; then
echo "Disabling old logrotate script for clamav-milter"
mv "$CLAMAVROTATEFILE" "$CLAMAVROTATEFILE".dpkg-old
ucf -p "$CLAMAVROTATEFILE"
fi
fi
db_stop || true
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
|