39
39
db_metaget clamav-milter/debconf value || true
40
40
if [ "$RET" = "true" ]; then
41
41
db_metaget clamav-milter/MilterSocket value || true
43
43
db_metaget clamav-milter/FixStaleSocket value || true
45
45
db_metaget clamav-milter/User value || true
47
47
db_metaget clamav-milter/AddGroups value || true
49
49
db_metaget clamav-milter/ReadTimeout value || true
51
51
db_metaget clamav-milter/Foreground value || true
53
53
db_metaget clamav-milter/Chroot value || true
55
55
db_metaget clamav-milter/PidFile value || true
57
57
db_metaget clamav-milter/TemporaryDirectory value || true
58
TemporaryDirectory="$RET"
58
temporarydirectory="$RET"
59
59
db_metaget clamav-milter/ClamdSocket value || true
61
61
db_metaget clamav-milter/LocalNet value || true
63
63
db_metaget clamav-milter/Whitelist value || true
65
db_metaget clamav-milter/OnClean value || true
67
65
db_metaget clamav-milter/OnInfected value || true
69
67
db_metaget clamav-milter/OnFail value || true
71
69
db_metaget clamav-milter/RejectMsg value || true
73
71
db_metaget clamav-milter/AddHeader value || true
75
73
db_metaget clamav-milter/LogFile value || true
77
75
db_metaget clamav-milter/LogFileUnlock value || true
79
77
db_metaget clamav-milter/LogFileMaxSize value || true
80
LogFileMaxSize="${RET}M"
78
logfilemaxsize="${RET}M"
81
79
db_metaget clamav-milter/LogTime value || true
83
81
db_metaget clamav-milter/LogSyslog value || true
85
83
db_metaget clamav-milter/LogFacility value || true
87
85
db_metaget clamav-milter/LogVerbose value || true
89
87
db_metaget clamav-milter/LogInfected value || true
91
89
db_metaget clamav-milter/MaxFileSize value || true
92
90
maxfilesize="`echo $RET | sed -e s/M//g`"
93
MaxFileSize="${maxfilesize}M"
95
if [ -z "$LogFile" ] || [ "$LogFile" = 'none' ]; then
91
MaxFSize="${maxfilesize}M"
93
if [ -z "$logfile" ] || [ "$logfile" = 'none' ]; then
97
if is_false $addheader; then
99
elif is_true $addheader; then
99
103
slurp_config "$CLAMAVMILTERCONF"
101
105
echo "#Automatically Generated by clamav-milter postinst" > $DEBCONFFILE
102
106
echo "#To reconfigure clamav-milter run #dpkg-reconfigure clamav-milter" >> $DEBCONFFILE
103
107
echo "#Please read /usr/share/doc/clamav-base/README.Debian.gz for details" >> $DEBCONFFILE
104
[ -z "$MilterSocket" ] && MilterSocket="/var/run/clamav/milter.ctl"
105
[ -z "$FixStaleSocket" ] && FixStaleSocket="true"
106
[ -z "$User" ] && User=clamav
108
[ -z "$MilterSocket" ] || [ "$MilterSocket" = 'true' ] && miltersocket="/var/run/clamav/milter.ctl"
109
[ -z "$FixStaleSocket" ] && fixstalesocket="true"
110
[ -z "$User" ] && user=clamav
107
111
[ -z "$AllowSupplementaryGroups" -o -n "$AddGroups" ] && AllowSupplementaryGroups=true
108
[ -z "$ReadTimeout" ] && ReadTimeout="120"
109
[ -z "$Foreground" ] && Foreground="false"
110
[ -z "$PidFile" ] && PidFile="/var/run/clamav/clamav-milter.pid"
111
[ -z "$ClamdSocket" ] && ClamdSocket="unix:/var/run/clamav/clamd.ctl"
112
[ -z "$OnClean" ] && OnClean="Accept"
113
[ -z "$OnInfected" ] && OnInfected="Quarantine"
114
[ -z "$OnFail" ] && OnFail="Defer"
115
[ -z "$AddHeader" ] && AddHeader="false"
116
[ -z "$LogSyslog" ] && LogSyslog="false"
117
[ -z "$LogFacility" ] && LogFacility="LOG_LOCAL6"
118
[ -z "$LogVerbose" ] && LogVerbose="false"
119
[ -z "$LogInfected" ] && LogInfected="Off"
120
[ -z "$MaxFileSize" ] && MaxFileSize="25M"
112
[ -z "$ReadTimeout" ] && readtimeout="120"
113
[ -z "$Foreground" ] && foreground="false"
114
[ -z "$PidFile" ] && pidfile="/var/run/clamav/clamav-milter.pid"
115
[ -z "$ClamdSocket" ] && clamdsocket="unix:/var/run/clamav/clamd.ctl"
116
[ -z "$OnClean" ] || [ "$OnClean" = 'true' ] && onclean="Accept"
117
[ -z "$OnInfected" ] && oninfected="Quarantine"
118
[ -z "$OnFail" ] && onfail="Defer"
119
[ -z "$AddHeader" ] && addheader="Replace"
120
[ -z "$LogSyslog" ] && logsyslog="false"
121
[ -z "$LogFacility" ] && logfacility="LOG_LOCAL6"
122
[ -z "$LogVerbose" ] && logverbose="false"
123
[ -z "$LogInfected" ] && loginfected="Off"
124
[ -z "$MaxFileSize" ] && MaxFSize="25M"
125
[ -z "$LogFile" ] && [ -z "$logfile" ] && is_false "$logsyslog" && logfile=/var/log/clamav/clamav-milter.log
127
if [ -z "$allowsupplementarygroups" ] && [ -n "$AllowSupplementaryGroups" ]; then
128
allowsupplementarygroups="$AllowSupplementaryGroups"
131
if [ -z "$onclean" ] && [ -n "$OnClean" ]; then
122
135
cat >> $DEBCONFFILE << EOF
123
MilterSocket $MilterSocket
124
FixStaleSocket $FixStaleSocket
126
AllowSupplementaryGroups $AllowSupplementaryGroups
127
ReadTimeout $ReadTimeout
128
Foreground $Foreground
130
ClamdSocket $ClamdSocket
132
OnInfected $OnInfected
136
LogFacility $LogFacility
137
LogVerbose $LogVerbose
138
LogInfected $LogInfected
139
MaxFileSize $MaxFileSize
136
MilterSocket $miltersocket
137
FixStaleSocket $fixstalesocket
139
AllowSupplementaryGroups $allowsupplementarygroups
140
ReadTimeout $readtimeout
141
Foreground $foreground
143
ClamdSocket $clamdsocket
145
OnInfected $oninfected
149
LogFacility $logfacility
150
LogVerbose $logverbose
151
LogInfected $loginfected
152
MaxFileSize $MaxFSize
141
154
if [ -n "$SkipAuthenticated" ]; then
142
155
cat >> $DEBCONFFILE << EOF
147
if [ -n "$Chroot" ]; then
148
cat >> $DEBCONFFILE << EOF
153
if [ -n "$LocalNet" ]; then
154
cat >> $DEBCONFFILE << EOF
159
if [ -n "$Whitelist" ]; then
160
cat >> $DEBCONFFILE << EOF
165
if [ -n "$RejectMsg" ]; then
166
cat >> $DEBCONFFILE << EOF
171
if [ -n "$TemporaryDirectory" ]; then
160
if [ -n "$chroot" ]; then
161
cat >> $DEBCONFFILE << EOF
166
if [ -n "$localnet" ]; then
167
cat >> $DEBCONFFILE << EOF
172
if [ -n "$whitelist" ]; then
173
cat >> $DEBCONFFILE << EOF
178
if [ -n "$rejectmsg" ]; then
179
cat >> $DEBCONFFILE << EOF
184
if [ -n "$temporarydirectory" ]; then
172
185
cat >> $DEBCONFFILE << EOF
173
TemporaryDirectory $TemporaryDirectory
186
TemporaryDirectory $temporarydirectory
176
189
cat >> $DEBCONFFILE << EOF
182
if [ -n "$LogFile" ] && [ "$LogFile" != 'none' ]; then
183
echo "LogFile $LogFile" >> $DEBCONFFILE
184
echo "LogTime $LogTime" >> $DEBCONFFILE
185
echo "LogFileUnlock $LogFileUnlock" >> $DEBCONFFILE
186
echo "LogFileMaxSize $LogFileMaxSize" >> $DEBCONFFILE
195
if [ -n "$logfile" ] && [ "$logfile" != 'none' ]; then
196
echo "LogFile $logfile" >> $DEBCONFFILE
197
echo "LogTime $logtime" >> $DEBCONFFILE
198
echo "LogFileUnlock $logfileunlock" >> $DEBCONFFILE
199
echo "LogFileMaxSize $logfilemaxsize" >> $DEBCONFFILE
189
202
ucf_cleanup "$CLAMAVMILTERCONF"
204
217
chmod 644 $CLAMAVMILTERCONF || true
205
218
chown root:root $CLAMAVMILTERCONF || true
207
slurp_config "$CLAMAVMILTERCONF"
209
if [ -n "$LogFile" ] && [ "$LogFile" != 'none' ]; then
210
if echo "$LogFile" | grep -q '^/dev/'; then
220
if [ -n "$logfile" ] && [ "$logfile" != 'none' ]; then
221
if echo "$logfile" | grep -q '^/dev/'; then
211
222
make_logrotate=false
213
224
make_logrotate=true
215
[ -n "$User" ] || User=clamav
226
[ -n "$user" ] || user=clamav
216
227
if [ "$make_logrotate" = 'true' ]; then
217
echo "$LogFile {" > $DEBROTATEFILE
228
echo "$logfile {" > $DEBROTATEFILE
218
229
echo " rotate 12" >> $DEBROTATEFILE
219
230
echo " weekly" >> $DEBROTATEFILE
220
231
echo " compress" >> $DEBROTATEFILE
224
235
echo " /etc/init.d/clamav-milter restart > /dev/null" >> $DEBROTATEFILE
225
236
echo " endscript" >> $DEBROTATEFILE
226
237
echo " }" >> $DEBROTATEFILE
228
chown "$User":adm "$LogFile"
229
chmod 0640 "$LogFile"
239
chown "$user":adm "$logfile"
240
chmod 0640 "$logfile"
230
241
ucf_cleanup "$CLAMAVROTATEFILE"
231
242
ucf_upgrade_check "$CLAMAVROTATEFILE" "$DEBROTATEFILE" /var/lib/ucf/cache/:etc:logrotate.d:clamav-milter
232
243
rm -f $DEBROTATEFILE
257
# clamav-milter between 0.95+dfsg-2ubuntu1 and 0.95.1+dfsg-1ubuntu1.1 had
258
# broken init and postinst scripts, which did some bad things
259
# this should clean it up (LP: #365823, #363796, #363804)
260
if dpkg --compare-versions "$2" le-nl "0.95.1+dfsg-1ubuntu1.2~" &&
261
dpkg --compare-versions "$2" ge "0.95+dfsg-2ubuntu1"
266
# remove rogue /none file created by postinst
267
find /none -type f -size 0 -user clamav -exec rm -f {} \; 2>/dev/null || true
269
# search for and fix other directories' owner
271
/bin /boot /dev /etc /lib /lib32 /lib64 /root /sbin /usr \
272
/var/backups /var/cache /var/games /var/lib /var/local \
273
/var/log /var/mail /var/spool"
274
find -H $DIR_LIST -type d -user clamav -gid 0 -print0 2>/dev/null | xargs -r -0 chown root -- || true
276
STICKY_DIR_LIST="/tmp /var/crash /var/lock /var/tmp"
277
find $STICKY_DIR_LIST -maxdepth 0 -user clamav -gid 0 -print0 2>/dev/null | xargs -r -0 chown root -- || true
279
# clean up rogue clamav-milter logrotate config
280
if [ -f /etc/logrotate.d/clamav-milter ] &&
281
head -1 /etc/logrotate.d/clamav-milter | grep -q "^none"
283
rm -f /etc/logrotate.d/clamav-milter
287
268
# dh_installdeb will replace this with shell code automatically
288
269
# generated by other debhelper scripts.