]> git.ipfire.org Git - people/ms/dma.git/blame - patches/24-random-message-id.patch
Really fix the build on the GNU Hurd.
[people/ms/dma.git] / patches / 24-random-message-id.patch
CommitLineData
064dc875 1Description: Randomize the generated Message-Id field a bit more.
064dc875
PP
2Origin: other: http://svn.ringlet.net/svn/ringlet/mail/dma/
3Bug-Debian: http://bugs.debian.org/544475
66ab518c 4Forwarded: yes
064dc875 5Author: Peter Pentchev <roam@ringlet.net>
383be5f5 6Last-Update: 2010-06-21
46f7b536 7
46f7b536
PP
8--- a/dma.c
9+++ b/dma.c
70f0f49b 10@@ -375,6 +375,15 @@
272191cb
PP
11
12 bzero(&queue, sizeof(queue));
13 LIST_INIT(&queue.queue);
14+#ifdef HAVE_RANDOM
15+#ifdef HAVE_SRANDOMDEV
16+ srandomdev();
17+#else
18+ srandom((unsigned long)((time(NULL) ^ getpid()) + ((uintptr_t)argv)));
19+#endif /* SRANDOMDEV */
20+#else
21+ srand((unsigned)((time(NULL) ^ getpid()) + ((uintptr_t)argv)));
22+#endif /* RANDOM */
23
24 if (strcmp(argv[0], "mailq") == 0) {
25 argv++; argc--;
26--- a/mail.c
27+++ b/mail.c
28@@ -37,6 +37,7 @@
29
30 #include <err.h>
31 #include <errno.h>
32+#include <inttypes.h>
33 #include <signal.h>
34 #include <syslog.h>
35 #include <unistd.h>
405ff48f 36@@ -514,8 +515,15 @@
46f7b536
PP
37 } else if (!had_messagid) {
38 /* XXX better msgid, assign earlier and log? */
39 had_messagid = 1;
272191cb 40- snprintf(line, sizeof(line), "Message-Id: <%s@%s>\n",
46f7b536 41- queue->id, hostname());
272191cb 42+ snprintf(line, sizeof(line), "Message-Id: <%"PRIxMAX".%s.%"PRIxMAX"@%s>\n",
46f7b536
PP
43+ (uintmax_t)time(NULL),
44+ queue->id,
45+#ifdef HAVE_RANDOM
46+ (uintmax_t)random(),
47+#else
48+ (uintmax_t)rand(),
49+#endif
50+ hostname());
51 } else if (!had_from) {
52 had_from = 1;
272191cb 53 snprintf(line, sizeof(line), "From: <%s>\n", queue->sender);
70f0f49b
PP
54--- a/Makefile.plain
55+++ b/Makefile.plain
56@@ -8,6 +8,7 @@
57 CFLAGS?= -O -pipe
58 LDADD?= -lssl -lcrypto -lresolv -llockfile
59
60+CFLAGS+= -DHAVE_RANDOM -DHAVE_SRANDOM
61 CFLAGS+= -DHAVE_LIBLOCKFILE
62
63 INSTALL?= install -p
383be5f5
PP
64--- a/Makefile
65+++ b/Makefile
66@@ -1,7 +1,7 @@
67 # $DragonFly: src/libexec/dma/Makefile,v 1.5 2008/09/19 00:36:57 corecode Exp $
68 #
69
70-CFLAGS+= -DHAVE_LIBLOCKFILE
71+CFLAGS+= -DHAVE_RANDOM -DHAVE_SRANDOM -DHAVE_LIBLOCKFILE
72 CFLAGS+= -I${.CURDIR}
73
74 DPADD= ${LIBSSL} ${LIBCRYPTO} /usr/lib/liblockfile.a