Article View: news.software.nntp
Article #28171X-Trace backported to 1.7.2
From: Paul Martin
Date: Fri, 15 May 1998 00:00
Date: Fri, 15 May 1998 00:00
184 lines
6369 bytes
6369 bytes
Here follows a short patch to NNRP which can be applied against INN from
1.5.1 (possibly even earlier) onwards. It was written for 1.7.2insync, but
applies (with fuzz factors) to earlier versions.
It adds X-Trace and NNTP-Posting-Date to the headers (as well as letting
certain hosts, defined in nnrp.access, to set their own
NNTP-Posting-Host).
--- nnrpd.c.orig Mon Dec 8 23:48:50 1997
+++ nnrpd.c Fri May 15 22:54:13 1998
@@ -326,6 +326,7 @@
PERMcanread = FALSE;
PERMcanpost = FALSE;
+ PERMpostinghost = FALSE;
found = FALSE;
accesslist[0] = '\0';
while (fgets(buff, sizeof buff, F) != NULL) {
@@ -365,6 +366,7 @@
PERMcanread = strchr(fields[1], 'R') != NULL;
PERMcanpost = strchr(fields[1], 'P') != NULL;
+ PERMpostinghost = strchr(fields[1], 'H') != NULL;
(void)strcpy(PERMuser, user ? user : fields[2]);
(void)strcpy(PERMpass, pass ? pass : fields[3]);
(void)strcpy(accesslist, fields[4]);
@@ -398,6 +400,7 @@
ExitWithStats(1);
}
(void)strcpy(ClientHost, "stdin");
+ ClientIP = 0L;
}
#if defined(AF_DECnet)
else if (sin.sin_family == AF_DECnet) {
@@ -428,14 +431,19 @@
syslog(L_NOTICE,
"? cant gethostbyaddr %s %m -- using IP address for access",
ClientHost);
+ ClientAddr = ClientHost;
+ ClientIP = inet_addr(ClientHost);
}
else {
ClientAddr = buff;
(void)strcpy(buff, inet_ntoa(sin.sin_addr));
+ ClientIP = inet_addr(buff);
}
#else
(void)strcpy(ClientHost, inet_ntoa(sin.sin_addr));
+ ClientIP = inet_addr(ClientHost);
#endif /* defined(DO_NNRP_GETHOSTBYADDR) */
+ (void)strncpy(ClientIp, inet_ntoa(sin.sin_addr), sizeof(ClientIp));
}
strncpy (LogName,ClientHost,sizeof(LogName) - 1) ;
@@ -650,10 +658,11 @@
PerlFilter (TRUE) ;
#endif /* defined(DO_PERL) */
- Reply("%d %s InterNetNews NNRP server %s ready (%s).\r\n",
+ Reply("%d %s InterNetNews NNRP server %s ready (%s%s).\r\n",
PERMcanpost ? NNTP_POSTOK_VAL : NNTP_NOPOSTOK_VAL,
MyHostName, INNVersion(),
- PERMcanpost ? "posting ok" : "no posting");
+ PERMcanpost ? "posting ok" : "no posting",
+ PERMpostinghost ? ", host ok" : "");
/* Main dispatch loop. */
for (timeout = INITIAL_TIMEOUT, av = NULL; ; timeout = CLIENT_TIMEOUT) {
--- nnrpd.h.orig Mon Dec 8 23:48:50 1997
+++ nnrpd.h Fri May 15 22:54:50 1998
@@ -88,11 +88,13 @@
EXTERN BOOL PERMcanread;
EXTERN BOOL PERMneedauth;
EXTERN BOOL PERMspecified;
+EXTERN BOOL PERMpostinghost;
EXTERN BOOL Tracing;
EXTERN char **PERMlist;
EXTERN STRING MyHostName;
extern char ACTIVE[];
EXTERN char ClientHost[SMBUF];
+EXTERN char ClientIp[40];
EXTERN char LogName[256] ;
extern char ACTIVETIMES[];
extern char HISTORY[];
@@ -112,7 +114,7 @@
EXTERN char GRPlast[SPOOLNAMEBUFF];
EXTERN long POSTreceived;
EXTERN long POSTrejected;
-
+EXTERN long ClientIP;
#if NNRP_LOADLIMIT > 0
extern int GetLoadAverage();
--- post.c.orig Mon Dec 8 23:48:50 1997
+++ post.c Fri May 15 23:02:51 1998
@@ -72,6 +72,10 @@
#define _contenttype 19
{ "Content-Transfer-Encoding", TRUE, HTstd },
#define _contenttransferencoding 20
+ { "X-Trace", FALSE, HTstd },
+#define _xtrace 21
+ { "NNTP-Posting-Date", FALSE, HTstd },
+#define _nntppostdate 22
{ "Xref", FALSE, HTstd },
{ "Summary", TRUE, HTstd },
{ "Keywords", TRUE, HTstd },
@@ -313,6 +317,7 @@
static char datebuff[40];
static char orgbuff[SMBUF];
static char linebuff[40];
+ static char xtracebuff[SMBUF];
static char sendbuff[SMBUF];
static char mimeversion[SMBUF];
static char mimetype[SMBUF];
@@ -323,6 +328,7 @@
struct tm *gmt;
TIMEINFO Now;
STRING error;
+ pid_t pid;
/* Do some preliminary fix-ups. */
for (hp = Table; hp < ENDOF(Table); hp++) {
@@ -356,12 +362,14 @@
return Error;
}
+ if ((gmt = gmtime(&Now.time)) == NULL)
+ return "Can't get the time";
+ (void)sprintf(datebuff, "%d %3.3s %d %02d:%02d:%02d GMT",
+ gmt->tm_mday, &MONTHS[3 * gmt->tm_mon], 1900 + gmt->tm_year,
+ gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
+
+
if (HDR(_date) == NULL) {
- if ((gmt = gmtime(&Now.time)) == NULL)
- return "Can't get the time";
- (void)sprintf(datebuff, "%d %3.3s %d %02d:%02d:%02d GMT",
- gmt->tm_mday, &MONTHS[3 * gmt->tm_mon], 1900 + gmt->tm_year,
- gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
HDR(_date) = datebuff;
}
else {
@@ -482,7 +490,22 @@
/* Supersedes; left alone. */
/* NNTP-Posting host; set. */
- HDR(_nntpposthost) = ClientHost;
+ if ((HDR(_nntpposthost) == NULL) || (!PERMpostinghost)) {
+ HDR(_nntpposthost) = ClientHost;
+ HDR(_nntppostdate) = datebuff;
+
+ t = time((time_t *)NULL);
+ pid = (long) getpid();
+ if ((gmt = gmtime(&Now.time)) == NULL)
+ return "Can't get the time";
+ if ((p = GetFQDN()) == NULL )
+ p = "unknown";
+ sprintf(xtracebuff, "%s %ld %ld %s (%d %3.3s %d %02d:%02d:%02d GMT)",
+ GetFQDN(), (long) t, (long) pid, ClientIp,
+ gmt->tm_mday, &MONTHS[3 * gmt->tm_mon], 1900 + gmt->tm_year,
+ gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
+ HDR(_xtrace) = xtracebuff ;
+ } /* pm@zetnet.net was here */
/* Now make sure everything is there. */
for (hp = Table; hp < ENDOF(Table); hp++)
@@ -837,6 +860,9 @@
hp->Size = strlen(hp->Name);
hp->Value = NULL;
}
+
+ Table[_nntpposthost].CanSet=PERMpostinghost; /* pm */
+
if ((article = StripOffHeaders(article)) == NULL)
return Error;
for (i = 0, p = article; p; i++, p = next + 1)
--
Paul Martin <pm@zetnet.net>
Technical Details
Message-ID:
<6jigoq$7on$1@roch.zetnet.co.uk>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <6jigoq$7on$1@roch.zetnet.co.uk> Subject: X-Trace backported to 1.7.2 Date: Fri, 15 May 1998 00:00:00 +0000 From: pm@zetnet.net (Paul Martin) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 353650568 Mime-Version: 1.0 NNTP-Posting-Date: 15 May 1998 22:48:58 GMT Content-Type: text/plain; charset=us-ascii X-Trace: roch.zetnet.co.uk 895272538 7959 194.247.32.3 (15 May 1998 22:48:58 GMT) Newsgroups: news.software.nntp