Thread View: news.software.nntp
6 messages
6 total messages
Started by Andre Berger
Sat, 24 Jan 2004 08:54
[mutt-nntp/NNTPPost] Replacement with authentification
Author: Andre Berger
Date: Sat, 24 Jan 2004 08:54
Date: Sat, 24 Jan 2004 08:54
26 lines
2096 bytes
2096 bytes
Hi there, I hope this is the right NG, if not please point me to it :) And please don't tell me to use slrn... I'm running mutt-nntp 1.4.1 (Orjan Stromberg's patch to the mutt email client). It comes with a very simple program, NNTPPost, which does what you expect but doesn't support authenification. Subsequently, I can't use mutt-nntp off-line. andre@hvk:~$ NNTPPost usage: NNTPPost <spool_file> <nntp_host[:nntp_port]> Unfortunately, I need to authentify against my mail server. Could you think of any drop-in replacement for NNTPPost? My .newsrc looks like this: [server user pass] comp.mail.mutt 18728 =nntp.comp.mail.mutt 0 news.software.nntp 120002 =nntp.news.software.nntp 0 Any suggestions here? TIA -Andre
Re: [mutt-nntp/NNTPPost] Replacement with authentification
Author: Jeffrey M. Vinocur
Date: Sat, 24 Jan 2004 16:04
Date: Sat, 24 Jan 2004 16:04
31 lines
2268 bytes
2268 bytes
In article <20040124085405.GA1794@hvk.local>, Andre Berger <andre.berger@web.de> wrote: > >I hope this is the right NG, if not please point me to it :) I think news.software.readers is better, crossposting there. >I'm running mutt-nntp 1.4.1 (Orjan Stromberg's patch to the mutt >email client). It comes with a very simple program, NNTPPost, which >does what you expect but doesn't support authenification. >Subsequently, I can't use mutt-nntp off-line. > >andre@hvk:~$ NNTPPost >usage: NNTPPost <spool_file> <nntp_host[:nntp_port]> > >Unfortunately, I need to authentify against my mail server. Could you >think of any drop-in replacement for NNTPPost? 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 (I don't use mutt, so I don't know). Alternatively, it probably wouldn't be too hard to patch NNTPPost. -- Jeffrey M. Vinocur jeff@litech.org
Re: [mutt-nntp/NNTPPost] Replacement with authentification (long)
Author: Andre Berger
Date: Sat, 24 Jan 2004 18:45
Date: Sat, 24 Jan 2004 18:45
307 lines
7892 bytes
7892 bytes
* Jeffrey M. Vinocur <jeff@litech.org>, 2004-01-24 19:15 +0100:
> In article <20040124085405.GA1794@hvk.local>,
> Andre Berger <andre.berger@web.de> wrote:
> >
> >I hope this is the right NG, if not please point me to it :)
>
> I think news.software.readers is better, crossposting there.
Thanks!
> >I'm running mutt-nntp 1.4.1 (Orjan Stromberg's patch to the mutt
> >email client). It comes with a very simple program, NNTPPost, which
> >does what you expect but doesn't support authenification.
> >Subsequently, I can't use mutt-nntp off-line.
> >
> >andre@hvk:~$ NNTPPost
> >usage: NNTPPost <spool_file> <nntp_host[:nntp_port]>
> >
> >Unfortunately, I need to authentify against my mail server. Could you
^^^^
news (of course)
> >think of any drop-in replacement for NNTPPost?
>
> 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
> (I don't use mutt, so I don't know).
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.
Or wait, maybe noffle if I can compile it (Mac OS X 10.3 Panther), I
used it on Debian/i386 and was very happy with it. Has anyone here
succeeded compiling noffle for OS X/fink?
> 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...
nntppost.c comes here (264 lines):
/*
* Very simple NNTP poster implementation, should be sufficent...
* In case of bugs write to: kbryd@albedo.art.pl
*
* Byte-stuffing added by Orjan Stromberg, might as well send bug-reports
* to me instead, if you have this package. :) <connor@ing.umu.se>
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
static int sd = -1;
// ripped from pop.c
static int
s_gets (int fd, char *s, int len)
{
char ch;
int bytes = 0;
while (read (fd, &ch, 1) > 0)
{
*s++ = ch;
bytes++;
if (ch == '\n')
{
*s = 0;
return (bytes);
}
/* make sure not to overwrite the buffer */
if (bytes == len - 1)
{
*s = 0;
return bytes;
}
}
*s = 0;
return (-1);
}
static int
s_puts (const char *str, int fd)
{
int ret;
ret = send (fd, (char *) str, strlen (str), 0);
if (ret < 0)
return (ret);
return (0);
}
static int
s_printf (int sd, const char *format,...)
{
va_list ap;
int ret;
char buf[1024];
va_start (ap, format);
ret = vsprintf (buf, format, ap);
s_puts (buf, sd);
va_end (ap);
return ret;
}
static int
nntp_open (char *nntp_host, int nntp_port)
{
struct sockaddr_in sin;
struct hostent *he;
int sd, n;
char buf[255];
sd = socket (AF_INET, SOCK_STREAM, IPPROTO_IP);
memset ((char *) &sin, 0, sizeof (sin));
sin.sin_family = AF_INET;
sin.sin_port = htons (nntp_port);
if ((n = inet_addr (nntp_host)) == -1)
{
/* Must be a DNS name */
if ((he = gethostbyname (nntp_host)) == NULL)
{
printf ("Could not find address for host %s.\n", nntp_host);
return (-1);
}
memcpy ((void *) &sin.sin_addr, *(he->h_addr_list), he->h_length);
}
else
memcpy ((void *) &sin.sin_addr, (void *) &n, sizeof (n));
printf ("Connecting to %s\n", inet_ntoa (sin.sin_addr));
if (connect (sd, (struct sockaddr *) &sin, sizeof (struct sockaddr_in)) == -1)
{
perror ("connect");
return (-1);
}
s_gets (sd, buf, sizeof (buf));
s_printf (sd, "MODE READER\r\n");
s_gets (sd, buf, sizeof (buf));
if (atol (buf) != 200)
return (-1);
return (sd);
}
static void
nntp_close (int sd)
{
s_printf (sd, "QUIT\r\n");
close (sd);
}
static char *
striprc (char *s)
{
char *lfrc;
lfrc = strchr (s, '\r');
if (!lfrc)
lfrc = strchr (s, '\n');
if (lfrc)
*lfrc = 0;
return (s);
}
int
mutt_post_article (char *filename)
{
char *line;
FILE *fp;
s_printf (sd, "POST\r\n");
line = (char *) malloc (4096);
s_gets (sd, line, 4096);
if (atol (line) != 340)
{
printf ("Posting not allowed\n");
nntp_close (sd);
free (line);
return (0);
}
fp = fopen (filename, "r");
if (!fp)
return (-1);
while (fgets (line, 4096, fp))
{
if (line[0] == '.')
s_printf (sd, ".%s\r\n", striprc (line));
else
s_printf (sd, "%s\r\n", striprc (line));
}
s_puts (".\r\n", sd);
s_gets (sd, line, 4096);
printf(line);
free (line);
return (0);
}
void
process_mailbox (FILE * src)
{
char buf[1024];
int a = 0;
FILE *dest;
while (a != 1000)
{
for (a = 0; a < 800; a++)
{
if (!(fgets (buf, sizeof (buf), src)))
{
a = 999;
break;
}
dest = fopen ("letter.tmp", "w+");
// fputs (buf, dest);
while (1)
{
if (!(fgets (buf, sizeof (buf), src)))
{
a = 999;
break;
}
if ((strncasecmp (buf, "From ", 5) == 0))
break;
fputs (buf, dest);
}
fseek (src, -strlen (buf), SEEK_CUR);
fclose (dest);
mutt_post_article ("letter.tmp");
unlink ("letter.tmp");
}
}
}
int
main (int argc, char **argv)
{
char *str;
int port;
FILE *src;
if (argc < 3)
{
printf("usage: %s <spool_file> <nntp_host[:nntp_port]>\n", argv[0]);
exit (20);
}
str = strchr (argv[2], ':'); // get the port number
if (str)
{
port = atoi (str + 1);
*str = 0;
}
else
port = 119; // if not given then use default
sd = nntp_open (argv[2], port);
if (sd < 0)
{
printf ("Unable to connect to host\n");
return (0);
}
src = fopen (argv[1], "r");
if (src)
{
process_mailbox (src);
fclose (src);
}
nntp_close (sd);
return 0;
}
Re: [mutt-nntp/NNTPPost] Replacement with authentification (long)
Author: 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
Re: [mutt-nntp/NNTPPost] Replacement with authentification (long)
Author: J.B. Moreno
Date: Sat, 24 Jan 2004 20:18
Date: Sat, 24 Jan 2004 20:18
51 lines
2390 bytes
2390 bytes
Andre Berger <andre.berger@web.de> wrote: > * Jeffrey M. Vinocur <jeff@litech.org>, 2004-01-24 19:15 +0100: -snip need to authenticate- > > 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... > nntppost.c comes here (264 lines): -snip- > s_printf (sd, "MODE READER\r\n"); > > s_gets (sd, buf, sizeof (buf)); > > if (atol (buf) != 200) > return (-1); > return (sd); > } Basically you want to add: s_printf (sd, "authinfo user USERNAME\r\n"); s_printf (sd, "authinfo pass PASSWORD\r\n"); and some error checking between "return (-1);" and the "return(sd);", do you have enough programming experience to do the error checking? Here's a transcript of my logging and authenticating into a couple of servers I use... 200 tango - NewsReader.Com NNTP Server (authentication required) authinfo user XXXXX 381 PASS required authinfo pass ZZZZZ 281 Ok quit 205 Bye! 200 The server welcomes dns-info. Authorization required for... authinfo user XXXX 381 PASS required authinfo pass ZZZZ 281 Authentication accepted. (UID=#####) quit 205 . -- JBM "Everything is futile." -- Marvin of Borg
Re: [mutt-nntp/NNTPPost] Replacement with authentification (long)
Author: Andre Berger
Date: Sat, 24 Jan 2004 21:31
Date: Sat, 24 Jan 2004 21:31
36 lines
2673 bytes
2673 bytes
* Jeffrey M. Vinocur <jeff@litech.org>, 2004-01-24 20:41 +0100: > [ 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. [snip patch] If you can read this, it works! THANK YOU VERY MUCH -Andre
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads