zconf.c revision c52235e52ee12e4d15f808ac06608584257f6479
1516N/A/**************************************************************** 181N/A** Most of the code is from the SixXS Heartbeat Client 181N/A** written by Jeroen Massar <jeroen@sixxs.net> 181N/A** New config types and many code changes by Holger Zuleger 181N/A** Copyright (c) Aug 2005, Jeroen Massar. 181N/A** Copyright (c) Aug 2005 - Apr 2010, Holger Zuleger. 181N/A** This software is open source. 181N/A** Redistribution and use in source and binary forms, with or without 181N/A** modification, are permitted provided that the following conditions 181N/A** Redistributions of source code must retain the above copyright notice, 181N/A** this list of conditions and the following disclaimer. 2690N/A** Redistributions in binary form must reproduce the above copyright notice, 2701N/A** this list of conditions and the following disclaimer in the documentation 2690N/A** and/or other materials provided with the distribution. 1715N/A** Neither the name of Jeroen Masar or Holger Zuleger nor the 1715N/A** names of its contributors may be used to endorse or promote products 1715N/A** derived from this software without specific prior written permission. 1715N/A** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2690N/A** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 289N/A** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2690N/A** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 289N/A** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 430N/A** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 289N/A** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2690N/A** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 289N/A** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 181N/A** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1859N/A** POSSIBILITY OF SUCH DAMAGE. 181N/A****************************************************************/ 2690N/A/***************************************************************** 2690N/A** private (static) variables 2690N/A*****************************************************************/ 2690N/A 0,
/* noexec cmdline parameter */ 2701N/A void *
var;
/* pointer to the parameter variable */ 2701N/A const void *
var2;
/* pointer to a second parameter variable */ 2701N/A /* this is a ugly hack needed by cmpconfig () */ /* { "ZSK_algo", 1, CONF_ALGO, &def.z_algo }, ZSK algo removed (set to same as ksk) */ {
"ZSK_algo",
first,
98,
CONF_ALGO, &
def.
k2_algo },
/* if someone using it already, map the algo to the additional key algorithm *//***************************************************************** ** private (static) function deklaration and definition *****************************************************************/ return val ?
"True" :
"False";
// set_varptr ("zsk_algo", &cp->z_algo, cp2 ? &cp2->z_algo: NULL); for (p =
buf;
isspace (*p); p++ )
/* Ignore leading white space */ /* Ignore comments and emtpy lines */ /* Get the end of the first argument */ while ( p <
end && !
ISDELIM (*p) )
/* Skip until delim */ *p++ =
'\0';
/* Terminate this argument */ while ( p <
end &&
ISDELIM (*p) )
/* Skip delim chars */ val = p;
/* Start of the value */ /* If starting with quote, skip until next quote */ if ( *p ==
'"' || *p ==
'\'' )
p++;
/* Find next quote */ while ( p <=
end && *p && *p != *
val )
val++;
/* Skip the first quote */ else /* Otherwise check if there is any comment char at the end */ do /* Chop off white space before comment */ /* Otherwise it is already terminated above */ if ( *
val ==
'u' || *
val ==
'U' )
error (
"Illegal algorithm \"%s\" " error (
"Illegal serial no format \"%s\" " error (
"Illegal NSEC3 format \"%s\" " fatal (
"Illegal configuration type in line %d.\n",
line);
error (
"Unknown configuration statement: %s \"%s\"\n",
tag,
val);
fprintf (
fp,
"#\tZKT config file for version %d.%02d\n",
if ( **(
char **)
cp->
var !=
'\0' )
for ( p = *(
char **)
cp->
var; *p; p++ )
lval = *(
ulong*)
cp->
var;
/* in that case it should be of type ulong */ fprintf (
fp,
"\t# (UnixTime|Incremental)\n");
/***************************************************************** ** public function definition *****************************************************************/ /***************************************************************** ** loadconfig (file, conf) ** Loads a config file into the "conf" structure pointed to by "z". ** If "z" is NULL then a new conf struct will be dynamically ** If no filename is given the conf struct will be initialized ** with the builtin default config *****************************************************************/ if ( z ==
NULL )
/* allocate new memory for zconf_t */ dbg_val0(
"loadconfig_fromstr (NULL)\n");
/* str is const, so we have to copy it into a new buffer */ fatal (
"loadconfig_fromstr: Out of memory");
/***************************************************************** ** duplicate config struct and return a ptr to the new struct *****************************************************************/ /***************************************************************** ** free memory for config struct and return a NULL ptr *****************************************************************/ /***************************************************************** ** setconfigpar (entry, pval) *****************************************************************/ *((
long *)c->
var) = *((
long *)
pval);
/***************************************************************** ** printconfig (fname, config) *****************************************************************/ error (
"Could not open config file \"%s\" for writing\n",
fname);
if (
iscompatible (
cp) )
/* is parameter compatible to current version? */ /***************************************************************** ** printconfigdiff (fname, conf_a, conf_b) *****************************************************************/ error (
"Could not open config file \"%s\" for writing\n",
fname);
if (
iscmdline (
cp) )
/* skip command line parameter */ /***************************************************************** *****************************************************************/ ret =
fprintf (
stderr,
"random device without enough entropie used for KSK generation \n");
ret =
fprintf (
stderr,
"random device without enough entropie used for ZSK generation\n");
fprintf (
stderr,
"While the maximum is 520 bits of salt, it's not recommended to use more than 128 bits.\n");
fprintf (
stderr,
"Signature should be valid for at least 1 day and no longer than 3 month (12 weeks)\n");
ret =
fprintf (
stderr,
"The max TTL is unknown which results in suboptimal key rollover.\n");
fprintf (
stderr,
"Please set max_ttl to the maximum ttl used in the zone (run zkt-conf -w zone.db)\n");
ret =
fprintf (
stderr,
"Max TTL (%ld) should be less or equal signature validity (%ld)\n",
// if ( z->resign > (z->sigvalidity*5/6) - (max_ttl + z->proptime) )