]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[1209] a related bug fix in the python datasrc wrapper:
authorJINMEI Tatuya <jinmei@isc.org>
Fri, 7 Oct 2011 23:54:55 +0000 (16:54 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Fri, 7 Oct 2011 23:54:55 +0000 (16:54 -0700)
DataSourceClient.get_updater must return None when it cannot find the zone.
Otherwise the returned updater would be incomplete and would subseuqently
cause a disruption (such as program crash).

src/lib/python/isc/datasrc/client_inc.cc
src/lib/python/isc/datasrc/client_python.cc
src/lib/python/isc/datasrc/tests/datasrc_test.py

index 1eba4885b429792ebf02f7217fd630ec282b82b3..9bfedac17fe40a3b9394fabca1f28b9e17928a15 100644 (file)
@@ -110,7 +110,7 @@ Return an updater to make updates to a specific zone.\n\
 The RR class of the zone is the one that the client is expected to\n\
 handle (see the detailed description of this class).\n\
 \n\
-If the specified zone is not found via the client, a NULL pointer will\n\
+If the specified zone is not found via the client, a None object will\n\
 be returned; in other words a completely new zone cannot be created\n\
 using an updater. It must be created beforehand (even if it's an empty\n\
 placeholder) in a way specific to the underlying data source.\n\
index c75e7caff4abd8bdc1b9913954e1fb4e76913cf4..8a3d408eec2fc774d380014e9428d61ccfb75090 100644 (file)
@@ -120,9 +120,12 @@ DataSourceClient_getUpdater(PyObject* po_self, PyObject* args) {
         PyBool_Check(replace_obj)) {
         bool replace = (replace_obj != Py_False);
         try {
-            return (createZoneUpdaterObject(
-                        self->cppobj->getUpdater(PyName_ToName(name_obj),
-                                                 replace)));
+            ZoneUpdaterPtr updater =
+                self->cppobj->getUpdater(PyName_ToName(name_obj), replace);
+            if (!updater) {
+                return (Py_None);
+            }
+            return (createZoneUpdaterObject(updater));
         } catch (const isc::NotImplemented& ne) {
             PyErr_SetString(getDataSourceException("NotImplemented"),
                             ne.what());
index 15ceb805e7c561c71fd58897b872dbbea4662e44..4a7f4eab74c10381779a46e1cf94e316de8927de 100644 (file)
@@ -383,6 +383,11 @@ class DataSrcUpdater(unittest.TestCase):
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
                          rrset.to_text())
 
+    def test_update_for_no_zone(self):
+        dsc = isc.datasrc.DataSourceClient(WRITE_ZONE_DB_FILE)
+        self.assertEqual(None,
+                         dsc.get_updater(isc.dns.Name("notexistent.example"),
+                                         True))
 
 if __name__ == "__main__":
     isc.log.init("bind10")