From fd00bac736a53d26c4c7f39c3d04d82d40f61958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 22 Jul 2019 10:33:17 -0400 Subject: [PATCH] Add -q (quiet) option to dnssec-signzone and dnssec-verify tool With the move of the normal output to stdout, we need a way how to silence the extra output, so the signed file name can be captured in a simple way. This commit adds `-q` command line option that will silence all the normal output that get's printed from both tools. --- bin/dnssec/dnssec-keygen.c | 1 - bin/dnssec/dnssec-signzone.c | 19 +++++++++++++------ bin/dnssec/dnssec-verify.c | 17 ++++++++++++----- bin/dnssec/dnssectool.c | 3 ++- bin/dnssec/dnssectool.h | 3 ++- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index be6779ca1d..2fad3fb285 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -218,7 +218,6 @@ main(int argc, char **argv) { bool unsetrev = false, unsetinact = false; bool unsetdel = false; bool genonly = false; - bool quiet = false; bool show_progress = false; unsigned char c; isc_stdtime_t syncadd = 0, syncdel = 0; diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 7a0155baa5..8b5e4c34a5 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -2645,12 +2645,14 @@ loadexplicitkeys(char *keyfiles[], int n, bool setksk) { static void report(const char *format, ...) { - FILE *out = output_stdout ? stderr : stdout; - va_list args; - va_start(args, format); - vfprintf(out, format, args); - va_end(args); - putc('\n', out); + if (!quiet) { + FILE *out = output_stdout ? stderr : stdout; + va_list args; + va_start(args, format); + vfprintf(out, format, args); + va_end(args); + putc('\n', out); + } } static void @@ -3086,6 +3088,7 @@ usage(void) { fprintf(stderr, "\t-j jitter:\n"); fprintf(stderr, "\t\trandomize signature end time up to jitter seconds\n"); fprintf(stderr, "\t-v debuglevel (0)\n"); + fprintf(stderr, "\t-q quiet\n"); fprintf(stderr, "\t-V:\tprint version information\n"); fprintf(stderr, "\t-o origin:\n"); fprintf(stderr, "\t\tzone origin (name of zonefile)\n"); @@ -3479,6 +3482,10 @@ main(int argc, char *argv[]) { fatal("verbose level must be numeric"); break; + case 'q': + quiet = true; + break; + case 'X': dnskey_endstr = isc_commandline_argument; break; diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index caf9742695..7fff0df94e 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -80,11 +80,13 @@ static bool keyset_kskonly = false; static void report(const char *format, ...) { - va_list args; - va_start(args, format); - vfprintf(stdout, format, args); - va_end(args); - putc('\n', stdout); + if (!quiet) { + va_list args; + va_start(args, format); + vfprintf(stdout, format, args); + va_end(args); + putc('\n', stdout); + } } /*% @@ -149,6 +151,7 @@ usage(void) { fprintf(stderr, "Options: (default value in parenthesis) \n"); fprintf(stderr, "\t-v debuglevel (0)\n"); + fprintf(stderr, "\t-q quiet\n"); fprintf(stderr, "\t-V:\tprint version information\n"); fprintf(stderr, "\t-o origin:\n"); fprintf(stderr, "\t\tzone origin (name of zonefile)\n"); @@ -246,6 +249,10 @@ main(int argc, char *argv[]) { fatal("verbose level must be numeric"); break; + case 'q': + quiet = true; + break; + case 'x': keyset_kskonly = true; break; diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index e1205d05f8..5ba2cc1266 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -57,7 +57,8 @@ #include "dnssectool.h" -int verbose; +int verbose = 0; +bool quiet = false; uint8_t dtype[8]; static fatalcallback_t *fatalcallback = NULL; diff --git a/bin/dnssec/dnssectool.h b/bin/dnssec/dnssectool.h index e4798e8336..cddfb2f902 100644 --- a/bin/dnssec/dnssectool.h +++ b/bin/dnssec/dnssectool.h @@ -25,8 +25,9 @@ #define PATH_MAX 1024 /* WIN32, and others don't define this. */ #endif -/*! verbosity: set by -v option in each program, defined in dnssectool.c */ +/*! verbosity: set by -v and -q option in each program, defined in dnssectool.c */ extern int verbose; +extern bool quiet; /*! program name, statically initialized in each program */ extern const char *program;