Commit f4d9f872 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

sync with trunk


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac221b@2562 e5f2f494-b856-4b98-b285-d166d9295462
parents 538e33c1 ee16d6b5
78. [bug] jinmei
lib/dns: Fixed miscellaneous bugs in the base32 (hex) and hex
(base16) implementation, including incorrect padding handling,
parser failure in decoding with a SunStudio build, missing
validation on the length of encoded hex string. Test cases were
more detailed to identify these bugs and confirm the fix. Also
renamed the incorrect term of "base32" to "base32hex". This
changed the API, but they are not intended to be used outside
libdns++, so we don't consider it a backward incompatible change.
(Trac #256, r2549)
77. [func] zhanglikun
Make error message be more friendly when running cmdctl and it's
already running(listening on same port)(Trac #277, r2540)
76. [bug] jelte
Fixed a bug in the handling of 'remote' config modules (i.e.
modules that peek at the configuration of other modules), where
they answered 'unknown command' to commands for those other
modules. (Trac #278, r2506)
75. [bug] jinmei
Fixed a bug in the sqlite3 data source where temporary strings
could be referenced after destruction. It caused various lookup
failures with SunStudio build. (Trac #288, r2494)
74. [func]* jinmei
Refactored the cc::Session class by introducing an abstract base
class. Test code can use their own derived mock class so that
......
......@@ -4,6 +4,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += -I$(top_builddir)/src/lib/cc
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
AM_CXXFLAGS = $(B10_CXXFLAGS)
......
......@@ -33,7 +33,7 @@
#include <asio_link.h>
#include <auth/auth_srv.h>
#include "common.h"
#include <auth/common.h>
using namespace asio;
using asio::ip::udp;
......
......@@ -5,7 +5,7 @@
"config_data": [
{ "item_name": "database_file",
"item_type": "string",
"item_optional": True,
"item_optional": true,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
}
],
......
......@@ -14,7 +14,7 @@
// $Id$
#include "config.h"
#include <config.h>
#include <sys/types.h>
#include <sys/socket.h>
......@@ -101,7 +101,7 @@ main(int argc, char* argv[]) {
const char* address = NULL;
bool use_ipv4 = true, use_ipv6 = true, cache = true;
while ((ch = getopt(argc, argv, "a:46np:v")) != -1) {
while ((ch = getopt(argc, argv, "46a:np:v")) != -1) {
switch (ch) {
case '4':
// Note that -4 means "ipv4 only", we need to set "use_ipv6" here,
......
......@@ -35,7 +35,7 @@ import os, time, random, re
import getpass
from hashlib import sha1
import csv
import ast
import json
import pwd
import getpass
import traceback
......@@ -568,7 +568,7 @@ class BindCmdInterpreter(Cmd):
else:
parsed_value = None
try:
parsed_value = ast.literal_eval(cmd.params['value'])
parsed_value = json.loads(cmd.params['value'])
except Exception as exc:
# ok could be an unquoted string, interpret as such
parsed_value = cmd.params['value']
......
......@@ -3,4 +3,5 @@
. Add check for the content of key/certificate file
(when cmdctl starts or is configured by bindctl).
. Use only one msgq/session to communicate with other modules?
. Add more test cases, especially about the cases where CmdctlException
is raised
......@@ -441,7 +441,11 @@ class SecureHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer):
CommandControlClass,
idle_timeout = 1200, verbose = False):
'''idle_timeout: the max idle time for login'''
http.server.HTTPServer.__init__(self, server_address, RequestHandlerClass)
try:
http.server.HTTPServer.__init__(self, server_address, RequestHandlerClass)
except socket.error as err:
raise CmdctlException("Error creating server, because: %s \n" % str(err))
self.user_sessions = {}
self.idle_timeout = idle_timeout
self.cmdctl = CommandControlClass(self, verbose)
......@@ -587,20 +591,23 @@ def set_cmd_options(parser):
help="display more about what is going on")
if __name__ == '__main__':
set_signal_handler()
parser = OptionParser(version = __version__)
set_cmd_options(parser)
(options, args) = parser.parse_args()
result = 1 # in case of failure
try:
set_signal_handler()
parser = OptionParser(version = __version__)
set_cmd_options(parser)
(options, args) = parser.parse_args()
run(options.addr, options.port, options.idle_timeout, options.verbose)
except isc.cc.SessionError as se:
result = 0
except isc.cc.SessionError as err:
sys.stderr.write("[b10-cmdctl] Error creating b10-cmdctl, "
"is the command channel daemon running?\n")
"is the command channel daemon running?\n")
except KeyboardInterrupt:
sys.stderr.write("[b10-cmdctl] exit http server\n")
sys.stderr.write("[b10-cmdctl] exit from Cmdctl\n")
except CmdctlException as err:
sys.stderr.write("[b10-cmdctl] " + str(err) + "\n")
if httpd:
httpd.shutdown()
sys.exit(result)
......@@ -6,20 +6,20 @@
{
"item_name": "key_file",
"item_type": "string",
"item_optional": False,
"item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-keyfile.pem'
"item_optional": false,
"item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-keyfile.pem"
},
{
"item_name": "cert_file",
"item_type": "string",
"item_optional": False,
"item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-certfile.pem'
"item_optional": false,
"item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-certfile.pem"
},
{
"item_name": "accounts_file",
"item_type": "string",
"item_optional": False,
"item_default": '@@SYSCONFDIR@@/@PACKAGE@/cmdctl-accounts.csv'
"item_optional": false,
"item_default": "@@SYSCONFDIR@@/@PACKAGE@/cmdctl-accounts.csv"
}
],
"commands": [
......@@ -32,7 +32,7 @@
"command_name": "shutdown",
"command_description": "shutdown cmdctl",
"command_args": []
},
}
]
}
}
......
......@@ -17,6 +17,7 @@
import unittest
import socket
import tempfile
import sys
from cmdctl import *
SPEC_FILE_PATH = '..' + os.sep
......@@ -383,13 +384,31 @@ class MySecureHTTPServer(SecureHTTPServer):
class TestSecureHTTPServer(unittest.TestCase):
def setUp(self):
self.old_stdout = sys.stdout
self.old_stderr = sys.stderr
sys.stdout = open(os.devnull, 'w')
sys.stderr = sys.stdout
self.server = MySecureHTTPServer(('localhost', 8080),
MySecureHTTPRequestHandler,
MyCommandControl, verbose=True)
def tearDown(self):
sys.stdout = self.old_stdout
sys.stderr = self.old_stderr
def test_addr_in_use(self):
server_one = None
try:
server_one = SecureHTTPServer(('localhost', 53531),
MySecureHTTPRequestHandler,
MyCommandControl)
except CmdctlException:
pass
else:
self.assertRaises(CmdctlException, SecureHTTPServer,
('localhost', 53531),
MySecureHTTPRequestHandler, MyCommandControl)
if server_one:
server_one.server_close()
def test_create_user_info(self):
self.server._create_user_info('/local/not-exist')
......
......@@ -24,14 +24,14 @@
#include <string>
#include <iostream>
#include "dns/buffer.h"
#include "dns/name.h"
#include "dns/message.h"
#include "dns/messagerenderer.h"
#include "dns/rrclass.h"
#include "dns/rrtype.h"
#include "dns/rrset.h"
#include "dns/message.h"
#include <dns/buffer.h>
#include <dns/name.h>
#include <dns/message.h>
#include <dns/messagerenderer.h>
#include <dns/rrclass.h>
#include <dns/rrtype.h>
#include <dns/rrset.h>
#include <dns/message.h>
using namespace std;
using namespace isc::dns;
......
......@@ -6,37 +6,37 @@
{
"item_name": "transfers_in",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 10
}
],
"commands": [
{
'command_name': 'retransfer',
"command_description": 'retransfer a single zone without checking zone serial number',
'command_args': [ {
"command_name": "retransfer",
"command_description": "retransfer a single zone without checking zone serial number",
"command_args": [ {
"item_name": "zone_name",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
},
{
"item_name": "master",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": ""
},
{
"item_name": "port",
"item_type": "integer",
"item_optional": True,
"item_optional": true,
"item_default": 53
},
{
"item_name": "db_file",
"item_type": "string",
"item_optional": True,
"item_default": '@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3'
"item_optional": true,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
}
]
},
......
......@@ -5,43 +5,43 @@
{
"item_name": "transfers_out",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 10
},
{
"item_name": "db_file",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3"
},
{
"item_name": "log_name",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "Xfrout"
},
{
"item_name": "log_file",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "@@LOCALSTATEDIR@@/@PACKAGE@/log/Xfrout.log"
},
{
"item_name": "log_severity",
"item_type": "string",
"item_optional": False,
"item_optional": false,
"item_default": "debug"
},
{
"item_name": "log_versions",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 5
},
{
"item_name": "log_max_bytes",
"item_type": "integer",
"item_optional": False,
"item_optional": false,
"item_default": 1048576
}
],
......
......@@ -14,9 +14,9 @@
// $Id$
#include "config.h"
#include <config.h>
#include "data.h"
#include <cc/data.h>
#include <cassert>
#include <climits>
......
......@@ -23,8 +23,8 @@
#include <exceptions/exceptions.h>
#include "data.h"
#include "session_config.h"
#include <cc/data.h>
#include <cc/session_config.h>
namespace asio {
class io_service;
......
......@@ -14,7 +14,7 @@
// $Id: data_unittests.cc 1899 2010-05-21 12:03:59Z jelte $
#include "config.h"
#include <config.h>
// for some IPC/network system calls in asio/detail/pipe_select_interrupter.hpp
#include <unistd.h>
......
......@@ -51,3 +51,4 @@ EXTRA_DIST += testdata/spec24.spec
EXTRA_DIST += testdata/spec25.spec
EXTRA_DIST += testdata/spec26.spec
EXTRA_DIST += testdata/spec27.spec
EXTRA_DIST += testdata/spec28.spec
......@@ -20,7 +20,7 @@
// react on config change announcements)
//
#include "config.h"
#include <config.h>
#include <stdexcept>
#include <stdlib.h>
......@@ -40,8 +40,7 @@
#include <cc/session.h>
#include <exceptions/exceptions.h>
#include "ccsession.h"
#include "config.h"
#include <config/ccsession.h>
using namespace std;
......@@ -300,8 +299,8 @@ ModuleCCSession::checkCommand()
ElementPtr answer;
try {
std::string cmd_str = parseCommand(arg, data);
std::string target_module = routing->get("group")->stringValue();
if (cmd_str == "config_update") {
std::string target_module = routing->get("group")->stringValue();
if (target_module == module_name_) {
answer = handleConfigUpdate(arg);
} else {
......@@ -312,16 +311,22 @@ ModuleCCSession::checkCommand()
return 0;
}
} else {
if (command_handler_) {
answer = command_handler_(cmd_str, arg);
} else {
answer = createAnswer(1, "Command given but no command handler for module");
if (target_module == module_name_) {
if (command_handler_) {
answer = command_handler_(cmd_str, arg);
} else {
answer = createAnswer(1, "Command given but no command handler for module");
}
}
}
} catch (CCSessionError re) {
// TODO: Once we have logging and timeouts, we should not
// answer here (potential interference)
answer = createAnswer(1, re.what());
}
session_.reply(routing, answer);
if (!isNull(answer)) {
session_.reply(routing, answer);
}
}
return 0;
......
......@@ -14,7 +14,7 @@
// $Id$
#include "config_data.h"
#include <config/config_data.h>
#include <boost/foreach.hpp>
......
......@@ -13,7 +13,7 @@
// NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
// WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "module_spec.h"
#include <config/module_spec.h>
#include <sstream>
#include <iostream>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment