From: Marcin Siodelski Date: Thu, 24 Jul 2014 15:26:00 +0000 (+0200) Subject: [3459] The server now checks if the configuration file was specified. X-Git-Tag: trac3482_base~69^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=07228dd9bfc663d6dbfcb0cb5f1e144954fcc62d;p=thirdparty%2Fkea.git [3459] The server now checks if the configuration file was specified. When the configuration file hasn't been specified the server will print an error message to the stderr and usage. Also I removed the spurious parens from one of the error messages. --- diff --git a/src/bin/dhcp4/kea_controller.cc b/src/bin/dhcp4/kea_controller.cc index 017bad5f72..4ef51a6976 100644 --- a/src/bin/dhcp4/kea_controller.cc +++ b/src/bin/dhcp4/kea_controller.cc @@ -100,7 +100,7 @@ void configure(const std::string& file_name) { if (rcode != 0) { string reason = ""; if (comment) { - reason = string(" (") + comment->stringValue() + string(")"); + reason = comment->stringValue(); } LOG_ERROR(dhcp4_logger, DHCP4_CONFIG_LOAD_FAIL).arg(reason); isc_throw(isc::BadValue, "Failed to apply configuration: " << reason); diff --git a/src/bin/dhcp4/main.cc b/src/bin/dhcp4/main.cc index fe259f5f06..592bf342e0 100644 --- a/src/bin/dhcp4/main.cc +++ b/src/bin/dhcp4/main.cc @@ -97,6 +97,12 @@ main(int argc, char* argv[]) { usage(); } + // Configuration file is required. + if (config_file.empty()) { + cerr << "Configuration file not specified." << endl; + usage(); + } + int ret = EXIT_SUCCESS; try { diff --git a/src/bin/dhcp6/kea_controller.cc b/src/bin/dhcp6/kea_controller.cc index c70cf3bf60..0fafe21cfe 100644 --- a/src/bin/dhcp6/kea_controller.cc +++ b/src/bin/dhcp6/kea_controller.cc @@ -103,7 +103,7 @@ void configure(const std::string& file_name) { if (rcode != 0) { string reason = ""; if (comment) { - reason = string(" (") + comment->stringValue() + string(")"); + reason = comment->stringValue(); } LOG_ERROR(dhcp6_logger, DHCP6_CONFIG_LOAD_FAIL).arg(reason); isc_throw(isc::BadValue, "Failed to apply configuration:" << reason); diff --git a/src/bin/dhcp6/main.cc b/src/bin/dhcp6/main.cc index 6de1205d6a..f491ee04be 100644 --- a/src/bin/dhcp6/main.cc +++ b/src/bin/dhcp6/main.cc @@ -97,6 +97,12 @@ main(int argc, char* argv[]) { usage(); } + // Configuration file is required. + if (config_file.empty()) { + cerr << "Configuration file not specified." << endl; + usage(); + } + int ret = EXIT_SUCCESS; try {