diff --git a/interface/lib/app.inc.php b/interface/lib/app.inc.php index 89595f5aaf350791fa81b82e0fec1f086ebd8a18..0a624330e3caaacb6528efa029199f9fc42ab1ca 100755 --- a/interface/lib/app.inc.php +++ b/interface/lib/app.inc.php @@ -195,14 +195,14 @@ class app { /* if (is_writable($this->_conf['log_file'])) { if (!$fp = fopen ($this->_conf['log_file'], 'a')) { - $this->error('Unable to open logfile.'); + $this->error('Unable to open logfile: ' . $this->_conf['log_file']); } if (!fwrite($fp, date('d.m.Y-H:i').' - '. $msg."\r\n")) { - $this->error('Unable to write to logfile.'); + $this->error('Unable to write to logfile: ' . $this->_conf['log_file']); } fclose($fp); } else { - $this->error('Unable to write to logfile.'); + $this->error('Unable to write to logfile: ' . $this->_conf['log_file']); } */ } diff --git a/interface/lib/classes/remote.d/admin.inc.php b/interface/lib/classes/remote.d/admin.inc.php index 497f9a65541259b52371938ea648fbee4b567ced..b07476fb5778d20cf10cb613cccac431bfd0b261 100644 --- a/interface/lib/classes/remote.d/admin.inc.php +++ b/interface/lib/classes/remote.d/admin.inc.php @@ -272,6 +272,49 @@ class remoting_admin extends remoting { return $app->db->query('DELETE FROM sys_config WHERE `group` = ? AND `name` = ?',$group,$name); } + + // Get datalog information with tstamp >= + public function sys_datalog_get_by_tstamp($session_id, $tstamp) + { + global $app; + + if(!$this->checkPerm($session_id, 'server_get')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $tstamp = $app->functions->intval($tstamp); + + if($tstamp > 0) { + $rec = $app->db->queryAllRecords("SELECT datalog_id, server_id, dbtable, dbidx, action, tstamp, user, data, status, error FROM sys_datalog WHERE tstamp >= ? ORDER BY datalog_id DESC", $tstamp); + return $rec; + } + } + + // Get datalog information by datalog_id + public function sys_datalog_get($session_id, $datalog_id, $newer = false) + { + global $app; + + if(!$this->checkPerm($session_id, 'server_get')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $tstamp = $app->functions->intval($tstamp); + + if($datalog_id > 0 && $newer === true) { + $rec = $app->db->queryAllRecords("SELECT datalog_id, server_id, dbtable, dbidx, action, tstamp, user, data, status, error FROM sys_datalog WHERE datalog_id >= ? ORDER BY datalog_id DESC", $datalog_id); + return $rec; + } elseif ($datalog_id > 0) { + $rec = $app->db->queryAllRecords("SELECT datalog_id, server_id, dbtable, dbidx, action, tstamp, user, data, status, error FROM sys_datalog WHERE datalog_id = ? ORDER BY datalog_id DESC", $datalog_id); + return $rec; + } else { + throw new SoapFault('invalid_datalog_id', 'The ID passed to the function must be > 0'); + return false; + } + } + } diff --git a/interface/lib/classes/remote.d/client.inc.php b/interface/lib/classes/remote.d/client.inc.php index 2d068a137ef2952d70a42e8f346118ca1a7ed9c7..bf5f3ba01fefb58cad6c872c1bc93657b441bff2 100644 --- a/interface/lib/classes/remote.d/client.inc.php +++ b/interface/lib/classes/remote.d/client.inc.php @@ -678,6 +678,27 @@ class remoting_client extends remoting { return $returnval; } + + public function client_get_by_groupid($session_id, $group_id) + { + global $app; + if(!$this->checkPerm($session_id, 'client_get_id')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $group_id = $app->functions->intval($group_id); + + $rec = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = ?", $group_id); + if(isset($rec['client_id'])) { + $client_id = $app->functions->intval($rec['client_id']); + return $this->client_get($session_id, $client_id); + } else { + throw new SoapFault('no_group_found', 'There is no client for this group ID.'); + return false; + } + } + } ?> diff --git a/interface/lib/classes/remote.d/dns.inc.php b/interface/lib/classes/remote.d/dns.inc.php index 4bd518ed1626ffaa2372fb045359d28f24ac8e82..d383f395a53dd02224717030fcbc8ff3e8e19895 100644 --- a/interface/lib/classes/remote.d/dns.inc.php +++ b/interface/lib/classes/remote.d/dns.inc.php @@ -42,8 +42,7 @@ class remoting_dns extends remoting { // DNS Function -------------------------------------------------------------------------------------------------- //* Create Zone with Template - public function dns_templatezone_add($session_id, $client_id, $template_id, $domain, $ip, $ns1, $ns2, $email) - { + public function dns_templatezone_add($session_id, $client_id, $template_id, $domain, $ip, $ns1, $ns2, $email) { global $app, $conf; if(!$this->checkPerm($session_id, 'dns_templatezone_add')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); @@ -186,8 +185,7 @@ class remoting_dns extends remoting { //* Get record details - public function dns_zone_get($session_id, $primary_id) - { + public function dns_zone_get($session_id, $primary_id) { global $app; if(!$this->checkPerm($session_id, 'dns_zone_get')) { @@ -199,9 +197,22 @@ class remoting_dns extends remoting { return $app->remoting_lib->getDataRecord($primary_id); } + //* Get slave zone details + public function dns_slave_get($session_id, $primary_id) { + global $app; + + if(!$this->checkPerm($session_id, 'dns_zone_get')) { + throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $app->uses('remoting_lib'); + $app->remoting_lib->loadFormDef('../dns/form/dns_slave.tform.php'); + return $app->remoting_lib->getDataRecord($primary_id); + } + + //* Add a slave zone - public function dns_slave_add($session_id, $client_id, $params) - { + public function dns_slave_add($session_id, $client_id, $params) { if(!$this->checkPerm($session_id, 'dns_zone_add')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -210,8 +221,7 @@ class remoting_dns extends remoting { } //* Update a slave zone - public function dns_slave_update($session_id, $client_id, $primary_id, $params) - { + public function dns_slave_update($session_id, $client_id, $primary_id, $params) { if(!$this->checkPerm($session_id, 'dns_zone_update')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -221,8 +231,7 @@ class remoting_dns extends remoting { } //* Delete a slave zone - public function dns_slave_delete($session_id, $primary_id) - { + public function dns_slave_delete($session_id, $primary_id) { if(!$this->checkPerm($session_id, 'dns_zone_delete')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -231,8 +240,7 @@ class remoting_dns extends remoting { } //* Get record id by origin - public function dns_zone_get_id($session_id, $origin) - { + public function dns_zone_get_id($session_id, $origin) { global $app; if(!$this->checkPerm($session_id, 'dns_zone_get_id')) { @@ -255,8 +263,7 @@ class remoting_dns extends remoting { } //* Add a record - public function dns_zone_add($session_id, $client_id, $params) - { + public function dns_zone_add($session_id, $client_id, $params) { if(!$this->checkPerm($session_id, 'dns_zone_add')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -265,8 +272,7 @@ class remoting_dns extends remoting { } //* Update a record - public function dns_zone_update($session_id, $client_id, $primary_id, $params) - { + public function dns_zone_update($session_id, $client_id, $primary_id, $params) { if(!$this->checkPerm($session_id, 'dns_zone_update')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -276,8 +282,7 @@ class remoting_dns extends remoting { } //* Delete a record - public function dns_zone_delete($session_id, $primary_id) - { + public function dns_zone_delete($session_id, $primary_id) { if(!$this->checkPerm($session_id, 'dns_zone_delete')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -288,563 +293,312 @@ class remoting_dns extends remoting { // ---------------------------------------------------------------------------------------------------------------- - //* Get record details - public function dns_aaaa_get($session_id, $primary_id) - { + private function dns_rr_get($session_id, $primary_id, $rr_type = 'A') { global $app; - - if(!$this->checkPerm($session_id, 'dns_aaaa_get')) { + + $rr_type = strtolower($rr_type); + if(!preg_match('/^[a-z]+$/', $rr_type)) { + throw new ISPConfigRemoteException('permission denied', 'Invalid rr type'); + } + + if(!$this->checkPerm($session_id, 'dns_' . $rr_type . '_get')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; } $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_aaaa.tform.php'); + $app->remoting_lib->loadFormDef('../dns/form/dns_' . $rr_type . '.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record - public function dns_aaaa_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_aaaa_add')) { + private function dns_rr_add($session_id, $client_id, $params, $update_serial=false, $rr_type = 'A') { + $rr_type = strtolower($rr_type); + if(!preg_match('/^[a-z]+$/', $rr_type)) { + throw new ISPConfigRemoteException('permission denied', 'Invalid rr type'); + } + + if(!$this->checkPerm($session_id, 'dns_' . $rr_type . '_add')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_aaaa.tform.php', $client_id, $params); + if($update_serial) { + $this->increase_serial($session_id, $client_id, $params); + } + return $this->insertQuery('../dns/form/dns_' . $rr_type . '.tform.php', $client_id, $params); } //* Update a record - public function dns_aaaa_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_aaaa_update')) { + private function dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial=false, $rr_type = 'A') { + $rr_type = strtolower($rr_type); + if(!preg_match('/^[a-z]+$/', $rr_type)) { + throw new ISPConfigRemoteException('permission denied', 'Invalid rr type'); + } + + if(!$this->checkPerm($session_id, 'dns_' . $rr_type . '_update')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_aaaa.tform.php', $client_id, $primary_id, $params); - if($update_serial) $this->increase_serial($session_id, $client_id, $params); + $affected_rows = $this->updateQuery('../dns/form/dns_' . $rr_type . '.tform.php', $client_id, $primary_id, $params); + if($update_serial) { + $this->increase_serial($session_id, $client_id, $params); + } return $affected_rows; } - + //* Delete a record - public function dns_aaaa_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_aaaa_delete')) { + private function dns_rr_delete($session_id, $primary_id, $update_serial=false, $rr_type = 'A') { + $rr_type = strtolower($rr_type); + if(!preg_match('/^[a-z]+$/', $rr_type)) { + throw new ISPConfigRemoteException('permission denied', 'Invalid rr type'); + } + if(!$this->checkPerm($session_id, 'dns_' . $rr_type . '_delete')) { throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_aaaa.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); + if($update_serial) { + $this->increase_serial($session_id, 0, array('dns_rr_id' => $primary_id)); + } + $affected_rows = $this->deleteQuery('../dns/form/dns_' . $rr_type . '.tform.php', $primary_id); return $affected_rows; } + + // ---------------------------------------------------------------------------------------------------------------- + + //* Get record details + public function dns_aaaa_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'AAAA'); + } + + //* Add a record + public function dns_aaaa_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'AAAA'); + } + + //* Update a record + public function dns_aaaa_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'AAAA'); + } + + //* Delete a record + public function dns_aaaa_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'AAAA'); + } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_a_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_a_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_a.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_a_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'A'); } //* Add a record - public function dns_a_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_a_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_a.tform.php', $client_id, $params); + public function dns_a_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'A'); } //* Update a record - public function dns_a_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_a_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_a.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_a_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'A'); } //* Delete a record - public function dns_a_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_a_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_a.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_a_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'A'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_alias_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_alias_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_alias.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_alias_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'ALIAS'); } //* Add a record - public function dns_alias_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_alias_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_alias.tform.php', $client_id, $params); + public function dns_alias_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'ALIAS'); } //* Update a record - public function dns_alias_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_alias_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_alias.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_alias_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'ALIAS'); } //* Delete a record - public function dns_alias_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_alias_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_alias.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_alias_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'ALIAS'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_cname_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_cname_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_cname.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_cname_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'CNAME'); } //* Add a record - public function dns_cname_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_cname_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_cname.tform.php', $client_id, $params); + public function dns_cname_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'CNAME'); } //* Update a record - public function dns_cname_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_cname_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_cname.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_cname_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'CNAME'); } //* Delete a record - public function dns_cname_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_cname_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_cname.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_cname_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'CNAME'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_hinfo_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_hinfo_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_hinfo.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_hinfo_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'HINFO'); } //* Add a record - public function dns_hinfo_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_hinfo_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_hinfo.tform.php', $client_id, $params); + public function dns_hinfo_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'HINFO'); } //* Update a record - public function dns_hinfo_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_hinfo_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_hinfo.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_hinfo_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'HINFO'); } //* Delete a record - public function dns_hinfo_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_hinfo_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_hinfo.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_hinfo_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'HINFO'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_mx_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_mx_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_mx.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_mx_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'MX'); } //* Add a record - public function dns_mx_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_mx_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_mx.tform.php', $client_id, $params); + public function dns_mx_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'MX'); } //* Update a record - public function dns_mx_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_mx_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_mx.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_mx_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'MX'); } //* Delete a record - public function dns_mx_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_mx_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_mx.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_mx_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'MX'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_ns_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_ns_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_ns.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_ns_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'NS'); } //* Add a record - public function dns_ns_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_ns_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_ns.tform.php', $client_id, $params); + public function dns_ns_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'NS'); } //* Update a record - public function dns_ns_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_ns_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_ns.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_ns_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'NS'); } //* Delete a record - public function dns_ns_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_ns_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_ns.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_ns_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'NS'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_ptr_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_ptr_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_ptr.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_ptr_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'PTR'); } //* Add a record - public function dns_ptr_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_ptr_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_ptr.tform.php', $client_id, $params); + public function dns_ptr_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'PTR'); } //* Update a record - public function dns_ptr_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_ptr_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_ptr.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_ptr_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'PTR'); } //* Delete a record - public function dns_ptr_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_ptr_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_ptr.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_ptr_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'PTR'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_rp_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_rp_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_rp.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_rp_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'RP'); } //* Add a record - public function dns_rp_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_rp_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_rp.tform.php', $client_id, $params); + public function dns_rp_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'RP'); } //* Update a record - public function dns_rp_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_rp_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_rp.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_rp_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'RP'); } //* Delete a record - public function dns_rp_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_rp_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_rp.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_rp_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'RP'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_srv_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_srv_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_srv.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_srv_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'SRV'); } //* Add a record - public function dns_srv_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_srv_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_srv.tform.php', $client_id, $params); + public function dns_srv_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'SRV'); } //* Update a record - public function dns_srv_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_srv_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_srv.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_srv_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'SRV'); } //* Delete a record - public function dns_srv_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_srv_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_srv.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_srv_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'SRV'); } // ---------------------------------------------------------------------------------------------------------------- //* Get record details - public function dns_txt_get($session_id, $primary_id) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_txt_get')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../dns/form/dns_txt.tform.php'); - return $app->remoting_lib->getDataRecord($primary_id); + public function dns_txt_get($session_id, $primary_id) { + return $this->dns_rr_get($session_id, $primary_id, 'TXT'); } //* Add a record - public function dns_txt_add($session_id, $client_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_txt_add')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - return $this->insertQuery('../dns/form/dns_txt.tform.php', $client_id, $params); + public function dns_txt_add($session_id, $client_id, $params, $update_serial=false) { + return $this->dns_rr_add($session_id, $client_id, $params, $update_serial, 'TXT'); } //* Update a record - public function dns_txt_update($session_id, $client_id, $primary_id, $params, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_txt_update')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if($update_serial) $this->increase_serial($session_id, $client_id, $params); - $affected_rows = $this->updateQuery('../dns/form/dns_txt.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + public function dns_txt_update($session_id, $client_id, $primary_id, $params, $update_serial=false) { + return $this->dns_rr_update($session_id, $client_id, $primary_id, $params, $update_serial, 'TXT'); } //* Delete a record - public function dns_txt_delete($session_id, $primary_id, $update_serial=false) - { - if(!$this->checkPerm($session_id, 'dns_txt_delete')) { - throw new ISPConfigRemoteException('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../dns/form/dns_txt.tform.php', $primary_id); - if($update_serial) $this->increase_serial($session_id, $client_id, array('dns_rr_id' => $primary_id)); - return $affected_rows; + public function dns_txt_delete($session_id, $primary_id, $update_serial=false) { + return $this->dns_rr_delete($session_id, $primary_id, $update_serial, 'TXT'); } /** @@ -944,5 +698,3 @@ class remoting_dns extends remoting { $this->dns_zone_update($session_id, $client_id, $soa['id'], $soa); } } - -?> diff --git a/remoting_client/API-docs/client_get_by_groupid.html b/remoting_client/API-docs/client_get_by_groupid.html new file mode 100644 index 0000000000000000000000000000000000000000..60fb58e474552acba2c6deebf6e5bac963956730 --- /dev/null +++ b/remoting_client/API-docs/client_get_by_groupid.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

client_get_by_groupid($session_id, $groupid);

+
+

Description:

+

Shows client information of user.


+

Input Variables:

+

$session_id, $groupid

+

Parameters (in $params):

+

None

+

Output:

+

Returns client information from client tyble by groupid of that client.

+ +
+ + diff --git a/remoting_client/API-docs/dns_slave_delete.html b/remoting_client/API-docs/dns_slave_delete.html new file mode 100644 index 0000000000000000000000000000000000000000..baaca8408e495c30d28c6305f9fe5c0b6392311e --- /dev/null +++ b/remoting_client/API-docs/dns_slave_delete.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

dns_slave_delete($session_id, $primary_id);

+
+

Description:

+

Deletes a dns slave zone.


+

Input Variables:

+

$session_id, $primary_id

+

Parameters (in $params):

+

None

+

Output:

+

Returns the number of deleted records.

+ +
+ + diff --git a/remoting_client/API-docs/dns_slave_get.html b/remoting_client/API-docs/dns_slave_get.html new file mode 100644 index 0000000000000000000000000000000000000000..8b66dd300617b05b13c511c93b4c4ed5ebefe65d --- /dev/null +++ b/remoting_client/API-docs/dns_slave_get.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

dns_slave_get($session_id, $primary_id);

+
+

Description:

+

Retrieves information about a dns slave zone.


+

Input Variables:

+

$session_id, $primary_id

+

Parameters (in $params):

+

None

+

Output:

+

Returns all fields and values of the chosen dns slave zone.

+ +
+ + diff --git a/remoting_client/API-docs/sys_datalog_get.html b/remoting_client/API-docs/sys_datalog_get.html new file mode 100644 index 0000000000000000000000000000000000000000..9f1714609086cbf6f28c7dbb8d86c124232daa1a --- /dev/null +++ b/remoting_client/API-docs/sys_datalog_get.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sys_datalog_get($session_id, $datalog_id, $newer);

+
+

Description:

+

Retrieves information from sys_datalog.


+

Input Variables:

+

$session_id, $datalog_id, $newer (true/false)

+

Parameters (in $params):

+

None

+

Output:

+

Returns all fields and values of the chosen dns slave zone.

+ +
+ + diff --git a/remoting_client/API-docs/sys_datalog_get_by_tstamp.html b/remoting_client/API-docs/sys_datalog_get_by_tstamp.html new file mode 100644 index 0000000000000000000000000000000000000000..fdc1008c2195f2530d63bf3f99b3df09b0f57f13 --- /dev/null +++ b/remoting_client/API-docs/sys_datalog_get_by_tstamp.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sys_datalog_get_by_tstamp($session_id, $tstamp);

+
+

Description:

+

Retrieves information from sys_datalog by timestamp. All records that are newer or same than given timestamp are returned.


+

Input Variables:

+

$session_id, $tstamp

+

Parameters (in $params):

+

None

+

Output:

+

Returns all fields and values of the chosen dns slave zone.

+ +
+ + diff --git a/server/plugins-available/mysql_clientdb_plugin.inc.php b/server/plugins-available/mysql_clientdb_plugin.inc.php index 14052e5b7078747e415ff2568d7c3c5662c72340..efe7142c8d68e953942839652b98cb90d5665a92 100644 --- a/server/plugins-available/mysql_clientdb_plugin.inc.php +++ b/server/plugins-available/mysql_clientdb_plugin.inc.php @@ -331,6 +331,7 @@ class mysql_clientdb_plugin { $timestamp = time(); $tables = $link->query("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema='".$old_name."' AND TABLE_TYPE='BASE TABLE'"); + $tables_all = $link->query("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema='".$old_name."'"); if ($tables->num_rows > 0) { while ($row = $tables->fetch_assoc()) { $tables_array[] = $row['TABLE_NAME']; @@ -436,6 +437,11 @@ class mysql_clientdb_plugin { } } + } elseif ($tables->num_rows == 0 && $tables_all->num_rows == 0) { + //* Rename empty database by creating a new one and dropping the old database + $this->db_insert($event_name, $data); + $this->db_delete($event_name, $data); + } else { //* SELECT TABLE_NAME error $app->log('Unable to rename database '.$old_name.' to '.$new_name, LOGLEVEL_ERROR); } diff --git a/server/plugins-available/postfix_server_plugin.inc.php b/server/plugins-available/postfix_server_plugin.inc.php index 1d500c8bcf6a127a90628d8c976383ef27e08dd0..3d32d805403d3e3bdbb85181ca91352d5a74cc97 100644 --- a/server/plugins-available/postfix_server_plugin.inc.php +++ b/server/plugins-available/postfix_server_plugin.inc.php @@ -85,7 +85,7 @@ class postfix_server_plugin { $content = file_exists('/etc/postfix/sasl_passwd') ? file_get_contents('/etc/postfix/sasl_passwd') : ''; $content = preg_replace('/^'.preg_quote($old_ini_data['email']['relayhost']).'\s+[^\n]*(:?\n|)/m','',$content); - if (!empty($mail_config['relayhost']) || !empty($mail_config['relayhost_user']) || !empty($mail_config['relayhost_password'])) { + if (!empty($mail_config['relayhost_user']) || !empty($mail_config['relayhost_password'])) { $content .= "\n".$mail_config['relayhost'].' '.$mail_config['relayhost_user'].':'.$mail_config['relayhost_password']; } diff --git a/server/plugins-available/powerdns_plugin.inc.php b/server/plugins-available/powerdns_plugin.inc.php index f5f5158c44825f9093f44f33710c4c6480e64859..1ecdfaf50174825e6817631434b8c6c287cda9de 100644 --- a/server/plugins-available/powerdns_plugin.inc.php +++ b/server/plugins-available/powerdns_plugin.inc.php @@ -7,14 +7,14 @@ All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of ISPConfig nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -97,7 +97,7 @@ class powerdns_plugin { /* - This function is called when the plugin is loaded + This function is called when the plugin is loaded */ function onLoad() { @@ -421,15 +421,23 @@ class powerdns_plugin { } } - function find_pdns_pdnssec() { + function find_pdns_pdnssec_or_pdnsutil() { $output = array(); $retval = ''; + + // The command is named pdnssec in PowerDNS 3 exec("type -p pdnssec", $output, $retval); if ($retval == 0 && is_file($output[0])){ return $output[0]; - } else { - return false; } + + // But in PowerNDS 4 they renamed it to pdnsutil + exec("type -p pdnsutil", $output, $retval); + if ($retval == 0 && is_file($output[0])){ + return $output[0]; + } + + return false; } function zoneRediscover() { @@ -466,6 +474,14 @@ class powerdns_plugin { } } + function is_pdns_version_supported() { + if (preg_match('/^[34]/',$this->get_pdns_version())) { + return true; + } + + return false; + } + function handle_dnssec($data) { // If origin changed, delete keys first if ($data['old']['origin'] != $data['new']['origin']) { @@ -475,14 +491,14 @@ class powerdns_plugin { } // If DNSSEC is disabled, but was enabled before, just disable DNSSEC but leave the keys in dns_info - if ($data['new']['dnssec_wanted'] === 'N' && $data['old']['dnssec_initialized'] === 'Y') { + if ($data['new']['dnssec_wanted'] === 'N' && $data['old']['dnssec_wanted'] === 'Y') { $this->soa_dnssec_disable($data); return; } // If DNSSEC is wanted, enable it - if ($data['new']['dnssec_wanted'] === 'Y') { + if ($data['new']['dnssec_wanted'] === 'Y' && $data['old']['dnssec_wanted'] === 'N') { $this->soa_dnssec_create($data); } } @@ -490,11 +506,11 @@ class powerdns_plugin { function soa_dnssec_create($data) { global $app; - if (!preg_match('/^3/',$this->get_pdns_version()) ) { + if (false === $this->is_pdns_version_supported()) { return; } - $pdns_pdnssec = $this->find_pdns_pdnssec(); + $pdns_pdnssec = $this->find_pdns_pdnssec_or_pdnsutil(); if ($pdns_pdnssec === false) { return; } @@ -504,9 +520,13 @@ class powerdns_plugin { // We don't log the actual commands here, because having commands in the dnssec_info field will trigger // the IDS if you try to save the record using the interface afterwards. - $cmd_secure_zone = sprintf('%s secure-zone %s 2>&1', $pdns_pdnssec, $zone); - $log[] = sprintf("\r\n%s %s", date('c'), 'Running secure-zone command...'); - exec($cmd_secure_zone, $log); + $cmd_add_zone_key_ksk = sprintf('%s add-zone-key %s ksk active 2048 rsasha256', $pdns_pdnssec, $zone); + $log[] = sprintf("\r\n%s %s", date('c'), 'Running add-zone-key ksk command...'); + exec($cmd_add_zone_key_ksk, $log); + + $cmd_add_zone_key_zsk = sprintf('%s add-zone-key %s zsk active 1024 rsasha256', $pdns_pdnssec, $zone); + $log[] = sprintf("\r\n%s %s", date('c'), 'Running add-zone-key zsk command...'); + exec($cmd_add_zone_key_zsk, $log); $cmd_set_nsec3 = sprintf('%s set-nsec3 %s "1 0 10 deadbeef" 2>&1', $pdns_pdnssec, $zone); $log[] = sprintf("\r\n%s %s", date('c'), 'Running set-nsec3 command...'); @@ -539,17 +559,19 @@ class powerdns_plugin { switch ($part = substr($line, 0, 3)) { case 'ID ': // Only process active keys - if (!strpos($line, 'Active: 1')) { - continue; + // 'Active: 1' is pdnssec (PowerDNS 3.x) output + // 'Active (' is pdnsutil (PowerDNS 4.x) output + if (!strpos($line, 'Active: 1') && !strpos($line, 'Active ( ')) { + break; } - // Determine key type (KSK or ZSK) - preg_match('/(KSK|ZSK)/', $line, $matches_key_type); + // Determine key type (KSK, ZSK or CSK) + preg_match('/(KSK|ZSK|CSK)/', $line, $matches_key_type); $key_type = $matches_key_type[1]; - // We only care about the KSK - if ('ZSK' === $key_type) { - continue; + // We only care about the KSK or CSK + if (!in_array($key_type, ['KSK', 'CSK'], true)) { + break; } // Determine key tag @@ -568,6 +590,7 @@ class powerdns_plugin { break; case 'KSK': + case 'CSK': // Determine DNSKEY preg_match('/ IN DNSKEY \d+ \d+ \d+ (.*) ;/', $line, $matches_dnskey); $formatted[] = sprintf('DNSKEY: %s', $matches_dnskey[1]); @@ -604,11 +627,11 @@ class powerdns_plugin { function soa_dnssec_disable($data) { global $app; - if (!preg_match('/^3/',$this->get_pdns_version()) ) { + if (false === $this->is_pdns_version_supported()) { return; } - $pdns_pdnssec = $this->find_pdns_pdnssec(); + $pdns_pdnssec = $this->find_pdns_pdnssec_or_pdnsutil(); if ($pdns_pdnssec === false) { return; } @@ -631,11 +654,11 @@ class powerdns_plugin { function soa_dnssec_delete($data) { global $app; - if (!preg_match('/^3/',$this->get_pdns_version()) ) { + if (false === $this->is_pdns_version_supported()) { return; } - $pdns_pdnssec = $this->find_pdns_pdnssec(); + $pdns_pdnssec = $this->find_pdns_pdnssec_or_pdnsutil(); if ($pdns_pdnssec === false) { return; } @@ -661,17 +684,20 @@ class powerdns_plugin { function rectifyZone($data) { global $app, $conf; - if ( preg_match('/^3/',$this->get_pdns_version()) ) { - $pdns_pdnssec = $this->find_pdns_pdnssec(); - if ( $pdns_pdnssec != false ) { - if (isset($data["new"]["origin"])) { - //* data has origin field only for SOA recordtypes - exec($pdns_pdnssec . ' rectify-zone ' . rtrim($data["new"]["origin"],".")); - } else { - // get origin from DB for all other recordtypes - $zn = $app->db->queryOneRecord("SELECT d.name AS name FROM powerdns.domains d, powerdns.records r WHERE r.ispconfig_id=? AND r.domain_id = d.id", $data["new"]["id"]); - exec($pdns_pdnssec . ' rectify-zone ' . trim($zn["name"])); - } + + if (false === $this->is_pdns_version_supported()) { + return; + } + + $pdns_pdnssec = $this->find_pdns_pdnssec_or_pdnsutil(); + if ( $pdns_pdnssec != false ) { + if (isset($data["new"]["origin"])) { + //* data has origin field only for SOA recordtypes + exec($pdns_pdnssec . ' rectify-zone ' . rtrim($data["new"]["origin"],".")); + } else { + // get origin from DB for all other recordtypes + $zn = $app->db->queryOneRecord("SELECT d.name AS name FROM powerdns.domains d, powerdns.records r WHERE r.ispconfig_id=? AND r.domain_id = d.id", $data["new"]["id"]); + exec($pdns_pdnssec . ' rectify-zone ' . trim($zn["name"])); } } }