/*****************************************************************
**
** @(#) 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
**
** 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 <stdio.h>
# include <stdlib.h> /* abort(), exit(), ... */
# include <string.h>
# include <dirent.h>
# include <assert.h>
# include <unistd.h>
# include <ctype.h>
# include <time.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
# include "config_zkt.h"
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
# include <getopt.h>
#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 int writeflag = 0;
static int allflag = 0;
static int testflag = 0;
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
{0, 0, 0, 0}
};
#endif
{
int c;
int opt_index;
int action;
int major;
int minor;
const char *file;
char *p;
progname = ++p;
dbg_val0 ("Load built in config \"%s\"\n");
{
}
fatal ("Out of memory\n");
opterr = 0;
opt_index = 0;
action = 0;
setconfigversion (100);
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
#else
#endif
{
switch ( c )
{
case 'V': /* view name */
fatal ("Out of memory\n");
break;
case 'O': /* read option from commandline */
break;
case 'C':
{
case 1: break;
default:
usage ("illegal release number");
}
break;
case 'c':
if ( *optarg == '\0' )
usage ("empty config file name");
confname = "stdout";
else
break;
case 'd': /* built-in default config */
break;
case 's': /* side wide config */
/* this is the default **/
break;
case 'a': /* set all flag */
allflag = 1;
break;
case 'l': /* local config file */
{
}
else if ( !writeflag )
usage ("error: no local config file found");
break;
case 't': /* test config */
testflag = 1;
break;
case 'v': /* version */
return 0;
break;
case 'w': /* write back conf file */
writeflag = 1;
break;
case 'h': /* print help */
usage ("");
break;
case ':':
optopt);
break;
case '?':
optopt);
else
optopt);
break;
default:
abort();
}
}
c = optind;
if ( c >= argc ) /* no arguments given on commandline */
{
if ( testflag )
{
if ( checkconfig (config) )
}
else
{
if ( !writeflag ) /* print to stdout */
confname = "stdout";
if ( refconfig ) /* have we seen a local config file ? */
if ( allflag )
else
else
}
}
else /* command line argument found: use it as name of zone file */
{
long minttl;
long maxttl;
int keydbfound;
char *dnskeydb;
minttl = 0x7FFFFFFF;
maxttl = 0;
if ( keydbfound < 0 )
if ( dnskeydb && !keydbfound )
{
if ( writeflag )
{
}
else
printf ("\"$INCLUDE %s\" should be added to \"%s\" (run with option -w)\n",
}
fprintf (stderr, "Min_TTL of %s (%ld seconds) is too low to use it in a signed zone (see RFC4641)\n",
else
if ( writeflag )
{
{
}
}
}
return 0;
}
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
#else
#endif
{
fprintf (stderr, " -s%s\tprint site wide config file parameter (this is the default)\n", loptstr (", --sitecfg", ""));
fprintf (stderr, " -a%s\tprint all parameter not only the different one\n", loptstr (", --all", ""));
fprintf (stderr, " -t%s\ttest the config parameter if they are useful \n", loptstr (", --test", "\t"));
exit (1);
}