summaryrefslogtreecommitdiffstats
path: root/spamlogd.patch
diff options
context:
space:
mode:
Diffstat (limited to 'spamlogd.patch')
-rw-r--r--spamlogd.patch78
1 files changed, 78 insertions, 0 deletions
diff --git a/spamlogd.patch b/spamlogd.patch
new file mode 100644
index 0000000..0d6527f
--- /dev/null
+++ b/spamlogd.patch
@@ -0,0 +1,78 @@
+Index: spamlogd.c
+===================================================================
+RCS file: /cvs/src/libexec/spamlogd/spamlogd.c,v
+retrieving revision 1.26
+diff -u -r1.26 spamlogd.c
+--- spamlogd.c 11 Dec 2015 17:16:52 -0000 1.26
++++ spamlogd.c 31 Dec 2015 15:48:03 -0000
+@@ -32,6 +32,7 @@
+
+ #include <netinet/in.h>
+ #include <netinet/ip.h>
++#include <netinet/ip6.h>
+ #include <arpa/inet.h>
+
+ #include <net/pfvar.h>
+@@ -110,8 +111,9 @@
+ init_pcap(void)
+ {
+ struct bpf_program bpfp;
+- char filter[PCAPFSIZ] = "ip and port 25 and action pass "
+- "and tcp[13]&0x12=0x2";
++ char filter[PCAPFSIZ] = "tcp and port 25 and action pass "
++ "and ((ip and tcp[13] & 0x12 = 0x2) or "
++ "(ip6 and ip6[6] = 0x6 and ip6[53] & 0x12 = 0x2))";
+
+ if ((hpcap = pcap_open_live(pflogif, PCAPSNAP, 1, PCAPTIMO,
+ errbuf)) == NULL) {
+@@ -155,6 +157,7 @@
+ u_int8_t hdrlen;
+ u_int32_t caplen = h->caplen;
+ const struct ip *ip = NULL;
++ const struct ip6_hdr *ip6 = NULL;
+ const struct pfloghdr *hdr;
+ char ipstraddr[40] = { '\0' };
+
+@@ -185,6 +188,14 @@
+ else if (hdr->dir == PF_OUT && !flag_inbound)
+ inet_ntop(af, &ip->ip_dst, ipstraddr,
+ sizeof(ipstraddr));
++ } else if (af == AF_INET6) {
++ ip6 = (const struct ip6_hdr *)(sp + hdrlen);
++ if (hdr->dir == PF_IN)
++ inet_ntop(af, &ip6->ip6_src, ipstraddr,
++ sizeof(ipstraddr));
++ else if (hdr->dir == PF_OUT && !flag_inbound)
++ inet_ntop(af, &ip6->ip6_dst, ipstraddr,
++ sizeof(ipstraddr));
+ }
+
+ if (ipstraddr[0] != '\0') {
+@@ -205,7 +216,12 @@
+ struct gdata gd;
+ time_t now;
+ int r;
+- struct in_addr ia;
++ struct addrinfo hints, *res;
++ memset(&hints, 0, sizeof(hints));
++ hints.ai_family = PF_UNSPEC;
++ hints.ai_socktype = SOCK_DGRAM; /*dummy*/
++ hints.ai_protocol = IPPROTO_UDP; /*dummy*/
++ hints.ai_flags = AI_NUMERICHOST;
+
+ now = time(NULL);
+ memset(&hashinfo, 0, sizeof(hashinfo));
+@@ -215,10 +231,12 @@
+ strerror(errno));
+ return (-1);
+ }
+- if (inet_pton(AF_INET, ip, &ia) != 1) {
++ if (getaddrinfo(ip, NULL, &hints, &res) != 0) {
+ logmsg(LOG_NOTICE, "Invalid IP address %s", ip);
+ goto bad;
+ }
++ freeaddrinfo(res);
++
+ memset(&dbk, 0, sizeof(dbk));
+ dbk.size = strlen(ip);
+ dbk.data = ip;