Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ACL: set the default (no filter) prefix when user entered empty or wr…
…ong prefix
  • Loading branch information
perexg committed Sep 16, 2014
1 parent 89ee111 commit 97999e4
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/access.c
Expand Up @@ -487,6 +487,23 @@ access_get_by_addr(struct sockaddr *src)
return a;
}

/**
*
*/
static void
access_set_prefix_default(access_entry_t *ae)
{
access_ipmask_t *ai;

ai = calloc(1, sizeof(access_ipmask_t));
ai->ai_ipv6 = 1;
TAILQ_INSERT_HEAD(&ae->ae_ipmasks, ai, ai_link);

ai = calloc(1, sizeof(access_ipmask_t));
ai->ai_ipv6 = 0;
TAILQ_INSERT_HEAD(&ae->ae_ipmasks, ai, ai_link);
}

/**
*
*/
Expand Down Expand Up @@ -578,6 +595,9 @@ access_set_prefix(access_entry_t *ae, const char *prefix)

tok = strtok_r(NULL, ",;| ", &saveptr);
}

if (!TAILQ_FIRST(&ae->ae_ipmasks))
access_set_prefix_default(ae);
}

/**
Expand Down Expand Up @@ -1073,7 +1093,6 @@ access_init(int createdefault, int noacl)
htsmsg_t *c, *m;
htsmsg_field_t *f;
access_entry_t *ae;
access_ipmask_t *ai;
const char *s;

static struct {
Expand Down Expand Up @@ -1118,13 +1137,7 @@ access_init(int createdefault, int noacl)

TAILQ_INIT(&ae->ae_ipmasks);

ai = calloc(1, sizeof(access_ipmask_t));
ai->ai_ipv6 = 1;
TAILQ_INSERT_HEAD(&ae->ae_ipmasks, ai, ai_link);

ai = calloc(1, sizeof(access_ipmask_t));
ai->ai_ipv6 = 0;
TAILQ_INSERT_HEAD(&ae->ae_ipmasks, ai, ai_link);
access_set_prefix_default(ae);

access_entry_save(ae);

Expand Down

0 comments on commit 97999e4

Please sign in to comment.