confparser.y revision 5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3
%{
/*
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
static char rcsid[] = "$Id: confparser.y,v 1.4 1999/09/15 23:56:24 explorer Exp $";
#endif /* not lint */
#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
#include <syslog.h>
#include <isc/assertions.h>
#include <dns/confparser.h>
#include <dns/rdatatype.h>
#include <dns/rdataclass.h>
#include <dns/confcommon.h>
/* Type keys for symtab lookup */
#define KEYWORD_SYM_TYPE 0x1
#define CLASS_SYM_TYPE 0x2
#define ACL_SYM_TYPE 0x3
static isc_mutex_t yacc_mutex;
/* All these statics are protected by the above yacc_mutex */
static dns_c_ctx_t *currcfg;
static isc_symtab_t *keywords;
static dns_c_cbks_t *callbacks;
static isc_lexspecials_t specials;
#define CONF_MAX_IDENT 1024
/* This should be sufficient to permit multiple parsers and lexers if needed */
#define yyparse confyyparse
#define YYDEBUG 1
static isc_result_t tmpres;
static int debug_lexer;
%}
%union {
char *text;
int number;
}
/* Misc */
/* Miscellaneous items (used in several places): */
%%
;
;
| acl_stmt
| key_stmt
;
{
$2);
}
}
;
{
if (tmpres == ISC_R_SUCCESS) {
/*
* Clean out options so rest of config won't fail
* or issue extra error messages
*/
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to create options structure: %s",
}
if (tmpres != ISC_R_SUCCESS) {
}
}
}
;
;
option: /* Empty */
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"set version error %s: %s",
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"error setting directory: %s: %s",
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining memstatistics-file");
} else if (tmpres != ISC_R_SUCCESS) {
"set memstatsfile error %s: %s",
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining deallocate-on-exit.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining maintain-ixfr-base.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
}
}
{
if ($4 == NULL) {
"address-match-list empty. "
"listen statement ignored.");
} else {
if (tmpres != ISC_R_SUCCESS) {
"Failed to add listen statement");
}
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining forward");
}
}
| L_FORWARDERS {
if (tmpres != ISC_R_NOTFOUND) {
"Redefining options forwarders");
} else {
&forwarders);
if (tmpres != ISC_R_SUCCESS) {
"Failed to create "
"forwarders list");
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to set forwarders list.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set allow-query");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining allow-transfer list");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set allow-transfer");
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set transfer-format.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining max-transfer-time-in.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set max-transfer-time-in.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining cleaning-interval.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set cleaning-interval.");
}
}
{
60);
if (tmpres == ISC_R_EXISTS) {
"Redefining interface-interval.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set interface-interval.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining statistics-interval.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set statistics-interval.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining max-ixfr-log-size.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set max-ixfr-log-size.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining max-ncache-ttl.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set max-ncache-ttl.");
}
}
{
60);
if (tmpres == ISC_R_EXISTS) {
"Redefining heartbeat-interval.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set heartbeat-interval.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres != ISC_R_NOTFOUND) {
"Redefining rrset-order list");
} else {
if (tmpres != ISC_R_SUCCESS) {
"Failed to create rrset-order "
"list");
}
ordering);
if (tmpres != ISC_R_SUCCESS) {
"Failed to set rrset-order.");
}
}
;
/*
* Controls.
*/
;
;
control: /* Empty */
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to build inet control structure");
}
}
{
$2, $4, $6, $8);
if (tmpres != ISC_R_SUCCESS) {
"Failed to build unix control structure");
}
}
;
;
ordering_class: /* nothing */
{
$$ = dns_rdataclass_any;
}
{
$$ = $2;
}
;
ordering_type: /* nothing */
{
$$ = dns_rdatatype_any;
}
{
} else {
if (tmpres != DNS_R_SUCCESS) {
"Unknown type. Assuming ``*''");
}
}
$$ = ty;
}
;
ordering_name: /* nothing */
{
}
{
$$ = $2;
}
{
if (tmpres != ISC_R_SUCCESS) {
"Unknown ordering type ``%s''."
" Using default", $5);
o = DNS_DEFAULT_ORDERING;
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to create rrset-order element");
}
}
{
$$ = dns_one_answer;
}
{
$$ = dns_many_answers;
}
;
{
$$ = $1;
}
| L_STRING
{
"Bad ip-address. Using ``*''");
}
}
;
{
$$ = $1;
}
| L_STRING
{
$$ = htons(0);
"Bad port specification. Using ``*''");
}
}
;
{
if (tmpres == ISC_R_EXISTS) {
"Redefining query-source address.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set query-source address.");
}
}
;
{
if (tmpres == ISC_R_EXISTS) {
"Redefining query-source port.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set query-source port.");
}
}
;
;
maybe_port: /* nothing */
{
$$ = htons(DNS_C_DEFAULTPORT);
}
{
$$ = $2;
}
;
maybe_zero_port : /* nothing */
{
$$ = htons(0);
}
{
$$ = $2;
}
;
{
$$ = isc_boolean_true;
}
| L_TRUE
{
$$ = isc_boolean_true;
}
| L_NO
{
$$ = isc_boolean_false;
}
| L_FALSE
{
$$ = isc_boolean_false;
}
{
if ($1 == 1) {
$$ = isc_boolean_true;
} else if ($1 == 0) {
$$ = isc_boolean_false;
} else {
"number should be 0 or 1; assuming 1");
$$ = isc_boolean_true;
}
}
;
{
$$ = dns_trans_primary;
}
| L_SLAVE
{
$$ = dns_trans_secondary;
}
{
$$ = dns_trans_response;
}
;
{
$$ = dns_c_severity_warn;
}
| L_FAIL
{
$$ = dns_c_severity_fail;
}
| L_IGNORE
{
$$ = dns_c_severity_ignore;
}
;
{
$$ = dns_c_forw_only;
}
| L_FIRST
{
$$ = dns_c_forw_first;
}
{
$$ = dns_c_forw_noanswer;
}
{
$$ = dns_c_forw_nodomain;
}
;
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
;
{
$$ = result;
if ($$ == DNS_C_SIZE_SPEC_DEFAULT) {
"value (%lu) too big. "
"Reducing to %lu",
(unsigned long)$$,
(unsigned long)newi);
$$ = newi; }
} else {
"invalid unit string '%s'. Using "
"default", $1);
$$ = DNS_C_SIZE_SPEC_DEFAULT;
}
}
{
$$ = (isc_uint32_t)$1;
if ($$ == DNS_C_SIZE_SPEC_DEFAULT) {
"value (%lu) too big. Reducing to %lu",
(unsigned long) $$,
(unsigned long) newi);
$$ = newi;
}
}
{
$$ = DNS_C_SIZE_SPEC_DEFAULT;
}
{
$$ = DNS_C_SIZE_SPEC_UNLIM;
}
;
{
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining transfers-out.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set transfers-out.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining transfers-per-ns.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set transfers-per-ns.");
}
}
;
opt_forwarders_list: /* nothing */ {
}
;
;
{
$1, 0);
if (tmpres != ISC_R_SUCCESS) {
"Failed to create forwarders "
"address element.");
}
}
;
/*
* Logging
*/
{
/* initialized in logging_init() */
}
;
;
;
if (tmpres == ISC_R_EXISTS) {
"Redefing channel %s\n", $2);
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to add new file channel.");
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to add file channel's path.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to add new syslog channel.");
}
if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel facility.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to add new channel ``%s''", $2);
}
"First statment inside a channel definition "
"must be ``file'' or ``syslog'' or ``null''.");
}
;
;
optional_channel_opt_list: /* empty */
;
if (tmpres == ISC_R_EXISTS) {
"Redefining category ``%s''", $2);
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to add new logging category.");
}
;
{
if (tmpres != ISC_R_SUCCESS) {
"Unknown severity ``%s''", $1);
}
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel severity.");
}
}
| L_DEBUG
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel severity(debug).");
}
}
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel "
"severity (debug).");
}
if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel "
"severity debug level.");
}
}
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel "
"severity (dynamic).");
}
}
;
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel versions.");
}
}
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel "
"versions (unlimited).");
}
}
;
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel size.");
}
}
;
maybe_file_modifiers: /* nothing */
;
{
if (tmpres != ISC_R_SUCCESS) {
$$ = LOG_DAEMON;
}
}
| L_SYSLOG
{
$$ = LOG_SYSLOG;
}
;
maybe_syslog_facility: /* nothing */
{
$$ = LOG_DAEMON;
}
{
$$ = $1;
}
;
;
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel print-time.");
}
}
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
"Redefining print-category.");
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel print-category.");
}
}
{
if (tmpres != ISC_R_SUCCESS) {
"Can't get current channel.");
}
if (tmpres == ISC_R_EXISTS) {
"Redefining print-severity.");
} else if (tmpres != ISC_R_SUCCESS) {
"Can't get set channel print-severity.");
}
}
;
{
}
;
{
/*
* XXX validate the channel name refers to a previously
* defined channel
*/
if (tmpres != ISC_R_SUCCESS) {
"Can't get current category.");
}
if (tmpres != ISC_R_SUCCESS) {
"Can't add new name to category.");
}
}
;
;
{
if (tmpres != ISC_R_SUCCESS) {
}
$$ = cat;
}
{
$$ = dns_c_cat_default;
}
| L_NOTIFY
{
$$ = dns_c_cat_notify;
}
;
/*
* Server Information
*/
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to create server list");
}
}
/*
* Check that this IP hasn't already bee used and if it has
* remove the old definition.
*/
sizeof(dns_c_addr_t)) == 0) {
break;
}
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to create server structure");
}
}
;
;
{
if (tmpres != ISC_R_NOTFOUND) {
"Redefining server bogus value");
}
}
{
if(tmpres != ISC_R_NOTFOUND) {
"Redefining server support-ixfr value");
}
}
{
if (tmpres != ISC_R_NOTFOUND) {
"Redefining server transfers value");
}
}
{
if (tmpres != ISC_R_NOTFOUND) {
"Redefining server transfer-format "
"value");
}
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to create keyid_list");
}
}
;
/*
* Address Matching
*/
{
dns_c_ipmatchlist_t *ml = 0;
if ($1 != NULL) {
if (tmpres != ISC_R_SUCCESS) {
&$1);
}
}
$$ = ml;
}
{
if (tmpres != ISC_R_SUCCESS) {
&$2);
}
}
if ($2 != NULL) {
}
$$ = ml;
}
;
{
if ($2 != NULL) {
dns_c_ipmatch_negate($2);
}
$$ = $2;
}
{
"Address match key element (%s) "
"referenced before defined", $2);
} else {
if (tmpres != ISC_R_SUCCESS) {
"Failed to create address match "
"key element for %s", $2);
}
}
$$ = ime;
}
;
{
switch (tmpres) {
case ISC_R_FAILURE:
break;
case ISC_R_NOMEMORY:
"Insufficient memory available.\n");
break;
case ISC_R_SUCCESS:
break;
}
$$ = ime;
}
{
if ($3 < 0 || $3 > 32) {
"mask bits (%d) out of range: "
"skipping", (int)$3);
$$ = NULL;
} else {
$1, $3);
switch (tmpres) {
case ISC_R_FAILURE:
"bad address match element.");
break;
case ISC_R_NOMEMORY:
"Insufficient memory available.\n");
break;
case ISC_R_SUCCESS:
break;
}
}
$$ = ime;
}
{
if ($1 > 255) {
"address out of range; skipping");
} else {
if ($3 < 0 || $3 > 32) {
"mask bits out of range; skipping");
$$ = NULL;
} else {
&ime,
$3);
switch (tmpres) {
case ISC_R_FAILURE:
"bad address match "
"element.");
break;
case ISC_R_NOMEMORY:
"Insufficient memory "
"available.\n");
break;
case ISC_R_SUCCESS:
break;
}
}
}
$$ = ime;
}
{
if ($2 != NULL) {
$2, NULL);
switch (tmpres) {
case ISC_R_SUCCESS:
break;
case ISC_R_NOMEMORY:
"Insufficient memory "
"available.\n");
break;
}
}
dns_c_ipmatchlist_delete(&$2);
$$ = ime;
}
;
{
if (tmpres == ISC_R_NOTFOUND) {
"Undefined acl ``%s'' referenced",
$1);
} else {
if (tmpres != ISC_R_SUCCESS) {
"Failed to create IPE-ACL\n");
}
}
$$ = elem;
}
;
/*
* Keys
*/
;
{
"Server keys key_id (%s) "
"referenced before defined", $1);
} else {
if (tmpres != ISC_R_SUCCESS) {
"Failed to create keyid\n");
}
}
}
;
/*
* The grammer in the man page implies a semicolon is not required before
* key_list_elements. We'll support either way.
*/
;
;
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to create keylist");
}
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to create key definition");
}
}
;
{
}
{
}
;
{
$$ = $2;
}
;
{
$$ = $2;
}
;
/*
* ACLs
*/
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to create acl %s", $2);
}
}
;
/*
* Zones
*/
{
$$ = $1;
}
;
/*
* ``type'' is no longer optional and must be the first statement in the
* zone block.
*/
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to create zone list");
}
}
if (tmpres != ISC_R_SUCCESS) {
}
}
zone,
if (tmpres != ISC_R_SUCCESS) {
}
}
}
{
"First statement in a zone definition must "
"be ``type''");
}
;
optional_zone_options_list: /* Empty */
;
{
} else {
if (tmpres != DNS_R_SUCCESS) {
"Unknown class assuming ``*''.");
}
}
$$ = cl;
}
optional_class: /* Empty */
{
$$ = dns_rdataclass_in;
}
;
{
$$ = dns_c_zone_master;
}
| L_SLAVE
{
$$ = dns_c_zone_slave;
}
| L_HINT
{
$$ = dns_c_zone_hint;
}
| L_STUB
{
$$ = dns_c_zone_stub;
}
{
$$ = dns_c_zone_forward;
}
;
;
;
{
if (tmpres == ISC_R_EXISTS) {
"redefining zone filename.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set zone file name");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining ixfr-base.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set zone ixfr_base.");
}
}
{
if (tmpres == ISC_R_EXISTS) {
"Redefining ixfr-tmp-file.");
} else if (tmpres != ISC_R_SUCCESS) {
"Failed to set zone ixfr_tmp-file.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone master's port.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone master port.");
}
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone masters ips.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone masters ips.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone transfer-source.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone transfer-source.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone check-names.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone check-names.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone allow-update.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone allow-update.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone allow-query.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone allow-query.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone allow-transfer.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone allow-transfer.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone forward.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone forward.");
}
}
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to create new zone "
"iplist");
}
} else {
iplist = $3;
}
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone forwarders.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone forwarders.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone "
"max-transfer-time-in.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone "
"max-transfer-time-in.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone max-ixfr-log-size.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone max-ixfr-log-size.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone notify.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone notify.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone maintain-ixfr-base.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone maintain-ixfr-base.");
}
}
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to create a zone pubkey");
}
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone pubkey.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone pubkey.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone also-notify.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone also-notify.");
}
}
{
switch (tmpres) {
case ISC_R_EXISTS:
"Redefining zone dialup.");
break;
case ISC_R_SUCCESS:
/* nothing */
break;
default:
"Failed to set zone dialup.");
}
}
;
;
;
{
$$.u.a = $1;
}
;
{
$$.u.a6 = $1;
}
{
$$ = $1;
}
{
$$ = $1;
}
;
;
opt_in_addr_list: /* nothing */
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to create new iplist");
}
$$ = list;
}
;
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to create new iplist");
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to append master address");
}
$$ = list;
}
{
if (tmpres != ISC_R_SUCCESS) {
"Failed to append master address");
}
$$ = $1;
}
;
{
$$ = dns_c_forw_only;
}
| L_FIRST
{
$$ = dns_c_forw_first;
}
;
;
/*
* Trusted Key statement
*/
{
if (tmpres == ISC_R_NOTFOUND) {
if (tmpres != ISC_R_SUCCESS) {
"Failed to create trusted key list.");
}
if (tmpres != ISC_R_SUCCESS) {
"Failed to set trusted keys");
}
}
;
;
{
if (tmpres != ISC_R_SUCCESS) {
}
if (tmpres != ISC_R_SUCCESS) {
}
if (tmpres != ISC_R_SUCCESS) {
}
}
;
/*
* Misc.
*/
{
if ($1 < 0 || $1 > 65535) {
"invalid IP port number '%d'; setting port to 0",
(int)$1);
$1 = 0;
} else
$$ = htons($1);
}
;
;
%%
const char *fmt, ...);
const char *fmt, ...);
static int intuit_token(const char *string);
static isc_result_t keyword_init(void);
static void init_action(void);
static void yyerror(const char *);
static int yylex(void);
int yyparse(void);
int lasttoken;
/*
* Definition of all unique keyword tokens to be recognised by the
* lexer. All the ``L_'' tokens defined in parser.y must be defined here too.
*/
struct token
{
char *token;
int yaccval;
};
static struct token keyword_tokens [] = {
{ "{", L_LBRACE },
{ "}", L_RBRACE },
{ ";", L_EOS },
{ "/", L_SLASH },
{ "!", L_BANG },
{ "acl", L_ACL },
{ "address", L_ADDRESS },
{ "algorithm", L_ALGID },
{ "allow", L_ALLOW },
{ "allow-query", L_ALLOW_QUERY },
{ "allow-transfer", L_ALLOW_TRANSFER },
{ "allow-update", L_ALLOW_UPDATE },
{ "also-notify", L_ALSO_NOTIFY },
{ "auth-nxdomain", L_AUTH_NXDOMAIN },
{ "blackhole", L_BLACKHOLE },
{ "bogus", L_BOGUS },
{ "category", L_CATEGORY },
{ "class", L_CLASS },
{ "channel", L_CHANNEL },
{ "check-names", L_CHECK_NAMES },
{ "cleaning-interval", L_CLEAN_INTERVAL },
{ "controls", L_CONTROLS },
{ "coresize", L_CORESIZE },
{ "datasize", L_DATASIZE },
{ "deallocate-on-exit", L_DEALLOC_ON_EXIT },
{ "debug", L_DEBUG },
{ "default", L_DEFAULT },
{ "dialup", L_DIALUP },
{ "directory", L_DIRECTORY },
{ "dump-file", L_DUMP_FILE },
{ "dynamic", L_DYNAMIC },
{ "expert-mode", L_EXPERT_MODE },
{ "fail", L_FAIL },
{ "fake-iquery", L_FAKE_IQUERY },
{ "false", L_FALSE },
{ "fetch-glue", L_FETCH_GLUE },
{ "file", L_FILE },
{ "files", L_FILES },
{ "first", L_FIRST },
{ "forward", L_FORWARD },
{ "forwarders", L_FORWARDERS },
{ "group", L_GROUP },
{ "has-old-clients", L_HAS_OLD_CLIENTS },
{ "heartbeat-interval", L_HEARTBEAT },
{ "hint", L_HINT },
{ "host-statistics", L_HOSTSTATS },
{ "if-no-answer", L_IF_NO_ANSWER },
{ "if-no-domain", L_IF_NO_DOMAIN },
{ "ignore", L_IGNORE },
{ "include", L_INCLUDE },
{ "inet", L_INET },
{ "interface-interval", L_INTERFACE_INTERVAL },
{ "ixfr-base", L_FILE_IXFR },
{ "ixfr-tmp-file", L_IXFR_TMP },
{ "key", L_SEC_KEY },
{ "keys", L_KEYS },
{ "listen-on", L_LISTEN_ON },
{ "logging", L_LOGGING },
{ "maintain-ixfr-base", L_MAINTAIN_IXFR_BASE },
{ "many-answers", L_MANY_ANSWERS },
{ "master", L_MASTER },
{ "masters", L_MASTERS },
{ "max-ixfr-log-size", L_MAX_LOG_SIZE_IXFR },
{ "max-ncache-ttl", L_MAX_NCACHE_TTL },
{ "max-transfer-time-in", L_MAX_TRANSFER_TIME_IN },
{ "memstatistics-file", L_MEMSTATS_FILE },
{ "multiple-cnames", L_MULTIPLE_CNAMES },
{ "name", L_NAME },
{ "named-xfer", L_NAMED_XFER },
{ "no", L_NO },
{ "notify", L_NOTIFY },
{ "null", L_NULL_OUTPUT },
{ "one-answer", L_ONE_ANSWER },
{ "only", L_ONLY },
{ "order", L_ORDER },
{ "options", L_OPTIONS },
{ "owner", L_OWNER },
{ "perm", L_PERM },
{ "pid-file", L_PIDFILE },
{ "port", L_PORT },
{ "print-category", L_PRINT_CATEGORY },
{ "print-severity", L_PRINT_SEVERITY },
{ "print-time", L_PRINT_TIME },
{ "pubkey", L_PUBKEY },
{ "query-source", L_QUERY_SOURCE },
{ "rrset-order", L_RRSET_ORDER },
{ "recursion", L_RECURSION },
{ "response", L_RESPONSE },
{ "secret", L_SECRET },
{ "server", L_SERVER },
{ "severity", L_SEVERITY },
{ "size", L_SIZE },
{ "slave", L_SLAVE },
{ "sortlist", L_SORTLIST },
{ "stacksize", L_STACKSIZE },
{ "statistics-file", L_STATS_FILE },
{ "statistics-interval", L_STATS_INTERVAL },
{ "stub", L_STUB },
{ "support-ixfr", L_SUPPORT_IXFR },
{ "syslog", L_SYSLOG },
{ "topology", L_TOPOLOGY },
{ "transfer-format", L_TRANSFER_FORMAT },
{ "transfer-source", L_TRANSFER_SOURCE },
{ "transfers", L_TRANSFERS },
{ "transfers-in", L_TRANSFERS_IN },
{ "transfers-out", L_TRANSFERS_OUT },
{ "transfers-per-ns", L_TRANSFERS_PER_NS },
{ "true", L_TRUE },
{ "trusted-keys", L_TRUSTED_KEYS },
{ "type", L_TYPE },
{ "unix", L_UNIX },
{ "unlimited", L_UNLIMITED },
{ "use-id-pool", L_USE_ID_POOL },
{ "use-ixfr", L_USE_IXFR },
{ "version", L_VERSION },
{ "versions", L_VERSIONS },
{ "warn", L_WARN },
{ "yes", L_YES },
{ "zone", L_ZONE },
{ NULL, 0 }
};
static struct token class_symbol_tokens[] = {
{ "IN", dns_rdataclass_in },
#if 0 /* XXX expand */
{ "CHAOS", dns_rdataclass_chaos },
{ "HS", dns_rdataclass_hs },
{ "HESIOD", dns_rdataclass_hs },
#endif
{ "ANY", dns_rdataclass_any },
{ "NONE", dns_rdataclass_none },
{ NULL, 0 }
};
static void
init_action(void)
{
}
/*
* XXX Need a parameter to specify where error messages should go (syslog,
* statments as appropriate.
*/
{
const char *funcname = "dns_parse_namedconf";
/* Lock down whole parser. */
return (ISC_R_UNEXPECTED);
}
debug_lexer++;
}
#if 0
#endif
/*
* This memory context is only used by the lexer routines (and must
* stay that way). Any memory that must live past the return of
* yyparse() must be allocated via the 'mem' parameter to this
* function.
*/
if (res != ISC_R_SUCCESS) {
funcname);
goto done;
}
res = keyword_init();
if (res != ISC_R_SUCCESS) {
funcname);
goto done;
}
if (res != ISC_R_SUCCESS) {
funcname);
goto done;
}
if (res != ISC_R_SUCCESS) {
funcname);
goto done;
}
if (res != ISC_R_SUCCESS) {
goto done;
}
if (yyparse() != 0) {
res = ISC_R_FAILURE;
/* Syntax errors in the config file make it very difficult
* to clean up memory properly (which causes assertion
* failure when the memory manager is destroyed).
*/
} else {
res = ISC_R_SUCCESS;
}
done:
return (res);
}
/***
*** PRIVATE
***/
static isc_result_t
keyword_init(void)
{
&keywords) == ISC_R_SUCCESS);
/* Stick all the keywords into the main symbol table. */
}
/* Now the class names */
}
return (ISC_R_SUCCESS);
}
static int
yylex(void)
{
int options = (ISC_LEXOPT_EOF |
switch(res) {
case ISC_R_SUCCESS:
break;
case ISC_R_EOF:
res = 0;
break;
case ISC_R_UNBALANCED:
"%s: %d: unbalanced parentheses",
(int)isc_lex_getsourceline(mylexer));
res = -1;
break;
case ISC_R_NOSPACE:
"%s: %d: token too big.",
(int)isc_lex_getsourceline(mylexer));
res = -1;
break;
case ISC_R_UNEXPECTEDEND:
"%s: %d: unexpected EOF",
(int)isc_lex_getsourceline(mylexer));
res = -1;
break;
default:
"%s: %d unknown lexer error (%d)",
(int)isc_lex_getsourceline(mylexer),
(int)res);
res = -1;
break;
}
lastyylval = yylval;
return (res);
}
static char *
static char buffer[1024];
int i;
/* Yacc keeps token numbers above 128, it seems. */
if (token < 128) {
if (token == 0)
else
>= sizeof buffer) {
abort();
}
} else {
switch (token) {
case L_STRING:
sizeof buffer) {
abort();
}
break;
case L_QSTRING:
sizeof buffer) {
abort();
}
break;
case L_IP6ADDR:
break;
case L_IP4ADDR:
break;
case L_INTEGER:
break;
case L_END_INCLUDE:
break;
default:
break;
}
(int)token);
} else {
sizeof buffer - 1);
}
}
}
return (buffer);
}
static void
{
static char message[20480];
/*
* We can't get a trace of the include files we may be nested in
* (lex.c has the structures hidden). So we only report the current
* file.
*/
filename = "(none)";
}
abort();
}
/* XXX this needs to use the log system instead of stdio. */
(void) is_warning; /* lint happiness */
if (print_last_token) {
} else {
}
}
/*
* For reporting items that are semantic, but not syntactic errors
*/
static void
{
}
static void
{
}
static void
{
}
static int
{
int res = -1;
const char *tokstring;
char tmpident [2];
case isc_tokentype_unknown:
if (debug_lexer) {
}
res = -1;
break;
case isc_tokentype_special:
case isc_tokentype_string:
} else {
}
if (debug_lexer) {
}
if (res != ISC_R_SUCCESS) {
} else {
}
break;
case isc_tokentype_number:
if(debug_lexer) {
}
break;
case isc_tokentype_qstring:
res = -1;
} else {
}
if (debug_lexer) {
}
break;
case isc_tokentype_eof:
/* the only way to tell that we
* closed the main file and not an included file
*/
if (debug_lexer) {
}
res = 0;
} else {
if (debug_lexer) {
}
res = L_END_INCLUDE;
}
break;
case isc_tokentype_initialws:
if (debug_lexer) {
}
res = -1;
break;
case isc_tokentype_eol:
if (debug_lexer) {
}
res = -1;
break;
case isc_tokentype_nomore:
if (debug_lexer) {
}
res = -1;
break;
}
return (res);
}
static int
intuit_token(const char *string)
{
int resval;
} else {
resval = -1;
} else {
}
}
return (resval);
}
/*
* Conversion Routines
*/
static isc_boolean_t
int c, units_done = 0;
isc_uint32_t result = 0L;
if (units_done)
return (0);
if (isdigit(c)) {
result *= 10;
result += (c - '0');
} else {
switch (c) {
case 'k':
case 'K':
result *= 1024;
units_done = 1;
break;
case 'm':
case 'M':
units_done = 1;
break;
case 'g':
case 'G':
units_done = 1;
break;
default:
return (0);
}
}
}
return (1);
}
static isc_boolean_t
{
#if 1
/* XXX this need to be properly fixed for IPv6 */
return ISC_FALSE;
}
return ISC_TRUE;
#else
(void)string;
(void)addr;
return ISC_FALSE;
#endif
}
static isc_boolean_t
{
const char *p = string;
int dots = 0;
char dot = '.';
while (*p) {
return (ISC_FALSE);
} else if (!isdigit(*p)) {
dots++;
}
p++;
}
if (dots > 3) {
return (ISC_FALSE);
} else if (dots < 3) {
if (dots == 1) {
} else {
return (ISC_FALSE);
}
} else if (dots == 2) {
} else {
return (ISC_FALSE);
}
}
} else {
return (ISC_FALSE);
}
return ISC_FALSE;
}
return ISC_TRUE;
}