Commit 1fc2b06b authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

Merge branch 'master' into trac2053

parents 9771dfb0 d5ec81ad
452. [func]* muks
b10-showtech: An initial implementation of the b10-showtech tool
is now available. It gathers and outputs system information which
can be used by future tech support staff.
(Trac #2062, git 144e80212746f8d55e6a59edcf689fec9f32ae95)
451. [bug] muks, jinmei
libdatasrc: the database-based data source now correctly returns
glue records on (not under) a zone cut, such as in the case where
......
......@@ -1027,6 +1027,7 @@ AC_CONFIG_FILES([Makefile
src/bin/dhcp4/tests/Makefile
src/bin/resolver/Makefile
src/bin/resolver/tests/Makefile
src/bin/showtech/Makefile
src/bin/sockcreator/Makefile
src/bin/sockcreator/tests/Makefile
src/bin/xfrin/Makefile
......@@ -1082,6 +1083,8 @@ AC_CONFIG_FILES([Makefile
src/lib/python/isc/xfrin/tests/Makefile
src/lib/python/isc/server_common/Makefile
src/lib/python/isc/server_common/tests/Makefile
src/lib/python/isc/sysinfo/Makefile
src/lib/python/isc/sysinfo/tests/Makefile
src/lib/config/Makefile
src/lib/config/tests/Makefile
src/lib/config/tests/testdata/Makefile
......@@ -1159,6 +1162,7 @@ AC_OUTPUT([doc/version.ent
src/bin/zonemgr/zonemgr.spec.pre
src/bin/zonemgr/tests/zonemgr_test
src/bin/zonemgr/run_b10-zonemgr.sh
src/bin/showtech/showtech.py
src/bin/stats/stats.py
src/bin/stats/stats_httpd.py
src/bin/bind10/bind10_src.py
......
......@@ -92,7 +92,7 @@
<title>Supported Platforms</title>
<para>
BIND 10 builds have been tested on (in no particular order)
Debian GNU/Linux 5 and unstable, Ubuntu 9.10, NetBSD 5,
Debian GNU/Linux 6 and unstable, Ubuntu 9.10, NetBSD 5,
Solaris 10 and 11, FreeBSD 7 and 8, CentOS Linux 5.3,
MacOS 10.6 and 10.7, and OpenBSD 5.1.
......@@ -105,7 +105,17 @@
</section>
<section id="required-software">
<title>Required Software</title>
<title>Required Software at Run-time</title>
<para>
Running BIND 10 uses various extra software which may
not be provided in some operating systems' default
installations nor standard packages collections. You may
need to install this required software separately.
(For the build requirements, also see
<xref linkend="build-requirements"/>.)
</para>
<para>
BIND 10 requires at least Python 3.1
(<ulink url="http://www.python.org/"/>).
......@@ -140,15 +150,6 @@
Python modules need to be built for the corresponding Python 3.
</para>
<!-- TODO: this will change ... -->
<note>
<para>
Some operating systems do not provide these dependencies
in their default installation nor standard packages
collections.
You may need to install them separately.
</para>
</note>
</section>
<section id="starting_stopping">
......@@ -1058,9 +1059,6 @@ address, but the usual ones don't." mean? -->
specifications and all current settings to the
<command>bindctl</command> client (via
<command>b10-cmdctl</command>).
</para>
<para>
<command>b10-cfgmgr</command> relays configurations received
from <command>b10-cmdctl</command> to the appropriate modules.
</para>
......@@ -1079,7 +1077,7 @@ config changes are actually commands to cfgmgr
<para>
The stored configuration file is at
<filename>/usr/local/var/bind10-devel/b10-config.db</filename>.
(The full path is what was defined at build configure time for
(The directory is what was defined at build configure time for
<option>--localstatedir</option>.
The default is <filename>/usr/local/var/</filename>.)
The format is loosely based on JSON and is directly parseable
......@@ -1197,7 +1195,7 @@ but you might wanna check with likun
<!-- TODO
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
but that is a single file, maybethis should go back to that format?
but that is a single file, maybe this should go back to that format?
-->
<!--
......@@ -1264,7 +1262,6 @@ shutdown
<!--
TODO
(12:21:30) jinmei: I'd like to have sample session using a command line www client such as wget
(12:21:33) jinmei: btw
-->
</chapter>
......
SUBDIRS = bind10 bindctl cfgmgr ddns loadzone msgq host cmdctl auth xfrin \
xfrout usermgr zonemgr stats tests resolver sockcreator dhcp4 dhcp6 dbutil
xfrout usermgr zonemgr stats tests resolver sockcreator dhcp4 dhcp6 \
dbutil showtech
check-recursive: all-recursive
......@@ -541,7 +541,7 @@ class SecureHTTPServer(socketserver_mixin.NoPollMixIn,
ssl_version = ssl.PROTOCOL_SSLv23)
return ssl_sock
except (ssl.SSLError, CmdctlException) as err :
logger.info(CMDCTL_SSL_SETUP_FAILURE_USER_DENIED, err)
logger.error(CMDCTL_SSL_SETUP_FAILURE_USER_DENIED, err)
self.close_request(sock)
# raise socket error to finish the request
raise socket.error
......
/b10-showtech
/showtech.py
bin_SCRIPTS = b10-showtech
CLEANFILES = b10-showtech showtech.pyc
# this is done here since configure.ac AC_OUTPUT doesn't expand exec_prefix
b10-showtech: showtech.py
$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" showtech.py >$@
chmod a+x $@
MAN1_FILES = \
b10-showtech.xml
man_MANS = \
$(MAN1_FILES:.xml=.1)
if ENABLE_MAN
.xml.1:
xsltproc --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
endif
EXTRA_DIST = $(man_MANS) $(MAN1_FILES)
CLEANDIRS = __pycache__
clean-local:
rm -rf $(CLEANDIRS)
'\" t
.\" Title: b10-showtech
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
.\" Date: June 26, 2012
.\" Manual: BIND10
.\" Source: BIND10
.\" Language: English
.\"
.TH "B10\-SHOWTECH" "1" "June 26, 2012" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
b10-showtech \- BIND 10 system information display tool
.SH "SYNOPSIS"
.HP \w'\fBb10\-showtech\fR\ 'u
\fBb10\-showtech\fR
.SH "DESCRIPTION"
.PP
The
\fBb10\-showtech\fR
program collects and outputs a variety of information about the system that BIND 10 is running on\&. This information can be useful to people involved in debugging and technical support\&.
.SH "ARGUMENTS"
.PP
\-h
.RS 4
Displays usage instructions\&.
.RE
.PP
\-o \fIoutput\-file\fR
.RS 4
If an output file is specified, the output of
\fBb10\-showtech\fR
is written to this file\&. By default, the output is written to standard output\&.
.RE
.SH "SEE ALSO"
.PP
\fBbind10\fR(8),
BIND 10 Guide\&.
.SH "HISTORY"
.PP
The
\fBb10\-showtech\fR
daemon was initially implemented by ISC staff in June, 2012\&.
.SH "COPYRIGHT"
.br
Copyright \(co 2012 Internet Systems Consortium, Inc. ("ISC")
.br
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[<!ENTITY mdash "&#8212;">]>
<!--
- Copyright (C) 2012 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.
-->
<refentry>
<refentryinfo>
<date>June 26, 2012</date>
</refentryinfo>
<refmeta>
<refentrytitle>b10-showtech</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo>BIND10</refmiscinfo>
</refmeta>
<refnamediv>
<refname>b10-showtech</refname>
<refpurpose>BIND 10 system information display tool</refpurpose>
</refnamediv>
<docinfo>
<copyright>
<year>2012</year>
<holder>Internet Systems Consortium, Inc. ("ISC")</holder>
</copyright>
</docinfo>
<refsynopsisdiv>
<cmdsynopsis>
<command>b10-showtech</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>
The <command>b10-showtech</command> program collects and outputs a
variety of information about the system that BIND 10 is running
on. This information can be useful to people involved in debugging
and technical support.
</para>
</refsect1>
<refsect1>
<title>ARGUMENTS</title>
<variablelist>
<varlistentry>
<term>-h</term>
<listitem><para>
Displays usage instructions.
</para></listitem>
</varlistentry>
<varlistentry>
<term>-o <replaceable class="parameter">output-file</replaceable></term>
<listitem><para>
If an output file is specified, the output
of <command>b10-showtech</command> is written to this file. By
default, the output is written to standard output.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>
<citerefentry>
<refentrytitle>bind10</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citetitle>BIND 10 Guide</citetitle>.
</para>
</refsect1>
<refsect1>
<title>HISTORY</title>
<para>
The <command>b10-showtech</command> daemon was initially
implemented by ISC staff in June, 2012.
</para>
</refsect1>
</refentry><!--
- Local variables:
- mode: sgml
- End:
-->
#!@PYTHON@
# Copyright (C) 2012 Internet Systems Consortium.
#
# Permission to use, copy, modify, and 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 INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM 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.
"""
BIND 10 showtech program.
"""
import sys; sys.path.append ('@@PYTHONPATH@@')
import getopt
import isc.util.process
from isc.sysinfo import *
isc.util.process.rename()
def usage():
print("Usage: %s [-h] [-o <output-file>]" % sys.argv[0], \
file=sys.stderr)
exit(1)
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "o:h", \
["output", "help"])
except getopt.GetoptError as e:
print(str(e))
usage()
exit(1)
output_filename = None
for option, arg in opts:
if option in ("-o", "--output"):
output_filename = arg
elif option in ("-h", "--help"):
usage()
else:
assert False, "unhandled option"
if output_filename is None:
f = sys.stdout
else:
f = open(output_filename, 'w')
s = SysInfoFromFactory()
f.write('BIND 10 ShowTech tool\n')
f.write('=====================\n')
f.write('\nCPU\n');
f.write(' + Number of processors: %d\n' % (s.get_num_processors()))
f.write(' + Endianness: %s\n' % (s.get_endianness()))
f.write('\nPlatform\n');
f.write(' + Operating system: %s\n' % (s.get_platform_name()))
f.write(' + Distribution: %s\n' % (s.get_platform_distro()))
f.write(' + Kernel version: %s\n' % (s.get_platform_version()))
f.write(' + SMP kernel: ')
if s.get_platform_is_smp():
f.write('yes')
else:
f.write('no')
f.write('\n')
f.write(' + Machine name: %s\n' % (s.get_platform_machine()))
f.write(' + Hostname: %s\n' % (s.get_platform_hostname()))
f.write(' + Uptime: %d seconds\n' % (s.get_uptime()))
l = s.get_loadavg()
f.write(' + Loadavg: %f %f %f\n' % (l[0], l[1], l[2]))
f.write('\nMemory\n');
f.write(' + Total: %d bytes\n' % (s.get_mem_total()))
f.write(' + Free: %d bytes\n' % (s.get_mem_free()))
f.write(' + Cached: %d bytes\n' % (s.get_mem_cached()))
f.write(' + Buffers: %d bytes\n' % (s.get_mem_buffers()))
f.write(' + Swap total: %d bytes\n' % (s.get_mem_swap_total()))
f.write(' + Swap free: %d bytes\n' % (s.get_mem_swap_free()))
f.write('\n\nNetwork\n');
f.write('-------\n\n');
f.write('Interfaces\n')
f.write('~~~~~~~~~~\n\n')
f.write(s.get_net_interfaces())
f.write('\nRouting table\n')
f.write('~~~~~~~~~~~~~\n\n')
f.write(s.get_net_routing_table())
f.write('\nStatistics\n')
f.write('~~~~~~~~~~\n\n')
f.write(s.get_net_stats())
f.write('\nConnections\n')
f.write('~~~~~~~~~~~\n\n')
f.write(s.get_net_connections())
try:
if os.getuid() != 0:
sys.stderr.write('\n')
sys.stderr.write('NOTE: You have to run this program as the root user so that it can\n')
sys.stderr.write(' collect all the information it requires. Some information is\n')
sys.stderr.write(' only available to the root user.\n\n')
except Exception:
pass
if f != sys.stdout:
f.close()
if __name__ == '__main__':
main()
......@@ -33,7 +33,6 @@ using namespace isc::data;
using namespace isc::config;
using namespace isc::cc;
using namespace std;
using namespace boost;
namespace {
std::string
......@@ -52,6 +51,7 @@ protected:
root_name(isc::log::getRootLoggerName())
{
// upon creation of a ModuleCCSession, the class
// sends its specification to the config manager.
// it expects an ok answer back, so everytime we
// create a ModuleCCSession, we must set an initial
......@@ -740,8 +740,9 @@ protected:
registerCommand(const string& recipient)
{
return (mccs_.groupRecvMsgAsync(
bind(&AsyncReceiveCCSessionTest::callback, this, next_flag_ ++, _1,
_2, _3), false, -1, recipient));
boost::bind(&AsyncReceiveCCSessionTest::callback, this,
next_flag_++, _1, _2, _3), false, -1,
recipient));
}
/// \brief Convenience function to queue a request to get a reply
/// message.
......@@ -749,8 +750,8 @@ protected:
registerReply(int seq)
{
return (mccs_.groupRecvMsgAsync(
bind(&AsyncReceiveCCSessionTest::callback, this, next_flag_ ++, _1,
_2, _3), true, seq));
boost::bind(&AsyncReceiveCCSessionTest::callback, this,
next_flag_++, _1, _2, _3), true, seq));
}
/// \brief Check the next called callback was with this flag
void called(int flag) {
......
......@@ -1260,6 +1260,9 @@ RBTree<T>::previousNode(RBTreeNodeChain<T>& node_path) const {
// already, which located the exact node. The rest of the function
// goes one domain left and returns it for us.
break;
default:
// This must not happen as Name::compare() never returns NONE.
isc_throw(isc::Unexpected, "Name::compare() returned unexpected result");
}
// So, the node_path now contains the path to a node we want previous for.
......
......@@ -71,6 +71,21 @@ LabelSequence::equals(const LabelSequence& other, bool case_sensitive) const {
return (true);
}
NameComparisonResult
LabelSequence::compare(const LabelSequence& other,
bool case_sensitive) const {
if (isAbsolute() ^ other.isAbsolute()) {
return (NameComparisonResult(0, 0, NameComparisonResult::NONE));
}
return (name_.compare(other.name_,
first_label_,
other.first_label_,
last_label_,
other.last_label_,
case_sensitive));
}
void
LabelSequence::stripLeft(size_t i) {
if (i >= getLabelCount()) {
......
......@@ -88,10 +88,10 @@ public:
/// \return The length of the data of the label sequence in octets.
size_t getDataLength() const;
/// \brief Compares two label sequences.
/// \brief Compares two label sequences for equality.
///
/// Performs a (optionally case-insensitive) comparison between this
/// LabelSequence and another LabelSequence.
/// LabelSequence and another LabelSequence for equality.
///
/// \param other The LabelSequence to compare with
/// \param case_sensitive If true, comparison is case-insensitive
......@@ -99,6 +99,18 @@ public:
/// and contain the same data.
bool equals(const LabelSequence& other, bool case_sensitive = false) const;
/// \brief Compares two label sequences.
///
/// Performs a (optionally case-insensitive) comparison between this
/// LabelSequence and another LabelSequence.
///
/// \param other The LabelSequence to compare with
/// \param case_sensitive If true, comparison is case-insensitive
/// \return a <code>NameComparisonResult</code> object representing the
/// comparison result.
NameComparisonResult compare(const LabelSequence& other,
bool case_sensitive = false) const;
/// \brief Remove labels from the front of this LabelSequence
///
/// \note No actual memory is changed, this operation merely updates the
......
......@@ -435,13 +435,33 @@ Name::toText(bool omit_final_dot) const {
NameComparisonResult
Name::compare(const Name& other) const {
return (compare(other, 0, 0, labelcount_, other.labelcount_));
}
NameComparisonResult
Name::compare(const Name& other,
unsigned int first_label,
unsigned int first_label_other,
unsigned int last_label,
unsigned int last_label_other,
bool case_sensitive) const {
// Determine the relative ordering under the DNSSEC order relation of
// 'this' and 'other', and also determine the hierarchical relationship
// of the names.
if ((first_label > last_label) ||
(first_label_other > last_label_other)) {
isc_throw(BadValue, "Bad label index ranges were passed");
}
if ((first_label > labelcount_) ||
(first_label_other > other.labelcount_)) {
isc_throw(BadValue, "Bad first label indices were passed");
}
unsigned int nlabels = 0;
unsigned int l1 = labelcount_;
unsigned int l2 = other.labelcount_;
int l1 = last_label - first_label;
int l2 = last_label_other - first_label_other;
int ldiff = (int)l1 - (int)l2;
unsigned int l = (ldiff < 0) ? l1 : l2;
......@@ -449,8 +469,8 @@ Name::compare(const Name& other) const {
--l;
--l1;
--l2;
size_t pos1 = offsets_[l1];
size_t pos2 = other.offsets_[l2];
size_t pos1 = offsets_[l1 + first_label];
size_t pos2 = other.offsets_[l2 + first_label_other];
unsigned int count1 = ndata_[pos1++];
unsigned int count2 = other.ndata_[pos2++];
......@@ -464,19 +484,39 @@ Name::compare(const Name& other) const {
while (count > 0) {
uint8_t label1 = ndata_[pos1];
uint8_t label2 = other.ndata_[pos2];
int chdiff;
if (case_sensitive) {
chdiff = (int)label1 - (int)label2;
} else {
chdiff = (int)maptolower[label1] - (int)maptolower[label2];
}
int chdiff = (int)maptolower[label1] - (int)maptolower[label2];
if (chdiff != 0) {
return (NameComparisonResult(chdiff, nlabels,
NameComparisonResult::COMMONANCESTOR));
if ((nlabels == 0) &&
((last_label < labelcount_) ||
(last_label_other < other.labelcount_))) {
return (NameComparisonResult(