]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - acl.c
Make allow/deny syntax consistent with that of add/delete
[paraslash.git] / acl.c
diff --git a/acl.c b/acl.c
index 14edcf7d87c08617e175e0fff44e3c572e305160..9bc83c2506f9083e577d8ff36d0c6953dd2d1285 100644 (file)
--- a/acl.c
+++ b/acl.c
@@ -136,30 +136,16 @@ char *acl_get_contents(struct list_head *acl)
  */
 void acl_init(struct list_head *acl, char * const *acl_info, int num)
 {
-       int i;
+       char    addr[16];
+       int     mask, i;
 
        INIT_LIST_HEAD(acl);
-       for (i = 0; i < num; i++) {
-               char *arg = para_strdup(acl_info[i]);
-               char *p = strchr(arg, '/');
-               int netmask;
-
-               if (!p)
-                       goto err;
-               *p = '\0';
-               if (!is_valid_ipv4_address(arg))
-                       goto err;
-               netmask = atoi(++p);
-               if (netmask < 0 || netmask > 32)
-                       goto err;
-               acl_add_entry(acl, arg, netmask);
-               goto success;
-err:
-               PARA_CRIT_LOG("syntax error: %s\n", acl_info[i]);
-success:
-               free(arg);
-               continue;
-       }
+       for (i = 0; i < num; i++)
+               if (parse_cidr(acl_info[i], addr, sizeof(addr), &mask) == NULL)
+                       PARA_CRIT_LOG("ACL syntax error: %s, ignoring\n",
+                                     acl_info[i]);
+               else
+                       acl_add_entry(acl, addr, mask);
 }
 
 /**