Commit 584cf666 authored by Francis Dupont's avatar Francis Dupont
Browse files

[master] Merged trac3513 (-V extended version)

parents 2707d683 0e848781
954. [func] fdupont
Enhance the versioning information printed by the executables and
make it more consistent across all of the executables. "-v" is for
basic Kea version information, "-V" provides more detailed
versioning and versions for external dynamic libraries, finally
"-W" provides the configure report from the configuration step
during the build of Kea.
(Trac #3513, git xxx)
953. [bug] fdupont
Corrected the setting of string characters to values above 127
in HMAC tests.
......
......@@ -1384,7 +1384,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
doc/version.ent
ext/asio/asio/Makefile
ext/asio/Makefile
ext/gtest/Makefile
ext/gtest/Makefile
ext/Makefile
m4macros/Makefile
Makefile
......@@ -1395,6 +1395,7 @@ AC_CONFIG_FILES([compatcheck/Makefile
src/bin/d2/tests/Makefile
src/bin/d2/tests/d2_process_tests.sh
src/bin/d2/tests/test_data_files_config.h
src/bin/cfgrpt/Makefile
src/bin/dhcp4/Makefile
src/bin/dhcp4/spec_config.h.pre
src/bin/dhcp4/tests/Makefile
......@@ -1651,6 +1652,10 @@ Developer:
END
# Create config_report.cc with embedded config.report
chmod +x ${srcdir}/tools/mk_cfgrpt.sh
${srcdir}/tools/mk_cfgrpt.sh ${srcdir}/src/bin/cfgrpt/config_report.cc
cat config.report
cat <<EOF
......
......@@ -91,8 +91,39 @@
additional parameters and exits.
</simpara>
</listitem>
<listitem>
<simpara>
<command>-W</command> - prints out Kea configuration report
and exits.
</simpara>
</listitem>
</itemizedlist>
<para>
The <command>-V</command> command returns the versions of the
external libraries dynamically linked.
</para>
<para>
The <command>-W</command> command describes the environment used
to build Kea. This command displays a copy of the
<filename>config.report</filename> file produced by
<userinput>./configure</userinput> that is embedded in the
executable binary.
</para>
<para>
The <filename>config.report</filename> may also be accessed more
directly. The following command may be used to extract this
information. The binary <userinput>path</userinput> may be found
in the install directory or in the <filename>.libs</filename>
subdirectory in the source treee. For example
<filename>kea/src/bin/d2/.libs/kea-dhcp-ddns</filename>.
<screen>
strings <userinput>path</userinput>/kea-dhcp-ddns | sed -n 's/;;;; //p'
</screen>
</para>
<para>
Upon start up the module will load its configuration and begin listening
for NCRs based on that configuration.
......
......@@ -55,8 +55,40 @@
additional parameters and exits.
</simpara>
</listitem>
<listitem>
<simpara>
<command>-W</command> - prints out Kea configuration report
and exits.
</simpara>
</listitem>
</itemizedlist>
<para>
The <command>-V</command> command returns the versions of the
external libraries dynamically linked.
</para>
<para>
The <command>-W</command> command describes the environment used
to build Kea. This command displays a copy of the
<filename>config.report</filename> file produced by
<userinput>./configure</userinput> that is embedded in the
executable binary.
</para>
<para>
The <filename>config.report</filename> may also be accessed more
directly. The following command may be used to extract this
information. The binary <userinput>path</userinput> may be found
in the install directory or in the <filename>.libs</filename>
subdirectory in the source treee. For example
<filename>kea/src/bin/dhcp4/.libs/kea-dhcp4</filename>.
<screen>
strings <userinput>path</userinput>/kea-dhcp4 | sed -n 's/;;;; //p'
</screen>
</para>
<para>
When running in a console, the server can be shut down by
pressing ctrl-c. It detects the key combination and shuts
......
......@@ -53,8 +53,40 @@
additional parameters and exits.
</simpara>
</listitem>
<listitem>
<simpara>
<command>-W</command> - prints out Kea configuration report
and exits.
</simpara>
</listitem>
</itemizedlist>
<para>
The <command>-V</command> command returns the versions of the
external libraries dynamically linked.
</para>
<para>
The <command>-W</command> command describes the environment used
to build Kea. This command displays a copy of the
<filename>config.report</filename> file produced by
<userinput>./configure</userinput> that is embedded in the
executable binary.
</para>
<para>
The <filename>config.report</filename> may also be accessed more
directly. The following command may be used to extract this
information. The binary <userinput>path</userinput> may be found
in the install directory or in the <filename>.libs</filename>
subdirectory in the source treee. For example
<filename>kea/src/bin/dhcp6/.libs/kea-dhcp6</filename>.
<screen>
strings <userinput>path</userinput>/kea-dhcp6 | sed -n 's/;;;; //p'
</screen>
</para>
<para>
When running in a console, the server can be shut down by
pressing ctrl-c. It detects the key combination and shuts
......
......@@ -334,6 +334,12 @@ Debian and Ubuntu:
dependencies.
</para>
<para>
<userinput>./configure</userinput> when it succeeds displays a report
with the building parameters. This report is saved into
<filename>config.report</filename> and embedded into executable
binaries, e.g., <userinput>kea-dhcp4</userinput>.
</para>
</section>
......
# The following build order must be maintained.
SUBDIRS = dhcp4 dhcp6 d2 perfdhcp admin lfc keactrl
SUBDIRS = cfgrpt dhcp4 dhcp6 d2 perfdhcp admin lfc keactrl
check-recursive: all-recursive
AM_CPPFLAGS = -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
# Get rid of generated message files on a clean
CLEANFILES = *.gcno *.gcda
# config_report.cc was generated by configure
DISTCLEANFILES = config_report.cc
# convenience archive
noinst_LTLIBRARIES = libcfgrpt.la
libcfgrpt_la_SOURCES = config_report.h config_report.cc cfgrpt.cc
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <sstream>
#include <cfgrpt/config_report.h>
namespace isc {
namespace detail {
// The config_report array ends with an empty line ("")
// Each line before this final one starts with four semicolons (;;;;)
// in order to be easy to extract from binaries.
std::string
getConfigReport() {
std::stringstream tmp;
size_t linenum = 0;
for (;;) {
const char* const line = config_report[linenum++];
if (line[0] == '\0')
break;
tmp << line + 4 << std::endl;
}
return (tmp.str());
}
}
}
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef CONFIG_REPORT_H
#define CONFIG_REPORT_H
namespace isc {
namespace detail {
extern const char* const config_report[];
// The config_report array ends with an empty line ("")
// Each line before this final one starts with four semicolons (;;;;)
// in order to be easy to extract from binaries.
std::string getConfigReport();
}
}
#endif // CONFIG_REPORT_H
......@@ -91,6 +91,8 @@ kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
kea_dhcp_ddns_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
kea_dhcp_ddns_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la
kea_dhcp_ddnsdir = $(pkgdatadir)
kea_dhcp_ddns_DATA = dhcp-ddns.spec
......@@ -19,6 +19,9 @@
#include <exceptions/exceptions.h>
#include <log/logger_support.h>
#include <dhcpsrv/cfgmgr.h>
#include <cryptolink/cryptolink.h>
#include <log/logger.h>
#include <cfgrpt/config_report.h>
#include <sstream>
#include <unistd.h>
......@@ -130,7 +133,7 @@ DControllerBase::parseArgs(int argc, char* argv[])
int ch;
opterr = 0;
optind = 1;
std::string opts("dvVc:" + getCustomOpts());
std::string opts("dvVWc:" + getCustomOpts());
while ((ch = getopt(argc, argv, opts.c_str())) != -1) {
switch (ch) {
case 'd':
......@@ -150,6 +153,12 @@ DControllerBase::parseArgs(int argc, char* argv[])
isc_throw(VersionMessage, getVersion(true));
break;
case 'W':
// gather Kea config report and throw so main() can catch and
// return rather than calling exit() here which disrupts gtest.
isc_throw(VersionMessage, isc::detail::getConfigReport());
break;
case 'c':
// config file name
if (optarg == NULL) {
......@@ -426,12 +435,14 @@ DControllerBase::usage(const std::string & text)
}
std::cerr << "Usage: " << bin_name_ << std::endl
<< " -c <config file name> : mandatory,"
<< " specifies name of configuration file " << std::endl
<< " -d: optional, verbose output " << std::endl
<< " -v: print version number and exit" << std::endl
<< " -V: print extended version information and exit"
<< std::endl;
<< std::endl
<< " -W: display the configuration report and exit"
<< std::endl
<< " -d: optional, verbose output " << std::endl
<< " -c <config file name> : mandatory,"
<< " specifies name of configuration file " << std::endl;
// add any derivation specific usage
std::cerr << getUsageText() << std::endl;
......@@ -440,6 +451,9 @@ DControllerBase::usage(const std::string & text)
DControllerBase::~DControllerBase() {
}
// Refer to config_report so it will be embedded in the binary
const char* const* d2_config_report = isc::detail::config_report;
}; // namespace isc::d2
}; // namespace isc
......@@ -450,11 +464,20 @@ isc::dhcp::Daemon::getVersion(bool extended) {
tmp << VERSION;
if (extended) {
tmp << std::endl << EXTENDED_VERSION;
// @todo print more details (is it Botan or OpenSSL build,
// with or without MySQL/Postgres? What compilation options were
// used? etc)
tmp << std::endl << EXTENDED_VERSION << std::endl;
tmp << "linked with:" << std::endl;
tmp << isc::log::Logger::getVersion() << std::endl;
tmp << isc::cryptolink::CryptoLink::getVersion() << std::endl;
#ifdef HAVE_MYSQL
tmp << "database: MySQL";
#else
#ifdef HAVE_PGSQL
tmp << "database: PostgreSQL";
#else
tmp << "no database";
#endif
#endif
// @todo: more details about database runtime
}
return (tmp.str());
......
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[<!ENTITY mdash "&#8212;">]>
[<!ENTITY mdash "&#8212;">]>
<!--
- Copyright (C) 2013, 2014 Internet Systems Consortium, Inc. ("ISC")
- Copyright (C) 2013, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
......@@ -20,7 +20,7 @@
<refentry>
<refentryinfo>
<date>July 1, 2014</date>
<date>June 10, 2015</date>
</refentryinfo>
<refmeta>
......@@ -36,7 +36,7 @@
<docinfo>
<copyright>
<year>2014</year>
<year>2014-2015</year>
<holder>Internet Systems Consortium, Inc. ("ISC")</holder>
</copyright>
</docinfo>
......@@ -45,12 +45,9 @@
<cmdsynopsis>
<command>kea-dhcp-ddns</command>
<arg><option>-v</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsynopsisdiv>
<cmdsynopsis>
<command>kea-dhcp-ddns</command>
<arg><option>-V</option></arg>
<arg><option>-W</option></arg>
<arg><option>-d</option></arg>
<arg><option>-s</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
......@@ -78,6 +75,27 @@
<varlistentry>
<term><option>-v</option></term>
<listitem><para>
Display the version.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-V</option></term>
<listitem><para>
Display the extended version.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-W</option></term>
<listitem><para>
Display the configuration report.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-d</option></term>
<listitem><para>
Verbose mode sets the logging level to debug. This is primarily
for development purposes in stand-alone mode.
......
......@@ -86,6 +86,7 @@ d2_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/testutils/libdhcpsrvtest.l
d2_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
d2_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
d2_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
d2_unittests_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la
endif
......
......@@ -77,6 +77,8 @@ kea_dhcp4_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la
kea_dhcp4_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
kea_dhcp4_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
kea_dhcp4_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la
kea_dhcp4_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
kea_dhcp4_LDADD += $(top_builddir)/src/bin/cfgrpt/libcfgrpt.la
kea_dhcp4dir = $(pkgdatadir)
kea_dhcp4_DATA = dhcp4.spec
......@@ -42,6 +42,9 @@
#include <hooks/hooks_manager.h>
#include <util/strutil.h>
#include <stats/stats_mgr.h>
#include <log/logger.h>
#include <cryptolink/cryptolink.h>
#include <cfgrpt/config_report.h>
#include <asio.hpp>
#include <boost/bind.hpp>
......@@ -52,6 +55,7 @@
using namespace isc;
using namespace isc::asiolink;
using namespace isc::cryptolink;
using namespace isc::dhcp;
using namespace isc::dhcp_ddns;
using namespace isc::hooks;
......@@ -2247,17 +2251,29 @@ Dhcpv4Srv::d2ClientErrorHandler(const
CfgMgr::instance().getD2ClientMgr().suspendUpdates();
}
// Refer to config_report so it will be embedded in the binary
const char* const* dhcp4_config_report = isc::detail::config_report;
std::string
Daemon::getVersion(bool extended) {
std::stringstream tmp;
tmp << VERSION;
if (extended) {
tmp << endl << EXTENDED_VERSION;
// @todo print more details (is it Botan or OpenSSL build,
// with or without MySQL/Postgres? What compilation options were
// used? etc)
tmp << endl << EXTENDED_VERSION << endl;
tmp << "linked with:" << endl;
tmp << Logger::getVersion() << endl;
tmp << CryptoLink::getVersion() << endl;
#ifdef HAVE_MYSQL
tmp << "database: MySQL";
#else
#ifdef HAVE_PGSQL
tmp << "database: PostgreSQL";
#else
tmp << "no database";
#endif
#endif
// @todo: more details about database runtime
}
return (tmp.str());
......
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[<!ENTITY mdash "&#8212;">]>
[<!ENTITY mdash "&#8212;">]>
<!--
- Copyright (C) 2011, 2014 Internet Systems Consortium, Inc. ("ISC")
- Copyright (C) 2011, 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
......@@ -20,7 +20,7 @@
<refentry>
<refentryinfo>
<date>July 1, 2014</date>
<date>June 10, 2015</date>
</refentryinfo>
<refmeta>
......@@ -36,7 +36,7 @@
<docinfo>
<copyright>
<year>2014</year>
<year>2014-2015</year>
<holder>Internet Systems Consortium, Inc. ("ISC")</holder>
</copyright>
</docinfo>
......@@ -45,6 +45,9 @@
<cmdsynopsis>
<command>kea-dhcp4</command>
<arg><option>-v</option></arg>
<arg><option>-V</option></arg>
<arg><option>-W</option></arg>
<arg><option>-d</option></arg>
<arg><option>-c<replaceable class="parameter">config-file</replaceable></option></arg>
<arg><option>-p<replaceable class="parameter">port-number</replaceable></option></arg>
</cmdsynopsis>
......@@ -69,7 +72,28 @@
<varlistentry>
<term><option>-v</option></term>
<listitem><para>
Enable verbose mode.
Display the version.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-V</option></term>
<listitem><para>
Display the extended version.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-W</option></term>
<listitem><para>
Display the configuration report.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-d</option></term>
<listitem><para>
Enable the debug mode with extra verbosity.
</para></listitem>
</varlistentry>
......
......@@ -19,6 +19,7 @@
#include <dhcpsrv/cfgmgr.h>
#include <log/logger_support.h>
#include <log/logger_manager.h>
#include <cfgrpt/config_report.h>
#include <boost/lexical_cast.hpp>
......@@ -48,13 +49,14 @@ usage() {
cerr << "Kea DHCPv4 server, version " << VERSION << endl;
cerr << endl;
cerr << "Usage: " << DHCP4_NAME
<< " [-v] [-V] [-d] [-p number] [-c file]" << endl;
cerr << " -c file: specify configuration file" << endl;
<< " -[v|V|W] [-d] [-c cfgfile] [-p number]" << endl;
cerr << " -v: print version number and exit" << endl;
cerr << " -V: print extended version and exit" << endl;
cerr << " -W: display the configuration report and exit" << endl;
cerr << " -d: debug mode with extra verbosity (former -v)" << endl;
cerr << " -c file: specify configuration file" << endl;
cerr << " -p number: specify non-standard port number 1-65535 "
<< "(useful for testing only)" << endl;
cerr << " -v: print version number and exit" << endl;
cerr << " -V: print extended version and exit" << endl;
exit(EXIT_FAILURE);
}
} // end of anonymous namespace
......@@ -69,7 +71,7 @@ main(int argc, char* argv[]) {
// The standard config file
std::string config_file("");
while ((ch = getopt(argc, argv, "dvVp:c:")) != -1) {
while ((ch = getopt(argc, argv, "dvVWc:p:")) != -1) {
switch (ch) {
case 'd':
verbose_mode = true;
......@@ -83,6 +85,14 @@ main(int argc, char* argv[]) {
cout << Daemon::getVersion(true) << endl;
return (EXIT_SUCCESS);
case 'W':
cout << isc::detail::getConfigReport() << endl;
return (EXIT_SUCCESS);
case 'c': // config file
config_file = optarg;
break;
case 'p':
try {
port_number = boost::lexical_cast<int>(optarg);
......@@ -98,10 +108,6 @@ main(int argc, char* argv[]) {
}
break;
case 'c': // config file
config_file = optarg;
break;
default:
usage();