dnssec-settime.c revision 6b95b91c617a3e56aff611772744af32b5410e1f
/*
* Copyright (C) 2009-2011 Internet Systems Consortium, Inc. ("ISC")
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-settime.c,v 1.32 2011/06/02 20:24:45 each Exp $ */
/*! \file */
#include <config.h>
#include <libgen.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <isc/commandline.h>
#include <dns/keyvalues.h>
#include "dnssectool.h"
const char *program = "dnssec-settime";
int verbose;
ISC_PLATFORM_NORETURN_PRE static void
usage(void) ISC_PLATFORM_NORETURN_POST;
static void
usage(void) {
#ifdef USE_PKCS11
"(default \"pkcs11\")\n");
#else
#endif
"keys\n");
"publication date\n");
"activation date\n");
"revocation date\n");
"inactivation date\n");
"deletion date\n");
"value or values\n");
"format\n");
"K<name>+<alg>+<new id>.private\n");
exit (-1);
}
static void
{
if (result == ISC_R_NOTFOUND) {
} else if (epoch) {
} else {
}
}
int
#ifdef USE_PKCS11
const char *engine = "pkcs11";
#else
#endif
char newname[1024];
char keystr[DST_KEY_FORMATSIZE];
char *endp, *p;
int ch;
const char *predecessor = NULL;
dns_secalg_t alg = 0;
unsigned int size = 0;
isc_uint16_t flags = 0;
int prepub = -1;
if (argc == 1)
usage();
if (result != ISC_R_SUCCESS)
fatal("Out of memory");
#define CMDLINE_FLAGS "A:D:E:fhI:i:K:L:P:p:R:S:uv:"
switch (ch) {
case 'E':
break;
case 'f':
break;
case 'p':
if (!strcasecmp(p, "all")) {
break;
}
do {
switch (*p++) {
case 'C':
break;
case 'P':
break;
case 'A':
break;
case 'R':
break;
case 'I':
break;
case 'D':
break;
case ' ':
break;
default:
usage();
break;
}
} while (*p != '\0');
break;
case 'u':
break;
case 'K':
/*
* We don't have to copy it here, but do it to
* simplify cleanup later
*/
fatal("Failed to allocate memory for "
"directory");
}
break;
case 'L':
ttl = 0;
else
break;
case 'v':
if (*endp != '\0')
fatal("-v must be followed by a number");
break;
case 'P':
fatal("-P specified more than once");
} else {
}
break;
case 'A':
fatal("-A specified more than once");
} else {
}
break;
case 'R':
fatal("-R specified more than once");
} else {
}
break;
case 'I':
if (setinact || unsetinact)
fatal("-I specified more than once");
} else {
}
break;
case 'D':
fatal("-D specified more than once");
} else {
}
break;
case 'S':
break;
case 'i':
break;
case '?':
if (isc_commandline_option != '?')
/* Falls into */
case 'h':
usage();
default:
exit(1);
}
}
fatal("The key file name was not specified");
fatal("Extraneous arguments");
if (result != ISC_R_SUCCESS)
fatal("Could not initialize hash");
if (result != ISC_R_SUCCESS)
fatal("Could not initialize dst: %s",
if (predecessor != NULL) {
char keystr[DST_KEY_FORMATSIZE];
if (prepub == -1)
fatal("-S and -P cannot be used together");
fatal("-S and -A cannot be used together");
if (result != ISC_R_SUCCESS)
fatal("Invalid keyfile %s: %s",
if (!dst_key_isprivate(prevkey))
fatal("Predecessor has incompatible format "
if (result != ISC_R_SUCCESS)
fatal("Predecessor has no activation date. "
"You must set one before\n\t"
"generating a successor.");
if (result != ISC_R_SUCCESS)
fatal("Predecessor has no inactivation date. "
"You must set one before\n\t"
"generating a successor.");
fatal("Predecessor will become inactive before the\n\t"
"prepublication period ends. Either change "
"its inactivation date,\n\t"
"or use the -i option to set a shorter "
"prepublication interval.");
if (result != ISC_R_SUCCESS)
"removal date;\n\t"
"it will remain in the zone "
"indefinitely after rollover.\n",
program);
} else {
if (prepub < 0)
prepub = 0;
if (prepub > 0) {
fatal("Activation and publication dates "
"are closer together than the\n\t"
"prepublication interval.");
}
fatal("Time until activation is shorter "
"than the\n\tprepublication interval.");
}
}
} else {
if (result != ISC_R_SUCCESS)
fatal("cannot process filename %s: %s",
}
if (result != ISC_R_SUCCESS)
fatal("Invalid keyfile %s: %s",
if (!dst_key_isprivate(key))
if (predecessor != NULL) {
fatal("Key name mismatch");
fatal("Key algorithm mismatch");
fatal("Key size mismatch");
fatal("Key flags mismatch");
}
if (force)
else
if (verbose > 2)
/*
* Set time values.
*/
if (setpub)
else if (unsetpub)
if (setact)
else if (unsetact)
if (setrev) {
"revoked; changing the revocation date "
"will not affect this.\n",
"a KSK, but -R was used. Revoking a "
"ZSK is legal, but undefined.\n",
} else if (unsetrev) {
"revoked; removing the revocation date "
"will not affect this.\n",
}
if (setinact)
else if (unsetinact)
if (setdel)
else if (unsetdel)
if (setttl)
/*
* No metadata changes were made but we're forcing an upgrade
* to the new format anyway: use "-P now -A now" as the default
*/
}
/*
* Print out time values, if -p was used.
*/
if (printcreate)
if (printpub)
if (printact)
if (printrev)
if (printinact)
if (printdel)
if (changed) {
&buf);
if (result != ISC_R_SUCCESS) {
fatal("Failed to build public key filename: %s",
}
if (result != ISC_R_SUCCESS) {
}
&buf);
if (result != ISC_R_SUCCESS) {
fatal("Failed to build private key filename: %s",
}
}
dst_key_free(&key);
if (verbose > 10)
return (0);
}