Article View: news.software.nntp
Article #86949Re: Patch to munge posting-host
From: noel
Date: Sun, 06 Sep 2015 12:17
Date: Sun, 06 Sep 2015 12:17
91 lines
4395 bytes
4395 bytes
On Sun, 06 Sep 2015 10:50:31 +0000, Steve Crook wrote:
> Hi all,
>
> I constructed the following patch to munge the client details in the
> Posting-Host and Path headers. Previously I've done this via the Perl
> hook but using this approach means I can drop "with-perl" from my INN
> config.
>
> It's probably not a mainstream thing to do but I thought a few people
> might find it useful. After applying, remember to change the
> SHA_PH_SALT in nnrpd/post.c to something unique.
>
>
> --- post.c.old 2015-09-06 11:25:11.923062898 +0100 +++ post.c
2015-09-06
> 11:24:02.592241184 +0100 @@ -9,6 +9,7 @@
> #include "nnrpd.h"
> #include "inn/ov.h"
> #include "post.h"
> +#include <openssl/sha.h>
>
> #define FLUSH_ERROR(F) (fflush((F)) == EOF || ferror
((F)))
> #define HEADER_DELTA 20
> @@ -23,6 +24,8 @@
> static const char * const BadDistribs[] = {
> BAD_DISTRIBS
> };
> +// Salt the SHA1 Hash used in posting-host +static const char*
> SHA_PH_SALT = "Insert Salt here";
>
> /*
> ** Do not modify the table without also looking at post.h for
> potential
> @@ -488,11 +491,10 @@
> free(newpath);
> if (PERMaccessconf->addinjectionpostinghost) {
> if (addvirtual) {
> - newpath = concat(VirtualPath, ".POSTED.", Client.host, "!",
> - HDR(HDR__PATH), (char *) 0);
> - } else {
> - newpath = concat(".POSTED.", Client.host, "!",
> HDR(HDR__PATH),
> + newpath = concat(VirtualPath, ".POSTED!", HDR(HDR__PATH),
> (char *) 0);
> + } else {
> + newpath = concat(".POSTED!", HDR(HDR__PATH), (char *) 0);
> }
> } else {
> if (addvirtual) {
> @@ -562,17 +564,26 @@
> * (we already saw the case of "localhost:" without IP),
> * when getpeername fails. */
> if ((strlen(Client.host) > 0) || (strlen(Client.ip) > 0)) {
> + unsigned char digest[SHA_DIGEST_LENGTH];
> + SHA_CTX ctx;
> + SHA1_Init(&ctx);
> if ((strcmp(Client.host, Client.ip) == 0)
> || (strlen(Client.host) == 0)) {
> - snprintf(postinghostbuff, sizeof(postinghostbuff),
> - "; posting-host=\"%s\"", Client.ip);
> + SHA1_Update(&ctx, Client.ip, strlen(Client.ip));
> } else if (strlen(Client.ip) == 0) {
> - snprintf(postinghostbuff, sizeof(postinghostbuff),
> - "; posting-host=\"%s\"", Client.host);
> + SHA1_Update(&ctx, Client.host, strlen(Client.host));
> } else {
> - snprintf(postinghostbuff, sizeof(postinghostbuff),
> - "; posting-host=\"%s:%s\"", Client.host,
> Client.ip); + SHA1_Update(&ctx, Client.host,
> strlen(Client.host));
> + SHA1_Update(&ctx, Client.ip, strlen(Client.ip));
> }
> + SHA1_Update(&ctx, SHA_PH_SALT, strlen(SHA_PH_SALT));
> + SHA1_Final(digest, &ctx);
> + char mdString[SHA_DIGEST_LENGTH*2+1];
> + int i;
> + for (i = 0; i < SHA_DIGEST_LENGTH; i++)
> + sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]);
> + snprintf(postinghostbuff, sizeof(postinghostbuff),
> + "; posting-host=\"%s\"", mdString);
> }
>
> /* Set the logging-data attribute. */
mungings a good idea, so long as there is a way to identify them if the
complaints come in.
Technical Details
Message-ID:
<55ec2ebf$1@news.ausics.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.(19219).mbox.7z!not-for-mailReferences:
<slrnmuo6jn.ilk.steve@snorky.mixmin.net>Show Full Headers
Complete Article Headers
Message-ID: <55ec2ebf$1@news.ausics.net> Subject: Re: Patch to munge posting-host Date: Sun, 06 Sep 2015 12:17:03 +0000 From: noel <deletethis@invalin.lan> References: <slrnmuo6jn.ilk.steve@snorky.mixmin.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.(19219).mbox.7z!not-for-mail Newsgroups: news.software.nntp X-No-Archive: Yes X-Ping: Pong User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: news.ausics.net Organization: Ausics - http://www.ausics.org Lines: 89 X-Complaints: abuse@ausics.net X-Received-Body-CRC: 713454348 X-Received-Bytes: 4336