dnssec-settime.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2009-2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*! \file */
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <isc/commandline.h>
#include <dns/keyvalues.h>
#ifdef PKCS11CRYPTO
#endif
#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) {
#if defined(PKCS11CRYPTO)
"(default: %s)\n", PK11_LIB_LOCATION);
#elif defined(USE_PKCS11)
"(default \"pkcs11\")\n");
#else
#endif
"keys\n");
"publication date\n");
"CDS and CDNSKEY publication date\n");
"activation date\n");
"revocation date\n");
"inactivation date\n");
"deletion date\n");
"CDS and CDNSKEY deletion date\n");
"particular time 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_ENGINE;
#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");
#ifdef PKCS11CRYPTO
#endif
#define CMDLINE_FLAGS "A:D:E:fhI:i:K:L:P:p:R:S:uv:V"
switch (ch) {
case 'E':
break;
case 'f':
break;
case 'p':
if (!strcasecmp(p, "all")) {
break;
}
do {
switch (*p++) {
case 'C':
break;
case 'P':
p += 4;
break;
}
break;
case 'A':
break;
case 'R':
break;
case 'I':
break;
case 'D':
p += 4;
break;
}
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':
break;
case 'v':
if (*endp != '\0')
fatal("-v must be followed by a number");
break;
case 'P':
/* -Psync ? */
if (unsetsyncadd || setsyncadd)
fatal("-P sync specified more than "
"once");
break;
}
fatal("-P specified more than once");
break;
case 'A':
fatal("-A specified more than once");
break;
case 'R':
fatal("-R specified more than once");
break;
case 'I':
if (setinact || unsetinact)
fatal("-I specified more than once");
unsetinact = !setinact;
break;
case 'D':
/* -Dsync ? */
if (unsetsyncdel || setsyncdel)
fatal("-D sync specified more than "
"once");
break;
}
/* -Ddnskey ? */
fatal("-D specified more than once");
break;
case 'S':
break;
case 'i':
break;
case '?':
if (isc_commandline_option != '?')
/* Falls into */
case 'h':
/* Does not return. */
usage();
case 'V':
/* Does not return. */
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) {
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",
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.");
&previnact);
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);
"scheduled to be deleted\n\t"
"before it is scheduled to be "
"inactive.\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 (predecessor != NULL) {
fatal("Key name mismatch");
fatal("Key algorithm mismatch");
fatal("Key size mismatch");
fatal("Key flags mismatch");
}
&previnact) == ISC_R_SUCCESS &&
&prevdel) == ISC_R_SUCCESS &&
"be deleted before it is\n\t"
"scheduled to be inactive.\n",
program);
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 (setsyncadd)
else if (unsetsyncadd)
if (setsyncdel)
else if (unsetsyncdel)
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 (printsyncadd)
if (printsyncdel)
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);
}