From: Peter Pentchev Date: Tue, 1 Sep 2009 09:09:34 +0000 (+0000) Subject: Randomize the generated Message-Id a bit more. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46f7b53636cace5ef9f16dc27e2ae4cc32509718;p=people%2Fms%2Fdma.git Randomize the generated Message-Id a bit more. Debian: #544475 Reported by: Tino Keitel --- diff --git a/changelog b/changelog index 14e6c5b..5cd6d73 100644 --- a/changelog +++ b/changelog @@ -3,6 +3,7 @@ dma (0.0.2009.07.17-2) unstable; urgency=low * Allow the spool directory to live on a filesystem that does not set the d_type member of the dirent structure, like XFS. Closes: #544357 + * Randomize the Message-Id a bit more. Closes: #544475 -- Peter Pentchev Tue, 01 Sep 2009 11:50:03 +0300 diff --git a/patches/24-random-message-id.patch b/patches/24-random-message-id.patch new file mode 100644 index 0000000..d3d1b2a --- /dev/null +++ b/patches/24-random-message-id.patch @@ -0,0 +1,50 @@ +Randomize the generated Message-Id field a bit more. + +Debian: #544475 + +--- a/Makefile ++++ b/Makefile +@@ -3,6 +3,7 @@ + + SUBDIR= etc + ++CFLAGS+= -DHAVE_RANDOM + CFLAGS+= -DHAVE_LIBLOCKFILE + CFLAGS+= -I${.CURDIR} + +--- a/dma.c ++++ b/dma.c +@@ -786,8 +786,15 @@ + } else if (!had_messagid) { + /* XXX better msgid, assign earlier and log? */ + had_messagid = 1; +- snprintf(line, sizeof(line), "Message-Id: <%"PRIxMAX"@%s>\n", +- queue->id, hostname()); ++ snprintf(line, sizeof(line), "Message-Id: <%"PRIxMAX".%"PRIxMAX".%"PRIxMAX"@%s>\n", ++ (uintmax_t)time(NULL), ++ queue->id, ++#ifdef HAVE_RANDOM ++ (uintmax_t)random(), ++#else ++ (uintmax_t)rand(), ++#endif ++ hostname()); + } else if (!had_from) { + had_from = 1; + snprintf(line, sizeof(line), "From: <%s>\n", sender); +@@ -1589,6 +1596,15 @@ + atexit(deltmp); + LIST_INIT(&queue.queue); + snprintf(tag, 254, "dma"); ++#ifdef HAVE_RANDOM ++#ifdef HAVE_SRANDOMDEV ++ srandomdev(); ++#else ++ srandom((unsigned long)((time(NULL) ^ getpid()) + ((uintptr_t)argv))); ++#endif /* SRANDOMDEV */ ++#else ++ srand((unsigned)((time(NULL) ^ getpid()) + ((uintptr_t)argv))); ++#endif /* RANDOM */ + + if (strcmp(argv[0], "mailq") == 0) { + argv++; argc--; diff --git a/patches/series b/patches/series index ac2c366..b329ae3 100644 --- a/patches/series +++ b/patches/series @@ -9,3 +9,4 @@ 20-parse-recipient.patch 22-openfiles.patch 23-dirent-d_type.patch +24-random-message-id.patch