Skip to content

Commit a59731a

Browse files
author
dcy
committed
Secondary DNS functionality for PowerDNS and Bind
1 parent 5619c7d commit a59731a

File tree

129 files changed

+1678
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1678
-40
lines changed

install/lib/installer_base.lib.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,20 @@ public function configure_powerdns() {
936936
public function configure_bind() {
937937
global $conf;
938938

939-
//* Nothing to do
939+
//* Check if the zonefile directory has a slash at the end
940+
$content=$conf['bind']['bind_zonefiles_dir'];
941+
if(substr($content,-1,1) != '/') {
942+
$content .= '/';
943+
}
944+
945+
//* Create the slave subdirectory
946+
$content .= 'slave';
947+
$content_mkdir = 'mkdir -p '.$content;
948+
exec($content_mkdir);
949+
950+
//* Chown the slave subdirectory to $conf['bind']['bind_user']
951+
exec('chown '.$conf['bind']['bind_user'].':'.$conf['bind']['bind_group'].' '.$content);
952+
exec('chmod 770 '.$content);
940953

941954
}
942955

install/lib/update.lib.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ function prepareDBDump() {
6060
copy('existing_db.sql',$backup_db_name);
6161
exec("chmod 700 $backup_db_name");
6262
exec("chown root:root $backup_db_name");
63+
64+
if ($conf['powerdns']['installed']) {
65+
//** export the current PowerDNS database data
66+
if( !empty($conf["mysql"]["admin_password"]) ) {
67+
system("mysqldump -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']);
68+
} else {
69+
system("mysqldump -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']);
70+
}
71+
72+
// create a backup copy of the PowerDNS database in the root folder
73+
$backup_db_name = '/root/ispconfig_powerdns_db_backup_'.@date('Y-m-d_h-i').'.sql';
74+
copy('existing_powerdns_db.sql',$backup_db_name);
75+
exec("chmod 700 $backup_db_name");
76+
exec("chown root:root $backup_db_name");
77+
}
6378
}
6479

6580
function updateDbAndIni() {
@@ -134,6 +149,26 @@ function updateDbAndIni() {
134149
} else {
135150
system("mysql --default-character-set=".$conf['mysql']['charset']." --force -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' ".$conf['mysql']['database']." < existing_db.sql");
136151
}
152+
153+
if ($conf['powerdns']['installed']) {
154+
155+
swriteln($inst->lng('Starting full PowerDNS database update.'));
156+
157+
//** Delete the old PowerDNS database
158+
if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['powerdns']['database']) ) {
159+
$inst->error('Unable to drop MySQL database: '.$conf['powerdns']['database'].'.');
160+
}
161+
162+
//** Create the mysql database
163+
$inst->configure_powerdns();
164+
165+
//** load old data back into the PowerDNS database
166+
if( !empty($conf["mysql"]["admin_password"]) ) {
167+
system("mysql --default-character-set=".$conf['mysql']['charset']." --force -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' ".$conf['powerdns']['database']." < existing_powerdns_db.sql");
168+
} else {
169+
system("mysql --default-character-set=".$conf['mysql']['charset']." --force -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' ".$conf['powerdns']['database']." < existing_powerdns_db.sql");
170+
}
171+
}
137172
}
138173

139174

install/sql/ispconfig3.sql

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ CREATE TABLE `client` (
9292
`limit_webdav_user` int(11) NOT NULL default '0',
9393
`default_dnsserver` int(11) unsigned NOT NULL default '1',
9494
`limit_dns_zone` int(11) NOT NULL default '-1',
95+
`limit_dns_slave_zone` int(11) NOT NULL default '-1',
9596
`limit_dns_record` int(11) NOT NULL default '-1',
9697
`default_dbserver` int(11) NOT NULL default '1',
9798
`limit_database` int(11) NOT NULL default '-1',
@@ -148,6 +149,7 @@ CREATE TABLE `client_template` (
148149
`limit_shell_user` int(11) NOT NULL default '0',
149150
`limit_webdav_user` int(11) NOT NULL default '0',
150151
`limit_dns_zone` int(11) NOT NULL default '-1',
152+
`limit_dns_slave_zone` int(11) NOT NULL default '-1',
151153
`limit_dns_record` int(11) NOT NULL default '-1',
152154
`limit_database` int(11) NOT NULL default '-1',
153155
`limit_cron` int(11) NOT NULL default '0',
@@ -162,7 +164,7 @@ CREATE TABLE `client_template` (
162164
-- --------------------------------------------------------
163165

164166
--
165-
-- Table structure for table `dns_rr`
167+
-- Table structure for table `cron`
166168
--
167169
CREATE TABLE `cron` (
168170
`id` int(11) unsigned NOT NULL auto_increment,
@@ -246,6 +248,29 @@ CREATE TABLE `dns_soa` (
246248

247249
-- --------------------------------------------------------
248250

251+
--
252+
-- Table structure for table `dns_slave`
253+
--
254+
255+
CREATE TABLE `dns_slave` (
256+
`id` int(10) unsigned NOT NULL auto_increment,
257+
`sys_userid` int(11) unsigned NOT NULL,
258+
`sys_groupid` int(11) unsigned NOT NULL,
259+
`sys_perm_user` varchar(5) NOT NULL,
260+
`sys_perm_group` varchar(5) NOT NULL,
261+
`sys_perm_other` varchar(5) NOT NULL,
262+
`server_id` int(11) NOT NULL default '1',
263+
`origin` varchar(255) NOT NULL,
264+
`ns` varchar(255) NOT NULL,
265+
`active` enum('N','Y') NOT NULL,
266+
`xfer` varchar(255) NOT NULL,
267+
PRIMARY KEY (`id`),
268+
UNIQUE KEY `origin` (`origin`),
269+
KEY `active` (`active`)
270+
) ENGINE=MyISAM AUTO_INCREMENT=1;
271+
272+
-- --------------------------------------------------------
273+
249274
--
250275
-- Table structure for table `dns_template`
251276
--

install/sql/powerdns.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS `domains` (
99
`ispconfig_id` int(11) NOT NULL,
1010
PRIMARY KEY (`id`),
1111
UNIQUE KEY `name_index` (`name`)
12-
) ENGINE=MyISAM;
12+
) ENGINE=InnoDB;
1313

1414
CREATE TABLE IF NOT EXISTS `records` (
1515
`id` int(11) NOT NULL auto_increment,
@@ -25,10 +25,10 @@ CREATE TABLE IF NOT EXISTS `records` (
2525
KEY `rec_name_index` (`name`),
2626
KEY `nametype_index` (`name`,`type`),
2727
KEY `domain_id` (`domain_id`)
28-
) ENGINE=MyISAM;
28+
) ENGINE=InnoDB;
2929

3030
CREATE TABLE IF NOT EXISTS `supermasters` (
3131
`ip` varchar(25) NOT NULL,
3232
`nameserver` varchar(255) NOT NULL,
3333
`account` varchar(40) default NULL
34-
) ENGINE=MyISAM;
34+
) ENGINE=InnoDB;

install/tpl/pdns.local.master

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ gmysql-host={mysql_server_host}
77
gmysql-user={mysql_server_ispconfig_user}
88
gmysql-password={mysql_server_ispconfig_password}
99
gmysql-dbname={powerdns_database}
10+
11+
slave=yes
12+
master=yes
13+
14+
disable-axfr=no

install/update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
$conf_old = $conf;
7777
unset($conf);
7878

79-
if($dist['id'] == '') die('Linux Dustribution or Version not recognized.');
79+
if($dist['id'] == '') die('Linux Distribution or Version not recognized.');
8080

8181
//** Include the distribution specific installer class library and configuration
8282
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');

interface/web/client/client_del.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function onDelete() {
7878
$client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id");
7979

8080
// Get all records (sub-clients, mail, web, etc....) of this client.
81-
$tables = 'client,dns_rr,dns_soa,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_domain,web_traffic';
81+
$tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_domain,web_traffic';
8282
$tables_array = explode(',',$tables);
8383
$client_group_id = intval($client_group['groupid']);
8484
$table_list = array();
@@ -127,7 +127,7 @@ function onAfterDelete() {
127127
$app->db->query("DELETE FROM sys_user WHERE client_id = $client_id");
128128

129129
// Delete all records (sub-clients, mail, web, etc....) of this client.
130-
$tables = 'client,dns_rr,dns_soa,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_domain,web_traffic';
130+
$tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_domain,web_traffic';
131131
$tables_array = explode(',',$tables);
132132
$client_group_id = intval($client_group['groupid']);
133133
if($client_group_id > 1) {
@@ -163,4 +163,4 @@ function onAfterDelete() {
163163
$page = new page_action;
164164
$page->onDelete()
165165

166-
?>
166+
?>

interface/web/client/form/client.tform.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,20 @@
665665
'rows' => '',
666666
'cols' => ''
667667
),
668+
'limit_dns_slave_zone' => array (
669+
'datatype' => 'INTEGER',
670+
'formtype' => 'TEXT',
671+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
672+
'errmsg'=> 'limit_dns_slave_zone_error_notint'),
673+
),
674+
'default' => '-1',
675+
'value' => '',
676+
'separator' => '',
677+
'width' => '10',
678+
'maxlength' => '10',
679+
'rows' => '',
680+
'cols' => ''
681+
),
668682
'limit_dns_record' => array (
669683
'datatype' => 'INTEGER',
670684
'formtype' => 'TEXT',
@@ -796,4 +810,4 @@
796810
*/
797811

798812

799-
?>
813+
?>

interface/web/client/form/client_template.tform.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,20 @@
395395
'rows' => '',
396396
'cols' => ''
397397
),
398+
'limit_dns_slave_zone' => array (
399+
'datatype' => 'INTEGER',
400+
'formtype' => 'TEXT',
401+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
402+
'errmsg'=> 'limit_dns_slave_zone_error_notint'),
403+
),
404+
'default' => '0',
405+
'value' => '',
406+
'separator' => '',
407+
'width' => '10',
408+
'maxlength' => '10',
409+
'rows' => '',
410+
'cols' => ''
411+
),
398412
'limit_dns_record' => array (
399413
'datatype' => 'INTEGER',
400414
'formtype' => 'TEXT',

interface/web/client/form/reseller.tform.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,20 @@
624624
'rows' => '',
625625
'cols' => ''
626626
),
627+
'limit_dns_slave_zone' => array (
628+
'datatype' => 'INTEGER',
629+
'formtype' => 'TEXT',
630+
'validators' => array ( 0 => array ( 'type' => 'ISINT',
631+
'errmsg'=> 'limit_dns_slave_zone_error_notint'),
632+
),
633+
'default' => '-1',
634+
'value' => '',
635+
'separator' => '',
636+
'width' => '10',
637+
'maxlength' => '10',
638+
'rows' => '',
639+
'cols' => ''
640+
),
627641
'limit_dns_record' => array (
628642
'datatype' => 'INTEGER',
629643
'formtype' => 'TEXT',
@@ -758,4 +772,4 @@
758772
*/
759773

760774

761-
?>
775+
?>

0 commit comments

Comments
 (0)