Article View: news.software.nntp
Article #67756Re: [mutt-nntp/NNTPPost] Replacement with authentification (long)
From: Jeffrey M. Vinocur
Date: Sat, 24 Jan 2004 19:34
Date: Sat, 24 Jan 2004 19:34
102 lines
3840 bytes
3840 bytes
[ CC'ing to NNTPPost authors in case they want to incorporate
this path, which provides authentication support ]
In article <20040124184513.GC5906@hvk.local>,
Andre Berger <andre.berger@web.de> wrote:
>* Jeffrey M. Vinocur <jeff@litech.org>, 2004-01-24 19:15 +0100:
>
>> I think any decent inews (maybe the one that comes with trn)
>> should suffice, although you might have to wrap a little script
>> around it to get the syntax to match exactly if that's necessary
>
>Isn't inews a server, and very hard to set up? Excuse my ignorance
>please, I don't really want to run a news server if I can avoid it.
Nope, inews is a utility for posting articles to a news server.
>> Alternatively, it probably wouldn't be too hard to patch
>> NNTPPost.
>
>Want to give it a try? That would be very nice, since I am by no
>means a programmer...
Oh, ok.
Here's a patch...minimally tested...should work.
--- NNTPPost-orig.c Sat Jan 24 14:12:57 2004
+++ NNTPPost.c Sat Jan 24 14:32:08 2004
@@ -76,7 +76,7 @@
}
static int
-nntp_open (char *nntp_host, int nntp_port)
+nntp_open (char *nntp_host, int nntp_port, char *user, char *pass)
{
struct sockaddr_in sin;
struct hostent *he;
@@ -118,6 +118,22 @@
if (atol (buf) != 200)
return (-1);
+
+ if (user)
+ {
+ s_printf (sd, "AUTHINFO USER %s\r\n", user);
+ s_gets (sd, buf, sizeof (buf));
+ if (atol (buf) == 381)
+ {
+ s_printf (sd, "AUTHINFO PASS %s\r\n", pass);
+ s_gets (sd, buf, sizeof (buf));
+ }
+ if (atol (buf) != 281) {
+ printf ("Authentication failed.\n");
+ return (-1);
+ }
+ }
+
return (sd);
}
@@ -227,10 +243,11 @@
char *str;
int port;
FILE *src;
+ char *pass;
- if (argc < 3)
+ if (argc < 3 || argc > 4)
{
- printf("usage: %s <spool_file> <nntp_host[:nntp_port]>\n", argv[0]);
+ printf("usage: %s <spool_file> <nntp_host[:nntp_port]> [<user>:<pass>]\n", argv[0]);
exit (20);
}
str = strchr (argv[2], ':'); // get the port number
@@ -243,7 +260,19 @@
else
port = 119; // if not given then use default
- sd = nntp_open (argv[2], port);
+ if (argc > 3)
+ {
+ str = strchr (argv[3], ':'); // get password
+ if (str)
+ {
+ pass = str + 1;
+ *str = 0;
+ }
+ else
+ pass = "";
+ }
+
+ sd = nntp_open (argv[2], port, argv[3], pass);
if (sd < 0)
{
printf ("Unable to connect to host\n");
--
Jeffrey M. Vinocur
jeff@litech.org
Technical Details
Message-ID:
<buuhcl$v14$1@puck.litech.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!intern1.nntp.aus1.giganews.com!internal1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!border1.nntp.ash.giganews.com!nntp.giganews.com!newshosting.com!news-xfer1.atl.newshosting.com!news.glorb.com!cox.net!news-xfer.cox.net!news.litech.org!not-for-mailReferences:
<20040124085405.GA1794@hvk.local> <buu51v$hcf$2@puck.litech.org> <20040124184513.GC5906@hvk.local>Show Full Headers
Complete Article Headers
Message-ID: <buuhcl$v14$1@puck.litech.org> Subject: Re: [mutt-nntp/NNTPPost] Replacement with authentification (long) Date: Sat, 24 Jan 2004 19:34:45 +0000 From: jeff@litech.org (Jeffrey M. Vinocur) References: <20040124085405.GA1794@hvk.local> <buu51v$hcf$2@puck.litech.org> <20040124184513.GC5906@hvk.local> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!intern1.nntp.aus1.giganews.com!internal1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!border1.nntp.ash.giganews.com!nntp.giganews.com!newshosting.com!news-xfer1.atl.newshosting.com!news.glorb.com!cox.net!news-xfer.cox.net!news.litech.org!not-for-mail Newsgroups: news.software.nntp,news.software.readers Organization: Litech Systems Design Lines: 102 Sender: jeff@litech.org NNTP-Posting-Host: puck.litech.org X-Trace: puck.litech.org 1074972885 31780 66.218.0.75 (24 Jan 2004 19:34:45 GMT) X-Complaints-To: usenet@litech.org NNTP-Posting-Date: Sat, 24 Jan 2004 19:34:45 +0000 (UTC) X-Newsreader: trn 4.0-test76 (Apr 2, 2001) Originator: jeff@litech.org (Jeffrey M. Vinocur)