home *** CD-ROM | disk | FTP | other *** search
-
- From brian@hyperreal.com Sat May 3 13:28:02 1997
- Date: Mon, 14 Apr 1997 12:01:11 -0700 (PDT)
- From: Brian Behlendorf <brian@hyperreal.com>
- Reply-To: new-httpd@apache.org
- To: new-httpd@apache.org
- Subject: mod_access.c patch for apache 1.2b8 (fwd)
-
-
- Could someone follow up, and help his patch make it to /contrib? Thanks.
-
- Brian
-
- --=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
- brian@hyperreal.com http://www.apache.org http://www.organic.com/jobs
-
- ---------- Forwarded message ----------
- Date: Wed, 9 Apr 1997 17:10:19 +0900 (JST)
- From: Hideo Matsumoto <hideo-m@nerv.org>
- To: apache@apache.org
- Subject: mod_access.c patch for apache 1.2b8
-
- Hello,
-
- I made following patch for mod_access.c. This patch extends access
- control syntax specifying IP address block for access control as
- follows:
-
- [access.conf sample] ------
- order deny,allow
- allow from 10.0.0.0/8
- allow from 172.16.0.0/12
- allow from 192.168.0.0/16
- deny from all
- ---------------------------
-
- If you feel this patch useful, please include next release.
- I'm Japanese. Sorry for my poor English.
-
- Thanx,
-
- --
- Hideo Matsumoto <hideo-m@nerv.org> NERV, Tokyo-3, Japan.
-
-
- [ Part 2: "" ]
-
- --- mod_access.c.orig Fri Mar 7 23:15:36 1997
- +++ mod_access.c Wed Apr 9 16:21:48 1997
- @@ -66,6 +66,7 @@
- typedef struct {
- char *from;
- int limited;
- + unsigned long net, mask;
- } allowdeny;
-
- /* things in the 'order' array */
- @@ -81,6 +82,35 @@
-
- module access_module;
-
- +int readmask(const char *param, unsigned long *Network, unsigned long *Netmask)
- +{
- + char buf[sizeof("255.255.255.255/255")];
- + char *s, *t;
- + int i;
- + unsigned long netmask;
- +
- + if (!strchr(param, '/')) return -1;
- +
- + strncpy(buf, param, sizeof(buf));
- + buf[sizeof(buf)-1] = '\0';
- +
- + if ((s = strtok(buf, "/")) == NULL) return -1; /* ex:192.168.0.1 */
- + if ((t = strtok(NULL, "/")) == NULL) return -1; /* ex:24 */
- +
- + if ((*Network = inet_addr(s)) == INADDR_NONE) return -1;
- +
- +#define ADDR_SIZE (sizeof(unsigned long) * 8)
- + if ((i = atoi(t)) <= 0)
- + netmask = 0x00000000UL;
- + else {
- + if (i > ADDR_SIZE) i = ADDR_SIZE;
- + netmask = 0xffffffffUL << (ADDR_SIZE - i);
- + }
- +
- + *Netmask = htonl(netmask);
- + return 0;
- +}
- +
- void *create_access_dir_config (pool *p, char *dummy)
- {
- access_dir_conf *conf =
- @@ -122,6 +152,8 @@
- a = (allowdeny *)push_array (cmd->info ? d->allows : d->denys);
- a->from = pstrdup (cmd->pool, where);
- a->limited = cmd->limited;
- + if (strchr(a->from, '/') == NULL||readmask(a->from, &a->net, &a->mask) < 0)
- + a->net = INADDR_NONE;
- return NULL;
- }
-
- @@ -213,6 +245,11 @@
- else
- gothost = 2;
- }
- +
- +
- + if (ap[i].net != INADDR_NONE
- + && (r->connection->remote_addr.sin_addr.s_addr & ap[i].mask) == ap[i].net)
- + return 1;
-
- if ((gothost == 2) && in_domain(ap[i].from, remotehost))
- return 1;
-