File: clamav-milter.config.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 (248 lines) | stat: -rw-r--r-- 6,388 bytes parent folder | download | duplicates (9)
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
#!/bin/sh

set -e

# Source debconf library
. /usr/share/debconf/confmodule

# This conf script is capable of backing up
db_version 2.0
db_capb backup

#COMMON-FUNCTIONS#

CLAMAVMILTERCONF='/etc/clamav/clamav-milter.conf'

slurp_config "$CLAMAVMILTERCONF"


# Store conf file values as debconf answers - make sure user changes made 
# outside of debconf are preserved
set_debconf_value milter MilterSocket
set_debconf_value milter FixStaleSocket
set_debconf_value milter MilterSocketGroup
set_debconf_value milter MilterSocketMode
if [ -n "$User" ]; then
  db_set clamav-milter/User "$User" || true
  if ! [ "$User" = 'root' ]; then
    AddGroups=`groups "$User" | awk -F ':' '{print $2}' | sed -e s/"$User"//`
  fi
  if [ -n "$AddGroups" ]; then
    db_set clamav-milter/AddGroups "$AddGroups" || true
  fi
fi
set_debconf_value milter ReadTimeout
set_debconf_value milter Foreground
set_debconf_value milter Chroot
if [ -n "$PidFile" ]; then
  db_set clamav-milter/PidFile "$PidFile" || true
fi
set_debconf_value milter TemporaryDirectory
if [ -n "$ClamdSocket" ]; then
  db_set clamav-milter/ClamdSocket "$ClamdSocket" || true
fi
set_debconf_value milter LocalNet
set_debconf_value milter Whitelist
set_debconf_value milter OnInfected
set_debconf_value milter OnFail
set_debconf_value milter RejectMsg
set_debconf_value milter AddHeader
set_debconf_value milter LogFile
set_debconf_value milter LogFileUnlock
set_debconf_value milter LogFileMaxSize
set_debconf_value milter LogTime
set_debconf_value milter LogSyslog
set_debconf_value milter LogFacility
set_debconf_value milter LogVerbose
set_debconf_value milter LogInfected
set_debconf_value milter LogClean
if [ -n "$MaxFileSize" ]; then
  MaxFileSize="`echo $MaxFileSize | sed -e s/M//g`"
else
  MaxFileSize=25
fi
db_set clamav-milter/MaxFileSize "$MaxFileSize" || true
set_debconf_value milter SupportMultipleRecipients
set_debconf_value milter LogRotate


# States

StateDebconf()
{
  db_input medium clamav-milter/debconf || true
  if ! db_go; then
    STATE="End"
  else
    db_get clamav-milter/debconf || true
    if [ "$RET" = "false" ]; then
      STATE="End"
    else
      STATE="User"
    fi
  fi
}

StateUser()
{
  db_input medium clamav-milter/User || true
  if db_go; then
    db_metaget clamav-milter/User value
    if [ "$RET" = "" ]; then
      db_set clamav-milter/User "clamav" || true
    fi
    STATE="AddGroups"
  else
    STATE="Debconf"
  fi
}

StateMilterSocketGroup()
{
  db_input low clamav-milter/MilterSocketGroup || true
  if db_go; then
    db_metaget clamav-milter/MilterSocketGroup value
    if [ "$RET" = "" ]; then
      db_set clamav-milter/MilterSocketGroup "clamav" || true
    fi
    STATE="MilterSocketMode"
  else
    STATE="MilterSocket"
  fi
}

StateLogFile()
{
  db_input low clamav-milter/LogFile || true
  if db_go; then
    db_metaget clamav-milter/LogFile value
    if [ "$RET" = "" ]; then
      db_set clamav-milter/LogFile "/var/log/clamav/clamav-milter.log" || true
      STATE="LogFileUnlock"
    elif [ "$RET" = 'none' ]; then
      db_set clamav-milter/LogFile "" || true
      STATE="LogSyslog"
    else
      STATE="LogFileUnlock"
    fi
  else
    STATE="AddHeader"
  fi
}

# To many options to configure at configure
if [ "$1" = "reconfigure" ]; then
  STATE="Init"
elif [ -n "$2" ]; then
  if [ -z "$User" ]; then
    STATE="User"
  fi
else
  STATE="End"
fi

[ -z "$STATE" ] && STATE='End'

# This is the statemachine that controls execution. All the 'real' work is 
# performed by subfunctions above. 

while [ "$STATE" != "End" ]; do
  case "$STATE" in
    "Init")
    StateDebconf
    ;;
    "User")
    StateUser
    ;;
    "AddGroups")
    StateGeneric medium clamav-milter/AddGroups MilterSocket User
    ;;
    "MilterSocket")
    StateGeneric low clamav-milter/MilterSocket MilterSocketGroup AddGroups
    ;;
    "MilterSocketGroup")
    StateMilterSocketGroup
    ;;
    "MilterSocketMode")
    StateGenericDigit low clamav-milter/MilterSocketMode FixStaleSocket MilterSocketGroup
    ;;
    "FixStaleSocket")
    StateGeneric low clamav-milter/FixStaleSocket ReadTimeout MilterSocketMode
    ;;
    "ReadTimeout")
    StateGenericDigit low clamav-milter/ReadTimeout Foreground FixStaleSocket
    ;;
    "Foreground")
    StateGeneric low clamav-milter/Foreground Chroot ReadTimeout
    ;;
    "Chroot")
    StateGeneric low clamav-milter/Chroot PidFile Foreground
    ;;
    "PidFile")
    StateGeneric low clamav-milter/PidFile TemporaryDirectory Chroot
    ;;
    "TemporaryDirectory")
    StateGeneric low clamav-milter/TemporaryDirectory ClamdSocket PidFile
    ;;
    "ClamdSocket")
    StateGeneric low clamav-milter/ClamdSocket LocalNet TemporaryDirectory
    ;;
    "LocalNet")
    StateGeneric low clamav-milter/LocalNet Whitelist ClamdSocket
    ;;
    "Whitelist")
    StateGeneric low clamav-milter/Whitelist OnInfected LocalNet
    ;;
    "OnInfected")
    StateGeneric low clamav-milter/OnInfected OnFail Whitelist
    ;;
    "OnFail")
    StateGeneric low clamav-milter/OnFail RejectMsg OnInfected
    ;;
    "RejectMsg")
    StateGeneric low clamav-milter/RejectMsg AddHeader OnFail
    ;;
    "AddHeader")
    StateGeneric low clamav-milter/AddHeader LogFile RejectMsg
    ;;
    "LogFile")
    StateLogFile
    ;;
    "LogFileUnlock")
    StateGeneric low clamav-milter/LogFileUnlock LogFileMaxSize LogFile
    ;;
    "LogFileMaxSize")
    StateGenericDigit low clamav-milter/LogFileMaxSize LogTime LogFileUnlock
    ;;
    "LogTime")
    StateGeneric low clamav-milter/LogTime LogSyslog LogFileMaxSize
    ;;
    "LogSyslog")
    StateGeneric low clamav-milter/LogSyslog LogFacility LogTime
    ;;
    "LogFacility")
    StateGeneric low clamav-milter/LogFacility LogVerbose LogSyslog
    ;;
    "LogVerbose")
    StateGeneric low clamav-milter/LogVerbose LogInfected LogFacility
    ;;
    "LogInfected")
    StateGeneric low clamav-milter/LogInfected LogClean LogVerbose
    ;;
    "LogClean")
    StateGeneric low clamav-milter/LogClean MaxFileSize LogInfected
    ;;
    "MaxFileSize")
    StateGenericDigit low clamav-milter/MaxFileSize SupportMultipleRecipients LogClean
    ;;
    "SupportMultipleRecipients")
    StateGeneric low clamav-milter/SupportMultipleRecipients LogRotate MaxFileSize
    ;;
    "LogRotate")
    StateGeneric low clamav-milter/LogRotate End SupportMultipleRecipients
    ;;
  esac
done
db_stop || true
exit 0