Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Dirk Dankhoff
ISPConfig 3
Commits
7dbea06e
Commit
7dbea06e
authored
Oct 30, 2009
by
tbrehm
Browse files
Implemented: FS#868 - Add support for BIND
parent
f7333ac8
Changes
16
Hide whitespace changes
Inline
Side-by-side
install/dist/conf/centos52.conf.php
View file @
7dbea06e
...
...
@@ -154,6 +154,15 @@ $conf['powerdns']['database'] = 'powerdns';
$conf
[
"powerdns"
][
"config_dir"
]
=
'/etc/powerdns/pdns.d'
;
$conf
[
'powerdns'
][
'init_script'
]
=
'pdns'
;
//* BIND DNS Server
$conf
[
'bind'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'bind'
][
'bind_user'
]
=
'root'
;
$conf
[
'bind'
][
'bind_group'
]
=
'bind'
;
$conf
[
'bind'
][
'bind_zonefiles_dir'
]
=
'/etc/bind'
;
$conf
[
'bind'
][
'named_conf_path'
]
=
'/etc/bind/named.conf'
;
$conf
[
'bind'
][
'named_conf_local_path'
]
=
'/etc/bind/named.conf.local'
;
$conf
[
'bind'
][
'init_script'
]
=
'named'
;
//* Jailkit
$conf
[
'jailkit'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'jailkit'
][
'config_dir'
]
=
'/etc/jailkit'
;
...
...
install/dist/conf/centos53.conf.php
View file @
7dbea06e
...
...
@@ -154,6 +154,15 @@ $conf['powerdns']['database'] = 'powerdns';
$conf
[
"powerdns"
][
"config_dir"
]
=
'/etc/powerdns/pdns.d'
;
$conf
[
'powerdns'
][
'init_script'
]
=
'pdns'
;
//* BIND DNS Server
$conf
[
'bind'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'bind'
][
'bind_user'
]
=
'root'
;
$conf
[
'bind'
][
'bind_group'
]
=
'bind'
;
$conf
[
'bind'
][
'bind_zonefiles_dir'
]
=
'/etc/bind'
;
$conf
[
'bind'
][
'named_conf_path'
]
=
'/etc/bind/named.conf'
;
$conf
[
'bind'
][
'named_conf_local_path'
]
=
'/etc/bind/named.conf.local'
;
$conf
[
'bind'
][
'init_script'
]
=
'named'
;
//* Jailkit
$conf
[
'jailkit'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'jailkit'
][
'config_dir'
]
=
'/etc/jailkit'
;
...
...
install/dist/conf/debian40.conf.php
View file @
7dbea06e
...
...
@@ -154,6 +154,15 @@ $conf['powerdns']['database'] = 'powerdns';
$conf
[
"powerdns"
][
"config_dir"
]
=
'/etc/powerdns/pdns.d'
;
$conf
[
'powerdns'
][
'init_script'
]
=
'pdns'
;
//* BIND DNS Server
$conf
[
'bind'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'bind'
][
'bind_user'
]
=
'root'
;
$conf
[
'bind'
][
'bind_group'
]
=
'bind'
;
$conf
[
'bind'
][
'bind_zonefiles_dir'
]
=
'/etc/bind'
;
$conf
[
'bind'
][
'named_conf_path'
]
=
'/etc/bind/named.conf'
;
$conf
[
'bind'
][
'named_conf_local_path'
]
=
'/etc/bind/named.conf.local'
;
$conf
[
'bind'
][
'init_script'
]
=
'bind9'
;
//* Jailkit
$conf
[
'jailkit'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'jailkit'
][
'config_dir'
]
=
'/etc/jailkit'
;
...
...
install/dist/conf/fedora9.conf.php
View file @
7dbea06e
...
...
@@ -154,6 +154,15 @@ $conf['powerdns']['database'] = 'powerdns';
$conf
[
"powerdns"
][
"config_dir"
]
=
'/etc/powerdns/pdns.d'
;
$conf
[
'powerdns'
][
'init_script'
]
=
'pdns'
;
//* BIND DNS Server
$conf
[
'bind'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'bind'
][
'bind_user'
]
=
'root'
;
$conf
[
'bind'
][
'bind_group'
]
=
'bind'
;
$conf
[
'bind'
][
'bind_zonefiles_dir'
]
=
'/etc/bind'
;
$conf
[
'bind'
][
'named_conf_path'
]
=
'/etc/bind/named.conf'
;
$conf
[
'bind'
][
'named_conf_local_path'
]
=
'/etc/bind/named.conf.local'
;
$conf
[
'bind'
][
'init_script'
]
=
'named'
;
//* Jailkit
$conf
[
'jailkit'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'jailkit'
][
'config_dir'
]
=
'/etc/jailkit'
;
...
...
install/dist/conf/opensuse110.conf.php
View file @
7dbea06e
...
...
@@ -154,6 +154,15 @@ $conf['powerdns']['database'] = 'powerdns';
$conf
[
"powerdns"
][
"config_dir"
]
=
'/etc/powerdns/pdns.d'
;
$conf
[
'powerdns'
][
'init_script'
]
=
'pdns'
;
//* BIND DNS Server
$conf
[
'bind'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'bind'
][
'bind_user'
]
=
'root'
;
$conf
[
'bind'
][
'bind_group'
]
=
'bind'
;
$conf
[
'bind'
][
'bind_zonefiles_dir'
]
=
'/etc/bind'
;
$conf
[
'bind'
][
'named_conf_path'
]
=
'/etc/bind/named.conf'
;
$conf
[
'bind'
][
'named_conf_local_path'
]
=
'/etc/bind/named.conf.local'
;
$conf
[
'bind'
][
'init_script'
]
=
'named'
;
//* Jailkit
$conf
[
'jailkit'
][
'installed'
]
=
false
;
// will be detected automatically during installation
$conf
[
'jailkit'
][
'config_dir'
]
=
'/etc/jailkit'
;
...
...
install/install.php
View file @
7dbea06e
...
...
@@ -194,6 +194,9 @@ if($install_mode == 'standard') {
if
(
$conf
[
'powerdns'
][
'installed'
]
==
true
)
{
swriteln
(
'Configuring PowerDNS'
);
$inst
->
configure_powerdns
();
}
elseif
(
$conf
[
'bind'
][
'installed'
]
==
true
)
{
swriteln
(
'Configuring BIND'
);
$inst
->
configure_bind
();
}
else
{
swriteln
(
'Configuring MyDNS'
);
$inst
->
configure_mydns
();
...
...
@@ -246,6 +249,7 @@ if($install_mode == 'standard') {
if
(
$conf
[
'pureftpd'
][
'init_script'
]
!=
''
&&
is_file
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'pureftpd'
][
'init_script'
]))
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'pureftpd'
][
'init_script'
]
.
' restart'
);
if
(
$conf
[
'mydns'
][
'installed'
]
==
true
&&
$conf
[
'mydns'
][
'init_script'
]
!=
''
&&
is_file
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'mydns'
][
'init_script'
]))
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'mydns'
][
'init_script'
]
.
' restart &> /dev/null'
);
if
(
$conf
[
'powerdns'
][
'installed'
]
==
true
&&
$conf
[
'powerdns'
][
'init_script'
]
!=
''
&&
is_file
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'powerdns'
][
'init_script'
]))
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'powerdns'
][
'init_script'
]
.
' restart &> /dev/null'
);
if
(
$conf
[
'bind'
][
'installed'
]
==
true
&&
$conf
[
'bind'
][
'init_script'
]
!=
''
&&
is_file
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'bind'
][
'init_script'
]))
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'bind'
][
'init_script'
]
.
' restart &> /dev/null'
);
}
else
{
...
...
@@ -370,6 +374,10 @@ if($install_mode == 'standard') {
swriteln
(
'Configuring PowerDNS'
);
$inst
->
configure_powerdns
();
if
(
$conf
[
'powerdns'
][
'init_script'
]
!=
''
)
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'powerdns'
][
'init_script'
]
.
' restart &> /dev/null'
);
}
elseif
(
$conf
[
'bind'
][
'installed'
]
==
true
)
{
swriteln
(
'Configuring BIND'
);
$inst
->
configure_bind
();
if
(
$conf
[
'bind'
][
'init_script'
]
!=
''
)
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'bind'
][
'init_script'
]
.
' restart &> /dev/null'
);
}
else
{
swriteln
(
'Configuring MyDNS'
);
$inst
->
configure_mydns
();
...
...
install/lib/installer_base.lib.php
View file @
7dbea06e
...
...
@@ -128,7 +128,7 @@ class installer_base {
if
(
is_installed
(
'mydns'
)
||
is_installed
(
'mydns-ng'
))
$conf
[
'mydns'
][
'installed'
]
=
true
;
if
(
is_installed
(
'jk_chrootsh'
))
$conf
[
'jailkit'
][
'installed'
]
=
true
;
if
(
is_installed
(
'pdns_server'
)
||
is_installed
(
'pdns_control'
))
$conf
[
'powerdns'
][
'installed'
]
=
true
;
if
(
is_installed
(
'named'
)
||
is_installed
(
'bind'
)
||
is_installed
(
'bind9'
))
$conf
[
'bind'
][
'installed'
]
=
true
;
}
...
...
@@ -818,6 +818,13 @@ class installer_base {
}
public
function
configure_bind
()
{
global
$conf
;
//* Nothing to do
}
public
function
configure_apache
()
...
...
install/tpl/server.ini.master
View file @
7dbea06e
...
...
@@ -43,6 +43,13 @@ apps_vhost_port=8081
apps_vhost_ip=_default_
apps_vhost_servername=
[dns]
bind_user=root
bind_group=bind
bind_zonefiles_dir=/etc/bind
named_conf_path=/etc/bind/named.conf
named_conf_local_path=/etc/bind/named.conf.local
[fastcgi]
fastcgi_starter_path=/var/www/php-fcgi-scripts/[system_user]/
fastcgi_starter_script=.php-fcgi-starter
...
...
install/update.php
View file @
7dbea06e
...
...
@@ -342,6 +342,9 @@ if($reconfigure_services_answer == 'yes') {
if
(
$conf
[
'powerdns'
][
'installed'
]
==
true
)
{
swriteln
(
'Configuring PowerDNS'
);
$inst
->
configure_powerdns
();
}
elseif
(
$conf
[
'bind'
][
'installed'
]
==
true
)
{
swriteln
(
'Configuring BIND'
);
$inst
->
configure_bind
();
}
else
{
swriteln
(
'Configuring MyDNS'
);
$inst
->
configure_mydns
();
...
...
@@ -413,6 +416,7 @@ if($reconfigure_services_answer == 'yes') {
if
(
$conf
[
'services'
][
'dns'
])
{
if
(
$conf
[
'mydns'
][
'installed'
]
==
true
&&
$conf
[
'mydns'
][
'init_script'
]
!=
''
&&
is_file
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'mydns'
][
'init_script'
]))
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'mydns'
][
'init_script'
]
.
' restart &> /dev/null'
);
if
(
$conf
[
'powerdns'
][
'installed'
]
==
true
&&
$conf
[
'powerdns'
][
'init_script'
]
!=
''
&&
is_file
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'powerdns'
][
'init_script'
]))
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'powerdns'
][
'init_script'
]
.
' restart &> /dev/null'
);
if
(
$conf
[
'bind'
][
'installed'
]
==
true
&&
$conf
[
'bind'
][
'init_script'
]
!=
''
&&
is_file
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'bind'
][
'init_script'
]))
system
(
$conf
[
'init_scripts'
]
.
'/'
.
$conf
[
'bind'
][
'init_script'
]
.
' restart &> /dev/null'
);
}
}
...
...
interface/web/admin/form/server_config.tform.php
View file @
7dbea06e
...
...
@@ -411,6 +411,75 @@ $form["tabs"]['web'] = array (
)
);
$form
[
"tabs"
][
'dns'
]
=
array
(
'title'
=>
"DNS"
,
'width'
=>
60
,
'template'
=>
"templates/server_config_dns_edit.htm"
,
'fields'
=>
array
(
##################################
# Begin Datatable fields
##################################
'bind_user'
=>
array
(
'datatype'
=>
'VARCHAR'
,
'formtype'
=>
'TEXT'
,
'default'
=>
''
,
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'NOTEMPTY'
,
'errmsg'
=>
'bind_user_error_empty'
),
),
'value'
=>
''
,
'width'
=>
'40'
,
'maxlength'
=>
'255'
),
'bind_group'
=>
array
(
'datatype'
=>
'VARCHAR'
,
'formtype'
=>
'TEXT'
,
'default'
=>
''
,
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'NOTEMPTY'
,
'errmsg'
=>
'bind_group_error_empty'
),
),
'value'
=>
''
,
'width'
=>
'40'
,
'maxlength'
=>
'255'
),
'bind_zonefiles_dir'
=>
array
(
'datatype'
=>
'VARCHAR'
,
'formtype'
=>
'TEXT'
,
'default'
=>
''
,
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'NOTEMPTY'
,
'errmsg'
=>
'bind_zonefiles_dir_error_empty'
),
),
'value'
=>
''
,
'width'
=>
'40'
,
'maxlength'
=>
'255'
),
'named_conf_path'
=>
array
(
'datatype'
=>
'VARCHAR'
,
'formtype'
=>
'TEXT'
,
'default'
=>
''
,
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'NOTEMPTY'
,
'errmsg'
=>
'named_conf_path_error_empty'
),
),
'value'
=>
''
,
'width'
=>
'40'
,
'maxlength'
=>
'255'
),
'named_conf_local_path'
=>
array
(
'datatype'
=>
'VARCHAR'
,
'formtype'
=>
'TEXT'
,
'default'
=>
''
,
'validators'
=>
array
(
0
=>
array
(
'type'
=>
'NOTEMPTY'
,
'errmsg'
=>
'named_conf_local_path_error_empty'
),
),
'value'
=>
''
,
'width'
=>
'40'
,
'maxlength'
=>
'255'
),
##################################
# ENDE Datatable fields
##################################
)
);
$form
[
"tabs"
][
'fastcgi'
]
=
array
(
'title'
=>
"FastCGI"
,
'width'
=>
80
,
...
...
interface/web/admin/lib/lang/en_server_config.lng
View file @
7dbea06e
...
...
@@ -50,4 +50,13 @@ $wb["loglevel_txt"] = 'Loglevel';
$wb
[
"apps_vhost_port_txt"
]
=
'Apps-vhost port'
;
$wb
[
"apps_vhost_ip_txt"
]
=
'Apps-vhost IP'
;
$wb
[
"apps_vhost_servername_txt"
]
=
'Apps-vhost Domain'
;
$wb
[
"bind_user_txt"
]
=
'BIND User'
;
$wb
[
"bind_group_txt"
]
=
'BIND Group'
;
$wb
[
"bind_zonefiles_dir_txt"
]
=
'BIND zonefiles directory'
;
$wb
[
"named_conf_path_txt"
]
=
'BIND named.conf path'
;
$wb
[
"bind_user_error_empty"
]
=
'BIND user is empty.'
;
$wb
[
"bind_group_error_empty"
]
=
'BIND group is empty.'
;
$wb
[
"bind_zonefiles_dir_error_empty"
]
=
'BIND zonefiles directory is empty.'
;
$wb
[
"named_conf_path_error_empty"
]
=
'BIND named.conf path is empty.'
;
$wb
[
"named_conf_local_path_error_empty"
]
=
'BIND named.conf.local path is empty.'
;
?>
\ No newline at end of file
interface/web/admin/templates/server_config_dns_edit.htm
0 → 100644
View file @
7dbea06e
<h2><tmpl_var
name=
"list_head_txt"
></h2>
<p><tmpl_var
name=
"list_desc_txt"
></p>
<div
class=
"panel panel_server_config"
>
<div
class=
"pnl_formsarea"
>
<fieldset
class=
"inlineLabels"
>
<div
class=
"ctrlHolder"
>
<label
for=
"bind_user"
>
{tmpl_var name='bind_user_txt'}
</label>
<input
name=
"bind_user"
id=
"bind_user"
value=
"{tmpl_var name='bind_user'}"
size=
"40"
maxlength=
"255"
type=
"text"
class=
"textInput"
/>
</div>
<div
class=
"ctrlHolder"
>
<label
for=
"bind_group"
>
{tmpl_var name='bind_group_txt'}
</label>
<input
name=
"bind_group"
id=
"bind_group"
value=
"{tmpl_var name='bind_group'}"
size=
"40"
maxlength=
"255"
type=
"text"
class=
"textInput"
/>
</div>
<div
class=
"ctrlHolder"
>
<label
for=
"bind_zonefiles_dir"
>
{tmpl_var name='bind_zonefiles_dir_txt'}
</label>
<input
name=
"bind_zonefiles_dir"
id=
"bind_zonefiles_dir"
value=
"{tmpl_var name='bind_zonefiles_dir'}"
size=
"40"
maxlength=
"255"
type=
"text"
class=
"textInput"
/>
</div>
<div
class=
"ctrlHolder"
>
<label
for=
"named_conf_path"
>
{tmpl_var name='named_conf_path_txt'}
</label>
<input
name=
"named_conf_path"
id=
"named_conf_path"
value=
"{tmpl_var name='named_conf_path'}"
size=
"40"
maxlength=
"255"
type=
"text"
class=
"textInput"
/>
</div>
<div
class=
"ctrlHolder"
>
<label
for=
"named_conf_local_path"
>
{tmpl_var name='named_conf_local_path_txt'}
</label>
<input
name=
"named_conf_local_path"
id=
"named_conf_local_path"
value=
"{tmpl_var name='named_conf_local_path'}"
size=
"40"
maxlength=
"255"
type=
"text"
class=
"textInput"
/>
</div>
</fieldset>
<input
type=
"hidden"
name=
"id"
value=
"{tmpl_var name='id'}"
>
<div
class=
"buttonHolder buttons"
>
<button
class=
"positive iconstxt icoPositive"
type=
"button"
value=
"{tmpl_var name='btn_save_txt'}"
onClick=
"submitForm('pageForm','admin/server_config_edit.php');"
><span>
{tmpl_var name='btn_save_txt'}
</span></button>
<button
class=
"negative iconstxt icoNegative"
type=
"button"
value=
"{tmpl_var name='btn_cancel_txt'}"
onClick=
"loadContent('admin/server_config_list.php');"
><span>
{tmpl_var name='btn_cancel_txt'}
</span></button>
</div>
</div>
</div>
server/conf/bind_named.conf.local.master
0 → 100644
View file @
7dbea06e
<tmpl_loop name='zones'>
zone "<tmpl_var name='origin'>" {
type master;
file "pri.<tmpl_var name='origin'>";
};
</tmpl_loop>
server/conf/bind_pri.domain.master
0 → 100644
View file @
7dbea06e
$TTL {tmpl_var name='ttl'}
@ IN SOA {tmpl_var name='ns'} {tmpl_var name='mbox'}. (
{tmpl_var name='serial'} ; serial, todays date + todays serial #
{tmpl_var name='refresh'} ; refresh, seconds
{tmpl_var name='retry'} ; retry, seconds
{tmpl_var name='expire'} ; expire, seconds
{tmpl_var name='ttl'} ) ; minimum, seconds
;
<tmpl_loop name='zones'>
<tmpl_if name="type" op='==' value='NS'>
{tmpl_var name='name'} NS {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='A'>
{tmpl_var name='name'} A {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='AAAA'>
{tmpl_var name='name'} AAAA {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='ALIAS'>
{tmpl_var name='name'} CNAME {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='CNAME'>
{tmpl_var name='name'} CNAME {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='HINFO'>
{tmpl_var name='name'} HINFO {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='MX'>
{tmpl_var name='name'} MX {tmpl_var name='aux'} {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='NAPTR'>
{tmpl_var name='name'} NAPTR {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='NS'>
{tmpl_var name='name'} NS {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='PTR'>
{tmpl_var name='name'} PTR {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='RP'>
{tmpl_var name='name'} RP {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='SRV'>
{tmpl_var name='name'} SRV {tmpl_var name='data'}
</tmpl_if>
<tmpl_if name="type" op='==' value='TXT'>
{tmpl_var name='name'} TXT {tmpl_var name='data'}
</tmpl_if>
</tmpl_loop>
server/mods-available/dns_module.inc.php
View file @
7dbea06e
...
...
@@ -75,6 +75,10 @@ class dns_module {
$app
->
modules
->
registerTableHook
(
'dns_soa'
,
$this
->
module_name
,
'process'
);
$app
->
modules
->
registerTableHook
(
'dns_rr'
,
$this
->
module_name
,
'process'
);
// Register service
$app
->
services
->
registerService
(
'bind'
,
'dns_module'
,
'restartBind'
);
}
/*
...
...
@@ -99,6 +103,25 @@ class dns_module {
}
// end switch
}
// end function
function
restartBind
(
$action
=
'restart'
)
{
global
$app
;
$command
=
''
;
if
(
is_file
(
'/etc/init.d/bind9'
))
{
$command
=
'/etc/init.d/bind9'
;
}
else
{
$command
=
'/etc/init.d/named'
;
}
if
(
$action
==
'restart'
)
{
exec
(
$command
.
' restart'
);
}
else
{
exec
(
$command
.
' reload'
);
}
}
}
// end class
...
...
server/plugins-available/bind_plugin.inc.php
0 → 100644
View file @
7dbea06e
<?php
/*
Copyright (c) 2009, Till Brehm, projektfarm Gmbh
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.
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
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class
bind_plugin
{
var
$plugin_name
=
'bind_plugin'
;
var
$class_name
=
'bind_plugin'
;
var
$action
=
'update'
;
//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function
onInstall
()
{
global
$conf
;
if
(
isset
(
$conf
[
'bind'
][
'installed'
])
&&
$conf
[
'bind'
][
'installed'
]
==
true
)
{
return
true
;
}
else
{
return
false
;
}
}
/*
This function is called when the plugin is loaded
*/
function
onLoad
()
{
global
$app
;
/*
Register for the events
*/
//* SOA
$app
->
plugins
->
registerEvent
(
'dns_soa_insert'
,
$this
->
plugin_name
,
'soa_insert'
);
$app
->
plugins
->
registerEvent
(
'dns_soa_update'
,
$this
->
plugin_name
,
'soa_update'
);
$app
->
plugins
->
registerEvent
(
'dns_soa_delete'
,
$this
->
plugin_name
,
'soa_delete'
);
//* RR
$app
->
plugins
->
registerEvent
(
'dns_rr_insert'
,
$this
->
plugin_name
,
'rr_insert'
);
$app
->
plugins
->
registerEvent
(
'dns_rr_update'
,
$this
->
plugin_name
,
'rr_update'
);
$app
->
plugins
->
registerEvent
(
'dns_rr_delete'
,
$this
->
plugin_name
,
'rr_delete'
);
}
function
soa_insert
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
$this
->
action
=
'insert'
;
$this
->
soa_update
(
$event_name
,
$data
);
}
function
soa_update
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
//* load the server configuration options
$app
->
uses
(
"getconf"
);
$dns_config
=
$app
->
getconf
->
get_server_config
(
$conf
[
"server_id"
],
'dns'
);
//* Write the domain file
$tpl
=
new
tpl
();
$tpl
->
newTemplate
(
"bind_pri.domain.master"
);
$zone
=
$data
[
'new'
];
$tpl
->
setVar
(
$zone
);
$records
=
$app
->
db
->
queryAllRecords
(
"SELECT * FROM dns_rr WHERE zone = "
.
$zone
[
'id'
]);
$tpl
->
setLoop
(
'records'
,
$records
);
$filename
=
escapeshellcmd
(
$dns_config
[
'bind_zonefiles_dir'
]
.
'/pri.'
.
$zone
[
'origin'
]);
file_put_contents
(
$filename
,
$tpl
->
grab
());
exec
(
'chown '
.
escapeshellcmd
(
$dns_config
[
'bind_user'
])
.
':'
.
escapeshellcmd
(
$dns_config
[
'bind_group'
])
.
' '
.
$filename
);
unset
(
$tpl
);
unset
(
$records
);
unset
(
$zone
);
//* rebuild the named.conf file if the origin has changed or when the origin is inserted.
if
(
$this
->
action
==
'insert'
||
$data
[
'old'
][
'origin'
]
!=
$data
[
'new'
][
'origin'
])
{
$this
->
write_named_conf
(
$data
,
$dns_config
);
}
//* Delete old domain file, if domain name has been changed
if
(
$data
[
'old'
][
'origin'
]
!=
$data
[
'new'
][
'origin'
])
{
$filename
=
$dns_config
[
'bind_zonefiles_dir'
]
.
'/pri.'
.
$data
[
'old'
][
'origin'
];
if
(
is_file
(
$filename
))
unset
(
$filename
);
}
//* Reload bind nameserver
$app
->
services
->
restartServiceDelayed
(
'bind'
,
'reload'
);
}
function
soa_delete
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
//* load the server configuration options
$app
->
uses
(
"getconf"
);
$dns_config
=
$app
->
getconf
->
get_server_config
(
$conf
[
"server_id"
],
'dns'
);
//* rebuild the named.conf file
$this
->
write_named_conf
(
$data
,
$dns_config
);
//* Delete the domain file
$filename
=
$dns_config
[
'bind_zonefiles_dir'
]
.
'/pri.'
.
$data
[
'old'
][
'origin'
];
if
(
is_file
(
$filename
))
unset
(
$filename
);
//* Reload bind nameserver
$app
->
services
->
restartServiceDelayed
(
'bind'
,
'reload'
);
}
function
rr_insert
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
//* Get the data of the soa and call soa_update
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT * FROM dns_soa WHERE id = "
.
$data
[
'new'
][
'zone'
]);
$data
[
"new"
]
=
$tmp
;
$data
[
"old"
]
=
$tmp
;
$this
->
action
=
'update'
;
$this
->
soa_update
(
$event_name
,
$data
);
}
function
rr_update
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
//* Get the data of the soa and call soa_update
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT * FROM dns_soa WHERE id = "
.
$data
[
'new'
][
'zone'
]);
$data
[
"new"
]
=
$tmp
;
$data
[
"old"
]
=
$tmp
;
$this
->
action
=
'update'
;
$this
->
soa_update
(
$event_name
,
$data
);
}
function
rr_delete
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
//* Get the data of the soa and call soa_update
$tmp
=
$app
->
db
->
queryOneRecord
(
"SELECT * FROM dns_soa WHERE id = "
.
$data
[
'old'
][
'zone'
]);
$data
[
"new"
]
=
$tmp
;
$data
[
"old"
]
=
$tmp
;
$this
->
action
=
'update'
;
$this
->
soa_update
(
$event_name
,
$data
);
}
###################################################################
function
write_named_conf
(
$data
,
$dns_config
)
{
global
$app
,
$conf
;
$zones
=
$app
->
db
->
queryAllRecords
(
"SELECT origin FROM dns_soa WHERE active = 'Y'"
);
$tpl
=
new
tpl
();
$tpl
->
newTemplate
(
"bind_named.conf.local.master"
);
$tpl
->
setLoop
(
'zones'
,
$zones
);
file_put_contents
(
$dns_config
[
'named_conf_local_path'
],
$tpl
->
grab
());
unset
(
$tpl
);
}