Evan Hunt via RT wrote: > > Incidentally, for a point-zero release in the future, I wonder if we should > make the -r the default for nsec3hash and add a different option for > backward compatibility. The existing argument ordering makes no sense > at all. I wondered if it might be simpler to key the off the number of arguments (five vs four) rather than requiring a -r flag.... diff --git a/bin/tests/system/tools/tests.sh b/bin/tests/system/tools/tests.sh index 7e8fe14..82b778d 100644 --- a/bin/tests/system/tools/tests.sh +++ b/bin/tests/system/tools/tests.sh @@ -78,6 +78,9 @@ checkempty echo "I:checking $NSEC3HASH -r - $name" out=`$NSEC3HASH -r $algo $flags $iters - $name` checkempty +echo "I:checking $NSEC3HASH optional -r" +out=`$NSEC3HASH $algo $flags $iters - $name` +checkempty checkfail() { case $? in diff --git a/bin/tools/nsec3hash.c b/bin/tools/nsec3hash.c index 4fc4339..90ffd6d 100644 --- a/bin/tools/nsec3hash.c +++ b/bin/tools/nsec3hash.c @@ -55,7 +55,7 @@ static void usage() { fprintf(stderr, "Usage: %s salt algorithm iterations domain\n", program); - fprintf(stderr, " %s -r algorithm flags iterations salt domain\n", + fprintf(stderr, " %s algorithm flags iterations salt domain\n", program); exit(1); } @@ -152,6 +152,7 @@ main(int argc, char *argv[]) { isc_boolean_t rdata_format = ISC_FALSE; int ch; + /* -r retained for backwards compatibility */ while ((ch = isc_commandline_parse(argc, argv, "-r")) != -1) { switch (ch) { case 'r': @@ -161,6 +162,7 @@ main(int argc, char *argv[]) { isc_commandline_index -= 1; goto skip; default: + usage(); break; } } @@ -169,18 +171,14 @@ main(int argc, char *argv[]) { argc -= isc_commandline_index; argv += isc_commandline_index; - if (rdata_format) { - if (argc != 5) { - usage(); - } + if (argc == 5) { nsec3hash(nsec3hash_rdata_print, argv[0], argv[1], argv[2], argv[3], argv[4]); - } else { - if (argc != 4) { - usage(); - } + } else if (argc == 4 && !rdata_format) { nsec3hash(nsec3hash_print, argv[1], NULL, argv[2], argv[0], argv[3]); + } else { + usage(); } return(0); } diff --git a/bin/tools/nsec3hash.docbook b/bin/tools/nsec3hash.docbook index d28a13c..ce47feb 100644 --- a/bin/tools/nsec3hash.docbook +++ b/bin/tools/nsec3hash.docbook @@ -47,7 +47,7 @@ domain - nsec3hash -r + nsec3hash algorithm flags iterations @@ -65,7 +65,7 @@ - If this command is invoked as nsec3hash -r, + If this command is invoked with five arguments, it takes arguments in an order matching the first four fields of an NSEC3 record, followed by the domain name: algorithm, flags, iterations, salt, domain. This makes it convenient to copy and