BIND 10 trac1071, updated. 88c4d5e241d0dd670eca6f9a4981439a08924704 [trac1071] ChangeLog entry for #1071
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jul 5 09:57:22 UTC 2011
The branch, trac1071 has been updated
via 88c4d5e241d0dd670eca6f9a4981439a08924704 (commit)
via 05164f9d61006869233b498d248486b4307ea8b6 (commit)
via bfcd0225fe669dde479dde1146612f7c067a817f (commit)
via 2c936393a16d79fa3d4bbbdacc66884f7d8d3cb9 (commit)
via 3383b56081364d68de8c29fb34698a7651c50e05 (commit)
via b60e7347e2b97d913b386b82b682c8c7ae2e3d4e (commit)
via cdadcd5d6a6bd594fdbcb9efe628067879623df6 (commit)
via 4d81613695a03b3d39adb5b54822dc1a07a37af0 (commit)
via af1dbc5024d5b3289841868ee49929ba4f4d3f50 (commit)
via 03d707719016e3d3a6d98b3fb9eb786c90df69ec (commit)
via ec45081d781ae19de834b11e000acc35415a8f30 (commit)
via 1eb10de8b47aaab24b48cb0e109cf2a3bbc22860 (commit)
via d191035ad012bc481ce0a4545f9b6819b897a04e (commit)
via dadf18e8c050ad6a5977fa32d563f31de99d3ac7 (commit)
via 3caca9f8debed45019acb731b5ef2f55a3479ee4 (commit)
via 3bbdd1e7d3f89b3a281900c75ceb0830d0cfd7d3 (commit)
via f5ae2264a57664aa6ab307865db72f1f740b80c7 (commit)
via 0a836aa297d08b3c375d245f50971cf4cf2760e7 (commit)
via f7af58ec51254d0586ee20ebfae4bd0f8977ed48 (commit)
via 22f3ad26d4bb70a03858d42122b7a648211911c7 (commit)
via 534acaf92fd8ba43488be7057d7a35623dcab0a9 (commit)
via ebe5d465d2995899aa3f95c944e0d32d09ec2034 (commit)
via 3f599b883384e9f180f12b06d704ef098e948c8e (commit)
via f8ef5bcb1e8ebc747b32192348faae9fd32fdba9 (commit)
via 666d6e49e1cd46fd293b3fdce239e34588666ed6 (commit)
via 8b21629d234228ff9fbb7a3c5ad5ebeca4b981c1 (commit)
via 4191945aad5aaf0873b15727716d0a988b1c978d (commit)
via ebc5206327363f747822e7344037d9c2b76b8cd9 (commit)
via 9e72b16bcbfcdc819cbdc437feb10f73b1694107 (commit)
via dfd7a01376d7b871cf7dfe631f5c96b4b2b7767b (commit)
via ae4e7f10136bd182db6d4801ace410e72574abf2 (commit)
via ca03a1f5156b0a68a2179e287d9af444c64aee91 (commit)
via f5cc3a37a155b140b4187a98028c1b8a5f79f9b9 (commit)
via 31bde63b8fae57143dd02d9db4798aa254494c77 (commit)
via 7e41b9c3e2e1ca809ed4ea6de67c843a1a0d7680 (commit)
via 4dc1b4bf31b25256bac76baca6e8af71e11cc83a (commit)
via af6b421d426357550e818d6fee79dd559382ae46 (commit)
via b9ad6d4babd3e10f1c13140e53d60181681a5def (commit)
via d137040ad98f7203cd440ca8b449a84f048af6fd (commit)
via 440524d524bde6ea17ec64b427e259f3bd08757a (commit)
via cb737e68ceac8238844fe2b8b9bc7feea23b4004 (commit)
via 6b48fd891428674ecf5eaaa083bcf5b843deabc5 (commit)
via a98a90d8c392ed3bd0ab51d644568cf560574112 (commit)
via 421d19914af7d7a6f886c1bce084324ce9407b99 (commit)
from e3d273a6048b48b7b39d55087d3a6b7ca0a623eb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 88c4d5e241d0dd670eca6f9a4981439a08924704
Author: Stephen Morris <stephen at isc.org>
Date: Tue Jul 5 10:56:53 2011 +0100
[trac1071] ChangeLog entry for #1071
commit 05164f9d61006869233b498d248486b4307ea8b6
Author: Stephen Morris <stephen at isc.org>
Date: Tue Jul 5 10:35:04 2011 +0100
[trac1071] Add liblog to list of libraries to link against
commit bfcd0225fe669dde479dde1146612f7c067a817f
Merge: e3d273a6048b48b7b39d55087d3a6b7ca0a623eb 2c936393a16d79fa3d4bbbdacc66884f7d8d3cb9
Author: Stephen Morris <stephen at isc.org>
Date: Tue Jul 5 10:15:50 2011 +0100
Merge branch 'master' into trac1071
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 65 ++++++++++-------
doc/guide/bind10-guide.xml | 17 +++++
src/bin/auth/auth_messages.mes | 2 +-
src/bin/cmdctl/Makefile.am | 10 ++-
src/bin/cmdctl/cmdctl.py.in | 59 +++++++++-------
src/bin/cmdctl/cmdctl_messages.mes | 81 ++++++++++++++++++++++
src/bin/cmdctl/tests/cmdctl_test.py | 4 +-
src/bin/resolver/resolver_messages.mes | 12 ++-
src/lib/acl/loader.h | 2 +-
src/lib/asiolink/README | 7 ++
src/lib/cc/data.cc | 4 +-
src/lib/cc/tests/data_unittests.cc | 15 ++++
src/lib/datasrc/data_source.cc | 2 +-
src/lib/datasrc/memory_datasrc.cc | 7 ++-
src/lib/log/log_formatter.h | 3 +-
src/lib/python/isc/cc/message.py | 2 +-
src/lib/python/isc/cc/session.py | 37 ++++++++---
src/lib/python/isc/cc/tests/message_test.py | 5 ++
src/lib/python/isc/cc/tests/session_test.py | 10 +++
src/lib/python/isc/config/ccsession.py | 21 +++++-
src/lib/python/isc/config/cfgmgr.py | 3 +
src/lib/python/isc/config/cfgmgr_messages.mes | 7 ++
src/lib/server_common/Makefile.am | 10 +++-
src/lib/server_common/keyring.cc | 4 +
src/lib/{datasrc => server_common}/logger.cc | 6 +-
src/lib/{datasrc => server_common}/logger.h | 18 ++---
src/lib/server_common/portconfig.cc | 21 ++++--
src/lib/server_common/server_common_messages.mes | 73 +++++++++++++++++++
src/lib/server_common/tests/Makefile.am | 1 +
src/lib/server_common/tests/run_unittests.cc | 3 +
tools/system_messages.py | 6 ++
31 files changed, 414 insertions(+), 103 deletions(-)
create mode 100644 src/bin/cmdctl/cmdctl_messages.mes
copy src/lib/{datasrc => server_common}/logger.cc (88%)
copy src/lib/{datasrc => server_common}/logger.h (73%)
create mode 100644 src/lib/server_common/server_common_messages.mes
-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 4616678..7c2dcf8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+267. [func] stephen
+ Add environment variable to allow redirection of logging output during
+ unit tests.
+ (Trac #1071, git 05164f9d61006869233b498d248486b4307ea8b6)
+
+266. [func] Multiple developers
+ Convert various error messages, debugging and other output
+ to the new logging interface, including for b10-resolver,
+ the resolver library, the CC library, b10-auth, b10-cfgmgr,
+ b10-xfrin, and b10-xfrout. This includes a lot of new
+ documentation describing the new log messages.
+ (Trac #738, #739, #742, #746, #759, #761, #762)
+
265. [func]* jinmei
b10-resolver: Introduced ACL on incoming queries. By default the
resolver accepts queries from ::1 and 127.0.0.1 and rejects all
@@ -52,7 +65,7 @@
Now builds and runs with Python 3.2
(Trac #710, git dae1d2e24f993e1eef9ab429326652f40a006dfb)
-257. [bug] y-aharen
+257. [bug] y-aharen
Fixed a bug an instance of IntervalTimerImpl may be destructed
while deadline_timer is holding the handler. This fix addresses
occasional failure of IntervalTimerTest.destructIntervalTimer.
@@ -61,25 +74,25 @@
256. [bug] jerry
src/bin/xfrin: update xfrin to check TSIG before other part of
incoming message.
- (Trac955, git 261450e93af0b0406178e9ef121f81e721e0855c)
+ (Trac #955, git 261450e93af0b0406178e9ef121f81e721e0855c)
255. [func] zhang likun
src/lib/cache: remove empty code in lib/cache and the corresponding
suppression rule in src/cppcheck-suppress.lst.
- (Trac639, git 4f714bac4547d0a025afd314c309ca5cb603e212)
+ (Trac #639, git 4f714bac4547d0a025afd314c309ca5cb603e212)
254. [bug] jinmei
b10-xfrout: failed to send notifies over IPv6 correctly.
- (Trac964, git 3255c92714737bb461fb67012376788530f16e40)
+ (Trac #964, git 3255c92714737bb461fb67012376788530f16e40)
-253. [func] jelte
+253. [func] jelte
Add configuration options for logging through the virtual module
Logging.
- (Trac 736, git 9fa2a95177265905408c51d13c96e752b14a0824)
+ (Trac #736, git 9fa2a95177265905408c51d13c96e752b14a0824)
-252. [func] stephen
+252. [func] stephen
Add syslog as destination for logging.
- (Trac976, git 31a30f5485859fd3df2839fc309d836e3206546e)
+ (Trac #976, git 31a30f5485859fd3df2839fc309d836e3206546e)
251. [bug]* jinmei
Make sure bindctl private files are non readable to anyone except
@@ -88,38 +101,38 @@
group will have to be adjusted. Also note that this change is
only effective for a fresh install; if these files already exist,
their permissions must be adjusted by hand (if necessary).
- (Trac870, git 461fc3cb6ebabc9f3fa5213749956467a14ebfd4)
+ (Trac #870, git 461fc3cb6ebabc9f3fa5213749956467a14ebfd4)
-250. [bug] ocean
+250. [bug] ocean
src/lib/util/encode, in some conditions, the DecodeNormalizer's
iterator may reach the end() and when later being dereferenced
it will cause crash on some platform.
- (Trac838, git 83e33ec80c0c6485d8b116b13045b3488071770f)
+ (Trac #838, git 83e33ec80c0c6485d8b116b13045b3488071770f)
-249. [func] jerry
+249. [func] jerry
xfrout: add support for TSIG verification.
- (Trac816, git 3b2040e2af2f8139c1c319a2cbc429035d93f217)
+ (Trac #816, git 3b2040e2af2f8139c1c319a2cbc429035d93f217)
-248. [func] stephen
+248. [func] stephen
Add file and stderr as destinations for logging.
- (Trac555, git 38b3546867425bd64dbc5920111a843a3330646b)
+ (Trac #555, git 38b3546867425bd64dbc5920111a843a3330646b)
-247. [func] jelte
+247. [func] jelte
Upstream queries from the resolver now set EDNS0 buffer size.
- (Trac834, git 48e10c2530fe52c9bde6197db07674a851aa0f5d)
+ (Trac #834, git 48e10c2530fe52c9bde6197db07674a851aa0f5d)
-246. [func] stephen
+246. [func] stephen
Implement logging using log4cplus (http://log4cplus.sourceforge.net)
- (Trac899, git 31d3f525dc01638aecae460cb4bc2040c9e4df10)
+ (Trac #899, git 31d3f525dc01638aecae460cb4bc2040c9e4df10)
-245. [func] vorner
+245. [func] vorner
Authoritative server can now sign the answers using TSIG
(configured in tsig_keys/keys, list of strings like
"name:<base64-secret>:sha1-hmac"). It doesn't use them for
ACL yet, only verifies them and signs if the request is signed.
- (Trac875, git fe5e7003544e4e8f18efa7b466a65f336d8c8e4d)
+ (Trac #875, git fe5e7003544e4e8f18efa7b466a65f336d8c8e4d)
-244. [func] stephen
+244. [func] stephen
In unit tests, allow the choice of whether unhandled exceptions are
caught in the unit test program (and details printed) or allowed to
propagate to the default exception handler. See the bind10-dev thread
@@ -129,7 +142,7 @@
243. [func]* feng
Add optional hmac algorithm SHA224/384/812.
- (Trac#782, git 77d792c9d7c1a3f95d3e6a8b721ac79002cd7db1)
+ (Trac #782, git 77d792c9d7c1a3f95d3e6a8b721ac79002cd7db1)
bind10-devel-20110519 released on May 19, 2011
@@ -176,7 +189,7 @@ bind10-devel-20110519 released on May 19, 2011
stats module and stats-httpd module, and maybe with other
statistical modules in future. "stats.spec" has own configuration
and commands of stats module, if it requires.
- (Trac#719, git a234b20dc6617392deb8a1e00eb0eed0ff353c0a)
+ (Trac #719, git a234b20dc6617392deb8a1e00eb0eed0ff353c0a)
236. [func] jelte
C++ client side of configuration now uses BIND10 logging system.
@@ -219,13 +232,13 @@ bind10-devel-20110519 released on May 19, 2011
instead of '%s,%d', which allows us to cope better with
mismatched placeholders and allows reordering of them in
case of translation.
- (Trac901, git 4903410e45670b30d7283f5d69dc28c2069237d6)
+ (Trac #901, git 4903410e45670b30d7283f5d69dc28c2069237d6)
230. [bug] naokikambe
Removed too repeated verbose messages in two cases of:
- when auth sends statistics data to stats
- when stats receives statistics data from other modules
- (Trac#620, git 0ecb807011196eac01f281d40bc7c9d44565b364)
+ (Trac #620, git 0ecb807011196eac01f281d40bc7c9d44565b364)
229. [doc] jreed
Add manual page for b10-host.
diff --git a/doc/guide/bind10-guide.xml b/doc/guide/bind10-guide.xml
index 7d1a006..6a42182 100644
--- a/doc/guide/bind10-guide.xml
+++ b/doc/guide/bind10-guide.xml
@@ -5,6 +5,23 @@
<!ENTITY % version SYSTEM "version.ent">
%version;
]>
+
+<!--
+ - Copyright (C) 2010-2011 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.
+-->
+
<book>
<?xml-stylesheet href="bind10-guide.css" type="text/css"?>
diff --git a/src/bin/auth/auth_messages.mes b/src/bin/auth/auth_messages.mes
index 8553d17..2bb402c 100644
--- a/src/bin/auth/auth_messages.mes
+++ b/src/bin/auth/auth_messages.mes
@@ -188,7 +188,7 @@ accepting queries.
The authoritative server has encountered a fatal error and is terminating. The
reason for the failure is included in the message.
-% AUTH_SERVER_STARTED server stated
+% AUTH_SERVER_STARTED server started
Initialization of the authoritative server has completed successfully
and it is entering the main loop, waiting for queries to arrive.
diff --git a/src/bin/cmdctl/Makefile.am b/src/bin/cmdctl/Makefile.am
index 97a64ff..fcd23f8 100644
--- a/src/bin/cmdctl/Makefile.am
+++ b/src/bin/cmdctl/Makefile.am
@@ -3,6 +3,7 @@ SUBDIRS = . tests
pkglibexecdir = $(libexecdir)/@PACKAGE@
pkglibexec_SCRIPTS = b10-cmdctl
+pyexec_DATA = cmdctl_messages.py
b10_cmdctldir = $(pkgdatadir)
@@ -18,10 +19,10 @@ b10_cmdctl_DATA += cmdctl.spec
EXTRA_DIST = $(CMDCTL_CONFIGURATIONS)
-CLEANFILES= b10-cmdctl cmdctl.pyc cmdctl.spec
+CLEANFILES= b10-cmdctl cmdctl.pyc cmdctl.spec cmdctl_messages.py cmdctl_messages.pyc
man_MANS = b10-cmdctl.8
-EXTRA_DIST += $(man_MANS) b10-cmdctl.xml
+EXTRA_DIST += $(man_MANS) b10-cmdctl.xml cmdctl_messages.mes
if ENABLE_MAN
@@ -33,8 +34,11 @@ endif
cmdctl.spec: cmdctl.spec.pre
$(SED) -e "s|@@SYSCONFDIR@@|$(sysconfdir)|" cmdctl.spec.pre >$@
+cmdctl_messages.py: cmdctl_messages.mes
+ $(top_builddir)/src/lib/log/compiler/message -p $(top_srcdir)/src/bin/cmdctl/cmdctl_messages.mes
+
# this is done here since configure.ac AC_OUTPUT doesn't expand exec_prefix
-b10-cmdctl: cmdctl.py
+b10-cmdctl: cmdctl.py cmdctl_messages.py
$(SED) "s|@@PYTHONPATH@@|@pyexecdir@|" cmdctl.py >$@
chmod a+x $@
diff --git a/src/bin/cmdctl/cmdctl.py.in b/src/bin/cmdctl/cmdctl.py.in
index f1c1021..778d38f 100755
--- a/src/bin/cmdctl/cmdctl.py.in
+++ b/src/bin/cmdctl/cmdctl.py.in
@@ -47,6 +47,18 @@ import isc.net.parse
from optparse import OptionParser, OptionValueError
from hashlib import sha1
from isc.util import socketserver_mixin
+from cmdctl_messages import *
+
+# TODO: these debug-levels are hard-coded here; we are planning on
+# creating a general set of debug levels, see ticket #1074. When done,
+# we should remove these values and use the general ones in the
+# logger.debug calls
+
+# Debug level for communication with BIND10
+DBG_CMDCTL_MESSAGING = 30
+
+isc.log.init("b10-cmdctl")
+logger = isc.log.Logger("cmdctl")
try:
import threading
@@ -173,7 +185,8 @@ class SecureHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
if not user_name:
return False, ["need user name"]
if not self.server.get_user_info(user_name):
- return False, ["user doesn't exist"]
+ logger.info(CMDCTL_NO_SUCH_USER, user_name)
+ return False, ["username or password error"]
user_pwd = user_info.get('password')
if not user_pwd:
@@ -181,7 +194,8 @@ class SecureHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
local_info = self.server.get_user_info(user_name)
pwd_hashval = sha1((user_pwd + local_info[1]).encode())
if pwd_hashval.hexdigest() != local_info[0]:
- return False, ["password doesn't match"]
+ logger.info(CMDCTL_BAD_PASSWORD, user_name)
+ return False, ["username or password error"]
return True, None
@@ -238,7 +252,8 @@ class CommandControl():
self._cc = isc.cc.Session()
self._module_cc = isc.config.ModuleCCSession(SPECFILE_LOCATION,
self.config_handler,
- self.command_handler)
+ self.command_handler,
+ None, True)
self._module_name = self._module_cc.get_module_spec().get_module_name()
self._cmdctl_config_data = self._module_cc.get_full_config()
self._module_cc.start()
@@ -281,7 +296,7 @@ class CommandControl():
errstr = 'unknown config item: ' + key
if errstr != None:
- self.log_info('Fail to apply config data, ' + errstr)
+ logger.error(CMDCTL_BAD_CONFIG_DATA, errstr);
return ccsession.create_answer(1, errstr)
return ccsession.create_answer(0)
@@ -387,8 +402,8 @@ class CommandControl():
'''Send the command from bindctl to proper module. '''
errstr = 'unknown error'
answer = None
- if self._verbose:
- self.log_info("Begin send command '%s' to module '%s'" %(command_name, module_name))
+ logger.debug(DBG_CMDCTL_MESSAGING, CMDCTL_SEND_COMMAND,
+ command_name, module_name)
if module_name == self._module_name:
# Process the command sent to cmdctl directly.
@@ -396,15 +411,14 @@ class CommandControl():
else:
msg = ccsession.create_command(command_name, params)
seq = self._cc.group_sendmsg(msg, module_name)
+ logger.debug(DBG_CMDCTL_MESSAGING, CMDCTL_COMMAND_SENT,
+ command_name, module_name)
#TODO, it may be blocked, msqg need to add a new interface waiting in timeout.
try:
answer, env = self._cc.group_recvmsg(False, seq)
except isc.cc.session.SessionTimeout:
errstr = "Module '%s' not responding" % module_name
- if self._verbose:
- self.log_info("Finish send command '%s' to module '%s'" % (command_name, module_name))
-
if answer:
try:
rcode, arg = ccsession.parse_answer(answer)
@@ -415,16 +429,13 @@ class CommandControl():
else:
return rcode, {}
else:
- # TODO: exception
errstr = str(answer['result'][1])
except ccsession.ModuleCCSessionError as mcse:
errstr = str("Error in ccsession answer:") + str(mcse)
- self.log_info(errstr)
+
+ logger.error(CMDCTL_COMMAND_ERROR, command_name, module_name, errstr)
return 1, {'error': errstr}
- def log_info(self, msg):
- sys.stdout.write("[b10-cmdctl] %s\n" % str(msg))
-
def get_cmdctl_config_data(self):
''' If running in source code tree, use keyfile, certificate
and user accounts file in source code. '''
@@ -481,14 +492,15 @@ class SecureHTTPServer(socketserver_mixin.NoPollMixIn,
for row in reader:
self._user_infos[row[0]] = [row[1], row[2]]
except (IOError, IndexError) as e:
- self.log_info("Fail to read user database, %s" % e)
+ logger.error(CMDCTL_USER_DATABASE_READ_ERROR,
+ accounts_file, e)
finally:
if csvfile:
csvfile.close()
self._accounts_file = accounts_file
if len(self._user_infos) == 0:
- self.log_info("Fail to get user information, will deny any user")
+ logger.error(CMDCTL_NO_USER_ENTRIES_READ)
def get_user_info(self, username):
'''Get user's salt and hashed string. If the user
@@ -520,7 +532,7 @@ class SecureHTTPServer(socketserver_mixin.NoPollMixIn,
ssl_version = ssl.PROTOCOL_SSLv23)
return ssl_sock
except (ssl.SSLError, CmdctlException) as err :
- self.log_info("Deny client's connection because %s" % str(err))
+ logger.info(CMDCTL_SSL_SETUP_FAILURE_USER_DENIED, err)
self.close_request(sock)
# raise socket error to finish the request
raise socket.error
@@ -547,9 +559,6 @@ class SecureHTTPServer(socketserver_mixin.NoPollMixIn,
def send_command_to_module(self, module_name, command_name, params):
return self.cmdctl.send_command_with_check(module_name, command_name, params)
- def log_info(self, msg):
- sys.stdout.write("[b10-cmdctl] %s\n" % str(msg))
-
httpd = None
def signal_handler(signal, frame):
@@ -607,15 +616,13 @@ if __name__ == '__main__':
run(options.addr, options.port, options.idle_timeout, options.verbose)
result = 0
except isc.cc.SessionError as err:
- sys.stderr.write("[b10-cmdctl] Error creating b10-cmdctl, "
- "is the command channel daemon running?\n")
+ logger.fatal(CMDCTL_CC_SESSION_ERROR, err)
except isc.cc.SessionTimeout:
- sys.stderr.write("[b10-cmdctl] Error creating b10-cmdctl, "
- "is the configuration manager running?\n")
+ logger.fatal(CMDCTL_CC_SESSION_TIMEOUT)
except KeyboardInterrupt:
- sys.stderr.write("[b10-cmdctl] exit from Cmdctl\n")
+ logger.info(CMDCTL_STOPPED_BY_KEYBOARD)
except CmdctlException as err:
- sys.stderr.write("[b10-cmdctl] " + str(err) + "\n")
+ logger.fatal(CMDCTL_UNCAUGHT_EXCEPTION, err);
if httpd:
httpd.shutdown()
diff --git a/src/bin/cmdctl/cmdctl_messages.mes b/src/bin/cmdctl/cmdctl_messages.mes
new file mode 100644
index 0000000..55b941f
--- /dev/null
+++ b/src/bin/cmdctl/cmdctl_messages.mes
@@ -0,0 +1,81 @@
+# Copyright (C) 2011 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.
+
+# No namespace declaration - these constants go in the global namespace
+# of the cmdctl_messages python module.
+
+% CMDCTL_BAD_CONFIG_DATA error in config data: %1
+There was an error reading the updated configuration data. The specific
+error is printed.
+
+% CMDCTL_BAD_PASSWORD bad password for user: %1
+A login attempt was made to b10-cmdctl, but the password was wrong.
+Users can be managed with the tool b10-cmdctl-usermgr.
+
+% CMDCTL_CC_SESSION_ERROR error reading from cc channel: %1
+There was a problem reading from the command and control channel. The
+most likely cause is that the message bus daemon is not running.
+
+% CMDCTL_CC_SESSION_TIMEOUT timeout on cc channel
+A timeout occurred when waiting for essential data from the cc session.
+This usually occurs when b10-cfgmgr is not running or not responding.
+Since we are waiting for essential information, this is a fatal error,
+and the cmdctl daemon will now shut down.
+
+% CMDCTL_COMMAND_ERROR error in command %1 to module %2: %3
+An error was encountered sending the given command to the given module.
+Either there was a communication problem with the module, or the module
+was not able to process the command, and sent back an error. The
+specific error is printed in the message.
+
+% CMDCTL_COMMAND_SENT command '%1' to module '%2' was sent
+This debug message indicates that the given command has been sent to
+the given module.
+
+% CMDCTL_NO_SUCH_USER username not found in user database: %1
+A login attempt was made to b10-cmdctl, but the username was not known.
+Users can be added with the tool b10-cmdctl-usermgr.
+
+% CMDCTL_NO_USER_ENTRIES_READ failed to read user information, all users will be denied
+The b10-cmdctl daemon was unable to find any user data in the user
+database file. Either it was unable to read the file (in which case
+this message follows a message CMDCTL_USER_DATABASE_READ_ERROR
+containing a specific error), or the file was empty. Users can be added
+with the tool b10-cmdctl-usermgr.
+
+% CMDCTL_SEND_COMMAND sending command %1 to module %2
+This debug message indicates that the given command is being sent to
+the given module.
+
+% CMDCTL_SSL_SETUP_FAILURE_USER_DENIED failed to create an SSL connection (user denied): %1
+The user was denied because the SSL connection could not successfully
+be set up. The specific error is given in the log message. Possible
+causes may be that the ssl request itself was bad, or the local key or
+certificate file could not be read.
+
+% CMDCTL_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
+There was a keyboard interrupt signal to stop the cmdctl daemon. The
+daemon will now shut down.
+
+% CMDCTL_UNCAUGHT_EXCEPTION uncaught exception: %1
+The b10-cdmctl daemon encountered an uncaught exception and
+will now shut down. This is indicative of a programming error and
+should not happen under normal circumstances. The exception message
+is printed.
+
+% CMDCTL_USER_DATABASE_READ_ERROR failed to read user database file %1: %2
+The b10-cmdctl daemon was unable to read the user database file. The
+file may be unreadable for the daemon, or it may be corrupted. In the
+latter case, it can be recreated with b10-cmdctl-usermgr. The specific
+error is printed in the log message.
diff --git a/src/bin/cmdctl/tests/cmdctl_test.py b/src/bin/cmdctl/tests/cmdctl_test.py
index 5463c36..e77c529 100644
--- a/src/bin/cmdctl/tests/cmdctl_test.py
+++ b/src/bin/cmdctl/tests/cmdctl_test.py
@@ -173,7 +173,7 @@ class TestSecureHTTPRequestHandler(unittest.TestCase):
self.handler.server._user_infos['root'] = ['aa', 'aaa']
ret, msg = self.handler._check_user_name_and_pwd()
self.assertFalse(ret)
- self.assertEqual(msg, ['password doesn\'t match'])
+ self.assertEqual(msg, ['username or password error'])
def test_check_user_name_and_pwd_2(self):
user_info = {'username':'root', 'password':'abc123'}
@@ -214,7 +214,7 @@ class TestSecureHTTPRequestHandler(unittest.TestCase):
ret, msg = self.handler._check_user_name_and_pwd()
self.assertFalse(ret)
- self.assertEqual(msg, ['user doesn\'t exist'])
+ self.assertEqual(msg, ['username or password error'])
def test_do_POST(self):
self.handler.headers = {}
diff --git a/src/bin/resolver/resolver_messages.mes b/src/bin/resolver/resolver_messages.mes
index 6c5be64..05b9a8b 100644
--- a/src/bin/resolver/resolver_messages.mes
+++ b/src/bin/resolver/resolver_messages.mes
@@ -210,10 +210,14 @@ query in the form of <Source IP address>#<source port>.
% RESOLVER_QUERY_REJECTED query rejected: '%1/%2/%3' from %4
An informational message that indicates an incoming query is rejected
in terms of the query ACL. This results in a response with an RCODE of
-REFUSED. See QUERYACCEPTED for the information given in the message.
+REFUSED. The log message shows the query in the form of <query
+name>/<query type>/<query class>, and the client that sends the
+query in the form of <Source IP address>#<source port>.
% RESOLVER_QUERY_DROPPED query dropped: '%1/%2/%3' from %4
An informational message that indicates an incoming query is dropped
-in terms of the query ACL. Unlike the QUERYREJECTED case, the server does
-not return any response. See QUERYACCEPTED for the information given in
-the message.
+in terms of the query ACL. Unlike the RESOLVER_QUERY_REJECTED
+case, the server does not return any response. The log message
+shows the query in the form of <query name>/<query type>/<query
+class>, and the client that sends the query in the form of <Source
+IP address>#<source port>.
diff --git a/src/lib/acl/loader.h b/src/lib/acl/loader.h
index 6b024c9..a2aa2f8 100644
--- a/src/lib/acl/loader.h
+++ b/src/lib/acl/loader.h
@@ -81,7 +81,7 @@ public:
* or if it doesn't contain one of the accepted values.
*
* \param action The JSON representation of the action. It must be a string
- * and contain one of "ACCEPT", "REJECT" or "DENY".
+ * and contain one of "ACCEPT", "REJECT" or "DROP.
* \note We could define different names or add aliases if needed.
*/
BasicAction defaultActionLoader(data::ConstElementPtr action);
diff --git a/src/lib/asiolink/README b/src/lib/asiolink/README
index 66091b1..b9e38f9 100644
--- a/src/lib/asiolink/README
+++ b/src/lib/asiolink/README
@@ -20,3 +20,10 @@ Some of the classes defined here--for example, IOSocket, IOEndpoint,
and IOAddress--are to be used by BIND 10 modules as wrappers around
ASIO-specific classes.
+
+Logging
+-------
+
+At this point, nothing is logged by this low-level library. We may
+revisit that in the future, if we find suitable messages to log, but
+right now there are also no loggers initialized or called.
diff --git a/src/lib/cc/data.cc b/src/lib/cc/data.cc
index 932bef4..a455d43 100644
--- a/src/lib/cc/data.cc
+++ b/src/lib/cc/data.cc
@@ -447,7 +447,9 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
ElementPtr map = Element::createMap();
skip_chars(in, " \t\n", line, pos);
char c = in.peek();
- if (c == '}') {
+ if (c == EOF) {
+ throwJSONError(std::string("Unterminated map, <string> or } expected"), file, line, pos);
+ } else if (c == '}') {
// empty map, skip closing curly
c = in.get();
} else {
diff --git a/src/lib/cc/tests/data_unittests.cc b/src/lib/cc/tests/data_unittests.cc
index 2536682..53d5ab8 100644
--- a/src/lib/cc/tests/data_unittests.cc
+++ b/src/lib/cc/tests/data_unittests.cc
@@ -396,9 +396,24 @@ TEST(Element, to_and_from_wire) {
EXPECT_EQ("1", Element::fromWire(ss, 1)->str());
// Some malformed JSON input
+ EXPECT_THROW(Element::fromJSON("{ "), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{ \"a\" "), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{ \"a\": "), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{ \"a\": \"b\""), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{ \"a\": {"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{ \"a\": {}"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{ \"a\": []"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{ \"a\": [ }"), isc::data::JSONError);
EXPECT_THROW(Element::fromJSON("{\":"), isc::data::JSONError);
EXPECT_THROW(Element::fromJSON("]"), isc::data::JSONError);
EXPECT_THROW(Element::fromJSON("[ 1, 2, }"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("[ 1, 2, {}"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("[ 1, 2, { ]"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("[ "), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{{}}"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{[]}"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("{ \"a\", \"b\" }"), isc::data::JSONError);
+ EXPECT_THROW(Element::fromJSON("[ \"a\": \"b\" ]"), isc::data::JSONError);
}
ConstElementPtr
diff --git a/src/lib/datasrc/data_source.cc b/src/lib/datasrc/data_source.cc
index 4e1fcde..b57a967 100644
--- a/src/lib/datasrc/data_source.cc
+++ b/src/lib/datasrc/data_source.cc
@@ -945,7 +945,7 @@ tryWildcard(Query& q, QueryTaskPtr task, ZoneInfo& zoneinfo, bool& found) {
void
DataSrc::doQuery(Query& q) {
LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_QUERY_PROCESS).arg(q.qname()).
- arg(q.qclass());
+ arg(q.qtype()).arg(q.qclass());
Message& m = q.message();
vector<RRsetPtr> additional;
diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc
index 3c57d1b..b8019a2 100644
--- a/src/lib/datasrc/memory_datasrc.cc
+++ b/src/lib/datasrc/memory_datasrc.cc
@@ -225,10 +225,13 @@ struct MemoryZone::MemoryZoneImpl {
*/
// Implementation of MemoryZone::add
result::Result add(const ConstRRsetPtr& rrset, DomainTree* domains) {
+ // Sanitize input. This will cause an exception to be thrown
+ // if the input RRset is empty.
+ addValidation(rrset);
+
+ // OK, can add the RRset.
LOG_DEBUG(logger, DBG_TRACE_DATA, DATASRC_MEM_ADD_RRSET).
arg(rrset->getName()).arg(rrset->getType()).arg(origin_);
- // Sanitize input
- addValidation(rrset);
// Add wildcards possibly contained in the owner name to the domain
// tree.
diff --git a/src/lib/log/log_formatter.h b/src/lib/log/log_formatter.h
index c81d4ea..11dec84 100644
--- a/src/lib/log/log_formatter.h
+++ b/src/lib/log/log_formatter.h
@@ -163,6 +163,8 @@ public:
}
/// \brief String version of arg.
+ ///
+ /// \param arg The text to place into the placeholder.
Formatter& arg(const std::string& arg) {
if (logger_) {
// Note that this method does a replacement and returns the
@@ -179,7 +181,6 @@ public:
}
return (*this);
}
-
};
}
diff --git a/src/lib/python/isc/cc/message.py b/src/lib/python/isc/cc/message.py
index 3601c41..3ebcc43 100644
--- a/src/lib/python/isc/cc/message.py
+++ b/src/lib/python/isc/cc/message.py
@@ -35,7 +35,7 @@ def from_wire(data):
Raises an AttributeError if the given object has no decode()
method (which should return a string).
'''
- return json.loads(data.decode('utf8'))
+ return json.loads(data.decode('utf8'), strict=False)
if __name__ == "__main__":
import doctest
diff --git a/src/lib/python/isc/cc/session.py b/src/lib/python/isc/cc/session.py
index fb7dd06..f6b6265 100644
--- a/src/lib/python/isc/cc/session.py
+++ b/src/lib/python/isc/cc/session.py
@@ -93,6 +93,19 @@ class Session:
self._socket.send(msg)
def recvmsg(self, nonblock = True, seq = None):
+ """Reads a message. If nonblock is true, and there is no
+ message to read, it returns (None, None).
+ If seq is not None, it should be a value as returned by
+ group_sendmsg(), in which case only the response to
+ that message is returned, and others will be queued until
+ the next call to this method.
+ If seq is None, only messages that are *not* responses
+ will be returned, and responses will be queued.
+ The queue is checked for relevant messages before data
+ is read from the socket.
+ Raises a SessionError if there is a JSON decode problem in
+ the message that is read, or if the session has been closed
+ prior to the call of recvmsg()"""
with self._lock:
if len(self._queue) > 0:
i = 0;
@@ -109,16 +122,22 @@ class Session:
if data and len(data) > 2:
header_length = struct.unpack('>H', data[0:2])[0]
data_length = len(data) - 2 - header_length
- if data_length > 0:
- env = isc.cc.message.from_wire(data[2:header_length+2])
- msg = isc.cc.message.from_wire(data[header_length + 2:])
- if (seq == None and "reply" not in env) or (seq != None and "reply" in env and seq == env["reply"]):
- return env, msg
+ try:
+ if data_length > 0:
+ env = isc.cc.message.from_wire(data[2:header_length+2])
+ msg = isc.cc.message.from_wire(data[header_length + 2:])
+ if (seq == None and "reply" not in env) or (seq != None and "reply" in env and seq == env["reply"]):
+ return env, msg
+ else:
+ self._queue.append((env,msg))
+ return self.recvmsg(nonblock, seq)
else:
- self._queue.append((env,msg))
- return self.recvmsg(nonblock, seq)
- else:
- return isc.cc.message.from_wire(data[2:header_length+2]), None
+ return isc.cc.message.from_wire(data[2:header_length+2]), None
+ except ValueError as ve:
+ # TODO: when we have logging here, add a debug
+ # message printing the data that we were unable
+ # to parse as JSON
+ raise SessionError(ve)
return None, None
def _receive_bytes(self, size):
diff --git a/src/lib/python/isc/cc/tests/message_test.py b/src/lib/python/isc/cc/tests/message_test.py
index 2024201..c417068 100644
--- a/src/lib/python/isc/cc/tests/message_test.py
+++ b/src/lib/python/isc/cc/tests/message_test.py
@@ -31,6 +31,10 @@ class MessageTest(unittest.TestCase):
self.msg2_str = "{\"aaa\": [1, 1.1, true, false, null]}";
self.msg2_wire = self.msg2_str.encode()
+ self.msg3 = { "aaa": [ 1, 1.1, True, False, "string\n" ] }
+ self.msg3_str = "{\"aaa\": [1, 1.1, true, false, \"string\n\" ]}";
+ self.msg3_wire = self.msg3_str.encode()
+
def test_encode_json(self):
self.assertEqual(self.msg1_wire, isc.cc.message.to_wire(self.msg1))
self.assertEqual(self.msg2_wire, isc.cc.message.to_wire(self.msg2))
@@ -40,6 +44,7 @@ class MessageTest(unittest.TestCase):
def test_decode_json(self):
self.assertEqual(self.msg1, isc.cc.message.from_wire(self.msg1_wire))
self.assertEqual(self.msg2, isc.cc.message.from_wire(self.msg2_wire))
+ self.assertEqual(self.msg3, isc.cc.message.from_wire(self.msg3_wire))
self.assertRaises(AttributeError, isc.cc.message.from_wire, 1)
self.assertRaises(ValueError, isc.cc.message.from_wire, b'\x001')
diff --git a/src/lib/python/isc/cc/tests/session_test.py b/src/lib/python/isc/cc/tests/session_test.py
index fe35a6c..772ed0c 100644
--- a/src/lib/python/isc/cc/tests/session_test.py
+++ b/src/lib/python/isc/cc/tests/session_test.py
@@ -274,6 +274,16 @@ class testSession(unittest.TestCase):
self.assertEqual({"hello": "b"}, msg)
self.assertFalse(sess.has_queued_msgs())
+ def test_recv_bad_msg(self):
+ sess = MySession()
+ self.assertFalse(sess.has_queued_msgs())
+ sess._socket.addrecv({'to': 'someone' }, {'hello': 'b'})
+ sess._socket.addrecv({'to': 'someone', 'reply': 1}, {'hello': 'a'})
+ # mangle the bytes a bit
+ sess._socket.recvqueue[5] = sess._socket.recvqueue[5] - 2
+ sess._socket.recvqueue = sess._socket.recvqueue[:-2]
+ self.assertRaises(SessionError, sess.recvmsg, True, 1)
+
def test_next_sequence(self):
sess = MySession()
self.assertEqual(sess._sequence, 1)
diff --git a/src/lib/python/isc/config/ccsession.py b/src/lib/python/isc/config/ccsession.py
index 0869160..bff4f58 100644
--- a/src/lib/python/isc/config/ccsession.py
+++ b/src/lib/python/isc/config/ccsession.py
@@ -142,14 +142,29 @@ class ModuleCCSession(ConfigData):
callbacks are called when 'check_command' is called on the
ModuleCCSession"""
- def __init__(self, spec_file_name, config_handler, command_handler, cc_session = None, handle_logging_config = False):
+ def __init__(self, spec_file_name, config_handler, command_handler, cc_session=None, handle_logging_config=False):
"""Initialize a ModuleCCSession. This does *NOT* send the
specification and request the configuration yet. Use start()
for that once the ModuleCCSession has been initialized.
- specfile_name is the path to the specification file
+
+ specfile_name is the path to the specification file.
+
config_handler and command_handler are callback functions,
see set_config_handler and set_command_handler for more
- information on their signatures."""
+ information on their signatures.
+
+ cc_session can be used to pass in an existing CCSession,
+ if it is None, one will be set up. This is mainly intended
+ for testing purposes.
+
+ handle_logging_config: if True, the module session will
+ automatically handle logging configuration for the module;
+ it will read the system-wide Logging configuration and call
+ the logger manager to apply it. It will also inform the
+ logger manager when the logging configuration gets updated.
+ The module does not need to do anything except intializing
+ its loggers, and provide log messages
+ """
module_spec = isc.config.module_spec_from_file(spec_file_name)
ConfigData.__init__(self, module_spec)
diff --git a/src/lib/python/isc/config/cfgmgr.py b/src/lib/python/isc/config/cfgmgr.py
index 83db159..18e001c 100644
--- a/src/lib/python/isc/config/cfgmgr.py
+++ b/src/lib/python/isc/config/cfgmgr.py
@@ -380,6 +380,9 @@ class ConfigManager:
answer, env = self.cc.group_recvmsg(False, seq)
except isc.cc.SessionTimeout:
answer = ccsession.create_answer(1, "Timeout waiting for answer from " + module_name)
+ except isc.cc.SessionError as se:
+ logger.error(CFGMGR_BAD_UPDATE_RESPONSE_FROM_MODULE, module_name, se)
+ answer = ccsession.create_answer(1, "Unable to parse response from " + module_name + ": " + str(se))
if answer:
rcode, val = ccsession.parse_answer(answer)
if rcode == 0:
diff --git a/src/lib/python/isc/config/cfgmgr_messages.mes b/src/lib/python/isc/config/cfgmgr_messages.mes
index 9355e4d..61a63ed 100644
--- a/src/lib/python/isc/config/cfgmgr_messages.mes
+++ b/src/lib/python/isc/config/cfgmgr_messages.mes
@@ -20,6 +20,13 @@ An older version of the configuration database has been found, from which
there was an automatic upgrade path to the current version. These changes
are now applied, and no action from the administrator is necessary.
+% CFGMGR_BAD_UPDATE_RESPONSE_FROM_MODULE Unable to parse response from module %1: %2
+The configuration manager sent a configuration update to a module, but
+the module responded with an answer that could not be parsed. The answer
+message appears to be invalid JSON data, or not decodable to a string.
+This is likely to be a problem in the module in question. The update is
+assumed to have failed, and will not be stored.
+
% CFGMGR_CC_SESSION_ERROR Error connecting to command channel: %1
The configuration manager daemon was unable to connect to the messaging
system. The most likely cause is that msgq is not running.
diff --git a/src/lib/server_common/Makefile.am b/src/lib/server_common/Makefile.am
index d576104..c2779b4 100644
--- a/src/lib/server_common/Makefile.am
+++ b/src/lib/server_common/Makefile.am
@@ -20,6 +20,9 @@ lib_LTLIBRARIES = libserver_common.la
libserver_common_la_SOURCES = client.h client.cc
libserver_common_la_SOURCES += keyring.h keyring.cc
libserver_common_la_SOURCES += portconfig.h portconfig.cc
+libserver_common_la_SOURCES += logger.h logger.cc
+nodist_libserver_common_la_SOURCES = server_common_messages.h
+nodist_libserver_common_la_SOURCES += server_common_messages.cc
libserver_common_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/cc/libcc.la
@@ -27,5 +30,10 @@ libserver_common_la_LIBADD += $(top_builddir)/src/lib/config/libcfgclient.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/log/liblog.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/acl/libacl.la
libserver_common_la_LIBADD += $(top_builddir)/src/lib/dns/libdns++.la
+BUILT_SOURCES = server_common_messages.h server_common_messages.cc
+server_common_messages.h server_common_messages.cc: server_common_messages.mes
+ $(top_builddir)/src/lib/log/compiler/message $(top_srcdir)/src/lib/server_common/server_common_messages.mes
-CLEANFILES = *.gcno *.gcda
+EXTRA_DIST = server_common_messages.mes
+
+CLEANFILES = *.gcno *.gcda server_common_messages.h server_common_messages.cc
diff --git a/src/lib/server_common/keyring.cc b/src/lib/server_common/keyring.cc
index b60e796..501dfd9 100644
--- a/src/lib/server_common/keyring.cc
+++ b/src/lib/server_common/keyring.cc
@@ -13,6 +13,7 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <server_common/keyring.h>
+#include <server_common/logger.h>
using namespace isc::dns;
using namespace isc::data;
@@ -31,6 +32,7 @@ updateKeyring(const std::string&, ConstElementPtr data,
const isc::config::ConfigData&) {
ConstElementPtr list(data->get("keys"));
KeyringPtr load(new TSIGKeyRing);
+ LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_KEYS_UPDATE);
// Note that 'data' only contains explicitly configured config parameters.
// So if we use the default list is NULL, rather than an empty list, and
@@ -50,6 +52,7 @@ initKeyring(config::ModuleCCSession& session) {
// We are already initialized
return;
}
+ LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_KEYS_INIT);
session.addRemoteConfig("tsig_keys", updateKeyring, false);
}
@@ -59,6 +62,7 @@ deinitKeyring(config::ModuleCCSession& session) {
// Not initialized, ignore it
return;
}
+ LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_KEYS_DEINIT);
keyring.reset();
session.removeRemoteConfig("tsig_keys");
}
diff --git a/src/lib/server_common/logger.cc b/src/lib/server_common/logger.cc
new file mode 100644
index 0000000..0b9ab6e
--- /dev/null
+++ b/src/lib/server_common/logger.cc
@@ -0,0 +1,23 @@
+// Copyright (C) 2011 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 <server_common/logger.h>
+
+namespace isc {
+namespace server_common {
+
+isc::log::Logger logger("server_common");
+
+}
+}
diff --git a/src/lib/server_common/logger.h b/src/lib/server_common/logger.h
new file mode 100644
index 0000000..cfca1f3
--- /dev/null
+++ b/src/lib/server_common/logger.h
@@ -0,0 +1,44 @@
+// Copyright (C) 2011 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 __SERVER_COMMON_LOGGER_H
+#define __SERVER_COMMON_LOGGER_H
+
+#include <log/macros.h>
+#include <server_common/server_common_messages.h>
+
+/// \file logger.h
+/// \brief Server Common library global logger
+///
+/// This holds the logger for the server common library. It is a private header
+/// and should not be included in any publicly used header, only in local
+/// cc files.
+
+namespace isc {
+namespace server_common {
+
+/// \brief The logger for this library
+extern isc::log::Logger logger;
+
+enum {
+ /// \brief Trace basic operations
+ DBG_TRACE_BASIC = 10,
+ /// \brief Print also values used
+ DBG_TRACE_VALUES = 40
+};
+
+}
+}
+
+#endif
diff --git a/src/lib/server_common/portconfig.cc b/src/lib/server_common/portconfig.cc
index 7b2b3dd..379a0a1 100644
--- a/src/lib/server_common/portconfig.cc
+++ b/src/lib/server_common/portconfig.cc
@@ -13,10 +13,10 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <server_common/portconfig.h>
+#include <server_common/logger.h>
#include <asiolink/io_address.h>
#include <asiodns/dns_service.h>
-#include <log/dummylog.h>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
@@ -25,7 +25,6 @@ using namespace std;
using namespace isc::data;
using namespace isc::asiolink;
using namespace isc::asiodns;
-using isc::log::dlog;
namespace isc {
namespace server_common {
@@ -43,6 +42,8 @@ parseAddresses(isc::data::ConstElementPtr addresses,
ConstElementPtr addr(addrPair->get("address"));
ConstElementPtr port(addrPair->get("port"));
if (!addr || ! port) {
+ LOG_ERROR(logger, SRVCOMM_ADDRESS_MISSING).
+ arg(addrPair->str());
isc_throw(BadValue, "Address must contain both the IP"
"address and port");
}
@@ -50,6 +51,8 @@ parseAddresses(isc::data::ConstElementPtr addresses,
IOAddress(addr->stringValue());
if (port->intValue() < 0 ||
port->intValue() > 0xffff) {
+ LOG_ERROR(logger, SRVCOMM_PORT_RANGE).
+ arg(port->intValue()).arg(addrPair->str());
isc_throw(BadValue, "Bad port value (" <<
port->intValue() << ")");
}
@@ -57,11 +60,14 @@ parseAddresses(isc::data::ConstElementPtr addresses,
port->intValue()));
}
catch (const TypeError &e) { // Better error message
+ LOG_ERROR(logger, SRVCOMM_ADDRESS_TYPE).
+ arg(addrPair->str());
isc_throw(TypeError,
"Address must be a string and port an integer");
}
}
} else if (addresses->getType() != Element::null) {
+ LOG_ERROR(logger, SRVCOMM_ADDRESSES_NOT_LIST).arg(elemName);
isc_throw(TypeError, elemName + " config element must be a list");
}
}
@@ -86,10 +92,10 @@ installListenAddresses(const AddressList& newAddresses,
isc::asiodns::DNSService& service)
{
try {
- dlog("Setting listen addresses:");
+ LOG_DEBUG(logger, DBG_TRACE_BASIC, SRVCOMM_SET_LISTEN);
BOOST_FOREACH(const AddressPair& addr, newAddresses) {
- dlog(" " + addr.first + ":" +
- boost::lexical_cast<string>(addr.second));
+ LOG_DEBUG(logger, DBG_TRACE_VALUES, SRVCOMM_ADDRESS_VALUE).
+ arg(addr.first).arg(addr.second);
}
setAddresses(service, newAddresses);
addressStore = newAddresses;
@@ -108,13 +114,12 @@ installListenAddresses(const AddressList& newAddresses,
* user will get error info, command control can be used to set new
* address. So we just catch the exception without propagating outside
*/
- dlog(string("Unable to set new address: ") + e.what(), true);
+ LOG_ERROR(logger, SRVCOMM_ADDRESS_FAIL).arg(e.what());
try {
setAddresses(service, addressStore);
}
catch (const exception& e2) {
- dlog("Unable to recover from error;", true);
- dlog(string("Rollback failed with: ") + e2.what(), true);
+ LOG_FATAL(logger, SRVCOMM_ADDRESS_UNRECOVERABLE).arg(e2.what());
}
//Anyway the new configure has problem, we need to notify configure
//manager the new configure doesn't work
diff --git a/src/lib/server_common/server_common_messages.mes b/src/lib/server_common/server_common_messages.mes
new file mode 100644
index 0000000..5fbbb0b
--- /dev/null
+++ b/src/lib/server_common/server_common_messages.mes
@@ -0,0 +1,73 @@
+# Copyright (C) 2011 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.
+
+$NAMESPACE isc::server_common
+
+# \brief Messages for the server_common library
+
+% SRVCOMM_ADDRESSES_NOT_LIST the address and port specification is not a list in %1
+This points to an error in configuration. What was supposed to be a list of
+IP address - port pairs isn't a list at all but something else.
+
+% SRVCOMM_ADDRESS_FAIL failed to listen on addresses (%1)
+The server failed to bind to one of the address/port pair it should according
+to configuration, for reason listed in the message (usually because that pair
+is already used by other service or missing privileges). The server will try
+to recover and bind the address/port pairs it was listening to before (if any).
+
+% SRVCOMM_ADDRESS_MISSING address specification is missing "address" or "port" element in %1
+This points to an error in configuration. An address specification in the
+configuration is missing either an address or port and so cannot be used. The
+specification causing the error is given in the message.
+
+% SRVCOMM_ADDRESS_TYPE address specification type is invalid in %1
+This points to an error in configuration. An address specification in the
+configuration malformed. The specification causing the error is given in the
+message. A valid specification contains an address part (which must be a string
+and must represent a valid IPv4 or IPv6 address) and port (which must be an
+integer in the range valid for TCP/UDP ports on your system).
+
+% SRVCOMM_ADDRESS_UNRECOVERABLE failed to recover original addresses also (%2)
+The recovery of old addresses after SRVCOMM_ADDRESS_FAIL also failed for
+the reason listed.
+
+The condition indicates problems with the server and/or the system on
+which it is running. The server will continue running to allow
+reconfiguration, but will not be listening on any address or port until
+an administrator does so.
+
+% SRVCOMM_ADDRESS_VALUE address to set: %1#%2
+Debug message. This lists one address and port value of the set of
+addresses we are going to listen on (eg. there will be one log message
+per pair). This appears only after SRVCOMM_SET_LISTEN, but might
+be hidden, as it has higher debug level.
+
+% SRVCOMM_KEYS_DEINIT deinitializing TSIG keyring
+Debug message indicating that the server is deinitializing the TSIG keyring.
+
+% SRVCOMM_KEYS_INIT initializing TSIG keyring
+Debug message indicating that the server is initializing the global TSIG
+keyring. This should be seen only at server start.
+
+% SRVCOMM_KEYS_UPDATE updating TSIG keyring
+Debug message indicating new keyring is being loaded from configuration (either
+on startup or as a result of configuration update).
+
+% SRVCOMM_PORT_RANGE port out of valid range (%1 in %2)
+This points to an error in configuration. The port in an address
+specification is outside the valid range of 0 to 65535.
+
+% SRVCOMM_SET_LISTEN setting addresses to listen to
+Debug message, noting that the server is about to start listening on a
+different set of IP addresses and ports than before.
diff --git a/src/lib/server_common/tests/Makefile.am b/src/lib/server_common/tests/Makefile.am
index 3c061c2..5bc6586 100644
--- a/src/lib/server_common/tests/Makefile.am
+++ b/src/lib/server_common/tests/Makefile.am
@@ -38,6 +38,7 @@ run_unittests_LDADD += $(top_builddir)/src/lib/server_common/libserver_common.la
run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
run_unittests_LDADD += $(top_builddir)/src/lib/asiodns/libasiodns.la
run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
+run_unittests_LDADD += $(top_builddir)/src/lib/log/liblog.la
run_unittests_LDADD += $(top_builddir)/src/lib/acl/libacl.la
run_unittests_LDADD += $(top_builddir)/src/lib/util/libutil.la
run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
diff --git a/src/lib/server_common/tests/run_unittests.cc b/src/lib/server_common/tests/run_unittests.cc
index b982ef3..860cb77 100644
--- a/src/lib/server_common/tests/run_unittests.cc
+++ b/src/lib/server_common/tests/run_unittests.cc
@@ -16,6 +16,7 @@
#include <gtest/gtest.h>
#include <util/unittests/run_all.h>
+#include <log/logger_support.h>
#include <dns/tests/unittest_util.h>
@@ -23,5 +24,7 @@ int
main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
+ isc::log::initLogger();
+
return (isc::util::unittests::run_all());
}
diff --git a/tools/system_messages.py b/tools/system_messages.py
index 6cf3ce9..7b0d60c 100644
--- a/tools/system_messages.py
+++ b/tools/system_messages.py
@@ -58,6 +58,12 @@ SEC_HEADER="""<?xml version="1.0" encoding="UTF-8"?>
<!ENTITY % version SYSTEM "version.ent">
%version;
]>
+<!--
+ This XML document is generated using the system_messages.py tool
+ based on the .mes message files.
+
+ Do not edit this file.
+-->
<book>
<?xml-stylesheet href="bind10-guide.css" type="text/css"?>
More information about the bind10-changes
mailing list