summaryrefslogtreecommitdiffstats
path: root/recipes-security/clamav/clamav-0.98.5/0016-clamav-milter-add-additinal-SMFIF_-flags-before-invo.patch
blob: 621c6dcf1c8d8569227f55b22882ef8515d37147 (plain)
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
From dbc72db36eced2d3ca7c5b7f14970528c435429e Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Date: Sun, 26 Oct 2014 12:11:09 +0100
Subject: clamav-milter: add additinal SMFIF_* flags before invoking
 smfi_register()

unfortunately after the shifting of the code (so that the socket could
be part of a group which is not part of the clamav user) I forgot (or
did not see it) to have the header flags added before the
smfi_register() was invoked. As a result the socket was working but it
was unable to add the X-Virus-Scanned &  X-Virus-Status flags. This
patch fixes the issue.

https://bugzilla.clamav.net/show_bug.cgi?id=10731

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
---
 clamav-milter/clamav-milter.c | 48 ++++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/clamav-milter/clamav-milter.c b/clamav-milter/clamav-milter.c
index 99e7fe7fac04..22db98ab7c5e 100644
--- a/clamav-milter/clamav-milter.c
+++ b/clamav-milter/clamav-milter.c
@@ -116,6 +116,33 @@ int main(int argc, char **argv) {
 	}
     }
 
+    pt = optget(opts, "AddHeader")->strarg;
+    if (strcasecmp(pt, "No")) {
+	char myname[255];
+
+	if (((opt = optget(opts, "ReportHostname"))->enabled &&
+	     strncpy(myname, opt->strarg, sizeof(myname))) ||
+	    !gethostname(myname, sizeof(myname))) {
+
+	    myname[sizeof(myname)-1] = '\0';
+	    snprintf(xvirushdr, sizeof(xvirushdr), "clamav-milter %s at %s",
+		     get_version(), myname);
+	} else {
+	    snprintf(xvirushdr, sizeof(xvirushdr), "clamav-milter %s",
+		     get_version());
+	}
+	xvirushdr[sizeof(xvirushdr)-1] = '\0';
+
+	descr.xxfi_flags |= SMFIF_ADDHDRS;
+
+	if (strcasecmp(pt, "Add")) { /* Replace or Yes */
+	    descr.xxfi_flags |= SMFIF_CHGHDRS;
+	    addxvirus = 1;
+	} else { /* Add */
+	    addxvirus = 2;
+	}
+    }
+
     if(!(my_socket = optget(opts, "MilterSocket")->strarg)) {
 	logg("!Please configure the MilterSocket directive\n");
 	logg_close();
@@ -323,27 +350,6 @@ int main(int argc, char **argv) {
 	return 1;
     }
 
-    pt = optget(opts, "AddHeader")->strarg;
-    if(strcasecmp(pt, "No")) {
-	char myname[255];
-
-	if(((opt = optget(opts, "ReportHostname"))->enabled && strncpy(myname, opt->strarg, sizeof(myname))) || !gethostname(myname, sizeof(myname))) {
-	    myname[sizeof(myname)-1] = '\0';
-	    snprintf(xvirushdr, sizeof(xvirushdr), "clamav-milter %s at %s", get_version(), myname);
-	} else
-	    snprintf(xvirushdr, sizeof(xvirushdr), "clamav-milter %s", get_version());
-	xvirushdr[sizeof(xvirushdr)-1] = '\0';
-
-	descr.xxfi_flags |= SMFIF_ADDHDRS;
-
-	if(strcasecmp(pt, "Add")) { /* Replace or Yes */
-	    descr.xxfi_flags |= SMFIF_CHGHDRS;
-	    addxvirus = 1;
-	} else { /* Add */
-	    addxvirus = 2;
-	}
-    }
-
     multircpt = optget(opts, "SupportMultipleRecipients")->enabled;
     
     if(!optget(opts, "Foreground")->enabled) {