🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #13455

Re: nnrpd patch for complicated access permissions ?

#13455
From: J. Porter Clark
Date: Fri, 20 Dec 1996 00:00
230 lines
7171 bytes
Note Followup-To.

jpc@drum.msfc.nasa.gov (J. Porter Clark) writes:

>jwr@ICM.EDU.PL (Jan Rychter) writes:

>>  I'm looking for a patch to nnrpd that will allow me to specify for a
>>given domain mask read/post access to a subset of groups and read only
>>access for all other groups.

>>  If it doesn't exist, I'll have to code it myself... (AFAIK nnrpd with
>>inn1.4 can't do that, I've already looked at the source).

>I have an nnrpd that allows individual entries in nnrp.access to
>specify the group access list by referencing files containing lists of
>newsgroup patterns.  Would that do?

[snip]

>If anyone's interested, I'll post my diffs to INN-1.5.1 in the
>appropriate newsgroup.  It might take me a couple of days, because I
>haven't rolled the code into 1.5.1 from 1.5 yet.

I have had some requests for this code, so here it is.  I'm not sure
that it's what you want.

This patch (to INN-1.5.1) does these things:

  1. In addition to the usual nnrp.access syntax, you can specify newsgroup
  patterns in adjunct files.  For example:

  nnrp.access:

    # In general, everybody can read everything
    *.my.domain.com:R P:::*
    # This one wants no alt
    no.alt.host.com:R P:::*,!alt.*
    # This one wants to pick and choose
    picky.host.com:R P:::@pickylist
  
  pickylist:

    # This is a comment
    *,!alt,alt.binaries.*
    !*erotica*,!*sex*

  pickylist can be extremely large if necessary and has relaxed
  syntax.  Parts of the patterns can be delimited by commas and/or
  newlines.  Comments are supported.

  Unfortunately, you cannot do something like this:

    picky2.host.com:R P:::@pickylist,!alt.*
  
  2. The Date header supplied on locally-generated posts is trampled
  upon and replaced with the server's date.  I like this.  It's a
  one-line change to post.c.

  3. You can turn on tracing on a per-host-pattern basis in nnrp.access.
  Example:

    # Turn on tracing
    odd.host.com:R P C:::*
  
  I chose the 'C' key letter because it's the only letter that is in
  the word 'trace' that is not in 'read' or 'post'.  I could have used
  a different letter.

Comments and criticism are welcome, particularly if not wrapped in
flames.  I'm not a real programmer, folks...

*** nnrpd/commands.c.orig	Tue Dec 17 08:40:40 1996
--- nnrpd/commands.c	Thu Dec 19 20:10:24 1996
***************
*** 170,175 ****
--- 170,176 ----
  
      PERMcanread = strchr(fields[1], 'R') != NULL;
      PERMcanpost = strchr(fields[1], 'P') != NULL;
+     Tracing = strchr(fields[1], 'C') != NULL;		/* jpc */
      sprintf(PERMuser, "%s@%s", fields[2], fields[0]);
      (void)strcpy(PERMpass, fields[3]);
      (void)strcpy(accesslist, fields[4]);
*** nnrpd/nnrpd.c.orig	Tue Dec 17 08:40:40 1996
--- nnrpd/nnrpd.c	Thu Dec 19 20:10:24 1996
***************
*** 59,64 ****
--- 59,67 ----
  #endif	/* !defined(HPUX) */
  STATIC SIGVAR	ChangeTrace;
  
+ STATIC char	*acclist;
+ STATIC char	*groups_from_file();
+ 
  extern FUNCTYPE	CMDauthinfo();
  extern FUNCTYPE	CMDdate();
  extern FUNCTYPE	CMDfetch();
***************
*** 365,370 ****
--- 368,374 ----
  
  	PERMcanread = strchr(fields[1], 'R') != NULL;
  	PERMcanpost = strchr(fields[1], 'P') != NULL;
+ 	Tracing = strchr(fields[1], 'C') != NULL;		/* jpc */
  	(void)strcpy(PERMuser, user ? user : fields[2]);
  	(void)strcpy(PERMpass, pass ? pass : fields[3]);
  	(void)strcpy(accesslist, fields[4]);
***************
*** 448,453 ****
--- 452,459 ----
  	    NNTP_ACCESS_VAL);
  	ExitWithStats(1);
      }
+     acclist = (*accesslist == '@') ? groups_from_file(accesslist + 1) :
+ 	accesslist;
  }
  
  
***************
*** 625,631 ****
  
      /* Proceed with initialization. */
      PERMneedauth = PERMuser[0] != '\0' && PERMpass[0] != '\0';
!     PERMspecified = NGgetlist(&PERMlist, accesslist);
      TITLEset("connect");
  
      /* Were we told to reject connections? */
--- 631,637 ----
  
      /* Proceed with initialization. */
      PERMneedauth = PERMuser[0] != '\0' && PERMpass[0] != '\0';
!     PERMspecified = NGgetlist(&PERMlist, acclist);
      TITLEset("connect");
  
      /* Were we told to reject connections? */
***************
*** 740,743 ****
--- 746,817 ----
  
      ExitWithStats(0);
      /* NOTREACHED */
+ }
+ 
+ /*
+ ** Grab access list from file.
+ ** by jpc@drum.msfc.nasa.gov
+ **
+ */
+ 
+ #define _PATH_GROUP_ACCESS	"/news/etc/nnrp.groups"
+ 
+ STATIC char *
+ groups_from_file(accesslist)
+     char		*accesslist;
+ {
+     register char	*basep = (char *) NULL;
+     register char 	*p; 
+     register int 	ncfilled = 0;
+     register int 	ncalloc;
+     register int 	c;
+     register FILE 	*gfile;
+     register int 	in_continuation = 0;
+     register int 	in_delimiter = 0;
+     char buff[BIG_BUFFER];
+ 
+     (void) sprintf(buff, "%s/%s", _PATH_GROUP_ACCESS, accesslist);
+     if ((gfile = fopen(buff, "r")) == NULL) {
+ 	*accesslist = '\0';
+ 	return(accesslist);
+     }
+     ncalloc = BIG_BUFFER;
+     basep = NEW(char, ncalloc);
+     while ((c = getc(gfile)) != EOF) {
+ 	if (c == '\n') {
+ 	    in_continuation = 0;
+ 	    in_delimiter = 1;
+ 	    continue;
+ 	}
+ 	if (in_continuation)
+ 	    continue;
+ 	if (c == '#') {
+ 	    in_continuation = 1;
+ 	    in_delimiter = 1;
+ 	    continue;
+ 	}
+ 	if (c == ',' || c == ' ' || c == '\t') {
+ 	    in_delimiter = 1;
+ 	    continue;
+ 	}
+ 	if (in_delimiter) {
+ 	    in_delimiter = 0;
+ 	    if ((ncfilled + 3) >= ncalloc) {
+ 		ncalloc += BIG_BUFFER;
+ 		basep = RENEW(basep, char, ncalloc);
+ 	    }
+ 	    if (ncfilled)
+ 		basep[ncfilled++] = ',';
+ 	    basep[ncfilled++] = c;
+ 	    continue;
+ 	}
+ 	if ((ncfilled + 3) >= ncalloc) {
+ 	    ncalloc += BIG_BUFFER;
+ 	    basep = RENEW(basep, char, ncalloc);
+ 	}
+ 	basep[ncfilled++] = c;
+     }
+     basep[ncfilled++] = '\0';
+     fclose(gfile);
+     return(basep);
  }
*** nnrpd/post.c.orig	Tue Dec 17 08:40:40 1996
--- nnrpd/post.c	Thu Dec 19 20:10:24 1996
***************
*** 301,306 ****
--- 301,308 ----
  	return Error;
      }
  
+     HDR(_date) = NULL;		/* jpc */
+ 
      if (HDR(_date) == NULL) {
  	if ((gmt = gmtime(&Now.time)) == NULL)
  	    return "Can't get the time";
-- 
J. Porter Clark    jpc@drum.msfc.nasa.gov
NASA/MSFC Flight Data Systems Branch


Technical Details
Message-ID: <59ebm9$pk7$1@drum.msfc.nasa.gov>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.admin.technical.mbox.zip!not-for-mail
References: <wsw7mmfpia9.fsf@krzak.icm.edu.pl> <59acqd$c1c$1@drum.msfc.nasa.gov>

Show Full Headers
Complete Article Headers
Message-ID: <59ebm9$pk7$1@drum.msfc.nasa.gov>
Subject: Re: nnrpd patch for complicated access permissions ?
Date: Fri, 20 Dec 1996 00:00:00 +0000
From: jpc@drum.msfc.nasa.gov (J. Porter Clark)
References: <wsw7mmfpia9.fsf@krzak.icm.edu.pl> <59acqd$c1c$1@drum.msfc.nasa.gov>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.admin.technical.mbox.zip!not-for-mail
X-Deja-AN: 205183172
Distribution: world
Sender: zorch@ftp.UU.NET
Followup-to: news.software.nntp
Organization: NASA/MSFC
Newsgroups: news.admin.technical,news.software.nntp