Browse Source

sync with trunk

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac275@2457 e5f2f494-b856-4b98-b285-d166d9295462
JINMEI Tatuya 15 years ago
parent
commit
1944a7d234

+ 11 - 0
ChangeLog

@@ -1,3 +1,14 @@
+  73.	[bug]		jelte
+  	Fixed a bug where in bindctl, locally changed settings were
+	reset when the list of running modules is updated. (Trac #285,
+	r2452)
+
+  72.	[build]		jinmei
+	Added -R when linking python wrapper modules to libpython when
+	possible.  This helps build BIND 10 on platforms that install
+	libpython whose path is unknown to run-time loader.  NetBSD is a
+	known such platform. (Trac #148, r2427)
+
   71.  [func]		each
   	Add "-a" (address) option to bind10 to specify an address for
 	the auth server to listen on.

+ 35 - 7
configure.ac

@@ -18,6 +18,20 @@ AC_LANG([C++])
 AM_CONDITIONAL(USE_GXX, test "X${GXX}" = "Xyes")
 AC_CHECK_DECL([__SUNPRO_CC], [SUNCXX="yes"], [SUNCXX="no"])
 
+# Linker options
+
+# check -R rather than gcc specific -rpath to be as portable as possible.
+AC_MSG_CHECKING([whether -R flag is available in linker])
+LDFLAGS_SAVED="$LDFLAGS"
+LDFLAGS="$LDFLAGS -R/usr/lib"
+AC_TRY_LINK([],[],
+	[ AC_MSG_RESULT(yes)
+		rpath_available=yes
+	],[ AC_MSG_RESULT(no)
+	rpath_available=no
+	])
+LDFLAGS=$LDFLAGS_SAVED
+
 # OS dependent compiler flags
 case "$host" in
 *-solaris*)
@@ -83,6 +97,20 @@ else
 		AC_MSG_WARN([${PYTHON}-config does not exist or is not executable, so we could not detect python development environment.  Your system may require an additional package (e.g. "python3-dev").  Alternatively, if you are sure you have python headers and libraries, define PYTHON_INCLUDES and PYTHON_LDFLAGS and run this script.])
 	fi
 fi
+
+# Some OSes including NetBSD don't install libpython.so in a well known path.
+# To avoid requiring dynamic library path with our python wrapper loadable
+# modules, we embed the path to the modules when possible.  We do this even
+# when the path is known in the common operational environment (e.g. when
+# it's stored in a common "hint" file) for simplicity.
+if test $rpath_available = yes; then
+	python_rpath=
+	for flag in ${PYTHON_LDFLAGS}; do
+		python_rpath="${python_rpath} `echo $flag | sed -ne 's/^\(\-L\)/-R/p'`"
+	done
+	PYTHON_LDFLAGS="${PYTHON_LDFLAGS} ${python_rpath}"
+fi
+
 AC_SUBST(PYTHON_INCLUDES)
 AC_SUBST(PYTHON_LDFLAGS)
 
@@ -91,9 +119,7 @@ CPPFLAGS="$CPPFLAGS ${PYTHON_INCLUDES}"
 AC_CHECK_HEADERS([Python.h],, AC_MSG_ERROR([Missing Python.h]))
 CPPFLAGS="$CPPFLAGS_SAVED"
 
-
-# Check for python library (not absolutely mandatory, but needed for
-# Boost.Python when we use it.  See below.)
+# Check for python library.  Needed for Python-wrapper libraries.
 LDFLAGS_SAVED="$LDFLAGS"
 LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS"
 python_bin="python${PYTHON_VERSION}"
@@ -102,6 +128,7 @@ if test $python_lib != "no"; then
 	PYTHON_LIB="-l$python_lib"
 fi
 AC_SUBST(PYTHON_LIB)
+LDFLAGS=$LDFLAGS_SAVED
 
 # TODO: check for _sqlite3.py module
 
@@ -143,6 +170,7 @@ namespace isc {class Bar {Foo foo_;};} ],,
 	 B10_CXXFLAGS="$B10_CXXFLAGS -Werror"],
 	[AC_MSG_RESULT(yes)])
 CXXFLAGS="$CXXFLAGS_SAVED"
+
 fi				dnl GXX = yes
 
 AM_CONDITIONAL(GCC_WERROR_OK, test $werror_ok = 1)
@@ -236,8 +264,6 @@ AC_HELP_STRING([--with-boost-lib=PATH],
    fi])
 AC_SUBST(BOOST_LDFLAGS)
 
-# Check availability of the Boost Python library
-
 #
 # Check availability of gtest, which will be used for unit tests.
 #
@@ -487,8 +513,10 @@ Flags:
   CXXFLAGS:      $CXXFLAGS
   B10_CXXFLAGS:  $B10_CXXFLAGS
 dnl includes too
-  Boost Python:  $BOOST_PYTHON_LIB
-  SQLite:	 $SQLITE_CFLAGS
+  Python:        ${PYTHON_INCLUDES}
+                 ${PYTHON_LDFLAGS}
+                 ${PYTHON_LIB}
+  SQLite:        $SQLITE_CFLAGS
                  $SQLITE_LIBS
 
 Features:

+ 6 - 2
src/bin/bindctl/bindcmd.py

@@ -102,7 +102,8 @@ class BindCmdInterpreter(Cmd):
         self.conn = ValidatedHTTPSConnection(self.server_port,
                                              ca_certs=pem_file)
         self.session_id = self._get_session_id()
-
+        self.config_data = None
+        
     def _get_session_id(self):
         '''Generate one session id for the connection. '''
         rand = os.urandom(16)
@@ -252,7 +253,10 @@ class BindCmdInterpreter(Cmd):
         should be called before interpreting command line or complete-key
         is entered. This may not be the best way to keep bindctl
         and cmdctl share same modules information, but it works.'''
-        self.config_data = isc.config.UIModuleCCSession(self)
+        if self.config_data is not None:
+            self.config_data.update_specs_and_config()
+        else:
+            self.config_data = isc.config.UIModuleCCSession(self)
         self._update_commands()
 
     def precmd(self, line):

+ 8 - 1
src/bin/xfrout/xfrout.py.in

@@ -79,10 +79,17 @@ class XfroutSession(BaseRequestHandler):
         sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
         try:
             self.dns_xfrout_start(sock, msgdata)
+            #TODO, avoid catching all exceptions
         except Exception as e:
             self._log.log_message("error", str(e))
 
-        sock.shutdown(socket.SHUT_RDWR)
+        try:
+            sock.shutdown(socket.SHUT_RDWR)
+        except socket.error:
+            # Avoid socket error caused by shutting down 
+            # one non-connected socket.
+            pass
+
         sock.close()
         os.close(fd)
         pass

+ 6 - 6
src/lib/datasrc/tests/sqlite3_unittest.cc

@@ -376,8 +376,8 @@ TEST_F(Sqlite3DataSourceTest, reOpen) {
 
     DataSrcMatch match(www_name, rrclass);
     data_source.findClosestEnclosure(match);
-    EXPECT_EQ(NULL, match.getEnclosingZone());
-    EXPECT_EQ(NULL, match.getDataSource());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getEnclosingZone());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getDataSource());
 }
 
 TEST_F(Sqlite3DataSourceTest, openFail) {
@@ -441,15 +441,15 @@ TEST_F(Sqlite3DataSourceTest, findClosestEnclosureAtDelegation) {
 TEST_F(Sqlite3DataSourceTest, findClosestEnclosureNoMatch) {
     DataSrcMatch match(nomatch_name, rrclass);
     data_source.findClosestEnclosure(match);
-    EXPECT_EQ(NULL, match.getEnclosingZone());
-    EXPECT_EQ(NULL, match.getDataSource());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getEnclosingZone());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getDataSource());
 }
 
 TEST_F(Sqlite3DataSourceTest, findClosestClassMismatch) {
     DataSrcMatch match(nomatch_name, rrclass);
     data_source.findClosestEnclosure(match);
-    EXPECT_EQ(NULL, match.getEnclosingZone());
-    EXPECT_EQ(NULL, match.getDataSource());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getEnclosingZone());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getDataSource());
 }
 
 // If the query class is ANY, the result should be the same as the case where

+ 4 - 4
src/lib/datasrc/tests/static_unittest.cc

@@ -214,8 +214,8 @@ TEST_F(StaticDataSourceTest, findClosestEnclosureForVersionClassAny) {
 TEST_F(StaticDataSourceTest, findClosestEnclosureForVersionClassMismatch) {
     DataSrcMatch match(version_name, RRClass::IN());
     data_source.findClosestEnclosure(match);
-    EXPECT_EQ(NULL, match.getEnclosingZone());
-    EXPECT_EQ(NULL, match.getDataSource());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getEnclosingZone());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getDataSource());
 }
 
 TEST_F(StaticDataSourceTest, findClosestEnclosureForVersionPartial) {
@@ -242,8 +242,8 @@ TEST_F(StaticDataSourceTest, findClosestEnclosureForAuthorsPartial) {
 TEST_F(StaticDataSourceTest, findClosestEnclosureNoMatch) {
     DataSrcMatch match(nomatch_name, rrclass);
     data_source.findClosestEnclosure(match);
-    EXPECT_EQ(NULL, match.getEnclosingZone());
-    EXPECT_EQ(NULL, match.getDataSource());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getEnclosingZone());
+    EXPECT_EQ(static_cast<void*>(NULL), match.getDataSource());
 }
 
 TEST_F(StaticDataSourceTest, findRRsetVersionTXT) {

+ 9 - 4
src/lib/dns/python/rrttl_python.cc

@@ -14,7 +14,11 @@
 
 // $Id$
 
+#include <vector>
+
 #include <dns/rrttl.h>
+
+using namespace std;
 using namespace isc::dns;
 
 //
@@ -160,14 +164,15 @@ RRTTL_init(s_RRTTL* self, PyObject* args) {
             PyErr_Clear();
             self->rrttl = new RRTTL(i);
             return (0);
-        } else if (PyArg_ParseTuple(args, "O", &bytes) && PySequence_Check(bytes)) {
+        } else if (PyArg_ParseTuple(args, "O", &bytes) &&
+                   PySequence_Check(bytes)) {
             Py_ssize_t size = PySequence_Size(bytes);
-            uint8_t data[size];
-            int result = readDataFromSequence(data, size, bytes);
+            vector<uint8_t> data(size);
+            int result = readDataFromSequence(&data[0], size, bytes);
             if (result != 0) {
                 return (result);
             }
-            InputBuffer ib(data, size);
+            InputBuffer ib(&data[0], size);
             self->rrttl = new RRTTL(ib);
             PyErr_Clear();
             return (0);

+ 7 - 3
src/lib/dns/python/rrtype_python.cc

@@ -14,7 +14,11 @@
 
 // $Id$
 
+#include <vector>
+
 #include <dns/rrtype.h>
+
+using namespace std;
 using namespace isc::dns;
 
 //
@@ -203,12 +207,12 @@ RRType_init(s_RRType* self, PyObject* args) {
             return (0);
         } else if (PyArg_ParseTuple(args, "O", &bytes) && PySequence_Check(bytes)) {
             Py_ssize_t size = PySequence_Size(bytes);
-            uint8_t data[size];
-            int result = readDataFromSequence(data, size, bytes);
+            vector<uint8_t> data(size);
+            int result = readDataFromSequence(&data[0], size, bytes);
             if (result != 0) {
                 return (result);
             }
-            InputBuffer ib(data, size);
+            InputBuffer ib(&data[0], size);
             self->rrtype = new RRType(ib);
             PyErr_Clear();
             return (0);

+ 2 - 4
src/lib/dns/tests/base64_unittest.cc

@@ -54,8 +54,7 @@ decodeCheck(const string& input_string, vector<uint8_t>& output,
     EXPECT_EQ(expected, string(&output[0], &output[0] + output.size()));
 }
 
-TEST_F(Base64Test, decode)
-{
+TEST_F(Base64Test, decode) {
     for (vector<StringPair>::const_iterator it = test_sequence.begin();
          it != test_sequence.end();
          ++it) {
@@ -82,8 +81,7 @@ TEST_F(Base64Test, decode)
     EXPECT_THROW(decodeBase64("Zm==", decoded_data), BadBase64String);
 }
 
-TEST_F(Base64Test, encode)
-{
+TEST_F(Base64Test, encode) {
     for (vector<StringPair>::const_iterator it = test_sequence.begin();
          it != test_sequence.end();
          ++it) {

+ 5 - 0
src/lib/python/isc/config/ccsession.py

@@ -323,6 +323,10 @@ class UIModuleCCSession(MultiConfigData):
         for module in specs.keys():
             self.set_specification(isc.config.ModuleSpec(specs[module]))
 
+    def update_specs_and_config(self):
+        self.request_specifications();
+        self.request_current_config();
+
     def request_current_config(self):
         """Requests the current configuration from the configuration
            manager through b10-cmdctl, and stores those as CURRENT"""
@@ -331,6 +335,7 @@ class UIModuleCCSession(MultiConfigData):
             raise ModuleCCSessionError("Bad config version")
         self._set_current_config(config)
 
+
     def add_value(self, identifier, value_str):
         """Add a value to a configuration list. Raises a DataTypeError
            if the value does not conform to the list_item_spec field

+ 1 - 1
src/lib/python/isc/datasrc/master.py

@@ -228,7 +228,7 @@ class MasterFile:
             percent = (self.__cur * 100)/self.__filesize
 
         sys.stdout.write("\r" + (80 * " "))
-        sys.stdout.write("\r%d RR(s) loaded in %d second(s) (%.2f%% of %s%s)"\
+        sys.stdout.write("\r%d RR(s) loaded in %.2f second(s) (%.2f%% of %s%s)"\
                 % (MasterFile.__records_num, interval, percent, MasterFile.__file_type, self.__datafile))
 
     def __del__(self):

+ 8 - 8
src/lib/python/isc/log/log.py

@@ -70,7 +70,7 @@ class NSFileLogHandler(logging.handlers.RotatingFileHandler):
             predetermined log file size
         """
         dir = os.path.split(file_name)
-        if(os.path.exists(dir[0])):
+        if (os.path.exists(dir[0])):
             self.baseFilename = file_name
         self.maxBytes = max_bytes
         self.backupCount = backup_count
@@ -158,7 +158,7 @@ class NSLogger(logging.getLoggerClass()):
             max_bytes : limit log growth
             backup_count : max backup count
         """
-        if(log_file != 0  and log_file != ''):
+        if (log_file != 0  and log_file != ''):
             try:
                 self._file_handler = NSFileLogHandler(filename = log_file,
                                           maxBytes = max_bytes, backupCount = backup_count)
@@ -194,7 +194,7 @@ class NSLogger(logging.getLoggerClass()):
         configuration, or add it to the logger.
         """
         if (self._file_handler in self.handlers):
-            if(log_file != 0 and log_file != ''):
+            if (log_file != 0 and log_file != ''):
                 self._file_handler.update_config(log_file, backup_count, max_bytes)
             else:
                 """If log file is empty, the handler will be removed."""
@@ -208,19 +208,19 @@ class NSLogger(logging.getLoggerClass()):
          """Get config data from module configuration"""
          
          log_file_str = config_data.get('log_file')
-         if(log_file_str):
+         if (log_file_str):
             self._log_file = log_file_str
          
          severity_str = config_data.get('log_severity')
-         if(severity_str):
+         if (severity_str):
              self._severity = severity_str
 
          versions_str = config_data.get('log_versions')
-         if(versions_str):
+         if (versions_str):
              self._versions = int(versions_str)
 
          max_bytes_str = config_data.get('log_max_bytes')
-         if(max_bytes_str):
+         if (max_bytes_str):
              self._max_bytes = int(max_bytes_str)
 
     def update_config(self, config_data):
@@ -231,7 +231,7 @@ class NSLogger(logging.getLoggerClass()):
         self._get_config(config_data)
 
         logLevel = LEVELS.get(self._severity, logging.NOTSET)
-        if(logLevel != self.getEffectiveLevel()):
+        if (logLevel != self.getEffectiveLevel()):
             self.setLevel(logLevel)
         self._update_rotate_handler(self._log_file, self._versions, self._max_bytes)
 

+ 0 - 9
src/lib/xfr/Makefile.am

@@ -17,12 +17,3 @@ libxfr_python_la_LDFLAGS = -module
 libxfr_python_la_SOURCES = fdshare_python.cc fd_share.cc fd_share.h
 libxfr_python_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
 libxfr_python_la_CXXFLAGS = $(AM_CXXFLAGS)
-
-#bind10_xfr_la_LDFLAGS = $(BOOST_LDFLAGS) $(PYTHON_LDFLAGS)
-
-# Python prefers .so, while some OSes (specifically MacOS) use a different
-# suffix for dynamic objects.  -module is necessary to work this around.
-#bind10_xfr_la_LDFLAGS += -module
-#bind10_xfr_la_LIBADD = $(BOOST_PYTHON_LIB) $(PYTHON_LIB)
-#endif
-