named-checkconf now has -h for help.
named-checkzone now has -h for help.
Better handling of '-?' for usage summaries.
[RT #16707]
+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]
* 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 */
}
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;
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;
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) {
result = dns_zone_dumptostream2(zone, output, fileformat, style);
- if (filename != NULL)
+ if (output != stdout)
(void)isc_stdio_close(output);
return (result);
* 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
/*! \file */
#include <isc/lang.h>
+#include <isc/stdio.h>
#include <isc/types.h>
#include <dns/masterdump.h>
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,
* 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 */
#include "check-tool.h"
+static const char *program = "named-checkconf";
+
isc_log_t *logc = NULL;
#define CHECK(r)\
/*% 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);
}
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++;
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')
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)
- 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>
<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>
<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>
* 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 */
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;
#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':
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);
}
}
}
}
- 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);
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);
- 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>
<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>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>-h</term>
+ <listitem>
+ <para>
+ Print the usage summary and exit.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>-q</term>
<listitem>
<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>
* 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 */
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':
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);
}
}
* 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 */
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':
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);
* 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 */
exit(0);
case '?':
usage();
+ if (isc_commandline_option == '?')
+ exit(0);
ns_main_earlyfatal("unknown option '-%c'",
isc_commandline_option);
default:
* 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 */
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) {
* 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 */
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) {
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);
}
}
* 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 */
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) {
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);
}
}