Commit 9efbe64f authored by zhanglikun's avatar zhanglikun
Browse files

[trac661]Add test data file message_fromWire9 to EXTRA_DISTOF

parents 7e385db1 385a9f81
189. [bug] zhang likun
Remove expired message and rrset entries when looking up them
in cache, touch or remove the rrset entry in cache properly
when doing lookup or update.
(Trac #661 git )
188. [bug] zhang likun
Make the rrset trust level ranking algorithm used by
isc::cache::MessageEntry::getRRsetTrustLevel() follow RFC2181
......
SUBDIRS = doc src
SUBDIRS = doc src tests
USE_LCOV=@USE_LCOV@
LCOV=@LCOV@
GENHTML=@GENHTML@
......@@ -77,6 +77,11 @@ cppcheck:
--template '{file}:{line}: check_fail: {message} ({severity},{id})' \
src
# system tests
systest:
cd tests/system; \
sh $(abs_srcdir)/tests/system/runall.sh
#### include external sources in the distributed tarball:
EXTRA_DIST = ext/asio/README
EXTRA_DIST += ext/asio/asio/local/stream_protocol.hpp
......
......@@ -164,8 +164,6 @@ source tree:
(Which will use the modules and configurations also from the source
tree.)
The server will listen on port 5300 for DNS requests.
CONFIGURATION
Commands can be given through the bindctl tool.
......
......@@ -583,6 +583,12 @@ if test "X$ac_cv_have_devpoll" = "Xyes" -a "X$GXX" = "Xyes"; then
CPPFLAGS="$CPPFLAGS -DASIO_DISABLE_DEV_POLL=1"
fi
#
# Perl is optional; it is used only by some of the system test scripts.
#
AC_PATH_PROGS(PERL, perl5 perl)
AC_SUBST(PERL)
AC_ARG_ENABLE(man, [AC_HELP_STRING([--enable-man],
[regenerate man pages [default=no]])], enable_man=yes, enable_man=no)
......@@ -683,6 +689,8 @@ AC_CONFIG_FILES([Makefile
src/lib/cache/tests/Makefile
src/lib/server_common/Makefile
src/lib/server_common/tests/Makefile
tests/Makefile
tests/system/Makefile
])
AC_OUTPUT([doc/version.ent
src/bin/cfgmgr/b10-cfgmgr.py
......@@ -712,9 +720,10 @@ AC_OUTPUT([doc/version.ent
src/bin/stats/tests/stats_test
src/bin/bind10/bind10.py
src/bin/bind10/tests/bind10_test
src/bin/bind10/tests/bind10_test.py
src/bin/bind10/run_bind10.sh
src/bin/bindctl/run_bindctl.sh
src/bin/bindctl/bindctl-source.py
src/bin/bindctl/bindctl_main.py
src/bin/bindctl/tests/bindctl_test
src/bin/loadzone/run_loadzone.sh
src/bin/loadzone/tests/correct/correct_test.sh
......@@ -739,6 +748,10 @@ AC_OUTPUT([doc/version.ent
src/lib/cc/session_config.h.pre
src/lib/cc/tests/session_unittests_config.h
src/lib/log/tests/run_time_init_test.sh
tests/system/conf.sh
tests/system/glue/setup.sh
tests/system/glue/nsx1/b10-config.db
tests/system/bindctl/nsx1/b10-config.db.template
], [
chmod +x src/bin/cmdctl/run_b10-cmdctl.sh
chmod +x src/bin/xfrin/run_b10-xfrin.sh
......@@ -763,6 +776,7 @@ AC_OUTPUT([doc/version.ent
chmod +x src/lib/dns/gen-rdatacode.py
chmod +x src/lib/dns/tests/testdata/gen-wiredata.py
chmod +x src/lib/log/tests/run_time_init_test.sh
chmod +x tests/system/conf.sh
])
AC_OUTPUT
......
......@@ -336,14 +336,6 @@ var/
</simpara>
</note>
<note>
<simpara>
The development prototype of the b10-auth server listens on
0.0.0.0 (all interfaces) port 5300. (This is not the standard
domain service port.)
</simpara>
</note>
<para>
To quickly get started with BIND 10, follow these steps.
</para>
......@@ -397,7 +389,7 @@ var/
<listitem>
<para>Test it; for example:
<screen>$ <userinput>dig @127.0.0.1 -p 5300 -c CH -t TXT authors.bind</userinput></screen>
<screen>$ <userinput>dig @127.0.0.1 -c CH -t TXT authors.bind</userinput></screen>
</para>
</listitem>
......@@ -1044,11 +1036,6 @@ TODO
process.
</para>
<note><simpara>
This development prototype release listens on all interfaces
and the non-standard port 5300.
</simpara></note>
<section>
<title>Server Configurations</title>
......
......@@ -63,12 +63,12 @@
"item_optional": false,
"item_default": [
{
"address": "::1",
"port": 5300
"address": "::",
"port": 53
},
{
"address": "127.0.0.1",
"port": 5300
"address": "0.0.0.0",
"port": 53
}
],
"list_item_spec": {
......@@ -87,7 +87,7 @@
"item_name": "port",
"item_type": "integer",
"item_optional": false,
"item_default": 5300
"item_default": 53
}
]
}
......
......@@ -2,12 +2,12 @@
.\" Title: b10-auth
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: January 19, 2011
.\" Date: March 8, 2011
.\" Manual: BIND10
.\" Source: BIND10
.\" Language: English
.\"
.TH "B10\-AUTH" "8" "January 19, 2011" "BIND10" "BIND10"
.TH "B10\-AUTH" "8" "March 8, 2011" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
......@@ -22,7 +22,7 @@
b10-auth \- Authoritative DNS server
.SH "SYNOPSIS"
.HP \w'\fBb10\-auth\fR\ 'u
\fBb10\-auth\fR [\fB\-4\fR] [\fB\-6\fR] [\fB\-a\ \fR\fB\fIaddress\fR\fR] [\fB\-n\fR] [\fB\-p\ \fR\fB\fInumber\fR\fR] [\fB\-u\ \fR\fB\fIusername\fR\fR] [\fB\-v\fR]
\fBb10\-auth\fR [\fB\-n\fR] [\fB\-u\ \fR\fB\fIusername\fR\fR] [\fB\-v\fR]
.SH "DESCRIPTION"
.PP
The
......@@ -42,55 +42,11 @@ It receives its configurations from
.PP
The arguments are as follows:
.PP
\fB\-4\fR
.RS 4
Enables IPv4 only mode\&. This switch may not be used with
\fB\-6\fR
nor
\fB\-a\fR\&. By default, it listens on both IPv4 and IPv6 (if capable)\&.
.RE
.PP
\fB\-6\fR
.RS 4
Enables IPv6 only mode\&. This switch may not be used with
\fB\-4\fR
nor
\fB\-a\fR\&. By default, it listens on both IPv4 and IPv6 (if capable)\&.
.RE
.PP
\fB\-a \fR\fB\fIaddress\fR\fR
.RS 4
The IPv4 or IPv6 address to listen on\&. This switch may not be used with
\fB\-4\fR
nor
\fB\-6\fR\&. The default is to listen on all addresses\&. (This is a short term workaround\&. This argument may change\&.)
.RE
.PP
\fB\-n\fR
.RS 4
Do not cache answers in memory\&. The default is to use the cache for faster responses\&. The cache keeps the most recent 30,000 answers (positive and negative) in memory for 30 seconds (instead of querying the data source, such as SQLite3 database, each time)\&.
.RE
.PP
\fB\-p \fR\fB\fInumber\fR\fR
.RS 4
The port number it listens on\&. The default is 5300\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
The Y1 prototype runs on all interfaces and on this nonstandard port\&.
.sp .5v
.RE
.RE
.PP
\fB\-u \fR\fB\fIusername\fR\fR
.RS 4
The user name of the
......@@ -114,6 +70,18 @@ defines the path to the SQLite3 zone file when using the sqlite datasource\&. Th
/usr/local/var/bind10\-devel/zone\&.sqlite3\&.
.PP
\fIlisten_on\fR
is a list of addresses and ports for
\fBb10\-auth\fR
to listen on\&. The list items are the
\fIaddress\fR
string and
\fIport\fR
number\&. By default,
\fBb10\-auth\fR
listens on port 53 on the IPv6 (::) and IPv4 (0\&.0\&.0\&.0) wildcard addresses\&.
.PP
\fIdatasources\fR
configures data sources\&. The list items include:
\fItype\fR
......
......@@ -20,7 +20,7 @@
<refentry>
<refentryinfo>
<date>January 19, 2011</date>
<date>March 8, 2011</date>
</refentryinfo>
<refmeta>
......@@ -131,6 +131,15 @@
<filename>/usr/local/var/bind10-devel/zone.sqlite3</filename>.
</para>
<para>
<varname>listen_on</varname> is a list of addresses and ports for
<command>b10-auth</command> to listen on.
The list items are the <varname>address</varname> string
and <varname>port</varname> number.
By default, <command>b10-auth</command> listens on port 53
on the IPv6 (::) and IPv4 (0.0.0.0) wildcard addresses.
</para>
<para>
<varname>datasources</varname> configures data sources.
The list items include:
......
......@@ -122,7 +122,13 @@ main(int argc, char* argv[]) {
ModuleCCSession* config_session = NULL;
string xfrout_socket_path;
if (getenv("B10_FROM_BUILD") != NULL) {
xfrout_socket_path = string(getenv("B10_FROM_BUILD")) + "/auth_xfrout_conn";
if (getenv("B10_FROM_SOURCE_LOCALSTATEDIR")) {
xfrout_socket_path = string("B10_FROM_SOURCE_LOCALSTATEDIR") +
"/auth_xfrout_conn";
} else {
xfrout_socket_path = string(getenv("B10_FROM_BUILD")) +
"/auth_xfrout_conn";
}
} else {
xfrout_socket_path = UNIX_SOCKET_FILE;
}
......
......@@ -2,12 +2,12 @@
.\" Title: bind10
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: July 29, 2010
.\" Date: February 22, 2011
.\" Manual: BIND10
.\" Source: BIND10
.\" Language: English
.\"
.TH "BIND10" "8" "July 29, 2010" "BIND10" "BIND10"
.TH "BIND10" "8" "February 22, 2011" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
......@@ -22,7 +22,7 @@
bind10 \- BIND 10 boss process
.SH "SYNOPSIS"
.HP \w'\fBbind10\fR\ 'u
\fBbind10\fR [\fB\-a\ \fR\fB\fIaddress\fR\fR] [\fB\-m\ \fR\fB\fIfile\fR\fR] [\fB\-n\fR] [\fB\-p\ \fR\fB\fInumber\fR\fR] [\fB\-u\ \fR\fB\fIuser\fR\fR] [\fB\-v\fR] [\fB\-\-address\ \fR\fB\fIaddress\fR\fR] [\fB\-\-msgq\-socket\-file\ \fR\fB\fIfile\fR\fR] [\fB\-\-no\-cache\fR] [\fB\-\-port\ \fR\fB\fInumber\fR\fR] [\fB\-\-user\ \fR\fB\fIuser\fR\fR] [\fB\-\-pretty\-name\ \fR\fB\fIname\fR\fR] [\fB\-\-verbose\fR]
\fBbind10\fR [\fB\-m\ \fR\fB\fIfile\fR\fR] [\fB\-n\fR] [\fB\-u\ \fR\fB\fIuser\fR\fR] [\fB\-v\fR] [\fB\-\-msgq\-socket\-file\ \fR\fB\fIfile\fR\fR] [\fB\-\-no\-cache\fR] [\fB\-\-user\ \fR\fB\fIuser\fR\fR] [\fB\-\-pretty\-name\ \fR\fB\fIname\fR\fR] [\fB\-\-verbose\fR]
.SH "DESCRIPTION"
.PP
The
......@@ -32,13 +32,6 @@ daemon starts up other BIND 10 required daemons\&. It handles restarting of exit
.PP
The arguments are as follows:
.PP
\fB\-a\fR \fIaddress\fR, \fB\-\-address\fR \fIaddress\fR
.RS 4
The IPv4 or IPv6 address for the
\fBb10-auth\fR(8)
daemon to listen on\&. The default is to listen on all addresses\&. (This is a short term workaround\&. This argument may change\&.)
.RE
.PP
\fB\-m\fR \fIfile\fR, \fB\-\-msgq\-socket\-file\fR \fIfile\fR
.RS 4
The UNIX domain socket file for the
......@@ -54,28 +47,6 @@ Disables the hot\-spot caching used by the
daemon\&.
.RE
.PP
\fB\-p\fR \fInumber\fR, \fB\-\-port\fR \fInumber\fR
.RS 4
The port number for the
\fBb10-auth\fR(8)
daemon to listen on\&. The default is 5300\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
This prototype release uses a non\-default port for domain service\&.
.sp .5v
.RE
.RE
.PP
\fB\-u\fR \fIuser\fR, \fB\-\-user\fR \fIname\fR
.RS 4
The username for
......@@ -125,5 +96,5 @@ The
daemon was initially designed by Shane Kerr of ISC\&.
.SH "COPYRIGHT"
.br
Copyright \(co 2010 Internet Systems Consortium, Inc. ("ISC")
Copyright \(co 2011 Internet Systems Consortium, Inc. ("ISC")
.br
......@@ -785,6 +785,35 @@ def process_rename(option, opt_str, value, parser):
"""Function that renames the process if it is requested by a option."""
isc.util.process.rename(value)
def dump_pid(pid_file):
"""
Dump the PID of the current process to the specified file. If the given
file is None this function does nothing. If the file already exists,
the existing content will be removed. If a system error happens in
creating or writing to the file, the corresponding exception will be
propagated to the caller.
"""
if pid_file is None:
return
f = open(pid_file, "w")
f.write('%d\n' % os.getpid())
f.close()
def unlink_pid_file(pid_file):
"""
Remove the given file, which is basically expected to be the PID file
created by dump_pid(). The specified may or may not exist; if it
doesn't this function does nothing. Other system level errors in removing
the file will be propagated as the corresponding exception.
"""
if pid_file is None:
return
try:
os.unlink(pid_file)
except OSError as error:
if error.errno is not errno.ENOENT:
raise
def main():
global options
global boss_of_bind
......@@ -805,6 +834,9 @@ def main():
parser.add_option("--pretty-name", type="string", action="callback",
callback=process_rename,
help="Set the process name (displayed in ps, top, ...)")
parser.add_option("--pid-file", dest="pid_file", type="string",
default=None,
help="file to dump the PID of the BIND 10 process")
(options, args) = parser.parse_args()
if args:
parser.print_help()
......@@ -865,6 +897,7 @@ def main():
sys.stderr.write("[bind10] Error on startup: %s\n" % startup_result)
sys.exit(1)
sys.stdout.write("[bind10] BIND 10 started\n")
dump_pid(options.pid_file)
# send "bind10.boot_time" to b10-stats
time.sleep(1) # wait a second
......@@ -918,6 +951,7 @@ def main():
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
boss_of_bind.shutdown()
sys.stdout.write("[bind10] BIND 10 exiting\n");
unlink_pid_file(options.pid_file)
sys.exit(0)
if __name__ == "__main__":
......
from bind10 import ProcessInfo, BoB
from bind10 import ProcessInfo, BoB, dump_pid, unlink_pid_file
# XXX: environment tests are currently disabled, due to the preprocessor
# setup that we have now complicating the environment
......@@ -48,7 +48,7 @@ class TestProcessInfo(unittest.TestCase):
# 'FOO': 'BAR' })
def test_setting_null_stdout(self):
pi = ProcessInfo('Test Process', [ '/bin/echo', 'foo' ],
pi = ProcessInfo('Test Process', [ '/bin/echo', 'foo' ],
dev_null_stdout=True)
os.dup2(self.old_stdout, sys.stdout.fileno())
self.assertEqual(pi.dev_null_stdout, True)
......@@ -412,5 +412,52 @@ class TestStartStopProcessesBob(unittest.TestCase):
bob.config_handler({'start_auth': True, 'start_resolver': True})
class TestPIDFile(unittest.TestCase):
def setUp(self):
self.pid_file = '@builddir@' + os.sep + 'bind10.pid'
if os.path.exists(self.pid_file):
os.unlink(self.pid_file)
def tearDown(self):
if os.path.exists(self.pid_file):
os.unlink(self.pid_file)
def check_pid_file(self):
# dump PID to the file, and confirm the content is correct
dump_pid(self.pid_file)
my_pid = os.getpid()
self.assertEqual(my_pid, int(open(self.pid_file, "r").read()))
def test_dump_pid(self):
self.check_pid_file()
# make sure any existing content will be removed
open(self.pid_file, "w").write('dummy data\n')
self.check_pid_file()
def test_unlink_pid_file_notexist(self):
dummy_data = 'dummy_data\n'
open(self.pid_file, "w").write(dummy_data)
unlink_pid_file("no_such_pid_file")
# the file specified for unlink_pid_file doesn't exist,
# and the original content of the file should be intact.
self.assertEqual(dummy_data, open(self.pid_file, "r").read())
def test_dump_pid_with_none(self):
# Check the behavior of dump_pid() and unlink_pid_file() with None.
# This should be no-op.
dump_pid(None)
self.assertFalse(os.path.exists(self.pid_file))
dummy_data = 'dummy_data\n'
open(self.pid_file, "w").write(dummy_data)
unlink_pid_file(None)
self.assertEqual(dummy_data, open(self.pid_file, "r").read())
def test_dump_pid_failure(self):
# the attempt to open file will fail, which should result in exception.
self.assertRaises(IOError, dump_pid,
'nonexistent_dir' + os.sep + 'bind10.pid')
if __name__ == '__main__':
unittest.main()
......@@ -5,12 +5,13 @@ man_MANS = bindctl.1
EXTRA_DIST = $(man_MANS) bindctl.xml
python_PYTHON = __init__.py bindcmd.py cmdparse.py exception.py moduleinfo.py mycollections.py
python_PYTHON = __init__.py bindcmd.py cmdparse.py exception.py moduleinfo.py \
mycollections.py
pythondir = $(pyexecdir)/bindctl
bindctldir = $(pkgdatadir)
CLEANFILES = bindctl
CLEANFILES = bindctl bindctl_main.pyc
if ENABLE_MAN
......@@ -19,8 +20,8 @@ bindctl.1: bindctl.xml
endif
bindctl: bindctl-source.py
bindctl: bindctl_main.py
$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" \
-e "s|@@SYSCONFDIR@@|@sysconfdir@|" \
-e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" bindctl-source.py >$@
-e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" bindctl_main.py >$@
chmod a+x $@
......@@ -87,7 +87,8 @@ class ValidatedHTTPSConnection(http.client.HTTPSConnection):
class BindCmdInterpreter(Cmd):
"""simple bindctl example."""
def __init__(self, server_port = 'localhost:8080', pem_file = None):
def __init__(self, server_port='localhost:8080', pem_file=None,
csv_file_dir=None):
Cmd.__init__(self)
self.location = ""
self.prompt_end = '> '
......@@ -103,7 +104,12 @@ class BindCmdInterpreter(Cmd):
ca_certs=pem_file)
self.session_id = self._get_session_id()
self.config_data = None
if csv_file_dir is not None:
self.csv_file_dir = csv_file_dir
else:
self.csv_file_dir = pwd.getpwnam(getpass.getuser()).pw_dir + \
os.sep + '.bind10' + os.sep
def _get_session_id(self):
'''Generate one session id for the connection. '''
rand = os.urandom(16)
......@@ -175,9 +181,7 @@ class BindCmdInterpreter(Cmd):
time, username and password saved in 'default_user.csv' will be
used first.
'''
csv_file_dir = pwd.getpwnam(getpass.getuser()).pw_dir
csv_file_dir += os.sep + '.bind10' + os.sep
users = self._get_saved_user_info(csv_file_dir, CSV_FILE_NAME)
users = self._get_saved_user_info(self.csv_file_dir, CSV_FILE_NAME)
for row in users:
param = {'username': row[0], 'password' : row[1]}
try:
......@@ -211,7 +215,8 @@ class BindCmdInterpreter(Cmd):
raise FailToLogin()
if response.status == http.client.OK:
self._save_user_info(username, passwd, csv_file_dir, CSV_FILE_NAME)
self._save_user_info(username, passwd, self.csv_file_dir,
CSV_FILE_NAME)
return True
def _update_commands(self):
......
......@@ -51,6 +51,7 @@
<arg><option>--address <replaceable>address</replaceable></option></arg>
<arg><option>--help</option></arg>
<arg><option>--certificate-chain <replaceable>file</replaceable></option></arg>
<arg><option>--csv-file-dir<replaceable>file</replaceable></option></arg>
<arg><option>--port <replaceable>number</replaceable></option></arg>
<arg><option>--version</option></arg>
</cmdsynopsis>
......@@ -109,6 +110,22 @@
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--csv-file-dir</option><replaceable>file</replaceable>
</term>
<listitem>
<para>
The directory name in which the user/password CSV file
is stored (see AUTHENTICATION).
By default this option doesn't have any value,
in which case the ".bind10" directory under the user's
home directory will be used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-h</option>,
<option>--help</option></term>
......@@ -148,8 +165,10 @@
<para>
The tool will authenticate using a username and password.
On the first successful login, it will save the details to
<filename>~/.bind10/default_user.csv</filename>
a comma-separated-value (CSV) file
which will be used for later uses of <command>bindctl</command>.
The file name is <filename>default_user.csv</filename>
located under the directory specified by the --csv-file-dir option.
</para>
<!-- TODO: mention HTTPS? -->
......
......@@ -111,25 +111,28 @@ def check_addr(option, opt_str, value, parser):
parser.values.addr = value
def set_bindctl_options(parser):
parser.add_option('-p', '--port', dest = 'port', type = 'int',
action = 'callback', callback=check_port,
default = '8080', help = 'port for cmdctl of bind10')
parser.add_option('-p', '--port', dest='port', type='int',
action='callback', callback=check_port,
default='8080', help='port for cmdctl of bind10')
parser.add_option('-a', '--address', dest = 'addr', type = 'string',
action = 'callback', callback=check_addr,
default = '127.0.0.1', help = 'IP address for cmdctl of bind10')
parser.add_option('-a', '--address', dest='addr', type='string',
action='callback', callback=check_addr,
default='127.0.0.1', help='IP address for cmdctl of bind10')
parser.add_option('-c', '--certificate-chain', dest = 'cert_chain',
type = 'string', action = 'store',
help = 'PEM formatted server certificate validation chain file')
parser.add_option('-c', '--certificate-chain', dest='cert_chain',
type='string', action='store',
help='PEM formatted server certificate validation chain file')
parser.add_option('--csv-file-dir', dest='csv_file_dir', type='string',
default=None, action='store',
help='Directory to store the password CSV file')
if __name__ == '__main__':
parser = OptionParser(version = VERSION)
set_bindctl_options(parser)
(options, args) = parser.parse_args()
server_addr = options.addr + ':' + str(options.port)
tool = BindCmdInterpreter(server_addr, pem_file=options.cert_chain)
tool = BindCmdInterpreter(server_addr, pem_file=options.cert_chain,
csv_file_dir=options.csv_file_dir)
prepare_config_commands(tool)
tool.run()