Commit 982f6e4d authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1209] a related bug fix in the python datasrc wrapper:

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).
parent 98104aa8
......@@ -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\
......
......@@ -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());
......
......@@ -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")
......
Supports Markdown
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