PowerDNS plugin NOTIFY fix
Well here's the thing - i have two powerdns servers acting as a Master < - > Slave. They use different database backends ( for various reasons ) hence i use the Supermaster functionality available in powerdns : http://doc.powerdns.com/slave.html#SUPERMASTER . The basic idea is that Powerdns sends NOTIFY to certain "possible" slaves after a domain is updated or added and they automatically add the zone and configure theirselves as slaves. I noted this wasn't working correctly with ISPConfig, and after some tinkering around i found out that for this to work only the notified_serial column in "domains" table has to be updated with the new serial. Updating the SOA record in the "records" table stops powerdns from sending NOTIFY at all. The code below fixed it. If you have problems again applying the patch, please let me know where i can send it to you over mail.
Index: server/plugins-available/powerdns_plugin.inc.php
--- server/plugins-available/powerdns_plugin.inc.php (revision 1409) +++ server/plugins-available/powerdns_plugin.inc.php (working copy) @@ -130,7 +130,6 @@ $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$ispconfig_id); $serial_id = $serial["serial"]; $app->db->query("INSERT INTO powerdns.domains (name, type, notified_serial, ispconfig_id) VALUES ('$origin', 'MASTER', $serial_id, $ispconfig_id)");
-
//$app->db->query("INSERT INTO powerdns.domains (name, type, ispconfig_id) VALUES ('$origin', 'NATIVE', $ispconfig_id)"); $zone_id = mysql_insert_id(); if(substr($data["new"]["ns"], -1) == '.'){ $ns = substr($data["new"]["ns"], 0, -1);
@@ -140,8 +139,8 @@ if($ns == '') $ns = $origin;
$hostmaster = substr($data["new"]["mbox"], 0, -1);
-
//$content = $ns.' '.$hostmaster.' 0';
-
$content = $ns.' '.$hostmaster.' '.$serial_id.'';
-
$content = $ns.' '.$hostmaster.' 0';
-
//$content = $ns.' '.$hostmaster.' '.$serial_id.''; $ttl = $data["new"]["ttl"]; $app->db->query("INSERT INTO powerdns.records (domain_id, name, type, content, ttl, prio, change_date, ispconfig_id) VALUES ($zone_id, '$origin', 'SOA', '$content', $ttl, 0, ".time().", $ispconfig_id)");
@@ -161,7 +160,6 @@ $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$ispconfig_id); $serial_id = $serial["serial"]; $app->db->query("UPDATE powerdns.domains SET name = '$origin', notified_serial = $serial_id WHERE ispconfig_id = $ispconfig_id");
-
//$app->db->query("UPDATE powerdns.domains SET name = '$origin' WHERE ispconfig_id = $ispconfig_id"); if(substr($data["new"]["ns"], -1) == '.'){ $ns = substr($data["new"]["ns"], 0, -1);
@@ -171,8 +169,8 @@ if($ns == '') $ns = $origin;
$hostmaster = substr($data["new"]["mbox"], 0, -1);
-
//$content = $ns.' '.$hostmaster.' 0';
-
$content = $ns.' '.$hostmaster.' '.$serial_id.'';
-
$content = $ns.' '.$hostmaster.' 0';
-
//$content = $ns.' '.$hostmaster.' '.$serial_id.''; $ttl = $data["new"]["ttl"]; $app->db->query("UPDATE powerdns.records SET name = '$origin', content = '$content', ttl = $ttl, change_date = ".time()." WHERE ispconfig_id = ".$data["new"]["id"]." AND type = 'SOA'"); } else {
@@ -354,4 +352,4 @@
} // end class
-?> \ No newline at end of file +?>