🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #18831

Re: virtual news hosting??

#18831
From: Sven Paulus
Date: Sat, 28 Jun 1997 00:00
125 lines
4647 bytes
Forrest J. Cavalier III <mibsoft@epix.net> wrote:
>>I'm looking for news software that easily support "virtual news hosting".
 FJ CI> - You need to apply a patch to bind to only a single IP address.
 FJ CI> - Unless you can have it work with chroot, you have to
 FJ CI> compile a version for each IP address, because the location of
 FJ CI> the spool and configuration files are INN compile-time options.

This is not the easy solution: Since he doesn't want the newsgroups to be
feeded to other servers, just one INN is needed.

I think it would be about half an hour of work to enhance nnrpd.c to do a
getsockname() and instead of getting the "accesslist" (a comma-delimited
list of newsgroups patterns, to which the user has access) in PERMinfile()
to read it from a different file which lists the ip addresses and available
newsgroups ("192.168.0.1 mickeysoft.*,general.*").

Ok, just for fun I did this patch: It introduces a new file
/etc/news/groupaccess in the format mentioned above. Just add an entry
"*:Read Post:::!*" to nnrpd.access to allow global access and a line for
each of your virtual IP addresses listing the available newsgroup pattern in
/etc/news/groupaccess. It's completely untested, but it should work.

--- nnrpd-orig/nnrpd.c	Tue Jan 14 15:07:54 1997
+++ nnrpd-virtual/nnrpd.c	Sat Jun 28 13:43:30 1997
@@ -301,6 +301,38 @@
 }
 #endif	/* defined(DO_NNRP_GETHOSTBYADDR) */
 
+void
+PERMadd(addr, accesslist)
+    char 		*addr;
+    char		*accesslist;
+{
+    register FILE	*F;
+    char		*chr1, *chr2;
+    char		buff[BIG_BUFFER];
+
+    if (!*accesslist)
+	return;
+
+    if ((F = fopen(VIRTACCESS, "r")) == NULL) {
+	syslog(L_ERROR, "%s cant fopen %s %m", ClientHost, VIRTACCESS);
+	return;
+    }
+    
+    while (fgets(buff, sizeof buff, F) != NULL) {
+	if (strncmp(buff, addr,	strlen(addr)))
+	    continue;
+	if ((chr1 = strpbrk(buff, " \t")) == NULL)
+	    continue;
+	while (*chr1 == ' ' || *chr1 == '\t')
+	    chr1++;
+	if ((chr2 = strpbrk(chr1, " \t")) != NULL)
+	    chr2 = '\0';
+	(void)strcat(accesslist, ",");
+	(void)strcat(accesslist, chr1);
+    }
+    
+    (void)fclose(F); 	
+}
 
 BOOL
 PERMinfile(hp, ip, user, pass, accesslist)
@@ -385,7 +417,7 @@
     struct sockaddr_in	sin;
     int			length;
     char		buff[SMBUF];
-    char		*ClientAddr;
+    char		*ClientAddr, MyAddr[20];
 
     /* Get the peer's name. */
     length = sizeof sin;
@@ -440,7 +472,21 @@
 
     strncpy (LogName,ClientHost,sizeof(LogName)-1) ;
 
-    syslog(L_NOTICE, "%s connect", ClientHost);
+    /* Get my address */
+    length = sizeof sin;
+    *MyAddr = '\0';
+    if (getsockname(STDIN, (struct sockaddr *)&sin, &length) < 0) {
+	if (!isatty(STDIN)) {
+	    syslog(L_ERROR, "%s cant getsockname %m", "?");
+	    Printf("%d I can't get my name.  Goodbye.\r\n", NNTP_ACCESS_VAL);
+	    ExitWithStats(1);
+	}
+    }
+    else if (sin.sin_family == AF_INET) {
+	(void)strcpy(MyAddr, inet_ntoa(sin.sin_addr));
+    }
+
+    syslog(L_NOTICE, "%s connect to %s", ClientHost, *MyAddr ? MyAddr: "?");
     if (!PERMinfile(ClientHost, ClientAddr, (char *)NULL, (char *)NULL,
 	    accesslist)) {
 	syslog(L_NOTICE, "%s no_access", ClientHost);
@@ -448,6 +494,7 @@
 	    NNTP_ACCESS_VAL);
 	ExitWithStats(1);
     }
+    PERMadd(MyAddr, accesslist);
 }
 
 
diff -ur nnrpd-orig/nnrpd.h nnrpd-virtual/nnrpd.h
--- nnrpd-orig/nnrpd.h	Tue Jan 14 14:47:44 1997
+++ nnrpd-virtual/nnrpd.h	Sat Jun 28 13:28:10 1997
@@ -34,6 +34,7 @@
 #define ART_LINE_LENGTH		1000
 #define ART_LINE_MALLOC		1024
 
+#define VIRTACCESS "/etc/news/groupaccess"
 
 /*
 **  Some convenient shorthands.


Sven
-- 
--Sven-Paulus----------28-48-32--3-----ub6v@rz.uni-karlsruhe.de------
--Karlstr.-55----------30--2-50-29-----sven@oops.sub.de-----3C9A6091-
--D-76133-Karlsruhe----44-49-10--8-----T#-49-721-9375094---------irc-
--Fido-2:2476/530-------9-12-19-71-----F#-49-721-9375095-----svennie-

Technical Details
Message-ID: <5p2th3$atm$1@imperator.oops.sub.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <5osu9i$f05$1@brokaw.wa.com> <5p0amp$e3a$2@news1.epix.net>

Show Full Headers
Complete Article Headers
Message-ID: <5p2th3$atm$1@imperator.oops.sub.de>
Subject: Re: virtual news hosting??
Date: Sat, 28 Jun 1997 00:00:00 +0000
From: Sven Paulus <sven@oops.sub.de>
References: <5osu9i$f05$1@brokaw.wa.com> <5p0amp$e3a$2@news1.epix.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 253176890
X-Trace: 867498339 11191 sven@imperator.oops.sub.de 192.101.75.81
Organization: clueless in Karlsruhe, Germany
Newsgroups: news.software.nntp