Article View: news.software.nntp
Article #70722a patch, some comments, and a question ...
From: Sylvain Robitaille
Date: Thu, 17 Feb 2005 00:02
Date: Thu, 17 Feb 2005 00:02
469 lines
19438 bytes
19438 bytes
Alright, this will likely be fairly long, but I hope folks will bear
with me ...
first the patch:
Way back in the Stone Ages (late 1993, into early 1994, actually), a
fellow by the name of Luke Mewburn produced a patch for Inn (1.4.x at the
time, I believe; we started using it here with Inn-1.5.1) which caused
nnrpd to add an additional header "NNTP-Posting-User" to all locally
posted messages. I've been running a news server for a number of years
now, with this (and more than a few others, which appear to have since
been incorporated into newer versions of Inn) patch applied to Inn-1.7.
Well, I'm in the process of "graduating" to Inn-2.4.2, and though I
realize that the NNTP-Posting-User patch is not of great value to many
news admins, it is functionality I did not want to lose. I've managed
to port it forward, though with some slight simplifications (and no
attempt to make it work with IPv6, as I do not have any IPv6 attached
systems to test with) of some of the code.
I've tested this on my new news server and it appears to be working as
expected. I include, below my signature, the patch against Inn-2.4.2,
in case this might be useful to anyone else. I hope it will be.
Comments and criticisms are of course welcome. I'm sure this could
have been done more elegantly, but I've done the best I believe I can do
(I have some programming skill, but I'm by no means a "programmer").
Next, the comments:
This applies to every version of Inn (and perhaps other news servers as
well, but I've only worked with Inn) that I'm aware of, interestingly
enough ...
- Installed file ownerships and permissions are arguably not restrictive
enough: why does the "news" user own the installed binaries, libraries,
include files, documentation, etc? More importantly, why is the
news server process able to rewrite (by virtue of running as user
"news") the news server configuration files and input filters?
I would argue that the news user needs write permission only to the
following:
- PATHARCHIVE
- PATHARTICLES
- PATHDB
- PATHINBAD
- PATHINCOMING
- PATHLOG
- PATHLOGOLD
- PATHOUTGOING
- PATHOVERVIEW
- PATHRUN
- PATHSPOOL
- PATHTAPE
- PATHTMP
- _PATH_RNEWS_DUP_LOG
The directories where binaries, libraries, configuration files, and
anything else that could change _how_ the news server functions (and
those files), in my opinion, should _not_ be writable to the same user
that the news server runs as. I do intend to ultimately adjust this
in my own installation of Inn-2.4.2.
Also, for those installing Inn-2.4.2 (from source) on Slackware Linux:
- On a Slackware-10 Linux system (probably also true of other versions),
the Berkeley DB package (at least with db3) is installed as "libdb",
rather than libdb3. Configure correctly finds /usr/include/db3, then
assumes that the library will also be named "db3" (EXTSTORAGELIBS in
Makefile.global is set via configure's BERKELEY_DB_LIB to "-ldb3").
This is arguably a Slackware oddity, rather than a problem with
Inn, but a usable work-around is to replace "@BERKELEY_DB_LIB@" in
Makefile.global.in with "-ldb" prior to running configure.
Finally, my question ...
Primarily, the news server I manage is a readers server. I do exchange
feeds with a small number of peers (at one time this system was one of a
few primary North-American news "hubs", but the growth of some of the
hierarchies and the proliferation of commercial news servers have made
that a historical tidbit at best).
In the end, I've not gone (perhaps "yet") with ovdb for overview, but
rather I'm using the traditional overview method (this system does have
_fast_ disks, and I am dealing with a primarily text-only feed). I've
configured to use overchan via the newsfeeds, as follows:
# News overview.
overview!:*,@junk,@control*:Tc,WnteO:/local/paths/overchan
The idea is to poison out any articles in junk and control*, since
readers aren't going to be interested in those anyway. However, in my
/news/log/errlog, I'm seeing repeated messages like the following from
overchan trying to write overview information for control messages
(mostly cancels, it seems, but some newgroup, rmgroup, and checkgroups
messages as well):
overchan: cannot write overview cmsg cancel <1108596738@reader1.news>
<nntpmon@ozemail.com.au> Wed, 16 Feb 2005 23:32:34 GMT
<cancel.1108596738@reader1.news> 710 1
Xref: newsflash.concordia.ca control.cancel:20796887535
Clearly my attempt above to poison junk and control* is not doing what I
intended. Can someone point me to some information that will help me
understand what I've done wrong, and how to get the result I want?
Thanks for taking the time to read this far... My adaptation of Luke
Mewburn's NNTP-Posting-User patch is appended.
--
----------------------------------------------------------------------
Sylvain Robitaille syl@alcor.concordia.ca
Systems analyst / Newsmaster Concordia University
Instructional & Information Technology Montreal, Quebec, Canada
----------------------------------------------------------------------
# nntp-posting-user patch (against Inn-2.4.2, originally by Luke
# Mewburn, adapted by Sylvain Robitaille -- any mistakes are my own):
--- nnrpd/post.h.original 2004-12-21 23:21:19.000000000 -0500
+++ nnrpd/post.h 2005-02-03 16:35:30.000000000 -0500
@@ -47,6 +47,7 @@
#define HDR__XTRACE 21
#define HDR__XCOMPLAINTSTO 22
#define HDR__NNTPPOSTINGDATE 23
+#define HDR__NNTPPOSTINGUSER 24
#define HDR__CC 33
#define HDR__BCC 34
#define HDR__TO 35
--- nnrpd/post.c.original 2004-12-21 23:21:19.000000000 -0500
+++ nnrpd/post.c 2005-02-03 16:38:50.000000000 -0500
@@ -51,6 +51,7 @@
{ "X-Trace", false, HTstd, 0, NULL, NULL, 0 },
{ "X-Complaints-To", false, HTstd, 0, NULL, NULL, 0 },
{ "NNTP-Posting-Date", false, HTstd, 0, NULL, NULL, 0 },
+ { "NNTP-Posting-User", false, HTstd, 0, NULL, NULL, 0 },
{ "Xref", false, HTstd, 0, NULL, NULL, 0 },
{ "Injector-Info", false, HTstd, 0, NULL, NULL, 0 },
{ "Summary", true, HTstd, 0, NULL, NULL, 0 },
@@ -489,6 +490,13 @@
if (!ihave && PERMaccessconf->addnntppostingdate)
HDR_SET(HDR__NNTPPOSTINGDATE, datebuff);
+ /*
+ * 2005/02/03 Sylvain Robitaille: adaptation of Luke Mewburn's
+ * NNTP-Posting-User patch
+ */
+ if (!ihave && PERMaccessconf->addnntppostinguser)
+ HDR_SET(HDR__NNTPPOSTINGUSER, ClientUser);
+
/* X-Trace; set */
t = time((time_t *)NULL) ;
pid = (long) getpid() ;
--- nnrpd/nnrpd.h.original 2004-12-21 23:21:19.000000000 -0500
+++ nnrpd/nnrpd.h 2005-02-08 16:34:53.000000000 -0500
@@ -76,6 +76,7 @@
int strippostcc;
int addnntppostinghost;
int addnntppostingdate;
+ int addnntppostinguser;
char *nnrpdposthost;
int nnrpdpostport;
int nnrpdoverstats;
@@ -154,6 +155,7 @@
EXTERN char **PERMreadlist;
EXTERN char **PERMpostlist;
EXTERN char ClientHost[SMBUF];
+EXTERN char ClientUser[SMBUF]; /* lm, 931203 */
EXTERN char ServerHost[SMBUF];
EXTERN char Username[SMBUF];
#ifdef HAVE_INET6
--- nnrpd/nnrpd.c.original 2004-12-21 23:21:19.000000000 -0500
+++ nnrpd/nnrpd.c 2005-02-15 19:55:29.000000000 -0500
@@ -571,6 +571,31 @@
break;
#endif
}
+
+ /*
+ * 2005/02/15 Sylvain Robitaille: This may not be the greatest place
+ * for this; we _just_ went from IP address to string in
+ * Sock2String above, but I need the in_addr_t form for
+ * Luke Mewburn's ident_client().
+ */
+ ClientIpAddr = inet_addr(ClientIpString);
+
+ /* lm, 940112 */
+ /* Adapted for Inn-2.4.2 by Sylvain Robitaille, 2005/02/15 */
+ ClientUser[0] = '\0';
+ if (!isatty(STDIN_FILENO)) {
+ length = sizeof(sss);
+ if (getsockname(STDIN_FILENO, (struct sockaddr *)&sss, &length) >= 0) {
+ char *ident_client();
+ char *them;
+
+ them = ident_client(ClientIpAddr, ClientPort,ServerPort);
+ if (them) {
+ (void)strncpy(ClientUser, them, sizeof(ClientUser) - 1);
+ ClientUser[sizeof(ClientUser) - 1] = '\0';
+ }
+ }
+ }
}
strlcpy(LogName, ClientHost, sizeof(LogName));
--- nnrpd/perm.c.original 2004-12-21 23:21:19.000000000 -0500
+++ nnrpd/perm.c 2005-02-08 16:53:45.000000000 -0500
@@ -135,32 +135,33 @@
#define PERMstrippostcc 37
#define PERMaddnntppostinghost 38
#define PERMaddnntppostingdate 39
-#define PERMnnrpdposthost 40
-#define PERMnnrpdpostport 41
-#define PERMnnrpdoverstats 42
-#define PERMbackoff_auth 43
-#define PERMbackoff_db 44
-#define PERMbackoff_k 45
-#define PERMbackoff_postfast 46
-#define PERMbackoff_postslow 47
-#define PERMbackoff_trigger 48
-#define PERMnnrpdcheckart 49
-#define PERMnnrpdauthsender 50
-#define PERMvirtualhost 51
-#define PERMnewsmaster 52
-#define PERMlocaladdress 53
-#define PERMrejectwith 54
-#define PERMmaxbytespersecond 55
-#define PERMperl_auth 56
-#define PERMpython_auth 57
-#define PERMperl_access 58
-#define PERMpython_access 59
-#define PERMpython_dynamic 60
+#define PERMaddnntppostinguser 40
+#define PERMnnrpdposthost 41
+#define PERMnnrpdpostport 42
+#define PERMnnrpdoverstats 43
+#define PERMbackoff_auth 44
+#define PERMbackoff_db 45
+#define PERMbackoff_k 46
+#define PERMbackoff_postfast 47
+#define PERMbackoff_postslow 48
+#define PERMbackoff_trigger 49
+#define PERMnnrpdcheckart 50
+#define PERMnnrpdauthsender 51
+#define PERMvirtualhost 52
+#define PERMnewsmaster 53
+#define PERMlocaladdress 54
+#define PERMrejectwith 55
+#define PERMmaxbytespersecond 56
+#define PERMperl_auth 57
+#define PERMpython_auth 58
+#define PERMperl_access 59
+#define PERMpython_access 60
+#define PERMpython_dynamic 61
#ifdef HAVE_SSL
-#define PERMrequire_ssl 61
-#define PERMMAX 62
+#define PERMrequire_ssl 62
+#define PERMMAX 63
#else
-#define PERMMAX 61
+#define PERMMAX 62
#endif
#define TEST_CONFIG(a, b) \
@@ -225,6 +226,7 @@
{ PERMstrippostcc, "strippostcc:" },
{ PERMaddnntppostinghost, "addnntppostinghost:" },
{ PERMaddnntppostingdate, "addnntppostingdate:" },
+ { PERMaddnntppostinguser, "addnntppostinguser:" },
{ PERMnnrpdposthost, "nnrpdposthost:" },
{ PERMnnrpdpostport, "nnrpdpostport:" },
{ PERMnnrpdoverstats, "nnrpdoverstats:" },
@@ -493,6 +495,7 @@
curaccess->strippostcc = innconf->strippostcc;
curaccess->addnntppostinghost = innconf->addnntppostinghost;
curaccess->addnntppostingdate = innconf->addnntppostingdate;
+ curaccess->addnntppostinguser = innconf->addnntppostinguser;
curaccess->nnrpdposthost = innconf->nnrpdposthost;
curaccess->nnrpdpostport = innconf->nnrpdpostport;
curaccess->nnrpdoverstats = innconf->nnrpdoverstats;
@@ -977,6 +980,10 @@
if (boolval != -1) curaccess->addnntppostingdate = boolval;
SET_CONFIG(oldtype);
break;
+ case PERMaddnntppostinguser:
+ if (boolval != -1) curaccess->addnntppostinguser = boolval;
+ SET_CONFIG(oldtype);
+ break;
case PERMnnrpdposthost:
if (curaccess->nnrpdposthost)
free(curaccess->nnrpdposthost);
@@ -1281,6 +1288,7 @@
case PERMstrippostcc:
case PERMaddnntppostinghost:
case PERMaddnntppostingdate:
+ case PERMaddnntppostinguser:
case PERMnnrpdposthost:
case PERMnnrpdpostport:
case PERMnnrpdoverstats:
--- nnrpd/ident_client.c.original 1969-12-31 19:00:00.000000000 -0500
+++ nnrpd/ident_client.c 2005-02-15 20:04:13.000000000 -0500
@@ -0,0 +1,121 @@
+/*
+ * ident_client.c
+ *
+ * Identifies the remote user of a given connection.
+ *
+ * Written 940112 by Luke Mewburn <lm@rmit.edu.au>
+ *
+ * Copyright (C) 1994 by Luke Mewburn.
+ * This code may be used freely by anyone as long as this copyright remains.
+ *
+ */
+
+/*
+ * adapted to Inn-2.4.2 by Sylvain Robitaille <syl@alcor.concordia.ca>,
+ * 2005/02/15: NOTE: no effort has been made to make this IPv6 friendly.
+ * I'm not un-inclined to do so, but it is a very low priority for me at
+ * the moment.
+ */
+#include "config.h"
+#include "nnrpd.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+#define IDENT_PORT 113
+
+/*
+ * ident_client
+ * - user interface to identd
+ *
+ * Args:
+ * peeraddr in_addr_t of peer end: the IP address in network byte order.
+ * peerport the port number used by the peer end.
+ * ourport the port number connected to at our end.
+ *
+ * Returns:
+ * NULL on failure to identify (for whatever reason), or pointer to
+ * static character string with the identity.
+ */
+
+char *
+ident_client(peeraddr, peerport, ourport)
+ in_addr_t peeraddr;
+ int peerport, ourport;
+{
+ struct sockaddr_in authcon;
+ int authfd, authlen;
+ struct servent *identserv;
+ int identport;
+
+ FILE *authfpin, *authfpout;
+ char buffer[8192]; /* XXX: argh! magic numbers */
+ char reply_type[81];
+ char opsys_or_err[81];
+ int rport, lport;
+
+ static char identifier[1024];
+
+ authfd = socket(AF_INET, SOCK_STREAM, 0);
+ if (authfd == -1)
+ return NULL;
+
+ identserv = getservbyname("ident", "tcp");
+ if (identserv)
+ identport = identserv->s_port;
+ else
+ identport = ntohs(IDENT_PORT);
+
+ memset(&authcon, 0, sizeof(authcon));
+ authcon.sin_family = AF_INET;
+ authcon.sin_addr.s_addr = peeraddr;
+ authcon.sin_port = identport;
+
+ authlen = sizeof(authcon);
+ if (connect(authfd, (struct sockaddr *)&authcon, authlen) < 0) {
+ syslog(L_ERROR, "ident_client: %s", "connect failed");
+ return NULL;
+ }
+ authfpin = fdopen(authfd, "r");
+ authfpout = fdopen(authfd, "w");
+ if (!authfpin || !authfpout) {
+ syslog(L_ERROR, "ident_client: %s", "fdopen failed");
+ return NULL;
+ }
+ /* Anne Bennett 1995/05/31 Some machines time out waiting for CR/LF;
+ * LF is not sufficient. (E.g.: VMS machines)
+ */
+ fprintf(authfpout, "%d , %d\r\n", peerport, ourport);
+ fflush(authfpout);
+
+ if (fgets(buffer, sizeof(buffer)-1, authfpin) == NULL) {
+ syslog(L_ERROR, "ident_client: %s", "fgets failed");
+ return NULL;
+ }
+
+ shutdown(authfd, 1);
+
+ authlen = sscanf(buffer, "%d , %d : %[^ \t\n\r:] : %[^ \t\n\r:] : %[^\n\r]",
+ &lport, &rport, reply_type, opsys_or_err, identifier);
+ if (authlen < 3) {
+ syslog(L_ERROR, "ident_client: %s: %s", "sscanf failed", buffer);
+ return NULL;
+ }
+
+#if 0 /* XXX: for if we ever handle the ERROR class */
+ if (! strcasecmp(reply_type, "ERROR"))
+ return NULL;
+#endif
+ if (strcasecmp(reply_type, "USERID")) {
+ syslog(L_ERROR, "ident_client: %s: %s", "reply type", reply_type);
+ syslog(L_ERROR, "ident_client: %s", buffer);
+ return NULL;
+ }
+
+ return identifier;
+} /* ident_client */
+
--- include/inn/innconf.h.original 2004-12-21 23:21:19.000000000 -0500
+++ include/inn/innconf.h 2005-02-08 16:55:36.000000000 -0500
@@ -91,6 +91,7 @@
/* Posting */
bool addnntppostingdate; /* Add NNTP-Posting-Date: to posts */
bool addnntppostinghost; /* Add NNTP-Posting-Host: to posts */
+ bool addnntppostinguser; /* Add NNTP-Posting-User: to posts */
bool checkincludedtext; /* Reject if too much included text */
char *complaints; /* Address for X-Complaints-To: */
char *fromhost; /* Host for the From: line */
--- nnrpd/Makefile.original 2004-12-21 23:21:19.000000000 -0500
+++ nnrpd/Makefile 2005-02-03 17:09:22.000000000 -0500
@@ -9,7 +9,7 @@
SOURCES = article.c cache.c group.c commands.c line.c list.c misc.c \
newnews.c nnrpd.c perl.c perm.c post.c python.c \
- sasl_config.c tls.c track.c
+ sasl_config.c tls.c track.c ident_client.c
INCLUDES = cache.h nnrpd.h post.h sasl_config.h tls.h
--- lib/innconf.c.original 2004-12-21 23:21:19.000000000 -0500
+++ lib/innconf.c 2005-02-08 16:36:36.000000000 -0500
@@ -180,6 +180,7 @@
/* The following settings are specific to nnrpd. */
{ K(addnntppostingdate), BOOL (true) },
{ K(addnntppostinghost), BOOL (true) },
+ { K(addnntppostinguser), BOOL (true) },
{ K(allownewnews), BOOL (true) },
{ K(backoffauth), BOOL (false) },
{ K(backoffdb), STRING (NULL) },
Technical Details
Message-ID:
<slrnd17nop.2nve.syl@alcor.concordia.ca>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!207.35.177.252!nf3.bellglobal.com!snoopy.risq.qc.ca!newsflash.concordia.ca!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <slrnd17nop.2nve.syl@alcor.concordia.ca> Subject: a patch, some comments, and a question ... Date: Thu, 17 Feb 2005 00:02:33 +0000 From: Sylvain Robitaille <syl@alcor.concordia.ca> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!207.35.177.252!nf3.bellglobal.com!snoopy.risq.qc.ca!newsflash.concordia.ca!not-for-mail Newsgroups: news.software.nntp Organization: Concordia University, Montreal, Canada Lines: 469 NNTP-Posting-Host: alcor.concordia.ca X-Trace: newnewsflash.concordia.ca 1108598553 29284 132.205.7.51 (17 Feb 2005 X-Complaints-To: abuse@concordia.ca NNTP-Posting-Date: Thu, 17 Feb 2005 00:02:33 +0000 (UTC) NNTP-Posting-User: syl User-Agent: slrn/0.9.7.4 (OSF1)