Browse code

config file cleanup

git-svn: trunk@4534

aCaB authored on 2008/12/05 01:27:32
Showing 2 changed files
... ...
@@ -7,7 +7,16 @@ use Getopt::Long qw(:config gnu_getopt);
7 7
 
8 8
 sub wwarn {
9 9
 	my $w = shift;
10
-	warn "WARINING: $w";
10
+	warn "WARNING: $w\n";
11
+}
12
+
13
+sub tosconf {
14
+	my ($cfg, $v) = @_;
15
+	if($v) {
16
+		my $sep = $v=~/ / ? '"' : '';
17
+		$v = "\n$cfg $sep$v$sep";
18
+	}
19
+	return $v;
11 20
 }
12 21
 
13 22
 my $notify = 0;
... ...
@@ -25,7 +34,7 @@ my $monitor = 0;
25 25
 my $oninfected = 'Reject';
26 26
 my $onfail = 'Defer';
27 27
 my @localnets = ();
28
-my $whitelist;
28
+my $whitelist = '';
29 29
 my $config = '';
30 30
 my $chroot = '';
31 31
 my $pidfile = '';
... ...
@@ -50,7 +59,7 @@ GetOptions (
50 50
 	"debug|D" => \$debug,
51 51
 	"sign|S" => \$sign,
52 52
 	"signature-file|F=s" => \$sign,
53
-	"broadcast|B" => \$broad,
53
+	"broadcast|B=s" => \$broad,
54 54
 	"detect-forged-local-address|L" => \$forge,
55 55
 	"dont-sanitise|z" => sub { $sanity = 0 },
56 56
 	"black-hole-mode|2" => \$blackhole,
... ...
@@ -106,6 +115,7 @@ if ($config) {
106 106
 	}
107 107
 }
108 108
 
109
+die "FAIL: No socket provided" unless $ARGV[0];
109 110
 die "FAIL: Unable to determine clamd socket\n" unless scalar keys %clamds;
110 111
 
111 112
 wwarn "Notifications and bounces are no longer supported.
... ...
@@ -156,9 +166,238 @@ As a result the following command line options cannot be converted into new conf
156 156
  --max-children (-m)
157 157
  --dont-wait (-w)
158 158
  --timeout (-T)
159
-
160 159
 Please make use of the native Sendmail / Postfix rate limiting facilities
161 160
 " if $rate;
162 161
 
163 162
 wwarn "The option --freshclam-monitor (-M) only made sense in internal mode\nPlease configure freshclam to notify clamd about updates instead\n" if $monitor;
164 163
 
164
+wwarn "Here is the auto generated config file. Please review:\n";
165
+
166
+my $mysock = tosconf('MilterSocket', $ARGV[0]);
167
+$chroot = tosconf('Chroot', $chroot);
168
+$pidfile = tosconf('PidFile', $pidfile);
169
+$oninfected = tosconf('OnInfected', $oninfected);
170
+$onfail = tosconf('OnFail', $onfail);
171
+$whitelist = tosconf('Whitelist', $whitelist);
172
+$addheader = $addheader ? "\nAddHeader Yes" : '';
173
+
174
+print <<BLOCK1;
175
+##
176
+## Example config file for clamav-milter
177
+## (automatically generated by make-clamav-milter-conf.pl)
178
+##
179
+
180
+# Comment or remove the line below.
181
+Example
182
+
183
+
184
+##
185
+## Main options
186
+##
187
+
188
+# Define the interface through which we communicate with sendmail
189
+# This option is mandatory! Possible formats are:
190
+# [[unix|local]:]/path/to/file - to specify a unix domain socket
191
+# inet:port@[hostname|ip-address] - to specify an ipv4 socket
192
+# inet6:port@[hostname|ip-address] - to specify an ipv6 socket
193
+#
194
+# Default: no default
195
+#MilterSocket /tmp/clamav-milter.socket
196
+#MilterSocket inet:7357$mysock
197
+
198
+# Remove stale socket after unclean shutdown.
199
+#
200
+# Default: yes
201
+#FixStaleSocket yes
202
+
203
+# Run as another user (clamav-milter must be started by root for this option to work)
204
+#
205
+# Default: unset (don't drop privileges)
206
+#User clamav /* FIXME */
207
+
208
+# Initialize supplementary group access (clamd must be started by root).
209
+#
210
+# Default: no
211
+#AllowSupplementaryGroups no /* FIXME */
212
+
213
+# Waiting for data from clamd will timeout after this time (seconds).
214
+# Value of 0 disables the timeout.
215
+#
216
+# Default: 120
217
+#ReadTimeout 300
218
+
219
+# Don't fork into background.
220
+#
221
+# Default: no
222
+#Foreground yes /* FIXME */
223
+
224
+# Chroot to the specified directory.
225
+# Chrooting is performed just after reading the config file and before dropping privileges.
226
+#
227
+# Default: unset (don't chroot)
228
+#Chroot /newroot$chroot
229
+
230
+# This option allows you to save a process identifier of the listening
231
+# daemon (main thread).
232
+#
233
+# Default: disabled
234
+#PidFile /var/run/clamd.pid$pidfile
235
+
236
+# Optional path to the global temporary directory.
237
+# Default: system specific (usually /tmp or /var/tmp).
238
+#
239
+#TemporaryDirectory /var/tmp /* FIXME */
240
+
241
+##
242
+## Clamd options
243
+##
244
+
245
+# Define the clamd socket to connect to for scanning.
246
+# If not set (the default), clamav-milter uses internal mode.
247
+# This option is mandatory! Syntax:
248
+# ClamdSocket unix:path
249
+# ClamdSocket tcp:host:port
250
+# The first syntax specifies a local unix socket (needs an bsolute path) e.g.:
251
+#     ClamdSocket unix:/var/run/clamd/clamd.socket
252
+# The second syntax specifies a tcp local or remote tcp socket: the
253
+# host can be a hostname or an ip address; the ":port" field is only required
254
+# for IPv6 addresses, otherwise it defaults to 3310
255
+#     ClamdSocket tcp:192.168.0.1
256
+#
257
+# This option can be repeated several times with different sockets or even
258
+# with the same socket: clamd servers will be selected in a round-robin fashion.
259
+#
260
+# Default: no default
261
+#ClamdSocket tcp:scanner.mydomain:7357
262
+BLOCK1
263
+
264
+print "ClamdSocket \"$_\"\n" foreach (keys %clamds);
265
+print <<BLOCK2;
266
+
267
+
268
+##
269
+## Exclusions
270
+##
271
+
272
+# Messages originating from these hosts/networks will not be scanned
273
+# This option takes a host(name)/mask pair in CIRD notation and can be
274
+# repeated several times. If "/mask" is omitted, a host is assumed.
275
+# To specify a locally orignated, non-smtp, email use the keyword "local"
276
+#
277
+# Default: unset (scan everything regardless of the origin)
278
+#LocalNet local
279
+#LocalNet 192.168.0.0/24
280
+#LocalNet 1111:2222:3333::/48
281
+
282
+# This option specifies a file which contains a list of POSIX regular
283
+# expressions. Addresses (sent to or from - see below) matching these regexes
284
+# will not be scanned.  Optionally each line can start with the string "From:"
285
+# or "To:" (note: no whitespace after the colon) indicating if it is, 
286
+# respectively, the sender or recipient that is to be whitelisted.
287
+# If the field is missing, "To:" is assumed.
288
+# Lines starting with #, : or ! are ignored.
289
+#
290
+# Default unset (no exclusion applied)
291
+#Whitelist /etc/whitelisted_addresses$whitelist
292
+
293
+
294
+##
295
+## Actions
296
+##
297
+
298
+# The following group of options controls the delievery process under
299
+# different circumstances.
300
+# The following actions are available:
301
+# - Accept
302
+#   The message is accepted for delievery
303
+# - Reject
304
+#   Immediately refuse delievery (a 5xx error is returned to the peer)
305
+# - Defer
306
+#   Return a temporary failure message (4xx) to the peer
307
+# - Blackhole (not available for OnFail)
308
+#   Like accept but the message is sent to oblivion
309
+# - Quarantine (not available for OnFail)
310
+#   Like accept but message is quarantined instead of being deilievered
311
+#   In sendmail the quarantine queue can be examined via mailq -qQ
312
+#   For Postfix this causes the message to be accepted but placed on hold
313
+# 
314
+# Action to be performed on clean messages (mostly useful for testing)
315
+# Default Accept
316
+#OnClean Accept
317
+
318
+# Action to be performed on infected messages
319
+# Default: Quarantine
320
+#OnInfected Quarantine$oninfected
321
+
322
+# Action to be performed on error conditions (this includes failure to
323
+# allocate data structures, no scanners available, network timeouts,
324
+# unknown scanner replies and the like)
325
+# Default Defer
326
+#OnFail Defer$onfail
327
+
328
+# If this option is set to Yes, an "X-Virus-Scanned" and an "X-Virus-Status"
329
+# headers will be attached to each processed message, possibly replacing
330
+# existing headers. 
331
+# Default: No
332
+#AddHeader Yes$addheader
333
+
334
+
335
+##
336
+## Logging options
337
+##
338
+
339
+# Uncomment this option to enable logging.
340
+# LogFile must be writable for the user running daemon.
341
+# A full path is required.
342
+#
343
+# Default: disabled
344
+#LogFile /tmp/clamav-milter.log
345
+
346
+# By default the log file is locked for writing - the lock protects against
347
+# running clamav-milter multiple times.
348
+# This option disables log file locking.
349
+#
350
+# Default: no
351
+#LogFileUnlock yes
352
+
353
+# Maximum size of the log file.
354
+# Value of 0 disables the limit.
355
+# You may use 'M' or 'm' for megabytes (1M = 1m = 1048576 bytes)
356
+# and 'K' or 'k' for kilobytes (1K = 1k = 1024 bytes). To specify the size
357
+# in bytes just don't use modifiers.
358
+#
359
+# Default: 1M
360
+#LogFileMaxSize 2M
361
+
362
+# Log time with each message.
363
+#
364
+# Default: no
365
+#LogTime yes
366
+
367
+# Use system logger (can work together with LogFile).
368
+#
369
+# Default: no
370
+#LogSyslog yes
371
+
372
+# Specify the type of syslog messages - please refer to 'man syslog'
373
+# for facility names.
374
+#
375
+# Default: LOG_LOCAL6
376
+#LogFacility LOG_MAIL
377
+
378
+# Enable verbose logging.
379
+#
380
+# Default: no
381
+#LogVerbose yes
382
+
383
+
384
+##
385
+## Limits
386
+##
387
+
388
+# Messages larger than this value won't be scanned.
389
+# Default: 25M
390
+#MaxFileSize 150M /* FIXME */
391
+BLOCK2
392
+
393
+
... ...
@@ -1,6 +1,5 @@
1 1
 ##
2
-## Example config file for the clamav-milter
3
-## /* FIXME : NOT DONE YET */ Please read the clamav-milter.conf(5) manual before editing this file.
2
+## Example config file for clamav-milter
4 3
 ##
5 4
 
6 5
 # Comment or remove the line below.
... ...
@@ -18,51 +17,46 @@ Example
18 18
 # inet6:port@[hostname|ip-address] - to specify an ipv6 socket
19 19
 #
20 20
 # Default: no default
21
-##MilterSocket /tmp/clamav-milter.socket
22
-##MilterSocket inet:7357
21
+#MilterSocket /tmp/clamav-milter.socket
22
+#MilterSocket inet:7357
23 23
 
24 24
 # Remove stale socket after unclean shutdown.
25 25
 #
26 26
 # Default: yes
27
-##FixStaleSocket yes
28
-
29
-# Maximum number of threads running at the same time.
30
-#
31
-# Default: 10
32
-##MaxThreads 20
27
+#FixStaleSocket yes
33 28
 
34 29
 # Run as another user (clamav-milter must be started by root for this option to work)
35 30
 #
36 31
 # Default: unset (don't drop privileges)
37
-##User clamav
32
+#User clamav
38 33
 
39 34
 # Initialize supplementary group access (clamd must be started by root).
40 35
 #
41 36
 # Default: no
42
-##AllowSupplementaryGroups no
37
+#AllowSupplementaryGroups no
43 38
 
44 39
 # Waiting for data from clamd will timeout after this time (seconds).
45 40
 # Value of 0 disables the timeout.
46 41
 #
47 42
 # Default: 120
48
-##ReadTimeout 300
43
+#ReadTimeout 300
49 44
 
50 45
 # Don't fork into background.
51 46
 #
52 47
 # Default: no
53
-##Foreground yes
48
+#Foreground yes
54 49
 
55 50
 # Chroot to the specified directory.
56 51
 # Chrooting is performed just after reading the config file and before dropping privileges.
57 52
 #
58 53
 # Default: unset (don't chroot)
59
-##Chroot /newroot
54
+#Chroot /newroot
60 55
 
61 56
 # This option allows you to save a process identifier of the listening
62 57
 # daemon (main thread).
63 58
 #
64 59
 # Default: disabled
65
-##PidFile /var/run/clamd.pid
60
+#PidFile /var/run/clamd.pid
66 61
 
67 62
 # Optional path to the global temporary directory.
68 63
 # Default: system specific (usually /tmp or /var/tmp).
... ...
@@ -89,14 +83,7 @@ Example
89 89
 # with the same socket: clamd servers will be selected in a round-robin fashion.
90 90
 #
91 91
 # Default: no default
92
-##ClamdSocket tcp:scanner.mydomain:7357
93
-
94
-# WARNING: The following options are deprecated and may go away soon.
95
-# Please use ClamdSocket instead!
96
-# Default: disabled
97
-#LocalSocket
98
-#TCPSocket
99
-#TCPAddr
92
+#ClamdSocket tcp:scanner.mydomain:7357
100 93
 
101 94
 
102 95
 ##
... ...
@@ -175,14 +162,14 @@ Example
175 175
 # A full path is required.
176 176
 #
177 177
 # Default: disabled
178
-##LogFile /tmp/clamav-milter.log
178
+#LogFile /tmp/clamav-milter.log
179 179
 
180 180
 # By default the log file is locked for writing - the lock protects against
181 181
 # running clamav-milter multiple times.
182 182
 # This option disables log file locking.
183 183
 #
184 184
 # Default: no
185
-##LogFileUnlock yes
185
+#LogFileUnlock yes
186 186
 
187 187
 # Maximum size of the log file.
188 188
 # Value of 0 disables the limit.
... ...
@@ -191,28 +178,28 @@ Example
191 191
 # in bytes just don't use modifiers.
192 192
 #
193 193
 # Default: 1M
194
-##LogFileMaxSize 2M
194
+#LogFileMaxSize 2M
195 195
 
196 196
 # Log time with each message.
197 197
 #
198 198
 # Default: no
199
-##LogTime yes
199
+#LogTime yes
200 200
 
201 201
 # Use system logger (can work together with LogFile).
202 202
 #
203 203
 # Default: no
204
-##LogSyslog yes
204
+#LogSyslog yes
205 205
 
206 206
 # Specify the type of syslog messages - please refer to 'man syslog'
207 207
 # for facility names.
208 208
 #
209 209
 # Default: LOG_LOCAL6
210
-##LogFacility LOG_MAIL
210
+#LogFacility LOG_MAIL
211 211
 
212 212
 # Enable verbose logging.
213 213
 #
214 214
 # Default: no
215
-##LogVerbose yes
215
+#LogVerbose yes
216 216
 
217 217
 
218 218
 ##
... ...
@@ -221,82 +208,5 @@ Example
221 221
 
222 222
 # Messages larger than this value won't be scanned.
223 223
 # Default: 25M
224
-##MaxFileSize 150M
225
-
226
-# WARNING: The following two options are deprecated and may go away soon.
227
-# Please use MaxFile size instead!
228
-# For compatibility reasons the minimum value among MaxFileSize,
229
-# MaxScanSize and StreamMaxLength will be used.
230
-#MaxScanSize
231
-#StreamMaxLength
232
-
233
-
234
-##
235
-## Deprecated options
236
-##
224
+#MaxFileSize 150M
237 225
 
238
-# The following deprecated options are only kept for compatibility
239
-# reaosns and may go away soon. These do not affect clamav-milter
240
-# in any way, except for a small warning emitted on startup.
241
-
242
-#ArchiveBlockEncrypted
243
-#DatabaseDirectory
244
-#Debug
245
-#DetectBrokenExecutables
246
-#LeaveTemporaryFiles
247
-#MailFollowURLs
248
-#MaxRecursion
249
-#MaxFiles
250
-#PhishingSignatures
251
-#ScanArchive
252
-#ScanHTML
253
-#ScanMail
254
-#ScanOLE2
255
-#ScanPE
256
-
257
-
258
-#Todo
259
-##-C --chroot
260
-#-D --debug
261
-##-i --pidfile
262
-##-I --ignore
263
-##-W --whitelist-file
264
-
265
-#Deprecated switches
266
-#-a --from
267
-#-H --headers
268
-#-x --debug-level
269
-#-b --bounce
270
-#-B --broadcast
271
-#-f --force-scan
272
-#-e --external
273
-#-k --blacklist-time
274
-#-K --dont-blacklist
275
-#-l --local
276
-#-M --freshclam-monitor
277
-#-o --outgoing
278
-#-p --postmaster
279
-#-P --postmaster-only
280
-#-q --quiet
281
-#-r --report-phish
282
-#-R --report-phish-false-positives
283
-#-s --sign
284
-#-F --signature-file
285
-#-m --max-children
286
-#--dont-wait
287
-#--dont-sanitise
288
-#-t --template-file
289
-#--template-headers
290
-#-T --timeout
291
-#-L --detect-forged-local-address
292
-#--sendmail-cf
293
-#--black-hole-mode
294
-#--server
295
-
296
-#Reworked
297
-##-A --advisory
298
-##-d --dont-scan-on-error
299
-##-n --noxheader
300
-##-N --noreject
301
-##-Q --quarantine
302
-##-U, --quarantine-dir