Article View: news.software.nntp
Article #50799Re: Authentication
From: Paul Tomblin
Date: Sat, 24 Feb 2001 03:26
Date: Sat, 24 Feb 2001 03:26
237 lines
8142 bytes
8142 bytes
In a previous article, "Brad" <flyboy@optushome.com.au> said:
>Is it possible to have INN ask for user/pass and then post as the username
>described in the username field, rather than what the person has in their
>news client?
I have a patch to nnrpd for inn 2.2.2 that can do that. The perl
authentication code returns a 5th argument, the full name to use in the
post, and then the user's given "From" is renamed to be a "X-Given-From"
and the userid and full name (and innconf->fromhost) used to construct a
new "From" header.
diff -rwbc ../inn-2.2.2.orig/innd/status.c ./innd/status.c
*** ../inn-2.2.2.orig/innd/status.c Mon Dec 13 08:18:37 1999
--- ./innd/status.c Fri Dec 17 22:57:01 1999
***************
*** 16,22 ****
--- 16,26 ----
#define MAX_PEER 100
#define MIN_REFRESH 60 /* 1 min */
#define HTML_STATUS
+ #if defined(HTML_STATUS)
+ #define STATUS_FILE "inn_status.html" /* will be in pathlog/pathhttp */
+ #else
#define STATUS_FILE "inn.status" /* will be in pathlog/pathhttp */
+ #endif
typedef struct _STATUS {
char name[SMBUF];
diff -rwbc ../inn-2.2.2.orig/nnrpd/nnrpd.c ./nnrpd/nnrpd.c
*** ../inn-2.2.2.orig/nnrpd/nnrpd.c Mon Dec 13 08:18:37 1999
--- ./nnrpd/nnrpd.c Fri Dec 17 22:58:51 1999
***************
*** 35,41 ****
** will have the standard timeout of CLIENT_TIMEOUT seconds.
*/
#if !defined(INITIAL_TIMEOUT)
! #define INITIAL_TIMEOUT 10
#endif
#define MAXPATTERNDEFINE 10
--- 35,41 ----
** will have the standard timeout of CLIENT_TIMEOUT seconds.
*/
#if !defined(INITIAL_TIMEOUT)
! #define INITIAL_TIMEOUT 60
#endif
#define MAXPATTERNDEFINE 10
Only in ./nnrpd: nnrpd.c.orig
diff -rwbc ../inn-2.2.2.orig/nnrpd/nnrpd.h ./nnrpd/nnrpd.h
*** ../inn-2.2.2.orig/nnrpd/nnrpd.h Mon Dec 13 08:18:37 1999
--- ./nnrpd/nnrpd.h Fri Dec 17 22:57:01 1999
***************
*** 153,158 ****
--- 153,168 ----
EXTERN BOOL BACKOFFenabled;
EXTERN long ClientIP;
+ /**
+ NCF_FROM_MANGLE, if defined, allows you to add another return argument
+ from the perl authentication module - if you return it, it's used as the
+ full name of the poster, and any "From:" header that they supply will be
+ replaced with one with the proper userid and fullname
+ */
+ #define NCF_FROM_MANGLE
+ #ifdef NCF_FROM_MANGLE
+ EXTERN char* fullName;
+ #endif
#if NNRP_LOADLIMIT > 0
extern int GetLoadAverage();
diff -rwbc ../inn-2.2.2.orig/nnrpd/perl.c ./nnrpd/perl.c
*** ../inn-2.2.2.orig/nnrpd/perl.c Mon Dec 13 08:18:37 1999
--- ./nnrpd/perl.c Fri Dec 17 22:57:01 1999
***************
*** 316,327 ****
ExitWithStats(1);
}
! if (rc != 4) {
syslog(L_ERROR, "Perl function authenticate returned wrong number of results: %d", rc);
Reply("%d Internal Error (2). Goodbye\r\n", NNTP_ACCESS_VAL);
ExitWithStats(1);
}
p = POPp;
strcpy(accesslist, p);
sv = POPs; PERMcanpost = SvTRUE(sv);
--- 316,341 ----
ExitWithStats(1);
}
! #ifdef NCF_FROM_MANGLE
! if (rc < 4 || rc > 5)
! #else
! if (rc != 4)
! #endif
! {
syslog(L_ERROR, "Perl function authenticate returned wrong number of results: %d", rc);
Reply("%d Internal Error (2). Goodbye\r\n", NNTP_ACCESS_VAL);
ExitWithStats(1);
}
+ #ifdef NCF_FROM_MANGLE
+ if (fullName)
+ free(fullName);
+ if (rc == 5)
+ {
+ p = POPp;
+ fullName = strdup(p);
+ }
+ #endif
p = POPp;
strcpy(accesslist, p);
sv = POPs; PERMcanpost = SvTRUE(sv);
Only in ./nnrpd: perl.c.orig
diff -rwbc ../inn-2.2.2.orig/nnrpd/post.c ./nnrpd/post.c
*** ../inn-2.2.2.orig/nnrpd/post.c Mon Dec 13 08:18:37 1999
--- ./nnrpd/post.c Fri Dec 17 22:57:01 1999
***************
*** 335,340 ****
--- 335,344 ----
static char mimeversion[SMBUF];
static char mimetype[SMBUF];
static char mimeencoding[SMBUF];
+ #if defined(NCF_FROM_MANGLE)
+ static char xgivenfrom[SMBUF];
+ static char xgivensender[SMBUF];
+ #endif
register HEADER *hp;
register char *p;
time_t t;
***************
*** 342,347 ****
--- 346,354 ----
TIMEINFO Now;
STRING error;
pid_t pid;
+ #if defined(NCF_FROM_MANGLE)
+ char *sender;
+ #endif
/* Do some preliminary fix-ups. */
for (hp = Table; hp < ENDOF(Table); hp++) {
***************
*** 357,362 ****
--- 364,437 ----
}
#if defined(DO_NNRP_AUTH_SENDER)
+ #if defined(NCF_FROM_MANGLE)
+ /*
+ If authorized, we throw away any given Sender and From lines, and use
+ the authorized user in both.
+ */
+ sender = HDR(_sender);
+ if (sender != NULL)
+ {
+ /* Make an X-Given-Sender out of the old Sender */
+ strcpy(xgivensender, "X-Given-Sender: ");
+ strncat(xgivensender, sender, SMBUF-16);
+ xgivensender[SMBUF-1] = '\0'; /* make sure it's null terminated */
+
+ if (OtherCount >= OtherSize - 1) {
+ OtherSize += HEADER_DELTA;
+ RENEW(OtherHeaders, char*, OtherSize);
+ }
+ OtherHeaders[OtherCount++] = xgivensender;
+ }
+ HDR(_sender) = NULL;
+ if (PERMauthorized)
+ {
+ int i;
+ char *p;
+ strcpy(sendbuff, PERMuser[0] ? PERMuser : "UNKNOWN");
+ i = strlen(sendbuff);
+ strcat(sendbuff, "@");
+ if ((p = innconf->fromhost) != NULL)
+ strncat(sendbuff, p, SMBUF-i-1);
+ else
+ strncat(sendbuff, ClientHost, SMBUF-i-1);
+ sendbuff[SMBUF-1] = '\0'; /* make sure it's null terminated */
+ if (fullName)
+ {
+ i = strlen(sendbuff);
+ if (i < SMBUF-3)
+ {
+ strcat(sendbuff, " (");
+ strncat(sendbuff, fullName, SMBUF-i-4);
+ strcat(sendbuff, ")");
+ }
+ }
+
+ HDR(_sender) = sendbuff;
+
+ /* Don't mangle the From line if it's been approved by the
+ * moderator.
+ */
+ if (HDR(_approved) == NULL)
+ {
+ char* from = HDR(_from);
+ if (from != NULL)
+ {
+ /* Make an X-Given-From out of the old From */
+ strcpy(xgivenfrom, "X-Given-From: ");
+ strncat(xgivenfrom, from, SMBUF-16);
+ xgivenfrom[SMBUF-1] = '\0'; /* make sure it's null terminated */
+
+ if (OtherCount >= OtherSize - 1) {
+ OtherSize += HEADER_DELTA;
+ RENEW(OtherHeaders, char*, OtherSize);
+ }
+ OtherHeaders[OtherCount++] = xgivenfrom;
+ }
+ HDR(_from) = sendbuff;
+ }
+ }
+ #else
/* If authorized and we didn't get a sender, add the header based on
* our info. If not authorized, zap the Sender so we don't put out
* unauthenticated data. */
***************
*** 367,372 ****
--- 442,448 ----
}
else if (!PERMauthorized)
HDR(_sender) = NULL;
+ #endif /* defined(NCF_FROM_MANGLE) */
#endif /* defined(DO_NNRP_AUTH_SENDER) */
/* Set Date. */
--
Paul Tomblin <ptomblin@xcski.com>, not speaking for anybody
Any sufficiently advanced technology is indistinguishable from magic.
-- Arthur C. Clarke
Technical Details
Message-ID:
<9779l2$rt3$1@allhats.xcski.com>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!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.stanford.edu!news.kjsl.com!xcski.com!not-for-mailReferences:
<nzFl6.420$p5.1817@news1.rivrw1.nsw.optushome.com.au>Show Full Headers
Complete Article Headers
Message-ID: <9779l2$rt3$1@allhats.xcski.com> Subject: Re: Authentication Date: Sat, 24 Feb 2001 03:26:26 +0000 From: ptomblin@xcski.com (Paul Tomblin) References: <nzFl6.420$p5.1817@news1.rivrw1.nsw.optushome.com.au> 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!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!newsfeed.stanford.edu!news.kjsl.com!xcski.com!not-for-mail Newsgroups: news.software.nntp Organization: Tomblin Computer Consulting, Rochester, New York and Ottawa, Ontario Lines: 236 Reply-To: ptomblin@xcski.com (Paul Tomblin) NNTP-Posting-Host: allhats.xcski.com X-Trace: allhats.xcski.com 982985186 28579 192.168.1.1 (24 Feb 2001 03:26:26 GMT) X-Complaints-To: abuse@xcski.com NNTP-Posting-Date: 24 Feb 2001 03:26:26 GMT X-Newsreader: trn 4.0-test70 (17 January 1999) Originator: ptomblin@xcski.com (Paul Tomblin)