From 12b074bff5b6834ad5ccd32d533f48ece807eb10 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Thu, 3 Apr 2014 19:39:44 -0700 Subject: [PATCH] [v9_9] improve command line error reporting 3799. [bug] Improve named's command line error reporting. [RT #35603] (cherry picked from commit 44fbdddcadd85a6e40ebc7b7834e08e156c681a1) --- CHANGES | 3 +++ bin/named/main.c | 18 +++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index b6b24b6c80..5be65e278d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3799. [bug] Improve named's command line error reporting. + [RT #35603] + 3796. [bug] Register dns error codes. [RT #35629] 3795. [bug] Make named-checkconf detect raw masterfiles for diff --git a/bin/named/main.c b/bin/named/main.c index 14ed5cf578..599c142fd4 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id$ */ - /*! \file */ #include @@ -410,16 +408,16 @@ static void parse_command_line(int argc, char *argv[]) { int ch; int port; + const char *p; isc_boolean_t disable6 = ISC_FALSE; isc_boolean_t disable4 = ISC_FALSE; save_command_line(argc, argv); /* PLEASE keep options synchronized when main is hooked! */ +#define CMDLINE_FLAGS "46c:C:d:E:fFgi:lm:n:N:p:P:sS:t:T:U:u:vVx:" isc_commandline_errprint = ISC_FALSE; - while ((ch = isc_commandline_parse(argc, argv, - "46c:C:d:E:fFgi:lm:n:N:p:P:" - "sS:t:T:U:u:vVx:")) != -1) { + while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) { switch (ch) { case '4': if (disable4) @@ -585,8 +583,14 @@ parse_command_line(int argc, char *argv[]) { usage(); if (isc_commandline_option == '?') exit(0); - ns_main_earlyfatal("unknown option '-%c'", - isc_commandline_option); + p = strchr(CMDLINE_FLAGS, isc_commandline_option); + if (p == NULL || *++p != ':') + ns_main_earlyfatal("unknown option '-%c'", + isc_commandline_option); + else + ns_main_earlyfatal("option '-%c' requires " + "an argument", + isc_commandline_option); /* FALLTHROUGH */ default: ns_main_earlyfatal("parsing options returned %d", ch);