[news.software.nntp] Access control via wildcard domain name

esj@banana.cis.ufl.edu (Eric S. Johnson) (09/19/88)

Here is a liitle hack I put together to allow the nntp access
to be controled by wildcard domain names. 

A number of different departments on our campus read news off of one
machine (ours). I got REAL tired of having to modify the nntp_access file
every time someone on campus bought a machine.  Access control via
subnets made this a little easier, but many of our physical subnets have
machines from different departments on them. Access control by domain
name was what I needed.

The following diff allows you to put lines like:

*.cis.ufl.edu		read	post
*.math.cis.ufl.edu	read	post	!alt
*.ufnet.ufl.edu		read	post
*.circa.ufl.edu		read	post	!alt,!talk,!soc,!rec,!misc
*.ufl.edu		read	no
default			xfer	no

in your access file. 

The feature is enabled by defining DOMAINWILD in common/conf.h
The following patch is for server/access.c. NNTP version 1.5

Your gethostbyaddr routine on the server will need to 
return full domain names, and you will need to have PTR
records in your nameserver for all the hosts. (but you
should anyway eh?)


Enjoy,
Eric Johnson
<esj@ufl.edu>

*** access.c.orig	Thu Sep 15 16:29:10 1988
--- access.c	Thu Sep 15 16:08:40 1988
***************
*** 174,180 ****
--- 174,184 ----
  			groups[0] = '\0';	/* No groups specified */
  		}
  
+ #ifdef DOMAINWILD
+ 		if (wildhostmatch(hostornet,host_name)) {
+ #else
  		if (!strcasecmp(hostornet, host_name)) {
+ #endif
  			*canread = (readperm[0] == 'r' || readperm[0] == 'R');
  			*canxfer = (*canread || readperm[0] == 'X'
  					     || readperm[0] == 'x');
***************
*** 205,207 ****
--- 209,242 ----
  
  	(void) fclose(acs_fp);
  }
+ 
+ 
+ 
+ #ifdef DOMAINWILD
+ 
+ wildhostmatch(hostwild,hostname)
+ char *hostwild,*hostname;
+ {
+ 	char *i;
+ 	int dlen;
+ 
+ 	if (!strcasecmp(hostwild,hostname)) 
+ 		return (1);
+ 
+ 	if (*hostwild++ != '*')
+ 		return (0);
+ 	if (*hostwild++ != '.' )
+ 		return (0);
+ 
+ 	dlen = strlen(hostwild);
+ 
+ 	hostname += (strlen(hostname)-strlen(hostwild));
+ 
+ 	if (!strcasecmp(hostwild,hostname)) 
+ 		return (1);
+ 
+ 	return (0);
+ }
+ #endif DOMAINWILD