add bind with sdb-ldap

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/mds@2827 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one
2011-02-02 06:22:07 +00:00
parent 9c2c3c4405
commit 0013c2a416
21 changed files with 3303 additions and 0 deletions

View File

@@ -0,0 +1 @@
CONFIG_PROTECT="/var/bind"

View File

@@ -0,0 +1,12 @@
$ORIGIN 127.in-addr.arpa.
$TTL 1W
@ 1D IN SOA localhost. root.localhost. (
2008122601 ; serial
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
@ 1D IN NS localhost.
1.0.0 1D IN PTR localhost.

View File

@@ -0,0 +1,59 @@
--- bind-9.5.0a6.orig/contrib/dlz/drivers/dlz_mysql_driver.c 2007-02-06 06:44:26.000000000 +0100
+++ bind-9.5.0a6/contrib/dlz/drivers/dlz_mysql_driver.c 2007-09-04 23:57:57.000000000 +0200
@@ -92,6 +92,25 @@
*/
/*%
+ * Factorize the mysql_ping for adding a log error message
+ */
+static isc_result_t
+mysqldrv_ping(dbinstance_t *dbi) {
+ int pres = 0;
+
+ pres = mysql_ping(dbi->dbconn);
+ if ( pres != 0 ) {
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
+ DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
+ "\nMySQL Ping Error : %s (%i)\n",
+ mysql_error(dbi->dbconn),
+ mysql_errno(dbi->dbconn));
+ return (ISC_R_FAILURE);
+ }
+ return (ISC_R_SUCCESS);
+}
+
+/*%
* Allocates memory for a new string, and then constructs the new
* string by "escaping" the input string. The new string is
* safe to be used in queries. This is necessary because we cannot
@@ -225,6 +244,8 @@
}
+ mysqldrv_ping(dbi);
+
/*
* was a zone string passed? If so, make it safe for use in
* queries.
@@ -324,7 +345,7 @@
qres = mysql_query((MYSQL *) dbi->dbconn, querystring);
if (qres == 0)
break;
- for (j=0; mysql_ping((MYSQL *) dbi->dbconn) != 0 && j < 4; j++)
+ for (j=0; mysqldrv_ping(dbi) != 0 && j < 4; j++)
;
}
@@ -923,6 +944,12 @@
pass = getParameterValue(argv[1], "pass=");
socket = getParameterValue(argv[1], "socket=");
+ if(mysql_options((MYSQL *) dbi->dbconn, MYSQL_OPT_RECONNECT, "1")) {
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
+ DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
+ "Could not set database reconnect option");
+ }
+
for (j=0; dbc == NULL && j < 4; j++)
dbc = mysql_real_connect((MYSQL *) dbi->dbconn, host,
user, pass, dbname, port, socket,

View File

@@ -0,0 +1,11 @@
$TTL 1W
@ IN SOA localhost. root.localhost. (
2008122601 ; Serial
28800 ; Refresh
14400 ; Retry
604800 ; Expire - 1 week
86400 ) ; Minimum
@ IN NS localhost.
@ IN A 127.0.0.1
@ IN AAAA ::1

View File

@@ -0,0 +1,86 @@
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . <file>"
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC
; under anonymous FTP as
; file /domain/named.cache
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: Dec 12, 2008
; related version of root zone: 2008121200
;
; formerly NS.INTERNIC.NET
;
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:BA3E::2:30
;
; FORMERLY NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201
;
; FORMERLY C.PSI.NET
;
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
;
; FORMERLY TERP.UMD.EDU
;
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
;
; FORMERLY NS.NASA.GOV
;
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
;
; FORMERLY NS.ISC.ORG
;
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2F::F
;
; FORMERLY NS.NIC.DDN.MIL
;
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
;
; FORMERLY AOS.ARL.ARMY.MIL
;
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::803F:235
;
; FORMERLY NIC.NORDU.NET
;
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
;
; OPERATED BY VERISIGN, INC.
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:C27::2:30
;
; OPERATED BY RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FD::1
;
; OPERATED BY ICANN
;
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42
L.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:3::42
;
; OPERATED BY WIDE
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
M.ROOT-SERVERS.NET. 3600000 AAAA 2001:DC3::35
; End of File

View File

@@ -0,0 +1,53 @@
options {
directory "/var/bind";
// uncomment the following lines to turn on DNS forwarding,
// and change the forwarding ip address(es) :
//forward first;
//forwarders {
// 123.123.123.123;
// 123.123.123.123;
//};
listen-on-v6 { none; };
listen-on { 127.0.0.1; };
// to allow only specific hosts to use the DNS server:
//allow-query {
// 127.0.0.1;
//};
// if you have problems and are behind a firewall:
//query-source address * port 53;
pid-file "/var/run/named/named.pid";
};
// Briefly, a zone which has been declared delegation-only will be effectively
// limited to containing NS RRs for subdomains, but no actual data beyond its
// own apex (for example, its SOA RR and apex NS RRset). This can be used to
// filter out "wildcard" or "synthesized" data from NAT boxes or from
// authoritative name servers whose undelegated (in-zone) data is of no
// interest.
// See http://www.isc.org/products/BIND/delegation-only.html for more info
//zone "COM" { type delegation-only; };
//zone "NET" { type delegation-only; };
zone "." IN {
type hint;
file "named.cache";
};
zone "localhost" IN {
type master;
file "pri/localhost.zone";
allow-update { none; };
notify no;
};
zone "127.in-addr.arpa" IN {
type master;
file "pri/127.zone";
allow-update { none; };
notify no;
};

View File

@@ -0,0 +1,216 @@
/*
* Refer to the named.conf(5) and named(8) man pages, and the documentation
* in /usr/share/doc/bind-9 for more details.
* Online versions of the documentation can be found here:
* http://www.isc.org/software/bind/documentation
*
* If you are going to set up an authoritative server, make sure you
* understand the hairy details of how DNS works. Even with simple mistakes,
* you can break connectivity for affected parties, or cause huge amounts of
* useless Internet traffic.
*/
acl "xfer" {
/* Allow no transfers. If we have other name servers, place them here. */
//127.0.0.1/32;
//::1/128;
"none";
};
/*
* You might put in here some ips which are allowed to use the cache or
* recursive queries
*/
acl "trusted" {
127.0.0.0/8;
::1/128;
};
options {
directory "/var/bind";
pid-file "/var/run/named/named.pid";
/* https://www.isc.org/solutions/dlv >=bind-9.7.x only */
// bindkeys-file "/etc/bind/bind.keys";
listen-on-v6 { ::1; };
listen-on { 127.0.0.1; };
allow-query {
/*
* Accept queries from our "trusted" ACL. We will
* allow anyone to query our master zones below.
* This prevents us from becoming a free DNS server
* to the masses.
*/
trusted;
};
allow-query-cache {
/* Use the cache for the "trusted" ACL. */
trusted;
};
allow-transfer {
/*
* Zone tranfers limited to members of the
* "xfer" ACL (e.g. secondary nameserver).
*/
xfer;
};
/*
* If you've got a DNS server around at your upstream provider, enter its
* IP address here, and enable the line below. This will make you benefit
* from its cache, thus reduce overall DNS traffic in the Internet.
*
* Uncomment the following lines to turn on DNS forwarding, and change
* and/or update the forwarding ip address(es):
*/
/*
forward first;
forwarders {
// 123.123.123.123; // Your ISP NS
// 124.124.124.124; // Your ISP NS
4.2.2.1; // Level3 Public DNS
4.2.2.2; // Level3 Public DNS
8.8.8.8; // Google Open DNS
8.8.4.4; // Google Open DNS
};
*/
// dnssec-enable yes;
// dnssec-validation yes;
/* if you have problems and are behind a firewall: */
//query-source address * port 53;
};
logging {
channel default_log {
file "/var/log/named/named.log" versions 5 size 50M;
print-time yes;
print-severity yes;
print-category yes;
};
category default { default_log; };
category general { default_log; };
};
include "/etc/bind/rndc.key";
controls {
inet 127.0.0.1 port 953 allow { 127.0.0.1/32; ::1/128; } keys { "rndc-key"; };
};
view "internal" in {
/*
* Our internal (trusted) view. We permit the internal networks
* to freely access this view. We perform recursion for our
* internal hosts, and retrieve data from the cache for them.
*/
match-clients { trusted; };
recursion yes;
additional-from-auth yes;
additional-from-cache yes;
zone "." in {
type hint;
file "/var/bind/root.cache";
};
zone "localhost" IN {
type master;
file "pri/localhost.zone";
allow-update { none; };
notify no;
allow-query { any; };
allow-transfer { none; };
};
zone "127.in-addr.arpa" IN {
type master;
file "pri/127.zone";
allow-update { none; };
notify no;
allow-query { any; };
allow-transfer { none; };
};
/*
* NOTE: All zone blocks for "public" view should be listed here in "internal"
* too! Otherwise you'll have trouble to resolv the public zones properly.
* That affects all hosts from the "trusted" ACL.
* A separate config, which contains all zone blocks, might be better in
* this case. Then you can simply add:
* include "/etc/bind/zones.cfg";
* for "internal" and "public" view.
*/
/*
* Briefly, a zone which has been declared delegation-only will be effectively
* limited to containing NS RRs for subdomains, but no actual data beyond its
* own apex (for example, its SOA RR and apex NS RRset). This can be used to
* filter out "wildcard" or "synthesized" data from NAT boxes or from
* authoritative name servers whose undelegated (in-zone) data is of no
* interest.
* See http://www.isc.org/software/bind/delegation-only for more info
*/
//zone "COM" { type delegation-only; };
//zone "NET" { type delegation-only; };
};
view "public" in {
/*
* Our external (untrusted) view. We permit any client to access
* portions of this view. We do not perform recursion or cache
* access for hosts using this view.
*/
match-clients { any; };
recursion no;
additional-from-auth no;
additional-from-cache no;
zone "." in {
type hint;
file "/var/bind/root.cache";
};
//zone "YOUR-DOMAIN.TLD" {
// type master;
// file "/var/bind/pri/YOUR-DOMAIN.TLD.zone";
// allow-query { any; };
// allow-transfer { xfer; };
//};
//zone "YOUR-SLAVE.TLD" {
// type slave;
// file "/var/bind/sec/YOUR-SLAVE.TLD.zone";
// masters { <MASTER>; };
// /* Anybody is allowed to query but transfer should be controlled by the master. */
// allow-query { any; };
// allow-transfer { none; };
// /* The master should be the only one who notifies the slaves, shouldn't it? */
// allow-notify { <MASTER>; };
// notify no;
//};
};
/* Hide the bind version */
/*
view "chaos" chaos {
match-clients { any; };
allow-query { none; };
zone "." {
type hint;
file "/dev/null"; // or any empty file
};
};
*/

View File

@@ -0,0 +1,165 @@
/*
* Refer to the named.conf(5) and named(8) man pages, and the documentation
* in /usr/share/doc/bind-9 for more details.
* Online versions of the documentation can be found here:
* http://www.isc.org/software/bind/documentation
*
* If you are going to set up an authoritative server, make sure you
* understand the hairy details of how DNS works. Even with simple mistakes,
* you can break connectivity for affected parties, or cause huge amounts of
* useless Internet traffic.
*/
acl "xfer" {
/* Deny transfers by default except for the listed hosts.
* If we have other name servers, place them here.
*/
none;
};
/*
* You might put in here some ips which are allowed to use the cache or
* recursive queries
*/
acl "trusted" {
127.0.0.0/8;
::1/128;
};
options {
directory "/var/bind";
pid-file "/var/run/named/named.pid";
/* https://www.isc.org/solutions/dlv >=bind-9.7.x only */
//bindkeys-file "/etc/bind/bind.keys";
listen-on-v6 { ::1; };
listen-on { 127.0.0.1; };
allow-query {
/*
* Accept queries from our "trusted" ACL. We will
* allow anyone to query our master zones below.
* This prevents us from becoming a free DNS server
* to the masses.
*/
trusted;
};
allow-query-cache {
/* Use the cache for the "trusted" ACL. */
trusted;
};
allow-recursion {
/* Only trusted addresses are allowed to use recursion. */
trusted;
};
allow-transfer {
/* Zone tranfers are denied by default. */
none;
};
allow-update {
/* Don't allow updates, e.g. via nsupdate. */
none;
};
/*
* If you've got a DNS server around at your upstream provider, enter its
* IP address here, and enable the line below. This will make you benefit
* from its cache, thus reduce overall DNS traffic in the Internet.
*
* Uncomment the following lines to turn on DNS forwarding, and change
* and/or update the forwarding ip address(es):
*/
/*
forward first;
forwarders {
// 123.123.123.123; // Your ISP NS
// 124.124.124.124; // Your ISP NS
// 4.2.2.1; // Level3 Public DNS
// 4.2.2.2; // Level3 Public DNS
8.8.8.8; // Google Open DNS
8.8.4.4; // Google Open DNS
};
*/
//dnssec-enable yes;
//dnssec-validation yes;
/* if you have problems and are behind a firewall: */
//query-source address * port 53;
};
/*
logging {
channel default_log {
file "/var/log/named/named.log" versions 5 size 50M;
print-time yes;
print-severity yes;
print-category yes;
};
category default { default_log; };
category general { default_log; };
};
*/
include "/etc/bind/rndc.key";
controls {
inet 127.0.0.1 port 953 allow { 127.0.0.1/32; ::1/128; } keys { "rndc-key"; };
};
zone "." in {
type hint;
file "/var/bind/root.cache";
};
zone "localhost" IN {
type master;
file "pri/localhost.zone";
notify no;
};
zone "127.in-addr.arpa" IN {
type master;
file "pri/127.zone";
notify no;
};
/*
* Briefly, a zone which has been declared delegation-only will be effectively
* limited to containing NS RRs for subdomains, but no actual data beyond its
* own apex (for example, its SOA RR and apex NS RRset). This can be used to
* filter out "wildcard" or "synthesized" data from NAT boxes or from
* authoritative name servers whose undelegated (in-zone) data is of no
* interest.
* See http://www.isc.org/software/bind/delegation-only for more info
*/
//zone "COM" { type delegation-only; };
//zone "NET" { type delegation-only; };
//zone "YOUR-DOMAIN.TLD" {
// type master;
// file "/var/bind/pri/YOUR-DOMAIN.TLD.zone";
// allow-query { any; };
// allow-transfer { xfer; };
//};
//zone "YOUR-SLAVE.TLD" {
// type slave;
// file "/var/bind/sec/YOUR-SLAVE.TLD.zone";
// masters { <MASTER>; };
/* Anybody is allowed to query but transfer should be controlled by the master. */
// allow-query { any; };
// allow-transfer { none; };
/* The master should be the only one who notifies the slaves, shouldn't it? */
// allow-notify { <MASTER>; };
// notify no;
//};

View File

@@ -0,0 +1,20 @@
# Set various named options here.
#
OPTIONS=""
# Set this to the number of processors you have.
#
CPU="1"
# If you wish to run bind in a chroot, run:
# emerge --config =<bind-version>
# and un-comment the following line.
# You can specify a different chroot directory but MAKE SURE it's empty.
# CHROOT="/chroot/dns"
# Default pid file location
PIDFILE="${CHROOT}/var/run/named/named.pid"
# Scheduling priority: 19 is the lowest and -20 is the highest.
#
NAMED_NICELEVEL="0"

View File

@@ -0,0 +1,26 @@
# Set various named options here.
#
OPTIONS=""
# Set this to the number of processors you want bind to use.
# Leave this unchanged if you want bind to automatically detect the number
#CPU="1"
# If you wish to run bind in a chroot:
# 1) un-comment the CHROOT= assignment, below. You may use
# a different chroot directory but MAKE SURE it's empty.
# 2) run: emerge --config =<bind-version>
#
# CHROOT="/chroot/dns"
# RNDC needs to be told what server we're using sometimes.
#SERVER="-s 127.0.0.1"
# rndc key to use
RNDC_KEY="${CHROOT}/etc/bind/rndc.key"
# Default pid file location
PIDFILE="${CHROOT}/var/run/named/named.pid"
# Scheduling priority: 19 is the lowest and -20 is the highest.
#
NAMED_NICELEVEL="0"

View File

@@ -0,0 +1,46 @@
# Set various named options here.
#
#OPTIONS=""
# Set this to the number of processors you want bind to use.
# Leave this unchanged if you want bind to automatically detect the number
#CPU="1"
# If you wish to run bind in a chroot:
# 1) un-comment the CHROOT= assignment, below. You may use
# a different chroot directory but MAKE SURE it's empty.
# 2) run: emerge --config =<bind-version>
#
#CHROOT="/chroot/dns"
# Uncomment the line below to avoid that the init script mounts the needed paths
# into the chroot directory.
# You have to copy all needed config files by hand if you say CHROOT_NOMOUNT="1".
#CHROOT_NOMOUNT="1"
# RNDC needs to be told what server we're using sometimes.
#SERVER="-s 127.0.0.1"
# rndc key to use
#RNDC_KEY="${CHROOT}/etc/bind/rndc.key"
# Default pid file location
PIDFILE="${CHROOT}/var/run/named/named.pid"
# Scheduling priority: 19 is the lowest and -20 is the highest.
# Default: 0
#NAMED_NICELEVEL="0"
# Uncomment rc_named_use/rc_named_after for the database you need.
# Its necessary to ensure the database backend will be started before named.
# MySQL
#rc_named_use="mysql"
#rc_named_after="mysql"
# PostgreSQL
#rc_named_use="pg_autovacuum postgresql"
#rc_named_after="pg_autovacuum postgresql"
# LDAP
#rc_named_use="ldap"
#rc_named_after="ldap"

View File

@@ -0,0 +1,44 @@
# Set various named options here.
#
#OPTIONS=""
# Set this to the number of processors you want bind to use.
# Leave this unchanged if you want bind to automatically detect the number
#CPU="1"
# If you wish to run bind in a chroot:
# 1) un-comment the CHROOT= assignment, below. You may use
# a different chroot directory but MAKE SURE it's empty.
# 2) run: emerge --config =<bind-version>
#
#CHROOT="/chroot/dns"
# Uncomment to enable binmount of /usr/share/GeoIP
#CHROOT_GEOIP="1"
# Uncomment the line below to avoid that the init script mounts the needed paths
# into the chroot directory.
# You have to copy all needed config files by hand if you say CHROOT_NOMOUNT="1".
#CHROOT_NOMOUNT="1"
# Default pid file location
PIDFILE="${CHROOT}/var/run/named/named.pid"
# Scheduling priority: 19 is the lowest and -20 is the highest.
# Default: 0
#NAMED_NICELEVEL="0"
# Uncomment rc_named_use/rc_named_after for the database you need.
# Its necessary to ensure the database backend will be started before named.
# MySQL
#rc_named_use="mysql"
#rc_named_after="mysql"
# PostgreSQL
#rc_named_use="pg_autovacuum postgresql"
#rc_named_after="pg_autovacuum postgresql"
# LDAP
#rc_named_use="ldap"
#rc_named_after="ldap"

View File

@@ -0,0 +1,77 @@
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.init-r5,v 1.3 2010/09/03 17:52:01 idl0r Exp $
opts="start stop reload restart"
depend() {
need net
use logger
provide dns
}
checkconfig() {
if [ ! -f ${CHROOT}/etc/bind/named.conf ] ; then
eerror "No ${CHROOT}/etc/bind/named.conf file exists!"
fi
# In case someone doesn't have $CPU set from /etc/conf.d/named
if [ ! ${CPU} ] ; then
CPU="1"
fi
# as suggested in bug #107724
[ -n "${PIDFILE}" ] || PIDFILE=${CHROOT}$(\
egrep -v \
"^([[:cntrl:] ]+(#|//|/\*)|(#|//|/\*))" \
${CHROOT}/etc/bind/named.conf \
| egrep -o -m1 "pid\-file +\".+\" *;" \
| cut -d\" -f2
)
KEY="${CHROOT}/etc/bind/rndc.key"
# create piddir (usually /var/run/named) if necessary
local piddir="${PIDFILE%/*}"
if [ ! -d "${piddir}" ] ; then
checkpath -q -d -o root:named -m 0770 "${piddir}" || return 1
fi
}
start() {
ebegin "Starting ${CHROOT:+chrooted }named"
checkconfig || return 1
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--nicelevel ${NAMED_NICELEVEL:-0} \
--exec /usr/sbin/named \
-- -u named -n ${CPU} ${OPTIONS} ${CHROOT:+-t} ${CHROOT}
eend $?
}
stop() {
ebegin "Stopping ${CHROOT:+chrooted }named"
checkconfig || return 2
if [ -f $KEY ] ; then
rndc -k $KEY stop &>/dev/null
else
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--exec /usr/sbin/named
fi
eend $?
}
reload() {
checkconfig || return 3
if [ ! -f $PIDFILE ] ; then
/etc/init.d/named start &>/dev/null
exit
fi
if [ -f $KEY ] ; then
ebegin "Reloading named.conf and zone files"
rndc -k $KEY reload &>/dev/null
eend $?
else /etc/init.d/named restart &>/dev/null
fi
}

View File

@@ -0,0 +1,164 @@
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.init-r7,v 1.6 2010/09/03 17:52:01 idl0r Exp $
opts="start stop reload restart"
depend() {
need net
use logger
after pg_autovacuum postgresql mysql ldap
provide dns
}
_mount() {
local from
local to
local opts
if [[ $# -lt 3 ]];
then
eerror "_mount(): to few arguments"
return 1
fi
from=$1
to=$2
shift 2
opts="${*}"
shift $#
if [[ -z $(grep "${to}" /proc/mounts) ]];
then
einfo "mounting ${from} to ${to}"
mount ${from} ${to} ${opts} || return 1
fi
}
_umount() {
local dir=$1
if [[ -n $(grep "${dir}" /proc/mounts) ]];
then
einfo "umount ${dir}"
umount ${dir}
fi
}
check_chroot() {
if [[ -n ${CHROOT} ]]; then
[[ ! -d ${CHROOT} ]] && return 1
[[ ! -d ${CHROOT}/dev || ! -d ${CHROOT}/etc || ! -d ${CHROOT}/var ]] && return 1
[[ ! -d ${CHROOT}/var/run || ! -d ${CHROOT}/var/log ]] && return 1
[[ ! -d ${CHROOT}/etc/bind || ! -d ${CHROOT}/var/bind ]] && return 1
[[ ! -d ${CHROOT}/var/log/named ]] && return 1
[[ ! -e ${CHROOT}/etc/localtime ]] && return 1
[[ ! -c ${CHROOT}/dev/null || ! -c ${CHROOT}/dev/zero ]] && return 1
[[ ! -c ${CHROOT}/dev/random && ! -c ${CHROOT}/dev/urandom ]] && return 1
fi
# create piddir (usually /var/run/named) if necessary
local piddir="${PIDFILE%/*}"
if [ ! -d "${piddir}" ] ; then
checkpath -q -d -o root:named -m 0770 "${piddir}" || return 1
fi
return 0
}
checkconfig() {
if [ ! -f ${CHROOT}/etc/bind/named.conf ] ; then
eerror "No ${CHROOT}/etc/bind/named.conf file exists!"
fi
# In case someone have $CPU set in /etc/conf.d/named
if [ ${CPU} ] ; then
CPU="-n ${CPU}"
fi
# as suggested in bug #107724
[ -n "${PIDFILE}" ] || PIDFILE=${CHROOT}$(\
egrep -v \
"^([[:cntrl:] ]+(#|//|/\*)|(#|//|/\*))" \
${CHROOT}/etc/bind/named.conf \
| egrep -o -m1 "pid\-file +\".+\" *;" \
| cut -d\" -f2
)
}
start() {
ebegin "Starting ${CHROOT:+chrooted }named"
if [[ -n ${CHROOT} ]];
then
check_chroot || {
eerror "Your chroot dir ${CHROOT} is inconsistent, please run 'emerge --config net-dns/bind' first"
return 1
}
einfo "Mounting chroot dirs"
_mount /etc/bind ${CHROOT}/etc/bind -o bind
_mount /var/bind ${CHROOT}/var/bind -o bind
_mount /var/log/named ${CHROOT}/var/log/named -o bind
fi
checkconfig || return 1
start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--nicelevel ${NAMED_NICELEVEL:-0} \
--exec /usr/sbin/named \
-- -u named ${CPU} ${OPTIONS} ${CHROOT:+-t} ${CHROOT}
eend $?
}
stop() {
local reported=0
ebegin "Stopping ${CHROOT:+chrooted }named"
checkconfig || return 2
if [[ -n "${RNDC_KEY}" && -f "${RNDC_KEY}" ]] ; then
rndc $SERVER -k $RNDC_KEY stop &>/dev/null
else
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--exec /usr/sbin/named
fi
if [[ -n ${CHROOT} ]];
then
einfo "Umounting chroot dirs"
# just to be sure everything gets clean
while [[ -n $(fuser ${CHROOT} 2>&1) ]]
do
if [[ ${reported} -eq 0 ]];
then
einfo "Waiting until all named processes are stopped"
reported=1
fi
sleep 1
done
_umount ${CHROOT}/etc/bind
_umount ${CHROOT}/var/log/named
_umount ${CHROOT}/var/bind
fi
eend $?
}
reload() {
checkconfig || return 3
if [ ! -f $PIDFILE ] ; then
/etc/init.d/named start &>/dev/null
exit
fi
if [ -f $RNDC_KEY ] ; then
ebegin "Reloading named.conf and zone files"
rndc $SERVER -k $RNDC_KEY reload &>/dev/null
eend $?
else
/etc/init.d/named restart &>/dev/null
fi
}

View File

@@ -0,0 +1,188 @@
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.init-r8,v 1.3 2010/10/24 20:47:17 idl0r Exp $
opts="start stop reload restart"
depend() {
need net
use logger
provide dns
}
NAMED_CONF=${CHROOT}/etc/bind/named.conf
_mount() {
local from
local to
local opts
if [ "${#}" -lt 3 ]; then
eerror "_mount(): to few arguments"
return 1
fi
from=$1
to=$2
shift 2
opts="${*}"
shift $#
if [ -z "$(grep ${to} /proc/mounts)" ]; then
einfo "mounting ${from} to ${to}"
mount ${from} ${to} ${opts} || return 1
fi
}
_umount() {
local dir=$1
if [ -n "$(grep ${dir} /proc/mounts)" ]; then
einfo "umount ${dir}"
umount ${dir}
fi
}
check_chroot() {
if [ -n "${CHROOT}" ]; then
[ ! -d "${CHROOT}" ] && return 1
[ ! -d "${CHROOT}/dev" ] || [ ! -d "${CHROOT}/etc" ] || [ ! -d "${CHROOT}/var" ] && return 1
[ ! -d "${CHROOT}/var/run" ] || [ ! -d "${CHROOT}/var/log" ] && return 1
[ ! -d "${CHROOT}/etc/bind" ] || [ ! -d "${CHROOT}/var/bind" ] && return 1
[ ! -d "${CHROOT}/var/log/named" ] && return 1
[ ! -e "${CHROOT}/etc/localtime" ] && return 1
[ ! -c "${CHROOT}/dev/null" ] || [ ! -c "${CHROOT}/dev/zero" ] && return 1
[ ! -c "${CHROOT}/dev/random" ] && [ ! -c "${CHROOT}/dev/urandom" ] && return 1
fi
return 0
}
checkconfig() {
if [ ! -f "${NAMED_CONF}" ] ; then
eerror "No ${NAMED_CONF} file exists!"
fi
named-checkconf -z -j ${CHROOT:+-t} ${CHROOT} ${NAMED_CONF/${CHROOT}} 1>/dev/null || {
eerror "named-checkconf failed! Please fix your config first."
return 1
}
# as suggested in bug #107724
[ -n "${PIDFILE}" ] || PIDFILE=${CHROOT}$(\
egrep -v \
"^([[:cntrl:] ]+(#|//|/\*)|(#|//|/\*))" \
${CHROOT}/etc/bind/named.conf \
| egrep -o -m1 "pid\-file +\".+\" *;" \
| cut -d\" -f2
)
[ -z "${PIDFILE}" ] && PIDFILE=${CHROOT}/var/run/named/named.pid
return 0
}
start() {
local piddir
ebegin "Starting ${CHROOT:+chrooted }named"
if [ -n "${CHROOT}" ]; then
check_chroot || {
eend 1
eerror "Your chroot dir ${CHROOT} is inconsistent, please run 'emerge --config net-dns/bind' first"
return 1
}
if [ "${CHROOT_NOMOUNT:-0}" -eq 0 ]; then
einfo "Mounting chroot dirs"
_mount /etc/bind ${CHROOT}/etc/bind -o bind
_mount /var/bind ${CHROOT}/var/bind -o bind
_mount /var/log/named ${CHROOT}/var/log/named -o bind
fi
fi
checkconfig || {
eend 1
return 1
}
# create piddir (usually /var/run/named) if necessary
piddir="${PIDFILE%/*}"
if [ ! -d "${piddir}" ]; then
checkpath -q -d -o root:named -m 0770 "${piddir}" || {
eend 1
return 1
}
fi
# In case someone have $CPU set in /etc/conf.d/named
if [ -n "${CPU}" ] && [ "${CPU}" -gt 0 ]; then
CPU="-n ${CPU}"
fi
start-stop-daemon --start --pidfile ${PIDFILE} \
--nicelevel ${NAMED_NICELEVEL:-0} \
--exec /usr/sbin/named \
-- -u named ${CPU} ${OPTIONS} ${CHROOT:+-t} ${CHROOT}
eend $?
}
stop() {
local reported=0
ebegin "Stopping ${CHROOT:+chrooted }named"
checkconfig || return 2
if [ -n "${RNDC_KEY}" ] && [ -f "${RNDC_KEY}" ]; then
rndc $SERVER -k $RNDC_KEY stop 1>/dev/null
else
# -R 10, bug 335398
start-stop-daemon --stop --retry 10 --pidfile $PIDFILE \
--exec /usr/sbin/named
fi
if [ -n "${CHROOT}" ] && [ "${CHROOT_NOMOUNT:-0}" -eq 0 ]; then
einfo "Umounting chroot dirs"
# just to be sure everything gets clean
while [ -n "$(fuser ${CHROOT} 2>/dev/null)" ]; do
if [ "${reported}" -eq 0 ]; then
einfo "Waiting until all named processes are stopped"
reported=1
fi
sleep 1
done
_umount ${CHROOT}/etc/bind
_umount ${CHROOT}/var/log/named
_umount ${CHROOT}/var/bind
fi
eend $?
}
reload() {
local ret
# checkconf also gives us the pidfile.
checkconfig || return 3
ebegin "Reloading named.conf and zone files"
if [ -n "${RNDC_KEY}" ] && [ -f "${RNDC_KEY}" ] ; then
rndc $SERVER -k $RNDC_KEY reload 1>/dev/null
ret=$?
elif [ -n "${PIDFILE}" ]; then
# FIXME: Remove --stop and --oknodo as soon as baselayout-1 has been removed... finally...
start-stop-daemon --stop --oknodo --pidfile $PIDFILE --signal HUP --exec /usr/sbin/named
ret=$?
else
ewarn "Neither an rndc key has been specified nor a pidfile... this is"
ewarn "a fallback mode. Please check your installation!"
$RC_SERVICE restart
ret=$?
fi
eend $ret
}

View File

@@ -0,0 +1,203 @@
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-dns/bind/files/named.init-r9,v 1.2 2010/12/15 23:35:09 idl0r Exp $
opts="start stop reload restart checkconfig checkzones"
depend() {
need net
use logger
provide dns
}
NAMED_CONF=${CHROOT}/etc/bind/named.conf
_mount() {
local from
local to
local opts
if [ "${#}" -lt 3 ]; then
eerror "_mount(): to few arguments"
return 1
fi
from=$1
to=$2
shift 2
opts="${*}"
shift $#
if [ -z "$(awk "\$2 == \"${to}\" { print \$2 }" /proc/mounts)" ]; then
einfo "mounting ${from} to ${to}"
mount ${from} ${to} ${opts} || return 1
fi
return 0
}
_umount() {
local dir=$1
if [ -n "$(awk "\$2 == \"${dir}\" { print \$2 }" /proc/mounts)" ]; then
einfo "umount ${dir}"
umount ${dir} || return 1
fi
return 0
}
_get_pidfile() {
# as suggested in bug #107724, bug 335398#c17
[ -n "${PIDFILE}" ] || PIDFILE=${CHROOT}$(\
/usr/sbin/named-checkconf -p ${CHROOT:+-t} ${CHROOT} ${NAMED_CONF/${CHROOT}} | grep 'pid-file' | cut -d\" -f2)
[ -z "${PIDFILE}" ] && PIDFILE=${CHROOT}/var/run/named/named.pid
}
check_chroot() {
if [ -n "${CHROOT}" ]; then
[ ! -d "${CHROOT}" ] && return 1
[ ! -d "${CHROOT}/dev" ] || [ ! -d "${CHROOT}/etc" ] || [ ! -d "${CHROOT}/var" ] && return 1
[ ! -d "${CHROOT}/var/run" ] || [ ! -d "${CHROOT}/var/log" ] && return 1
[ ! -d "${CHROOT}/etc/bind" ] || [ ! -d "${CHROOT}/var/bind" ] && return 1
[ ! -d "${CHROOT}/var/log/named" ] && return 1
[ ! -e "${CHROOT}/etc/localtime" ] && return 1
[ ! -c "${CHROOT}/dev/null" ] || [ ! -c "${CHROOT}/dev/zero" ] && return 1
[ ! -c "${CHROOT}/dev/random" ] && [ ! -c "${CHROOT}/dev/urandom" ] && return 1
[ "${CHROOT_GEOIP:-0}" -eq 1 ] && [ ! -d "${CHROOT}/usr/share/GeoIP" ] && return 1
fi
return 0
}
checkconfig() {
ebegin "Checking named configuration"
if [ ! -f "${NAMED_CONF}" ] ; then
eerror "No ${NAMED_CONF} file exists!"
return 1
fi
/usr/sbin/named-checkconf ${CHROOT:+-t} ${CHROOT} ${NAMED_CONF/${CHROOT}} || {
eerror "named-checkconf failed! Please fix your config first."
return 1
}
eend 0
return 0
}
checkzones() {
ebegin "Checking named configuration and zones"
/usr/sbin/named-checkconf -z -j ${CHROOT:+-t} ${CHROOT} ${NAMED_CONF/${CHROOT}}
eend $?
}
start() {
local piddir
ebegin "Starting ${CHROOT:+chrooted }named"
if [ -n "${CHROOT}" ]; then
check_chroot || {
eend 1
eerror "Your chroot dir ${CHROOT} is inconsistent, please run 'emerge --config net-dns/bind' first"
return 1
}
if [ "${CHROOT_NOMOUNT:-0}" -eq 0 ]; then
einfo "Mounting chroot dirs"
_mount /etc/bind ${CHROOT}/etc/bind -o bind
_mount /var/bind ${CHROOT}/var/bind -o bind
_mount /var/log/named ${CHROOT}/var/log/named -o bind
if [ "${CHROOT_GEOIP:-0}" -eq 1 ]; then
_mount /usr/share/GeoIP ${CHROOT}/usr/share/GeoIP -o bind
fi
fi
fi
checkconfig || { eend 1; return 1; }
# create piddir (usually /var/run/named) if necessary, bug 334535
_get_pidfile
piddir="${PIDFILE%/*}"
if [ ! -d "${piddir}" ]; then
checkpath -q -d -o root:named -m 0770 "${piddir}" || {
eend 1
return 1
}
fi
# In case someone have $CPU set in /etc/conf.d/named
if [ -n "${CPU}" ] && [ "${CPU}" -gt 0 ]; then
CPU="-n ${CPU}"
fi
start-stop-daemon --start --pidfile ${PIDFILE} \
--nicelevel ${NAMED_NICELEVEL:-0} \
--exec /usr/sbin/named \
-- -u named ${CPU} ${OPTIONS} ${CHROOT:+-t} ${CHROOT}
eend $?
}
stop() {
local reported=0
ebegin "Stopping ${CHROOT:+chrooted }named"
# Workaround for now, until openrc's restart has been fixed.
# openrc doesn't care about a restart() function in init scripts.
if [ "${RC_CMD}" = "restart" ]; then
checkconfig || { eend 1; return 1; }
fi
# -R 10, bug 335398
_get_pidfile
start-stop-daemon --stop --retry 10 --pidfile $PIDFILE \
--exec /usr/sbin/named
if [ -n "${CHROOT}" ] && [ "${CHROOT_NOMOUNT:-0}" -eq 0 ]; then
ebegin "Umounting chroot dirs"
# just to be sure everything gets clean
while fuser -s ${CHROOT} 2>/dev/null; do
if [ "${reported}" -eq 0 ]; then
einfo "Waiting until all named processes are stopped"
reported=1
fi
sleep 1
done
[ "${CHROOT_GEOIP:-0}" -eq 1 ] && _umount ${CHROOT}/usr/share/GeoIP
_umount ${CHROOT}/etc/bind
_umount ${CHROOT}/var/log/named
_umount ${CHROOT}/var/bind
fi
eend $?
}
reload() {
local ret
ebegin "Reloading named.conf and zone files"
checkconfig || { eend 1; return 1; }
_get_pidfile
if [ -n "${PIDFILE}" ]; then
# FIXME: Remove --stop and --oknodo as soon as baselayout-1 has been removed... finally...
start-stop-daemon --stop --oknodo --pidfile $PIDFILE --signal HUP --exec /usr/sbin/named
ret=$?
else
ewarn "Unable to determine the pidfile... this is"
ewarn "a fallback mode. Please check your installation!"
$RC_SERVICE restart
ret=$?
fi
eend $ret
}