S?~3uuv=S($d5azQO8P}{z2RlExY7K%oYo8c
zMFPmv0|fV>bi%!|hD@D$xebObRg6rkX$>@fz3tgR@b%ilJT9RXM8T&qzl2=vFX6sF!CcC(ZMCv2JU|h|2^uBn`n6|D%Q(y!>*&lF+h5gCsCcremE%vS>akYcVEd
zrs18PU_3>r0~9>W>xpF_g$*I1b5Iy(`R&6vv2vn=KfeRN
z$EH)keiJJpB;r+0$%1r0A9S_w(<2Y^N06M%xh&a=7F!}k6dqw+wPMUp;Bp*O2Gcc<
zFn&FH4Hm}WH5FpHeFg1ZF`_b2`N)%JPzHWfO*0QeWyxpEALGQvFH3f({DhXX@4bjf
z!qG88NulHgZOBtmbw>ejWgnJOlbYp7Tu>CLIq)VmP`)aFE
z0|CS>)j=?I>w%DYE9+ioMrPb3^tns`S=iYZ0Xhjy@%9FKkhz
zI+nU&nqoUCXSwlC+`qyxoeATxN+F+)nXWli{hZ=p`A%)|s$k>8MEom?;rHHj332x0
z7rQa=cCbXS*G#Z6?fv1S@8GS$?6*oo!O%*gncf1ccawCo6Ij!b1-8QXWq{tS3xDd+
z;mGdIk!4jRJ-3`LlwzDi6xpIuN1bgexGwXGiYr)2M1d1z+kLnuqgXg(NpX_!$B1-a
zKN_mM$}%P-{-&_q_H7LCUSD51chQ0dy{&9GdknC>IXu&!hu^#M<*fHh==e5Ie#vS{
zX$Q&=zLw^j(=VS+nwq%4Y0GP@7c5vZOx^5)7z8bX31<{9QI5Z#87~!+qR%z_=td%7
z#rNdc45IF&Cb?Y^+8!0)!)o`8C+}F`thVx9AcXLAU*~{O+j9$Fud6=Ux}AP0K%$I0
zE+zc@xvHW>VZfC>r%UiCa+OGQ?GlVyU{;rw5^o41<#c1zs&w}(ZIC`gf%Rv~%9
zOfK(n=byF~I+#Bp)-7T(OLwguP-6kPWLoT$?NPWrl}pMrTkydMu?>5}J}z{gA@7YS
zP4WCn{m1w`1=99~flIq9IS2gNsuyOF!}d$oQ_>mpV8F{|2Y4mEo^&kt
zX00|BgRSaT`gL2PtYxi_3U!%>p
zjSF1n9ROBX8F`7jXcDjOe7MCv}a1$5~bZOc=*jIcp=cdW`yXQ#wKp<-n7>lYu)--uZcjDlzOrS@PHbHQ1ZbHp1
z8#gqmQ(+FG-(lk^TOw+D&^YgGrFDjZHIG>`>}EwbKJrBmGkh+$YcVXd&vu0!QyagY
zeIULr$OOtXOI}2vp;lrRGQT?2(>&UE9c;9oBuGauTxquW0%FX0`E4Lytb4KTW7&Jg
z4_Ee}xm=jqypI$&O9xI{?ifpG=I`QH5_YC?0nAPm#`p!#d?!L%WBA^tZU~HU)~SIZ
zA~vEwh}a0F;Pvf&7D3uBVe7WeqK3G&0oNAYH%u)Su^Aj-FOUam3VtoA
z`a~x;2Rd!-1@J;8Q%1++GaKO;P{N`lq_uQ*um~oYhI+(R7YEB$_{aw&`MEC}DwfDl<>j-+dBsu?Qusg}LgLAj&pZ
zXf)F+EE5P0&fb_DBsp0J+;m$Q=De$YYXw;_Byc3<4lYWr)N_%WY8r9L_Z%T2R@yyu
zKE`4{`=+lZDl8|_GmFBFl(Op(mjH+pnx=SHid4*!Oru-*mQT}AD}BiO7!5{$J?NAOiq+9T_Q6=PF3
zp<6?oJ9*RoxUIs)_7YqBm8ja--AS;~$nNl*LPO6yyz*JB(fICC`G*#FB$PVJ#vcUH
zLgYb3Z13frz2?qScH3b+*SUz=4Jm$r>D9M6T3gZ-kh~j-U19@d5oj)HSA0v*gl6EZ
z)4nmS@RU9I5Fk>Tr|?c7XHG_^I_R8%QZ5;PQAih`hsqFpt#q}4CGs(;$Nm>#`i4!V
zlF)|!{`Ap8vKej5tSvRjV0l;B)$Q@Hf$@r6Z7_E!Z{MDaWIWCf8%GR5h$%i7}sf@R-pDT>{y$2a|k6bQ%O6OCK#`rXLcyUQqkU=~1
zYoUKA;17i!#0dueUg&?P-Cu^&aDM>-s2E#70E!SZsIj>HOKQD`9W56h7d0;@*Z>Wn
zX77A|HI5p1&*ccQbEbY+B-HN75GQ*VM^lK?y$}^gdsB6YvmW67&K)&C1M<@Oew?)Z
zJu~Px?)xis0EzqG_v4+YAC6tr(C$gUpTqng!r}RS?tjDic?|RyJiPZz4<`HnZyqq{
zZ}2?4WB4;3F!=ut&mX?|w|#zg1%Jl#?=Ioq*Z1K={WE@?r~&d&Gbd_2w4W`*eZ2it
z1N2}_HME~PsG%89-^+Emj|xPD&!>M5`QOI@B%$W!ko&y9PjtO|p8^5qP&5z^2f!9;=i+4W
zZwWtb|1SxDV7m9UBNXEJUr_z#oqt00C%^oxQ~!YK@8CT6|DWI}o7g}dTz)gc&oYGu
z_y+`k0`P}YzZqK1-qzUe?=AgXK>mY7@SlA5-*n>O1wd@gjGZk1tI;1K`X99Xdu%@=
z|DUu4|LN`Kf5Y}S_Wskz|1i|k`&@>a{w*4g-xBg4EcNs0{~D8jio`!v%lmc7%*7Pq
z$Rwq%LM>xy@8s-c>Ii+|OwG#<;$psElJ0MLJ45a5B<~kECP{uU5CjBrfbah}c{n)k
zpDWs%{rw|h;eXYlmyQr~G$1tx2o3nhhnky4+wlntiSNx|9Duk{z~KE;=2#5ztBJ+4vzau`Bxf{kLN$-fk503rv57*
zh?DPEJ}~#MG!W=lJ$N2!|6k?ZL;g=1kc0bSarg@#kQ)sAPZ|iwbKi^nl@A02|Dx~x
z*oOfAt2|y#o?qqh{(=Prconf->dist_cmd != NULL);
+ assert ( what == 1 || what == 2 );
+
+ if ( zp->conf->dist_cmd == NULL )
+ return 0;
if ( !is_exec_ok (zp->conf->dist_cmd) )
{
@@ -119,20 +127,40 @@ int dist_and_reload (const zone_t *zp)
return -1;
}
+ view = ""; /* default is an empty view string */
if ( zp->conf->view )
+ {
snprintf (zone, sizeof (zone), "\"%s\" in view \"%s\"", zp->zone, zp->conf->view);
+ view = zp->conf->view;
+ }
else
snprintf (zone, sizeof (zone), "\"%s\"", zp->zone);
+ if ( what == 2 )
+ {
+ lg_mesg (LG_NOTICE, "%s: key distribution triggered", zone);
+ verbmesg (1, zp->conf, "\tDistribute keys for zone %s\n", zone);
+ snprintf (cmdline, sizeof (cmdline), "%s distkeys %s %s %s",
+ zp->conf->dist_cmd, zp->zone, path, view);
+ *str = '\0';
+ if ( zp->conf->noexec == 0 )
+ {
+ verbmesg (2, zp->conf, "\t Run cmd \"%s\"\n", cmdline);
+ if ( (fp = popen (cmdline, "r")) == NULL || fgets (str, sizeof str, fp) == NULL )
+ return -2;
+ pclose (fp);
+ verbmesg (2, zp->conf, "\t %s distribute return: \"%s\"\n", zp->conf->dist_cmd, str_chop (str, '\n'));
+ }
+
+ return 0;
+ }
+
pathname (path, sizeof (path), zp->dir, zp->sfile, NULL);
lg_mesg (LG_NOTICE, "%s: distribution triggered", zone);
verbmesg (1, zp->conf, "\tDistribute zone %s\n", zone);
- if ( zp->conf->view )
- snprintf (cmdline, sizeof (cmdline), "%s distribute %s %s %s", zp->conf->dist_cmd, zp->zone, path, zp->conf->view);
- else
- snprintf (cmdline, sizeof (cmdline), "%s distribute %s %s", zp->conf->dist_cmd, zp->zone, path);
+ snprintf (cmdline, sizeof (cmdline), "%s distribute %s %s %s", zp->conf->dist_cmd, zp->zone, path, view);
*str = '\0';
if ( zp->conf->noexec == 0 )
@@ -147,10 +175,7 @@ int dist_and_reload (const zone_t *zp)
lg_mesg (LG_NOTICE, "%s: reload triggered", zone);
verbmesg (1, zp->conf, "\tReload zone %s\n", zone);
- if ( zp->conf->view )
- snprintf (cmdline, sizeof (cmdline), "%s reload %s %s %s", zp->conf->dist_cmd, zp->zone, path, zp->conf->view);
- else
- snprintf (cmdline, sizeof (cmdline), "%s reload %s %s", zp->conf->dist_cmd, zp->zone, path);
+ snprintf (cmdline, sizeof (cmdline), "%s reload %s %s %s", zp->conf->dist_cmd, zp->zone, path, view);
*str = '\0';
if ( zp->conf->noexec == 0 )
diff --git a/contrib/zkt/nscomm.h b/contrib/zkt/nscomm.h
index c4621dcedd..8dd116362a 100644
--- a/contrib/zkt/nscomm.h
+++ b/contrib/zkt/nscomm.h
@@ -35,6 +35,7 @@
**
*****************************************************************/
#ifndef NSCOMM_H
+# define NSCOMM_H
# include
# include
# include
@@ -44,9 +45,8 @@
# include "log.h"
# include "misc.h"
# include "debug.h"
-# define NSCOMM_H
extern int dyn_update_freeze (const char *domain, const zconf_t *z, int freeze);
extern int reload_zone (const char *domain, const zconf_t *z);
-extern int dist_and_reload (const zone_t *zp);
+extern int dist_and_reload (const zone_t *zp, int what);
#endif
diff --git a/contrib/zkt/rollover.c b/contrib/zkt/rollover.c
index 104ef45bb4..88d7e0f813 100644
--- a/contrib/zkt/rollover.c
+++ b/contrib/zkt/rollover.c
@@ -335,7 +335,7 @@ static int kskrollover (dki_t *ksk, zone_t *zonelist, zone_t *zp)
#if 0
verbmesg (2, z, "\t\tkskrollover: we are in state 2 and waiting for parent propagation (parentfile %d < parentprop %d + parentresig %d + parentkeyttl %d\n", parfile_age, parent_propagation, parent_resign, parent_keyttl);
#else
- verbmesg (2, z, "\t\tkskrollover: we are in state 2 and waiting for parent propagation (parentfile %dsec < parentprop %dsec + parentkeyttl %dsec\n", parfile_age, parent_propagation, parent_keyttl);
+ verbmesg (2, z, "\t\tkskrollover: we are in state 2 and waiting for parent propagation (parentfile %dsec < parentprop %dsec + parentkeyttl %dsec\n", parfile_age, parent_propagation, parent_keyttl);
#endif
break;
default:
@@ -505,16 +505,16 @@ int kskstatus (zone_t *zonelist, zone_t *zp)
akey = (dki_t *)dki_findalgo (zp->keys, DKI_KSK, z->k2_algo, 'a', 1);
if ( akey == NULL )
{
- verbmesg (1, z, "\tNo active KSK for second algorithm found: generate new one\n");
+ verbmesg (1, z, "\tNo active KSK for additional algorithm found: generate new one\n");
akey = genkey2 (&zp->keys, zp->dir, zp->zone, DKI_KSK, z, DKI_ACTIVE);
if ( !akey )
{
- error ("\tcould not generate new KSK for 2nd algorithm\n");
+ error ("\tcould not generate new KSK for additional algorithm\n");
lg_mesg (LG_ERROR, "\"%s\": can't generate new KSK for 2nd algorithm: \"%s\"",
zp->zone, dki_geterrstr());
}
else
- lg_mesg (LG_INFO, "\"%s\": generated new KSK %d for 2nd algorithm",
+ lg_mesg (LG_INFO, "\"%s\": generated new KSK %d for additional algorithm",
zp->zone, akey->tag);
return 1; /* return value of 1 forces a resigning of the zone */
}
diff --git a/contrib/zkt/tags b/contrib/zkt/tags
index f64df2dba0..fa2d67aecf 100644
--- a/contrib/zkt/tags
+++ b/contrib/zkt/tags
@@ -11,16 +11,20 @@ CONF_END zconf.c /^ CONF_END = 0,$/;" e enum:__anon2 file:
CONF_FACILITY zconf.c /^ CONF_FACILITY,$/;" e enum:__anon2 file:
CONF_INT zconf.c /^ CONF_INT,$/;" e enum:__anon2 file:
CONF_LEVEL zconf.c /^ CONF_LEVEL,$/;" e enum:__anon2 file:
+CONF_NSEC3 zconf.c /^ CONF_NSEC3,$/;" e enum:__anon2 file:
CONF_SERIAL zconf.c /^ CONF_SERIAL,$/;" e enum:__anon2 file:
CONF_STRING zconf.c /^ CONF_STRING,$/;" e enum:__anon2 file:
CONF_TIMEINT zconf.c /^ CONF_TIMEINT,$/;" e enum:__anon2 file:
-ISCOMMENT zconf.c 67;" d file:
-ISDELIM zconf.c 69;" d file:
-ISTRUE zconf.c 65;" d file:
-KEYSET_FILE_PFX dnssec-signer.c 709;" d file:
+CONF_VERSION zconf.c /^ CONF_VERSION,$/;" e enum:__anon2 file:
+ISCOMMENT zconf.c 68;" d file:
+ISDELIM zconf.c 70;" d file:
+ISTRUE zconf.c 66;" d file:
+KEYGEN_COMPMODE dki.c 231;" d file:
+KEYGEN_COMPMODE dki.c 233;" d file:
+KEYSET_FILE_PFX zkt-signer.c 747;" d file:
KeyWords ncparse.c /^static struct KeyWords {$/;" s file:
-MAXFNAME log.c 97;" d file:
-STRCONFIG_DELIMITER zconf.c 529;" d file:
+MAXFNAME log.c 98;" d file:
+STRCONFIG_DELIMITER zconf.c 632;" d file:
TAINTEDCHARS misc.c 60;" d file:
TOK_DELEGATION ncparse.c 59;" d file:
TOK_DIR ncparse.c 49;" d file:
@@ -37,31 +41,39 @@ TOK_UNKNOWN ncparse.c 64;" d file:
TOK_VIEW ncparse.c 60;" d file:
TOK_ZONE ncparse.c 52;" d file:
a domaincmp.c /^ char *a;$/;" m struct:__anon1 file:
-add2zonelist dnssec-signer.c /^static int add2zonelist (const char *dir, const char *view, const char *zone, const char *file)$/;" f file:
+add2zonelist zkt-signer.c /^static int add2zonelist (const char *dir, const char *view, const char *zone, const char *file)$/;" f file:
+addkeydb zfparse.c /^int addkeydb (const char *file, const char *keydbfile)$/;" f
age2str misc.c /^char *age2str (time_t sec)$/;" f
-ageflag dnssec-zkt.c /^int ageflag = 0;$/;" v
+ageflag zkt-keyman.c /^int ageflag = 0;$/;" v
+ageflag zkt-ls.c /^int ageflag = 0;$/;" v
+allflag zkt-conf.c /^static int allflag = 0;$/;" v file:
b domaincmp.c /^ char *b;$/;" m struct:__anon1 file:
-bind94_dynzone dnssec-signer.c 130;" d file:
-bind96_dynzone dnssec-signer.c 131;" d file:
+bind94_dynzone zkt-signer.c 130;" d file:
+bind96_dynzone zkt-signer.c 131;" d file:
+bold_off tcap.c /^static const char *bold_off = "";$/;" v file:
+bold_on tcap.c /^static const char *bold_on = "";$/;" v file:
bool2str zconf.c /^static const char *bool2str (int val)$/;" f file:
-check_keydb_timestamp dnssec-signer.c /^static int check_keydb_timestamp (dki_t *keylist, time_t reftime)$/;" f file:
+check_keydb_timestamp zkt-signer.c /^static int check_keydb_timestamp (dki_t *keylist, time_t reftime)$/;" f file:
checkconfig zconf.c /^int checkconfig (const zconf_t *z)$/;" f
-cmdline zconf.c /^ int cmdline; \/* is this a command line parameter ? *\/$/;" m struct:__anon3 file:
+cmdln zconf.c 73;" d file:
cmpfile misc.c /^int cmpfile (const char *file1, const char *file2)$/;" f
-config dnssec-signer.c /^static zconf_t *config;$/;" v file:
+colortab tcap.c /^static char colortab[8][31+1];$/;" v file:
+compversion zconf.c /^static int compversion;$/;" v file:
config zconf.c /^static zconf_t *config;$/;" v file:
+config zkt-signer.c /^static zconf_t *config;$/;" v file:
confpara zconf.c /^static zconf_para_t confpara[] = {$/;" v file:
-copy_keyset dnssec-signer.c /^static void copy_keyset (const char *dir, const char *domain, const zconf_t *conf)$/;" f file:
+copy_keyset zkt-signer.c /^static void copy_keyset (const char *dir, const char *domain, const zconf_t *conf)$/;" f file:
copyfile misc.c /^int copyfile (const char *fromfile, const char *tofile, const char *dnskeyfile)$/;" f
copyzonefile misc.c /^int copyzonefile (const char *fromfile, const char *tofile, const char *dnskeyfile)$/;" f
-create_parent_file dnssec-zkt.c /^static int create_parent_file (const char *fname, int phase, int ttl, const dki_t *dkp)$/;" f file:
create_parent_file rollover.c /^static int create_parent_file (const char *fname, int phase, int ttl, const dki_t *dkp)$/;" f file:
-createkey dnssec-zkt.c /^static void createkey (const char *keyname, const dki_t *list, const zconf_t *conf)$/;" f file:
+create_parent_file zkt-keyman.c /^static int create_parent_file (const char *fname, int phase, int ttl, const dki_t *dkp)$/;" f file:
+createkey zkt-keyman.c /^static void createkey (const char *keyname, const dki_t *list, const zconf_t *conf)$/;" f file:
ctype_t zconf.c /^} ctype_t;$/;" t typeref:enum:__anon2 file:
def zconf.c /^static zconf_t def = {$/;" v file:
-dirflag dnssec-zkt.c /^static int dirflag = 0;$/;" v file:
-dirname dnssec-signer.c /^static const char *dirname = NULL;$/;" v file:
-dist_and_reload nscomm.c /^int dist_and_reload (const zone_t *zp)$/;" f
+dirflag zkt-keyman.c /^static int dirflag = 0;$/;" v file:
+dirflag zkt-ls.c /^static int dirflag = 0;$/;" v file:
+dirname zkt-signer.c /^static const char *dirname = NULL;$/;" v file:
+dist_and_reload nscomm.c /^int dist_and_reload (const zone_t *zp, int what)$/;" f
dki_add dki.c /^dki_t *dki_add (dki_t **list, dki_t *new)$/;" f
dki_age dki.c /^int dki_age (const dki_t *dkp, time_t curr)$/;" f
dki_algo dki.c /^time_t dki_algo (const dki_t *dkp)$/;" f
@@ -98,6 +110,7 @@ dki_read dki.c /^dki_t *dki_read (const char *dirname, const char *filename)$/;"
dki_readdir dki.c /^int dki_readdir (const char *dir, dki_t **listp, int recursive)$/;" f
dki_readfile dki.c /^static int dki_readfile (FILE *fp, dki_t *dkp)$/;" f file:
dki_remove dki.c /^dki_t *dki_remove (dki_t *dkp)$/;" f
+dki_revnamecmp dki.c /^int dki_revnamecmp (const dki_t *a, const dki_t *b)$/;" f
dki_search dki.c /^const dki_t *dki_search (const dki_t *list, int tag, const char *name)$/;" f
dki_setexptime dki.c /^time_t dki_setexptime (dki_t *dkp, time_t sec)$/;" f
dki_setflag dki.c /^dk_flag_t dki_setflag (dki_t *dkp, dk_flag_t flag)$/;" f
@@ -107,7 +120,7 @@ dki_setstatus dki.c /^int dki_setstatus (dki_t *dkp, int status)$/;" f
dki_setstatus_preservetime dki.c /^int dki_setstatus_preservetime (dki_t *dkp, int status)$/;" f
dki_status dki.c /^dk_status_t dki_status (const dki_t *dkp)$/;" f
dki_statusstr dki.c /^const char *dki_statusstr (const dki_t *dkp)$/;" f
-dki_tadd dki.c /^dki_t *dki_tadd (dki_t **tree, dki_t *new)$/;" f
+dki_tadd dki.c /^dki_t *dki_tadd (dki_t **tree, dki_t *new, int sub_before)$/;" f
dki_tagcmp dki.c /^int dki_tagcmp (const dki_t *a, const dki_t *b)$/;" f
dki_tfree dki.c /^void dki_tfree (dki_t **tree)$/;" f
dki_time dki.c /^time_t dki_time (const dki_t *dkp)$/;" f
@@ -117,17 +130,19 @@ dki_unsetflag dki.c /^dk_flag_t dki_unsetflag (dki_t *dkp, dk_flag_t flag)$/;" f
dki_writeinfo dki.c /^static int dki_writeinfo (const dki_t *dkp, const char *path)$/;" f file:
domain_canonicdup misc.c /^char *domain_canonicdup (const char *s)$/;" f
domaincmp domaincmp.c /^int domaincmp (const char *a, const char *b)$/;" f
-dosigning dnssec-signer.c /^static int dosigning (zone_t *zonelist, zone_t *zp)$/;" f file:
+domaincmp_dir domaincmp.c /^int domaincmp_dir (const char *a, const char *b, int subdomain_above)$/;" f
+dosigning zkt-signer.c /^static int dosigning (zone_t *zonelist, zone_t *zp)$/;" f file:
dupconfig zconf.c /^zconf_t *dupconfig (const zconf_t *conf)$/;" f
dyn_update_freeze nscomm.c /^int dyn_update_freeze (const char *domain, const zconf_t *z, int freeze)$/;" f
-dynamic_zone dnssec-signer.c /^static int dynamic_zone = 0; \/* dynamic zone ? *\/$/;" v file:
+dynamic_zone zkt-signer.c /^static int dynamic_zone = 0; \/* dynamic zone ? *\/$/;" v file:
error misc.c /^void error (char *fmt, ...)$/;" f
ex domaincmp.c /^} ex[] = {$/;" v typeref:struct:__anon1 file:
-exptimeflag dnssec-zkt.c /^int exptimeflag = 0;$/;" v
+exptimeflag zkt-keyman.c /^int exptimeflag = 0;$/;" v
+exptimeflag zkt-ls.c /^int exptimeflag = 0;$/;" v
extern dki.c 59;" d file:
extern dki.c 61;" d file:
-extern domaincmp.c 42;" d file:
-extern domaincmp.c 44;" d file:
+extern domaincmp.c 43;" d file:
+extern domaincmp.c 45;" d file:
extern log.c 55;" d file:
extern log.c 57;" d file:
extern misc.c 56;" d file:
@@ -140,10 +155,14 @@ extern rollover.c 57;" d file:
extern rollover.c 59;" d file:
extern soaserial.c 53;" d file:
extern soaserial.c 55;" d file:
-extern zconf.c 60;" d file:
-extern zconf.c 62;" d file:
-extern zkt.c 47;" d file:
+extern tcap.c 31;" d file:
+extern tcap.c 33;" d file:
+extern zconf.c 61;" d file:
+extern zconf.c 63;" d file:
+extern zfparse.c 58;" d file:
+extern zfparse.c 60;" d file:
extern zkt.c 49;" d file:
+extern zkt.c 51;" d file:
extern zone.c 53;" d file:
extern zone.c 55;" d file:
fatal misc.c /^void fatal (char *fmt, ...)$/;" f
@@ -151,44 +170,63 @@ file_age misc.c /^int file_age (const char *fname)$/;" f
file_mtime misc.c /^time_t file_mtime (const char *fname)$/;" f
fileexist misc.c /^int fileexist (const char *name)$/;" f
filesize misc.c /^size_t filesize (const char *name)$/;" f
-force dnssec-signer.c /^static int force = 0;$/;" v file:
+first zconf.c 74;" d file:
+force zkt-signer.c /^static int force = 0;$/;" v file:
+freeconfig zconf.c /^zconf_t *freeconfig (zconf_t *conf)$/;" f
genkey rollover.c /^static dki_t *genkey (dki_t **listp, const char *dir, const char *domain, int ksk, const zconf_t *conf, int status)$/;" f file:
genkey2 rollover.c /^static dki_t *genkey2 (dki_t **listp, const char *dir, const char *domain, int ksk, const zconf_t *conf, int status)$/;" f file:
-gensalt misc.c /^int gensalt (char *salt, size_t saltsize, int saltbits)$/;" f
+gensalt misc.c /^int gensalt (char *salt, size_t saltsize, int saltbits, unsigned int seed)$/;" f
get_exptime rollover.c /^static time_t get_exptime (dki_t *key, const zconf_t *z)$/;" f file:
-get_parent_phase dnssec-zkt.c /^static int get_parent_phase (const char *file)$/;" f file:
get_parent_phase rollover.c /^static int get_parent_phase (const char *file)$/;" f file:
+get_parent_phase zkt-keyman.c /^static int get_parent_phase (const char *file)$/;" f file:
+get_ttl zfparse.c /^static long get_ttl (const char *s)$/;" f file:
getdefconfname misc.c /^const char *getdefconfname (const char *view)$/;" f
getnameappendix misc.c /^const char *getnameappendix (const char *progname, const char *basename)$/;" f
gettok ncparse.c /^static int gettok (FILE *fp, char *val, size_t valsize)$/;" f file:
-goto_labelstart domaincmp.c 47;" d file:
-headerflag dnssec-zkt.c /^int headerflag = 1;$/;" v
+goto_labelstart domaincmp.c 48;" d file:
+headerflag zkt-keyman.c /^int headerflag = 1;$/;" v
+headerflag zkt-ls.c /^int headerflag = 1;$/;" v
+html tcap.c /^static int html = 0;$/;" v file:
in_strarr misc.c /^int in_strarr (const char *str, char *const arr[], int cnt)$/;" f
inc_errstr soaserial.c /^const char *inc_errstr (int err)$/;" f
inc_serial soaserial.c /^int inc_serial (const char *fname, int use_unixtime)$/;" f
inc_soa_serial soaserial.c /^static int inc_soa_serial (FILE *fp, int use_unixtime)$/;" f file:
+is1 tcap.c /^static const char *is1 = "";$/;" v file:
+is2 tcap.c /^static const char *is2 = "";$/;" v file:
+is_defined zkt-signer.c 132;" d file:
is_directory misc.c /^int is_directory (const char *name)$/;" f
is_dotfilename misc.c /^int is_dotfilename (const char *name)$/;" f
is_exec_ok misc.c /^int is_exec_ok (const char *prog)$/;" f
is_keyfilename misc.c /^int is_keyfilename (const char *name)$/;" f
+is_multiline_rr zfparse.c /^static const char *is_multiline_rr (int *multi_line_rr, const char *p)$/;" f file:
is_parentdirsigned rollover.c /^static int is_parentdirsigned (const zone_t *zonelist, const zone_t *zp)$/;" f file:
is_soa_rr soaserial.c /^static int is_soa_rr (const char *line)$/;" f file:
+iscmdline zconf.c 77;" d file:
+iscompatible zconf.c 78;" d file:
isinlist strlist.c /^int isinlist (const char *str, const char *list)$/;" f
+isparentdomain domaincmp.c /^int isparentdomain (const char *child, const char *parent, int level)$/;" f
+issubdomain domaincmp.c /^int issubdomain (const char *child, const char *parent)$/;" f
+italic_off tcap.c /^static const char *italic_off = "";$/;" v file:
+italic_on tcap.c /^static const char *italic_on = "";$/;" v file:
ksk5011status rollover.c /^int ksk5011status (dki_t **listp, const char *dir, const char *domain, const zconf_t *z)$/;" f
-ksk_roll dnssec-zkt.c /^static void ksk_roll (const char *keyname, int phase, const dki_t *list, const zconf_t *conf)$/;" f file:
-kskdomain dnssec-zkt.c /^static char *kskdomain = "";$/;" v file:
-kskflag dnssec-zkt.c /^int kskflag = 1;$/;" v
+ksk_roll zkt-keyman.c /^static void ksk_roll (const char *keyname, int phase, const dki_t *list, const zconf_t *conf)$/;" f file:
+kskdomain zkt-keyman.c /^static char *kskdomain = "";$/;" v file:
+kskflag zkt-keyman.c /^int kskflag = 1;$/;" v
+kskflag zkt-ls.c /^int kskflag = 1;$/;" v
kskrollover rollover.c /^static int kskrollover (dki_t *ksk, zone_t *zonelist, zone_t *zp)$/;" f file:
kskstatus rollover.c /^int kskstatus (zone_t *zonelist, zone_t *zp)$/;" f
kw ncparse.c /^} kw[] = {$/;" v typeref:struct:KeyWords file:
label zconf.c /^ char *label; \/* the name of the paramter *\/$/;" m struct:__anon3 file:
-labellist dnssec-zkt.c /^char *labellist = NULL;$/;" v
+labellist zkt-keyman.c /^char *labellist = NULL;$/;" v
+labellist zkt-ls.c /^char *labellist = NULL;$/;" v
+last zconf.c 75;" d file:
level log.c /^ lg_lvl_t level;$/;" m struct:__anon4 file:
lg_args log.c /^void lg_args (lg_lvl_t level, int argc, char * const argv[])$/;" f
lg_close log.c /^int lg_close ()$/;" f
lg_errcnt log.c /^static long lg_errcnt;$/;" v file:
lg_fileopen log.c /^static FILE *lg_fileopen (const char *path, const char *name)$/;" f file:
lg_fp log.c /^static FILE *lg_fp;$/;" v file:
+lg_fpsave log.c /^static FILE *lg_fpsave;$/;" v file:
lg_geterrcnt log.c /^long lg_geterrcnt ()$/;" f
lg_lvl2str log.c /^const char *lg_lvl2str (lg_lvl_t level)$/;" f
lg_lvl2syslog log.c /^lg_lvl_t lg_lvl2syslog (lg_lvl_t level)$/;" f
@@ -203,90 +241,134 @@ lg_str2lvl log.c /^lg_lvl_t lg_str2lvl (const char *name)$/;" f
lg_str2syslog log.c /^int lg_str2syslog (const char *facility)$/;" f
lg_symtbl_t log.c /^} lg_symtbl_t;$/;" t typeref:struct:__anon4 file:
lg_syslogging log.c /^static int lg_syslogging;$/;" v file:
-lifetime dnssec-zkt.c /^int lifetime = 0;$/;" v
-lifetimeflag dnssec-zkt.c /^int lifetimeflag = 0;$/;" v
+lg_zone_end log.c /^int lg_zone_end ()$/;" f
+lg_zone_start log.c /^int lg_zone_start (const char *dir, const char *domain)$/;" f
+lifetime zkt-keyman.c /^int lifetime = 0;$/;" v
+lifetime zkt-ls.c /^int lifetime = 0;$/;" v
+lifetimeflag zkt-keyman.c /^int lifetimeflag = 0;$/;" v
+lifetimeflag zkt-ls.c /^int lifetimeflag = 0;$/;" v
linkfile misc.c /^int linkfile (const char *fromfile, const char *tofile)$/;" f
list_dnskey zkt.c /^static void list_dnskey (const dki_t **nodep, const VISIT which, int depth)$/;" f file:
list_key zkt.c /^static void list_key (const dki_t **nodep, const VISIT which, int depth)$/;" f file:
list_trustedkey zkt.c /^static void list_trustedkey (const dki_t **nodep, const VISIT which, int depth)$/;" f file:
-ljustflag dnssec-zkt.c /^int ljustflag = 0;$/;" v
+ljustflag zkt-keyman.c /^int ljustflag = 0;$/;" v
+ljustflag zkt-ls.c /^int ljustflag = 0;$/;" v
loadconfig zconf.c /^zconf_t *loadconfig (const char *filename, zconf_t *z)$/;" f
loadconfig_fromstr zconf.c /^zconf_t *loadconfig_fromstr (const char *str, zconf_t *z)$/;" f
-logfile dnssec-signer.c /^static const char *logfile = NULL;$/;" v file:
+logfile zkt-signer.c /^static const char *logfile = NULL;$/;" v file:
logflush misc.c /^void logflush ()$/;" f
logmesg misc.c /^void logmesg (char *fmt, ...)$/;" f
-long_options dnssec-signer.c /^static struct option long_options[] = {$/;" v typeref:struct:option file:
-long_options dnssec-zkt.c /^static struct option long_options[] = {$/;" v typeref:struct:option file:
-lopt_usage dnssec-signer.c 326;" d file:
-lopt_usage dnssec-signer.c 329;" d file:
-lopt_usage dnssec-zkt.c 402;" d file:
-lopt_usage dnssec-zkt.c 405;" d file:
-loptstr dnssec-signer.c 327;" d file:
-loptstr dnssec-signer.c 330;" d file:
-loptstr dnssec-zkt.c 403;" d file:
-loptstr dnssec-zkt.c 406;" d file:
-main dnssec-signer.c /^int main (int argc, char *const argv[])$/;" f
-main dnssec-zkt.c /^int main (int argc, char *argv[])$/;" f
+long_options zkt-conf.c /^static struct option long_options[] = {$/;" v typeref:struct:option file:
+long_options zkt-keyman.c /^static struct option long_options[] = {$/;" v typeref:struct:option file:
+long_options zkt-ls.c /^static struct option long_options[] = {$/;" v typeref:struct:option file:
+long_options zkt-signer.c /^static struct option long_options[] = {$/;" v typeref:struct:option file:
+lopt_usage zkt-conf.c 306;" d file:
+lopt_usage zkt-conf.c 309;" d file:
+lopt_usage zkt-keyman.c 334;" d file:
+lopt_usage zkt-keyman.c 337;" d file:
+lopt_usage zkt-ls.c 314;" d file:
+lopt_usage zkt-ls.c 317;" d file:
+lopt_usage zkt-signer.c 341;" d file:
+lopt_usage zkt-signer.c 344;" d file:
+loptstr zkt-conf.c 307;" d file:
+loptstr zkt-conf.c 310;" d file:
+loptstr zkt-keyman.c 335;" d file:
+loptstr zkt-keyman.c 338;" d file:
+loptstr zkt-ls.c 315;" d file:
+loptstr zkt-ls.c 318;" d file:
+loptstr zkt-signer.c 342;" d file:
+loptstr zkt-signer.c 345;" d file:
main domaincmp.c /^main (int argc, char *argv[])$/;" f
main log.c /^int main (int argc, char *argv[])$/;" f
main misc.c /^main (int argc, char *argv[])$/;" f
main ncparse.c /^main (int argc, char *argv[])$/;" f
main soaserial.c /^main (int argc, char *argv[])$/;" f
main strlist.c /^main (int argc, char *argv[])$/;" f
+main tcap.c /^main (int argc, const char *argv[])$/;" f
main zconf.c /^main (int argc, char *argv[])$/;" f
+main zfparse.c /^int main (int argc, char *argv[])$/;" f
+main zkt-conf.c /^int main (int argc, char *argv[])$/;" f
+main zkt-keyman.c /^int main (int argc, char *argv[])$/;" f
+main zkt-ls.c /^int main (int argc, char *argv[])$/;" f
+main zkt-signer.c /^int main (int argc, char *const argv[])$/;" f
main zkt-soaserial.c /^int main (int argc, char *argv[])$/;" f
+maxcolor tcap.c /^static int maxcolor;$/;" v file:
name ncparse.c /^ char *name;$/;" m struct:KeyWords file:
-namedconf dnssec-signer.c /^static const char *namedconf = NULL;$/;" v file:
-new_keysetfiles dnssec-signer.c /^static int new_keysetfiles (const char *dir, time_t zone_signing_time)$/;" f file:
-noexec dnssec-signer.c /^static int noexec = 0;$/;" v file:
-origin dnssec-signer.c /^static const char *origin = NULL;$/;" v file:
+namedconf zkt-signer.c /^static const char *namedconf = NULL;$/;" v file:
+new_keysetfiles zkt-signer.c /^static int new_keysetfiles (const char *dir, time_t zone_signing_time)$/;" f file:
+noexec zkt-signer.c /^static int noexec = 0;$/;" v file:
+origin zkt-signer.c /^static const char *origin = NULL;$/;" v file:
+parent zkt.c /^const dki_t *parent;$/;" v
parse_namedconf ncparse.c /^int parse_namedconf (const char *filename, const char *chroot_dir, char *dir, size_t dirsize, int (*func) ())$/;" f
parseconfigline zconf.c /^static void parseconfigline (char *buf, unsigned int line, zconf_t *z)$/;" f file:
-parsedir dnssec-signer.c /^static int parsedir (const char *dir, zone_t **zp, const zconf_t *conf)$/;" f file:
-parsedirectory dnssec-zkt.c /^static int parsedirectory (const char *dir, dki_t **listp)$/;" f file:
-parsefile dnssec-zkt.c /^static void parsefile (const char *file, dki_t **listp)$/;" f file:
-parsetag dnssec-zkt.c /^static const char *parsetag (const char *str, int *tagp)$/;" f file:
+parsedir zkt-signer.c /^static int parsedir (const char *dir, zone_t **zp, const zconf_t *conf)$/;" f file:
+parsedirectory zkt-keyman.c /^static int parsedirectory (const char *dir, dki_t **listp)$/;" f file:
+parsedirectory zkt-ls.c /^static int parsedirectory (const char *dir, dki_t **listp, int sub_before)$/;" f file:
+parsefile zkt-keyman.c /^static void parsefile (const char *file, dki_t **listp)$/;" f file:
+parsefile zkt-ls.c /^static void parsefile (const char *file, dki_t **listp, int sub_before)$/;" f file:
+parsetag zkt-keyman.c /^static const char *parsetag (const char *str, int *tagp)$/;" f file:
parseurl misc.c /^void parseurl (char *url, char **proto, char **host, char **port, char **para)$/;" f
-pathflag dnssec-zkt.c /^int pathflag = 0;$/;" v
+parsezonefile zfparse.c /^int parsezonefile (const char *file, long *pminttl, long *pmaxttl, const char *keydbfile)$/;" f
+pathflag zkt-keyman.c /^int pathflag = 0;$/;" v
+pathflag zkt-ls.c /^int pathflag = 0;$/;" v
pathname misc.c /^char *pathname (char *path, size_t size, const char *dir, const char *file, const char *ext)$/;" f
prepstrlist strlist.c /^char *prepstrlist (const char *str, const char *delim)$/;" f
printconfig zconf.c /^int printconfig (const char *fname, const zconf_t *z)$/;" f
+printconfigdiff zconf.c /^int printconfigdiff (const char *fname, const zconf_t *ref, const zconf_t *z)$/;" f
printconfigline zconf.c /^static void printconfigline (FILE *fp, zconf_para_t *cp)$/;" f file:
printkeyinfo zkt.c /^static void printkeyinfo (const dki_t *dkp, const char *oldpath)$/;" f file:
printserial zkt-soaserial.c /^static void printserial (const char *fname, unsigned long serial)$/;" f file:
printzone ncparse.c /^int printzone (const char *dir, const char *view, const char *zone, const char *file)$/;" f
-progname dnssec-signer.c /^const char *progname;$/;" v
-progname dnssec-zkt.c /^const char *progname;$/;" v
progname domaincmp.c /^const char *progname;$/;" v
progname log.c /^const char *progname;$/;" v
progname misc.c /^const char *progname;$/;" v
progname ncparse.c /^char *progname;$/;" v
progname soaserial.c /^const char *progname;$/;" v
+progname tcap.c /^static const char *progname;$/;" v file:
progname zconf.c /^const char *progname;$/;" v
+progname zfparse.c /^const char *progname;$/;" v
+progname zkt-conf.c /^const char *progname;$/;" v
+progname zkt-keyman.c /^const char *progname;$/;" v
+progname zkt-ls.c /^const char *progname;$/;" v
+progname zkt-signer.c /^const char *progname;$/;" v
progname zkt-soaserial.c /^static const char *progname;$/;" v file:
+put tcap.c /^static int put (int c)$/;" f file:
+r1 tcap.c /^static const char *r1 = "";$/;" v file:
+r2 tcap.c /^static const char *r2 = "";$/;" v file:
read_serial_fromfile zkt-soaserial.c /^static int read_serial_fromfile (const char *fname, unsigned long *serial)$/;" f file:
-recflag dnssec-zkt.c /^static int recflag = RECURSIVE;$/;" v file:
-register_key dnssec-signer.c /^static void register_key (dki_t *list, const zconf_t *z)$/;" f file:
+recflag zkt-keyman.c /^static int recflag = RECURSIVE;$/;" v file:
+recflag zkt-ls.c /^static int recflag = RECURSIVE;$/;" v file:
+register_key zkt-signer.c /^static void register_key (dki_t *list, const zconf_t *z)$/;" f file:
reload_zone nscomm.c /^int reload_zone (const char *domain, const zconf_t *z)$/;" f
-reloadflag dnssec-signer.c /^static int reloadflag = 0;$/;" v file:
+reloadflag zkt-signer.c /^static int reloadflag = 0;$/;" v file:
res domaincmp.c /^ int res;$/;" m struct:__anon1 file:
searchitem zkt.c /^static int searchitem;$/;" v file:
searchkw ncparse.c /^static int searchkw (const char *keyword)$/;" f file:
searchresult zkt.c /^static const dki_t *searchresult;$/;" v file:
serialtime soaserial.c /^static ulong serialtime (time_t sec)$/;" f file:
-set_all_varptr zconf.c /^static void set_all_varptr (zconf_t *cp)$/;" f file:
-set_bind94_dynzone dnssec-signer.c 128;" d file:
-set_bind96_dynzone dnssec-signer.c 129;" d file:
+set_all_varptr zconf.c /^static void set_all_varptr (zconf_t *cp, const zconf_t *cp2)$/;" f file:
+set_bind94_dynzone zkt-signer.c 128;" d file:
+set_bind96_dynzone zkt-signer.c 129;" d file:
set_keylifetime zkt.c /^static void set_keylifetime (const dki_t **nodep, const VISIT which, int depth)$/;" f file:
-set_varptr zconf.c /^static int set_varptr (char *entry, void *ptr)$/;" f file:
+set_varptr zconf.c /^static int set_varptr (char *entry, void *ptr, const void *ptr2)$/;" f file:
setconfigpar zconf.c /^int setconfigpar (zconf_t *config, char *entry, const void *pval)$/;" f
-setglobalflags dnssec-zkt.c /^static void setglobalflags (zconf_t *config)$/;" f file:
-short_options dnssec-signer.c 68;" d file:
-short_options dnssec-signer.c 70;" d file:
-short_options dnssec-zkt.c 89;" d file:
-sign_zone dnssec-signer.c /^static int sign_zone (const char *dir, const char *domain, const char *file, const zconf_t *conf)$/;" f file:
-sopt_usage dnssec-signer.c 324;" d file:
-sopt_usage dnssec-zkt.c 400;" d file:
+setconfigversion zconf.c /^void setconfigversion (int version)$/;" f
+setglobalflags zkt-keyman.c /^static void setglobalflags (zconf_t *config)$/;" f file:
+setglobalflags zkt-ls.c /^static void setglobalflags (zconf_t *config)$/;" f file:
+setminmax zfparse.c /^static void setminmax (long *pmin, long val, long *pmax)$/;" f file:
+short_options zkt-conf.c 73;" d file:
+short_options zkt-keyman.c 88;" d file:
+short_options zkt-ls.c 92;" d file:
+short_options zkt-ls.c 94;" d file:
+short_options zkt-signer.c 68;" d file:
+short_options zkt-signer.c 70;" d file:
+sign_zone zkt-signer.c /^static int sign_zone (const zone_t *zp)$/;" f file:
+skiplabel zfparse.c /^static const char *skiplabel (const char *s)$/;" f file:
+skipws zfparse.c /^static const char *skipws (const char *s)$/;" f file:
+sopt_usage zkt-conf.c 304;" d file:
+sopt_usage zkt-keyman.c 332;" d file:
+sopt_usage zkt-ls.c 312;" d file:
+sopt_usage zkt-signer.c 339;" d file:
splitpath misc.c /^const char *splitpath (char *path, size_t psize, const char *filename)$/;" f
start_timer misc.c /^time_t start_timer ()$/;" f
stop_timer misc.c /^time_t stop_timer (time_t start)$/;" f
@@ -295,30 +377,48 @@ str_chop misc.c /^char *str_chop (char *str, char c)$/;" f
str_delspace misc.c /^char *str_delspace (char *s)$/;" f
str_untaint misc.c /^char *str_untaint (char *str)$/;" f
strfindstr soaserial.c /^static const char *strfindstr (const char *str, const char *search)$/;" f file:
+subdomain_before_parent zkt-ls.c /^int subdomain_before_parent = 1;$/;" v
symtbl log.c /^static lg_symtbl_t symtbl[] = {$/;" v file:
syslog_level log.c /^ int syslog_level;$/;" m struct:__anon4 file:
tag_search zkt.c /^static void tag_search (const dki_t **nodep, const VISIT which, int depth)$/;" f file:
+tc_attr tcap.c /^int tc_attr (FILE *fp, tc_att_t attr, int on)$/;" f
+tc_color tcap.c /^static int tc_color (FILE *fp, int color)$/;" f file:
+tc_end tcap.c /^int tc_end (FILE *fp, const char *term)$/;" f
+tc_init tcap.c /^int tc_init (FILE *fp, const char *term)$/;" f
+tc_outfp tcap.c /^static FILE *tc_outfp;$/;" v file:
+tc_printattr tcap.c /^static int tc_printattr (FILE *fp, const char *attstr)$/;" f file:
+term zkt-ls.c /^static const char *term = NULL;$/;" v file:
+testflag zkt-conf.c /^static int testflag = 0;$/;" v file:
time2isostr misc.c /^char *time2isostr (time_t sec, int precision)$/;" f
time2str misc.c /^char *time2str (time_t sec, int precision)$/;" f
-timeflag dnssec-zkt.c /^int timeflag = 1;$/;" v
-timeint2str zconf.c /^static const char *timeint2str (ulong val)$/;" f file:
+timeflag zkt-keyman.c /^int timeflag = 1;$/;" v
+timeflag zkt-ls.c /^int timeflag = 1;$/;" v
+timeint2str zconf.c /^const char *timeint2str (unsigned long val)$/;" f
timestr zkt-soaserial.c /^static char *timestr (time_t sec)$/;" f file:
timestr2time misc.c /^time_t timestr2time (const char *timestr)$/;" f
tok ncparse.c /^ int tok;$/;" m struct:KeyWords file:
tok2str ncparse.c /^static const char *tok2str (int tok)$/;" f file:
touch misc.c /^int touch (const char *fname, time_t sec)$/;" f
-trustedkeyflag dnssec-zkt.c /^static int trustedkeyflag = 0;$/;" v file:
+trustedkeyflag zkt-ls.c /^static int trustedkeyflag = 0;$/;" v file:
type zconf.c /^ ctype_t type; \/* the parameter type *\/$/;" m struct:__anon3 file:
unprepstrlist strlist.c /^char *unprepstrlist (char *list, char delimc)$/;" f
-usage dnssec-signer.c /^static void usage (char *mesg, zconf_t *conf)$/;" f file:
-usage dnssec-zkt.c /^static void usage (char *mesg, zconf_t *cp)$/;" f file:
+usage zkt-conf.c /^static void usage (char *mesg)$/;" f file:
+usage zkt-keyman.c /^static void usage (char *mesg, zconf_t *cp)$/;" f file:
+usage zkt-ls.c /^static void usage (char *mesg, zconf_t *cp)$/;" f file:
+usage zkt-signer.c /^static void usage (char *mesg, zconf_t *conf)$/;" f file:
usage zkt-soaserial.c /^static void usage (const char *msg)$/;" f file:
+used_since zconf.c /^ short used_since; \/* compability (from version; 0 == command line) *\/$/;" m struct:__anon3 file:
+used_till zconf.c /^ short used_till; \/* compability (to version) *\/$/;" m struct:__anon3 file:
var zconf.c /^ void *var; \/* pointer to the parameter variable *\/$/;" m struct:__anon3 file:
+var2 zconf.c /^ const void *var2; \/* pointer to a second parameter variable *\/$/;" m struct:__anon3 file:
verbmesg misc.c /^void verbmesg (int verblvl, const zconf_t *conf, char *fmt, ...)$/;" f
-verbose dnssec-signer.c /^static int verbose = 0;$/;" v file:
-view dnssec-zkt.c /^static const char *view = "";$/;" v file:
-viewname dnssec-signer.c /^static const char *viewname = NULL;$/;" v file:
-writekeyfile dnssec-signer.c /^static int writekeyfile (const char *fname, const dki_t *list, int key_ttl)$/;" f file:
+verbose zkt-signer.c /^static int verbose = 0;$/;" v file:
+view zkt-conf.c /^static const char *view = "";$/;" v file:
+view zkt-keyman.c /^static const char *view = "";$/;" v file:
+view zkt-ls.c /^static const char *view = "";$/;" v file:
+viewname zkt-signer.c /^static const char *viewname = NULL;$/;" v file:
+writeflag zkt-conf.c /^static int writeflag = 0;$/;" v file:
+writekeyfile zkt-signer.c /^static int writekeyfile (const char *fname, const dki_t *list, int key_ttl)$/;" f file:
zconf_para_t zconf.c /^} zconf_para_t;$/;" t typeref:struct:__anon3 file:
zkt_list_dnskeys zkt.c /^void zkt_list_dnskeys (const dki_t *data)$/;" f
zkt_list_keys zkt.c /^void zkt_list_keys (const dki_t *data)$/;" f
@@ -336,6 +436,7 @@ zone_new zone.c /^zone_t *zone_new (zone_t **zp, const char *zone, const char *d
zone_print zone.c /^int zone_print (const char *mesg, const zone_t *z)$/;" f
zone_readdir zone.c /^int zone_readdir (const char *dir, const char *zone, const char *zfile, zone_t **listp, const zconf_t *conf, int dyn_zone)$/;" f
zone_search zone.c /^const zone_t *zone_search (const zone_t *list, const char *zone)$/;" f
-zonelist dnssec-signer.c /^static zone_t *zonelist = NULL; \/* must be static global because add2zonelist use it *\/$/;" v file:
-zskflag dnssec-zkt.c /^int zskflag = 1;$/;" v
+zonelist zkt-signer.c /^static zone_t *zonelist = NULL; \/* must be static global because add2zonelist use it *\/$/;" v file:
+zskflag zkt-keyman.c /^int zskflag = 1;$/;" v
+zskflag zkt-ls.c /^int zskflag = 1;$/;" v
zskstatus rollover.c /^int zskstatus (dki_t **listp, const char *dir, const char *domain, const zconf_t *z)$/;" f
diff --git a/contrib/zkt/tcap.c b/contrib/zkt/tcap.c
new file mode 100644
index 0000000000..5763b01b7b
--- /dev/null
+++ b/contrib/zkt/tcap.c
@@ -0,0 +1,343 @@
+/*****************************************************************
+**
+** tcap.c -- termcap color capabilities
+**
+** (c) Jan 1991 - Feb 2010 by hoz
+**
+** Feb 2002 max line size increased to 512 byte
+** default terminal "html" added
+** Feb 2010 color capabilities added
+**
+*****************************************************************/
+
+#include
+#include
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+
+# include "config_zkt.h"
+
+#if defined(COLOR_MODE) && COLOR_MODE && HAVE_LIBNCURSES
+# ifdef HAVE_TERM_H
+# include
+# endif
+# ifdef HAVE_CURSES_H
+# include
+# endif
+#endif
+
+#define extern
+# include "tcap.h"
+#undef extern
+
+/*****************************************************************
+** global vars
+*****************************************************************/
+/* termcap strings */
+static const char *is1 = "";
+static const char *is2 = "";
+static const char *r1 = "";
+static const char *r2 = "";
+static const char *bold_on = "";
+static const char *bold_off = "";
+static const char *italic_on = "";
+static const char *italic_off = "";
+static char colortab[8][31+1];
+
+/* termcap numbers */
+static int maxcolor;
+
+/* function declaration */
+static int tc_printattr (FILE *fp, const char *attstr);
+static int tc_color (FILE *fp, int color);
+
+static int html = 0;
+
+
+
+/*****************************************************************
+** global functions
+*****************************************************************/
+#if defined(COLOR_MODE) && COLOR_MODE && HAVE_LIBNCURSES
+int tc_init (FILE *fp, const char *term)
+{
+ static char area[1024];
+ char buf[1024];
+ char *ap = area;
+ char *af = ""; /* AF */ /* ansi foreground */
+ int i;
+
+ /* clear all color strings */
+ for ( i = 0; i < 8; i++ )
+ colortab[i][0] = '\0';
+
+ if ( term == NULL || *term == '\0' ||
+ strcmp (term, "none") == 0 || strcmp (term, "dumb") == 0 )
+ return 0;
+
+ if ( strcmp (term, "html") == 0 || strcmp (term, "HTML") == 0 )
+ {
+ bold_on = "";
+ bold_off = "";
+ italic_on = "";
+ italic_off = "";
+ af = "";
+ maxcolor = 8;
+ snprintf (colortab[TC_BLACK], sizeof colortab[0], "");
+ snprintf (colortab[TC_BLUE], sizeof colortab[0], "");
+ snprintf (colortab[TC_GREEN], sizeof colortab[0], "");
+ snprintf (colortab[TC_CYAN], sizeof colortab[0], "");
+ snprintf (colortab[TC_RED], sizeof colortab[0], "");
+ snprintf (colortab[TC_MAGENTA], sizeof colortab[0], "");
+ snprintf (colortab[TC_YELLOW], sizeof colortab[0], "");
+ snprintf (colortab[TC_WHITE], sizeof colortab[0], "");
+ html = 1;
+ return 0;
+ }
+#if 0
+ if ( !istty (fp) )
+ return 0;
+#endif
+ switch ( tgetent (buf, term) )
+ {
+ case -1: perror ("termcap file");
+ return -1;
+ case 0: fprintf (stderr, "unknown terminal %s\n", term);
+ return -1;
+ }
+
+ if ( !(is1 = tgetstr ("is1", &ap)) )
+ is1 = "";
+ if ( !(is2 = tgetstr ("is2", &ap)) )
+ is2 = "";
+ if ( !(r1 = tgetstr ("r1", &ap)) )
+ r1 = "";
+ if ( !(r2 = tgetstr ("r2", &ap)) )
+ r2 = "";
+
+ /* if bold is not present */
+ if ( !(bold_on = tgetstr ("md", &ap)) )
+ /* use standout mode */
+ if ( !(bold_on = tgetstr ("so", &ap)) )
+ bold_on = bold_off = "";
+ else
+ bold_off = tgetstr ("se", &ap);
+ else
+ bold_off = tgetstr ("me", &ap);
+
+ /* if italic not present */
+ if ( !(italic_on = tgetstr ("ZH", &ap)) )
+ /* use underline mode */
+ if ( !(italic_on = tgetstr ("us", &ap)) )
+ italic_on = italic_off = "";
+ else
+ italic_off = tgetstr ("ue", &ap);
+ else
+ italic_off = tgetstr ("ZR", &ap);
+
+ maxcolor = tgetnum ("Co");
+ if ( maxcolor < 0 ) /* no colors ? */
+ return 0;
+ if ( maxcolor > 8 )
+ maxcolor = 8;
+
+ if ( (af = tgetstr ("AF", &ap)) ) /* set ansi color foreground */
+ {
+ for ( i = 0; i < maxcolor; i++ )
+ snprintf (colortab[i], sizeof colortab[0], "%s", tparm (af, i));
+ }
+ else if ( (af = tgetstr ("Sf", &ap)) ) /* or set color foreground */
+ {
+ snprintf (colortab[TC_BLACK], sizeof colortab[0], "%s", tparm (af, 0));
+ snprintf (colortab[TC_BLUE], sizeof colortab[0], "%s", tparm (af, 1));
+ snprintf (colortab[TC_GREEN], sizeof colortab[0], "%s", tparm (af, 2));
+ snprintf (colortab[TC_CYAN], sizeof colortab[0], "%s", tparm (af, 3));
+ snprintf (colortab[TC_RED], sizeof colortab[0], "%s", tparm (af, 4));
+ snprintf (colortab[TC_MAGENTA], sizeof colortab[0], "%s", tparm (af, 5));
+ snprintf (colortab[TC_YELLOW], sizeof colortab[0], "%s", tparm (af, 6));
+ snprintf (colortab[TC_WHITE], sizeof colortab[0], "%s", tparm (af, 7));
+ }
+
+#if 0
+ if ( is1 && *is1 )
+ tc_printattr (fp, is1);
+ if ( is2 && *is2 )
+ tc_printattr (fp, is2);
+#endif
+
+ return 0;
+}
+#else
+int tc_init (FILE *fp, const char *term)
+{
+ int i;
+
+ is1 = "";
+ is2 = "";
+ r1 = "";
+ r2 = "";
+ bold_on = "";
+ bold_off = "";
+ italic_on = "";
+ italic_off = "";
+ for ( i = 0; i < 8; i++ )
+ colortab[i][0] = '\0';
+ maxcolor = 0;
+ html = 0;
+
+ return 0;
+}
+#endif
+
+#if defined(COLOR_MODE) && COLOR_MODE && HAVE_LIBNCURSES
+int tc_end (FILE *fp, const char *term)
+{
+#if 0
+ if ( term )
+ {
+// if ( r1 && *r1 ) tc_printattr (fp, r1);
+ if ( r2 && *r2 )
+ tc_printattr (fp, r2);
+ }
+#endif
+ return 0;
+}
+#else
+int tc_end (FILE *fp, const char *term)
+{
+ return 0;
+}
+#endif
+
+#if defined(COLOR_MODE) && COLOR_MODE && HAVE_LIBNCURSES
+int tc_attr (FILE *fp, tc_att_t attr, int on)
+{
+ int len;
+
+ len = 0;
+ if ( on ) /* turn attributes on ? */
+ {
+ if ( (attr & TC_BOLD) == TC_BOLD )
+ len += tc_printattr (fp, bold_on);
+ if ( (attr & TC_ITALIC) == TC_ITALIC )
+ len += tc_printattr (fp, italic_on);
+
+ if ( attr & 0xFF )
+ len += tc_color (fp, attr & 0xFF);
+ }
+ else /* turn attributes off */
+ {
+ if ( html )
+ len += fprintf (fp, "");
+ else
+ len += tc_color (fp, TC_BLACK);
+
+ if ( (attr & TC_ITALIC) == TC_ITALIC )
+ len += tc_printattr (fp, italic_off);
+ if ( !html || (attr & TC_BOLD) == TC_BOLD )
+ len += tc_printattr (fp, bold_off);
+ }
+
+ return len;
+}
+#else
+int tc_attr (FILE *fp, tc_att_t attr, int on)
+{
+ return 0;
+}
+#endif
+
+/*****************************************************************
+** internal functions
+*****************************************************************/
+static FILE *tc_outfp;
+static int put (int c)
+{
+ return putc (c, tc_outfp);
+}
+
+#if defined(COLOR_MODE) && COLOR_MODE && HAVE_LIBNCURSES
+static int tc_printattr (FILE *fp, const char *attstr)
+{
+ tc_outfp = fp;
+ return tputs (attstr, 0, put);
+}
+#else
+static int tc_printattr (FILE *fp, const char *attstr)
+{
+ return 0;
+}
+#endif
+
+#if defined(COLOR_MODE) && COLOR_MODE && HAVE_LIBNCURSES
+static int tc_color (FILE *fp, int color)
+{
+ tc_outfp = fp;
+
+ if ( color < 0 || color >= maxcolor )
+ return 0;
+ return tputs (colortab[color], 0, put);
+}
+#else
+static int tc_color (FILE *fp, int color)
+{
+ return 0;
+}
+#endif
+
+
+#ifdef TEST
+static const char *progname;
+/*****************************************************************
+** test main()
+*****************************************************************/
+main (int argc, const char *argv[])
+{
+ extern char *getenv ();
+ char *term = getenv ("TERM");
+ int i;
+ const char *text;
+
+ progname = *argv;
+
+ tc_init (stdout, term);
+
+ // printattr (is); /* Initialisierungsstring ausgeben */
+
+ text = "Test";
+ if ( argc > 1 )
+ text = *++argv;
+
+ tc_attr (stdout, TC_BOLD, 1);
+ printf ("Bold Headline\n");
+ tc_attr (stdout, TC_BOLD, 0);
+ for ( i = 0; i < 8; i++ )
+ {
+ tc_attr (stdout, i, 1);
+ printf ("%s", text);
+ tc_attr (stdout, i, 0);
+
+#if 0
+ tc_attr (stdout, (i | TC_BOLD), 1);
+ printf ("\t%s", text);
+ tc_attr (stdout, (i | TC_BOLD), 0);
+
+ tc_attr (stdout, (i | TC_ITALIC), 1);
+ printf ("\t%s", text);
+ tc_attr (stdout, (i | TC_ITALIC), 0);
+
+ tc_attr (stdout, (i | TC_BOLD | TC_ITALIC), 1);
+ printf ("\t%s", text);
+ tc_attr (stdout, (i | TC_BOLD | TC_ITALIC), 0);
+#endif
+ printf ("\n");
+ }
+ printf ("now back to black\n");
+
+ // printattr (r2); /* Zuruecksetzen */
+
+ return (0);
+}
+#endif
diff --git a/contrib/zkt/tcap.h b/contrib/zkt/tcap.h
new file mode 100644
index 0000000000..27ca051405
--- /dev/null
+++ b/contrib/zkt/tcap.h
@@ -0,0 +1,29 @@
+/*****************************************************************
+**
+** tcap.h -- termcap color capabilities
+**
+** (c) Mar 2010 by hoz
+**
+*****************************************************************/
+
+#ifndef TCAP_H
+# define TCAP_H
+
+typedef enum {
+ TC_BLACK = 0,
+ TC_RED,
+ TC_GREEN,
+ TC_YELLOW,
+ TC_BLUE,
+ TC_MAGENTA,
+ TC_CYAN,
+ TC_WHITE,
+
+ TC_BOLD = 0x100,
+ TC_ITALIC = 0x200
+} tc_att_t;
+
+extern int tc_init (FILE *fp, const char *term);
+extern int tc_end (FILE *fp, const char *term);
+extern int tc_attr (FILE *fp, tc_att_t attr, int on);
+#endif
diff --git a/contrib/zkt/zconf.c b/contrib/zkt/zconf.c
index 5c7a66f88f..25cdb18ddc 100644
--- a/contrib/zkt/zconf.c
+++ b/contrib/zkt/zconf.c
@@ -5,9 +5,10 @@
** Most of the code is from the SixXS Heartbeat Client
** written by Jeroen Massar
**
-** New config types and some slightly code changes by Holger Zuleger
+** New config types and many code changes by Holger Zuleger
**
-** Copyright (c) Aug 2005, Jeroen Massar, Holger Zuleger.
+** Copyright (c) Aug 2005, Jeroen Massar.
+** Copyright (c) Aug 2005 - Apr 2010, Holger Zuleger.
** All rights reserved.
**
** This software is open source.
@@ -66,9 +67,17 @@
strcasecmp (val, "true") == 0 )
# define ISCOMMENT(cp) (*(cp) == '#' || *(cp) == ';' || \
(*(cp) == '/' && *((cp)+1) == '/') )
-# define ISDELIM(c) ( isspace (c) || (c) == ':' || (c) == '=' )
+# define ISDELIM(c) (isspace (c) || (c) == ':' || (c) == '=')
+# define cmdln (0)
+# define first (1)
+# define last (0x7FFF)
+
+# define iscmdline(x) ((x)->used_since == cmdln)
+# define iscompatible(x) ((x)->used_since != cmdln && compversion >= (x)->used_since && \
+ ((x)->used_till == 1 || (compversion <= (x)->used_till)))
+
typedef enum {
CONF_END = 0,
CONF_STRING,
@@ -79,100 +88,131 @@ typedef enum {
CONF_SERIAL,
CONF_FACILITY,
CONF_LEVEL,
+ CONF_NSEC3,
CONF_COMMENT,
+ CONF_VERSION,
} ctype_t;
/*****************************************************************
** private (static) variables
*****************************************************************/
+static int compversion;
+
static zconf_t def = {
ZONEDIR, RECURSIVE,
- PRINTTIME, PRINTAGE, LJUST,
- SIG_VALIDITY, MAX_TTL, KEY_TTL, PROPTIME, Incremental,
+ PRINTTIME, PRINTAGE, LJUST, LSCOLORTERM,
+ SIG_VALIDITY, MAX_TTL, KEY_TTL, PROPTIME, Unixtime,
RESIGN_INT,
KEY_ALGO, ADDITIONAL_KEY_ALGO,
KSK_LIFETIME, KSK_BITS, KSK_RANDOM,
ZSK_LIFETIME, ZSK_BITS, ZSK_RANDOM,
- SALTLEN,
+ NSEC3_OFF, SALTLEN,
NULL, /* viewname cmdline parameter */
0, /* noexec cmdline parameter */
- LOGFILE, LOGLEVEL, SYSLOGFACILITY, SYSLOGLEVEL, VERBOSELOG, 0,
+ LOGFILE, LOGLEVEL, LOGDOMAINDIR, SYSLOGFACILITY, SYSLOGLEVEL, VERBOSELOG, 0,
DNSKEYFILE, ZONEFILE, KEYSETDIR,
LOOKASIDEDOMAIN,
- SIG_RANDOM, SIG_PSEUDO, SIG_GENDS, SIG_PARAM,
+ SIG_RANDOM, SIG_PSEUDO, SIG_GENDS, SIG_DNSKEY_KSK, SIG_PARAM,
DIST_CMD, /* defaults to NULL which means to run "rndc reload" */
NAMED_CHROOT
};
typedef struct {
char *label; /* the name of the paramter */
- int cmdline; /* is this a command line parameter ? */
+ short used_since; /* compability (from version; 0 == command line) */
+ short used_till; /* compability (to version) */
ctype_t type; /* the parameter type */
void *var; /* pointer to the parameter variable */
+ const void *var2; /* pointer to a second parameter variable */
+ /* this is a ugly hack needed by cmpconfig () */
} zconf_para_t;
static zconf_para_t confpara[] = {
- { "", 0, CONF_COMMENT, ""},
- { "", 0, CONF_COMMENT, "\t@(#) dnssec.conf " ZKT_VERSION },
- { "", 0, CONF_COMMENT, ""},
- { "", 0, CONF_COMMENT, NULL },
+ { "", first, last, CONF_COMMENT, ""},
+ { "", first, last, CONF_COMMENT, "\t@(#) dnssec.conf "},
+ { "", first, last, CONF_VERSION, "" },
+ { "", first, last, CONF_COMMENT, ""},
+ { "", first, last, CONF_COMMENT, NULL },
- { "", 0, CONF_COMMENT, "dnssec-zkt options" },
- { "Zonedir", 0, CONF_STRING, &def.zonedir },
- { "Recursive", 0, CONF_BOOL, &def.recursive },
- { "PrintTime", 0, CONF_BOOL, &def.printtime },
- { "PrintAge", 0, CONF_BOOL, &def.printage },
- { "LeftJustify", 0, CONF_BOOL, &def.ljust },
+ { "", first, 99, CONF_COMMENT, "dnssec-zkt options" },
+ { "", 100, last, CONF_COMMENT, "zkt-ls options" },
+ { "ZoneDir", first, last, CONF_STRING, &def.zonedir },
+ { "Recursive", first, last, CONF_BOOL, &def.recursive },
+ { "PrintTime", first, last, CONF_BOOL, &def.printtime },
+ { "PrintAge", first, last, CONF_BOOL, &def.printage },
+ { "LeftJustify", first, last, CONF_BOOL, &def.ljust },
+ { "lsColor", 100, last, CONF_STRING, &def.colorterm },
- { "", 0, CONF_COMMENT, NULL },
- { "", 0, CONF_COMMENT, "zone specific values" },
- { "ResignInterval", 0, CONF_TIMEINT, &def.resign },
- { "Sigvalidity", 0, CONF_TIMEINT, &def.sigvalidity },
- { "Max_TTL", 0, CONF_TIMEINT, &def.max_ttl },
- { "Propagation", 0, CONF_TIMEINT, &def.proptime },
- { "KEY_TTL", 0, CONF_TIMEINT, &def.key_ttl },
+ { "", first, last, CONF_COMMENT, NULL },
+ { "", first, last, CONF_COMMENT, "zone specific values" },
+ { "ResignInterval", first, last, CONF_TIMEINT, &def.resign },
+ { "SigValidity", first, last, CONF_TIMEINT, &def.sigvalidity },
+ { "Max_TTL", first, 100, CONF_TIMEINT, &def.max_ttl },
+ { "MaximumTTL", 101, last, CONF_TIMEINT, &def.max_ttl },
+ { "Propagation", first, last, CONF_TIMEINT, &def.proptime },
+ { "Key_TTL", 90, 100, CONF_TIMEINT, &def.key_ttl },
+ { "DnsKeyTTL", 101, last, CONF_TIMEINT, &def.key_ttl },
#if defined (DEF_TTL)
- { "def_ttl", 0, CONF_TIMEINT, &def.def_ttl },
+ { "def_ttl", first, last, CONF_TIMEINT, &def.def_ttl },
#endif
- { "Serialformat", 0, CONF_SERIAL, &def.serialform },
+ { "SerialFormat", 92, last, CONF_SERIAL, &def.serialform },
- { "", 0, CONF_COMMENT, NULL },
- { "", 0, CONF_COMMENT, "signing key parameters"},
- { "Key_algo", 0, CONF_ALGO, &def.k_algo }, /* now used as general KEY algoritjm (KSK & ZSK) */
- { "AddKey_algo", 0, CONF_ALGO, &def.k2_algo }, /* second key algorithm added (v0.99) */
- { "KSK_lifetime", 0, CONF_TIMEINT, &def.k_life },
- { "KSK_algo", 1, CONF_ALGO, &def.k_algo }, /* old KSK value changed to key algorithm */
- { "KSK_bits", 0, CONF_INT, &def.k_bits },
- { "KSK_randfile", 0, CONF_STRING, &def.k_random },
- { "ZSK_lifetime", 0, CONF_TIMEINT, &def.z_life },
- /* { "ZSK_algo", 1, CONF_ALGO, &def.z_algo }, ZSK algo removed (set to same as ksk) */
- { "ZSK_algo", 1, CONF_ALGO, &def.k2_algo }, /* if someone using it already, map the algo to the additional key algorithm */
- { "ZSK_bits", 0, CONF_INT, &def.z_bits },
- { "ZSK_randfile", 0, CONF_STRING, &def.z_random },
- { "SaltBits", 0, CONF_INT, &def.saltbits },
+ { "", first, last, CONF_COMMENT, NULL },
+ { "", first, last, CONF_COMMENT, "signing key parameters"},
+ { "Key_Algo", 99, 100, CONF_ALGO, &def.k_algo }, /* now used as general KEY algoritjm (KSK & ZSK) */
+ { "KeyAlgo", 101, last, CONF_ALGO, &def.k_algo }, /* now used as general KEY algoritjm (KSK & ZSK) */
+ { "AddKey_Algo", 99, 100, CONF_ALGO, &def.k2_algo }, /* second key algorithm added (v0.99) */
+ { "AddKeyAlgo", 101, last, CONF_ALGO, &def.k2_algo }, /* second key algorithm added (v0.99) */
+ { "KSK_lifetime", first, 100, CONF_TIMEINT, &def.k_life },
+ { "KSKlifetime", 101, last, CONF_TIMEINT, &def.k_life },
+ { "KSK_algo", first, 98, CONF_ALGO, &def.k_algo }, /* old KSK value changed to key algorithm */
+ { "KSK_bits", first, 100, CONF_INT, &def.k_bits },
+ { "KSKbits", 101, last, CONF_INT, &def.k_bits },
+ { "KSK_randfile", first, 100, CONF_STRING, &def.k_random },
+ { "KSKrandfile", 101, last, CONF_STRING, &def.k_random },
+ { "ZSK_lifetime", first, 100, CONF_TIMEINT, &def.z_life },
+ { "ZSKlifetime", 101, last, CONF_TIMEINT, &def.z_life },
+ /* { "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 */
+ { "ZSK_bits", first, 100, CONF_INT, &def.z_bits },
+ { "ZSKbits", 101, last, CONF_INT, &def.z_bits },
+ { "ZSK_randfile", first, 100, CONF_STRING, &def.z_random },
+ { "ZSKrandfile", 101, last, CONF_STRING, &def.z_random },
+ { "NSEC3", 100, last, CONF_NSEC3, &def.nsec3 },
+ { "SaltBits", 98, last, CONF_INT, &def.saltbits },
- { "", 0, CONF_COMMENT, NULL },
- { "", 0, CONF_COMMENT, "dnssec-signer options"},
- { "--view", 1, CONF_STRING, &def.view },
- { "--noexec", 1, CONF_BOOL, &def.noexec },
- { "LogFile", 0, CONF_STRING, &def.logfile },
- { "LogLevel", 0, CONF_LEVEL, &def.loglevel },
- { "SyslogFacility", 0, CONF_FACILITY, &def.syslogfacility },
- { "SyslogLevel", 0, CONF_LEVEL, &def.sysloglevel },
- { "VerboseLog", 0, CONF_INT, &def.verboselog },
- { "-v", 1, CONF_INT, &def.verbosity },
- { "Keyfile", 0, CONF_STRING, &def.keyfile },
- { "Zonefile", 0, CONF_STRING, &def.zonefile },
- { "KeySetDir", 0, CONF_STRING, &def.keysetdir },
- { "DLV_Domain", 0, CONF_STRING, &def.lookaside },
- { "Sig_Randfile", 0, CONF_STRING, &def.sig_random },
- { "Sig_Pseudorand", 0, CONF_BOOL, &def.sig_pseudo },
- { "Sig_GenerateDS", 0, CONF_BOOL, &def.sig_gends },
- { "Sig_Parameter", 0, CONF_STRING, &def.sig_param },
- { "Distribute_Cmd", 0, CONF_STRING, &def.dist_cmd },
- { "NamedChrootDir", 0, CONF_STRING, &def.chroot_dir },
+ { "", first, last, CONF_COMMENT, NULL },
+ { "", first, 99, CONF_COMMENT, "dnssec-signer options"},
+ { "", 100, last, CONF_COMMENT, "zkt-signer options"},
+ { "--view", cmdln, last, CONF_STRING, &def.view },
+ { "--noexec", cmdln, last, CONF_BOOL, &def.noexec },
+ { "LogFile", 96, last, CONF_STRING, &def.logfile },
+ { "LogLevel", 96, last, CONF_LEVEL, &def.loglevel },
+ { "LogDomainDir", 96, last, CONF_STRING, &def.logdomaindir },
+ { "SyslogFacility", 96, last, CONF_FACILITY, &def.syslogfacility },
+ { "SyslogLevel", 96, last, CONF_LEVEL, &def.sysloglevel },
+ { "VerboseLog", 96, last, CONF_INT, &def.verboselog },
+ { "-v", cmdln, last, CONF_INT, &def.verbosity },
+ { "KeyFile", first, last, CONF_STRING, &def.keyfile },
+ { "ZoneFile", first, last, CONF_STRING, &def.zonefile },
+ { "KeySetDir", first, last, CONF_STRING, &def.keysetdir },
+ { "DLV_Domain", first, 100, CONF_STRING, &def.lookaside },
+ { "DLVdomain", 101, last, CONF_STRING, &def.lookaside },
+ { "Sig_Randfile", first, 100, CONF_STRING, &def.sig_random },
+ { "SigRandfile", 101, last, CONF_STRING, &def.sig_random },
+ { "Sig_Pseudorand", first, 100, CONF_BOOL, &def.sig_pseudo },
+ { "SigPseudorand", 101, last, CONF_BOOL, &def.sig_pseudo },
+ { "Sig_GenerateDS", first, 100, CONF_BOOL, &def.sig_gends },
+ { "SigGenerateDS", 101, last, CONF_BOOL, &def.sig_gends },
+ { "Sig_DnsKeyKSK", 99, 100, CONF_BOOL, &def.sig_dnskeyksk },
+ { "SigDnsKeyKSK", 101, last, CONF_BOOL, &def.sig_dnskeyksk },
+ { "Sig_Parameter", first, 100, CONF_STRING, &def.sig_param },
+ { "SigParameter", 101, last, CONF_STRING, &def.sig_param },
+ { "Distribute_Cmd", 97, 100, CONF_STRING, &def.dist_cmd },
+ { "DistributeCmd", 101, last, CONF_STRING, &def.dist_cmd },
+ { "NamedChrootDir", 99, last, CONF_STRING, &def.chroot_dir },
- { NULL, 0, CONF_END, NULL},
+ { NULL, 0, 0, CONF_END, NULL},
};
/*****************************************************************
@@ -183,29 +223,7 @@ static const char *bool2str (int val)
return val ? "True" : "False";
}
-static const char *timeint2str (ulong val)
-{
- static char str[20+1];
-
- if ( val == 0 )
- snprintf (str, sizeof (str), "%lu", val / YEARSEC);
- else if ( val % YEARSEC == 0 )
- snprintf (str, sizeof (str), "%luy", val / YEARSEC);
- else if ( val % WEEKSEC == 0 )
- snprintf (str, sizeof (str), "%luw", val / WEEKSEC);
- else if ( val % DAYSEC == 0 )
- snprintf (str, sizeof (str), "%lud", val / DAYSEC);
- else if ( val % HOURSEC == 0 )
- snprintf (str, sizeof (str), "%luh", val / HOURSEC);
- else if ( val % MINSEC == 0 )
- snprintf (str, sizeof (str), "%lum", val / MINSEC);
- else
- snprintf (str, sizeof (str), "%lus", val);
-
- return str;
-}
-
-static int set_varptr (char *entry, void *ptr)
+static int set_varptr (char *entry, void *ptr, const void *ptr2)
{
zconf_para_t *c;
@@ -213,61 +231,66 @@ static int set_varptr (char *entry, void *ptr)
if ( strcasecmp (entry, c->label) == 0 )
{
c->var = ptr;
+ c->var2 = ptr2;
return 1;
}
return 0;
}
-static void set_all_varptr (zconf_t *cp)
+static void set_all_varptr (zconf_t *cp, const zconf_t *cp2)
{
- set_varptr ("zonedir", &cp->zonedir);
- set_varptr ("recursive", &cp->recursive);
- set_varptr ("printage", &cp->printage);
- set_varptr ("printtime", &cp->printtime);
- set_varptr ("leftjustify", &cp->ljust);
+ set_varptr ("zonedir", &cp->zonedir, cp2 ? &cp2->zonedir: NULL);
+ set_varptr ("recursive", &cp->recursive, cp2 ? &cp2->recursive: NULL);
+ set_varptr ("printage", &cp->printage, cp2 ? &cp2->printage: NULL);
+ set_varptr ("printtime", &cp->printtime, cp2 ? &cp2->printtime: NULL);
+ set_varptr ("leftjustify", &cp->ljust, cp2 ? &cp2->ljust: NULL);
+ set_varptr ("lscolor", &cp->colorterm, cp2 ? &cp2->colorterm: NULL);
- set_varptr ("resigninterval", &cp->resign);
- set_varptr ("sigvalidity", &cp->sigvalidity);
- set_varptr ("max_ttl", &cp->max_ttl);
- set_varptr ("key_ttl", &cp->key_ttl);
- set_varptr ("propagation", &cp->proptime);
+ set_varptr ("resigninterval", &cp->resign, cp2 ? &cp2->resign: NULL);
+ set_varptr ("sigvalidity", &cp->sigvalidity, cp2 ? &cp2->sigvalidity: NULL);
+ set_varptr ("max_ttl", &cp->max_ttl, cp2 ? &cp2->max_ttl: NULL);
+ set_varptr ("key_ttl", &cp->key_ttl, cp2 ? &cp2->key_ttl: NULL);
+ set_varptr ("propagation", &cp->proptime, cp2 ? &cp2->proptime: NULL);
#if defined (DEF_TTL)
- set_varptr ("def_ttl", &cp->def_ttl);
+ set_varptr ("def_ttl", &cp->def_ttl, cp2 ? &cp2->def_ttl: NULLl);
#endif
- set_varptr ("serialformat", &cp->serialform);
+ set_varptr ("serialformat", &cp->serialform, cp2 ? &cp2->serialform: NULL);
- set_varptr ("key_algo", &cp->k_algo);
- set_varptr ("addkey_algo", &cp->k2_algo);
- set_varptr ("ksk_lifetime", &cp->k_life);
- set_varptr ("ksk_algo", &cp->k_algo); /* to be removed in next release */
- set_varptr ("ksk_bits", &cp->k_bits);
- set_varptr ("ksk_randfile", &cp->k_random);
+ set_varptr ("key_algo", &cp->k_algo, cp2 ? &cp2->k_algo: NULL);
+ set_varptr ("addkey_algo", &cp->k2_algo, cp2 ? &cp2->k2_algo: NULL);
+ set_varptr ("ksk_lifetime", &cp->k_life, cp2 ? &cp2->k_life: NULL);
+ set_varptr ("ksk_algo", &cp->k_algo, cp2 ? &cp2->k_algo: NULL); /* used only in compability mode */
+ set_varptr ("ksk_bits", &cp->k_bits, cp2 ? &cp2->k_bits: NULL);
+ set_varptr ("ksk_randfile", &cp->k_random, cp2 ? &cp2->k_random: NULL);
- set_varptr ("zsk_lifetime", &cp->z_life);
- // set_varptr ("zsk_algo", &cp->z_algo);
- set_varptr ("zsk_algo", &cp->k2_algo);
- set_varptr ("zsk_bits", &cp->z_bits);
- set_varptr ("zsk_randfile", &cp->z_random);
- set_varptr ("saltbits", &cp->saltbits);
+ set_varptr ("zsk_lifetime", &cp->z_life, cp2 ? &cp2->z_life: NULL);
+ // set_varptr ("zsk_algo", &cp->z_algo, cp2 ? &cp2->z_algo: NULL);
+ set_varptr ("zsk_algo", &cp->k2_algo, cp2 ? &cp2->k2_algo: NULL);
+ set_varptr ("zsk_bits", &cp->z_bits, cp2 ? &cp2->z_bits: NULL);
+ set_varptr ("zsk_randfile", &cp->z_random, cp2 ? &cp2->z_random: NULL);
+ set_varptr ("nsec3", &cp->nsec3, cp2 ? &cp2->nsec3: NULL);
+ set_varptr ("saltbits", &cp->saltbits, cp2 ? &cp2->saltbits: NULL);
- set_varptr ("--view", &cp->view);
- set_varptr ("--noexec", &cp->noexec);
- set_varptr ("logfile", &cp->logfile);
- set_varptr ("loglevel", &cp->loglevel);
- set_varptr ("syslogfacility", &cp->syslogfacility);
- set_varptr ("sysloglevel", &cp->sysloglevel);
- set_varptr ("verboselog", &cp->verboselog);
- set_varptr ("-v", &cp->verbosity);
- set_varptr ("keyfile", &cp->keyfile);
- set_varptr ("zonefile", &cp->zonefile);
- set_varptr ("keysetdir", &cp->keysetdir);
- set_varptr ("dlv_domain", &cp->lookaside);
- set_varptr ("sig_randfile", &cp->sig_random);
- set_varptr ("sig_pseudorand", &cp->sig_pseudo);
- set_varptr ("sig_generateds", &cp->sig_gends);
- set_varptr ("sig_parameter", &cp->sig_param);
- set_varptr ("distribute_cmd", &cp->dist_cmd);
- set_varptr ("namedchrootdir", &cp->chroot_dir);
+ set_varptr ("--view", &cp->view, cp2 ? &cp2->view: NULL);
+ set_varptr ("--noexec", &cp->noexec, cp2 ? &cp2->noexec: NULL);
+ set_varptr ("logfile", &cp->logfile, cp2 ? &cp2->logfile: NULL);
+ set_varptr ("loglevel", &cp->loglevel, cp2 ? &cp2->loglevel: NULL);
+ set_varptr ("logdomaindir", &cp->logdomaindir, cp2 ? &cp2->logdomaindir: NULL);
+ set_varptr ("syslogfacility", &cp->syslogfacility, cp2 ? &cp2->syslogfacility: NULL);
+ set_varptr ("sysloglevel", &cp->sysloglevel, cp2 ? &cp2->sysloglevel: NULL);
+ set_varptr ("verboselog", &cp->verboselog, cp2 ? &cp2->verboselog: NULL);
+ set_varptr ("-v", &cp->verbosity, cp2 ? &cp2->verbosity: NULL);
+ set_varptr ("keyfile", &cp->keyfile, cp2 ? &cp2->keyfile: NULL);
+ set_varptr ("zonefile", &cp->zonefile, cp2 ? &cp2->zonefile: NULL);
+ set_varptr ("keysetdir", &cp->keysetdir, cp2 ? &cp2->keysetdir: NULL);
+ set_varptr ("dlv_domain", &cp->lookaside, cp2 ? &cp2->lookaside: NULL);
+ set_varptr ("sig_randfile", &cp->sig_random, cp2 ? &cp2->sig_random: NULL);
+ set_varptr ("sig_pseudorand", &cp->sig_pseudo, cp2 ? &cp2->sig_pseudo: NULL);
+ set_varptr ("sig_generateds", &cp->sig_gends, cp2 ? &cp2->sig_gends: NULL);
+ set_varptr ("sig_dnskeyksk", &cp->sig_dnskeyksk, cp2 ? &cp2->sig_dnskeyksk: NULL);
+ set_varptr ("sig_parameter", &cp->sig_param, cp2 ? &cp2->sig_param: NULL);
+ set_varptr ("distribute_cmd", &cp->dist_cmd, cp2 ? &cp2->dist_cmd: NULL);
+ set_varptr ("namedchrootdir", &cp->chroot_dir, cp2 ? &cp2->chroot_dir: NULL);
}
static void parseconfigline (char *buf, unsigned int line, zconf_t *z)
@@ -298,7 +321,6 @@ static void parseconfigline (char *buf, unsigned int line, zconf_t *z)
*p++ = '\0'; /* Terminate this argument */
dbg_val1 ("Parsing \"%s\"\n", tag);
-
while ( p < end && ISDELIM (*p) ) /* Skip delim chars */
p++;
@@ -327,7 +349,6 @@ static void parseconfigline (char *buf, unsigned int line, zconf_t *z)
}
/* Otherwise it is already terminated above */
-
found = 0;
c = confpara;
while ( !found && c->type != CONF_END )
@@ -342,6 +363,8 @@ static void parseconfigline (char *buf, unsigned int line, zconf_t *z)
found = 1;
switch ( c->type )
{
+ case CONF_VERSION:
+ break;
case CONF_LEVEL:
case CONF_FACILITY:
case CONF_STRING:
@@ -354,7 +377,10 @@ static void parseconfigline (char *buf, unsigned int line, zconf_t *z)
break;
case CONF_TIMEINT:
quantity = 'd';
- sscanf (val, "%ld%c", &lval, &quantity);
+ if ( *val == 'u' || *val == 'U' )
+ lval = 0L;
+ else
+ sscanf (val, "%ld%c", &lval, &quantity);
if ( quantity == 'm' )
lval *= MINSEC;
else if ( quantity == 'h' )
@@ -368,18 +394,41 @@ static void parseconfigline (char *buf, unsigned int line, zconf_t *z)
(*(long *)c->var) = lval;
break;
case CONF_ALGO:
- if ( strcasecmp (val, "rsa") == 0 || strcasecmp (val, "rsamd5") == 0 )
+ if ( strcmp (val, "1") == 0 || strcasecmp (val, "rsa") == 0 ||
+ strcasecmp (val, "rsamd5") == 0 )
*((int *)c->var) = DK_ALGO_RSA;
- else if ( strcasecmp (val, "dsa") == 0 )
+ else if ( strcmp (val, "3") == 0 ||
+ strcasecmp (val, "dsa") == 0 )
*((int *)c->var) = DK_ALGO_DSA;
- else if ( strcasecmp (val, "rsasha1") == 0 )
+ else if ( strcmp (val, "5") == 0 ||
+ strcasecmp (val, "rsasha1") == 0 )
*((int *)c->var) = DK_ALGO_RSASHA1;
- else if ( strcasecmp (val, "nsec3dsa") == 0 ||
+ else if ( strcmp (val, "6") == 0 ||
+ strcasecmp (val, "nsec3dsa") == 0 ||
strcasecmp (val, "n3dsa") == 0 )
*((int *)c->var) = DK_ALGO_NSEC3DSA;
- else if ( strcasecmp (val, "nsec3rsasha1") == 0 ||
+ else if ( strcmp (val, "7") == 0 ||
+ strcasecmp (val, "nsec3rsasha1") == 0 ||
strcasecmp (val, "n3rsasha1") == 0 )
*((int *)c->var) = DK_ALGO_NSEC3RSASHA1;
+#if defined(BIND_VERSION) && BIND_VERSION >= 970
+ else if ( strcmp (val, "8") == 0 ||
+ strcasecmp (val, "rsasha2") == 0 ||
+ strcasecmp (val, "rsasha256") == 0 ||
+ strcasecmp (val, "nsec3rsasha2") == 0 ||
+ strcasecmp (val, "n3rsasha2") == 0 ||
+ strcasecmp (val, "nsec3rsasha256") == 0 ||
+ strcasecmp (val, "n3rsasha256") == 0 )
+ *((int *)c->var) = DK_ALGO_RSASHA256;
+ else if ( strcmp (val, "10") == 0 ||
+ strcasecmp (val, "rsasha5") == 0 ||
+ strcasecmp (val, "rsasha212") == 0 ||
+ strcasecmp (val, "nsec3rsasha5") == 0 ||
+ strcasecmp (val, "n3rsasha5") == 0 ||
+ strcasecmp (val, "nsec3rsasha512") == 0 ||
+ strcasecmp (val, "n3rsasha512") == 0 )
+ *((int *)c->var) = DK_ALGO_RSASHA512;
+#endif
else
error ("Illegal algorithm \"%s\" "
"in line %d.\n" , val, line);
@@ -387,12 +436,23 @@ static void parseconfigline (char *buf, unsigned int line, zconf_t *z)
case CONF_SERIAL:
if ( strcasecmp (val, "unixtime") == 0 )
*((serial_form_t *)c->var) = Unixtime;
- else if ( strcasecmp (val, "incremental") == 0 )
+ else if ( strcasecmp (val, "incremental") == 0 || strcasecmp (val, "inc") == 0 )
*((serial_form_t *)c->var) = Incremental;
else
error ("Illegal serial no format \"%s\" "
"in line %d.\n" , val, line);
break;
+ case CONF_NSEC3:
+ if ( strcasecmp (val, "off") == 0 )
+ *((nsec3_t *)c->var) = NSEC3_OFF;
+ else if ( strcasecmp (val, "on") == 0 )
+ *((nsec3_t *)c->var) = NSEC3_ON;
+ else if ( strcasecmp (val, "optout") == 0 )
+ *((nsec3_t *)c->var) = NSEC3_OPTOUT;
+ else
+ error ("Illegal NSEC3 format \"%s\" "
+ "in line %d.\n" , val, line);
+ break;
case CONF_BOOL:
*((int *)c->var) = ISTRUE (val);
break;
@@ -417,6 +477,10 @@ static void printconfigline (FILE *fp, zconf_para_t *cp)
switch ( cp->type )
{
+ case CONF_VERSION:
+ fprintf (fp, "#\tZKT config file for version %d.%02d\n",
+ compversion / 100, compversion % 100);
+ break;
case CONF_COMMENT:
if ( cp->var )
fprintf (fp, "# %s\n", (char *)cp->var);
@@ -451,23 +515,34 @@ static void printconfigline (FILE *fp, zconf_para_t *cp)
lval = *(ulong*)cp->var; /* in that case it should be of type ulong */
fprintf (fp, "%s:\t%s", cp->label, timeint2str (lval));
if ( lval )
- fprintf (fp, "\t# (%ld seconds)", lval);
+ fprintf (fp, "\t\t# (%ld seconds)", lval);
putc ('\n', fp);
break;
case CONF_ALGO:
i = *(int*)cp->var;
if ( i )
{
- fprintf (fp, "%s:\t%s", cp->label, dki_algo2str (i));
+ fprintf (fp, "%s:\t%s ", cp->label, dki_algo2str (i));
fprintf (fp, "\t# (Algorithm ID %d)\n", i);
}
break;
case CONF_SERIAL:
fprintf (fp, "%s:\t", cp->label);
if ( *(serial_form_t*)cp->var == Unixtime )
- fprintf (fp, "unixtime\n");
+ fprintf (fp, "UnixTime");
else
- fprintf (fp, "incremental\n");
+ fprintf (fp, "Incremental");
+ fprintf (fp, "\t# (UnixTime|Incremental)\n");
+ break;
+ case CONF_NSEC3:
+ fprintf (fp, "%s:\t\t", cp->label);
+ if ( *(nsec3_t*)cp->var == NSEC3_OFF )
+ fprintf (fp, "Off");
+ else if ( *(nsec3_t*)cp->var == NSEC3_ON )
+ fprintf (fp, "On");
+ else if ( *(nsec3_t*)cp->var == NSEC3_OPTOUT )
+ fprintf (fp, "OptOut");
+ fprintf (fp, "\t\t# (On|Off|OptOut)\n");
break;
case CONF_INT:
fprintf (fp, "%s:\t%d\n", cp->label, *(int *)cp->var);
@@ -482,13 +557,41 @@ static void printconfigline (FILE *fp, zconf_para_t *cp)
** public function definition
*****************************************************************/
+void setconfigversion (int version)
+{
+ compversion = version;
+}
+
+const char *timeint2str (unsigned long val)
+{
+ static char str[20+1];
+
+ if ( val == 0 )
+ snprintf (str, sizeof (str), "Unset");
+ else if ( val % YEARSEC == 0 )
+ snprintf (str, sizeof (str), "%luy", val / YEARSEC);
+ else if ( val % WEEKSEC == 0 )
+ snprintf (str, sizeof (str), "%luw", val / WEEKSEC);
+ else if ( val % DAYSEC == 0 )
+ snprintf (str, sizeof (str), "%lud", val / DAYSEC);
+ else if ( val % HOURSEC == 0 )
+ snprintf (str, sizeof (str), "%luh", val / HOURSEC);
+ else if ( val % MINSEC == 0 )
+ snprintf (str, sizeof (str), "%lum", val / MINSEC);
+ else
+ snprintf (str, sizeof (str), "%lus", val);
+
+ return str;
+}
+
+
/*****************************************************************
** 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
** allocated.
** If no filename is given the conf struct will be initialized
-** by the builtin default config
+** with the builtin default config
*****************************************************************/
zconf_t *loadconfig (const char *filename, zconf_t *z)
{
@@ -513,7 +616,7 @@ zconf_t *loadconfig (const char *filename, zconf_t *z)
}
dbg_val1 ("loadconfig (%s)\n", filename);
- set_all_varptr (z);
+ set_all_varptr (z, NULL);
if ( (fp = fopen(filename, "r")) == NULL )
fatal ("Could not open config file \"%s\"\n", filename);
@@ -548,7 +651,7 @@ zconf_t *loadconfig_fromstr (const char *str, zconf_t *z)
}
dbg_val1 ("loadconfig_fromstr (\"%s\")\n", str);
- set_all_varptr (z);
+ set_all_varptr (z, NULL);
/* str is const, so we have to copy it into a new buffer */
if ( (buf = strdup (str)) == NULL )
@@ -584,6 +687,18 @@ zconf_t *dupconfig (const zconf_t *conf)
return z;
}
+/*****************************************************************
+** freeconfig (config)
+** free memory for config struct and return a NULL ptr
+*****************************************************************/
+zconf_t *freeconfig (zconf_t *conf)
+{
+ if (conf != NULL);
+ free (conf);
+
+ return (zconf_t *)NULL;
+}
+
/*****************************************************************
** setconfigpar (entry, pval)
*****************************************************************/
@@ -592,13 +707,15 @@ int setconfigpar (zconf_t *config, char *entry, const void *pval)
char *str;
zconf_para_t *c;
- set_all_varptr (config);
+ set_all_varptr (config, NULL);
for ( c = confpara; c->type != CONF_END; c++ )
if ( strcasecmp (entry, c->label) == 0 )
{
switch ( c->type )
{
+ case CONF_VERSION:
+ break;
case CONF_LEVEL:
case CONF_FACILITY:
case CONF_STRING:
@@ -621,6 +738,9 @@ int setconfigpar (zconf_t *config, char *entry, const void *pval)
case CONF_TIMEINT:
*((long *)c->var) = *((long *)pval);
break;
+ case CONF_NSEC3:
+ *((nsec3_t *)c->var) = *((nsec3_t *)pval);
+ break;
case CONF_SERIAL:
*((serial_form_t *)c->var) = *((serial_form_t *)pval);
break;
@@ -659,10 +779,10 @@ int printconfig (const char *fname, const zconf_t *z)
}
}
- set_all_varptr ((zconf_t *)z);
+ set_all_varptr ((zconf_t *)z, NULL);
for ( cp = confpara; cp->type != CONF_END; cp++ ) /* loop through all parameter */
- if ( !cp->cmdline ) /* if this is not a command line parameter ? */
+ if ( iscompatible (cp) ) /* is parameter compatible to current version? */
printconfigline (fp, cp); /* print it out */
if ( fp && fp != stdout && fp != stderr )
@@ -671,13 +791,14 @@ int printconfig (const char *fname, const zconf_t *z)
return 1;
}
-#if 0
/*****************************************************************
** printconfigdiff (fname, conf_a, conf_b)
*****************************************************************/
int printconfigdiff (const char *fname, const zconf_t *ref, const zconf_t *z)
{
zconf_para_t *cp;
+ int eq;
+ char *p1, *p2;
FILE *fp;
if ( ref == NULL || z == NULL )
@@ -697,14 +818,47 @@ int printconfigdiff (const char *fname, const zconf_t *ref, const zconf_t *z)
}
}
- set_all_varptr ((zconf_t *)z);
+ set_all_varptr ((zconf_t *)z, ref);
for ( cp = confpara; cp->type != CONF_END; cp++ ) /* loop through all parameter */
{
- if ( cp->cmdline )
+ eq = 0;
+ if ( iscmdline (cp) ) /* skip command line parameter */
continue;
-
+ switch ( cp->type )
+ {
+ case CONF_VERSION:
+ case CONF_END:
+ case CONF_COMMENT:
+ continue;
+ case CONF_NSEC3:
+ eq = ( *(nsec3_t *)cp->var == *(nsec3_t *)cp->var2 );
+ break;
+ case CONF_SERIAL:
+ eq = ( *(serial_form_t *)cp->var == *(serial_form_t *)cp->var2 );
+ break;
+ case CONF_BOOL:
+ case CONF_ALGO:
+ case CONF_INT:
+ eq = ( *(int *)cp->var == *(int *)cp->var2 );
+ break;
+ case CONF_TIMEINT:
+ eq = ( *(long *)cp->var == *(long *)cp->var2 );
+ break;
+ case CONF_LEVEL:
+ case CONF_FACILITY:
+ case CONF_STRING:
+ p1 = *(char **)cp->var;
+ p2 = *(char **)cp->var2;
+ if ( p1 && p2 )
+ eq = strcmp (p1, p2) == 0;
+ else if ( p1 == NULL || p2 == NULL )
+ eq = 0;
+ else
+ eq = 1;
+ }
+ if ( !eq )
printconfigline (fp, cp); /* print it out */
}
@@ -713,66 +867,86 @@ int printconfigdiff (const char *fname, const zconf_t *ref, const zconf_t *z)
return 1;
}
-#endif
/*****************************************************************
** checkconfig (config)
*****************************************************************/
int checkconfig (const zconf_t *z)
{
+ int ret;
+ long max_ttl;
+
if ( z == NULL )
return 1;
+ max_ttl = z->max_ttl;
+ if ( max_ttl <= 0 )
+ max_ttl = z->sigvalidity;
+
+ ret = 0;
+ if ( strcmp (z->k_random, "/dev/urandom") == 0 )
+ ret = fprintf (stderr, "random device without enough entropie used for KSK generation \n");
+ if ( strcmp (z->z_random, "/dev/urandom") == 0 )
+ ret = fprintf (stderr, "random device without enough entropie used for ZSK generation\n");
+
if ( z->saltbits < 4 )
- fprintf (stderr, "Saltlength must be at least 4 bits\n");
+ ret = fprintf (stderr, "Saltlength must be at least 4 bits\n");
if ( z->saltbits > 128 )
{
fprintf (stderr, "While the maximum is 520 bits of salt, it's not recommended to use more than 128 bits.\n");
- fprintf (stderr, "The current value is %d bits\n", z->saltbits);
+ ret = fprintf (stderr, "The current value is %d bits\n", z->saltbits);
}
if ( z->sigvalidity < (1 * DAYSEC) || z->sigvalidity > (12 * WEEKSEC) )
{
fprintf (stderr, "Signature should be valid for at least 1 day and no longer than 3 month (12 weeks)\n");
- fprintf (stderr, "The current value is %s\n", timeint2str (z->sigvalidity));
+ ret = fprintf (stderr, "The current value is %s\n", timeint2str (z->sigvalidity));
}
- if ( z->resign > (z->sigvalidity*5/6) - (z->max_ttl + z->proptime) )
+ if ( z->max_ttl <= 0 )
+ {
+ 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");
+ }
+ else
+ if ( max_ttl > z->sigvalidity/2 )
+ ret = fprintf (stderr, "Max TTL (%ld) should be less or equal signature validity (%ld)\n",
+ max_ttl, z->sigvalidity);
+
+ // if ( z->resign > (z->sigvalidity*5/6) - (max_ttl + z->proptime) )
+ if ( z->resign > (z->sigvalidity*5/6) )
{
fprintf (stderr, "Re-signing interval (%s) should be less than ", timeint2str (z->resign));
- fprintf (stderr, "5/6 of sigvalidity\n");
- }
- if ( z->resign < (z->max_ttl + z->proptime) )
- {
- fprintf (stderr, "Re-signing interval (%s) should be ", timeint2str (z->resign));
- fprintf (stderr, "greater than max_ttl (%ld) plus ", z->max_ttl);
- fprintf (stderr, "propagation time (%ld)\n", z->proptime);
+ ret = fprintf (stderr, "5/6 of sigvalidity (%s)\n", timeint2str (z->sigvalidity));
}
- if ( z->max_ttl >= z->sigvalidity )
- fprintf (stderr, "Max TTL (%ld) should be less than signature validity (%ld)\n",
- z->max_ttl, z->sigvalidity);
+ if ( z->max_ttl > 0 && z->resign > (z->sigvalidity - max_ttl) )
+ {
+ fprintf (stderr, "Re-signing interval (%s) should be ", timeint2str (z->resign));
+ fprintf (stderr, "end at least one max_ttl (%ld) before the end of ", max_ttl);
+ ret = fprintf (stderr, "signature lifetime (%ld) (%s)\n", z->sigvalidity, timeint2str(z->sigvalidity - max_ttl));
+ }
if ( z->z_life > (12 * WEEKSEC) * (z->z_bits / 512.) )
{
fprintf (stderr, "Lifetime of zone signing key (%s) ", timeint2str (z->z_life));
fprintf (stderr, "seems a little bit high ");
- fprintf (stderr, "(In respect of key size (%d))\n", z->z_bits);
+ ret = fprintf (stderr, "(In respect of key size (%d))\n", z->z_bits);
}
if ( z->k_life > 0 && z->k_life <= z->z_life )
{
fprintf (stderr, "Lifetime of key signing key (%s) ", timeint2str (z->k_life));
- fprintf (stderr, "should be greater than lifetime of zsk\n");
+ ret = fprintf (stderr, "should be greater than lifetime of zsk\n");
}
if ( z->k_life > 0 && z->k_life > (26 * WEEKSEC) * (z->k_bits / 512.) )
{
fprintf (stderr, "Lifetime of key signing key (%s) ", timeint2str (z->k_life));
fprintf (stderr, "seems a little bit high ");
- fprintf (stderr, "(In respect of key size (%d))\n", z->k_bits);
+ ret = fprintf (stderr, "(In respect of key size (%d))\n", z->k_bits);
}
- return 1;
+ return !ret;
}
#ifdef CONF_TEST
diff --git a/contrib/zkt/zconf.h b/contrib/zkt/zconf.h
index a0c919e33e..f35d8f7543 100644
--- a/contrib/zkt/zconf.h
+++ b/contrib/zkt/zconf.h
@@ -79,6 +79,7 @@
/* # define ZSK_ALGO (DK_ALGO_RSASHA1) ZSK_ALGO has to be the same as KSK, so this is no longer used (v0.99) */
# define ZSK_BITS (512)
# define ZSK_RANDOM "/dev/urandom"
+# define NSEC3 0 /* by default nsec3 is off */
# define SALTLEN 24 /* salt length in bits (resolution is 4 bits)*/
# define ZONEDIR "."
@@ -86,9 +87,11 @@
# define PRINTTIME 1
# define PRINTAGE 0
# define LJUST 0
+# define LSCOLORTERM NULL /* or "" */
# define KEYSETDIR NULL /* keysets */
# define LOGFILE ""
# define LOGLEVEL "error"
+# define LOGDOMAINDIR ""
# define SYSLOGFACILITY "none"
# define SYSLOGLEVEL "notice"
# define VERBOSELOG 0
@@ -98,6 +101,7 @@
# define SIG_RANDOM NULL /* "/dev/urandom" */
# define SIG_PSEUDO 0
# define SIG_GENDS 1
+# define SIG_DNSKEY_KSK 0 /* Sign DNSKEY RR with KSK only */
# define SIG_PARAM ""
# define DIST_CMD NULL /* default is to run "rndc reload" */
# define NAMED_CHROOT NULL /* default is none */
@@ -121,6 +125,12 @@ typedef enum {
Incremental
} serial_form_t;
+typedef enum {
+ NSEC3_OFF = 0,
+ NSEC3_ON,
+ NSEC3_OPTOUT
+} nsec3_t;
+
typedef enum {
none = 0,
user,
@@ -133,6 +143,7 @@ typedef struct zconf {
int printtime;
int printage;
int ljust;
+ char *colorterm;
long sigvalidity; /* should be less than expire time */
long max_ttl; /* should be set to the maximum used ttl in the zone */
long key_ttl;
@@ -152,6 +163,7 @@ typedef struct zconf {
/* int z_algo; no longer used; renamed to k2_algo (v0.99) */
int z_bits;
char *z_random;
+ nsec3_t nsec3; /* 0 == off; 1 == on; 2 == on with optout */
int saltbits;
char *view;
@@ -159,6 +171,7 @@ typedef struct zconf {
// char *errlog;
char *logfile;
char *loglevel;
+ char *logdomaindir;
char *syslogfacility;
char *sysloglevel;
int verboselog;
@@ -170,16 +183,21 @@ typedef struct zconf {
char *sig_random;
int sig_pseudo;
int sig_gends;
+ int sig_dnskeyksk;
char *sig_param;
char *dist_cmd; /* cmd to run instead of "rndc reload" */
char *chroot_dir; /* chroot directory of named */
} zconf_t;
+extern const char *timeint2str (unsigned long val);
extern zconf_t *loadconfig (const char *filename, zconf_t *z);
extern zconf_t *loadconfig_fromstr (const char *str, zconf_t *z);
extern zconf_t *dupconfig (const zconf_t *conf);
+extern zconf_t *freeconfig (zconf_t *conf);
extern int setconfigpar (zconf_t *conf, char *entry, const void *pval);
extern int printconfig (const char *fname, const zconf_t *cp);
+extern int printconfigdiff (const char *fname, const zconf_t *ref, const zconf_t *z);
extern int checkconfig (const zconf_t *z);
+extern void setconfigversion (int version);
#endif
diff --git a/contrib/zkt/zfparse.c b/contrib/zkt/zfparse.c
new file mode 100644
index 0000000000..07d966ff80
--- /dev/null
+++ b/contrib/zkt/zfparse.c
@@ -0,0 +1,289 @@
+/*****************************************************************
+**
+** @(#) zfparse.c -- A zone file parser
+**
+** Copyright (c) Jan 2010 - Jan 2010, Holger Zuleger HZnet. All rights reserved.
+**
+** This software is open source.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+**
+** Neither the name of Holger Zuleger HZnet nor the names of its contributors may
+** be used to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+** POSSIBILITY OF SUCH DAMAGE.
+**
+*****************************************************************/
+# include
+# include
+# include
+# include /* for link(), unlink() */
+# include
+# include
+#if 0
+# include
+# include
+# include
+# include
+# include
+# include
+#endif
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+# include "config_zkt.h"
+# include "zconf.h"
+# include "log.h"
+# include "debug.h"
+#define extern
+# include "zfparse.h"
+#undef extern
+
+
+extern const char *progname;
+
+/*****************************************************************
+** is_multiline_rr (const char *s)
+*****************************************************************/
+static const char *is_multiline_rr (int *multi_line_rr, const char *p)
+{
+ while ( *p && *p != ';' )
+ {
+ if ( *p == '\"' )
+ do
+ p++;
+ while ( *p && *p != '\"' );
+
+ if ( *p == '(' )
+ *multi_line_rr = 1;
+ if ( *p == ')' )
+ *multi_line_rr = 0;
+ p++;
+ }
+ return p;
+}
+
+/*****************************************************************
+** skipws (const char *s)
+*****************************************************************/
+static const char *skipws (const char *s)
+{
+ while ( *s && (*s == ' ' || *s == '\t' || *s == '\n') )
+ s++;
+ return s;
+}
+
+/*****************************************************************
+** skiplabel (const char *s)
+*****************************************************************/
+static const char *skiplabel (const char *s)
+{
+ while ( *s && *s != ';' && *s != ' ' && *s != '\t' && *s != '\n' )
+ s++;
+ return s;
+}
+
+/*****************************************************************
+** setminmax ()
+*****************************************************************/
+static void setminmax (long *pmin, long val, long *pmax)
+{
+ if ( val < *pmin )
+ *pmin = val;
+ if ( val > *pmax )
+ *pmax = val;
+}
+
+/*****************************************************************
+** get_ttl ()
+*****************************************************************/
+static long get_ttl (const char *s)
+{
+ char quantity;
+ long lval;
+
+ quantity = 'd';
+ sscanf (s, "%ld%c", &lval, &quantity);
+ quantity = tolower (quantity);
+ if ( quantity == 'm' )
+ lval *= MINSEC;
+ else if ( quantity == 'h' )
+ lval *= HOURSEC;
+ else if ( quantity == 'd' )
+ lval *= DAYSEC;
+ else if ( quantity == 'w' )
+ lval *= WEEKSEC;
+ else if ( quantity == 'y' )
+ lval *= YEARSEC;
+
+ return lval;
+}
+
+/*****************************************************************
+** addkeydb ()
+*****************************************************************/
+int addkeydb (const char *file, const char *keydbfile)
+{
+ FILE *fp;
+
+ if ( (fp = fopen (file, "a")) == NULL )
+ return -1;
+
+ fprintf (fp, "\n");
+ fprintf (fp, "$INCLUDE %s\t; this is the database of public DNSKEY RR\n", keydbfile);
+
+ fclose (fp);
+
+ return 0;
+}
+
+/*****************************************************************
+** parsezonefile ()
+** parse the BIND zone file 'file' and store the minimum and
+** maximum ttl value in the corresponding parameter.
+** if keydbfile is set, check if this file is already include.
+** return 0 if keydbfile is not included
+** return 1 if keydbfile is included
+** return -1 on error
+*****************************************************************/
+int parsezonefile (const char *file, long *pminttl, long *pmaxttl, const char *keydbfile)
+{
+ FILE *infp;
+ int len;
+ int lnr;
+ long ttl;
+ int multi_line_rr;
+ int keydbfilefound;
+ char buf[1024];
+ const char *p;
+
+ assert (file != NULL);
+ assert (pminttl != NULL);
+ assert (pmaxttl != NULL);
+
+ dbg_val4 ("parsezonefile (\"%s\", %ld, %ld, \"%s\")\n", file, *pminttl, *pmaxttl, keydbfile);
+
+ if ( (infp = fopen (file, "r")) == NULL )
+ return -1;
+
+ lnr = 0;
+ keydbfilefound = 0;
+ multi_line_rr = 0;
+ while ( fgets (buf, sizeof buf, infp) != NULL )
+ {
+ len = strlen (buf);
+ if ( buf[len-1] != '\n' ) /* line too long ? */
+ fprintf (stderr, "line too long\n");
+ lnr++;
+
+ p = buf;
+ if ( multi_line_rr ) /* skip line if it's part of a multiline rr */
+ {
+ is_multiline_rr (&multi_line_rr, p);
+ continue;
+ }
+
+ if ( *p == '$' ) /* special directive ? */
+ {
+ if ( strncmp (p+1, "TTL", 3) == 0 ) /* $TTL ? */
+ {
+ ttl = get_ttl (p+4);
+ dbg_val3 ("%s:%d:ttl %ld\n", file, lnr, ttl);
+ setminmax (pminttl, ttl, pmaxttl);
+ }
+ else if ( strncmp (p+1, "INCLUDE", 7) == 0 ) /* $INCLUDE ? */
+ {
+ char fname[30+1];
+
+ sscanf (p+9, "%30s", fname);
+ dbg_val ("$INCLUDE directive for file \"%s\" found\n", fname);
+ if ( keydbfile && strcmp (fname, keydbfile) == 0 )
+ keydbfilefound = 1;
+ else
+ keydbfilefound = parsezonefile (fname, pminttl, pmaxttl, keydbfile);
+ }
+ }
+ else if ( !isspace (*p) ) /* label ? */
+ p = skiplabel (p);
+
+ p = skipws (p);
+ if ( *p == ';' ) /* skip line if it's a comment line */
+ continue;
+
+ /* skip class (hesiod is not supported now) */
+ if ( (toupper (*p) == 'I' && toupper (p[1]) == 'N') ||
+ (toupper (*p) == 'C' && toupper (p[1]) == 'H') )
+ p += 2;
+ p = skipws (p);
+
+ if ( isdigit (*p) ) /* ttl ? */
+ {
+ ttl = get_ttl (p);
+ dbg_val3 ("%s:%d:ttl %ld\n", file, lnr, ttl);
+ setminmax (pminttl, ttl, pmaxttl);
+ }
+
+ /* check the rest of the line if it's the beginning of a multi_line_rr */
+ is_multiline_rr (&multi_line_rr, p);
+ }
+
+ if ( file )
+ fclose (infp);
+
+ dbg_val5 ("parsezonefile (\"%s\", %ld, %ld, \"%s\") ==> %d\n",
+ file, *pminttl, *pmaxttl, keydbfile, keydbfilefound);
+ return keydbfilefound;
+}
+
+
+#ifdef TEST
+const char *progname;
+int main (int argc, char *argv[])
+{
+ long minttl;
+ long maxttl;
+ int keydbfound;
+ char *dnskeydb;
+
+ progname = *argv;
+ dnskeydb = NULL;
+ dnskeydb = "dnskey.db";
+
+ minttl = 0x7FFFFFFF;
+ maxttl = 0;
+ keydbfound = parsezonefile (argv[1], &minttl, &maxttl, dnskeydb);
+ if ( keydbfound < 0 )
+ error ("can't parse zone file %s\n", argv[1]);
+
+ if ( dnskeydb && !keydbfound )
+ {
+ printf ("$INCLUDE %s directive added \n", dnskeydb);
+ addkeydb (argv[1], dnskeydb);
+ }
+
+ printf ("minttl = %ld\n", minttl);
+ printf ("maxttl = %ld\n", maxttl);
+
+ return 0;
+}
+#endif
diff --git a/contrib/zkt/zfparse.h b/contrib/zkt/zfparse.h
new file mode 100644
index 0000000000..90967c4ba3
--- /dev/null
+++ b/contrib/zkt/zfparse.h
@@ -0,0 +1,42 @@
+/*****************************************************************
+**
+** @(#) zfparse.h -- headerfile for a zone file parser
+**
+** Copyright (c) Jan 2010 - Feb 2010, Holger Zuleger HZnet. All rights reserved.
+**
+** This software is open source.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+**
+** Neither the name of Holger Zuleger HZnet nor the names of its contributors may
+** be used to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+** POSSIBILITY OF SUCH DAMAGE.
+**
+*****************************************************************/
+
+#ifndef ZFPARSE_H
+# define ZFPARSE_H
+extern int parsezonefile (const char *file, long *pminttl, long *pmaxttl, const char *keydbfile);
+extern int addkeydb (const char *file, const char *keydbfile);
+#endif
diff --git a/contrib/zkt/zkt-conf.c b/contrib/zkt/zkt-conf.c
new file mode 100644
index 0000000000..82a1c33e25
--- /dev/null
+++ b/contrib/zkt/zkt-conf.c
@@ -0,0 +1,340 @@
+/*****************************************************************
+**
+** @(#) zkt-conf.c (c) Jan 2005 / Jan 2010 Holger Zuleger hznet.de
+**
+** A config file utility for the DNSSEC Zone Key Tool
+**
+** Copyright (c) 2005 - 2008, Holger Zuleger HZnet. All rights reserved.
+**
+** This software is open source.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+**
+** Neither the name of Holger Zuleger HZnet nor the names of its contributors may
+** be used to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+** POSSIBILITY OF SUCH DAMAGE.
+**
+*****************************************************************/
+
+# include
+# include /* abort(), exit(), ... */
+# include
+# include
+# include
+# include
+# include
+# include
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+# include "config_zkt.h"
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+# include
+#endif
+
+# include "debug.h"
+# include "misc.h"
+# include "zfparse.h"
+# include "zconf.h"
+
+extern int optopt;
+extern int opterr;
+extern int optind;
+extern char *optarg;
+const char *progname;
+
+static const char *view = "";
+static int writeflag = 0;
+static int allflag = 0;
+static int testflag = 0;
+
+# define short_options ":aC:c:O:dlstvwV:rh"
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+static struct option long_options[] = {
+ {"compability", required_argument, NULL, 'C'},
+ {"config", required_argument, NULL, 'c'},
+ {"option", required_argument, NULL, 'O'},
+ {"config-option", required_argument, NULL, 'O'},
+ {"default", no_argument, NULL, 'd'},
+ {"sidecfg", no_argument, NULL, 's'},
+ {"localcfg", no_argument, NULL, 'l'},
+ {"all-values", no_argument, NULL, 'a'},
+ {"test", no_argument, NULL, 't'},
+ {"overwrite", no_argument, NULL, 'w'},
+ {"version", no_argument, NULL, 'v' },
+ {"write", no_argument, NULL, 'w'},
+ {"view", required_argument, NULL, 'V' },
+ {"help", no_argument, NULL, 'h'},
+ {0, 0, 0, 0}
+};
+#endif
+
+static void usage (char *mesg);
+
+
+int main (int argc, char *argv[])
+{
+ int c;
+ int opt_index;
+ int action;
+ int major;
+ int minor;
+ const char *file;
+ const char *defconfname = NULL;
+ const char *confname = NULL;
+ char *p;
+ char str[254+1];
+ zconf_t *refconfig = NULL;
+ zconf_t *config;
+
+ progname = *argv;
+ if ( (p = strrchr (progname, '/')) )
+ progname = ++p;
+ view = getnameappendix (progname, "zkt-conf");
+
+ defconfname = getdefconfname (view);
+ dbg_val0 ("Load built in config \"%s\"\n");
+ config = loadconfig ("", (zconf_t *)NULL); /* load built in config */
+
+ if ( fileexist (defconfname) ) /* load default config file */
+ {
+ dbg_val ("Load site wide config file \"%s\"\n", defconfname);
+ config = loadconfig (defconfname, config);
+ }
+ if ( config == NULL )
+ fatal ("Out of memory\n");
+ confname = defconfname;
+
+ opterr = 0;
+ opt_index = 0;
+ action = 0;
+ setconfigversion (100);
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+ while ( (c = getopt_long (argc, argv, short_options, long_options, &opt_index)) != -1 )
+#else
+ while ( (c = getopt (argc, argv, short_options)) != -1 )
+#endif
+ {
+ switch ( c )
+ {
+ case 'V': /* view name */
+ view = optarg;
+ defconfname = getdefconfname (view);
+ if ( fileexist (defconfname) ) /* load default config file */
+ config = loadconfig (defconfname, config);
+ if ( config == NULL )
+ fatal ("Out of memory\n");
+ confname = defconfname;
+ break;
+ case 'O': /* read option from commandline */
+ config = loadconfig_fromstr (optarg, config);
+ break;
+ case 'C':
+ switch ( sscanf (optarg, "%d.%d", &major, &minor) )
+ {
+ case 2: major = major * 100 + minor;
+ case 1: break;
+ default:
+ usage ("illegal release number");
+ }
+ setconfigversion (major);
+ break;
+ case 'c':
+ if ( *optarg == '\0' )
+ usage ("empty config file name");
+ config = loadconfig (optarg, config);
+ if ( *optarg == '-' || strcmp (optarg, "stdin") == 0 )
+ confname = "stdout";
+ else
+ confname = optarg;
+ break;
+ case 'd': /* built-in default config */
+ config = loadconfig ("", config); /* load built-in config */
+ confname = defconfname;
+ break;
+ case 's': /* side wide config */
+ /* this is the default **/
+ break;
+ case 'a': /* set all flag */
+ allflag = 1;
+ break;
+ case 'l': /* local config file */
+ refconfig = dupconfig (config); /* duplicate current config */
+ confname = LOCALCONF_FILE;
+ if ( fileexist (LOCALCONF_FILE) ) /* try to load local config file */
+ {
+ dbg_val ("Load local config file \"%s\"\n", LOCALCONF_FILE);
+ config = loadconfig (LOCALCONF_FILE, config);
+ }
+ else if ( !writeflag )
+ usage ("error: no local config file found");
+ break;
+ case 't': /* test config */
+ testflag = 1;
+ break;
+ case 'v': /* version */
+ fprintf (stderr, "%s version %s compiled for BIND version %d\n",
+ progname, ZKT_VERSION, BIND_VERSION);
+ fprintf (stderr, "ZKT %s\n", ZKT_COPYRIGHT);
+ return 0;
+ break;
+ case 'w': /* write back conf file */
+ writeflag = 1;
+ break;
+ case 'h': /* print help */
+ usage ("");
+ break;
+ case ':':
+ snprintf (str, sizeof(str), "option \"-%c\" requires an argument.",
+ optopt);
+ usage (str);
+ break;
+ case '?':
+ if ( isprint (optopt) )
+ snprintf (str, sizeof(str), "Unknown option \"-%c\".",
+ optopt);
+ else
+ snprintf (str, sizeof (str), "Unknown option char \\x%x.",
+ optopt);
+ usage (str);
+ break;
+ default:
+ abort();
+ }
+ }
+
+ c = optind;
+ if ( c >= argc ) /* no arguments given on commandline */
+ {
+ if ( testflag )
+ {
+ if ( checkconfig (config) )
+ fprintf (stderr, "All config file parameter seems to be ok\n");
+ }
+ else
+ {
+ if ( !writeflag ) /* print to stdout */
+ confname = "stdout";
+
+ if ( refconfig ) /* have we seen a local config file ? */
+ if ( allflag )
+ printconfig (confname, config);
+ else
+ printconfigdiff (confname, refconfig, config);
+ else
+ printconfig (confname, config);
+ }
+ }
+ else /* command line argument found: use it as name of zone file */
+ {
+ long minttl;
+ long maxttl;
+ int keydbfound;
+ char *dnskeydb;
+
+ file = argv[c++];
+
+ dnskeydb = config->keyfile;
+
+ minttl = 0x7FFFFFFF;
+ maxttl = 0;
+ keydbfound = parsezonefile (file, &minttl, &maxttl, dnskeydb);
+ if ( keydbfound < 0 )
+ error ("can't parse zone file %s\n", file);
+
+ if ( dnskeydb && !keydbfound )
+ {
+ if ( writeflag )
+ {
+ addkeydb (file, dnskeydb);
+ printf ("\"$INCLUDE %s\" directive added to \"%s\"\n", dnskeydb, file);
+ }
+ else
+ printf ("\"$INCLUDE %s\" should be added to \"%s\" (run with option -w)\n",
+ dnskeydb, file);
+ }
+
+ if ( minttl < (10 * MINSEC) )
+ fprintf (stderr, "Min_TTL of %s (%ld seconds) is too low to use it in a signed zone (see RFC4641)\n",
+ timeint2str (minttl), minttl);
+ else
+ fprintf (stderr, "Min_TTL:\t%s\t# (%ld seconds)\n", timeint2str (minttl), minttl);
+ fprintf (stdout, "Max_TTL:\t%s\t# (%ld seconds)\n", timeint2str (maxttl), maxttl);
+
+ if ( writeflag )
+ {
+ refconfig = dupconfig (config); /* duplicate current config */
+ confname = LOCALCONF_FILE;
+ if ( fileexist (LOCALCONF_FILE) ) /* try to load local config file */
+ {
+ dbg_val ("Load local config file \"%s\"\n", LOCALCONF_FILE);
+ config = loadconfig (LOCALCONF_FILE, config);
+ }
+ setconfigpar (config, "Max_TTL", &maxttl);
+ printconfigdiff (confname, refconfig, config);
+ }
+ }
+
+
+ return 0;
+}
+
+# define sopt_usage(mesg, value) fprintf (stderr, mesg, value)
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+# define lopt_usage(mesg, value) fprintf (stderr, mesg, value)
+# define loptstr(lstr, sstr) lstr
+#else
+# define lopt_usage(mesg, value)
+# define loptstr(lstr, sstr) sstr
+#endif
+static void usage (char *mesg)
+{
+ fprintf (stderr, "%s version %s\n", progname, ZKT_VERSION);
+ if ( mesg && *mesg )
+ fprintf (stderr, "%s\n", mesg);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "usage: %s -h\n", progname);
+ fprintf (stderr, "usage: %s [-V view] [-w|-t] -d [-O ]\n", progname);
+ fprintf (stderr, "usage: %s [-V view] [-w|-t] [-s] [-c config] [-O ]\n", progname);
+ fprintf (stderr, "usage: %s [-V view] [-w|-t] [-a] -l [-c config] [-O ]\n", progname);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "usage: %s [-c config] [-w] \n", progname);
+ fprintf (stderr, "\n");
+ fprintf (stderr, " -V name%s", loptstr (", --view=name\n", ""));
+ fprintf (stderr, "\t\t specify the view name \n");
+ fprintf (stderr, " -d%s\tprint built-in default config parameter\n", loptstr (", --default", ""));
+ fprintf (stderr, " -s%s\tprint site wide config file parameter (this is the default)\n", loptstr (", --sitecfg", ""));
+ fprintf (stderr, " -l%s\tprint local config file parameter\n", loptstr (", --localcfg", ""));
+ fprintf (stderr, " -a%s\tprint all parameter not only the different one\n", loptstr (", --all", ""));
+ fprintf (stderr, " -c file%s", loptstr (", --config=file\n", ""));
+ fprintf (stderr, " \t\tread config from instead of %s\n", CONFIG_FILE);
+ fprintf (stderr, " -O optstr%s", loptstr (", --config-option=\"optstr\"\n", ""));
+ fprintf (stderr, " \t\tread config options from commandline\n");
+ fprintf (stderr, " -t%s\ttest the config parameter if they are useful \n", loptstr (", --test", "\t"));
+ fprintf (stderr, " -w%s\twrite or rewrite config file \n", loptstr (", --write", "\t"));
+ fprintf (stderr, " -h%s\tprint this help \n", loptstr (", --help", "\t"));
+ exit (1);
+}
+
diff --git a/contrib/zkt/zkt-keyman.c b/contrib/zkt/zkt-keyman.c
new file mode 100644
index 0000000000..e7f96ec764
--- /dev/null
+++ b/contrib/zkt/zkt-keyman.c
@@ -0,0 +1,722 @@
+/*****************************************************************
+**
+** @(#) zkt-keyman.c (c) Jan 2005 - Apr 2010 Holger Zuleger hznet.de
+**
+** ZKT key managing tool (formely knon as dnsses-zkt)
+** A wrapper command around the BIND dnssec-keygen utility
+**
+** Copyright (c) 2005 - 2010, Holger Zuleger HZnet. All rights reserved.
+**
+** This software is open source.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+**
+** Neither the name of Holger Zuleger HZnet nor the names of its contributors may
+** be used to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+** POSSIBILITY OF SUCH DAMAGE.
+**
+*****************************************************************/
+
+# include
+# include /* abort(), exit(), ... */
+# include
+# include
+# include
+# include
+# include
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+# include "config_zkt.h"
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+# include
+#endif
+
+# include "debug.h"
+# include "misc.h"
+# include "strlist.h"
+# include "zconf.h"
+# include "dki.h"
+# include "zkt.h"
+
+extern int optopt;
+extern int opterr;
+extern int optind;
+extern char *optarg;
+const char *progname;
+
+char *labellist = NULL;
+
+int headerflag = 1;
+int ageflag = 0;
+int lifetime = 0;
+int lifetimeflag = 0;
+int timeflag = 1;
+int exptimeflag = 0;
+int pathflag = 0;
+int kskflag = 1;
+int zskflag = 1;
+int ljustflag = 0;
+
+static int dirflag = 0;
+static int recflag = RECURSIVE;
+static char *kskdomain = "";
+static const char *view = "";
+
+# define short_options ":0:1:2:3:9A:C:D:P:S:R:h:ZV:F:c:O:krz"
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+static struct option long_options[] = {
+ {"ksk-rollover", no_argument, NULL, '9'},
+ {"ksk-status", required_argument, NULL, '0'},
+ {"ksk-roll-status", required_argument, NULL, '0'},
+ {"ksk-newkey", required_argument, NULL, '1'},
+ {"ksk-publish", required_argument, NULL, '2'},
+ {"ksk-delkey", required_argument, NULL, '3'},
+ {"ksk-roll-phase1", required_argument, NULL, '1'},
+ {"ksk-roll-phase2", required_argument, NULL, '2'},
+ {"ksk-roll-phase3", required_argument, NULL, '3'},
+ {"ksk", no_argument, NULL, 'k'},
+ {"zsk", no_argument, NULL, 'z'},
+ {"recursive", no_argument, NULL, 'r'},
+ {"config", required_argument, NULL, 'c'},
+ {"option", required_argument, NULL, 'O'},
+ {"config-option", required_argument, NULL, 'O'},
+ {"published", required_argument, NULL, 'P'},
+ {"standby", required_argument, NULL, 'S'},
+ {"active", required_argument, NULL, 'A'},
+ {"depreciated", required_argument, NULL, 'D'},
+ {"create", required_argument, NULL, 'C'},
+ {"revoke", required_argument, NULL, 'R'},
+ {"remove", required_argument, NULL, 19 },
+ {"destroy", required_argument, NULL, 20 },
+ {"setlifetime", required_argument, NULL, 'F' },
+ {"view", required_argument, NULL, 'V' },
+ {"help", no_argument, NULL, 'h'},
+ {0, 0, 0, 0}
+};
+#endif
+
+static int parsedirectory (const char *dir, dki_t **listp);
+static void parsefile (const char *file, dki_t **listp);
+static void createkey (const char *keyname, const dki_t *list, const zconf_t *conf);
+static void ksk_roll (const char *keyname, int phase, const dki_t *list, const zconf_t *conf);
+static int create_parent_file (const char *fname, int phase, int ttl, const dki_t *dkp);
+static void usage (char *mesg, zconf_t *cp);
+static const char *parsetag (const char *str, int *tagp);
+
+static void setglobalflags (zconf_t *config)
+{
+ recflag = config->recursive;
+}
+
+int main (int argc, char *argv[])
+{
+ dki_t *data = NULL;
+ dki_t *dkp;
+ int c;
+ int opt_index;
+ int action;
+ const char *file;
+ const char *defconfname = NULL;
+ char *p;
+ char str[254+1];
+ const char *keyname = NULL;
+ int searchtag;
+ zconf_t *config;
+
+ progname = *argv;
+ if ( (p = strrchr (progname, '/')) )
+ progname = ++p;
+ view = getnameappendix (progname, "dnssec-zkt");
+
+ defconfname = getdefconfname (view);
+ config = loadconfig ("", (zconf_t *)NULL); /* load built in config */
+ if ( fileexist (defconfname) ) /* load default config file */
+ config = loadconfig (defconfname, config);
+ if ( config == NULL )
+ fatal ("Out of memory\n");
+ setglobalflags (config);
+
+ opterr = 0;
+ opt_index = 0;
+ action = 0;
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+ while ( (c = getopt_long (argc, argv, short_options, long_options, &opt_index)) != -1 )
+#else
+ while ( (c = getopt (argc, argv, short_options)) != -1 )
+#endif
+ {
+ switch ( c )
+ {
+ case '9': /* ksk rollover help */
+ ksk_roll ("help", c - '0', NULL, NULL);
+ exit (1);
+ case '1': /* ksk rollover: create new key */
+ case '2': /* ksk rollover: publish DS */
+ case '3': /* ksk rollover: delete old key */
+ case '0': /* ksk rollover: show current status */
+ action = c;
+ if ( !optarg )
+ usage ("ksk rollover requires an domain argument", config);
+ kskdomain = domain_canonicdup (optarg);
+ break;
+ case 'h':
+ case 'K':
+ case 'Z':
+ action = c;
+ break;
+ case 'C':
+ pathflag = !pathflag;
+ /* fall through */
+ case 'P':
+ case 'S':
+ case 'A':
+ case 'D':
+ case 'R':
+ case 's':
+ case 19:
+ case 20:
+ if ( (keyname = parsetag (optarg, &searchtag)) != NULL )
+ keyname = domain_canonicdup (keyname);
+ action = c;
+ break;
+ case 'F': /* set key lifetime */
+ lifetime = atoi (optarg);
+ action = c;
+ break;
+ case 'V': /* view name */
+ view = optarg;
+ defconfname = getdefconfname (view);
+ if ( fileexist (defconfname) ) /* load default config file */
+ config = loadconfig (defconfname, config);
+ if ( config == NULL )
+ fatal ("Out of memory\n");
+ setglobalflags (config);
+ break;
+ case 'c':
+ config = loadconfig (optarg, config);
+ setglobalflags (config);
+ checkconfig (config);
+ break;
+ case 'O': /* read option from commandline */
+ config = loadconfig_fromstr (optarg, config);
+ setglobalflags (config);
+ checkconfig (config);
+ break;
+ case 'd': /* ignore directory arg */
+ dirflag = 1;
+ break;
+ case 'k': /* ksk only */
+ zskflag = 0;
+ break;
+ case 'r': /* switch recursive flag */
+ recflag = !recflag;
+ break;
+ case 'z': /* zsk only */
+ kskflag = 0;
+ break;
+ case ':':
+ snprintf (str, sizeof(str), "option \"-%c\" requires an argument.\n",
+ optopt);
+ usage (str, config);
+ break;
+ case '?':
+ if ( isprint (optopt) )
+ snprintf (str, sizeof(str), "Unknown option \"-%c\".\n",
+ optopt);
+ else
+ snprintf (str, sizeof (str), "Unknown option char \\x%x.\n",
+ optopt);
+ usage (str, config);
+ break;
+ default:
+ abort();
+ }
+ }
+
+ if ( kskflag == 0 && zskflag == 0 )
+ kskflag = zskflag = 1;
+
+ c = optind;
+ do {
+ if ( c >= argc ) /* no args left */
+ file = config->zonedir; /* use default directory */
+ else
+ file = argv[c++];
+
+ if ( is_directory (file) )
+ parsedirectory (file, &data);
+ else
+ parsefile (file, &data);
+
+ } while ( c < argc ); /* for all arguments */
+
+ switch ( action )
+ {
+ case 'h':
+ usage ("", config);
+ case 'C':
+ createkey (keyname, data, config);
+ break;
+ case 'P':
+ case 'S':
+ case 'A':
+ case 'D':
+ if ( (dkp = (dki_t*)zkt_search (data, searchtag, keyname)) == NULL )
+ fatal ("Key with tag %u not found\n", searchtag);
+ else if ( dkp == (void *) 01 )
+ fatal ("Key with tag %u found multiple times\n", searchtag);
+ if ( (c = dki_setstatus_preservetime (dkp, action)) != 0 )
+ fatal ("Couldn't change status of key %u: %d\n", searchtag, c);
+ break;
+ case 19: /* remove (rename) key file */
+ if ( (dkp = (dki_t *)zkt_search (data, searchtag, keyname)) == NULL )
+ fatal ("Key with tag %u not found\n", searchtag);
+ else if ( dkp == (void *) 01 )
+ fatal ("Key with tag %u found multiple times\n", searchtag);
+ dki_remove (dkp);
+ break;
+ case 20: /* destroy the key (remove the files!) */
+ if ( (dkp = (dki_t *)zkt_search (data, searchtag, keyname)) == NULL )
+ fatal ("Key with tag %u not found\n", searchtag);
+ else if ( dkp == (void *) 01 )
+ fatal ("Key with tag %u found multiple times\n", searchtag);
+ dki_destroy (dkp);
+ break;
+ case 'R':
+ if ( (dkp = (dki_t *)zkt_search (data, searchtag, keyname)) == NULL )
+ fatal ("Key with tag %u not found\n", searchtag);
+ else if ( dkp == (void *) 01 )
+ fatal ("Key with tag %u found multiple times\n", searchtag);
+ if ( (c = dki_setstatus (dkp, action)) != 0 )
+ fatal ("Couldn't change status of key %u: %d\n", searchtag, c);
+ break;
+ case '1': /* ksk rollover new key */
+ case '2': /* ksk rollover publish DS */
+ case '3': /* ksk rollover delete old key */
+ case '0': /* ksk rollover status */
+ ksk_roll (kskdomain, action - '0', data, config);
+ break;
+ case 'F':
+ zkt_setkeylifetime (data);
+ /* fall through */
+ default:
+ zkt_list_keys (data);
+ }
+
+ return 0;
+}
+
+# define sopt_usage(mesg, value) fprintf (stderr, mesg, value)
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+# define lopt_usage(mesg, value) fprintf (stderr, mesg, value)
+# define loptstr(lstr, sstr) lstr
+#else
+# define lopt_usage(mesg, value)
+# define loptstr(lstr, sstr) sstr
+#endif
+static void usage (char *mesg, zconf_t *cp)
+{
+ fprintf (stderr, "DNS Zone Key Management Tool %s\n", ZKT_VERSION);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Create a new key \n");
+ sopt_usage ("\tusage: %s -C [-k] [-dpr] [-c config] [dir ...]\n", progname);
+ lopt_usage ("\tusage: %s --create= [-k] [-dpr] [-c config] [dir ...]\n", progname);
+ fprintf (stderr, "\t\tKSK (use -k): %s %d bits\n", dki_algo2str (cp->k_algo), cp->k_bits);
+ fprintf (stderr, "\t\tZSK (default): %s %d bits\n", dki_algo2str (cp->k_algo), cp->z_bits);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Change key status of specified key to published, active or depreciated\n");
+ fprintf (stderr, "\t( := tag | tag:name) \n");
+ sopt_usage ("\tusage: %s -P|-A|-D [-dr] [-c config] [dir ...]\n", progname);
+ lopt_usage ("\tusage: %s --published= [-dr] [-c config] [dir ...]\n", progname);
+ lopt_usage ("\tusage: %s --active= [-dr] [-c config] [dir ...]\n", progname);
+ lopt_usage ("\tusage: %s --depreciated= [-dr] [-c config] [dir ...]\n", progname);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Revoke specified key ( := tag | tag:name) \n");
+ sopt_usage ("\tusage: %s -R [-dr] [-c config] [dir ...]\n", progname);
+ lopt_usage ("\tusage: %s --revoke= [-dr] [-c config] [dir ...]\n", progname);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Remove (rename) or destroy (delete) specified key ( := tag | tag:name) \n");
+ lopt_usage ("\tusage: %s --remove= [-dr] [-c config] [dir ...]\n", progname);
+ lopt_usage ("\tusage: %s --destroy= [-dr] [-c config] [dir ...]\n", progname);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "Initiate a semi-automated KSK rollover");
+ fprintf (stderr, "('%s -9%s' prints out a brief description)\n", progname, loptstr ("|--ksk-rollover", ""));
+ sopt_usage ("\tusage: %s {-1} do.ma.in.\n", progname);
+ lopt_usage ("\tusage: %s {--ksk-roll-phase1|--ksk-newkey} do.ma.in.\n", progname);
+ sopt_usage ("\tusage: %s {-2} do.ma.in.\n", progname);
+ lopt_usage ("\tusage: %s {--ksk-roll-phase2|--ksk-publish} do.ma.in.\n", progname);
+ sopt_usage ("\tusage: %s {-3} do.ma.in.\n", progname);
+ lopt_usage ("\tusage: %s {--ksk-roll-phase3|--ksk-delkey} do.ma.in.\n", progname);
+ sopt_usage ("\tusage: %s {-0} do.ma.in.\n", progname);
+ lopt_usage ("\tusage: %s {--ksk-roll-status|--ksk-status} do.ma.in.\n", progname);
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "General options \n");
+ fprintf (stderr, "\t-c file%s", loptstr (", --config=file\n", ""));
+ fprintf (stderr, "\t\t read config from instead of %s\n", CONFIG_FILE);
+ fprintf (stderr, "\t-O optstr%s", loptstr (", --config-option=\"optstr\"\n", ""));
+ fprintf (stderr, "\t\t read config options from commandline\n");
+ fprintf (stderr, "\t-d%s\t skip directory arguments\n", loptstr (", --directory", "\t"));
+ fprintf (stderr, "\t-r%s\t recursive mode on/off (default: %s)\n", loptstr(", --recursive", "\t"), recflag ? "on": "off");
+ fprintf (stderr, "\t-F days%s=days\t set key lifetime\n", loptstr (", --setlifetime", "\t"));
+ fprintf (stderr, "\t-k%s\t key signing keys only\n", loptstr (", --ksk", "\t"));
+ fprintf (stderr, "\t-z%s\t zone signing keys only\n", loptstr (", --zsk", "\t"));
+ if ( mesg && *mesg )
+ fprintf (stderr, "%s\n", mesg);
+ exit (1);
+}
+
+static void createkey (const char *keyname, const dki_t *list, const zconf_t *conf)
+{
+ const char *dir = "";
+ dki_t *dkp;
+
+ if ( keyname == NULL || *keyname == '\0' )
+ fatal ("Create key: no keyname!");
+
+ dbg_val2 ("createkey: keyname %s, pathflag = %d\n", keyname, pathflag);
+ /* search for already existent key to get the directory name */
+ if ( pathflag && (dkp = (dki_t *)zkt_search (list, 0, keyname)) != NULL )
+ {
+ char path[MAX_PATHSIZE+1];
+ zconf_t localconf;
+
+ dir = dkp->dname;
+ pathname (path, sizeof (path), dir, LOCALCONF_FILE, NULL);
+ if ( fileexist (path) ) /* load local config file */
+ {
+ dbg_val ("Load local config file \"%s\"\n", path);
+ memcpy (&localconf, conf, sizeof (zconf_t));
+ conf = loadconfig (path, &localconf);
+ }
+ }
+
+ if ( zskflag )
+ dkp = dki_new (dir, keyname, DKI_ZSK, conf->k_algo, conf->z_bits, conf->z_random, conf->z_life / DAYSEC);
+ else
+ dkp = dki_new (dir, keyname, DKI_KSK, conf->k_algo, conf->k_bits, conf->k_random, conf->k_life / DAYSEC);
+ if ( dkp == NULL )
+ fatal ("Can't create key %s: %s!\n", keyname, dki_geterrstr ());
+
+ /* create a new key always in state published, which means "standby" for ksk */
+ dki_setstatus (dkp, DKI_PUB);
+}
+
+static int get_parent_phase (const char *file)
+{
+ FILE *fp;
+ int phase;
+
+ if ( (fp = fopen (file, "r")) == NULL )
+ return -1;
+
+ phase = 0;
+ if ( fscanf (fp, "; KSK rollover phase%d", &phase) != 1 )
+ phase = 0;
+
+ fclose (fp);
+ return phase;
+}
+
+static void ksk_roll (const char *keyname, int phase, const dki_t *list, const zconf_t *conf)
+{
+ char path[MAX_PATHSIZE+1];
+ zconf_t localconf;
+ const char *dir;
+ dki_t *keylist;
+ dki_t *dkp;
+ dki_t *standby;
+ int parent_exist;
+ int parent_age;
+ int parent_phase;
+ int parent_propagation;
+ int key_ttl;
+ int ksk;
+
+ if ( phase == 9 ) /* usage */
+ {
+ fprintf (stderr, "A KSK rollover requires three consecutive steps:\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "-1%s", loptstr ("|--ksk-roll-phase1 (--ksk-newkey)\n", ""));
+ fprintf (stderr, "\t Create a new KSK.\n");
+ fprintf (stderr, "\t This step also creates a parent- file which contains only\n");
+ fprintf (stderr, "\t the _old_ key. This file will be copied in hierarchical mode\n");
+ fprintf (stderr, "\t by dnssec-signer to the parent directory as keyset- file.\n");
+ fprintf (stderr, "\t Wait until the new keyset is propagated, before going to the next step.\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "-2%s", loptstr ("|--ksk-roll-phase2 (--ksk-publish)\n", ""));
+ fprintf (stderr, "\t This step creates a parent- file with the _new_ key only.\n");
+ fprintf (stderr, "\t Please send this file immediately to the parent (In hierarchical\n");
+ fprintf (stderr, "\t mode this will be done automatically by the dnssec-signer command).\n");
+ fprintf (stderr, "\t Then wait until the new DS is generated by the parent and propagated\n");
+ fprintf (stderr, "\t to all the parent name server, plus the old DS TTL before going to step three.\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "-3%s", loptstr ("|--ksk-roll-phase3 (--ksk-delkey)\n", ""));
+ fprintf (stderr, "\t Remove (rename) the old KSK and the parent- file.\n");
+ fprintf (stderr, "\t You have to manually delete the old KSK (look at file names beginning\n");
+ fprintf (stderr, "\t with an lower 'k').\n");
+ fprintf (stderr, "\n");
+ fprintf (stderr, "-0%s", loptstr ("|--ksk-roll-stat (--ksk-status)\n", ""));
+ fprintf (stderr, "\t Show the current KSK rollover state of a domain.\n");
+
+ fprintf (stderr, "\n");
+
+ return;
+ }
+
+ if ( keyname == NULL || *keyname == '\0' )
+ fatal ("ksk rollover: no domain!");
+
+ dbg_val2 ("ksk_roll: keyname %s, phase = %d\n", keyname, phase);
+
+ /* search for already existent key to get the directory name */
+ if ( (keylist = (dki_t *)zkt_search (list, 0, keyname)) == NULL )
+ fatal ("ksk rollover: domain %s not found!\n", keyname);
+ dkp = keylist;
+
+ /* try to read local config file */
+ dir = dkp->dname;
+ pathname (path, sizeof (path), dir, LOCALCONF_FILE, NULL);
+ if ( fileexist (path) ) /* load local config file */
+ {
+ dbg_val ("Load local config file \"%s\"\n", path);
+ memcpy (&localconf, conf, sizeof (zconf_t));
+ conf = loadconfig (path, &localconf);
+ }
+ key_ttl = conf->key_ttl;
+
+ /* check if parent-file already exist */
+ pathname (path, sizeof (path), dir, "parent-", keyname);
+ parent_phase = parent_age = 0;
+ if ( (parent_exist = fileexist (path)) != 0 )
+ {
+ parent_phase = get_parent_phase (path);
+ parent_age = file_age (path);
+ }
+ // parent_propagation = 2 * DAYSEC;
+ parent_propagation = 5 * MINSEC;
+
+ ksk = 0; /* count active(!) key signing keys */
+ standby = NULL; /* find standby key if available */
+ for ( dkp = keylist; dkp; dkp = dkp->next )
+ if ( dki_isksk (dkp) )
+ {
+ if ( dki_status (dkp) == DKI_ACT )
+ ksk++;
+ else if ( dki_status (dkp) == DKI_PUB )
+ standby = dkp;
+ }
+
+ switch ( phase )
+ {
+ case 0: /* print status (debug) */
+ fprintf (stdout, "ksk_rollover:\n");
+ fprintf (stdout, "\t domain = %s\n", keyname);
+ fprintf (stdout, "\t phase = %d\n", parent_phase);
+ fprintf (stdout, "\t parent_file %s %s\n", path, parent_exist ? "exist": "not exist");
+ if ( parent_exist )
+ fprintf (stdout, "\t age of parent_file %d %s\n", parent_age, str_delspace (age2str (parent_age)));
+ fprintf (stdout, "\t # of active key signing keys %d\n", ksk);
+ fprintf (stdout, "\t parent_propagation %d %s\n", parent_propagation, str_delspace (age2str (parent_propagation)));
+ fprintf (stdout, "\t keys ttl %d %s\n", key_ttl, age2str (key_ttl));
+
+ for ( dkp = keylist; dkp; dkp = dkp->next )
+ {
+ /* TODO: Nur zum testen */
+ dki_prt_dnskey (dkp, stdout);
+ }
+ break;
+ case 1:
+ if ( parent_exist || ksk > 1 )
+ fatal ("Can\'t create new ksk because there is already an ksk rollover in progress\n");
+
+ fprintf (stdout, "create new ksk \n");
+ dkp = dki_new (dir, keyname, DKI_KSK, conf->k_algo, conf->k_bits, conf->k_random, conf->k_life / DAYSEC);
+ if ( dkp == NULL )
+ fatal ("Can't create key %s: %s!\n", keyname, dki_geterrstr ());
+ if ( standby )
+ {
+ dki_setstatus (standby, DKI_ACT); /* activate standby key */
+ dki_setstatus (dkp, DKI_PUB); /* new key will be the new standby */
+ }
+
+ // dkp = keylist; /* use old key to create the parent file */
+ if ( (dkp = (dki_t *)dki_findalgo (keylist, 1, conf->k_algo, 'a', 1)) == NULL ) /* find the oldest active ksk to create the parent file */
+ fatal ("ksk_rollover phase1: Couldn't find the old active key\n");
+ if ( !create_parent_file (path, phase, key_ttl, dkp) )
+ fatal ("Couldn't create parentfile %s\n", path);
+ break;
+
+ case 2:
+ if ( ksk < 2 )
+ fatal ("Can\'t publish new key because no one exist\n");
+ if ( !parent_exist )
+ fatal ("More than one KSK but no parent file found!\n");
+ if ( parent_phase != 1 )
+ fatal ("Parent file exists but is in wrong state (phase = %d)\n", parent_phase);
+ if ( parent_age < conf->proptime + key_ttl )
+ fatal ("ksk_rollover (phase2): you have to wait for the propagation of the new KSK (at least %dsec or %s)\n",
+ conf->proptime + key_ttl - parent_age,
+ str_delspace (age2str (conf->proptime + key_ttl - parent_age)));
+
+ fprintf (stdout, "save new ksk in parent file\n");
+ dkp = keylist->next; /* set dkp to new ksk */
+ if ( !create_parent_file (path, phase, key_ttl, dkp) )
+ fatal ("Couldn't create parentfile %s\n", path);
+ break;
+ case 3:
+ if ( !parent_exist || ksk < 2 )
+ fatal ("ksk-delkey only allowed after ksk-publish\n");
+ if ( parent_phase != 2 )
+ fatal ("Parent file exists but is in wrong state (phase = %d)\n", parent_phase);
+ if ( parent_age < parent_propagation + key_ttl )
+ fatal ("ksk_rollover (phase3): you have to wait for DS propagation (at least %dsec or %s)\n",
+ parent_propagation + key_ttl - parent_age,
+ str_delspace (age2str (parent_propagation + key_ttl - parent_age)));
+ /* remove the parentfile */
+ fprintf (stdout, "remove parentfile \n");
+ unlink (path);
+ /* remove or rename the old key */
+ fprintf (stdout, "old ksk renamed \n");
+ dkp = keylist; /* set dkp to old ksk */
+ dki_remove (dkp);
+ break;
+ default: assert (phase == 1 || phase == 2 || phase == 3);
+ }
+}
+
+/*****************************************************************
+** create_parent_file ()
+*****************************************************************/
+static int create_parent_file (const char *fname, int phase, int ttl, const dki_t *dkp)
+{
+ FILE *fp;
+
+ assert ( fname != NULL );
+
+ if ( dkp == NULL || (phase != 1 && phase != 2) )
+ return 0;
+
+ if ( (fp = fopen (fname, "w")) == NULL )
+ fatal ("can\'t create new parentfile \"%s\"\n", fname);
+
+ if ( phase == 1 )
+ fprintf (fp, "; KSK rollover phase1 (old key)\n");
+ else
+ fprintf (fp, "; KSK rollover phase2 (new key)\n");
+
+ dki_prt_dnskeyttl (dkp, fp, ttl);
+ fclose (fp);
+
+ return phase;
+}
+
+static int parsedirectory (const char *dir, dki_t **listp)
+{
+ dki_t *dkp;
+ DIR *dirp;
+ struct dirent *dentp;
+ char path[MAX_PATHSIZE+1];
+
+ if ( dirflag )
+ return 0;
+
+ dbg_val ("directory: opendir(%s)\n", dir);
+ if ( (dirp = opendir (dir)) == NULL )
+ return 0;
+
+ while ( (dentp = readdir (dirp)) != NULL )
+ {
+ if ( is_dotfilename (dentp->d_name) )
+ continue;
+
+ dbg_val ("directory: check %s\n", dentp->d_name);
+ pathname (path, sizeof (path), dir, dentp->d_name, NULL);
+ if ( is_directory (path) && recflag )
+ {
+ dbg_val ("directory: recursive %s\n", path);
+ parsedirectory (path, listp);
+ }
+ else if ( is_keyfilename (dentp->d_name) )
+ if ( (dkp = dki_read (dir, dentp->d_name)) )
+ {
+ // fprintf (stderr, "parsedir: tssearch (%d %s)\n", dkp, dkp->name);
+#if defined (USE_TREE) && USE_TREE
+ dki_tadd (listp, dkp, 1);
+#else
+ dki_add (listp, dkp);
+#endif
+ }
+ }
+ closedir (dirp);
+ return 1;
+}
+
+static void parsefile (const char *file, dki_t **listp)
+{
+ char path[MAX_PATHSIZE+1];
+ dki_t *dkp;
+
+ /* file arg contains path ? ... */
+ file = splitpath (path, sizeof (path), file); /* ... then split of */
+
+ if ( is_keyfilename (file) ) /* plain file name looks like DNS key file ? */
+ {
+ if ( (dkp = dki_read (path, file)) ) /* read DNS key file ... */
+#if defined (USE_TREE) && USE_TREE
+ dki_tadd (listp, dkp, 1); /* ... and add to tree */
+#else
+ dki_add (listp, dkp); /* ... and add to list */
+#endif
+ else
+ error ("error parsing %s: (%s)\n", file, dki_geterrstr());
+ }
+}
+
+static const char *parsetag (const char *str, int *tagp)
+{
+ const char *p;
+
+ *tagp = 0;
+ while ( isspace (*str) ) /* skip leading ws */
+ str++;
+
+ p = str;
+ if ( isdigit (*p) ) /* keytag starts with digit */
+ {
+ sscanf (p, "%u", tagp); /* read keytag as number */
+ do /* eat up to the end of the number */
+ p++;
+ while ( isdigit (*p) );
+
+ if ( *p == ':' ) /* label follows ? */
+ return p+1; /* return that */
+ if ( *p == '\0' )
+ return NULL; /* no label */
+ }
+ return str; /* return as label string if not a numeric keytag */
+}
diff --git a/contrib/zkt/zkt-ls.c b/contrib/zkt/zkt-ls.c
new file mode 100644
index 0000000000..67e2ce4873
--- /dev/null
+++ b/contrib/zkt/zkt-ls.c
@@ -0,0 +1,424 @@
+/*****************************************************************
+**
+** @(#) zkt-ls.c (c) Jan 2010 Holger Zuleger hznet.de
+**
+** Secure DNS zone key tool
+** A command to list dnssec keys
+**
+** Copyright (c) 2005 - 2010, Holger Zuleger HZnet. All rights reserved.
+**
+** This software is open source.
+**
+** Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions
+** are met:
+**
+** Redistributions of source code must retain the above copyright notice,
+** this list of conditions and the following disclaimer.
+**
+** Redistributions in binary form must reproduce the above copyright notice,
+** this list of conditions and the following disclaimer in the documentation
+** and/or other materials provided with the distribution.
+**
+** Neither the name of Holger Zuleger HZnet nor the names of its contributors may
+** be used to endorse or promote products derived from this software without
+** specific prior written permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+** POSSIBILITY OF SUCH DAMAGE.
+**
+*****************************************************************/
+
+# include
+# include /* abort(), exit(), ... */
+# include
+# include
+# include
+# include
+# include
+
+#ifdef HAVE_CONFIG_H
+# include
+#endif
+# include "config_zkt.h"
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+# include
+#endif
+
+# include "debug.h"
+# include "misc.h"
+# include "strlist.h"
+# include "zconf.h"
+# include "dki.h"
+# include "tcap.h"
+# include "zkt.h"
+
+extern int optopt;
+extern int opterr;
+extern int optind;
+extern char *optarg;
+const char *progname;
+
+char *labellist = NULL;
+
+int headerflag = 1;
+int ageflag = 0;
+int lifetime = 0;
+int lifetimeflag = 0;
+int timeflag = 1;
+int exptimeflag = 0;
+int pathflag = 0;
+int kskflag = 1;
+int zskflag = 1;
+int ljustflag = 0;
+int subdomain_before_parent = 1;
+
+static int dirflag = 0;
+static int recflag = RECURSIVE;
+static int trustedkeyflag = 0;
+static const char *view = "";
+static const char *term = NULL;
+
+#if defined(COLOR_MODE) && COLOR_MODE
+# define short_options ":HKTV:afC::c:O:dhkLl:prstez"
+#else
+# define short_options ":HKTV:af:c:O:dhkLl:prstez"
+#endif
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+static struct option long_options[] = {
+ {"list-dnskeys", no_argument, NULL, 'K'},
+ {"list-trustedkeys", no_argument, NULL, 'T'},
+ {"ksk", no_argument, NULL, 'k'},
+ {"zsk", no_argument, NULL, 'z'},
+ {"age", no_argument, NULL, 'a'},
+ {"lifetime", no_argument, NULL, 'f'},
+ {"time", no_argument, NULL, 't'},
+ {"expire", no_argument, NULL, 'e'},
+ {"recursive", no_argument, NULL, 'r'},
+ {"leftjust", no_argument, NULL, 'L'},
+ {"label-list", no_argument, NULL, 'l'},
+ {"path", no_argument, NULL, 'p'},
+ {"sort", no_argument, NULL, 's'},
+ {"subdomain", no_argument, NULL, 's'},
+ {"nohead", no_argument, NULL, 'h'},
+ {"directory", no_argument, NULL, 'd'},
+#if defined(COLOR_MODE) && COLOR_MODE
+ {"color", optional_argument, NULL, 'C'},
+#endif
+ {"config", required_argument, NULL, 'c'},
+ {"option", required_argument, NULL, 'O'},
+ {"config-option", required_argument, NULL, 'O'},
+ {"view", required_argument, NULL, 'V' },
+ {"help", no_argument, NULL, 'H'},
+ {0, 0, 0, 0}
+};
+#endif
+
+static int parsedirectory (const char *dir, dki_t **listp, int sub_before);
+static void parsefile (const char *file, dki_t **listp, int sub_before);
+static void usage (char *mesg, zconf_t *cp);
+
+static void setglobalflags (zconf_t *config)
+{
+ recflag = config->recursive;
+ ageflag = config->printage;
+ timeflag = config->printtime;
+ ljustflag = config->ljust;
+ term = config->colorterm;
+ if ( term && *term == '\0' )
+ term = getenv ("TERM");
+}
+
+int main (int argc, char *argv[])
+{
+ dki_t *data = NULL;
+ int c;
+ int opt_index;
+ int action;
+ const char *file;
+ const char *defconfname = NULL;
+ char *p;
+ char str[254+1];
+ zconf_t *config;
+
+ progname = *argv;
+ if ( (p = strrchr (progname, '/')) )
+ progname = ++p;
+ view = getnameappendix (progname, "zkt-ls");
+
+ defconfname = getdefconfname (view);
+ config = loadconfig ("", (zconf_t *)NULL); /* load built in config */
+ if ( fileexist (defconfname) ) /* load default config file */
+ config = loadconfig (defconfname, config);
+ if ( config == NULL )
+ fatal ("Out of memory\n");
+ setglobalflags (config);
+
+ opterr = 0;
+ opt_index = 0;
+ action = 0;
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+ while ( (c = getopt_long (argc, argv, short_options, long_options, &opt_index)) != -1 )
+#else
+ while ( (c = getopt (argc, argv, short_options)) != -1 )
+#endif
+ {
+ switch ( c )
+ {
+#if defined(COLOR_MODE) && COLOR_MODE
+ case 'C': /* color mode on; optional with terminal name */
+ if ( optarg )
+ term = optarg;
+ else
+ term = getenv ("TERM");
+ break;
+#endif
+ case 'T':
+ trustedkeyflag = 1;
+ subdomain_before_parent = 0;
+ zskflag = pathflag = 0;
+ /* fall through */
+ case 'H':
+ case 'K':
+ case 'Z':
+ action = c;
+ break;
+ case 'a': /* age */
+ ageflag = !ageflag;
+ break;
+ case 'f': /* key lifetime */
+ lifetimeflag = !lifetimeflag;
+ break;
+ case 'V': /* view name */
+ view = optarg;
+ defconfname = getdefconfname (view);
+ if ( fileexist (defconfname) ) /* load default config file */
+ config = loadconfig (defconfname, config);
+ if ( config == NULL )
+ fatal ("Out of memory\n");
+ setglobalflags (config);
+ break;
+ case 'c':
+ config = loadconfig (optarg, config);
+ setglobalflags (config);
+ checkconfig (config);
+ break;
+ case 'O': /* read option from commandline */
+ config = loadconfig_fromstr (optarg, config);
+ setglobalflags (config);
+ checkconfig (config);
+ break;
+ case 'd': /* ignore directory arg */
+ dirflag = 1;
+ break;
+ case 'h': /* print no headline */
+ headerflag = 0;
+ break;
+ case 'k': /* ksk only */
+ zskflag = 0;
+ break;
+ case 'L': /* ljust */
+ ljustflag = !ljustflag;
+ break;
+ case 'l': /* label list */
+ labellist = prepstrlist (optarg, LISTDELIM);
+ if ( labellist == NULL )
+ fatal ("Out of memory\n");
+ break;
+ case 'p': /* print path */
+ pathflag = 1;
+ break;
+ case 'r': /* switch recursive flag */
+ recflag = !recflag;
+ break;
+ case 's': /* switch subdomain sorting flag */
+ subdomain_before_parent = !subdomain_before_parent;
+ break;
+ case 't': /* time */
+ timeflag = !timeflag;
+ break;
+ case 'e': /* expire time */
+ exptimeflag = !exptimeflag;
+ break;
+ case 'z': /* zsk only */
+ kskflag = 0;
+ break;
+ case ':':
+ snprintf (str, sizeof(str), "option \"-%c\" requires an argument.\n",
+ optopt);
+ usage (str, config);
+ break;
+ case '?':
+ if ( isprint (optopt) )
+ snprintf (str, sizeof(str), "Unknown option \"-%c\".\n",
+ optopt);
+ else
+ snprintf (str, sizeof (str), "Unknown option char \\x%x.\n",
+ optopt);
+ usage (str, config);
+ break;
+ default:
+ abort();
+ }
+ }
+
+ if ( kskflag == 0 && zskflag == 0 )
+ kskflag = zskflag = 1;
+
+ tc_init (stdout, term);
+
+ c = optind;
+ do {
+ if ( c >= argc ) /* no args left */
+ file = config->zonedir; /* use default directory */
+ else
+ file = argv[c++];
+
+ if ( is_directory (file) )
+ parsedirectory (file, &data, subdomain_before_parent);
+ else
+ parsefile (file, &data, subdomain_before_parent);
+
+ } while ( c < argc ); /* for all arguments */
+
+ switch ( action )
+ {
+ case 'H':
+ usage ("", config);
+ case 'K':
+ zkt_list_dnskeys (data);
+ break;
+ case 'T':
+ zkt_list_trustedkeys (data);
+ break;
+ default:
+ zkt_list_keys (data);
+ }
+
+ tc_end (stdout, term);
+
+ return 0;
+}
+
+# define sopt_usage(mesg, value) fprintf (stderr, mesg, value)
+#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
+# define lopt_usage(mesg, value) fprintf (stderr, mesg, value)
+# define loptstr(lstr, sstr) lstr
+#else
+# define lopt_usage(mesg, value)
+# define loptstr(lstr, sstr) sstr
+#endif
+static void usage (char *mesg, zconf_t *cp)
+{
+ fprintf (stderr, "Secure DNS Zone Key Tool %s\n", ZKT_VERSION);
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "List keys in current or given directory (-r for recursive mode)\n");
+ sopt_usage ("\tusage: %s [-adefhkLprtzC] [-c config] [file|dir ...]\n", progname);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "List public part of keys in DNSKEY RR format\n");
+ sopt_usage ("\tusage: %s -K [-dhkrz] [-c config] [file|dir ...]\n", progname);
+ lopt_usage ("\tusage: %s --list-dnskeys [-dhkzr] [-c config] [file|dir ...]\n", progname);
+ fprintf (stderr, "\n");
+ fprintf (stderr, "List keys (output is suitable for trusted-keys section)\n");
+ sopt_usage ("\tusage: %s -T [-dhrz] [-c config] [file|dir ...]\n", progname);
+ lopt_usage ("\tusage: %s --list-trustedkeys [-dhzr] [-c config] [file|dir ...]\n", progname);
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, "General options \n");
+ fprintf (stderr, "\t-c file%s", loptstr (", --config=file\n", ""));
+ fprintf (stderr, "\t\t read config from instead of %s\n", CONFIG_FILE);
+ fprintf (stderr, "\t-O optstr%s", loptstr (", --config-option=\"optstr\"\n", ""));
+ fprintf (stderr, "\t\t read config options from commandline\n");
+ fprintf (stderr, "\t-h%s\t no headline or trusted-key section header/trailer in -T mode\n", loptstr (", --nohead", "\t"));
+ fprintf (stderr, "\t-d%s\t skip directory arguments\n", loptstr (", --directory", "\t"));
+ fprintf (stderr, "\t-L%s\t print the domain name left justified (default: %s)\n", loptstr (", --leftjust", "\t"), ljustflag ? "on": "off");
+ fprintf (stderr, "\t-l list%s", loptstr (", --label=\"list\"\n\t", ""));
+ fprintf (stderr, "\t\t print out only zone keys from the given domain list\n");
+ fprintf (stderr, "\t-C[term]%s", loptstr (", --color[=\"term\"]\n\t", ""));
+ fprintf (stderr, "\t\t turn color mode on \n");
+ fprintf (stderr, "\t-p%s\t show path of keyfile / create key in current directory\n", loptstr (", --path", "\t"));
+ fprintf (stderr, "\t-r%s\t recursive mode on/off (default: %s)\n", loptstr(", --recursive", "\t"), recflag ? "on": "off");
+ fprintf (stderr, "\t-s%s\t change sorting of subdomains\n", loptstr(", --subdomain", "\t"));
+ fprintf (stderr, "\t-a%s\t print age of key (default: %s)\n", loptstr (", --age", "\t"), ageflag ? "on": "off");
+ fprintf (stderr, "\t-t%s\t print key generation time (default: %s)\n", loptstr (", --time", "\t"),
+ timeflag ? "on": "off");
+ fprintf (stderr, "\t-e%s\t print key expiration time\n", loptstr (", --expire", "\t"));
+ fprintf (stderr, "\t-f%s\t print key lifetime\n", loptstr (", --lifetime", "\t"));
+ fprintf (stderr, "\t-k%s\t key signing keys only\n", loptstr (", --ksk", "\t"));
+ fprintf (stderr, "\t-z%s\t zone signing keys only\n", loptstr (", --zsk", "\t"));
+ if ( mesg && *mesg )
+ fprintf (stderr, "%s\n", mesg);
+ exit (1);
+}
+
+static int parsedirectory (const char *dir, dki_t **listp, int sub_before)
+{
+ dki_t *dkp;
+ DIR *dirp;
+ struct dirent *dentp;
+ char path[MAX_PATHSIZE+1];
+
+ if ( dirflag )
+ return 0;
+
+ dbg_val ("directory: opendir(%s)\n", dir);
+ if ( (dirp = opendir (dir)) == NULL )
+ return 0;
+
+ while ( (dentp = readdir (dirp)) != NULL )
+ {
+ if ( is_dotfilename (dentp->d_name) )
+ continue;
+
+ dbg_val ("directory: check %s\n", dentp->d_name);
+ pathname (path, sizeof (path), dir, dentp->d_name, NULL);
+ if ( is_directory (path) && recflag )
+ {
+ dbg_val ("directory: recursive %s\n", path);
+ parsedirectory (path, listp, sub_before);
+ }
+ else if ( is_keyfilename (dentp->d_name) )
+ if ( (dkp = dki_read (dir, dentp->d_name)) )
+ {
+ // fprintf (stderr, "parsedir: tssearch (%d %s)\n", dkp, dkp->name);
+#if defined (USE_TREE) && USE_TREE
+ dki_tadd (listp, dkp, sub_before);
+#else
+ dki_add (listp, dkp);
+#endif
+ }
+ }
+ closedir (dirp);
+ return 1;
+}
+
+static void parsefile (const char *file, dki_t **listp, int sub_before)
+{
+ char path[MAX_PATHSIZE+1];
+ dki_t *dkp;
+
+ /* file arg contains path ? ... */
+ file = splitpath (path, sizeof (path), file); /* ... then split of */
+
+ if ( is_keyfilename (file) ) /* plain file name looks like DNS key file ? */
+ {
+ if ( (dkp = dki_read (path, file)) ) /* read DNS key file ... */
+#if defined (USE_TREE) && USE_TREE
+ dki_tadd (listp, dkp, sub_before); /* ... and add to tree */
+#else
+ dki_add (listp, dkp); /* ... and add to list */
+#endif
+ else
+ error ("error parsing %s: (%s)\n", file, dki_geterrstr());
+ }
+}
diff --git a/contrib/zkt/dnssec-signer.c b/contrib/zkt/zkt-signer.c
similarity index 88%
rename from contrib/zkt/dnssec-signer.c
rename to contrib/zkt/zkt-signer.c
index 69b69d54e8..7a20ae3469 100644
--- a/contrib/zkt/dnssec-signer.c
+++ b/contrib/zkt/zkt-signer.c
@@ -1,11 +1,11 @@
/*****************************************************************
**
-** @(#) dnssec-signer.c (c) Jan 2005 Holger Zuleger hznet.de
+** @(#) zkt-signer.c (c) Jan 2005 - Jan 2010 Holger Zuleger hznet.de
**
** A wrapper around the BIND dnssec-signzone command which is able
** to resign a zone if necessary and doing a zone or key signing key rollover.
**
-** Copyright (c) 2005 - 2008, Holger Zuleger HZnet. All rights reserved.
+** Copyright (c) 2005 - 2010, Holger Zuleger HZnet. All rights reserved.
** This software is open source.
**
** Redistribution and use in source and binary forms, with or without
@@ -101,7 +101,7 @@ static int dosigning (zone_t *zonelist, zone_t *zp);
static int check_keydb_timestamp (dki_t *keylist, time_t reftime);
static int new_keysetfiles (const char *dir, time_t zone_signing_time);
static int writekeyfile (const char *fname, const dki_t *list, int key_ttl);
-static int sign_zone (const char *dir, const char *domain, const char *file, const zconf_t *conf);
+static int sign_zone (const zone_t *zp);
static void register_key (dki_t *listp, const zconf_t *z);
static void copy_keyset (const char *dir, const char *domain, const zconf_t *conf);
@@ -129,6 +129,7 @@ static zconf_t *config;
#define set_bind96_dynzone(dz) ((dz) = 6)
#define bind94_dynzone(dz) ( (dz) > 0 && (dz) < 6 )
#define bind96_dynzone(dz) ( (dz) >= 6 )
+#define is_defined(str) ( (str) && *(str) )
int main (int argc, char *const argv[])
{
@@ -145,8 +146,14 @@ int main (int argc, char *const argv[])
progname = *argv;
if ( (p = strrchr (progname, '/')) )
progname = ++p;
- viewname = getnameappendix (progname, "dnssec-signer");
+ if ( strncmp (progname, "dnssec-signer", 13) == 0 )
+ {
+ fprintf (stderr, "The use of dnssec-signer is deprecated, please run zkt-signer instead\n");
+ viewname = getnameappendix (progname, "dnssec-signer");
+ }
+ else
+ viewname = getnameappendix (progname, "zkt-signer");
defconfname = getdefconfname (viewname);
config = loadconfig ("", (zconf_t *)NULL); /* load build-in config */
if ( fileexist (defconfname) ) /* load default config file */
@@ -253,6 +260,14 @@ int main (int argc, char *const argv[])
#endif
lg_args (LG_NOTICE, argc, argv);
+ /* 1.0rc1: If the ttl for dynamic zones is not known or if it is 0, use sig valid time for this */
+ if ( config->max_ttl <= 0 || dynamic_zone )
+ {
+ // config = dupconfig (config);
+ config->max_ttl = config->sigvalidity;
+ }
+
+
if ( origin ) /* option -o ? */
{
int ret;
@@ -331,18 +346,19 @@ int main (int argc, char *const argv[])
#endif
static void usage (char *mesg, zconf_t *conf)
{
- fprintf (stderr, "%s version %s\n", progname, ZKT_VERSION);
+ fprintf (stderr, "%s version %s compiled for BIND %d\n", progname, ZKT_VERSION, BIND_VERSION);
+ fprintf (stderr, "ZKT %s\n", ZKT_COPYRIGHT);
fprintf (stderr, "\n");
- fprintf (stderr, "usage: %s [-c file] [-O optstr] ", progname);
+ fprintf (stderr, "usage: %s [-L] [-V view] [-c file] [-O optstr] ", progname);
fprintf (stderr, "[-D directorytree] ");
fprintf (stderr, "[-fhnr] [-v [-v]] [zone ...]\n");
- fprintf (stderr, "usage: %s [-c file] [-O optstr] ", progname);
+ fprintf (stderr, "usage: %s [-L] [-V view] [-c file] [-O optstr] ", progname);
fprintf (stderr, "-N named.conf ");
fprintf (stderr, "[-fhnr] [-v [-v]] [zone ...]\n");
- fprintf (stderr, "usage: %s [-c file] [-O optstr] ", progname);
+ fprintf (stderr, "usage: %s [-L] [-V view] [-c file] [-O optstr] ", progname);
fprintf (stderr, "-o origin ");
fprintf (stderr, "[-fhnr] [-v [-v]] [zonefile.signed]\n");
@@ -352,6 +368,8 @@ static void usage (char *mesg, zconf_t *conf)
fprintf (stderr, "\t\t set config options on the commandline\n");
fprintf (stderr, "\t-L file|dir%s", loptstr (", --logfile=file|dir\n", ""));
fprintf (stderr, "\t\t specify file or directory for the log output\n");
+ fprintf (stderr, "\t-V name%s", loptstr (", --view=name\n", ""));
+ fprintf (stderr, "\t\t specify the view name \n");
fprintf (stderr, "\t-D dir%s", loptstr (", --directory=dir\n", ""));
fprintf (stderr, "\t\t parse the given directory tree for a list of secure zones \n");
fprintf (stderr, "\t-N file%s", loptstr (", --named-conf=file\n", ""));
@@ -476,6 +494,15 @@ static int dosigning (zone_t *zonelist, zone_t *zp)
zfile_time = file_mtime (path);
currtime = time (NULL);
+ /* check for domain based logging */
+ if ( is_defined (zp->conf->logdomaindir) ) /* parameter is not null or empty ? */
+ {
+ if ( strcmp (zp->conf->logdomaindir, ".") == 0 ) /* current (".") means zone directory */
+ lg_zone_start (zp->dir, zp->zone);
+ else
+ lg_zone_start (zp->conf->logdomaindir, zp->zone);
+ }
+
/* check rfc5011 key signing keys, create new one if necessary */
dbg_msg("parsezonedir check rfc 5011 ksk ");
newkey = ksk5011status (&zp->keys, zp->dir, zp->zone, zp->conf);
@@ -553,6 +580,8 @@ static int dosigning (zone_t *zonelist, zone_t *zp)
verbmesg (2, zp->conf, "\tCheck if there is a parent file to copy\n");
if ( zp->conf->keysetdir && strcmp (zp->conf->keysetdir, "..") == 0 )
copy_keyset (zp->dir, zp->zone, zp->conf); /* copy the parent- file if it exist */
+ if ( is_defined (zp->conf->logdomaindir) )
+ lg_zone_end ();
return 0; /* nothing to do */
}
@@ -630,13 +659,19 @@ static int dosigning (zone_t *zonelist, zone_t *zp)
path, zfile);
if ( newkey ) /* if we have new keys, they should be added to the zone file */
+ {
copyzonefile (path, zfile, zp->conf->keyfile);
+#if 0
+ if ( zp->conf->dist_cmd )
+ dist_and_reload (zp, 2); /* ... and send to the name server */
+#endif
+ }
else /* else we can do a simple file copy */
copyfile (path, zfile, NULL);
}
timer = start_timer ();
- if ( (err = sign_zone (zp->dir, zp->zone, zp->file, zp->conf)) < 0 )
+ if ( (err = sign_zone (zp)) < 0 )
{
error ("\tSigning of zone %s failed (%d)!\n", zp->zone, err);
lg_mesg (LG_ERROR, "\"%s\": signing failed!", zp->zone);
@@ -661,13 +696,16 @@ static int dosigning (zone_t *zonelist, zone_t *zp)
if ( err >= 0 && reloadflag )
{
if ( zp->conf->dist_cmd )
- dist_and_reload (zp);
+ dist_and_reload (zp, 1);
else
reload_zone (zp->zone, zp->conf);
register_key (zp->keys, zp->conf);
}
+ if ( is_defined (zp->conf->logdomaindir) )
+ lg_zone_end ();
+
return err;
}
@@ -784,7 +822,7 @@ static int writekeyfile (const char *fname, const dki_t *list, int key_ttl)
return 1;
}
-static int sign_zone (const char *dir, const char *domain, const char *file, const zconf_t *conf)
+static int sign_zone (const zone_t *zp)
{
char cmd[2047+1];
char str[1023+1];
@@ -792,13 +830,22 @@ static int sign_zone (const char *dir, const char *domain, const char *file, con
char nsec3param[637+1];
char keysetdir[254+1];
const char *gends;
+ const char *dnskeyksk;
const char *pseudo;
const char *param;
int len;
FILE *fp;
- assert (conf != NULL);
- assert (domain != NULL);
+ const char *dir;
+ const char *domain;
+ const char *file;
+ const zconf_t *conf;
+
+ assert (zp != NULL);
+ dir = zp->dir;
+ domain = zp->zone;
+ file = zp->file;
+ conf = zp->conf;
len = 0;
str[0] = '\0';
@@ -813,7 +860,17 @@ static int sign_zone (const char *dir, const char *domain, const char *file, con
gends = "";
if ( conf->sig_gends )
+#if defined(BIND_VERSION) && BIND_VERSION >= 970
+ gends = "-C -g ";
+#else
gends = "-g ";
+#endif
+
+ dnskeyksk = "";
+#if defined(BIND_VERSION) && BIND_VERSION >= 970
+ if ( conf->sig_dnskeyksk )
+ dnskeyksk = "-x ";
+#endif
pseudo = "";
if ( conf->sig_pseudo )
@@ -825,12 +882,41 @@ static int sign_zone (const char *dir, const char *domain, const char *file, con
nsec3param[0] = '\0';
#if defined(BIND_VERSION) && BIND_VERSION >= 960
- if ( conf->k_algo == DK_ALGO_NSEC3DSA || conf->k_algo == DK_ALGO_NSEC3RSASHA1 )
+ if ( conf->k_algo == DK_ALGO_NSEC3DSA || conf->k_algo == DK_ALGO_NSEC3RSASHA1 ||
+ conf->nsec3 != NSEC3_OFF )
{
char salt[510+1]; /* salt has a maximum of 255 bytes == 510 hex nibbles */
+ const char *update;
+ const char *optout;
+ unsigned int seed;
- if ( gensalt (salt, sizeof (salt), conf->saltbits) )
- snprintf (nsec3param, sizeof (nsec3param), "-3 %s ", salt);
+# if defined(BIND_VERSION) && BIND_VERSION >= 970
+ update = "-u "; /* trailing blank is necessary */
+# else
+ update = "";
+# endif
+ if ( conf->nsec3 == NSEC3_OPTOUT )
+ optout = "-A ";
+ else
+ optout = "";
+
+ /* static zones can use always a new salt (full zone signing) */
+ seed = 0L; /* no seed: use mechanism build in gensalt() */
+ if ( dynamic_zone )
+ { /* dynamic zones have to reuse the salt on signing */
+ const dki_t *kp;
+
+ /* use gentime timestamp of ZSK for seeding rand generator */
+ kp = dki_find (zp->keys, DKI_ZSK, DKI_ACTIVE, 1);
+ assert ( kp != NULL );
+ if ( kp->gentime )
+ seed = kp->gentime;
+ else
+ seed = kp->time;
+ }
+
+ if ( gensalt (salt, sizeof (salt), conf->saltbits, seed) )
+ snprintf (nsec3param, sizeof (nsec3param), "%s%s-3 %s ", update, optout, salt);
}
#endif
@@ -850,12 +936,12 @@ static int sign_zone (const char *dir, const char *domain, const char *file, con
dbg_line();
#if defined(BIND_VERSION) && BIND_VERSION >= 940
if ( dynamic_zone )
- snprintf (cmd, sizeof (cmd), "cd %s; %s %s %s%s%s%s%s-o %s -e +%ld %s -N increment -f %s.dsigned %s K*.private 2>&1",
- dir, SIGNCMD, param, nsec3param, gends, pseudo, rparam, keysetdir, domain, conf->sigvalidity, str, file, file);
+ snprintf (cmd, sizeof (cmd), "cd %s; %s %s %s%s%s%s%s%s-o %s -e +%ld %s -N increment -f %s.dsigned %s K*.private 2>&1",
+ dir, SIGNCMD, param, nsec3param, dnskeyksk, gends, pseudo, rparam, keysetdir, domain, conf->sigvalidity, str, file, file);
else
#endif
- snprintf (cmd, sizeof (cmd), "cd %s; %s %s %s%s%s%s%s-o %s -e +%ld %s %s K*.private 2>&1",
- dir, SIGNCMD, param, nsec3param, gends, pseudo, rparam, keysetdir, domain, conf->sigvalidity, str, file);
+ snprintf (cmd, sizeof (cmd), "cd %s; %s %s %s%s%s%s%s%s-o %s -e +%ld %s %s K*.private 2>&1",
+ dir, SIGNCMD, param, nsec3param, dnskeyksk, gends, pseudo, rparam, keysetdir, domain, conf->sigvalidity, str, file);
verbmesg (2, conf, "\t Run cmd \"%s\"\n", cmd);
*str = '\0';
if ( noexec == 0 )
diff --git a/contrib/zkt/zkt.c b/contrib/zkt/zkt.c
index f8e51a974c..511c08c535 100644
--- a/contrib/zkt/zkt.c
+++ b/contrib/zkt/zkt.c
@@ -44,6 +44,8 @@
# include "misc.h"
# include "strlist.h"
# include "zconf.h"
+# include "domaincmp.h"
+# include "tcap.h"
#define extern
# include "zkt.h"
#undef extern
@@ -70,6 +72,7 @@ static void printkeyinfo (const dki_t *dkp, const char *oldpath)
{
if ( headerflag )
{
+ tc_attr (stdout, TC_BOLD, 1);
printf ("%-33.33s %5s %3s %3.3s %-7s", "Keyname",
"Tag", "Typ", "Status", "Algorit");
if ( timeflag )
@@ -80,6 +83,7 @@ static void printkeyinfo (const dki_t *dkp, const char *oldpath)
printf (" %16s", "Age");
if ( lifetimeflag )
printf (" %4s", "LfTm");
+ tc_attr (stdout, TC_BOLD, 0);
putchar ('\n');
}
return;
@@ -93,14 +97,35 @@ static void printkeyinfo (const dki_t *dkp, const char *oldpath)
if ( (kskflag && dki_isksk (dkp)) || (zskflag && !dki_isksk (dkp)) )
{
+ int color;
+
if ( ljustflag )
printf ("%-33.33s ", dkp->name);
else
printf ("%33.33s ", dkp->name);
printf ("%05d ", dkp->tag);
printf ("%3s ", dki_isksk (dkp) ? "KSK" : "ZSK");
+
+ if ( dkp->status == DKI_ACT )
+ color = TC_GREEN;
+ else if ( dkp->status == DKI_PUB )
+ color = TC_BLUE;
+ else if ( dkp->status == DKI_DEP )
+ color = TC_RED;
+ else
+ color = TC_BLACK;
+ tc_attr (stdout, color, 1);
printf ("%-3.3s ", dki_statusstr (dkp) );
+ tc_attr (stdout, color, 0);
+
printf ("%-7s", dki_algo2sstr(dkp->algo));
+
+ if ( currtime < dkp->time + dkp->lifetime )
+ color = TC_GREEN;
+ else
+ color = TC_BOLD|TC_RED;
+ tc_attr (stdout, color, 1);
+
if ( timeflag )
printf (" %-20s", time2str (dkp->gentime ? dkp->gentime: dkp->time, 's'));
if ( exptimeflag )
@@ -115,6 +140,7 @@ static void printkeyinfo (const dki_t *dkp, const char *oldpath)
putchar (' ');
printf ("%hdd", dki_lifetimedays (dkp));
}
+ tc_attr (stdout, color, 0);
putchar ('\n');
}
}
@@ -167,6 +193,7 @@ void zkt_list_keys (const dki_t *data)
}
#if defined(USE_TREE) && USE_TREE
+# if 0
static void list_trustedkey (const dki_t **nodep, const VISIT which, int depth)
{
const dki_t *dkp;
@@ -175,23 +202,54 @@ static void list_trustedkey (const dki_t **nodep, const VISIT which, int depth)
return;
dkp = *nodep;
-//fprintf (stderr, "list_trustedkey %d %d %s\n", which, depth, dkp->name);
if ( which == INORDER || which == LEAF )
- while ( dkp ) /* loop through list */
+ {
+// fprintf (stderr, "list_trustedkey order=%d(pre=0,in=1,post=2,leaf=3) depth=%d %s\n", which, depth, dkp->name);
+ /* loop through list */
+ while ( dkp )
{
if ( (dki_isksk (dkp) || zskflag) &&
(labellist == NULL || isinlist (dkp->name, labellist)) )
dki_prt_trustedkey (dkp, stdout);
dkp = dkp->next;
}
+ }
}
+# else
+const dki_t *parent;
+static void list_trustedkey (const dki_t **nodep, const VISIT which, int depth)
+{
+ const dki_t *dkp;
+
+ if ( nodep == NULL )
+ return;
+
+ dkp = *nodep;
+ if ( which == INORDER || which == LEAF )
+ {
+// fprintf (stderr, "list_trustedkey order=%d(pre=0,in=1,post=2,leaf=3) depth=%d %s\n", which, depth, dkp->name);
+ if ( labellist && !isinlist (dkp->name, labellist) )
+ return;
+
+ if ( parent == NULL || !issubdomain (dkp->name, parent->name) )
+ {
+ parent = dkp;
+ /* loop through list */
+ while ( dkp )
+ {
+ if ( (dki_isksk (dkp) || zskflag) )
+ dki_prt_trustedkey (dkp, stdout);
+ dkp = dkp->next;
+ }
+ }
+ }
+}
+# endif
#endif
void zkt_list_trustedkeys (const dki_t *data)
{
-#if !defined(USE_TREE) || !USE_TREE
- const dki_t *dkp;
-#endif
+
/* print headline if list is not empty */
if ( data && headerflag )
printf ("trusted-keys {\n");
@@ -199,7 +257,6 @@ void zkt_list_trustedkeys (const dki_t *data)
#if defined(USE_TREE) && USE_TREE
twalk (data, list_trustedkey);
#else
-
for ( dkp = data; dkp; dkp = dkp->next ) /* loop through list */
if ( (dki_isksk (dkp) || zskflag) &&
(labellist == NULL || isinlist (dkp->name, labellist)) )
diff --git a/contrib/zkt/zone.c b/contrib/zkt/zone.c
index 9f7df62d4f..da5da09759 100644
--- a/contrib/zkt/zone.c
+++ b/contrib/zkt/zone.c
@@ -197,6 +197,7 @@ int zone_readdir (const char *dir, const char *zone, const char *zfile, zone_t *
char *p;
char path[MAX_PATHSIZE+1];
char *signed_ext = ".signed";
+ zconf_t *localconf = NULL;
assert (dir != NULL && *dir != '\0');
assert (conf != NULL);
@@ -229,10 +230,9 @@ int zone_readdir (const char *dir, const char *zone, const char *zfile, zone_t *
dbg_val1 ("zone_readdir: check local config file %s\n", path);
if ( fileexist (path) ) /* load local config file */
{
- zconf_t *localconf;
-
localconf = dupconfig (conf);
conf = loadconfig (path, localconf);
+ /* do not free localconf, because a ptr to it will be added to the zone by zone_new() */
}
if ( zfile == NULL )
@@ -293,7 +293,7 @@ zone_t *zone_add (zone_t **list, zone_t *new)
curr = curr->next;
}
- if ( curr == *list ) /* add node at the beginning of the list */
+ if ( curr == *list ) /* add node at the begining of the list */
*list = new;
else /* add node at end or between two nodes */
last->next = new;