Thread View: news.software.nntp
1 messages
1 total messages
Started by Murray S. Kucherawy
Wed, 11 Dec 1996 00:00
Patch to nnrpd to allow netmasks in nnrp.access
Author: Murray S. Kucherawy
Date: Wed, 11 Dec 1996 00:00
Date: Wed, 11 Dec 1996 00:00
102 lines
4089 bytes
4089 bytes
The following patch will allow you to do a netmask in your nnrp.access
file so that you can offer news access to pieces of what are commonly
known as subnetted class Cs. For example, you can currently do this:
165.154.*:RP:::*,!clari*
...or this:
165.154.1.*:RP:::*,!clari*
...but you can't get any more specific than that with wildcards in any
reasonable fashion. If you split this network at a bit boundary beyond
24 bits, you start to require multiple lines to do the trick. With
this patch, you can do this:
165.154.1.0/255.255.255.224:RP:::*,!clari*
...or this:
165.154.1.0/27:RP:::*,!clari*
It's worked for me so far. Let me know if you have any problems with it.
*** nnrpd.c 1996/11/19 19:59:00 1.2
--- nnrpd.c 1996/12/11 01:03:29
***************
*** 347,357 ****
/* Malformed line. */
continue;
! if (hp)
/* Got an address; try to match either the IP address or as
* a text hostname. */
if (!(ip && wildmat(ip, fields[0])) && !wildmat(hp, fields[0]))
continue;
/* See if we should lookup a specific user in the passwd file */
if (user && pass && EQ(fields[2], "+")) {
--- 347,401 ----
/* Malformed line. */
continue;
! if (hp) {
/* Got an address; try to match either the IP address or as
* a text hostname. */
+ #if defined(HOOKUP)
+ int ipmatch = FALSE;
+ int hostmatch = FALSE;
+ int netmatch = FALSE;
+
+ /* compare IP number and first field */
+ if (ip && wildmat(ip, fields[0]))
+ ipmatch = TRUE;
+
+ /* compare hostname and first field */
+ if (hp && wildmat(hp, fields[0]))
+ hostmatch = TRUE;
+
+ /* try a netmask match */
+ if (ip && (p = strchr(fields[0],'/')) != (char *)NULL) {
+ int bits;
+ int c;
+ struct in_addr ia;
+ unsigned int mask;
+ struct in_addr net;
+ char *q;
+
+ *p = '\0';
+ mask = inet_addr(p+1);
+ if (mask == (unsigned int)INADDR_NONE) {
+ bits = strtoul(p+1,&q,10);
+ for (c = 0; c <= bits; c++)
+ mask |= (1 << (32-c));
+ mask = htonl(mask);
+ }
+ ia.s_addr = inet_addr(ip);
+ net.s_addr = inet_addr(fields[0]);
+ if (ia.s_addr != (unsigned int)INADDR_NONE &&
+ net.s_addr != (unsigned int)INADDR_NONE &&
+ bits > 0 &&
+ *q == '\0' &&
+ (ia.s_addr & mask) == (net.s_addr & mask))
+ netmatch = TRUE;
+ }
+ if (!ipmatch && !hostmatch && !netmatch)
+ continue;
+ #else
if (!(ip && wildmat(ip, fields[0])) && !wildmat(hp, fields[0]))
continue;
+ #endif
+ }
/* See if we should lookup a specific user in the passwd file */
if (user && pass && EQ(fields[2], "+")) {
--
Murray S. Kucherawy ====================================== mskucher@hookup.net
Vice-President, Software Services HookUp Communication Corporation
(905) 847-8000 NIC Handle "MSK" Oakville, Ontario, CANADA
-- No matter who you vote for, the government always gets in. --
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads