/*****************************************************************
**
** @(#) 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
**
** 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>
#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 "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;
int ageflag = 0;
int lifetime = 0;
int lifetimeflag = 0;
int exptimeflag = 0;
int pathflag = 0;
int ljustflag = 0;
static int dirflag = 0;
static int trustedkeyflag = 0;
#if defined(COLOR_MODE) && COLOR_MODE
#else
#endif
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
#if defined(COLOR_MODE) && COLOR_MODE
#endif
{0, 0, 0, 0}
};
#endif
{
}
{
int c;
int opt_index;
int action;
const char *file;
char *p;
progname = ++p;
fatal ("Out of memory\n");
opterr = 0;
opt_index = 0;
action = 0;
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
#else
#endif
{
switch ( c )
{
#if defined(COLOR_MODE) && COLOR_MODE
case 'C': /* color mode on; optional with terminal name */
if ( optarg )
else
break;
#endif
case 'T':
trustedkeyflag = 1;
/* fall through */
case 'H':
case 'K':
case 'Z':
action = c;
break;
case 'a': /* age */
break;
case 'f': /* key lifetime */
break;
case 'V': /* view name */
fatal ("Out of memory\n");
break;
case 'c':
break;
case 'O': /* read option from commandline */
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 */
break;
case 'l': /* label list */
fatal ("Out of memory\n");
break;
case 'p': /* print path */
pathflag = 1;
break;
case 'r': /* switch recursive flag */
break;
case 's': /* switch subdomain sorting flag */
break;
case 't': /* time */
break;
case 'e': /* expire time */
break;
case 'z': /* zsk only */
kskflag = 0;
break;
case ':':
optopt);
break;
case '?':
optopt);
else
optopt);
break;
default:
abort();
}
}
c = optind;
do {
if ( c >= argc ) /* no args left */
else
if ( is_directory (file) )
else
} while ( c < argc ); /* for all arguments */
switch ( action )
{
case 'H':
case 'K':
break;
case 'T':
break;
default:
}
return 0;
}
#if defined(HAVE_GETOPT_LONG) && HAVE_GETOPT_LONG
#else
#endif
{
fprintf (stderr, "\t-h%s\t no headline or trusted-key section header/trailer in -T mode\n", loptstr (", --nohead", "\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-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-a%s\t print age of key (default: %s)\n", loptstr (", --age", "\t"), ageflag ? "on": "off");
exit (1);
}
{
if ( dirflag )
return 0;
return 0;
{
continue;
{
}
{
// fprintf (stderr, "parsedir: tssearch (%d %s)\n", dkp, dkp->name);
#else
#endif
}
}
return 1;
}
{
/* file arg contains path ? ... */
{
#else
#endif
else
}
}