Add htacess and icons for fancy indexing.
[paraslash.git] / acl.c
diff --git a/acl.c b/acl.c
index 9bc83c2506f9083e577d8ff36d0c6953dd2d1285..2923523db35665bdb323c34e6789cd8d2bc8a47e 100644 (file)
--- a/acl.c
+++ b/acl.c
@@ -1,16 +1,24 @@
 /*
- * Copyright (C) 2005-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2014 Andre Noll <maan@tuebingen.mpg.de>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
 /** \file acl.c Access control lists for paraslash senders. */
 
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <regex.h>
+#include <arpa/inet.h>
+#include <sys/un.h>
+#include <netdb.h>
+
 #include "para.h"
 #include "error.h"
 #include "string.h"
 #include "list.h"
 #include "net.h"
+#include "acl.h"
 
 /**
  * Describes one entry in the blacklist/whitelist of a paraslash sender.
@@ -55,7 +63,7 @@ static int acl_lookup(int fd, struct list_head *acl)
                PARA_ERROR_LOG("Can not determine peer address: %s\n", strerror(errno));
                goto no_match;
        }
-       v4_addr = extract_v4_addr(&ss);
+       extract_v4_addr(&ss, &v4_addr);
        if (!v4_addr.s_addr)
                goto no_match;
 
@@ -90,13 +98,17 @@ static void acl_add_entry(struct list_head *acl, char *addr, int netmask)
  * \param addr The address to delete.
  * \param netmask The netmask of the entry to be removed from the list.
  */
-static void acl_del_entry(struct list_head *acl, char *addr, int netmask)
+static void acl_del_entry(struct list_head *acl, char *addr, unsigned netmask)
 {
        struct access_info *ai, *tmp;
+       struct in_addr to_delete;
+
+       inet_pton(AF_INET, addr, &to_delete);
 
        list_for_each_entry_safe(ai, tmp, acl, node) {
-               if (!strcmp(addr, inet_ntoa(ai->addr)) &&
-                               ai->netmask == netmask) {
+
+               if (v4_addr_match(to_delete.s_addr, ai->addr.s_addr,
+                                       PARA_MIN(netmask, ai->netmask))) {
                        PARA_NOTICE_LOG("removing %s/%i from access list\n",
                                        addr, ai->netmask);
                        list_del(&ai->node);