dnssec-settime.c revision e3b59e4af757d4b26ecb96e65f9953488283c216
/*
* Copyright (C) 2009 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.19 2009/10/27 18:56:49 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 is \"pkcs11\")\n");
#else
#endif
"keys\n");
"publication date\n");
"activation date\n");
"revocation date\n");
"inactivation date\n");
"deletion date\n");
"value or values "
"[default: all]\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;
if (argc == 1)
usage();
if (result != ISC_R_SUCCESS)
fatal("Out of memory");
"E:fK:uhp:v:P:A:R:I:D:")) != -1) {
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 '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 '?':
if (isc_commandline_option != '?')
/* Falls into */
case 'h':
usage();
default:
exit(1);
}
}
fatal("The key file name was not specified");
fatal("Extraneous arguments");
} else {
if (result != ISC_R_SUCCESS)
fatal("cannot process filename %s: %s",
}
if (result != ISC_R_SUCCESS)
fatal("Could not initialize hash");
if (result != ISC_R_SUCCESS)
fatal("Could not initialize dst: %s",
if (result != ISC_R_SUCCESS)
fatal("Invalid keyfile %s: %s",
if (!dst_key_isprivate(key))
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)
/*
* 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);
}