2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

contrib/dbus is deprecated

This commit is contained in:
Evan Hunt 2012-09-18 14:55:30 -07:00
parent 664320a88f
commit 1af6a932b0
14 changed files with 0 additions and 5848 deletions

View File

@ -1,31 +0,0 @@
#!/bin/bash
#
# This script uses the named D-BUS support, which must be enabled in
# the running named with the named '-D' option, to get and print the
# list of forwarding zones in the running server.
#
# It accepts an optional <zone> first argument which is the DNS name
# of the zone whose forwarders (if any) will be retrieved.
#
# If no zone argument is specified, all forwarding zones will be listed.
#
# Usage: GetForwarders [ <zone> ]
#
# Copyright(C) Jason Vas Dias<jvdias@redhat.com> Red Hat Inc. 2005
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation at
# http://www.fsf.org/licensing/licenses/gpl.txt
# and included in this software distribution as the "LICENSE" file.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
zone=''
if [ $# -gt 0 ]; then
zone="string:$1";
fi
dbus-send --system --type=method_call --print-reply --reply-timeout=20000 --dest=com.redhat.named /com/redhat/named com.redhat.named.text.GetForwarders $zone;

View File

@ -1,9 +0,0 @@
To build named with D-BUS support, run
# make
in this directory.
Then cd to the top-level BIND source directory,
(../..), and
# ./configure ...; make
After building, cd back to contrib/dbus and run:
# make install
as root to install the D-BUS configuration files.

View File

@ -1,20 +0,0 @@
# contrib/dbus/Makefile
#
# This Makefile will install D-BUS support into the ISC BIND 9.3.2b1+ source,
# necessary to support dynamic forwarding table management with D-BUS, for
# Red Hat NetworkManager support.
#
# After running "make" in this directory, simply run make in the top level
# BIND source directory, and D-BUS support will be enabled.
#
all:
echo 'Enabling D-BUS support...'
@ cp -fp dbus_mgr.c dbus_service.c ../../bin/named;
@ cp -fp dbus_mgr.h dbus_service.h ../../bin/named/include/named;
@ cp -fp README.DBUS ../../doc/misc
@ cd ../..; patch -s -p1 -b --suffix=.dbus < contrib/dbus/bind-9.3.2b1-dbus.patch
install:
install -o root -g root -m 640 named-dbus-system.conf /etc/dbus-1/system.d/named.conf
install -o root -g root -m 640 named-dbus.service /usr/share/dbus-1/services/named.service

View File

@ -1,20 +0,0 @@
# contrib/dbus/Makefile
#
# This Makefile will install D-BUS support into the ISC BIND 9.3.2b1+ source,
# necessary to support dynamic forwarding table management with D-BUS, for
# Red Hat NetworkManager support.
#
# After running "make" in this directory, simply run make in the top level
# BIND source directory, and D-BUS support will be enabled.
#
all:
echo 'Enabling D-BUS support...'
@ cp -fp dbus_mgr.c dbus_service.c ../../bin/named;
@ cp -fp dbus_mgr.h dbus_service.h ../../bin/named/include/named;
@ cp -fp README.DBUS ../../doc/misc
@ cd ../..; patch -s -p1 -b --suffix=.dbus < contrib/dbus/bind-9.3.3rc2-dbus.patch
install:
install -o root -g root -m 640 named-dbus-system.conf /etc/dbus-1/system.d/named.conf
install -o root -g root -m 640 named-dbus.service /usr/share/dbus-1/services/named.service

View File

@ -1,259 +0,0 @@
Dynamic Management of the ISC BIND named Forwarding Table with D-BUS
Jason Vas Dias<jvdias@redhat.com>, Red Hat Inc., May 2005
Overview:
Red Hat has developed an extension to named that is enabled during
rpmbuild of the bind SRPM with the option --define 'WITH_DBUS=1',
and at named runtime with the -D named option.
You can obtain the latest version of the source code for the BIND
D-BUS extensions from:
http://people.redhat.com/~jvdias/bind-dbus/
The Red Hat BIND D-BUS extensions allow services such as Red Hat's
NetworkManager and dhcdbd (the DHCP Client controller D-Bus daemon)
to tell named which name servers to forward requests to dynamically,
instead of only with the "forward" and "forwarders" named.conf options.
Dynamic forwarding table management allows named to be an effective
and efficient caching nameserver for configurations with multiple
wireless or VPN IP interfaces that are not always active, and whose
name service parameters are typically configured with DHCP.
Problems with trying to configure such systems automatically using
only the libc resolver, causing conflicts over the contents of the
/etc/resolv.conf file, are avoided; the resolv.conf file can contain
only the users chosen search path and the single "nameserver 127.0.0.1"
entry.
named also provides a much more efficient, both in terms of caching
performance and resolving time, and much more feature rich DNS resolver
than does the libc resolver library and nscd, and has the benefit of
existing improved IPv6 and DNSSEC support over glibc and nscd.
Operation Guide for Developers:
Programs can access named's dynamic forward table management services
using D-BUS, the "service messagebus" sysv-init service that is started
by default at boot (see the D-BUS documentation for details).
When named is started with the -D option (by adding -D to the $OPTIONS
variable in /etc/sysconfig/named), named provides two D-BUS methods:
These D-BUS names are common to all named D-BUS methods:
D-BUS Destination D-BUS Path D-BUS interface
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~~~~~~
com.redhat.named /com/redhat/named com.redhat.named
D-BUS Members:
~~~~~~~~~~~~~~
SetForwarders ( { [ string:<domain name>,
~~~~~~~~~~~~~ [ ( uint32:<nameserver IPv4 address>
| array of 4 bytes : <nameserver IPv4 address>
| array of 16 bytes : <nameserver IPv6 address>
| string: <nameserver dotted-quad IPv4 or RFC2374 IPv6 address>
)
[ uint16: <nameserver port>, ]
[ uint8: <forward policy> ]
]
]
} , ...
)
SetForwarders will create or delete members of the forwarding table.
It accepts a list of tuples of up to 4 members: only the <domain name>
is required.
If ONLY the <domain name> is specified, the forwarding entry for
EXACTLY that domain name is deleted if it exists.
Only a specification of at least one <nameserver IP address> is required to
create a forwarding entry.
The IP address can be IPv4:
( 32-bit integer OR array of 4 bytes OR dotted-quad string )
Or IPv6:
( array of 16 bytes
OR RFC 2373/4 ascii string of 8 ':' separate hex quads as supported by inet_pton(3)
)
32 and 16-bit integer parameters MUST be given in network byte order; ie the IPv4 address
192.168.2.1 would be specified as uint32:16951488 on an i386 and port 53 would be uint16:13568.
There are an optional <port> 16-bit integer parameter, to specify the name server socket
address port associated with the preceding IP address, and a <forward policy>
parameter, which sets the forward policy as follows:
0: "none" : never forward to this nameserver for this domain.
1: "first": forward first to this server, and then search its authoritative data.
2: "only" : always forward to this nameserver for this domain.
If not specified, <port> will have the value 53, and <forward policy> will be "2": "only".
named's default forward policy is "first" .
Creation of forwarding domains is not "exact", as is deletion, but is "inclusive":
creating forwarding entry for the '.' domain sets the default set of nameservers named
will query for ALL domains, and creating an entry for "redhat.com" creates a set of
nameservers to be queried for all names suffixed by "redhat.com." . If both are specified,
the "redhat.com" servers will be tried first, followed by the "." servers.
Forwarding entries are ONLY created in the first DNS View that matches the "localhost" client
(127.0.0.1) and destination. The default view, which exists if no views have been specified
in named.conf, matches ALL clients and destinations. If the user has configured views, none
of which match the localhost client, then no forwarding will be dynamically configurable.
Users are also free to configure a view that matches the localhost, for which forwarding
will be dynamically configurable, and other views which do not match the localhost, so that
other, remote clients can be served that will not be subject to dynamic forwarding. So it
is a fully supported configuration that users can serve authoritative data to external
clients and still use named's forwarding features for their localhost resolver.
SetForwarders returns uint32:0 on success or a DBUS_ERROR message on failure .
GetForwarders ( [ string:<domain name> ] )
~~~~~~~~~~~~~
Using the default "com.redhat.named" interface, returns the EXACT forwarding entry for
<domain name> as binary D-BUS types; there is also a com.redhat.named.text interface
supported by GetForwarders which returns all values as string: text .
If a <domain name> is not specified, all forwarding table entries are dumped.
Examples:
~~~~~~~~
Suppose we start out with the named.conf configuration:
options { ...
forwarders { 172.16.80.118; };
...
};
zone "redhat.com" {
forward only;
forwarders { 172.16.76.10; 172.16.52.28; };
};
Using a "dbus-send" trivially modified to support uint16 parameters (!) :
$ dbus-send --system --type=method_call --print-reply --reply-timeout=20000 \
--dest=com.redhat.named /com/redhat/named com.redhat.named.GetForwarders
method return sender=:1.367 -> dest=:1.368
0 string "redhat.com"
1 byte 2
2 uint32 172757164
3 uint16 13568
4 uint32 473174188
5 uint16 13568
6 string "."
7 byte 1
8 uint32 1984958636
9 uint16 13568
ie. GetForwarders always returns a list of tuples of
( <domain name>, <forward policy>, <ip address>, <port> )
If the "text" interface was specified:
$ dbus-send --system --type=method_call --print-reply --reply-timeout=20000 \
--dest=com.redhat.named /com/redhat/named com.redhat.named.text.GetForwarders
method return sender=:1.367 -> dest=:1.370
0 string "redhat.com"
1 string "only"
2 string "172.16.76.10"
3 string "53"
4 string "172.16.52.28"
5 string "53"
6 string "."
7 string "first"
8 string "172.16.80.118"
9 string "53"
So we could set the default nameserver for the root zone as follows:
$ dbus-send --system --type=method_call --print-reply --reply-timeout=20000 \
--dest=com.redhat.named /com/redhat/named com.redhat.named.SetForwarders \
string:'.' string:'192.33.14.30' string:'2001:503:231d::2:30'
method return sender=:1.367 -> dest=:1.371
0 uint32 0
$ dbus-send --system --type=method_call --print-reply --reply-timeout=20000 \
--dest=com.redhat.named /com/redhat/named com.redhat.named.text.GetForwarders
method return sender=:1.367 -> dest=:1.372
0 string "redhat.com"
1 string "only"
2 string "172.16.76.10"
3 string "53"
4 string "172.16.52.28"
5 string "53"
6 string "."
7 string "only"
8 string "192.33.14.30"
9 string "53"
10 string "2001:503:231d::2:30"
11 string "53"
Using tcpdump one can verify that named will attempt to contact 192.33.14.30, then
2001:503:231d::2:30, for all zones not in redhat.com; for redhat.com zones, 172.16.76.10
and 192.33.14.30 will be tried in that order.
If the D-BUS driver dbus-daemon should shut down, named will emit the syslog message:
"D-BUS service disabled."
And will retry connecting to D-BUS every 10 seconds - once it has connected, the message:
"D-BUS service enabled."
will be logged.
NOTE: there are the "SetForwarders" and "GetForwarders" scripts in the contrib/dbus directory
of the BIND source code distribution which are wrappers around the dbus-send commands above.
Usage: SetForwarders [ -t first | only ] <zone> [ <server> [...<server>] ]
GetForwarders [ <zone> ]
DHCP Integration
~~~~~~~~~~~~~~~~
With the -D option, named will try to subscribe to dhcdbd, the DHCP Client D-BUS Daemon, to
be notified of DHCP "reason", "domain-name", "domain-name-server", "ip-address", and "subnet-mask"
DHCP options when the dhclient program has received them from a DHCP server .
If it cannot subscribe to dhcdbd, named will emit the message :
"D-BUS dhcdbd subscription disabled."
and will monitor D-BUS "NameOwnerChanged" messages for the appearance of a new owner
for "com.redhat.dhcp". When the name is owned, named will send a "com.redhat.dhcp.subscribe.binary"
message to dhcdbd to subscribe to the above options for all interfaces (provided by dhcdbd-1.5+),
and emit the log message:
"D-BUS dhcdbd subscription enabled."
named will match on signals from the com.redhat.dhcp.subscribe.binary interface for those option
settings, and , when the last option is received (indicated by a "reason" of 15: END_OPTIONS), it
will configure the forwarding table .
For each whitespace separated member of "domain-name-servers", AND for the reverse IPv4 in-addr.arpa
class C or less domain of the ip-address masked by the subnet-mask, it will create a forwarding entry
to query each "domain-server" .
To support CIDR-based reverse subnet forwarding, Views would have to be configured dynamically, a
possible future direction which is not yet implemented. (It would perhaps be easier to add a
"match-queries" ACL to the forwarders table).
When dhclient acquires a lease, named will configure forwarding, and emit the message:
"D-BUS: dhclient for interface eth0 acquired new lease - creating forwarders."
When a lease expires or the interface is brought down (dhclient is stopped with dhcdbd), it
will revert any forwarding entries from the initial, static configuration that were modified
by the DHCP subscription to their initial values; ie. if redhat.com had a forwarder configured
in named.conf, and then an DHCP session specified forwarders for redhat.com, when the DHCP
session ends the forwarders for redhat.com are reverted to their named.conf values; thus
when all DHCP interfaces have released their leases, and if no SetForwarders commands were issued,
the forwarding configuration will be identical to that at named startup.
To Do:
- Sending signals when any Forwarding entry is changed (easy to implement if it would be desirable).
- CIDR based reverse Forwarding

View File

@ -1,52 +0,0 @@
#!/bin/bash
#
# This script uses the named D-BUS support, which must be enabled in
# the running named with the named '-D' option, to set the forwarding zones
# in the running server.
#
# One zone argument is required, followed by any number of server IP (v4 or v6)
# addresses. If the server IP address list is empty, any forwarders for the zone
# will be removed.
#
# Usage:
# SetForwarders [ -t <'first' | 'only'> ] <zone> [ <server IP> [...<server IP>] ]
#
# Copyright(C) Jason Vas Dias<jvdias@redhat.com> Red Hat Inc. 2005
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation at
# http://www.fsf.org/licensing/licenses/gpl.txt
# and included in this software distribution as the "LICENSE" file.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
usage() { echo "Usage: SetForwarders [ -t <'first' | 'only'> ] <zone> [ <server> [...<server>] ]"; }
type=''
if [ $# -eq 0 ]; then
usage;
exit 1;
elif [ "$1" = "-t" ]; then
if [ $# -lt 2 ]; then
echo '-t option requires an argument.'
exit 1;
fi;
type=$2;
shift 2;
fi;
if [ $# -lt 1 ]; then
echo '<zone> first argument required.'
exit 1;
fi;
zone='string:'"$1";
shift;
servers='';
if [ $# -gt 0 ]; then
for svr in $*; do
servers="$servers string:$svr";
done
fi;
dbus-send --system --type=method_call --print-reply --reply-timeout=20000 --dest=com.redhat.named /com/redhat/named com.redhat.named.text.SetForwarders $zone $type $servers;

View File

@ -1,713 +0,0 @@
--- bind-9.3.2b1/lib/dns/rbt.c.dbus 2005-06-17 21:03:24.000000000 -0400
+++ bind-9.3.2b1/lib/dns/rbt.c 2005-10-07 12:43:26.000000000 -0400
@@ -2172,6 +2172,47 @@
dns_rbt_printtree(rbt->root, NULL, 0);
}
+static void
+dns_rbt_traverse_tree(dns_rbtnode_t *root, dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2 ) {
+/*
+ * This is used ONLY to traverse the forward table by dbus_mgr at the moment.
+ * Since the forward table is not likely to be large, this can be recursive.
+ */
+ dns_name_t name;
+ dns_offsets_t offsets;
+ char buf[DNS_NAME_MAXWIRE];
+ isc_buffer_t buffer;
+
+ if (root != NULL) {
+
+ if (DOWN(root))
+ dns_rbt_traverse_tree(DOWN(root), cb, cb_arg1, cb_arg2);
+
+ if( LEFT(root) != NULL )
+ dns_rbt_traverse_tree(LEFT(root), cb, cb_arg1, cb_arg2);
+
+ if( RIGHT(root) != NULL )
+ dns_rbt_traverse_tree(RIGHT(root), cb, cb_arg1, cb_arg2);
+
+ if( DATA(root) == 0L )
+ return;
+
+ dns_name_init(&name, offsets);
+ isc_buffer_init(&buffer, buf, DNS_NAME_MAXWIRE);
+ dns_name_setbuffer( &name, &buffer);
+ dns_rbt_fullnamefromnode(root, &name);
+
+ (*cb)(&name, DATA(root), cb_arg1, cb_arg2);
+ }
+}
+
+void dns_rbt_traverse( dns_rbt_t *rbt, dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2 )
+{
+ REQUIRE(VALID_RBT(rbt));
+
+ dns_rbt_traverse_tree( rbt->root, cb, cb_arg1, cb_arg2 );
+}
+
/*
* Chain Functions
*/
--- bind-9.3.2b1/lib/dns/forward.c.dbus 2005-03-16 22:58:30.000000000 -0500
+++ bind-9.3.2b1/lib/dns/forward.c 2005-10-07 12:43:26.000000000 -0400
@@ -200,3 +200,89 @@
}
isc_mem_put(fwdtable->mctx, forwarders, sizeof(dns_forwarders_t));
}
+
+/***
+ *** new D-BUS Dynamic Forwarding Zones functions:
+ ***/
+isc_result_t
+dns_fwdtable_delete(dns_fwdtable_t *fwdtable, dns_name_t *name )
+{
+ isc_result_t result;
+
+ REQUIRE(VALID_FWDTABLE(fwdtable));
+
+ RWLOCK(&fwdtable->rwlock, isc_rwlocktype_write);
+
+ result = dns_rbt_deletename(fwdtable->table, name, ISC_FALSE);
+
+ RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_write);
+
+ return (result);
+}
+
+isc_result_t
+dns_fwdtable_find_closest(dns_fwdtable_t *fwdtable,
+ dns_name_t *name,
+ dns_name_t *foundname,
+ dns_forwarders_t **forwardersp)
+{
+ isc_result_t result;
+
+ REQUIRE(VALID_FWDTABLE(fwdtable));
+
+ RWLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
+
+ result = dns_rbt_findname(fwdtable->table, name, 0, foundname,
+ (void **)forwardersp);
+
+ if(result == DNS_R_PARTIALMATCH)
+ result = ISC_R_SUCCESS;
+
+ RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
+
+ return (result);
+}
+
+isc_result_t
+dns_fwdtable_find_exact(dns_fwdtable_t *fwdtable, dns_name_t *name,
+ dns_forwarders_t **forwardersp)
+{
+ isc_result_t result;
+
+ REQUIRE(VALID_FWDTABLE(fwdtable));
+
+ REQUIRE(forwardersp != 0L);
+
+ RWLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
+
+ result = dns_rbt_findname(fwdtable->table, name, 0, NULL,
+ (void **)forwardersp);
+
+ if( result != ISC_R_SUCCESS )
+ *forwardersp = 0L;
+
+ RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
+
+ return (result);
+}
+
+static
+void dns_fwdtable_traverse
+(
+ dns_name_t *name,
+ void *node_data,
+ void *cbp,
+ void *cb_arg
+)
+{
+ dns_fwdtable_callback_t cb = (dns_fwdtable_callback_t) cbp;
+
+ (*cb)( name, node_data, cb_arg);
+}
+
+void dns_fwdtable_foreach(dns_fwdtable_t *fwdtable, dns_fwdtable_callback_t cb, void *cb_arg )
+{
+ REQUIRE(VALID_FWDTABLE(fwdtable));
+
+ dns_rbt_traverse( fwdtable->table, dns_fwdtable_traverse, cb, cb_arg );
+}
--- bind-9.3.2b1/lib/dns/include/dns/forward.h.dbus 2005-03-16 22:58:31.000000000 -0500
+++ bind-9.3.2b1/lib/dns/include/dns/forward.h 2005-10-07 12:43:26.000000000 -0400
@@ -98,6 +98,37 @@
* all memory associated with the forwarding table is freed.
*/
+
+/* These are ONLY used by dbus_mgr :
+ */
+
+isc_result_t
+dns_fwdtable_delete( dns_fwdtable_t *fwdtable, dns_name_t *name );
+/*
+ * Removes an entry from the forwarding table.
+ */
+
+isc_result_t
+dns_fwdtable_find_exact(dns_fwdtable_t *fwdtable, dns_name_t *name,
+ dns_forwarders_t **forwardersp);
+/*
+ * Finds an exact match for "name" in the forwarding table.
+ */
+
+isc_result_t
+dns_fwdtable_find_closest(dns_fwdtable_t *fwdtable, dns_name_t *name, dns_name_t *foundname,
+ dns_forwarders_t **forwardersp);
+/*
+ * Finds the closest match for "*name" in the forwarding table, returning
+ * the actual name matching in *name if different to *name passed in.
+ */
+
+typedef void (*dns_fwdtable_callback_t)( dns_name_t *, dns_forwarders_t *, void *);
+void dns_fwdtable_foreach(dns_fwdtable_t *fwdtable, dns_fwdtable_callback_t cb, void * );
+/* Invoke cb for each member of fwdtable
+ */
+
+
ISC_LANG_ENDDECLS
#endif /* DNS_FORWARD_H */
--- bind-9.3.2b1/lib/dns/include/dns/rbt.h.dbus 2004-10-11 01:55:51.000000000 -0400
+++ bind-9.3.2b1/lib/dns/include/dns/rbt.h 2005-10-07 12:43:26.000000000 -0400
@@ -833,6 +833,17 @@
* <something_else> Any error result from dns_name_concatenate.
*/
+
+typedef void (*dns_rbt_traverse_callback_t)( dns_name_t *name,
+ void *node_data,
+ void *cb_arg1,
+ void *cb_arg2);
+
+void dns_rbt_traverse( dns_rbt_t *rbt, dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2 );
+/* tree traversal function (only used by D-BUS dynamic forwarding dbus_mgr at
+ * the moment)
+ */
+
ISC_LANG_ENDDECLS
#endif /* DNS_RBT_H */
--- bind-9.3.2b1/lib/isc/unix/socket.c.dbus 2005-08-25 00:32:55.000000000 -0400
+++ bind-9.3.2b1/lib/isc/unix/socket.c 2005-10-07 13:40:03.000000000 -0400
@@ -148,6 +148,11 @@
ISC_LIST(isc_socketevent_t) recv_list;
ISC_LIST(isc_socket_newconnev_t) accept_list;
isc_socket_connev_t *connect_ev;
+
+ /* these are used only by isc_sockettype_fd sockets:*/
+ isc_socketevent_t *read_ready_event;
+ isc_socketevent_t *write_ready_event;
+ isc_socketevent_t *selected_event;
/*
* Internal events. Posted when a descriptor is readable or
@@ -304,7 +309,7 @@
static void
wakeup_socket(isc_socketmgr_t *manager, int fd, int msg) {
- isc_socket_t *sock;
+ isc_socket_t *sock=0L;
/*
* This is a wakeup on a socket. If the socket is not in the
@@ -1266,6 +1271,9 @@
sock->connected = 0;
sock->connecting = 0;
sock->bound = 0;
+ sock->read_ready_event = 0L;
+ sock->write_ready_event = 0L;
+ sock->selected_event = 0L;
/*
* initialize the lock
@@ -1378,13 +1386,16 @@
case isc_sockettype_tcp:
sock->fd = socket(pf, SOCK_STREAM, IPPROTO_TCP);
break;
+
+ case isc_sockettype_fd:
+ sock->fd = pf;
}
#ifdef F_DUPFD
/*
* Leave a space for stdio to work in.
*/
- if (sock->fd >= 0 && sock->fd < 20) {
+ if ( (type != isc_sockettype_fd) && (sock->fd >= 0) && (sock->fd < 20) ) {
int new, tmp;
new = fcntl(sock->fd, F_DUPFD, 20);
tmp = errno;
@@ -1438,7 +1449,7 @@
}
}
- if (make_nonblock(sock->fd) != ISC_R_SUCCESS) {
+ if ((type != isc_sockettype_fd) && (make_nonblock(sock->fd) != ISC_R_SUCCESS)) {
(void)close(sock->fd);
free_socket(&sock);
return (ISC_R_UNEXPECTED);
@@ -1706,6 +1717,38 @@
isc_task_send(ev->ev_sender, (isc_event_t **)&iev);
}
+static
+isc_event_t *dispatch_read_ready(isc_socketmgr_t *manager, isc_socket_t *sock)
+{
+ isc_event_t *dev = (isc_event_t*)sock->read_ready_event, *ev;
+
+ ev = isc_mem_get(manager->mctx, dev->ev_size);
+ memcpy(ev,dev,dev->ev_size);
+ ISC_LINK_INIT(ev,ev_link);
+ isc_task_send(dev->ev_sender, &ev );
+ return (isc_event_t *)sock->selected_event;
+}
+
+static
+isc_event_t *dispatch_write_ready(isc_socketmgr_t *manager,isc_socket_t *sock)
+{
+ isc_event_t *dev = (isc_event_t*)sock->write_ready_event, *ev;
+ ev = isc_mem_get(manager->mctx, dev->ev_size);
+ memcpy(ev,dev,dev->ev_size);
+ ISC_LINK_INIT(ev,ev_link);
+ isc_task_send(dev->ev_sender, &ev );
+ return (isc_event_t *)sock->selected_event;
+}
+
+static
+void dispatch_selected(isc_socketmgr_t *manager, isc_event_t *dev)
+{ isc_event_t *ev;
+ ev = isc_mem_get(manager->mctx, dev->ev_size);
+ memcpy(ev,dev,dev->ev_size);
+ ISC_LINK_INIT(ev,ev_link);
+ isc_task_send(dev->ev_sender, &ev );
+}
+
/*
* Dequeue an item off the given socket's read queue, set the result code
* in the done event to the one provided, and send it to the task it was
@@ -2113,6 +2156,7 @@
int i;
isc_socket_t *sock;
isc_boolean_t unlock_sock;
+ isc_event_t *sock_selected = 0L;
REQUIRE(maxfd <= (int)FD_SETSIZE);
@@ -2146,11 +2190,15 @@
unlock_sock = ISC_TRUE;
LOCK(&sock->lock);
if (!SOCK_DEAD(sock)) {
+ if( sock->type != isc_sockettype_fd )
+ {
if (sock->listener)
dispatch_accept(sock);
else
dispatch_recv(sock);
- }
+ }else
+ sock_selected = dispatch_read_ready(manager,sock);
+ }
FD_CLR(i, &manager->read_fds);
}
check_write:
@@ -2164,16 +2212,24 @@
LOCK(&sock->lock);
}
if (!SOCK_DEAD(sock)) {
+ if( sock->type != isc_sockettype_fd )
+ {
if (sock->connecting)
dispatch_connect(sock);
else
dispatch_send(sock);
+ }else
+ sock_selected = dispatch_write_ready(manager,sock);
}
FD_CLR(i, &manager->write_fds);
}
if (unlock_sock)
UNLOCK(&sock->lock);
}
+ if( sock_selected != 0L )
+ {
+ dispatch_selected(manager, sock_selected);
+ }
}
#ifdef ISC_PLATFORM_USETHREADS
@@ -2192,7 +2248,7 @@
int cc;
fd_set readfds;
fd_set writefds;
- int msg, fd;
+ int msg, fd = -1;
int maxfd;
char strbuf[ISC_STRERRORSIZE];
@@ -3523,3 +3579,55 @@
return (ISC_R_SUCCESS);
}
#endif /* ISC_PLATFORM_USETHREADS */
+
+isc_socketevent_t*
+isc_socket_fd_handle_reads( isc_socket_t *sock, isc_socketevent_t *dev )
+{
+ REQUIRE(VALID_SOCKET(sock));
+ if(dev != 0L)
+ {
+ sock->references=1;
+ sock->read_ready_event = dev;
+ select_poke(sock->manager, sock->fd, SELECT_POKE_READ);
+ }else
+ {
+ dev = sock->read_ready_event ;
+ sock->read_ready_event = 0L ;
+ }
+ return dev;
+}
+
+isc_socketevent_t*
+isc_socket_fd_handle_writes( isc_socket_t *sock, isc_socketevent_t *dev )
+{
+ REQUIRE(VALID_SOCKET(sock));
+ if(dev != 0L)
+ {
+ sock->references=1;
+ sock->write_ready_event = dev;
+ select_poke(sock->manager, sock->fd, SELECT_POKE_WRITE);
+ }else
+ {
+ dev = sock->write_ready_event;
+ sock->write_ready_event = 0L;
+ }
+ return dev;
+}
+
+isc_socketevent_t*
+isc_socket_fd_handle_selected( isc_socket_t *sock, isc_socketevent_t *dev )
+{
+ REQUIRE(VALID_SOCKET(sock));
+ if(dev != 0L)
+ {
+ sock->references=1;
+ sock->selected_event = dev;
+ }else
+ {
+ dev = sock->selected_event;
+ sock->selected_event = 0L;
+ sock->references=0;
+ destroy(&sock);
+ }
+ return dev;
+}
--- bind-9.3.2b1/lib/isc/include/isc/socket.h.dbus 2004-03-08 04:04:53.000000000 -0500
+++ bind-9.3.2b1/lib/isc/include/isc/socket.h 2005-10-07 12:43:26.000000000 -0400
@@ -136,6 +136,10 @@
#define ISC_SOCKEVENT_NEWCONN (ISC_EVENTCLASS_SOCKET + 3)
#define ISC_SOCKEVENT_CONNECT (ISC_EVENTCLASS_SOCKET + 4)
+#define ISC_SOCKEVENT_READ_READY (ISC_EVENTCLASS_SOCKET + 5)
+#define ISC_SOCKEVENT_WRITE_READY (ISC_EVENTCLASS_SOCKET + 6)
+#define ISC_SOCKEVENT_SELECTED (ISC_EVENTCLASS_SOCKET + 7)
+
/*
* Internal events.
*/
@@ -144,7 +148,8 @@
typedef enum {
isc_sockettype_udp = 1,
- isc_sockettype_tcp = 2
+ isc_sockettype_tcp = 2,
+ isc_sockettype_fd = 8
} isc_sockettype_t;
/*
@@ -699,6 +704,30 @@
* 'sock' is a valid socket.
*/
+isc_socketevent_t*
+isc_socket_fd_handle_reads( isc_socket_t *sock, isc_socketevent_t *dev );
+/* register the "dev" event to be sent when the isc_sockettype_fd sock
+ * was select()-ed for read. If there is already an event registered, it
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
+ * registered event.
+ */
+
+isc_socketevent_t*
+isc_socket_fd_handle_writes( isc_socket_t *sock, isc_socketevent_t *dev );
+/* register the "dev" event to be sent when the isc_sockettype_fd sock
+ * was select()-ed for write. If there is already an event registered, it
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
+ * registered event.
+ */
+
+isc_socketevent_t*
+isc_socket_fd_handle_selected( isc_socket_t *sock, isc_socketevent_t *dev );
+/* register the "dev" event to be sent when ALL isc_sockettype_fd sockets
+ * have been select()-ed . If there is already an event registered, it
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
+ * registered event.
+ */
+
ISC_LANG_ENDDECLS
#endif /* ISC_SOCKET_H */
--- bind-9.3.2b1/bin/named/log.c.dbus 2005-05-24 19:58:17.000000000 -0400
+++ bind-9.3.2b1/bin/named/log.c 2005-10-07 12:43:26.000000000 -0400
@@ -41,6 +41,7 @@
{ "queries", 0 },
{ "unmatched", 0 },
{ "update-security", 0 },
+ { "dbus", 0 },
{ NULL, 0 }
};
@@ -60,6 +61,7 @@
{ "notify", 0 },
{ "control", 0 },
{ "lwresd", 0 },
+ { "dbus", 0 },
{ NULL, 0 }
};
--- bind-9.3.2b1/bin/named/Makefile.in.dbus 2004-09-06 17:47:25.000000000 -0400
+++ bind-9.3.2b1/bin/named/Makefile.in 2005-10-07 13:44:22.000000000 -0400
@@ -35,7 +35,9 @@
${LWRES_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES} \
${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
${DBDRIVER_INCLUDES}
-
+DBUS_ARCHDEP_LIBDIR ?= lib
+DBUS_INCLUDES = \
+ -I/usr/${DBUS_ARCHDEP_LIBDIR}/dbus-1.0/include -I/usr/include/dbus-1.0
CDEFINES =
CWARNINGS =
@@ -52,6 +54,7 @@
ISCDEPLIBS = ../../lib/isc/libisc.@A@
LWRESDEPLIBS = ../../lib/lwres/liblwres.@A@
BIND9DEPLIBS = ../../lib/bind9/libbind9.@A@
+DBUSLIBS= -ldbus-1
DEPLIBS = ${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
${ISCCFGDEPLIBS} ${ISCCCDEPLIBS} ${ISCDEPLIBS}
@@ -71,6 +74,7 @@
zoneconf.@O@ \
lwaddr.@O@ lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \
lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \
+ dbus_service.@O@ dbus_mgr.@O@ \
$(DBDRIVER_OBJS)
UOBJS = unix/os.@O@
@@ -83,6 +87,7 @@
zoneconf.c \
lwaddr.c lwresd.c lwdclient.c lwderror.c lwdgabn.c \
lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \
+ dbus_service.c dbus_mgr.c \
$(DBDRIVER_SRCS)
MANPAGES = named.8 lwresd.8 named.conf.5
@@ -105,9 +110,14 @@
-DNS_LOCALSTATEDIR=\"${localstatedir}\" \
-c ${srcdir}/config.c
+dbus_service.@O@: dbus_service.c
+ ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
+ ${DBUS_INCLUDES} \
+ -c ${srcdir}/dbus_service.c
+
named@EXEEXT@: ${OBJS} ${UOBJS} ${DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- ${OBJS} ${UOBJS} ${LIBS}
+ ${OBJS} ${UOBJS} ${LIBS} ${DBUSLIBS}
lwresd@EXEEXT@: named@EXEEXT@
rm -f lwresd@EXEEXT@
--- bind-9.3.2b1/bin/named/named.8.dbus 2005-05-12 22:43:20.000000000 -0400
+++ bind-9.3.2b1/bin/named/named.8 2005-10-07 13:50:12.000000000 -0400
@@ -41,7 +41,7 @@
named \- Internet domain name server
.SH "SYNOPSIS"
.HP 6
-\fBnamed\fR [\fB\-4\fR] [\fB\-6\fR] [\fB\-c\ \fIconfig\-file\fR\fR] [\fB\-d\ \fIdebug\-level\fR\fR] [\fB\-f\fR] [\fB\-g\fR] [\fB\-n\ \fI#cpus\fR\fR] [\fB\-p\ \fIport\fR\fR] [\fB\-s\fR] [\fB\-t\ \fIdirectory\fR\fR] [\fB\-u\ \fIuser\fR\fR] [\fB\-v\fR] [\fB\-x\ \fIcache\-file\fR\fR]
+\fBnamed\fR [\fB\-4\fR] [\fB\-6\fR] [\fB\-c\ \fIconfig\-file\fR\fR] [\fB\-d\ \fIdebug\-level\fR\fR] [\fB\-f\fR] [\fB\-g\fR] [\fB\-n\ \fI#cpus\fR\fR] [\fB\-p\ \fIport\fR\fR] [\fB\-s\fR] [\fB\-t\ \fIdirectory\fR\fR] [\fB\-u\ \fIuser\fR\fR] [\fB\-v\fR] [\fB\-x\ \fIcache\-file\fR\fR] [\fB\-D\fR]
.SH "DESCRIPTION"
.PP
\fBnamed\fR is a Domain Name System (DNS) server, part of the BIND 9 distribution from ISC\&. For more information on the DNS, see RFCs 1033, 1034, and 1035\&.
@@ -103,6 +103,13 @@
.B "Warning:"
This option must not be used\&. It is only of interest to BIND 9 developers and may be removed or changed in a future release\&.
.RE
+.sp
+.TP
+\fB\-D\fR
+Enable dynamic management of the forwarding table with D-BUS
+messages. This option is required for Red Hat NetworkManager
+support. See doc/README.DBUS .
+.sp
.SH "SIGNALS"
.PP
In routine operation, signals should not be used to control the nameserver; \fBrndc\fR should be used instead\&.
@@ -117,6 +124,7 @@
.SH "CONFIGURATION"
.PP
The \fBnamed\fR configuration file is too complex to describe in detail here\&. A complete description is provided in the BIND 9 Administrator Reference Manual\&.
+.PP
.SH "FILES"
.TP
\fI/etc/named\&.conf\fR
--- bind-9.3.2b1/bin/named/main.c.dbus 2005-04-28 21:04:47.000000000 -0400
+++ bind-9.3.2b1/bin/named/main.c 2005-10-07 12:43:26.000000000 -0400
@@ -239,7 +239,8 @@
"usage: named [-4|-6] [-c conffile] [-d debuglevel] "
"[-f|-g] [-n number_of_cpus]\n"
" [-p port] [-s] [-t chrootdir] [-u username]\n"
- " [-m {usage|trace|record}]\n");
+ " [-m {usage|trace|record}]\n"
+ " [-D ]\n");
}
static void
@@ -345,7 +346,7 @@
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv,
- "46c:C:d:fgi:lm:n:N:p:P:st:u:vx:")) != -1) {
+ "46c:C:d:fgi:lm:n:N:p:P:st:u:vx:D")) != -1) {
switch (ch) {
case '4':
if (disable4)
@@ -434,6 +435,9 @@
case 'v':
printf("BIND %s\n", ns_g_version);
exit(0);
+ case 'D':
+ ns_g_dbus = 1;
+ break;
case '?':
usage();
ns_main_earlyfatal("unknown option '-%c'",
--- bind-9.3.2b1/bin/named/server.c.dbus 2005-07-26 22:53:15.000000000 -0400
+++ bind-9.3.2b1/bin/named/server.c 2005-10-07 12:43:26.000000000 -0400
@@ -86,6 +86,8 @@
#include <stdlib.h>
#endif
+#include <named/dbus_mgr.h>
+
/*
* Check an operation for failure. Assumes that the function
* using it has a 'result' variable and a 'cleanup' label.
@@ -1496,12 +1498,12 @@
if (result != ISC_R_SUCCESS) {
char namebuf[DNS_NAME_FORMATSIZE];
dns_name_format(origin, namebuf, sizeof(namebuf));
- cfg_obj_log(forwarders, ns_g_lctx, ISC_LOG_WARNING,
- "could not set up forwarding for domain '%s': %s",
+ cfg_obj_log(forwarders, ns_g_lctx, ISC_LOG_NOTICE,
+ "setting up forwarding failed for domain '%s': %s",
namebuf, isc_result_totext(result));
goto cleanup;
}
-
+
result = ISC_R_SUCCESS;
cleanup:
@@ -2873,6 +2875,20 @@
CHECKFATAL(load_zones(server, ISC_FALSE), "loading zones");
+ server->dbus_mgr = 0L;
+ if( ns_g_dbus )
+ if( dbus_mgr_create
+ ( ns_g_mctx, ns_g_taskmgr, ns_g_socketmgr, ns_g_timermgr,
+ &server->dbus_mgr
+ ) != ISC_R_SUCCESS
+ )
+ {
+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
+ NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
+ "dbus_mgr initialization failed. D-BUS service is disabled."
+ );
+ }
+
ns_os_started();
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
ISC_LOG_NOTICE, "running");
@@ -2935,6 +2951,9 @@
dns_db_detach(&server->in_roothints);
+ if( server->dbus_mgr != 0L )
+ dbus_mgr_shutdown(server->dbus_mgr);
+
isc_task_endexclusive(server->task);
isc_task_detach(&server->task);
--- bind-9.3.2b1/bin/named/include/named/globals.h.dbus 2004-03-07 23:04:20.000000000 -0500
+++ bind-9.3.2b1/bin/named/include/named/globals.h 2005-10-07 13:47:36.000000000 -0400
@@ -112,6 +112,8 @@
EXTERN int ns_g_listen INIT(3);
+EXTERN int ns_g_dbus INIT(0);
+
#undef EXTERN
#undef INIT
--- bind-9.3.2b1/bin/named/include/named/server.h.dbus 2004-03-07 23:04:21.000000000 -0500
+++ bind-9.3.2b1/bin/named/include/named/server.h 2005-10-07 12:43:26.000000000 -0400
@@ -91,7 +91,8 @@
ns_controls_t * controls; /* Control channels */
unsigned int dispatchgen;
ns_dispatchlist_t dispatches;
-
+
+ ns_dbus_mgr_t * dbus_mgr;
};
#define NS_SERVER_MAGIC ISC_MAGIC('S','V','E','R')
--- bind-9.3.2b1/bin/named/include/named/log.h.dbus 2004-03-07 23:04:21.000000000 -0500
+++ bind-9.3.2b1/bin/named/include/named/log.h 2005-10-07 12:43:26.000000000 -0400
@@ -34,6 +34,7 @@
#define NS_LOGCATEGORY_QUERIES (&ns_g_categories[4])
#define NS_LOGCATEGORY_UNMATCHED (&ns_g_categories[5])
#define NS_LOGCATEGORY_UPDATE_SECURITY (&ns_g_categories[6])
+#define NS_LOGCATEGORY_DBUS (&ns_g_categories[7])
/*
* Backwards compatibility.
@@ -51,6 +52,7 @@
#define NS_LOGMODULE_NOTIFY (&ns_g_modules[8])
#define NS_LOGMODULE_CONTROL (&ns_g_modules[9])
#define NS_LOGMODULE_LWRESD (&ns_g_modules[10])
+#define NS_LOGMODULE_DBUS (&ns_g_modules[11])
isc_result_t
ns_log_init(isc_boolean_t safe);
--- bind-9.3.2b1/bin/named/include/named/types.h.dbus 2004-03-06 05:21:26.000000000 -0500
+++ bind-9.3.2b1/bin/named/include/named/types.h 2005-10-07 12:43:26.000000000 -0400
@@ -38,4 +38,6 @@
typedef struct ns_dispatch ns_dispatch_t;
typedef ISC_LIST(ns_dispatch_t) ns_dispatchlist_t;
+typedef struct ns_dbus_mgr ns_dbus_mgr_t ;
+
#endif /* NAMED_TYPES_H */

View File

@ -1,778 +0,0 @@
--- bind-9.3.3rc2/lib/dns/forward.c.dbus 2005-03-17 04:58:30.000000000 +0100
+++ bind-9.3.3rc2/lib/dns/forward.c 2006-09-18 10:08:37.000000000 +0200
@@ -200,3 +200,89 @@
}
isc_mem_put(fwdtable->mctx, forwarders, sizeof(dns_forwarders_t));
}
+
+/***
+ *** new D-BUS Dynamic Forwarding Zones functions:
+ ***/
+isc_result_t
+dns_fwdtable_delete(dns_fwdtable_t *fwdtable, dns_name_t *name )
+{
+ isc_result_t result;
+
+ REQUIRE(VALID_FWDTABLE(fwdtable));
+
+ RWLOCK(&fwdtable->rwlock, isc_rwlocktype_write);
+
+ result = dns_rbt_deletename(fwdtable->table, name, ISC_FALSE);
+
+ RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_write);
+
+ return (result);
+}
+
+isc_result_t
+dns_fwdtable_find_closest(dns_fwdtable_t *fwdtable,
+ dns_name_t *name,
+ dns_name_t *foundname,
+ dns_forwarders_t **forwardersp)
+{
+ isc_result_t result;
+
+ REQUIRE(VALID_FWDTABLE(fwdtable));
+
+ RWLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
+
+ result = dns_rbt_findname(fwdtable->table, name, 0, foundname,
+ (void **)forwardersp);
+
+ if(result == DNS_R_PARTIALMATCH)
+ result = ISC_R_SUCCESS;
+
+ RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
+
+ return (result);
+}
+
+isc_result_t
+dns_fwdtable_find_exact(dns_fwdtable_t *fwdtable, dns_name_t *name,
+ dns_forwarders_t **forwardersp)
+{
+ isc_result_t result;
+
+ REQUIRE(VALID_FWDTABLE(fwdtable));
+
+ REQUIRE(forwardersp != 0L);
+
+ RWLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
+
+ result = dns_rbt_findname(fwdtable->table, name, 0, NULL,
+ (void **)forwardersp);
+
+ if( result != ISC_R_SUCCESS )
+ *forwardersp = 0L;
+
+ RWUNLOCK(&fwdtable->rwlock, isc_rwlocktype_read);
+
+ return (result);
+}
+
+static
+void dns_fwdtable_traverse
+(
+ dns_name_t *name,
+ void *node_data,
+ void *cbp,
+ void *cb_arg
+)
+{
+ dns_fwdtable_callback_t cb = (dns_fwdtable_callback_t) cbp;
+
+ (*cb)( name, node_data, cb_arg);
+}
+
+void dns_fwdtable_foreach(dns_fwdtable_t *fwdtable, dns_fwdtable_callback_t cb, void *cb_arg )
+{
+ REQUIRE(VALID_FWDTABLE(fwdtable));
+
+ dns_rbt_traverse( fwdtable->table, dns_fwdtable_traverse, cb, cb_arg );
+}
--- bind-9.3.3rc2/lib/dns/include/dns/forward.h.dbus 2005-03-17 04:58:31.000000000 +0100
+++ bind-9.3.3rc2/lib/dns/include/dns/forward.h 2006-09-18 10:08:37.000000000 +0200
@@ -98,6 +98,37 @@
* all memory associated with the forwarding table is freed.
*/
+
+/* These are ONLY used by dbus_mgr :
+ */
+
+isc_result_t
+dns_fwdtable_delete( dns_fwdtable_t *fwdtable, dns_name_t *name );
+/*
+ * Removes an entry from the forwarding table.
+ */
+
+isc_result_t
+dns_fwdtable_find_exact(dns_fwdtable_t *fwdtable, dns_name_t *name,
+ dns_forwarders_t **forwardersp);
+/*
+ * Finds an exact match for "name" in the forwarding table.
+ */
+
+isc_result_t
+dns_fwdtable_find_closest(dns_fwdtable_t *fwdtable, dns_name_t *name, dns_name_t *foundname,
+ dns_forwarders_t **forwardersp);
+/*
+ * Finds the closest match for "*name" in the forwarding table, returning
+ * the actual name matching in *name if different to *name passed in.
+ */
+
+typedef void (*dns_fwdtable_callback_t)( dns_name_t *, dns_forwarders_t *, void *);
+void dns_fwdtable_foreach(dns_fwdtable_t *fwdtable, dns_fwdtable_callback_t cb, void * );
+/* Invoke cb for each member of fwdtable
+ */
+
+
ISC_LANG_ENDDECLS
#endif /* DNS_FORWARD_H */
--- bind-9.3.3rc2/lib/dns/include/dns/rbt.h.dbus 2004-10-11 07:55:51.000000000 +0200
+++ bind-9.3.3rc2/lib/dns/include/dns/rbt.h 2006-09-18 10:08:37.000000000 +0200
@@ -833,6 +833,17 @@
* <something_else> Any error result from dns_name_concatenate.
*/
+
+typedef void (*dns_rbt_traverse_callback_t)( dns_name_t *name,
+ void *node_data,
+ void *cb_arg1,
+ void *cb_arg2);
+
+void dns_rbt_traverse( dns_rbt_t *rbt, dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2 );
+/* tree traversal function (only used by D-BUS dynamic forwarding dbus_mgr at
+ * the moment)
+ */
+
ISC_LANG_ENDDECLS
#endif /* DNS_RBT_H */
--- bind-9.3.3rc2/lib/dns/rbt.c.dbus 2005-06-18 03:03:24.000000000 +0200
+++ bind-9.3.3rc2/lib/dns/rbt.c 2006-09-18 10:08:37.000000000 +0200
@@ -2172,6 +2172,47 @@
dns_rbt_printtree(rbt->root, NULL, 0);
}
+static void
+dns_rbt_traverse_tree(dns_rbtnode_t *root, dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2 ) {
+/*
+ * This is used ONLY to traverse the forward table by dbus_mgr at the moment.
+ * Since the forward table is not likely to be large, this can be recursive.
+ */
+ dns_name_t name;
+ dns_offsets_t offsets;
+ char buf[DNS_NAME_MAXWIRE];
+ isc_buffer_t buffer;
+
+ if (root != NULL) {
+
+ if (DOWN(root))
+ dns_rbt_traverse_tree(DOWN(root), cb, cb_arg1, cb_arg2);
+
+ if( LEFT(root) != NULL )
+ dns_rbt_traverse_tree(LEFT(root), cb, cb_arg1, cb_arg2);
+
+ if( RIGHT(root) != NULL )
+ dns_rbt_traverse_tree(RIGHT(root), cb, cb_arg1, cb_arg2);
+
+ if( DATA(root) == 0L )
+ return;
+
+ dns_name_init(&name, offsets);
+ isc_buffer_init(&buffer, buf, DNS_NAME_MAXWIRE);
+ dns_name_setbuffer( &name, &buffer);
+ dns_rbt_fullnamefromnode(root, &name);
+
+ (*cb)(&name, DATA(root), cb_arg1, cb_arg2);
+ }
+}
+
+void dns_rbt_traverse( dns_rbt_t *rbt, dns_rbt_traverse_callback_t cb, void *cb_arg1, void *cb_arg2 )
+{
+ REQUIRE(VALID_RBT(rbt));
+
+ dns_rbt_traverse_tree( rbt->root, cb, cb_arg1, cb_arg2 );
+}
+
/*
* Chain Functions
*/
--- bind-9.3.3rc2/lib/isc/include/isc/socket.h.dbus 2004-03-08 10:04:53.000000000 +0100
+++ bind-9.3.3rc2/lib/isc/include/isc/socket.h 2006-09-18 10:08:37.000000000 +0200
@@ -136,6 +136,10 @@
#define ISC_SOCKEVENT_NEWCONN (ISC_EVENTCLASS_SOCKET + 3)
#define ISC_SOCKEVENT_CONNECT (ISC_EVENTCLASS_SOCKET + 4)
+#define ISC_SOCKEVENT_READ_READY (ISC_EVENTCLASS_SOCKET + 5)
+#define ISC_SOCKEVENT_WRITE_READY (ISC_EVENTCLASS_SOCKET + 6)
+#define ISC_SOCKEVENT_SELECTED (ISC_EVENTCLASS_SOCKET + 7)
+
/*
* Internal events.
*/
@@ -144,7 +148,8 @@
typedef enum {
isc_sockettype_udp = 1,
- isc_sockettype_tcp = 2
+ isc_sockettype_tcp = 2,
+ isc_sockettype_fd = 8
} isc_sockettype_t;
/*
@@ -699,6 +704,30 @@
* 'sock' is a valid socket.
*/
+isc_socketevent_t*
+isc_socket_fd_handle_reads( isc_socket_t *sock, isc_socketevent_t *dev );
+/* register the "dev" event to be sent when the isc_sockettype_fd sock
+ * was select()-ed for read. If there is already an event registered, it
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
+ * registered event.
+ */
+
+isc_socketevent_t*
+isc_socket_fd_handle_writes( isc_socket_t *sock, isc_socketevent_t *dev );
+/* register the "dev" event to be sent when the isc_sockettype_fd sock
+ * was select()-ed for write. If there is already an event registered, it
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
+ * registered event.
+ */
+
+isc_socketevent_t*
+isc_socket_fd_handle_selected( isc_socket_t *sock, isc_socketevent_t *dev );
+/* register the "dev" event to be sent when ALL isc_sockettype_fd sockets
+ * have been select()-ed . If there is already an event registered, it
+ * is returned, otherwise 0 is returned. If dev is 0, removes any existing
+ * registered event.
+ */
+
ISC_LANG_ENDDECLS
#endif /* ISC_SOCKET_H */
--- bind-9.3.3rc2/lib/isc/unix/socket.c.dbus 2006-05-19 04:53:36.000000000 +0200
+++ bind-9.3.3rc2/lib/isc/unix/socket.c 2006-09-18 10:08:37.000000000 +0200
@@ -148,6 +148,11 @@
ISC_LIST(isc_socketevent_t) recv_list;
ISC_LIST(isc_socket_newconnev_t) accept_list;
isc_socket_connev_t *connect_ev;
+
+ /* these are used only by isc_sockettype_fd sockets:*/
+ isc_socketevent_t *read_ready_event;
+ isc_socketevent_t *write_ready_event;
+ isc_socketevent_t *selected_event;
/*
* Internal events. Posted when a descriptor is readable or
@@ -304,7 +309,7 @@
static void
wakeup_socket(isc_socketmgr_t *manager, int fd, int msg) {
- isc_socket_t *sock;
+ isc_socket_t *sock=0L;
/*
* This is a wakeup on a socket. If the socket is not in the
@@ -1289,6 +1294,9 @@
sock->connected = 0;
sock->connecting = 0;
sock->bound = 0;
+ sock->read_ready_event = 0L;
+ sock->write_ready_event = 0L;
+ sock->selected_event = 0L;
/*
* initialize the lock
@@ -1401,13 +1409,16 @@
case isc_sockettype_tcp:
sock->fd = socket(pf, SOCK_STREAM, IPPROTO_TCP);
break;
+
+ case isc_sockettype_fd:
+ sock->fd = pf;
}
#ifdef F_DUPFD
/*
* Leave a space for stdio to work in.
*/
- if (sock->fd >= 0 && sock->fd < 20) {
+ if ( (type != isc_sockettype_fd) && (sock->fd >= 0) && (sock->fd < 20) ) {
int new, tmp;
new = fcntl(sock->fd, F_DUPFD, 20);
tmp = errno;
@@ -1461,7 +1472,7 @@
}
}
- if (make_nonblock(sock->fd) != ISC_R_SUCCESS) {
+ if ((type != isc_sockettype_fd) && (make_nonblock(sock->fd) != ISC_R_SUCCESS)) {
(void)close(sock->fd);
free_socket(&sock);
return (ISC_R_UNEXPECTED);
@@ -1729,6 +1740,38 @@
isc_task_send(ev->ev_sender, (isc_event_t **)&iev);
}
+static
+isc_event_t *dispatch_read_ready(isc_socketmgr_t *manager, isc_socket_t *sock)
+{
+ isc_event_t *dev = (isc_event_t*)sock->read_ready_event, *ev;
+
+ ev = isc_mem_get(manager->mctx, dev->ev_size);
+ memcpy(ev,dev,dev->ev_size);
+ ISC_LINK_INIT(ev,ev_link);
+ isc_task_send(dev->ev_sender, &ev );
+ return (isc_event_t *)sock->selected_event;
+}
+
+static
+isc_event_t *dispatch_write_ready(isc_socketmgr_t *manager,isc_socket_t *sock)
+{
+ isc_event_t *dev = (isc_event_t*)sock->write_ready_event, *ev;
+ ev = isc_mem_get(manager->mctx, dev->ev_size);
+ memcpy(ev,dev,dev->ev_size);
+ ISC_LINK_INIT(ev,ev_link);
+ isc_task_send(dev->ev_sender, &ev );
+ return (isc_event_t *)sock->selected_event;
+}
+
+static
+void dispatch_selected(isc_socketmgr_t *manager, isc_event_t *dev)
+{ isc_event_t *ev;
+ ev = isc_mem_get(manager->mctx, dev->ev_size);
+ memcpy(ev,dev,dev->ev_size);
+ ISC_LINK_INIT(ev,ev_link);
+ isc_task_send(dev->ev_sender, &ev );
+}
+
/*
* Dequeue an item off the given socket's read queue, set the result code
* in the done event to the one provided, and send it to the task it was
@@ -2136,6 +2179,7 @@
int i;
isc_socket_t *sock;
isc_boolean_t unlock_sock;
+ isc_event_t *sock_selected = 0L;
REQUIRE(maxfd <= (int)FD_SETSIZE);
@@ -2169,11 +2213,15 @@
unlock_sock = ISC_TRUE;
LOCK(&sock->lock);
if (!SOCK_DEAD(sock)) {
+ if( sock->type != isc_sockettype_fd )
+ {
if (sock->listener)
dispatch_accept(sock);
else
dispatch_recv(sock);
- }
+ }else
+ sock_selected = dispatch_read_ready(manager,sock);
+ }
FD_CLR(i, &manager->read_fds);
}
check_write:
@@ -2187,16 +2235,24 @@
LOCK(&sock->lock);
}
if (!SOCK_DEAD(sock)) {
+ if( sock->type != isc_sockettype_fd )
+ {
if (sock->connecting)
dispatch_connect(sock);
else
dispatch_send(sock);
+ }else
+ sock_selected = dispatch_write_ready(manager,sock);
}
FD_CLR(i, &manager->write_fds);
}
if (unlock_sock)
UNLOCK(&sock->lock);
}
+ if( sock_selected != 0L )
+ {
+ dispatch_selected(manager, sock_selected);
+ }
}
#ifdef ISC_PLATFORM_USETHREADS
@@ -2215,7 +2271,7 @@
int cc;
fd_set readfds;
fd_set writefds;
- int msg, fd;
+ int msg, fd = -1;
int maxfd;
char strbuf[ISC_STRERRORSIZE];
@@ -3546,3 +3602,55 @@
return (ISC_R_SUCCESS);
}
#endif /* ISC_PLATFORM_USETHREADS */
+
+isc_socketevent_t*
+isc_socket_fd_handle_reads( isc_socket_t *sock, isc_socketevent_t *dev )
+{
+ REQUIRE(VALID_SOCKET(sock));
+ if(dev != 0L)
+ {
+ sock->references=1;
+ sock->read_ready_event = dev;
+ select_poke(sock->manager, sock->fd, SELECT_POKE_READ);
+ }else
+ {
+ dev = sock->read_ready_event ;
+ sock->read_ready_event = 0L ;
+ }
+ return dev;
+}
+
+isc_socketevent_t*
+isc_socket_fd_handle_writes( isc_socket_t *sock, isc_socketevent_t *dev )
+{
+ REQUIRE(VALID_SOCKET(sock));
+ if(dev != 0L)
+ {
+ sock->references=1;
+ sock->write_ready_event = dev;
+ select_poke(sock->manager, sock->fd, SELECT_POKE_WRITE);
+ }else
+ {
+ dev = sock->write_ready_event;
+ sock->write_ready_event = 0L;
+ }
+ return dev;
+}
+
+isc_socketevent_t*
+isc_socket_fd_handle_selected( isc_socket_t *sock, isc_socketevent_t *dev )
+{
+ REQUIRE(VALID_SOCKET(sock));
+ if(dev != 0L)
+ {
+ sock->references=1;
+ sock->selected_event = dev;
+ }else
+ {
+ dev = sock->selected_event;
+ sock->selected_event = 0L;
+ sock->references=0;
+ destroy(&sock);
+ }
+ return dev;
+}
--- bind-9.3.3rc2/bin/named/named.8.dbus 2006-06-29 15:02:30.000000000 +0200
+++ bind-9.3.3rc2/bin/named/named.8 2006-09-18 10:08:37.000000000 +0200
@@ -33,7 +33,7 @@
named \- Internet domain name server
.SH "SYNOPSIS"
.HP 6
-\fBnamed\fR [\fB\-4\fR] [\fB\-6\fR] [\fB\-c\ \fR\fB\fIconfig\-file\fR\fR] [\fB\-d\ \fR\fB\fIdebug\-level\fR\fR] [\fB\-f\fR] [\fB\-g\fR] [\fB\-n\ \fR\fB\fI#cpus\fR\fR] [\fB\-p\ \fR\fB\fIport\fR\fR] [\fB\-s\fR] [\fB\-t\ \fR\fB\fIdirectory\fR\fR] [\fB\-u\ \fR\fB\fIuser\fR\fR] [\fB\-v\fR] [\fB\-x\ \fR\fB\fIcache\-file\fR\fR]
+\fBnamed\fR [\fB\-4\fR] [\fB\-6\fR] [\fB\-c\ \fR\fB\fIconfig\-file\fR\fR] [\fB\-d\ \fR\fB\fIdebug\-level\fR\fR] [\fB\-f\fR] [\fB\-g\fR] [\fB\-n\ \fR\fB\fI#cpus\fR\fR] [\fB\-p\ \fR\fB\fIport\fR\fR] [\fB\-s\fR] [\fB\-t\ \fR\fB\fIdirectory\fR\fR] [\fB\-u\ \fR\fB\fIuser\fR\fR] [\fB\-v\fR] [\fB\-x\ \fR\fB\fIcache\-file\fR\fR] [\fB\-D\fR]
.SH "DESCRIPTION"
.PP
\fBnamed\fR
@@ -146,6 +146,13 @@
.B "Warning:"
This option must not be used. It is only of interest to BIND 9 developers and may be removed or changed in a future release.
.RE
+.sp
+.TP
+\fB\-D\fR
+Enable dynamic management of the forwarding table with D-BUS
+messages. This option is required for Red Hat NetworkManager
+support. See doc/README.DBUS .
+.sp
.SH "SIGNALS"
.PP
In routine operation, signals should not be used to control the nameserver;
@@ -165,6 +172,73 @@
\fBnamed\fR
configuration file is too complex to describe in detail here. A complete description is provided in the
BIND 9 Administrator Reference Manual.
+.PP
+.SH "NOTES"
+.PP
+.TP
+\fBRed Hat SELinux BIND Security Profile:\fR
+.PP
+By default, Red Hat ships BIND with the most secure SELinux policy
+that will not prevent normal BIND operation and will prevent exploitation
+of all known BIND security vulnerabilities . See the selinux(8) man page
+for information about SElinux.
+.PP
+It is not necessary to run named in a chroot environment if the Red Hat
+SELinux policy for named is enabled. When enabled, this policy is far
+more secure than a chroot environment.
+.PP
+With this extra security comes some restrictions:
+.br
+By default, the SELinux policy does not allow named to write any master
+zone database files. Only the root user may create files in the $ROOTDIR/var/named
+zone database file directory (the options { "directory" } option), where
+$ROOTDIR is set in /etc/sysconfig/named.
+.br
+The "named" group must be granted read privelege to
+these files in order for named to be enabled to read them.
+.br
+Any file created in the zone database file directory is automatically assigned
+the SELinux file context named_zone_t .
+.br
+By default, SELinux prevents any role from modifying named_zone_t files; this
+means that files in the zone database directory cannot be modified by dynamic
+DNS (DDNS) updates or zone transfers.
+.br
+The Red Hat BIND distribution and SELinux policy creates two directories where
+named is allowed to create and modify files: $ROOTDIR/var/named/slaves and
+$ROOTDIR/var/named/data. By placing files you want named to modify, such as
+slave or DDNS updateable zone files and database / statistics dump files in
+these directories, named will work normally and no further operator action is
+required. Files in these directories are automatically assigned the 'named_cache_t'
+file context, which SELinux allows named to write.
+.br
+You can enable the named_t domain to write and create named_zone_t files by use
+of the SELinux tunable boolean variable "named_write_master_zones", using the
+setsebool(8) command or the system-config-security GUI . If you do this, you
+must also set the ENABLE_ZONE_WRITE variable in /etc/sysconfig/named to
+1 / yes to set the ownership of files in the $ROOTDIR/var/named directory
+to named:named in order for named to be allowed to write them.
+.PP
+\fBRed Hat BIND named_sdb SDB support:\fR
+.PP
+Red Hat ships the bind-sdb RPM that provides the /usr/sbin/named_sdb program,
+which is named compiled with the Simplified Database Backend modules that ISC
+provides in the "contrib/sdb" directory.
+.br
+The SDB modules for LDAP, PostGreSQL and DirDB are compiled into named_sdb.
+.br
+To run named_sdb, set the ENABLE_SDB variable in /etc/sysconfig/named to 1 or "yes",
+and then the "service named start" named initscript will run named_sdb instead
+of named .
+.br
+See the documentation for the various SDB modules in /usr/share/doc/bind-sdb-*/ .
+.PP
+\fBRed Hat system-config-bind:\fR
+.PP
+Red Hat provides the system-config-bind GUI to configure named.conf and zone
+database files. Run the "system-config-bind" command and access the manual
+by selecting the Help menu.
+.PP
.SH "FILES"
.TP 3n
\fI/etc/named.conf\fR
--- bind-9.3.3rc2/bin/named/include/named/globals.h.dbus 2006-03-02 01:37:20.000000000 +0100
+++ bind-9.3.3rc2/bin/named/include/named/globals.h 2006-09-18 10:08:37.000000000 +0200
@@ -112,6 +112,8 @@
EXTERN int ns_g_listen INIT(3);
+EXTERN int ns_g_dbus INIT(0);
+
#undef EXTERN
#undef INIT
--- bind-9.3.3rc2/bin/named/include/named/log.h.dbus 2004-03-08 05:04:21.000000000 +0100
+++ bind-9.3.3rc2/bin/named/include/named/log.h 2006-09-18 10:08:37.000000000 +0200
@@ -34,6 +34,7 @@
#define NS_LOGCATEGORY_QUERIES (&ns_g_categories[4])
#define NS_LOGCATEGORY_UNMATCHED (&ns_g_categories[5])
#define NS_LOGCATEGORY_UPDATE_SECURITY (&ns_g_categories[6])
+#define NS_LOGCATEGORY_DBUS (&ns_g_categories[7])
/*
* Backwards compatibility.
@@ -51,6 +52,7 @@
#define NS_LOGMODULE_NOTIFY (&ns_g_modules[8])
#define NS_LOGMODULE_CONTROL (&ns_g_modules[9])
#define NS_LOGMODULE_LWRESD (&ns_g_modules[10])
+#define NS_LOGMODULE_DBUS (&ns_g_modules[11])
isc_result_t
ns_log_init(isc_boolean_t safe);
--- bind-9.3.3rc2/bin/named/include/named/server.h.dbus 2006-03-02 01:37:20.000000000 +0100
+++ bind-9.3.3rc2/bin/named/include/named/server.h 2006-09-18 10:08:37.000000000 +0200
@@ -91,7 +91,8 @@
ns_controls_t * controls; /* Control channels */
unsigned int dispatchgen;
ns_dispatchlist_t dispatches;
-
+
+ ns_dbus_mgr_t * dbus_mgr;
};
#define NS_SERVER_MAGIC ISC_MAGIC('S','V','E','R')
--- bind-9.3.3rc2/bin/named/include/named/types.h.dbus 2004-03-06 11:21:26.000000000 +0100
+++ bind-9.3.3rc2/bin/named/include/named/types.h 2006-09-18 10:08:37.000000000 +0200
@@ -38,4 +38,6 @@
typedef struct ns_dispatch ns_dispatch_t;
typedef ISC_LIST(ns_dispatch_t) ns_dispatchlist_t;
+typedef struct ns_dbus_mgr ns_dbus_mgr_t ;
+
#endif /* NAMED_TYPES_H */
--- bind-9.3.3rc2/bin/named/log.c.dbus 2005-05-25 01:58:17.000000000 +0200
+++ bind-9.3.3rc2/bin/named/log.c 2006-09-18 10:08:37.000000000 +0200
@@ -41,6 +41,7 @@
{ "queries", 0 },
{ "unmatched", 0 },
{ "update-security", 0 },
+ { "dbus", 0 },
{ NULL, 0 }
};
@@ -60,6 +61,7 @@
{ "notify", 0 },
{ "control", 0 },
{ "lwresd", 0 },
+ { "dbus", 0 },
{ NULL, 0 }
};
--- bind-9.3.3rc2/bin/named/main.c.dbus 2006-01-06 01:01:42.000000000 +0100
+++ bind-9.3.3rc2/bin/named/main.c 2006-09-18 10:08:37.000000000 +0200
@@ -239,7 +239,8 @@
"usage: named [-4|-6] [-c conffile] [-d debuglevel] "
"[-f|-g] [-n number_of_cpus]\n"
" [-p port] [-s] [-t chrootdir] [-u username]\n"
- " [-m {usage|trace|record}]\n");
+ " [-m {usage|trace|record}]\n"
+ " [-D ]\n");
}
static void
@@ -345,7 +346,7 @@
isc_commandline_errprint = ISC_FALSE;
while ((ch = isc_commandline_parse(argc, argv,
- "46c:C:d:fgi:lm:n:N:p:P:st:u:vx:")) != -1) {
+ "46c:C:d:fgi:lm:n:N:p:P:st:u:vx:D")) != -1) {
switch (ch) {
case '4':
if (disable4)
@@ -434,6 +435,9 @@
case 'v':
printf("BIND %s\n", ns_g_version);
exit(0);
+ case 'D':
+ ns_g_dbus = 1;
+ break;
case '?':
usage();
ns_main_earlyfatal("unknown option '-%c'",
--- bind-9.3.3rc2/bin/named/server.c.dbus 2006-05-24 06:30:24.000000000 +0200
+++ bind-9.3.3rc2/bin/named/server.c 2006-09-18 10:08:37.000000000 +0200
@@ -86,6 +86,8 @@
#include <stdlib.h>
#endif
+#include <named/dbus_mgr.h>
+
/*
* Check an operation for failure. Assumes that the function
* using it has a 'result' variable and a 'cleanup' label.
@@ -1495,12 +1497,12 @@
if (result != ISC_R_SUCCESS) {
char namebuf[DNS_NAME_FORMATSIZE];
dns_name_format(origin, namebuf, sizeof(namebuf));
- cfg_obj_log(forwarders, ns_g_lctx, ISC_LOG_WARNING,
- "could not set up forwarding for domain '%s': %s",
+ cfg_obj_log(forwarders, ns_g_lctx, ISC_LOG_NOTICE,
+ "setting up forwarding failed for domain '%s': %s",
namebuf, isc_result_totext(result));
goto cleanup;
}
-
+
result = ISC_R_SUCCESS;
cleanup:
@@ -2875,6 +2877,20 @@
CHECKFATAL(load_zones(server, ISC_FALSE), "loading zones");
+ server->dbus_mgr = 0L;
+ if( ns_g_dbus )
+ if( dbus_mgr_create
+ ( ns_g_mctx, ns_g_taskmgr, ns_g_socketmgr, ns_g_timermgr,
+ &server->dbus_mgr
+ ) != ISC_R_SUCCESS
+ )
+ {
+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
+ NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
+ "dbus_mgr initialization failed. D-BUS service is disabled."
+ );
+ }
+
ns_os_started();
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
ISC_LOG_NOTICE, "running");
@@ -2937,6 +2953,9 @@
dns_db_detach(&server->in_roothints);
+ if( server->dbus_mgr != 0L )
+ dbus_mgr_shutdown(server->dbus_mgr);
+
isc_task_endexclusive(server->task);
isc_task_detach(&server->task);
--- bind-9.3.3rc2/bin/named/Makefile.in.dbus 2004-09-06 23:47:25.000000000 +0200
+++ bind-9.3.3rc2/bin/named/Makefile.in 2006-09-18 10:10:58.000000000 +0200
@@ -35,7 +35,8 @@
${LWRES_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES} \
${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
${DBDRIVER_INCLUDES}
-
+DBUS_INCLUDES = \
+ -I/usr/lib/dbus-1.0/include -I/usr/include/dbus-1.0
CDEFINES =
CWARNINGS =
@@ -52,6 +53,7 @@
ISCDEPLIBS = ../../lib/isc/libisc.@A@
LWRESDEPLIBS = ../../lib/lwres/liblwres.@A@
BIND9DEPLIBS = ../../lib/bind9/libbind9.@A@
+DBUSLIBS= -ldbus-1
DEPLIBS = ${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
${ISCCFGDEPLIBS} ${ISCCCDEPLIBS} ${ISCDEPLIBS}
@@ -71,6 +73,7 @@
zoneconf.@O@ \
lwaddr.@O@ lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \
lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \
+ dbus_service.@O@ dbus_mgr.@O@ \
$(DBDRIVER_OBJS)
UOBJS = unix/os.@O@
@@ -83,6 +86,7 @@
zoneconf.c \
lwaddr.c lwresd.c lwdclient.c lwderror.c lwdgabn.c \
lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \
+ dbus_service.c dbus_mgr.c \
$(DBDRIVER_SRCS)
MANPAGES = named.8 lwresd.8 named.conf.5
@@ -105,9 +109,14 @@
-DNS_LOCALSTATEDIR=\"${localstatedir}\" \
-c ${srcdir}/config.c
+dbus_service.o: dbus_service.c
+ ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
+ ${DBUS_INCLUDES} \
+ -c ${srcdir}/dbus_service.c
+
named@EXEEXT@: ${OBJS} ${UOBJS} ${DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- ${OBJS} ${UOBJS} ${LIBS}
+ ${OBJS} ${UOBJS} ${LIBS} ${DBUSLIBS}
lwresd@EXEEXT@: named@EXEEXT@
rm -f lwresd@EXEEXT@

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
/* dbus_mgr.h
*
* named module to provide dynamic forwarding zones in
* response to D-BUS dhcp events
*
* Copyright(C) Jason Vas Dias, Red Hat Inc., 2005
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation at
* http://www.fsf.org/licensing/licenses/gpl.txt
* and included in this software distribution as the "LICENSE" file.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
extern isc_result_t
dbus_mgr_create
( isc_mem_t *mctx,
isc_taskmgr_t *taskmgr,
isc_socketmgr_t *socketmgr,
isc_timermgr_t *timermgr,
ns_dbus_mgr_t **dbus_mgr
);
extern void
dbus_mgr_shutdown
( ns_dbus_mgr_t *dus_mgr_t
);

File diff suppressed because it is too large Load Diff

View File

@ -1,287 +0,0 @@
/* D-BUS Service Utilities
*
* Provides utilities for construction of D-BUS "Services"
*
* Copyright(C) Jason Vas Dias, Red Hat Inc., 2005
* Modified by Adam Tkac, Red Hat Inc., 2007
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation at
* http://www.fsf.org/licensing/licenses/gpl.txt
* and included in this software distribution as the "LICENSE" file.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef D_BUS_SERVER_UTILITIES_H
#define D_BUS_SERVER_UTILITIES_H
#include <stdint.h>
#include <stdarg.h>
#include <isc/types.h>
typedef struct dbcs_s* DBUS_SVC;
typedef enum
{ HANDLED, NOT_HANDLED, HANDLED_NOW
} dbus_svc_HandlerResult;
typedef enum
{ INVALID, CALL, RETURN, ERROR, SIGNAL
} dbus_svc_MessageType;
typedef enum
{
DBUS_SESSION,
DBUS_SYSTEM,
DBUS_STARTER,
DBUS_PRIVATE_SYSTEM,
DBUS_PRIVATE_SESSION
} dbus_svc_DBUS_TYPE;
typedef enum /* D-BUS Protocol Type Codes / Signature Chars */
{
TYPE_INVALID = (int)'\0',
TYPE_BYTE = (int)'y',
TYPE_BOOLEAN = (int)'b',
TYPE_INT16 = (int)'n',
TYPE_UINT16 = (int)'q',
TYPE_INT32 = (int)'i',
TYPE_UINT32 = (int)'u',
TYPE_INT64 = (int)'x',
TYPE_UINT64 = (int)'t',
TYPE_DOUBLE = (int)'d',
TYPE_STRING = (int)'s',
TYPE_OBJECT_PATH =(int)'o',
TYPE_SIGNATURE= (int)'g',
TYPE_ARRAY = (int)'a',
TYPE_VARIANT = (int)'v',
TYPE_STRUCT = (int)'r',
TYPE_DICT_ENTRY = (int)'e',
STRUCT_BEGIN = (int)'(',
STRUCT_END = (int)')',
DICT_ENTRY_BEGIN =(int)'{',
DICT_ENTRY_END =(int)'}'
} dbus_svc_DataType;
typedef struct DBusMessage* dbus_svc_MessageHandle;
typedef int
(*dbus_svc_ErrorHandler)
( const char *errorFmt, ...
); /* Error Handler function prototype - handle FATAL errors from D-BUS calls */
typedef enum
{
WATCH_ENABLE = 8,
WATCH_ERROR = 4,
WATCH_WRITE = 2,
WATCH_READ = 1
} dbus_svc_WatchFlags;
typedef void (*dbus_svc_WatchHandler)( int, dbus_svc_WatchFlags, void *arg );
typedef dbus_svc_HandlerResult
(*dbus_svc_MessageHandler)
( DBUS_SVC dbus,
dbus_svc_MessageType type,
uint8_t reply_expected, /* 1 / 0 */
uint32_t serial, /* serial number of message; needed to reply */
const char *destination, /* D-BUS connection name / destination */
const char *path, /* D-BUS Object Path */
const char *member, /* D-BUS Object Member */
const char *interface, /* D-BUS Object interface */
const char *if_suffix, /* remainder of interface prefixed by ifPrefix */
const char *sender, /* Senders' connection destination */
const char *signature, /* Signature String composed of Type Codes */
dbus_svc_MessageHandle msg,/* Message pointer: call dbus_svc_get_args(msg,...) to get data */
const char *prefix, /* If non-null, this is the root prefix for this sub-path message */
const char *suffix, /* If non-null, this is the suffix of this sub-path message */
void *prefixObject, /* If non-null, this is the object that was registered for the prefix */
void *object /* If non-null, this is the object that was registered for the complete path */
); /* Message Handler function prototype */
#define DBusMsgHandlerArgs \
DBUS_SVC dbus, \
dbus_svc_MessageType type, \
uint8_t reply_expected, \
uint32_t serial, \
const char *destination, \
const char *path, \
const char *member, \
const char *interface, \
const char *if_suffix, \
const char *sender, \
const char *signature, \
dbus_svc_MessageHandle msg, \
const char *prefix, \
const char *suffix, \
void *prefixObject, \
void *object
#define SHUTDOWN 255
extern isc_result_t dbus_svc_init
( dbus_svc_DBUS_TYPE bus,
char *name, /* name to register with D-BUS */
DBUS_SVC *dbus, /* dbus handle */
dbus_svc_WatchHandler wh, /* optional handler for watch events */
dbus_svc_ErrorHandler eh, /* optional error log message handler */
dbus_svc_ErrorHandler dh, /* optional debug / info log message handler */
void *wh_arg /* optional watch handler arg */
);
/*
* Obtains connection to DBUS_BUS_STARTER and registers "name".
* "eh" will be called for all errors from this server session.
*/
/* EITHER :
* pass a NULL WatchHandler to dbus_svc_init and use dbus_svc_main_loop
* OR:
* supply a valid WatchHandler, and call dbus_svc_handle_watch when
* select() returns the watch fd as ready for the watch action, and
* call dbus_svc_dispatch when all watches have been handled.
*/
uint8_t
dbus_svc_add_filter
( DBUS_SVC, dbus_svc_MessageHandler mh, void *obj, int n_matches, ... );
/*
* Registers SINGLE message handler to handle ALL messages, adding match rules
*/
void dbus_svc_main_loop( DBUS_SVC, void (*idle_handler)(DBUS_SVC) );
void dbus_svc_handle_watch( DBUS_SVC, int watch_fd, dbus_svc_WatchFlags action);
void dbus_svc_dispatch( DBUS_SVC );
/*
* Enter message processing loop.
* If "idle_handler" is non-null, it will be called once per iteration of loop.
*/
const char *dbus_svc_unique_name( DBUS_SVC );
/*
* Returns connection "unique" (socket) name
*/
void dbus_svc_quit( DBUS_SVC );
/*
* Exit message processing loop
*/
void dbus_svc_shutdown( DBUS_SVC );
/*
* Close connections and clean up.
* DBUS_SVC pointer is invalid after this.
*/
uint8_t
dbus_svc_get_args( DBUS_SVC, dbus_svc_MessageHandle, dbus_svc_DataType, ... );
/* get arguments from message */
uint8_t
dbus_svc_get_args_va( DBUS_SVC, dbus_svc_MessageHandle, dbus_svc_DataType, va_list );
/* get arguments from message */
typedef void (*dbus_svc_ShutdownHandler) ( DBUS_SVC, void * );
uint8_t
dbus_svc_add_shutdown_filter
(
DBUS_SVC, dbus_svc_ShutdownHandler sh, void *obj
);
/* Registers a filter for D-BUS shutdown event.
* Cannot be used in conjunction with dbus_svc_add_message_filter.
*/
uint8_t
dbus_svc_remove_message_filter
( DBUS_SVC, dbus_svc_MessageHandler mh);
/* Unregisters the message filter */
uint8_t
dbus_svc_send
( DBUS_SVC,
dbus_svc_MessageType type,
int32_t reply_serial,
uint32_t *new_serial,
const char *destination,
const char *path,
const char *member,
const char *interface,
dbus_svc_DataType firstType,
... /* pointer, { (dbus_svc_DataType, pointer )...} */
); /* sends messages / replies to "destination" */
uint8_t
dbus_svc_send_va
( DBUS_SVC cs,
dbus_svc_MessageType type,
int32_t reply_serial,
uint32_t *new_serial,
const char *destination,
const char *path,
const char *member,
const char *interface,
dbus_svc_DataType firstType,
va_list va
); /* sends messages / replies to "destination" */
dbus_svc_MessageHandle
dbus_svc_call
( DBUS_SVC cs,
const char *destination,
const char *path,
const char *member,
const char *interface,
dbus_svc_DataType firstType,
...
); /* constructs message, sends it, returns reply */
dbus_svc_MessageHandle
dbus_svc_new_message
( DBUS_SVC cs,
dbus_svc_MessageType type,
int32_t reply_serial,
const char *destination,
const char *path,
const char *interface,
const char *member
);
uint8_t
dbus_svc_send_message(DBUS_SVC , dbus_svc_MessageHandle , uint32_t * );
uint8_t
dbus_svc_message_append_args( DBUS_SVC , dbus_svc_MessageHandle, dbus_svc_DataType, ...);
typedef struct DBusMessageIter *dbus_svc_MessageIterator;
dbus_svc_MessageIterator
dbus_svc_message_iterator_new( DBUS_SVC, dbus_svc_MessageHandle );
uint32_t
dbus_svc_message_next_arg_type( DBUS_SVC, dbus_svc_MessageIterator );
void
dbus_svc_message_next_arg( DBUS_SVC, dbus_svc_MessageIterator, void * );
uint32_t
dbus_svc_message_element_type( DBUS_SVC, dbus_svc_MessageIterator );
void
dbus_svc_message_get_elements( DBUS_SVC, dbus_svc_MessageIterator, uint32_t *n, void *array );
uint8_t dbus_svc_message_type( dbus_svc_MessageHandle );
void dbus_svc_message_iterator_free( DBUS_SVC, dbus_svc_MessageIterator );
#endif

View File

@ -1,20 +0,0 @@
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<servicedir>/usr/share/dbus-1/services</servicedir>
<policy user="named">
<allow own="com.redhat.named"/>
<allow send_interface="com.redhat.named"/>
<allow send_destination="com.redhat.named"/>
</policy>
<policy user="root">
<allow send_interface="com.redhat.named"/>
<allow send_destination="com.redhat.named"/>
</policy>
<policy context="default">
<deny own="com.redhat.named"/>
<deny send_destination="com.redhat.named"/>
<deny send_interface="com.redhat.named"/>
</policy>
</busconfig>

View File

@ -1,3 +0,0 @@
[D-BUS Service]
Name=com.redhat.named
Exec=/usr/sbin/named