Skip to content
Snippets Groups Projects
Commit ac51ea03 authored by Marek Vavrusa's avatar Marek Vavrusa
Browse files

Configurable zone semantic checks.

Semantic checks may be enabled for all zones (in 'zones' section)
or specifically in each zone section.

See samples/knot.conf.sample

Commit refs #736.
parent 5b89c304
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,14 @@ system {
# Section 'zones' contains information about zones to be served.
zones {
# Shared options for all listed zones
#
# Enable semantic checks for all zones (if 'on')
# Possible values: on|off
# Default value: off
semantic-checks off;
# Zone entry
#
# Format: <zone-name> { file "<path-to-zone-file>"; }
......@@ -50,6 +58,11 @@ zones {
# it is considered relative to the current directory from which the server
# was started.
file "samples/example.com.zone";
# Enable zone semantic checks
# Possible values: on|off
# Default value: off
semantic-checks on;
}
}
......
......@@ -67,6 +67,7 @@ key return KEY;
zones return ZONES;
file return FILENAME;
semantic-checks return SEMANTIC_CHECKS;
interfaces return INTERFACES;
address return ADDRESS;
......@@ -87,6 +88,14 @@ notice { cf_lval.i = LOG_MASK(LOG_NOTICE); return LOG_LEVEL; }
warning { cf_lval.i = LOG_MASK(LOG_WARNING); return LOG_LEVEL; }
error { cf_lval.i = LOG_MASK(LOG_ERR); return LOG_LEVEL; }
on|off {
cf_lval.i = 0;
if (strcmp(yytext, "on") == 0) {
cf_lval.i = 1;
}
return BOOL;
}
{DIGIT}+ {
cf_lval.i = atoi(yytext);
return NUM;
......
......@@ -35,11 +35,13 @@ static conf_log_map_t *this_logmap = 0;
%token END INVALID_TOKEN
%token <t> TEXT
%token <i> NUM
%token <i> BOOL
%token SYSTEM IDENTITY VERSION STORAGE KEY
%token <alg> TSIG_ALGO_NAME
%token ZONES FILENAME
%token SEMANTIC_CHECKS
%token INTERFACES ADDRESS PORT
%token <t> IPA
......@@ -140,11 +142,13 @@ zone_start: TEXT {
zone:
zone_start '{'
| zone FILENAME TEXT ';' { this_zone->file = $3; }
| zone SEMANTIC_CHECKS BOOL ';' { this_zone->enable_checks = $3; }
;
zones:
ZONES '{'
| zones zone '}'
| zones SEMANTIC_CHECKS BOOL ';' { new_config->zone_checks = $3; }
;
log_prios_start: {
......
......@@ -216,6 +216,11 @@ static int conf_process(conf_t *conf)
WALK_LIST (n, conf->zones) {
conf_zone_t *zone = (conf_zone_t*)n;
// Default policy for semantic checks
if (conf->zone_checks) {
zone->enable_checks = 1;
}
// Normalize zone filename
zone->file = strcpath(zone->file);
......@@ -392,6 +397,9 @@ conf_t *conf_new(const char* path)
init_list(&c->zones);
init_list(&c->hooks);
// Defaults
c->zone_checks = 0;
return c;
}
......
......@@ -81,6 +81,7 @@ typedef struct {
enum dnslib_rr_class cls; /*!< Zone class (IN or CH). */
char *file; /*!< Path to a zone file. */
char *db; /*!< Path to a database file. */
int enable_checks; /*!< Semantic checks for parser.*/
} conf_zone_t;
/*!
......@@ -146,6 +147,7 @@ typedef struct conf_t {
*/
list zones; /*!< List of zones. */
int zones_count; /*!< Count of zones. */
int zone_checks; /*!< Semantic checks for parser.*/
/*
* Implementation specifics
......
......@@ -249,9 +249,11 @@ int execute(const char *action, char **argv, int argc, pid_t pid, int verbose,
// Prepare command
char* cmd = 0;
const char *cmd_str = "%s -o %s %s%s %s";
const char *cmd_str = "%s %s%s-o %s %s %s";
rc = asprintf(&cmd, cmd_str, ZONEPARSER_EXEC,
zone->db, verbose ? "-v " : "",
zone->enable_checks ? "-s " : "",
verbose ? "-v " : "",
zone->db,
zone->name, zone->file);
// Execute command
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment