]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
debug override date config option.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 9 Aug 2007 15:16:25 +0000 (15:16 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Thu, 9 Aug 2007 15:16:25 +0000 (15:16 +0000)
git-svn-id: file:///svn/unbound/trunk@505 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
doc/example.conf
util/config_file.c
util/config_file.h
util/configlexer.lex
util/configparser.y
validator/val_sigcrypt.c

index 06f9f4105b03fae7e7f35a046a532dfe38ff50d9..56295e5a4bd6f30e27613b9c5497c5e83ee512d0 100644 (file)
@@ -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).
index 30db1943706520939447171a1ff1e3fe5b805d33..caabbf9ded3db01d8bd41c2f97dac0457f0b351b 100644 (file)
@@ -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 
index 2be1ff78459a8812fb70ded0f5797d9132469dc7..5d831a4b0b4579497a947c3b99e9d30ee0a8de57 100644 (file)
@@ -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;
+}
index d70f33c28198ceadfec6f642ec635646d71bdb45..42f383ad3f986aa4e224070281a395184044cf8d 100644 (file)
@@ -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
  */
index 5f128ec4cb4ef0ac94fd16580e1e8a4854eaa831..775797412021a39a42dd124c7134f99f6662b28e 100644 (file)
@@ -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 */
index fa2a57bfd4c33d7daeee01729fb977647f6aa59c..bc921b930eee18256a8aa00f8cc008b59e36d7ec 100644 (file)
@@ -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));
index 614310d7a5c59f24ff79cd393bedf349d2c06463..f1a2e6e8409df9a8482102f9ae5803983d83685d 100644 (file)
@@ -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) {