- Possibility to specify local-zone types for an acl/tag pair

- Possibility to specify (override) local-zone types for a source address block


git-svn-id: file:///svn/unbound/trunk@3797 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Ralph Dolmans 2016-06-24 19:08:58 +00:00
parent dfe52a0de5
commit 54b820773c
11 changed files with 642 additions and 361 deletions

View File

@ -944,7 +944,8 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
}
if(local_zones_answer(worker->daemon->local_zones, &qinfo, &edns,
c->buffer, worker->scratchpad, repinfo,
acladdr->taglist, acladdr->taglen)) {
acladdr->taglist, acladdr->taglen, acladdr->tag_actions,
acladdr->tag_actions_size)) {
regional_free_all(worker->scratchpad);
if(sldns_buffer_limit(c->buffer) == 0) {
comm_point_drop_reply(repinfo);

View File

@ -1,3 +1,7 @@
24 June 2016: Ralph
- Possibility to specify local-zone type for an acl/tag pair
- Possibility to specify (override) local-zone type for a source address
block
16 June 2016: Ralph
- Decrease dp attempts at each QNAME minimisation iteration

View File

@ -608,7 +608,7 @@ int libworker_fg(struct ub_ctx* ctx, struct ctx_query* q)
sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
if(local_zones_answer(ctx->local_zones, &qinfo, &edns,
w->back->udp_buff, w->env->scratch, NULL, NULL, 0)) {
w->back->udp_buff, w->env->scratch, NULL, NULL, 0, NULL, 0)) {
regional_free_all(w->env->scratch);
libworker_fillup_fg(q, LDNS_RCODE_NOERROR,
w->back->udp_buff, sec_status_insecure, NULL);
@ -678,7 +678,7 @@ int libworker_attach_mesh(struct ub_ctx* ctx, struct ctx_query* q,
sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
if(local_zones_answer(ctx->local_zones, &qinfo, &edns,
w->back->udp_buff, w->env->scratch, NULL, NULL, 0)) {
w->back->udp_buff, w->env->scratch, NULL, NULL, 0, NULL, 0)) {
regional_free_all(w->env->scratch);
free(qinfo.qname);
libworker_event_done_cb(q, LDNS_RCODE_NOERROR,
@ -798,7 +798,7 @@ handle_newq(struct libworker* w, uint8_t* buf, uint32_t len)
sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
if(local_zones_answer(w->ctx->local_zones, &qinfo, &edns,
w->back->udp_buff, w->env->scratch, NULL, NULL, 0)) {
w->back->udp_buff, w->env->scratch, NULL, NULL, 0, NULL, 0)) {
regional_free_all(w->env->scratch);
q->msg_security = sec_status_insecure;
add_bg_result(w, q, w->back->udp_buff, UB_NOERROR, NULL);

View File

@ -1120,6 +1120,18 @@ void local_zones_print(struct local_zones* zones)
log_nametypeclass(0, "inform_deny zone",
z->name, 0, z->dclass);
break;
case local_zone_always_transparent:
log_nametypeclass(0, "always_transparent zone",
z->name, 0, z->dclass);
break;
case local_zone_always_refuse:
log_nametypeclass(0, "always_refuse zone",
z->name, 0, z->dclass);
break;
case local_zone_always_nxdomain:
log_nametypeclass(0, "always_nxdomain zone",
z->name, 0, z->dclass);
break;
default:
log_nametypeclass(0, "badtyped zone",
z->name, 0, z->dclass);
@ -1169,7 +1181,7 @@ local_encode(struct query_info* qinfo, struct edns_data* edns,
static int
local_data_answer(struct local_zone* z, struct query_info* qinfo,
struct edns_data* edns, sldns_buffer* buf, struct regional* temp,
int labs, struct local_data** ldp)
int labs, struct local_data** ldp, enum localzone_type lz_type)
{
struct local_data key;
struct local_data* ld;
@ -1178,7 +1190,7 @@ local_data_answer(struct local_zone* z, struct query_info* qinfo,
key.name = qinfo->qname;
key.namelen = qinfo->qname_len;
key.namelabs = labs;
if(z->type == local_zone_redirect) {
if(lz_type == local_zone_redirect) {
key.name = z->name;
key.namelen = z->namelen;
key.namelabs = z->namelabs;
@ -1191,7 +1203,7 @@ local_data_answer(struct local_zone* z, struct query_info* qinfo,
lr = local_data_find_type(ld, qinfo->qtype);
if(!lr)
return 0;
if(z->type == local_zone_redirect) {
if(lz_type == local_zone_redirect) {
/* convert rrset name to query name; like a wildcard */
struct ub_packed_rrset_key r = *lr->rrset;
r.rk.dname = qinfo->qname;
@ -1211,25 +1223,28 @@ local_data_answer(struct local_zone* z, struct query_info* qinfo,
* @param buf: buffer for answer.
* @param temp: temp region for encoding
* @param ld: local data, if NULL, no such name exists in localdata.
* @param lz_type: type of the local zone
* @return 1 if a reply is to be sent, 0 if not.
*/
static int
lz_zone_answer(struct local_zone* z, struct query_info* qinfo,
struct edns_data* edns, sldns_buffer* buf, struct regional* temp,
struct local_data* ld)
struct local_data* ld, enum localzone_type lz_type)
{
if(z->type == local_zone_deny || z->type == local_zone_inform_deny) {
if(lz_type == local_zone_deny || lz_type == local_zone_inform_deny) {
/** no reply at all, signal caller by clearing buffer. */
sldns_buffer_clear(buf);
sldns_buffer_flip(buf);
return 1;
} else if(z->type == local_zone_refuse) {
} else if(lz_type == local_zone_refuse
|| lz_type == local_zone_always_refuse) {
error_encode(buf, (LDNS_RCODE_REFUSED|BIT_AA), qinfo,
*(uint16_t*)sldns_buffer_begin(buf),
sldns_buffer_read_u16_at(buf, 2), edns);
return 1;
} else if(z->type == local_zone_static ||
z->type == local_zone_redirect) {
} else if(lz_type == local_zone_static ||
lz_type == local_zone_redirect ||
lz_type == local_zone_always_nxdomain) {
/* for static, reply nodata or nxdomain
* for redirect, reply nodata */
/* no additional section processing,
@ -1245,11 +1260,12 @@ lz_zone_answer(struct local_zone* z, struct query_info* qinfo,
*(uint16_t*)sldns_buffer_begin(buf),
sldns_buffer_read_u16_at(buf, 2), edns);
return 1;
} else if(z->type == local_zone_typetransparent) {
} else if(lz_type == local_zone_typetransparent
|| lz_type == local_zone_always_transparent) {
/* no NODATA or NXDOMAINS for this zone type */
return 0;
}
/* else z->type == local_zone_transparent */
/* else lz_type == local_zone_transparent */
/* if the zone is transparent and the name exists, but the type
* does not, then we should make this noerror/nodata */
@ -1283,17 +1299,47 @@ lz_inform_print(struct local_zone* z, struct query_info* qinfo,
log_nametypeclass(0, txt, qinfo->qname, qinfo->qtype, qinfo->qclass);
}
enum localzone_type
lz_type(uint8_t *taglist, size_t taglen, uint8_t *taglist2, size_t taglen2,
uint8_t *tagactions, size_t tagactionssize, enum localzone_type lzt,
struct comm_reply* repinfo, struct rbtree_t* override_tree)
{
size_t i, j;
uint8_t tagmatch;
struct local_zone_override* lzo;
if(repinfo && override_tree) {
lzo = (struct local_zone_override*)addr_tree_lookup(
override_tree, &repinfo->addr, repinfo->addrlen);
if(lzo && lzo->type)
return lzo->type;
}
if(!taglist || !taglist2 || !tagactions)
return lzt;
for(i=0; i<taglen && i<taglen2; i++) {
tagmatch = (taglist[i] & taglist2[i]);
for(j=0; j<8 && tagmatch>0; j++) {
if((tagmatch & 0x1) && i*8+j < tagactionssize
&& tagactions[i*8+j] != 0)
return (enum localzone_type)tagactions[i*8+j];
tagmatch >>= 1;
}
}
return lzt;
}
int
local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
struct edns_data* edns, sldns_buffer* buf, struct regional* temp,
struct comm_reply* repinfo, uint8_t* taglist, size_t taglen)
struct comm_reply* repinfo, uint8_t* taglist, size_t taglen,
uint8_t* tagactions, size_t tagactionssize)
{
/* see if query is covered by a zone,
* if so: - try to match (exact) local data
* - look at zone type for negative response. */
int labs = dname_count_labels(qinfo->qname);
struct local_data* ld;
struct local_data* ld = NULL;;
struct local_zone* z;
enum localzone_type lzt;
int r;
lock_rw_rdlock(&zones->lock);
z = local_zones_tags_lookup(zones, qinfo->qname,
@ -1305,15 +1351,20 @@ local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
lock_rw_rdlock(&z->lock);
lock_rw_unlock(&zones->lock);
if((z->type == local_zone_inform || z->type == local_zone_inform_deny)
lzt = lz_type(taglist, taglen, z->taglist, z->taglen, tagactions,
tagactionssize, z->type, repinfo, z->override_tree);
if((lzt == local_zone_inform || lzt == local_zone_inform_deny)
&& repinfo)
lz_inform_print(z, qinfo, repinfo);
if(local_data_answer(z, qinfo, edns, buf, temp, labs, &ld)) {
if(lzt != local_zone_always_refuse && lzt != local_zone_always_transparent
&& lzt != local_zone_always_nxdomain
&& local_data_answer(z, qinfo, edns, buf, temp, labs, &ld, lzt)) {
lock_rw_unlock(&z->lock);
return 1;
}
r = lz_zone_answer(z, qinfo, edns, buf, temp, ld);
r = lz_zone_answer(z, qinfo, edns, buf, temp, ld, lzt);
lock_rw_unlock(&z->lock);
return r;
}
@ -1330,6 +1381,9 @@ const char* local_zone_type2str(enum localzone_type t)
case local_zone_nodefault: return "nodefault";
case local_zone_inform: return "inform";
case local_zone_inform_deny: return "inform_deny";
case local_zone_always_transparent: return "always_transparent";
case local_zone_always_refuse: return "always_refuse";
case local_zone_always_nxdomain: return "always_nxdomain";
}
return "badtyped";
}
@ -1352,6 +1406,12 @@ int local_zone_str2type(const char* type, enum localzone_type* t)
*t = local_zone_inform;
else if(strcmp(type, "inform_deny") == 0)
*t = local_zone_inform_deny;
else if(strcmp(type, "always_transparent") == 0)
*t = local_zone_always_transparent;
else if(strcmp(type, "always_refuse") == 0)
*t = local_zone_always_refuse;
else if(strcmp(type, "always_nxdomain") == 0)
*t = local_zone_always_nxdomain;
else return 0;
return 1;
}

View File

@ -76,7 +76,13 @@ enum localzone_type {
/** log client address, but no block (transparent) */
local_zone_inform,
/** log client address, and block (drop) */
local_zone_inform_deny
local_zone_inform_deny,
/** resolve normally, even when there is local data */
local_zone_always_transparent,
/** answer with error, even when there is local data */
local_zone_always_refuse,
/** answer with nxdomain, even when there is local data */
local_zone_always_nxdomain
};
/**
@ -264,13 +270,16 @@ void local_zones_print(struct local_zones* zones);
* @param repinfo: source address for checks. may be NULL.
* @param taglist: taglist for checks. May be NULL.
* @param taglen: length of the taglist.
* @param tagactions: local zone actions for tags. May be NULL.
* @param tagactionssize: length of the tagactions.
* @return true if answer is in buffer. false if query is not answered
* by authority data. If the reply should be dropped altogether, the return
* value is true, but the buffer is cleared (empty).
*/
int local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
struct edns_data* edns, struct sldns_buffer* buf, struct regional* temp,
struct comm_reply* repinfo, uint8_t* taglist, size_t taglen);
struct comm_reply* repinfo, uint8_t* taglist, size_t taglen,
uint8_t* tagactions, size_t tagactionssize);
/**
* Parse the string into localzone type.

93
testdata/local_acl_override.rpl vendored Normal file
View File

@ -0,0 +1,93 @@
; config options
server:
local-zone: "1.example." transparent
local-zone: "2.example." transparent
access-control: 10.10.10.0/24 allow
local-zone-override: "1.example." 10.10.10.20/32 refuse
local-zone-override: "2.example." 10.10.10.30/32 refuse
local-zone-override: "2.example." 10.10.10.40/32 always_nxdomain
forward-zone:
name: "example."
forward-addr: 1.2.3.4
CONFIG_END
SCENARIO_BEGIN Test local data queries
RANGE_BEGIN 0 100
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR NOERROR
SECTION QUESTION
1.example. IN TXT
SECTION ANSWER
1.example. IN TXT "data 1"
ENTRY_END
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR NOERROR
SECTION QUESTION
2.example. IN TXT
SECTION ANSWER
2.example. IN TXT "data 2"
ENTRY_END
RANGE_END
STEP 1 QUERY ADDRESS 10.10.10.10
ENTRY_BEGIN
REPLY RD
SECTION QUESTION
1.example. IN TXT
ENTRY_END
STEP 2 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RD RA
SECTION QUESTION
1.example. IN TXT
SECTION ANSWER
1.example. IN TXT "data 1"
ENTRY_END
STEP 3 QUERY ADDRESS 10.10.10.20
ENTRY_BEGIN
SECTION QUESTION
1.example. IN TXT
ENTRY_END
STEP 4 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RA AA REFUSED
SECTION QUESTION
1.example. IN TXT
ENTRY_END
STEP 5 QUERY ADDRESS 10.10.10.30
ENTRY_BEGIN
SECTION QUESTION
2.example. IN TXT
ENTRY_END
STEP 6 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RA AA REFUSED
SECTION QUESTION
2.example. IN TXT
ENTRY_END
STEP 7 QUERY ADDRESS 10.10.10.40
ENTRY_BEGIN
SECTION QUESTION
2.example. IN TXT
ENTRY_END
STEP 8 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RA AA NXDOMAIN
SECTION QUESTION
2.example. IN TXT
ENTRY_END
SCENARIO_END

125
testdata/local_acl_taglist_action.rpl vendored Normal file
View File

@ -0,0 +1,125 @@
; config options
server:
define-tag: "tag1 tag2 tag3"
local-zone: "example." static
local-data: 'example. IN TXT "data 0"'
local-zone-tag: "example." "tag1 tag2 tag3"
access-control: 10.10.10.0/24 allow
access-control-tag: 10.10.10.10/32 "tag1"
access-control-tag: 10.10.10.20/32 "tag2 tag3"
access-control-tag: 10.10.10.30/32 "tag2 tag3"
access-control-tag: 10.10.10.40/32 "tag3"
access-control-tag: 10.10.10.50/32 "tag3"
access-control-tag-action: 10.10.10.10/32 tag1 always_refuse
access-control-tag-action: 10.10.10.20/32 tag2 always_nxdomain
access-control-tag-action: 10.10.10.30/32 tag3 always_refuse
access-control-tag-action: 10.10.10.50/32 tag3 always_transparent
forward-zone:
name: "example."
forward-addr: 1.2.3.4
CONFIG_END
SCENARIO_BEGIN Test local data queries
RANGE_BEGIN 0 100
ENTRY_BEGIN
MATCH opcode qtype qname
ADJUST copy_id
REPLY QR NOERROR
SECTION QUESTION
example. IN TXT
SECTION ANSWER
example. IN TXT "data 1"
ENTRY_END
RANGE_END
STEP 1 QUERY ADDRESS 10.10.10.10
ENTRY_BEGIN
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 2 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RA AA REFUSED
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 3 QUERY ADDRESS 10.10.10.20
ENTRY_BEGIN
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 4 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RA AA NXDOMAIN
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 5 QUERY ADDRESS 10.10.10.30
ENTRY_BEGIN
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 6 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RA AA REFUSED
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 7 QUERY ADDRESS 10.10.10.40
ENTRY_BEGIN
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 8 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RA AA
SECTION QUESTION
example. IN TXT
SECTION ANSWER
example. IN TXT "data 0"
ENTRY_END
STEP 9 QUERY ADDRESS 10.10.10.50
ENTRY_BEGIN
REPLY RD
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 10 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RD RA
SECTION QUESTION
example. IN TXT
SECTION ANSWER
example. IN TXT "data 1"
ENTRY_END
STEP 11 QUERY ADDRESS 10.10.10.60
ENTRY_BEGIN
REPLY RD
SECTION QUESTION
example. IN TXT
ENTRY_END
STEP 12 CHECK_ANSWER
ENTRY_BEGIN
MATCH all
REPLY QR RD RA
SECTION QUESTION
example. IN TXT
SECTION ANSWER
example. IN TXT "data 1"
ENTRY_END
SCENARIO_END

View File

@ -9,8 +9,8 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
#define YY_FLEX_SUBMINOR_VERSION 0
#define YY_FLEX_MINOR_VERSION 5
#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@ -163,12 +163,7 @@ typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
extern yy_size_t yyleng;
extern int yyleng;
extern FILE *yyin, *yyout;
@ -177,14 +172,13 @@ extern FILE *yyin, *yyout;
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
#define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
yy_size_t yyless_macro_arg = (n); \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = (yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
@ -195,6 +189,11 @@ extern FILE *yyin, *yyout;
#define unput(c) yyunput( c, (yytext_ptr) )
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
@ -212,7 +211,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
yy_size_t yy_n_chars;
int yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@ -282,8 +281,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
yy_size_t yyleng;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
int yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
@ -311,7 +310,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
@ -354,17 +353,11 @@ extern int yylineno;
int yylineno = 1;
extern char *yytext;
#ifdef yytext_ptr
#undef yytext_ptr
#endif
#define yytext_ptr yytext
static yy_state_type yy_get_previous_state (void );
static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
static int yy_get_next_buffer (void );
#if defined(__GNUC__) && __GNUC__ >= 3
__attribute__((__noreturn__))
#endif
static void yy_fatal_error (yyconst char msg[] );
/* Done after the current pattern has been matched and before the
@ -597,7 +590,7 @@ static yyconst flex_int16_t yy_accept[1874] =
155, 159, 0
} ;
static yyconst YY_CHAR yy_ec[256] =
static yyconst flex_int32_t yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
@ -629,7 +622,7 @@ static yyconst YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst YY_CHAR yy_meta[40] =
static yyconst flex_int32_t yy_meta[40] =
{ 0,
1, 2, 3, 4, 5, 1, 6, 1, 1, 1,
1, 7, 1, 1, 1, 1, 1, 1, 1, 1,
@ -637,7 +630,7 @@ static yyconst YY_CHAR yy_meta[40] =
1, 1, 1, 1, 1, 1, 1, 1, 1
} ;
static yyconst flex_uint16_t yy_base[1888] =
static yyconst flex_int16_t yy_base[1888] =
{ 0,
0, 0, 37, 40, 44, 51, 63, 75, 56, 68,
87, 108, 2327, 2209, 50, 3703, 3703, 3703, 129, 94,
@ -1059,7 +1052,7 @@ static yyconst flex_int16_t yy_def[1888] =
1873, 1873, 1873, 1873, 1873, 1873, 1873
} ;
static yyconst flex_uint16_t yy_nxt[3743] =
static yyconst flex_int16_t yy_nxt[3743] =
{ 0,
14, 15, 16, 17, 18, 19, 18, 14, 14, 14,
14, 18, 20, 21, 14, 22, 23, 24, 25, 14,
@ -2093,7 +2086,7 @@ static void config_end_include(void)
#define YY_NO_INPUT 1
#endif
#line 2095 "<stdout>"
#line 2088 "<stdout>"
#define INITIAL 0
#define quotedstring 1
@ -2131,19 +2124,19 @@ void yyset_extra (YY_EXTRA_TYPE user_defined );
FILE *yyget_in (void );
void yyset_in (FILE * _in_str );
void yyset_in (FILE * in_str );
FILE *yyget_out (void );
void yyset_out (FILE * _out_str );
void yyset_out (FILE * out_str );
yy_size_t yyget_leng (void );
int yyget_leng (void );
char *yyget_text (void );
int yyget_lineno (void );
void yyset_lineno (int _line_number );
void yyset_lineno (int line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@ -2157,10 +2150,6 @@ extern int yywrap (void );
#endif
#endif
#ifndef YY_NO_UNPUT
#endif
#ifndef yytext_ptr
static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
@ -2273,7 +2262,7 @@ extern int yylex (void);
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
#define YY_BREAK /*LINTED*/break;
#define YY_BREAK break;
#endif
#define YY_RULE_SETUP \
@ -2283,10 +2272,14 @@ extern int yylex (void);
*/
YY_DECL
{
yy_state_type yy_current_state;
char *yy_cp, *yy_bp;
int yy_act;
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
#line 201 "./util/configlexer.lex"
#line 2280 "<stdout>"
if ( !(yy_init) )
{
(yy_init) = 1;
@ -2313,12 +2306,7 @@ YY_DECL
yy_load_buffer_state( );
}
{
#line 201 "./util/configlexer.lex"
#line 2318 "<stdout>"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
while ( 1 ) /* loops until end-of-file is reached */
{
(yy_more_len) = 0;
if ( (yy_more_flag) )
@ -2340,7 +2328,7 @@ YY_DECL
yy_match:
do
{
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -3413,7 +3401,7 @@ YY_RULE_SETUP
#line 473 "./util/configlexer.lex"
ECHO;
YY_BREAK
#line 3415 "<stdout>"
#line 3403 "<stdout>"
case YY_END_OF_BUFFER:
{
@ -3542,7 +3530,6 @@ ECHO;
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
@ -3554,9 +3541,9 @@ ECHO;
*/
static int yy_get_next_buffer (void)
{
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = (yytext_ptr);
yy_size_t number_to_move, i;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = (yytext_ptr);
register int number_to_move, i;
int ret_val;
if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
@ -3585,7 +3572,7 @@ static int yy_get_next_buffer (void)
/* Try to read more data. */
/* First move last chars to start of buffer. */
number_to_move = (yy_size_t) ((yy_c_buf_p) - (yytext_ptr)) - 1;
number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@ -3598,21 +3585,21 @@ static int yy_get_next_buffer (void)
else
{
yy_size_t num_to_read =
int num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
yy_size_t new_size = b->yy_buf_size * 2;
int new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@ -3643,7 +3630,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
(yy_n_chars), num_to_read );
(yy_n_chars), (size_t) num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
@ -3688,14 +3675,14 @@ static int yy_get_next_buffer (void)
static yy_state_type yy_get_previous_state (void)
{
yy_state_type yy_current_state;
char *yy_cp;
register yy_state_type yy_current_state;
register char *yy_cp;
yy_current_state = (yy_start);
for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -3720,10 +3707,10 @@ static int yy_get_next_buffer (void)
*/
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
{
int yy_is_jam;
char *yy_cp = (yy_c_buf_p);
register int yy_is_jam;
register char *yy_cp = (yy_c_buf_p);
YY_CHAR yy_c = 1;
register YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@ -3738,13 +3725,9 @@ static int yy_get_next_buffer (void)
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 1873);
return yy_is_jam ? 0 : yy_current_state;
return yy_is_jam ? 0 : yy_current_state;
}
#ifndef YY_NO_UNPUT
#endif
#ifndef YY_NO_INPUT
#ifdef __cplusplus
static int yyinput (void)
@ -3769,7 +3752,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
int offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@ -3894,7 +3877,7 @@ static void yy_load_buffer_state (void)
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_buf_size = (yy_size_t)size;
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
@ -3929,6 +3912,10 @@ static void yy_load_buffer_state (void)
yyfree((void *) b );
}
#ifndef __cplusplus
extern int isatty (int );
#endif /* __cplusplus */
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF.
@ -4041,7 +4028,7 @@ void yypop_buffer_state (void)
*/
static void yyensure_buffer_stack (void)
{
yy_size_t num_to_alloc;
int num_to_alloc;
if (!(yy_buffer_stack)) {
@ -4049,7 +4036,7 @@ static void yyensure_buffer_stack (void)
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1; // After all that talk, this was set to 1 anyways...
num_to_alloc = 1;
(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
);
@ -4066,7 +4053,7 @@ static void yyensure_buffer_stack (void)
if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
/* Increase the buffer to prepare for a possible push. */
yy_size_t grow_size = 8 /* arbitrary grow size */;
int grow_size = 8 /* arbitrary grow size */;
num_to_alloc = (yy_buffer_stack_max) + grow_size;
(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
@ -4138,12 +4125,12 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
*
* @return the newly allocated buffer state object.
*/
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
yy_size_t i;
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
@ -4174,7 +4161,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len
static void yy_fatal_error (yyconst char* msg )
{
(void) fprintf( stderr, "%s\n", msg );
(void) fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@ -4185,7 +4172,7 @@ static void yy_fatal_error (yyconst char* msg )
do \
{ \
/* Undo effects of setting up yytext. */ \
yy_size_t yyless_macro_arg = (n); \
int yyless_macro_arg = (n); \
YY_LESS_LINENO(yyless_macro_arg);\
yytext[yyleng] = (yy_hold_char); \
(yy_c_buf_p) = yytext + yyless_macro_arg; \
@ -4225,7 +4212,7 @@ FILE *yyget_out (void)
/** Get the length of the current token.
*
*/
yy_size_t yyget_leng (void)
int yyget_leng (void)
{
return yyleng;
}
@ -4240,29 +4227,29 @@ char *yyget_text (void)
}
/** Set the current line number.
* @param _line_number line number
* @param line_number
*
*/
void yyset_lineno (int _line_number )
void yyset_lineno (int line_number )
{
yylineno = _line_number;
yylineno = line_number;
}
/** Set the input stream. This does not discard the current
* input buffer.
* @param _in_str A readable stream.
* @param in_str A readable stream.
*
* @see yy_switch_to_buffer
*/
void yyset_in (FILE * _in_str )
void yyset_in (FILE * in_str )
{
yyin = _in_str ;
yyin = in_str ;
}
void yyset_out (FILE * _out_str )
void yyset_out (FILE * out_str )
{
yyout = _out_str ;
yyout = out_str ;
}
int yyget_debug (void)
@ -4270,9 +4257,9 @@ int yyget_debug (void)
return yy_flex_debug;
}
void yyset_debug (int _bdebug )
void yyset_debug (int bdebug )
{
yy_flex_debug = _bdebug ;
yy_flex_debug = bdebug ;
}
static int yy_init_globals (void)
@ -4332,8 +4319,7 @@ int yylex_destroy (void)
#ifndef yytext_ptr
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
{
int i;
register int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
@ -4342,7 +4328,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
#ifdef YY_NEED_STRLEN
static int yy_flex_strlen (yyconst char * s )
{
int n;
register int n;
for ( n = 0; s[n]; ++n )
;
@ -4352,12 +4338,11 @@ static int yy_flex_strlen (yyconst char * s )
void *yyalloc (yy_size_t size )
{
return (void *) malloc( size );
return (void *) malloc( size );
}
void *yyrealloc (void * ptr, yy_size_t size )
{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@ -4370,7 +4355,7 @@ void *yyrealloc (void * ptr, yy_size_t size )
void yyfree (void * ptr )
{
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.0.4. */
/* A Bison parser, made by GNU Bison 3.0.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -393,7 +393,7 @@ extern int yydebug;
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 64 "./util/configparser.y" /* yacc.c:1909 */
@ -402,8 +402,6 @@ union YYSTYPE
#line 404 "util/configparser.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif

View File

@ -1237,12 +1237,16 @@ server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 &&
strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 &&
strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0
&& strcmp($3, "typetransparent")!=0 &&
strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0)
&& strcmp($3, "typetransparent")!=0
&& strcmp($3, "always_transparent")!=0
&& strcmp($3, "always_refuse")!=0
&& strcmp($3, "always_nxdomain")!=0
&& strcmp($3, "inform")!=0 && strcmp($3, "inform_deny")!=0)
yyerror("local-zone type: expected static, deny, "
"refuse, redirect, transparent, "
"typetransparent, inform, inform_deny "
"or nodefault");
"typetransparent, inform, inform_deny, "
"always_transparent, always_refuse, "
"always_nxdomain or nodefault");
else if(strcmp($3, "nodefault")==0) {
if(!cfg_strlist_insert(&cfg_parser->cfg->
local_zones_nodefault, $2))