🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #573

NNTP 1.5.9 (postauth.c)

#573
From: Stan Barber
Date: Fri, 13 Jul 1990 01:40
82 lines
2324 bytes
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 <stdio.h>
#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
Technical Details
Message-ID: <4036@lib.tmc.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!bcm!lib!lib.tmc.edu

Show Full Headers
Complete Article Headers
Message-ID: <4036@lib.tmc.edu>
Subject: NNTP 1.5.9 (postauth.c)
Date: Fri, 13 Jul 1990 01:40:37 +0000
From: nntp@lib.tmc.edu (Stan Barber)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!bcm!lib!lib.tmc.edu
Newsgroups: news.software.nntp,comp.sources.bugs
Sender: sob@lib.tmc.edu
Followup-To: poster
Organization: Texas Medical Center, Houston
Lines: 81