Commit e5322cbb authored by Marius Burkard's avatar Marius Burkard

Merge branch 'stable-3.1'

parents 178b34eb 04d8e6f6
......@@ -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']);
}
*/
}
......
......@@ -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;
}
}
}
......
......@@ -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;
}
}
}
?>
This diff is collapsed.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>ISPCOnfig 3 remote API documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="definitionen.css">
<style type="text/css">
</style></head>
<body>
<div style="padding:40px">
<h1>client_get_by_groupid(<span class="var">$session_id</span>, <span class="var">$groupid</span>);</h1>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Shows client information of user.</p><br>
<p class="headgrp">Input Variables: </p>
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$groupid</span></p>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin"> None</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns client information from client tyble by groupid of that client.</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>ISPCOnfig 3 remote API documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="definitionen.css">
<style type="text/css">
</style></head>
<body>
<div style="padding:40px">
<h1>dns_slave_delete(<span class="var">$session_id</span>, <span class="var">$primary_id</span>);</h1>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Deletes a dns slave zone.</p><br>
<p class="headgrp">Input Variables: </p>
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id</span></p>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin">None</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns the number of deleted records.</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>ISPCOnfig 3 remote API documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="definitionen.css">
<style type="text/css">
</style></head>
<body>
<div style="padding:40px">
<h1>dns_slave_get(<span class="var">$session_id</span>, <span class="var">$primary_id</span>);</h1>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Retrieves information about a dns slave zone.</p><br>
<p class="headgrp">Input Variables: </p>
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$primary_id</span></p>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin"> None</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns all fields and values of the chosen dns slave zone.</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>ISPCOnfig 3 remote API documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="definitionen.css">
<style type="text/css">
</style></head>
<body>
<div style="padding:40px">
<h1>sys_datalog_get(<span class="var">$session_id</span>, <span class="var">$datalog_id</span>, <span class="var">$newer</span>);</h1>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Retrieves information from sys_datalog.</p><br>
<p class="headgrp">Input Variables: </p>
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$datalog_id</span>, <span class="var">$newer (true/false)</span></p>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin"> None</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns all fields and values of the chosen dns slave zone.</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>ISPCOnfig 3 remote API documentation</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="definitionen.css">
<style type="text/css">
</style></head>
<body>
<div style="padding:40px">
<h1>sys_datalog_get_by_tstamp(<span class="var">$session_id</span>, <span class="var">$tstamp</span>);</h1>
<br>
<p class="headgrp">Description: </p>
<p class="margin"> Retrieves information from sys_datalog by timestamp. All records that are newer or same than given timestamp are returned.</p><br>
<p class="headgrp">Input Variables: </p>
<p class="margin"> <span class="var">$session_id</span>, <span class="var">$tstamp</span></p>
<p class="headgrp">Parameters (in <span class="var">$params</span>): </p>
<p class="margin"> None</p>
<p class="headgrp">Output: </p>
<p class="margin"> Returns all fields and values of the chosen dns slave zone.</p>
<!--<b>Output:</b>
<p style="margin-left:100px">Gives a record of </p> -->
</div>
</body></html>
......@@ -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);
}
......
......@@ -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'];
}
......
......@@ -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"]));
}
}
}
......
Markdown is supported
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