Xref: utzoo news.software.nntp:699 comp.sources.bugs:2446 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!bcm!lib!lib.tmc.edu From: nntp@lib.tmc.edu (Stan Barber) Newsgroups: news.software.nntp,comp.sources.bugs Subject: NNTP 1.5.9 (postauth.c) Message-ID: <4036@lib.tmc.edu> Date: 13 Jul 90 01:40:37 GMT Sender: sob@lib.tmc.edu Followup-To: poster Organization: Texas Medical Center, Houston Lines: 81 Here is postauth.c....sorry it was left out. The patch files on bcm.tmc.edu will be updated to include this, but they will not be reposted. --------------------------------------------------------------------------- /* * postauth: do authorization handshake when posting requires it. * Originally by Brian Kantor. Some modifications by Stan Barber. */ #ifndef lint static char * rcsid = "$Header: postauth.c,v 1.2 90/07/08 01:00:05 sob Exp $"; #endif #include #include "../common/conf.h" #include "../common/nntp.h" #ifdef AUTH extern FILE *passfile; postauth(host) char *host; { char remote[64], user[16], pass[16]; char buf[1024]; int i; if (passfile == NULL) { fprintf(stderr,"Posting is not allowed from this system.\n"); exit(1); } while(fgets(buf, sizeof(buf), passfile)) { if (buf[0] == '#') continue; i = sscanf(buf,"%s %s %s", remote, user, pass); /* malformed entry? */ if (i != 3) { fprintf(stderr,"Posting Authorization Denied. File format error.\n"); continue; } /* right host? */ if (!strcasecmp(remote,host)) break; } if (feof(passfile)) { fprintf(stderr,"Posting to %s is not allowed from this system\n", host); exit(1); } sprintf(buf,"authinfo user %s", user); if (converse(buf, sizeof(buf)) != NEED_AUTHDATA) { fprintf(stderr,"%s\n", buf); exit(1); } sprintf(buf,"authinfo pass %s", pass); if (converse(buf, sizeof(buf)) != OK_AUTH) { fprintf(stderr,"%s\n", buf); exit(1); } fclose(passfile); } int converse(buf,buflen) char *buf; int buflen; { put_server(buf,buflen); get_server(buf,buflen); return(atoi(buf)); } #endif AUTH