Subject: proposal: IP/netmask in ftpaccess file

From: [email-masked]
Date: Mon, 16 Feb 1998 16:26:02 +0000

Note: I'm new in this list, don't know if this topic has been
discussed before.

We needed to control the access to the FTP based on
the IP addresses which are grouped into subnets. The
standard <addrglob> syntax is not very usefull in this
situation, so here is a little patch extending the syntax
for <addrglob> also to IP/netmask (in dot notation).

Example:

class rclass real 172.16.10.96/255.255.255.224
# matches all addresses in the range from
# 172.16.10.96 to 172.16.10.127.

	Vlado
	[email-masked]

=== BEGIN (cut here) ==============================================
*** access.c.WU Sat Feb 14 13:12:45 1998
--- access.c Sat Feb 14 13:32:07 1998
***************
*** 190,195 ****
      FILE  *incfile;
      char  *ptr;
      int   found = 0;
  
      if (addr == NULL) return(0);
  
--- 190,196 ----
      FILE  *incfile;
      char  *ptr;
      int   found = 0;
+ 	int   i, a[4], m[4], r[4];
  
      if (addr == NULL) return(0);
  
***************
*** 193,199 ****
  
      if (addr == NULL) return(0);
  
!     if (isdigit(*addr))
          return(!fnmatch(addr, remoteaddr, NULL));
      else if (*addr == '/') {
          /*
--- 194,208 ----
  
      if (addr == NULL) return(0);
  
! 	if (sscanf(addr,"%d.%d.%d.%d/%d.%d.%d.%d",
! 	  a,a+1,a+2,a+3, m,m+1,m+2,m+3) == 8) {
! 		sscanf(remoteaddr,"%d.%d.%d.%d",r,r+1,r+2,r+3);
! 		for (i = 0; i < 4; i++)
! 			if ((a[i] & m[i]) != (r[i] & m[i]))
! 				return 0;
! 		return 1;
! 	}
!     else if (isdigit(*addr))
          return(!fnmatch(addr, remoteaddr, NULL));
      else if (*addr == '/') {
          /*
=== END (cut here) ==============================================