Browse code

Add option ReportHostname

aCaB authored on 2009/09/24 08:16:02
Showing 4 changed files
... ...
@@ -1,3 +1,7 @@
1
+Thu Sep 24 01:14:50 CEST 2009 (acab)
2
+------------------------------------
3
+ * clamav-milter: Add option ReportHostname to mangle the host name in X headers
4
+
1 5
 Wed Sep 23 03:19:53 CEST 2009 (acab)
2 6
 ------------------------------------
3 7
  * libclamav/mpool.c: update frag sizes, small cleanup
... ...
@@ -223,14 +223,14 @@ int main(int argc, char **argv) {
223 223
     if(strcasecmp(pt, "No")) {
224 224
 	char myname[255];
225 225
 
226
-	if(!gethostname(myname, sizeof(myname))) {
226
+	if(((opt = optget(opts, "ReportHostname"))->enabled && strncpy(myname, opt->strarg, sizeof(myname))) || !gethostname(myname, sizeof(myname))) {
227 227
 	    myname[sizeof(myname)-1] = '\0';
228 228
 	    snprintf(xvirushdr, sizeof(xvirushdr), "clamav-milter %s at %s", get_version(), myname);
229
-	    xvirushdr[sizeof(xvirushdr)-1] = '\0';
230
-	} else {
229
+	} else
231 230
 	    snprintf(xvirushdr, sizeof(xvirushdr), "clamav-milter %s", get_version());
232
-	    xvirushdr[sizeof(xvirushdr)-1] = '\0';
233
-	}
231
+	xvirushdr[sizeof(xvirushdr)-1] = '\0';
232
+
233
+	printf("\n%s\n", xvirushdr);
234 234
 
235 235
 	descr.xxfi_flags |= SMFIF_ADDHDRS;
236 236
 
... ...
@@ -169,6 +169,11 @@ Example
169 169
 # Default: no
170 170
 #AddHeader Replace
171 171
 
172
+# When AddHeader is in use, this option allows to arbitrary set the reported
173
+# hostname. This may be desirable in order to avoid leaking internal names.
174
+# If unset the real machine name is used.
175
+# Default: disabled
176
+#ReportHostname my.mail.server.name
172 177
 
173 178
 ##
174 179
 ## Logging options
... ...
@@ -387,6 +387,8 @@ const struct clam_option clam_options[] = {
387 387
 
388 388
     { "AddHeader", NULL, 0, TYPE_STRING, "^(No|Replace|Yes|Add)$", -1, "no", 0, OPT_MILTER, "If this option is set to \"Replace\" (or \"Yes\"), an \"X-Virus-Scanned\" and an\n\"X-Virus-Status\" headers will be attached to each processed message, possibly\nreplacing existing headers.\nIf it is set to Add, the X-Virus headers are added possibly on top of the\nexisting ones.\nNote that while \"Replace\" can potentially break DKIM signatures, \"Add\" may\nconfuse procmail and similar filters.", "Replace" },
389 389
 
390
+    { "ReportHostname", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER, "When AddHeader is in use, this option allows to arbitrary set the reported\nhostname. This may be desirable in order to avoid leaking internal names.\nIf unset the real machine name is used.", "my.mail.server.name" },
391
+
390 392
     { "Chroot", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER, "Chroot to the specified directory.\nChrooting is performed just after reading the config file and before\ndropping privileges.", "/newroot" },
391 393
 
392 394
     { "Whitelist", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_MILTER, "This option specifies a file which contains a list of basic POSIX regular\nexpressions. Addresses (sent to or from - see below) matching these regexes\nwill not be scanned.  Optionally each line can start with the string \"From:\"\nor \"To:\" (note: no whitespace after the colon) indicating if it is,\nrespectively, the sender or recipient that is to be whitelisted.\nIf the field is missing, \"To:\" is assumed.\nLines starting with #, : or ! are ignored.", "/etc/whitelisted_addresses" },