Commit 0f8c9b5e authored by Mark Andrews's avatar Mark Andrews

2191. [func] named-checkzone now allows dumping to stdout (-).

                        named-checkconf now has -h for help.
                        named-checkzone now has -h for help.
                        Better handling of '-?' for usage summaries.
                        [RT #16707]
parent bc6af069
2191. [func] named-checkzone now allows dumping to stdout (-).
named-checkconf now has -h for help.
named-checkzone now has -h for help.
Better handling of '-?' for usage summaries.
[RT #16707]
2190. [func] Make fallback to plain DNS from EDNS due to timeouts
more visible. New logging category "edns-disabled".
[RT #16871]
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: check-tool.c,v 1.26 2006/07/21 07:11:56 marka Exp $ */
/* $Id: check-tool.c,v 1.27 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -494,7 +494,7 @@ checksrv(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
}
isc_result_t
setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
isc_logdestination_t destination;
isc_logconfig_t *logconfig = NULL;
isc_log_t *log = NULL;
......@@ -506,7 +506,7 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
dns_log_setcontext(log);
cfg_log_init(log);
destination.file.stream = stdout;
destination.file.stream = errout;
destination.file.name = NULL;
destination.file.versions = ISC_LOG_ROLLNEVER;
destination.file.maximum_size = 0;
......@@ -590,14 +590,14 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
FILE *output = stdout;
if (debug) {
if (filename != NULL)
if (filename != NULL && strcmp(filename, "-") != 0)
fprintf(stderr, "dumping \"%s\" to \"%s\"\n",
zonename, filename);
else
fprintf(stderr, "dumping \"%s\"\n", zonename);
}
if (filename != NULL) {
if (filename != NULL && strcmp(filename, "-") != 0) {
result = isc_stdio_open(filename, "w+", &output);
if (result != ISC_R_SUCCESS) {
......@@ -609,7 +609,7 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
result = dns_zone_dumptostream2(zone, output, fileformat, style);
if (filename != NULL)
if (output != stdout)
(void)isc_stdio_close(output);
return (result);
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: check-tool.h,v 1.11 2005/06/20 01:03:48 marka Exp $ */
/* $Id: check-tool.h,v 1.12 2007/05/21 02:47:25 marka Exp $ */
#ifndef CHECK_TOOL_H
#define CHECK_TOOL_H
......@@ -23,6 +23,7 @@
/*! \file */
#include <isc/lang.h>
#include <isc/stdio.h>
#include <isc/types.h>
#include <dns/masterdump.h>
......@@ -31,7 +32,7 @@
ISC_LANG_BEGINDECLS
isc_result_t
setup_logging(isc_mem_t *mctx, isc_log_t **logp);
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp);
isc_result_t
load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: named-checkconf.c,v 1.42 2006/02/28 02:39:51 marka Exp $ */
/* $Id: named-checkconf.c,v 1.43 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -47,6 +47,8 @@
#include "check-tool.h"
static const char *program = "named-checkconf";
isc_log_t *logc = NULL;
#define CHECK(r)\
......@@ -59,8 +61,8 @@ isc_log_t *logc = NULL;
/*% usage */
static void
usage(void) {
fprintf(stderr, "usage: named-checkconf [-j] [-v] [-z] [-t directory] "
"[named.conf]\n");
fprintf(stderr, "usage: %s [-h] [-j] [-v] [-z] [-t directory] "
"[named.conf]\n", program);
exit(1);
}
......@@ -397,7 +399,9 @@ main(int argc, char **argv) {
isc_entropy_t *ectx = NULL;
isc_boolean_t load_zones = ISC_FALSE;
while ((c = isc_commandline_parse(argc, argv, "djt:vz")) != EOF) {
isc_commandline_errprint = ISC_FALSE;
while ((c = isc_commandline_parse(argc, argv, "dhjt:vz")) != EOF) {
switch (c) {
case 'd':
debug++;
......@@ -433,11 +437,22 @@ main(int argc, char **argv) {
dochecksrv = ISC_FALSE;
break;
default:
case '?':
if (isc_commandline_option != '?')
fprintf(stderr, "%s: invalid argument -%c\n",
program, isc_commandline_option);
case 'h':
usage();
default:
fprintf(stderr, "%s: unhandled option -%c\n",
program, isc_commandline_option);
exit(1);
}
}
if (isc_commandline_index + 1 < argc)
usage();
if (argv[isc_commandline_index] != NULL)
conffile = argv[isc_commandline_index];
if (conffile == NULL || conffile[0] == '\0')
......@@ -445,7 +460,7 @@ main(int argc, char **argv) {
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(setup_logging(mctx, &logc) == ISC_R_SUCCESS);
RUNTIME_CHECK(setup_logging(mctx, stdout, &logc) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_entropy_create(mctx, &ectx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE)
......
......@@ -18,7 +18,7 @@
- PERFORMANCE OF THIS SOFTWARE.
-->
<!-- $Id: named-checkconf.docbook,v 1.16 2007/05/09 01:32:08 marka Exp $ -->
<!-- $Id: named-checkconf.docbook,v 1.17 2007/05/21 02:47:25 marka Exp $ -->
<refentry id="man.named-checkconf">
<refentryinfo>
<date>June 14, 2000</date>
......@@ -53,6 +53,7 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>named-checkconf</command>
<arg><option>-h</option></arg>
<arg><option>-v</option></arg>
<arg><option>-j</option></arg>
<arg><option>-t <replaceable class="parameter">directory</replaceable></option></arg>
......@@ -73,6 +74,15 @@
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>-h</term>
<listitem>
<para>
Print the usage summary and exit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-t <replaceable class="parameter">directory</replaceable></term>
<listitem>
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: named-checkzone.c,v 1.47 2007/03/29 23:47:04 tbox Exp $ */
/* $Id: named-checkzone.c,v 1.48 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -105,6 +105,7 @@ main(int argc, char **argv) {
const char *outputformatstr = NULL;
dns_masterformat_t inputformat = dns_masterformat_text;
dns_masterformat_t outputformat = dns_masterformat_text;
FILE *errout = stdout;
outputstyle = &dns_master_style_full;
......@@ -139,8 +140,10 @@ main(int argc, char **argv) {
#define ARGCMP(X) (strcmp(isc_commandline_argument, X) == 0)
isc_commandline_errprint = ISC_FALSE;
while ((c = isc_commandline_parse(argc, argv,
"c:df:i:jk:m:n:qs:t:o:vw:DF:M:S:W:"))
"c:df:hi:jk:m:n:qs:t:o:vw:DF:M:S:W:"))
!= EOF) {
switch (c) {
case 'c':
......@@ -342,17 +345,17 @@ main(int argc, char **argv) {
zone_options &= ~DNS_ZONEOPT_CHECKWILDCARD;
break;
default:
case '?':
if (isc_commandline_option != '?')
fprintf(stderr, "%s: invalid argument -%c\n",
prog_name, isc_commandline_option);
case 'h':
usage();
}
}
if (progmode == progmode_compile) {
dumpzone = 1; /* always dump */
if (output_filename == NULL) {
fprintf(stderr,
"output file required, but not specified\n");
usage();
default:
fprintf(stderr, "%s: unhandled option -%c\n",
prog_name, isc_commandline_option);
exit(1);
}
}
......@@ -389,12 +392,36 @@ main(int argc, char **argv) {
}
}
if (isc_commandline_index + 2 > argc)
if (progmode == progmode_compile) {
dumpzone = 1; /* always dump */
if (output_filename == NULL) {
fprintf(stderr,
"output file required, but not specified\n");
usage();
}
}
if (output_filename != NULL)
dumpzone = 1;
/*
* If we are outputing to stdout then send the informational
* output to stderr.
*/
if (dumpzone &&
(output_filename == NULL ||
strcmp(output_filename, "-") == 0 ||
strcmp(output_filename, "/dev/fd/1") == 0 ||
strcmp(output_filename, "/dev/stdout") == 0))
errout = stderr;
if (isc_commandline_index + 2 != argc)
usage();
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
if (!quiet)
RUNTIME_CHECK(setup_logging(mctx, &lctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(setup_logging(mctx, errout, &lctx)
== ISC_R_SUCCESS);
RUNTIME_CHECK(isc_entropy_create(mctx, &ectx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE)
== ISC_R_SUCCESS);
......@@ -408,17 +435,17 @@ main(int argc, char **argv) {
if (result == ISC_R_SUCCESS && dumpzone) {
if (!quiet && progmode == progmode_compile) {
fprintf(stdout, "dump zone to %s...", output_filename);
fflush(stdout);
fprintf(errout, "dump zone to %s...", output_filename);
fflush(errout);
}
result = dump_zone(origin, zone, output_filename,
outputformat, outputstyle);
if (!quiet && progmode == progmode_compile)
fprintf(stdout, "done\n");
fprintf(errout, "done\n");
}
if (!quiet && result == ISC_R_SUCCESS)
fprintf(stdout, "OK\n");
fprintf(errout, "OK\n");
destroy();
if (lctx != NULL)
isc_log_destroy(&lctx);
......
......@@ -18,7 +18,7 @@
- PERFORMANCE OF THIS SOFTWARE.
-->
<!-- $Id: named-checkzone.docbook,v 1.31 2007/05/09 06:18:44 marka Exp $ -->
<!-- $Id: named-checkzone.docbook,v 1.32 2007/05/21 02:47:25 marka Exp $ -->
<refentry id="man.named-checkzone">
<refentryinfo>
<date>June 13, 2000</date>
......@@ -56,6 +56,7 @@
<cmdsynopsis>
<command>named-checkzone</command>
<arg><option>-d</option></arg>
<arg><option>-h</option></arg>
<arg><option>-j</option></arg>
<arg><option>-q</option></arg>
<arg><option>-v</option></arg>
......@@ -136,6 +137,15 @@
</listitem>
</varlistentry>
<varlistentry>
<term>-h</term>
<listitem>
<para>
Print the usage summary and exit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>-q</term>
<listitem>
......@@ -301,6 +311,8 @@
<listitem>
<para>
Write zone output to <filename>filename</filename>.
If <filename>filename</filename> is <filename>-</filename> then
write to standard out.
This is mandatory for <command>named-compilezone</command>.
</para>
</listitem>
......
......@@ -16,7 +16,7 @@
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-keygen.c,v 1.75 2007/01/09 23:49:38 marka Exp $ */
/* $Id: dnssec-keygen.c,v 1.76 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -134,8 +134,10 @@ main(int argc, char **argv) {
dns_result_register();
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv,
"a:b:c:d:ef:g:kn:t:p:s:r:v:h")) != -1)
"a:b:c:d:ef:g:kn:t:p:s:r:v:h")) != -1)
{
switch (ch) {
case 'a':
......@@ -202,12 +204,17 @@ main(int argc, char **argv) {
fatal("-v must be followed by a number");
break;
case '?':
if (isc_commandline_option != '?')
fprintf(stderr, "%s: invalid argument -%c\n",
program, isc_commandline_option);
case 'h':
usage();
default:
fprintf(stderr, "%s: invalid argument -%c\n",
program, ch);
usage();
fprintf(stderr, "%s: unhandled option -%c\n",
program, isc_commandline_option);
exit(1);
}
}
......
......@@ -16,7 +16,7 @@
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: dnssec-signzone.c,v 1.201 2007/05/18 23:46:58 tbox Exp $ */
/* $Id: dnssec-signzone.c,v 1.202 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -1862,8 +1862,10 @@ main(int argc, char *argv[]) {
dns_result_register();
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv,
"ac:d:e:f:ghi:I:j:k:l:n:N:o:O:pr:s:Stv:z"))
"ac:d:e:f:ghi:I:j:k:l:n:N:o:O:pr:s:Stv:z"))
!= -1) {
switch (ch) {
case 'a':
......@@ -1890,11 +1892,19 @@ main(int argc, char *argv[]) {
generateds = ISC_TRUE;
break;
case '?':
if (isc_commandline_option != '?')
fprintf(stderr, "%s: invalid argument -%c\n",
program, isc_commandline_option);
case 'h':
default:
usage();
break;
default:
fprintf(stderr, "%s: unhandled option -%c\n",
program, isc_commandline_option);
exit(1);
case 'i':
endp = NULL;
cycle = strtol(isc_commandline_argument, &endp, 0);
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: main.c,v 1.154 2006/12/21 06:02:29 marka Exp $ */
/* $Id: main.c,v 1.155 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -447,6 +447,8 @@ parse_command_line(int argc, char *argv[]) {
exit(0);
case '?':
usage();
if (isc_commandline_option == '?')
exit(0);
ns_main_earlyfatal("unknown option '-%c'",
isc_commandline_option);
default:
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: nsupdate.c,v 1.149 2007/04/24 07:02:31 marka Exp $ */
/* $Id: nsupdate.c,v 1.150 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -847,13 +847,19 @@ parse_args(int argc, char **argv) {
exit(1);
}
break;
default:
fprintf(stderr, "%s: invalid argument -%c\n",
argv[0], ch);
case '?':
if (isc_commandline_option != '?')
fprintf(stderr, "%s: invalid argument -%c\n",
argv[0], isc_commandline_option);
fprintf(stderr, "usage: nsupdate [-d] "
"[-g | -o | -y keyname:secret | -k keyfile] "
"[-v] [filename]\n");
exit(1);
default:
fprintf(stderr, "%s: unhandled option: %c\n",
argv[0], isc_commandline_option);
exit(1);
}
}
if (keyfile != NULL && keystr != NULL) {
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: rndc-confgen.c,v 1.21 2005/04/29 00:22:35 marka Exp $ */
/* $Id: rndc-confgen.c,v 1.22 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -160,6 +160,8 @@ main(int argc, char **argv) {
serveraddr = DEFAULT_SERVER;
port = DEFAULT_PORT;
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv,
"ab:c:hk:Mmp:r:s:t:u:Vy")) != -1) {
switch (ch) {
......@@ -214,12 +216,17 @@ main(int argc, char **argv) {
verbose = ISC_TRUE;
break;
case '?':
usage(1);
if (isc_commandline_option != '?') {
fprintf(stderr, "%s: invalid argument -%c\n",
program, isc_commandline_option);
usage(1);
} else
usage(0);
break;
default:
fatal("unexpected error parsing command arguments: "
"got %c\n", ch);
break;
fprintf(stderr, "%s: unhandled option -%c\n",
program, isc_commandline_option);
exit(1);
}
}
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: rndc.c,v 1.114 2006/12/04 01:52:45 marka Exp $ */
/* $Id: rndc.c,v 1.115 2007/05/21 02:47:25 marka Exp $ */
/*! \file */
......@@ -690,6 +690,8 @@ main(int argc, char **argv) {
if (result != ISC_R_SUCCESS)
fatal("isc_app_start() failed: %s", isc_result_totext(result));
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv, "b:c:k:Mmp:s:Vy:"))
!= -1) {
switch (ch) {
......@@ -741,13 +743,18 @@ main(int argc, char **argv) {
break;
case '?':
if (isc_commandline_option != '?') {
fprintf(stderr, "%s: invalid argument -%c\n",
program, isc_commandline_option);
usage(1);
}
case 'h':
usage(0);
break;
default:
fatal("unexpected error parsing command arguments: "
"got %c\n", ch);
break;
fprintf(stderr, "%s: unhandled option -%c\n",
program, isc_commandline_option);
exit(1);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment