File: clamav-daemon.postinst.in

package info (click to toggle)
clamav 0.101.4+dfsg-0+deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 29,564 kB
  • sloc: ansic: 158,978; sh: 8,178; cpp: 5,173; makefile: 2,088; yacc: 1,351; lex: 714; python: 120; perl: 17
file content (548 lines) | stat: -rw-r--r-- 22,203 bytes parent folder | download
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
#! /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)

  # The DEB*FILE files are used temporarily during the update of the CLAMAV* files.
  DEBCONFFILE=/var/lib/clamav/clamav.conf
  CLAMAVCONF=/etc/clamav/clamd.conf
  DEBROTATEFILE=/var/lib/clamav/clamdrotate.debconf
  CLAMAVROTATEFILE=/etc/logrotate.d/clamav-daemon
  DEBSYSTEMDCLAMDCONF=/var/lib/clamav/extend.conf
  CLAMAVSYSTEMDCLAMDONF=/etc/systemd/system/clamav-daemon.service.d/extend.conf

  # Update the configuration file
  db_get clamav-daemon/debconf || true
  if [ "$RET" = "true" ]; then
    # Handle the configuration via debconf

    # Read the configuration file
    slurp_config "$CLAMAVCONF"

    # Get the debconf configuration
    db_get clamav-daemon/User || true
    User="$RET"
    db_get clamav-daemon/AddGroups || true
    AddGroups="$RET"
    db_get clamav-daemon/TcpOrLocal || true
    if [ "$RET" = "TCP" ]; then
      sock="tcp"
      db_get clamav-daemon/TCPSocket || true
      TCPSocket="$RET"
      db_get clamav-daemon/TCPAddr
      TCPAddr="$RET"
    else
      sock="unix"
      db_get clamav-daemon/LocalSocket || true
      LocalSocket="$RET"
      db_get clamav-daemon/FixStaleSocket || true
      FixStaleSocket="$RET"
      db_get clamav-daemon/LocalSocketGroup || true
      LocalSocketGroup="$RET"
      db_get clamav-daemon/LocalSocketMode || true
      LocalSocketMode="$RET"
    fi
    db_get clamav-daemon/ScanMail || true
    ScanMail="$RET"
    db_get clamav-daemon/ScanArchive || true
    ScanArchive="$RET"
    db_get clamav-daemon/MaxDirectoryRecursion || true
    if [ "$RET" != "0" ]; then
      MaxDirectoryRecursion="$RET"
      db_get clamav-daemon/FollowDirectorySymlinks || true
      FollowDirectorySymlinks="$RET"
    else
      MaxDirectoryRecursion=15
      FollowDirectorySymlinks=false
    fi
    db_get clamav-daemon/FollowFileSymlinks || true
    FollowFileSymlinks="$RET"
    db_get clamav-daemon/ThreadTimeout || true
    ThreadTimeout="$RET"
    db_get clamav-daemon/ReadTimeout || true
    ReadTimeout="$RET"
    [ -z "$ReadTimeout" ] && ReadTimeout="$ThreadTimeout"
    db_get clamav-daemon/MaxThreads || true
    MaxThreads="$RET"
    db_get clamav-daemon/MaxConnectionQueueLength || true
    MaxConnectionQueueLength="$RET"
    db_get clamav-daemon/StreamMaxLength || true
    StreamMaxLength="$RET"
    db_get clamav-daemon/LogSyslog || true
    LogSyslog="$RET"
    db_get clamav-daemon/LogFile || true
    if [ "$RET" != "" ]; then
      LogFile="$RET"
      db_get clamav-daemon/LogTime || true
      LogTime="$RET"
    fi
    db_get clamav-daemon/LogRotate || true
    LogRotate="$RET"
    db_get clamav-daemon/SelfCheck || true
    SelfCheck="$RET"
    db_get clamav-daemon/Bytecode || true
    Bytecode="$RET"
    if [ "$Bytecode" = "true" ]; then
      db_get clamav-daemon/BytecodeSecurity || true
      BytecodeSecurity="$RET"
      db_get clamav-daemon/BytecodeTimeout || true
      BytecodeTimeout="$RET"
    fi
    db_get clamav-daemon/ScanOnAccess || true
    ScanOnAccess="$RET"
    if [ "$ScanOnAccess" = "true" ]; then
      db_get clamav-daemon/OnAccessMaxFileSize || true
      OnAccessMaxFileSize="$RET"
    fi
    db_get clamav-daemon/AllowAllMatchScan || true
    AllowAllMatchScan="$RET"
    db_get clamav-daemon/ForceToDisk || true
    ForceToDisk="$RET"
    db_get clamav-daemon/DisableCertCheck || true
    DisableCertCheck="$RET"
    db_get clamav-daemon/ScanSWF || true
    ScanSWF="$RET"
    db_get clamav-daemon/MaxEmbeddedPE || true
    MaxEmbeddedPE="$RET"
    db_get clamav-daemon/MaxHTMLNormalize || true
    MaxHTMLNormalize="$RET"
    db_get clamav-daemon/MaxHTMLNoTags || true
    MaxHTMLNoTags="$RET"
    db_get clamav-daemon/MaxScriptNormalize || true
    MaxScriptNormalize="$RET"
    db_get clamav-daemon/MaxZipTypeRcg || true
    MaxZipTypeRcg="$RET"
    db_get clamav-daemon/BlockMax || RET=""
    BlockMax="$RET"

    # Test for the broken versions, see #741675.
    if [ "$2" = "0.98.1+dfsg-3" ] || [ "$2" = "0.98.1+dfsg-1+deb7u2" ] || [ "$2" = "0.98.1+dfsg-1+deb6u2" ]; then
      # Use the defaults instead of the bogus values created by that versions.
      db_metaget clamav-daemon/LogRotate default || true
      LogRotate="$RET"
      db_metaget clamav-daemon/ScanOnAccess default || true
      ScanOnAccess="$RET"
      OnAccessMaxFileSize=""
      OnAccessIncludePath=""
      OnAccessExcludePath=""
      OnAccessExcludeUID=""
      db_metaget clamav-daemon/AllowAllMatchScan default || true
      AllowAllMatchScan="$RET"
      db_metaget clamav-daemon/ForceToDisk default || true
      ForceToDisk="$RET"
      db_metaget clamav-daemon/DisableCertCheck default || true
      DisableCertCheck="$RET"
      db_metaget clamav-daemon/ScanSWF default || true
      ScanSWF="$RET"
      db_metaget clamav-daemon/MaxEmbeddedPE default || true
      MaxEmbeddedPE="$RET"
      db_metaget clamav-daemon/MaxHTMLNormalize default || true
      MaxHTMLNormalize="$RET"
      db_metaget clamav-daemon/MaxHTMLNoTags default || true
      MaxHTMLNoTags="$RET"
      db_metaget clamav-daemon/MaxScriptNormalize default || true
      MaxScriptNormalize="$RET"
      db_metaget clamav-daemon/MaxZipTypeRcg default || true
      MaxZipTypeRcg="$RET"
    fi

    # Set default values for options not configured via debconf
    [ -z "$LogFileUnlock" ] && LogFileUnlock=false
    [ -z "$LogFileMaxSize" ] && LogFileMaxSize=0
    [ -z "$LogClean" ] && LogClean=false
    [ -z "$LogFacility" ] && LogFacility=LOG_LOCAL6
    [ -z "$LogVerbose" ] && LogVerbose=false
    [ -z "$ExtendedDetectionInfo" ] && ExtendedDetectionInfo=true
    [ -z "$DatabaseDirectory" ] && DatabaseDirectory='/var/lib/clamav'
    [ -z "$OfficialDatabaseOnly" ] && OfficialDatabaseOnly=false
    [ -z "$CommandReadTimeout" ] && CommandReadTimeout=30
    [ -z "$SendBufTimeout" ] && SendBufTimeout=200
    [ -z "$MaxQueue" ] && MaxQueue=100
    [ -z "$IdleTimeout" ] && IdleTimeout=30
    [ -z "$CrossFilesystems" ] && CrossFilesystems=true
    [ -z "$ExitOnOOM" ] && ExitOnOOM=false
    [ -z "$Foreground" ] && Foreground=false
    [ -z "$Debug" ] && Debug=false
    [ -z "$LeaveTemporaryFiles" ] && LeaveTemporaryFiles=false
    [ -z "$DetectPUA" ] && DetectPUA=false
    [ -z "$AlgorithmicDetection" ] && AlgorithmicDetection=true
    [ -z "$DisableCache" ] && DisableCache=false
    [ -z "$ScanPE" ] && ScanPE=true
    [ -z "$ScanELF" ] && ScanELF=true
    [ -z "$ScanOLE2" ] && ScanOLE2=true
    [ -z "$OLE2BlockMacros" ] && OLE2BlockMacros=false
    [ -z "$OnAccessExcludeRootUID" ] && OnAccessExcludeRootUID=no
    [ -z "$ScanPDF" ] && ScanPDF=true
    [ -z "$ScanPartialMessages" ] && ScanPartialMessages=false
    [ -z "$PhishingSignatures" ] && PhishingSignatures=true
    [ -z "$PhishingScanURLs" ] && PhishingScanURLs=true
    [ -z "$PhishingAlwaysBlockSSLMismatch" ] && PhishingAlwaysBlockSSLMismatch=false
    [ -z "$PhishingAlwaysBlockCloak" ] && PhishingAlwaysBlockCloak=false
    [ -z "$PartitionIntersection" ] && PartitionIntersection=false
    [ -z "$HeuristicScanPrecedence" ] && HeuristicScanPrecedence=false
    [ -z "$StructuredDataDetection" ] && StructuredDataDetection=false
    [ -z "$ScanHTML" ] && ScanHTML=true
    [ -z "$ArchiveBlockEncrypted" ] && ArchiveBlockEncrypted=false
    [ -z "$MaxScanTime" ] && MaxScanTime=120000
    [ -z "$MaxScanSize" ] && MaxScanSize=100M
    [ -z "$MaxFileSize" ] && MaxFileSize=25M
    [ -z "$MaxRecursion" ] && MaxRecursion=16
    [ -z "$MaxFiles" ] && MaxFiles=10000
    [ -z "$MaxPartitions" ] && MaxPartitions=50
    [ -z "$MaxIconsPE" ] && MaxIconsPE=100
    [ -z "$PCREMatchLimit" ] && PCREMatchLimit=10000
    [ -z "$PCRERecMatchLimit" ] && PCRERecMatchLimit=5000
    [ -z "$PCREMaxFileSize" ] && PCREMaxFileSize=25M
    [ -z "$ScanXMLDOCS" ] && ScanXMLDOCS=true
    [ -z "$ScanHWP3" ] && ScanHWP3=true
    [ -z "$MaxRecHWP3" ] && MaxRecHWP3=16
    [ -z "$PreludeEnable" ] && PreludeEnable=no
    [ -z "$PreludeAnalyzerName" ] && PreludeAnalyzerName=ClamAV

    if `dpkg --compare-versions "$2" lt 0.98.7+dfsg-2~`; then
      # Update the MaxRecursion variable, if it is the previous default value.
      if [ "$MaxRecursion" = "10" ]; then
        MaxRecursion=16
      fi
    fi

    # Create the new configuration file
    echo "#Automatically Generated by clamav-daemon postinst" > $DEBCONFFILE
    echo "#To reconfigure clamd run #dpkg-reconfigure clamav-daemon" >> $DEBCONFFILE
    echo "#Please read /usr/share/doc/clamav-daemon/README.Debian.gz for details" >> $DEBCONFFILE
    echo "[Service]" > "$DEBSYSTEMDCLAMDCONF"
    echo "ExecStartPre=-/bin/mkdir /run/clamav" >> "$DEBSYSTEMDCLAMDCONF"
    echo "ExecStartPre=/bin/chown $User /run/clamav" >> "$DEBSYSTEMDCLAMDCONF"

    if [ "$sock" = "tcp" ]; then
      echo "TCPSocket $TCPSocket" >> $DEBCONFFILE
      if [ "$TCPAddr" != "any" ]; then
        echo "TCPAddr $TCPAddr" >> $DEBCONFFILE
      fi
    else
      echo "LocalSocket $LocalSocket" >> $DEBCONFFILE
      echo "FixStaleSocket $FixStaleSocket" >> $DEBCONFFILE
      echo "LocalSocketGroup $LocalSocketGroup" >> $DEBCONFFILE
      echo "LocalSocketMode $LocalSocketMode" >> $DEBCONFFILE
    fi
    # Finish the configuration file update, by applying changes to the real configuration file.
    mkdir -p `dirname $CLAMAVSYSTEMDCLAMDONF` 2>/dev/null || true
    ucf_cleanup "$CLAMAVSYSTEMDCLAMDONF"
    ucf_upgrade_check "$CLAMAVSYSTEMDCLAMDONF" "$DEBSYSTEMDCLAMDCONF" /var/lib/ucf/cache/:etc:systemd:system:clamav-daemon.service.d:extend.conf
    rm -f "$DEBSYSTEMDCLAMDCONF"
    if [ -e "$CLAMAVSYSTEMDCLAMDONF".dpkg-old ]; then
      echo "Removing old systemd service override options for clamav-daemon"
      rm -f "$CLAMAVSYSTEMDCLAMDONF".dpkg-old
    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

    cat >> $DEBCONFFILE << EOF
User $User
ScanMail $ScanMail
ScanArchive $ScanArchive
ArchiveBlockEncrypted $ArchiveBlockEncrypted
MaxDirectoryRecursion $MaxDirectoryRecursion
FollowDirectorySymlinks $FollowDirectorySymlinks
FollowFileSymlinks $FollowFileSymlinks
ReadTimeout $ReadTimeout
MaxThreads $MaxThreads
MaxConnectionQueueLength $MaxConnectionQueueLength
LogSyslog $LogSyslog
LogRotate $LogRotate
LogFacility $LogFacility
LogClean $LogClean
LogVerbose $LogVerbose
PreludeEnable $PreludeEnable
PreludeAnalyzerName $PreludeAnalyzerName
DatabaseDirectory $DatabaseDirectory
OfficialDatabaseOnly $OfficialDatabaseOnly
SelfCheck $SelfCheck
Foreground $Foreground
Debug $Debug
ScanPE $ScanPE
MaxEmbeddedPE $MaxEmbeddedPE
ScanOLE2 $ScanOLE2
ScanPDF $ScanPDF
ScanHTML $ScanHTML
MaxHTMLNormalize $MaxHTMLNormalize
MaxHTMLNoTags $MaxHTMLNoTags
MaxScriptNormalize $MaxScriptNormalize
MaxZipTypeRcg $MaxZipTypeRcg
ScanSWF $ScanSWF
ExitOnOOM $ExitOnOOM
LeaveTemporaryFiles $LeaveTemporaryFiles
AlgorithmicDetection $AlgorithmicDetection
ScanELF $ScanELF
IdleTimeout $IdleTimeout
CrossFilesystems $CrossFilesystems
PhishingSignatures $PhishingSignatures
PhishingScanURLs $PhishingScanURLs
PhishingAlwaysBlockSSLMismatch $PhishingAlwaysBlockSSLMismatch
PhishingAlwaysBlockCloak $PhishingAlwaysBlockCloak
PartitionIntersection $PartitionIntersection
DetectPUA $DetectPUA
ScanPartialMessages $ScanPartialMessages
HeuristicScanPrecedence $HeuristicScanPrecedence
StructuredDataDetection $StructuredDataDetection
CommandReadTimeout $CommandReadTimeout
SendBufTimeout $SendBufTimeout
MaxQueue $MaxQueue
ExtendedDetectionInfo $ExtendedDetectionInfo
OLE2BlockMacros $OLE2BlockMacros
ScanOnAccess $ScanOnAccess
AllowAllMatchScan $AllowAllMatchScan
ForceToDisk $ForceToDisk
DisableCertCheck $DisableCertCheck
DisableCache $DisableCache
MaxScanTime $MaxScanTime
MaxScanSize $MaxScanSize
MaxFileSize $MaxFileSize
MaxRecursion $MaxRecursion
MaxFiles $MaxFiles
MaxPartitions $MaxPartitions
MaxIconsPE $MaxIconsPE
PCREMatchLimit $PCREMatchLimit
PCRERecMatchLimit $PCRERecMatchLimit
PCREMaxFileSize $PCREMaxFileSize
ScanXMLDOCS $ScanXMLDOCS
ScanHWP3 $ScanHWP3
MaxRecHWP3 $MaxRecHWP3
EOF

    if is_true "$StructuredDataDetection"; then
      [ -z "$StructuredMinCreditCardCount" ] || StructuredMinCreditCardCount=3
      [ -z "$StructuredMinSSNCount" ] || StructuredMinSSNCount=3
      [ -z "$StructuredSSNFormatNormal" ] || StructuredSSNFormatNormal=true
      [ -z "$StructuredSSNFormatStripped" ] || StructuredSSNFormatStripped=false
      cat >> $DEBCONFFILE << EOF
StructuredMinCreditCardCount $StructuredMinCreditCardCount
StructuredMinSSNCount $StructuredMinSSNCount
StructuredSSNFormatNormal $StructuredSSNFormatNormal
StructuredSSNFormatStripped $StructuredSSNFormatStripped
EOF
    fi

    if [ -n "$StreamMaxLength" ]; then
      if [ "$StreamMaxLength" -gt 0 ] ;then
        StreamMaxLength="${StreamMaxLength}M"
      fi
      echo "StreamMaxLength $StreamMaxLength" >> $DEBCONFFILE
    fi
    if [ -n "$IncludePUA" ]; then
      for i in $IncludePUA; do
        echo "IncludePUA $i" >> $DEBCONFFILE
      done
    fi
    if [ -n "$ExcludePUA" ]; then
      for e in $ExcludePUA; do
        echo "ExcludePUA $i" >> $DEBCONFFILE
      done
    fi
    if [ -n "$LogFile" ]; then
      echo "LogFile $LogFile" >> $DEBCONFFILE
      echo "LogTime $LogTime" >> $DEBCONFFILE
      echo "LogFileUnlock $LogFileUnlock" >> $DEBCONFFILE
      echo "LogFileMaxSize $LogFileMaxSize" >> $DEBCONFFILE
    fi

    echo "Bytecode $Bytecode" >> $DEBCONFFILE
    if is_true "$Bytecode"; then
      echo "BytecodeSecurity $BytecodeSecurity" >> $DEBCONFFILE
      echo "BytecodeTimeout $BytecodeTimeout" >> $DEBCONFFILE
    fi
    if `dpkg --compare-versions "$2" lt 0.99+dfsg~`; then
      # Remove the PidFile variable from the configuration, if it is the previous default value.
      if [ "$PidFile" = "/var/run/clamav/clamd.pid" ]; then
        PidFile=''
      fi
    fi
    if [ -n "$BlockMax" ]; then
		echo "BlockMax $BlockMax" >> $DEBCONFFILE
    fi
    # Preserve manually created, usually not needed options.
    [ -n "$PidFile" ] && echo "PidFile $PidFile" >> $DEBCONFFILE
    [ -n "$ExcludePath" ] && echo "ExcludePath $ExcludePath" >> $DEBCONFFILE
    [ -n "$VirusEvent" ] && echo "VirusEvent $VirusEvent" >> $DEBCONFFILE
    [ -n "$StreamMinPort" ] && echo "StreamMinPort $StreamMinPort" >> $DEBCONFFILE
    [ -n "$StreamMaxPort" ] && echo "StreamMaxPort $StreamMaxPort" >> $DEBCONFFILE
    [ -n "$OnAccessMaxFileSize" ] && echo "OnAccessMaxFileSize $OnAccessMaxFileSize" >> $DEBCONFFILE
    [ -n "$OnAccessIncludePath" ] && echo "OnAccessIncludePath $OnAccessIncludePath" >> $DEBCONFFILE
    [ -n "$OnAccessExcludePath" ] && echo "OnAccessExcludePath $OnAccessExcludePath" >> $DEBCONFFILE
    [ -n "$OnAccessExcludeUID" ] && echo "OnAccessExcludeUID $OnAccessExcludeUID" >> $DEBCONFFILE
    [ -n "$OnAccessMountPath" ] && echo "OnAccessMountPath $OnAccessMountPath" >> $DEBCONFFILE
    [ -n "$OnAccessDisableDDD" ] && echo "OnAccessDisableDDD $OnAccessDisableDDD" >> $DEBCONFFILE
    [ -n "$OnAccessPrevention" ] && echo "OnAccessPrevention $OnAccessPrevention" >> $DEBCONFFILE
    [ -n "$OnAccessExtraScanning" ] && echo "OnAccessExtraScanning $OnAccessExtraScanning" >> $DEBCONFFILE
    [ -n "$HeuristicAlerts" ] && echo "HeuristicAlerts $HeuristicAlerts" >> $DEBCONFFILE
    [ -n "$AlertBrokenExecutables" ] && echo "AlertBrokenExecutables $AlertBrokenExecutables" >> $DEBCONFFILE
    [ -n "$AlertEncrypted" ] && echo "AlertEncrypted $AlertEncrypted" >> $DEBCONFFILE
    [ -n "$AlertEncryptedArchive" ] && echo "AlertEncryptedArchive $AlertEncryptedArchive" >> $DEBCONFFILE
    [ -n "$AlertEncryptedDoc" ] && echo "AlertEncryptedDoc $AlertEncryptedDoc" >> $DEBCONFFILE
    [ -n "$AlertOLE2Macros" ] && echo "AlertOLE2Macros $AlertOLE2Macros" >> $DEBCONFFILE
    [ -n "$AlertPhishingSSLMismatch" ] && echo "AlertPhishingSSLMismatch $AlertPhishingSSLMismatch" >> $DEBCONFFILE
    [ -n "$AlertPhishingCloak" ] && echo "AlertPhishingCloak $AlertPhishingCloak" >> $DEBCONFFILE
    [ -n "$AlertPartitionIntersection" ] && echo "AlertPartitionIntersection $AlertPartitionIntersection" >> $DEBCONFFILE
    [ -n "$AlertExceedsMax" ] && echo "AlertExceedsMax $AlertExceedsMax" >> $DEBCONFFILE

    # Preserve old, deprecated options.
    [ -n "$ClamukoScanOnAccess" ] && echo "ClamukoScanOnAccess $ClamukoScanOnAccess" >> $DEBCONFFILE
    [ -n "$ClamukoScanOnOpen" ] && echo "ClamukoScanOnOpen $ClamukoScanOnOpen" >> $DEBCONFFILE
    [ -n "$ClamukoScanOnClose" ] && echo "ClamukoScanOnClose $ClamukoScanOnClose" >> $DEBCONFFILE
    [ -n "$ClamukoScanOnExec" ] && echo "ClamukoScanOnExec $ClamukoScanOnExec" >> $DEBCONFFILE
    [ -n "$ClamukoIncludePath" ] && echo "ClamukoIncludePath $ClamukoIncludePath" >> $DEBCONFFILE
    [ -n "$ClamukoIncludePath" ] && echo "ClamukoIncludePath $ClamukoIncludePath" >> $DEBCONFFILE
    [ -n "$ClamukoExcludePath" ] && echo "ClamukoExcludePath $ClamukoExcludePath" >> $DEBCONFFILE
    [ -n "$ClamukoMaxFileSize" ] && echo "ClamukoMaxFileSize $ClamukoMaxFileSize" >> $DEBCONFFILE
    [ -n "$ClamukoScannerCount" ] && echo "ClamukoScannerCount $ClamukoScannerCount" >> $DEBCONFFILE
    [ -n "$ClamukoExcludeUID" ] && echo "ClamukoExcludeUID $ClamukoExcludeUID" >> $DEBCONFFILE

    # Finish the configuration file update, by applying changes to the real configuration file.
    ucf_cleanup "$CLAMAVCONF"
    ucf_upgrade_check "$CLAMAVCONF" "$DEBCONFFILE" /var/lib/ucf/cache/:etc:clamav:clamd.conf
    rm -f "$DEBCONFFILE"

    # Add additional groups (if any)
    if [ -n "$AddGroups" ]; then
      for group in $AddGroups; do
        id "$User" | grep -q "$group" || adduser "$User" "$group"
      done
    fi

  else
    # Let the configuration be handled manually.
    ucf_cleanup "$CLAMAVCONF"
    ucf -p "$CLAMAVCONF"
    if [ -e "$CLAMAVSYSTEMDCLAMDONF" ]; then
      echo "Disabling old systemd service override options for clamav-daemon"
      mv "$CLAMAVSYSTEMDCLAMDONF" "$CLAMAVSYSTEMDCLAMDONF".dpkg-old
      ucf -p "$CLAMAVSYSTEMDCLAMDONF"
    fi
  fi

  if `dpkg --compare-versions "$2" lt 0.99.2+dfsg-3~`; then
    # Remove /etc/systemd/system/clamav-daemon.socket.d/extend.conf
    if [ -e /etc/systemd/system/clamav-daemon.socket.d/extend.conf ]; then
      rm -f /etc/systemd/system/clamav-daemon.socket.d/extend.conf \
	      /etc/systemd/system/clamav-daemon.socket.d/extend.conf.dpkg-old \
	      /etc/systemd/system/clamav-daemon.socket.d/extend.conf.ucf*
      rmdir /etc/systemd/system/clamav-daemon.socket.d 2> /dev/null || true
      ucf -p /etc/systemd/system/clamav-daemon.socket.d/extend.conf
    fi
  fi

  # Set permission for the configuration file.
  chmod 644 $CLAMAVCONF || true
  chown root:root $CLAMAVCONF || true

  # Read the configuration file
  slurp_config "$CLAMAVCONF"

  if [ -n "$LogFile" ]; then
    if echo "$LogFile" | grep -q '^/dev/'; then
      make_logrotate=false
    else
      if [ "$LogRotate" = "true" ]; then
        make_logrotate=true
      else
        make_logrotate=false
      fi
    fi
    [ -z "$User" ] && User=clamav
    if [ "$make_logrotate" = 'true' ]; then
      # update the logrotate file
      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 "     if [ -d /run/systemd/system ]; then" >> $DEBROTATEFILE
      echo "         systemctl -q is-active clamav-daemon && systemctl kill --signal=SIGHUP clamav-daemon || true" >> $DEBROTATEFILE
      echo "     else" >> $DEBROTATEFILE
      echo "         /etc/init.d/clamav-daemon reload-log > /dev/null || true" >> $DEBROTATEFILE
      echo "     fi" >> $DEBROTATEFILE
      echo "     endscript" >> $DEBROTATEFILE
      echo "     }" >> $DEBROTATEFILE
      touch "$LogFile"
      if [ -f "$LogFile" ] && [ ! -L "$LogFile" ]; then
        chown "$User":adm "$LogFile"
        chmod 0640 "$LogFile"
      fi
      ucf_cleanup "$CLAMAVROTATEFILE"
      ucf_upgrade_check "$CLAMAVROTATEFILE" "$DEBROTATEFILE" /var/lib/ucf/cache/:etc:logrotate.d:clamav-daemon
      rm -f $DEBROTATEFILE
      if [ -e "$CLAMAVROTATEFILE".dpkg-old ]; then
        echo "Removing old logrotate script for clamav-daemon"
        rm -f "$CLAMAVROTATEFILE".dpkg-old
      fi
    else
      if [ -e "$CLAMAVROTATEFILE" ]; then
        echo "Disabling old logrotate script for clamav-daemon"
        mv "$CLAMAVROTATEFILE" "$CLAMAVROTATEFILE".dpkg-old
        ucf -p "$CLAMAVROTATEFILE"
      fi
    fi
  else
    if [ -e "$CLAMAVROTATEFILE" ]; then
      echo "Disabling old logrotate script for clamav-daemon"
      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