mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-01-02 21:09:35 -05:00
debug override date config option.
git-svn-id: file:///svn/unbound/trunk@505 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
9ada9f1093
commit
5166d65ea2
7 changed files with 60 additions and 4 deletions
|
|
@ -4,6 +4,7 @@
|
|||
- added debug heap size print to memory printout.
|
||||
- typo fixup in worker.c
|
||||
- -R needed on solaris.
|
||||
- validator override option for date check testing.
|
||||
|
||||
8 August 2007: Wouter
|
||||
- ldns _raw routines created (in ldns trunk).
|
||||
|
|
|
|||
|
|
@ -162,6 +162,11 @@ server:
|
|||
# (These examples are from August 2007 and may not be valid anymore).
|
||||
# trust-anchor: "nlnetlabs.nl. DNSKEY 257 3 5 AQPzzTWMz8qSWIQlfRnPckx2BiVmkVN6LPupO3mbz7FhLSnm26n6iG9N Lby97Ji453aWZY3M5/xJBSOS2vWtco2t8C0+xeO1bc/d6ZTy32DHchpW 6rDH1vp86Ll+ha0tmwyy9QP7y2bVw5zSbFCrefk8qCUBgfHm9bHzMG1U BYtEIQ=="
|
||||
# trust-anchor: "jelte.nlnetlabs.nl. DS 42860 5 1 14D739EB566D2B1A5E216A0BA4D17FA9B038BE4A"
|
||||
|
||||
# Override the date for validation with a specific fixed date.
|
||||
# Do not set this unless you are debugging signature inception
|
||||
# and expiration. "" or "0" turns the feature off.
|
||||
# val-override-date: ""
|
||||
|
||||
# Stub zones.
|
||||
# Create entries like below, to make all queries for 'example.com' and
|
||||
|
|
|
|||
|
|
@ -258,3 +258,26 @@ cfg_strlist_insert(struct config_strlist** head, char* item)
|
|||
*head = s;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
cfg_convert_timeval(const char* str)
|
||||
{
|
||||
uint32_t t;
|
||||
struct tm tm;
|
||||
memset(&tm, 0, sizeof(tm));
|
||||
if(sscanf(str, "%4d%2d%2d%2d%2d%2d", &tm.tm_year, &tm.tm_mon,
|
||||
&tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6)
|
||||
return 0;
|
||||
tm.tm_year -= 1900;
|
||||
tm.tm_mon--;
|
||||
/* Check values */
|
||||
if (tm.tm_year < 70) return 0;
|
||||
if (tm.tm_mon < 0 || tm.tm_mon > 11) return 0;
|
||||
if (tm.tm_mday < 1 || tm.tm_mday > 31) return 0;
|
||||
if (tm.tm_hour < 0 || tm.tm_hour > 23) return 0;
|
||||
if (tm.tm_min < 0 || tm.tm_min > 59) return 0;
|
||||
if (tm.tm_sec < 0 || tm.tm_sec > 59) return 0;
|
||||
/* call ldns conversion function */
|
||||
t = mktime_from_utc(&tm);
|
||||
return t;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,6 +203,13 @@ void config_delete(struct config_file* config);
|
|||
*/
|
||||
int cfg_strlist_insert(struct config_strlist** head, char* item);
|
||||
|
||||
/**
|
||||
* Convert 14digit to time value
|
||||
* @param str: string of 14 digits
|
||||
* @return time value or 0 for error.
|
||||
*/
|
||||
uint32_t cfg_convert_timeval(const char* str);
|
||||
|
||||
/**
|
||||
* Used during options parsing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ version{COLON} { YDOUT; return VAR_VERSION;}
|
|||
module-conf{COLON} { YDOUT; return VAR_MODULE_CONF;}
|
||||
trust-anchor-file{COLON} { YDOUT; return VAR_TRUST_ANCHOR_FILE;}
|
||||
trust-anchor{COLON} { YDOUT; return VAR_TRUST_ANCHOR;}
|
||||
val-override-date{COLON} { YDOUT; return VAR_VAL_OVERRIDE_DATE;}
|
||||
{NEWLINE} { LEXOUT(("NL\n")); cfg_parser->line++;}
|
||||
|
||||
/* Quoted strings. Strip leading and ending quotes */
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ extern struct config_parser_state* cfg_parser;
|
|||
%token VAR_FORWARD_ZONE VAR_FORWARD_HOST VAR_FORWARD_ADDR
|
||||
%token VAR_DO_NOT_QUERY_ADDRESS VAR_HIDE_IDENTITY VAR_HIDE_VERSION
|
||||
%token VAR_IDENTITY VAR_VERSION VAR_HARDEN_GLUE VAR_MODULE_CONF
|
||||
%token VAR_TRUST_ANCHOR_FILE VAR_TRUST_ANCHOR
|
||||
%token VAR_TRUST_ANCHOR_FILE VAR_TRUST_ANCHOR VAR_VAL_OVERRIDE_DATE
|
||||
|
||||
%%
|
||||
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
|
||||
|
|
@ -114,7 +114,7 @@ content_server: server_num_threads | server_verbosity | server_port |
|
|||
server_do_not_query_address | server_hide_identity |
|
||||
server_hide_version | server_identity | server_version |
|
||||
server_harden_glue | server_module_conf | server_trust_anchor_file |
|
||||
server_trust_anchor
|
||||
server_trust_anchor | server_val_override_date
|
||||
;
|
||||
stubstart: VAR_STUB_ZONE
|
||||
{
|
||||
|
|
@ -486,6 +486,24 @@ server_module_conf: VAR_MODULE_CONF STRING
|
|||
cfg_parser->cfg->module_conf = $2;
|
||||
}
|
||||
;
|
||||
server_val_override_date: VAR_VAL_OVERRIDE_DATE STRING
|
||||
{
|
||||
OUTYY(("P(server_val_override_date:%s)\n", $2));
|
||||
if(strlen($2) == 0 || strcmp($2, "0") == 0) {
|
||||
cfg_parser->cfg->val_date_override = 0;
|
||||
} else if(strlen($2) == 14) {
|
||||
cfg_parser->cfg->val_date_override =
|
||||
cfg_convert_timeval($2);
|
||||
if(!cfg_parser->cfg->val_date_override)
|
||||
yyerror("bad date/time specification");
|
||||
} else {
|
||||
if(atoi($2) == 0)
|
||||
yyerror("number expected");
|
||||
cfg_parser->cfg->outgoing_num_ports = atoi($2);
|
||||
}
|
||||
free($2);
|
||||
}
|
||||
;
|
||||
stub_name: VAR_NAME STRING
|
||||
{
|
||||
OUTYY(("P(name:%s)\n", $2));
|
||||
|
|
|
|||
|
|
@ -659,9 +659,10 @@ check_dates(struct val_env* ve, uint8_t* expi_p, uint8_t* incep_p)
|
|||
incep = ntohl(incep);
|
||||
|
||||
/* get current date */
|
||||
if(ve->date_override)
|
||||
if(ve->date_override) {
|
||||
now = ve->date_override;
|
||||
else now = (int32_t)time(0);
|
||||
verbose(VERB_ALGO, "date override option %d", (int)now);
|
||||
} else now = (int32_t)time(0);
|
||||
|
||||
/* check them */
|
||||
if(incep - expi > 0) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue