🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
4 messages
4 total messages Started by nico_halpern Tue, 11 May 1999 00:00
NNTP authentication, revisited (C2 sec)
#37378
Author: nico_halpern
Date: Tue, 11 May 1999 00:00
102 lines
3646 bytes
Hello,
        I recently installed inn-2.2 on a Digital UNIX v4.0b box. I have
been having problems hacking nnrpd.c trying to have it authenticate
users from /etc/passwd. nnrpd (as forked by innd) runs as the 'news'
user, and the calls to getpwnam(user) for user->pw_passwd return "*", as
expected.

        To get around this, I modified nnrpd.c as attached below. I have
tested the routine sia_validate_user() on a separate (test) program, and
it seems to work just fine, returning SIAFAIL when the user/pass don't
match.

        When I telnet to the nntp port or run nnrpd in stdin/stdout
mode, the authentication dialog is as follows:

200 news.ramapo.edu InterNetNews NNRP server INN 2.2 21-Jan-1999 ready
(posting ok).
authinfo user foo
381 PASS required
authinfo pass bar
281 Ok
quit
205 .


The problem is, when I use regular news clients to connect
(pine,netscape,etc), nnrpd returns 'bad_auth'. I have run nnrpd through
gdb, stepping line by line, but I still can't figure out what is going
wrong here.

Is the logic in the code OK? Anyone has done this before? Can someone
help? I have found little (or none) information on the FAQ, ORA's
Managing Usenet (3rd ed.) on this particular topic..

I must say, this is my first news server, and this little problem is
annoying the hell out of me. Are there any other ways of accomplishing
this?

This is what my nnrp.access looks like:
*:: -no- : -no- :!*
*:Read Post:+::*

TIA,
        -Nico Halpern.

--- nnrpd.c.original    Mon May 10 10:58:55 1999
+++ nnrpd.c     Mon May 10 11:06:22 1999
@@ -25,6 +25,9 @@
 #if HAVE_GETSPNAM
 #  include <shadow.h>
 #endif /* HAVE_GETSPNAM */
+#if HAVE_SIASEC
+#      include <sia.h>
+#endif

 /*
 ** Here is some defensive code to protect the news server from hosts,
@@ -149,6 +152,11 @@
     {  NULL }
 };

+#if HAVE_SIASEC
+int argc_sec = 0;
+char ** argv_sec = NULL;
+#endif
+

 /*
 **  Log a summary status message and exit.
@@ -480,8 +488,11 @@
            if ((spwd = getspnam(user)) != NULL)
                pwd->pw_passwd = spwd->sp_pwdp;
 #endif
-           if (!EQ(pwd->pw_passwd, crypt(pass, pwd->pw_passwd)))
+#if HAVE_SIASEC
+               if (sia_validate_user(NULL, argc_sec, argv_sec, NULL,
user,
+                                         NULL, 1, NULL, pass)==SIAFAIL)
                continue;
+#endif
        } else {
            /* Matching for a specific user or just the host? */
            if (user && (!EQ(user, fields[2]) || !EQ(pass, fields[3])))
@@ -784,6 +795,11 @@
     struct group       *grp;
     GID_T              shadowgid;
 #endif /* HAVE_GETSPNAM */
+
+#if HAVE_SIASEC
+       argc_sec = argc;
+       argv_sec = argv;
+#endif

 #if    !defined(HPUX)
     /* Save start and extent of argv for TITLEset. */



--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---

Re: NNTP authentication, revisited (C2 sec)
#37356
Author: Russ Allbery
Date: Mon, 10 May 1999 00:00
56 lines
2645 bytes
nico halpern <nico_halpern@my-dejanews.com> writes:

> I recently installed inn-2.2 on a Digital UNIX v4.0b box. I have been
> having problems hacking nnrpd.c trying to have it authenticate users
> from /etc/passwd. nnrpd (as forked by innd) runs as the 'news' user, and
> the calls to getpwnam(user) for user->pw_passwd return "*", as expected.

FYI, readers.conf in current snapshots (not STABLE) has the capabilities
required to do this in a cleaner fashion.  It can talk to an external
authentication program that can make the right OS-dependent or setup-
dependent calls to work out the authentication.

> To get around this, I modified nnrpd.c as attached below. I have tested
> the routine sia_validate_user() on a separate (test) program, and it
> seems to work just fine, returning SIAFAIL when the user/pass don't
> match.

> +#if HAVE_SIASEC
> +#      include <sia.h>
> +#endif

This should really be either:

#ifdef HAVE_SIASEC

or

#if defined(HAVE_SIASEC)

What you have may work, but I think it's unnecessarily unportable.

> +#if HAVE_SIASEC
> +               if (sia_validate_user(NULL, argc_sec, argv_sec, NULL,
> user,
> +                                         NULL, 1, NULL, pass)==SIAFAIL)
>                 continue;
> +#endif

The problem with doing this is that if there's any other sort of error,
you've lost it.  You're only checking SIAFAIL.  You really want to save
the return code of sia_validate_user() and make sure it succeeded.

Are you running nnrpd as root when you run it by hand?  Does
sia_validate_user() work for any user or only for root?  (I don't know
much about the facility that you're using.)

Something else to try, just to make sure, is comment out your
sia_validate_user() call so that that section always succeeds and it
thinks authentication always worked.  Then try connecting with a client
and see if you still get that error message.  That will determine if the
call to sia_validate_user() is the problem or not.

-- 
Russ Allbery (rra@stanford.edu)         <URL:http://www.eyrie.org/~eagle/>

Re: NNTP authentication, revisited (C2 sec)
#37371
Author: Doug S
Date: Tue, 11 May 1999 00:00
119 lines
3978 bytes
When I had to configure authentication into my news-server, I had the
complication that the news-server is on a different subnet than the
machine with the password files, and we don't use NIS.

I borrowed a trick from DNews and wrote a program that can check the
password via POP3. Source is attached, although I admit up-front that I
did not put a lot of scrutiny into handling things like buffer
overflows, interrupted reads, etc. It works for me.

/* this program accepts a user and password (on separate lines) from stdin
and checks the pop server to see if the ID is correct - DMS */
#include <stdio.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <netdb.h>
#define POPSERVER "cc.ysu.edu"
/* we "should" use "getservbyname" to get this, but it won't move... */
#define POPPORT 110
#define BUFSIZE 128
int debug;
main(argc, argv)
int argc;
char *argv[];
{
struct sockaddr_in sa;
struct hostent *hp;
int s;
char user[BUFSIZE], pass[BUFSIZE], works[BUFSIZE], resp[BUFSIZE];
debug = 0;
if (strcmp(argv[1], "-d") == 0) debug = 1;
/* set up socket */
hp = gethostbyname(POPSERVER);
if (hp == NULL) {
   fprintf(stderr,"DNS failure for %s\n",POPSERVER);
   exit(1);
   }
bzero(&sa,sizeof(struct sockaddr_in));
bcopy(hp->h_addr,(char *)&sa.sin_addr,hp->h_length); 
sa.sin_family = hp->h_addrtype;
sa.sin_port = htons(POPPORT);
if ((s = socket(AF_INET, SOCK_STREAM,0)) < 0) {
   fprintf(stderr,"socket create error\n");
   exit(2);
   }
if (connect(s, &sa, sizeof sa) < 0) {
   fprintf(stderr,"connect error\n");
   close(s);
   exit(3);
   }
/* get user and password from stdin so it won't show up in "ps" */
gets(user);
gets(pass);
/* read initial welcome */
if (debug) fprintf(stderr,"waiting for welcome banner\n");
read_data(s,resp,BUFSIZE);
if (debug) fprintf(stderr,"welcome: %s",resp);
if (resp[0] == "-") {
   quit_conn(s,resp);
   exit(4);
   }
/* send the "user" string */
sprintf(works,"user %s\n",user);
if (debug) fprintf(stderr,"sending %s",works);
write(s,works,strlen(works));
read_data(s,resp,BUFSIZE);
if (debug) fprintf(stderr,"response: %s",resp);
if (resp[0] == "-") {
   quit_conn(s,resp);
   exit(4);
   }
/* send the "pass" string */
sprintf(works,"pass %s\n",pass);
if (debug) fprintf(stderr,"sending %s",works);
write(s,works,strlen(works));
read_data(s,resp,BUFSIZE);
if (debug) fprintf(stderr,"response: %s", resp);
if (resp[0] == '-') {
   quit_conn(s,resp);
   if (debug) fprintf(stderr,"bad password\n");
   exit(100);
   }
/* close up shop */
if (debug) fprintf(stderr,"password ok\n");
quit_conn(s,resp);
exit(0);
}
/* I really *should* loop in this function in case read() gets interrupted,
but since we're only dealing with short strings - under 80 chars - big deal */
int read_data(s, buf, n)
int s;
char *buf;
int n;
{
int br;
br = read(s,buf,n);
if (br == (BUFSIZE)) buf[BUFSIZE-1] = 0;
else buf[br] = 0;
return(br);
}
int quit_conn(s,resp)
int s;
char *resp;
{
char quit[6];
sprintf(quit,"quit\n");
if (debug) fprintf(stderr,"sending quit\n");
write(s,quit,5);
read_data(s,resp,BUFSIZE);  /* quit response */
if (debug) fprintf(stderr,"connection closed\n");
close(s);
}
-- 
Doug S. (doug@cc.ysu.edu) (http://cc.ysu.edu/~doug/)

The shadow of a dog never bit anyone -- Kenneth Copeland

Re: NNTP authentication, revisited (C2 sec)
#37382
Author: Brad Knowles
Date: Tue, 11 May 1999 00:00
18 lines
1537 bytes
In article <7h7u9l$t3v$1@nnrp1.deja.com>, nico_halpern@my-dejanews.com wrote:

>         I recently installed inn-2.2 on a Digital UNIX v4.0b box.

    Note that Digital Unix/Tru64 4.0B is not Y2k compliant.  You might as
well replace/upgrade that machine now, before that news server goes into
production.  I believe that 4.0D is the earliest version they have that is
Y2k compliant, but if you're going to be making the upgrade you might as
well go for 4.0E or even 4.0F (if it's out yet).

-- 
Brad Knowles <brad@shub-internet.org> <http://www.shub-internet.org/brad/>
    <http://wwwkeys.pgp.net:11371/pks/lookup?op=get&search=0xE38CCEF1>

Are you looking for a news feed from a site in the Freenix Top 130?
If so, contact me via private e-mail for details.

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