mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-06 15:51:41 +00:00
Compare commits
43
Commits
v2.62test3
..
v2.63
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f11b3e5e0 | ||
|
|
3169daad46 | ||
|
|
fd05f12790 | ||
|
|
ad094275b0 | ||
|
|
c740e4f342 | ||
|
|
132255b5da | ||
|
|
c4c0488ac6 | ||
|
|
a2ce6fcc91 | ||
|
|
12090548d2 | ||
|
|
8223cb15e7 | ||
|
|
4ba9b38cc5 | ||
|
|
42243214b5 | ||
|
|
23245c0cb2 | ||
|
|
b271446f82 | ||
|
|
611ebc5f1e | ||
|
|
be0f45cdbc | ||
|
|
9b40cbf587 | ||
|
|
c4a7f90ebb | ||
|
|
9609baee41 | ||
|
|
395eb71931 | ||
|
|
8bc4cecee6 | ||
|
|
6b617c0d15 | ||
|
|
55d290a3bf | ||
|
|
e17b4b3871 | ||
|
|
236e072cab | ||
|
|
05ff1ed7cc | ||
|
|
2b5bae9a8f | ||
|
|
39f1b8e73d | ||
|
|
af576b56c2 | ||
|
|
54dd393f39 | ||
|
|
4ce4f3779b | ||
|
|
8b3ae2fd43 | ||
|
|
ed55cb66e6 | ||
|
|
2cd9a0de1f | ||
|
|
c514ab9907 | ||
|
|
078a630bba | ||
|
|
43c271b07c | ||
|
|
24ce681e51 | ||
|
|
5ae34bf3c8 | ||
|
|
51931b888a | ||
|
|
9f7f3b1216 | ||
|
|
97c83bb05b | ||
|
|
8767ceecd4 |
No files matched your search
@@ -1,3 +1,54 @@
|
|||||||
|
version 2.63
|
||||||
|
Do duplicate dhcp-host address check in --test mode.
|
||||||
|
|
||||||
|
Check that tftp-root directories are accessible before
|
||||||
|
start-up. Thanks to Daniel Veillard for the initial patch.
|
||||||
|
|
||||||
|
Allow more than one --tfp-root flag. The per-interface
|
||||||
|
stuff is pointless without that.
|
||||||
|
|
||||||
|
Add --bind-dynamic. A hybrid mode between the default and
|
||||||
|
--bind-interfaces which copes with dynamically created
|
||||||
|
interfaces.
|
||||||
|
|
||||||
|
A couple of fixes to the build system for Android. Thanks
|
||||||
|
to Metin Kaya for the patches.
|
||||||
|
|
||||||
|
Remove the interface:<interface> argument in --dhcp-range, and
|
||||||
|
the interface argument to --enable-tftp. These were a
|
||||||
|
still-born attempt to allow automatic isolated
|
||||||
|
configuration by libvirt, but have never (to my knowledge)
|
||||||
|
been used, had very strange semantics, and have been
|
||||||
|
superceded by other mechanisms.
|
||||||
|
|
||||||
|
Fixed bug logging filenames when duplicate dhcp-host
|
||||||
|
addresses are found. Thanks to John Hanks for the patch.
|
||||||
|
|
||||||
|
Fix regression in 2.61 which broke caching of CNAME
|
||||||
|
chains. Thanks to Atul Gupta for the bug report.
|
||||||
|
|
||||||
|
Allow the target of a --cname flag to be another --cname.
|
||||||
|
|
||||||
|
Teach DHCPv6 about the RFC 4242 information-refresh-time
|
||||||
|
option, and add parsing if the minutes, hours and days
|
||||||
|
format for options. Thanks to Francois-Xavier Le Bail for
|
||||||
|
the suggestion.
|
||||||
|
|
||||||
|
Allow "w" (for week) as multiplier in lease times, as well
|
||||||
|
as seconds, minutes, hours and days. Álvaro Gámez Machado
|
||||||
|
spotted the ommission.
|
||||||
|
|
||||||
|
Update French translation. Thanks to Gildas Le Nadan.
|
||||||
|
|
||||||
|
Allow a DBus service name to be given with --enable-dbus
|
||||||
|
which overrides the default,
|
||||||
|
uk.org.thekelleys.dnsmasq. Thanks to Mathieu
|
||||||
|
Trudel-Lapierre for the patch.
|
||||||
|
|
||||||
|
Set the "prefix on-link" bit in Router
|
||||||
|
Advertisements. Thanks to Gui Iribarren for the patch.
|
||||||
|
|
||||||
|
|
||||||
version 2.62
|
version 2.62
|
||||||
Update German translation. Thanks to Conrad Kostecki.
|
Update German translation. Thanks to Conrad Kostecki.
|
||||||
|
|
||||||
@@ -16,6 +67,11 @@ version 2.62
|
|||||||
router-advertisement configured, but DHCPv6 not
|
router-advertisement configured, but DHCPv6 not
|
||||||
configured. Thanks to Marien Zwart for the patch.
|
configured. Thanks to Marien Zwart for the patch.
|
||||||
|
|
||||||
|
Add --dns-rr, to allow arbitrary DNS resource records.
|
||||||
|
|
||||||
|
Fixed bug which broke RA scheduling when an interface had
|
||||||
|
two addresses in the same network. Thanks to Jim Bos for
|
||||||
|
his help nailing this.
|
||||||
|
|
||||||
version 2.61
|
version 2.61
|
||||||
Re-write interface discovery code on *BSD to use
|
Re-write interface discovery code on *BSD to use
|
||||||
|
|||||||
@@ -236,53 +236,70 @@ Q: What network types are supported by the DHCP server?
|
|||||||
A: Ethernet (and 802.11 wireless) are supported on all platforms. On
|
A: Ethernet (and 802.11 wireless) are supported on all platforms. On
|
||||||
Linux all network types (including FireWire) are supported.
|
Linux all network types (including FireWire) are supported.
|
||||||
|
|
||||||
Q: What is this strange "bind-interface" option?
|
Q: What are these strange "bind-interface" and "bind-dynamic" options?
|
||||||
|
|
||||||
A: The DNS spec says that the reply to a DNS query must come from the
|
A: Dnsmasq from v2.63 can operate in one of three different "networking
|
||||||
same address it was sent to. The traditional way to write an UDP
|
modes". This is unfortunate as it requires users configuring dnsmasq
|
||||||
server to do this is to find all of the addresses belonging to the
|
to take into account some rather bizzare contraints and select the
|
||||||
machine (ie all the interfaces on the machine) and then create a
|
mode which best fits the requirements of a particular installation.
|
||||||
socket for each interface which is bound to the address of the
|
The origin of these are deficiencies in the Unix networking
|
||||||
interface. Then when a packet is sent to address A, it is received
|
model and APIs and each mode has different advantages and
|
||||||
on the socket bound to address A and when the reply is also sent
|
problems. Just to add to the confusion, not all modes are available on
|
||||||
via that socket, the source address is set to A by the kernel and
|
all platforms (due the to lack of supporting network APIs).To further
|
||||||
everything works. This is the how dnsmasq works when
|
add to the confusion, the rules for the DHCP subsystem on dnsmasq are
|
||||||
"bind-interfaces" is set, with the obvious extension that is misses
|
different to the rules for the DNS and TFTP subsystems.
|
||||||
out creating sockets for some interfaces depending on the
|
|
||||||
--interface, --address and --except-interface flags. The
|
|
||||||
disadvantage of this approach is that it breaks if interfaces don't
|
|
||||||
exist or are not configured when the daemon starts and does the
|
|
||||||
socket creation step. In a hotplug-aware world this is a real
|
|
||||||
problem.
|
|
||||||
|
|
||||||
The alternative approach is to have only one socket, which is bound
|
The three modes are "wildcard", "bind-interfaces" and "bind-dynamic".
|
||||||
to the correct port and the wildcard IP address (0.0.0.0). That
|
|
||||||
socket will receive _all_ packets sent to port 53, no matter what
|
|
||||||
destination address they have. This solves the problem of
|
|
||||||
interfaces which are created or reconfigured after daemon
|
|
||||||
start-up. To make this work is more complicated because of the
|
|
||||||
"reply source address" problem. When a UDP packet is sent by a
|
|
||||||
socket bound to 0.0.0.0 its source address will be set to the
|
|
||||||
address of one of the machine's interfaces, but which one is not
|
|
||||||
determined and can vary depending on the OS being run. To get round
|
|
||||||
this it is neccessary to use a scary advanced API to determine the
|
|
||||||
address to which a query was sent, and force that to be the source
|
|
||||||
address in the reply. For IPv4 this stuff in non-portable and quite
|
|
||||||
often not even available (It's different between FreeBSD 5.x and
|
|
||||||
Linux, for instance, and FreeBSD 4.x, Linux 2.0.x and OpenBSD don't
|
|
||||||
have it at all.) Hence "bind-interfaces" has to always be available
|
|
||||||
as a fall back. For IPv6 the API is standard and universally
|
|
||||||
available.
|
|
||||||
|
|
||||||
It could be argued that if the --interface or --address flags are
|
In "wildcard" mode, dnsmasq binds the wildcard IP address (0.0.0.0 or
|
||||||
used then binding interfaces is more appropriate, but using
|
::). This allows it to recieve all the packets sent to the server on
|
||||||
wildcard binding means that dnsmasq will quite happily start up
|
the relevant port. Access control (--interface, --except-interface,
|
||||||
after being told to use interfaces which don't exist, but which are
|
--listen-address, etc) is implemented by dnsmasq: it queries the
|
||||||
created later. Wildcard binding breaks the scenario when dnsmasq is
|
kernel to determine the interface on which a packet was recieved and
|
||||||
listening on one interface and another server (most probably BIND)
|
the address to which it was sent, and applies the configured
|
||||||
is listening on another. It's not possible for BIND to bind to an
|
rules. Wildcard mode is the default if neither of the other modes are
|
||||||
(address,port) pair when dnsmasq has bound (wildcard,port), hence
|
specified.
|
||||||
the ability to explicitly turn off wildcard binding.
|
|
||||||
|
In "bind-interfaces" mode, dnsmasq runs through all the network
|
||||||
|
interfaces available when it starts, finds the set of IP addresses on
|
||||||
|
those interfaces, filters that set using the access control
|
||||||
|
configuration, and then binds the set of IP addresses. Only packets
|
||||||
|
sent to the allowed addresses are delivered by the kernel to dnsmasq.
|
||||||
|
|
||||||
|
In "bind-dynamic" mode, access control filtering is done both by
|
||||||
|
binding individual IP addresses, as for bind-interfaces, and by
|
||||||
|
inspecting individual packets on arrival as for wildcard mode. In
|
||||||
|
addition, dnsmasq notices when new interfaces appear or new addresses
|
||||||
|
appear on existing interfaces, and the resulting IP addresses are
|
||||||
|
bound automatically without having to restart dnsmasq.
|
||||||
|
|
||||||
|
The mode chosen has four different effects: co-existence with other
|
||||||
|
servers, semantics of --interface access control, effect of new
|
||||||
|
interfaces, and legality of --interface specifications for
|
||||||
|
non-existent inferfaces. We will deal with these in order.
|
||||||
|
|
||||||
|
A dnsmasq instance running in wildcard mode precludes a machine from
|
||||||
|
running a second instance of dnsmasq or any other DNS, TFTP or DHCP
|
||||||
|
server. Attempts to do so will fail with an "address in use" error.
|
||||||
|
Dnsmasq running in --bind-interfaces or bind-dynamic mode allow other
|
||||||
|
instances of dnsmasq or other servers, as long as no two servers are
|
||||||
|
configured to listen on the same interface address.
|
||||||
|
|
||||||
|
The semantics of --interface varies subtly between wildcard or
|
||||||
|
bind-dynamic mode and bind-interfaces mode. The situation where this
|
||||||
|
matters is a request which arrives via one interface (A), but with a
|
||||||
|
destination address of a second interface (B) and when dnsmasq is
|
||||||
|
configured to listen only on B. In wildcard or bind-dynamic mode, such
|
||||||
|
a request will be ignored, in bind-interfaces mode, it will be
|
||||||
|
accepted.
|
||||||
|
|
||||||
|
The creation of new network interfaces after dnsmasq starts is ignored
|
||||||
|
by dnsmasq when in --bind-interfaces mode. In wildcard or bind-dynamic
|
||||||
|
mode, such interfaces are handled normally.
|
||||||
|
|
||||||
|
A --interface specification for a non-existent interface is a fatal
|
||||||
|
error at start-up when in --bind-interfaces mode, by just generates a
|
||||||
|
warning in wildcard or bind-dynamic mode.
|
||||||
|
|
||||||
Q: Why doesn't Kerberos work/why can't I get sensible answers to
|
Q: Why doesn't Kerberos work/why can't I get sensible answers to
|
||||||
queries for SRV records.
|
queries for SRV records.
|
||||||
|
|||||||
@@ -17,4 +17,6 @@ LOCAL_C_INCLUDES := external/dnsmasq/src
|
|||||||
LOCAL_CFLAGS := -O2 -g -W -Wall -D__ANDROID__ -DNO_IPV6 -DNO_TFTP -DNO_SCRIPT
|
LOCAL_CFLAGS := -O2 -g -W -Wall -D__ANDROID__ -DNO_IPV6 -DNO_TFTP -DNO_SCRIPT
|
||||||
LOCAL_SYSTEM_SHARED_LIBRARIES := libc libcutils
|
LOCAL_SYSTEM_SHARED_LIBRARIES := libc libcutils
|
||||||
|
|
||||||
|
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
|
||||||
|
|
||||||
include $(BUILD_EXECUTABLE)
|
include $(BUILD_EXECUTABLE)
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
To: dnsmasq-discuss@lists.thekelleys.org.uk
|
||||||
|
From: Alex Elsayed <eternaleye+usenet@gmail.com>
|
||||||
|
Date: Tue, 15 May 2012 01:53:54 -0700
|
||||||
|
Subject: [Dnsmasq-discuss] [PATCH] Support dbus activation
|
||||||
|
|
||||||
|
Introduce dbus service file and turn dbus on in the systemd
|
||||||
|
unit.
|
||||||
|
|
||||||
|
Note to packagers:
|
||||||
|
To add support for dbus activation, you must install the dbus
|
||||||
|
service file (dbus/uk.org.thekelleys.dnsmasq.service) into
|
||||||
|
$DATADIR/dbus-1/system-services.
|
||||||
|
|
||||||
|
---
|
||||||
|
contrib/systemd/dnsmasq.service | 2 +-
|
||||||
|
dbus/uk.org.thekelleys.dnsmasq.service | 7 +++++++
|
||||||
|
2 files changed, 8 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 dbus/uk.org.thekelleys.dnsmasq.service
|
||||||
|
|
||||||
|
diff --git a/contrib/systemd/dnsmasq.service
|
||||||
|
b/contrib/systemd/dnsmasq.service
|
||||||
|
index a27fe6d..4a784d3 100644
|
||||||
|
--- a/contrib/systemd/dnsmasq.service
|
||||||
|
+++ b/contrib/systemd/dnsmasq.service
|
||||||
|
@@ -5,7 +5,7 @@ Description=A lightweight DHCP and caching DNS server
|
||||||
|
Type=dbus
|
||||||
|
BusName=uk.org.thekelleys.dnsmasq
|
||||||
|
ExecStartPre=/usr/sbin/dnsmasq --test
|
||||||
|
-ExecStart=/usr/sbin/dnsmasq -k
|
||||||
|
+ExecStart=/usr/sbin/dnsmasq -k -1
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
diff --git a/dbus/uk.org.thekelleys.dnsmasq.service
|
||||||
|
b/dbus/uk.org.thekelleys.dnsmasq.service
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..f5fe98d
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/dbus/uk.org.thekelleys.dnsmasq.service
|
||||||
|
@@ -0,0 +1,7 @@
|
||||||
|
+[D-BUS Service]
|
||||||
|
+Name=uk.org.thekelleys.dnsmasq
|
||||||
|
+Exec=/usr/sbin/dnsmasq -k -1
|
||||||
|
+User=root
|
||||||
|
+SystemdService=dnsmasq.service
|
||||||
|
+
|
||||||
|
+
|
||||||
|
--
|
||||||
|
1.7.10.2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_______________________________________________
|
||||||
|
Dnsmasq-discuss mailing list
|
||||||
|
Dnsmasq-discuss@lists.thekelleys.org.uk
|
||||||
|
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
|
||||||
|
|
||||||
+2
-1
@@ -19,7 +19,8 @@ and avoids startup races with the provider of nameserver information.
|
|||||||
|
|
||||||
|
|
||||||
Dnsmasq provides one service on the DBus: uk.org.thekelleys.dnsmasq
|
Dnsmasq provides one service on the DBus: uk.org.thekelleys.dnsmasq
|
||||||
and a single object: /uk/org/thekelleys/dnsmasq
|
and a single object: /uk/org/thekelleys/dnsmasq
|
||||||
|
The name of the service may be changed by giving an argument to --enable-dbus.
|
||||||
|
|
||||||
1. METHODS
|
1. METHODS
|
||||||
----------
|
----------
|
||||||
|
|||||||
Vendored
+21
@@ -1,6 +1,27 @@
|
|||||||
|
dnsmasq (2.63-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream.
|
||||||
|
* Move /etc/dbus-1/system.d/dnsmasq.conf from dnsmasq to dnsmasq-base.
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Mon, 11 Jun 2012 21:55:35 +0000
|
||||||
|
|
||||||
|
dnsmasq (2.62-3) unstable; urgency=low
|
||||||
|
|
||||||
|
* Do resolvconf and /etc/default startup logic when
|
||||||
|
starting with systemd. (closes: #675854)
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Mon, 11 Jun 2012 21:50:11 +0000
|
||||||
|
|
||||||
|
dnsmasq (2.62-2) unstable; urgency=low
|
||||||
|
|
||||||
|
* Pass LDFLAGS to make to get hardening in linker.
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Thu, 7 Jun 2012 09:53:43 +0000
|
||||||
|
|
||||||
dnsmasq (2.62-1) unstable; urgency=low
|
dnsmasq (2.62-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream.
|
* New upstream.
|
||||||
|
* Use dpkg-buildflags. (Enables hardening).
|
||||||
|
|
||||||
-- Simon Kelley <simon@thekelleys.org.uk> Sat, 12 May 2012 15:25:23 +0000
|
-- Simon Kelley <simon@thekelleys.org.uk> Sat, 12 May 2012 15:25:23 +0000
|
||||||
|
|
||||||
|
|||||||
Vendored
-1
@@ -2,5 +2,4 @@
|
|||||||
/etc/default/dnsmasq
|
/etc/default/dnsmasq
|
||||||
/etc/dnsmasq.conf
|
/etc/dnsmasq.conf
|
||||||
/etc/resolvconf/update.d/dnsmasq
|
/etc/resolvconf/update.d/dnsmasq
|
||||||
/etc/dbus-1/system.d/dnsmasq.conf
|
|
||||||
/etc/insserv.conf.d/dnsmasq
|
/etc/insserv.conf.d/dnsmasq
|
||||||
Vendored
+2
-1
@@ -23,7 +23,8 @@ Description: Small caching DNS proxy and DHCP/TFTP server
|
|||||||
Package: dnsmasq-base
|
Package: dnsmasq-base
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: ${shlibs:Depends}
|
Depends: ${shlibs:Depends}
|
||||||
Conflicts: dnsmasq (<<2.41)
|
Breaks: dnsmasq (<< 2.62-3)
|
||||||
|
Replaces: dnsmasq (<< 2.62-3)
|
||||||
Description: Small caching DNS proxy and DHCP/TFTP server
|
Description: Small caching DNS proxy and DHCP/TFTP server
|
||||||
This package contains the dnsmasq executable and documentation, but
|
This package contains the dnsmasq executable and documentation, but
|
||||||
not the infrastructure required to run it as a system daemon. For
|
not the infrastructure required to run it as a system daemon. For
|
||||||
|
|||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/etc/dbus-1/system.d/dnsmasq.conf
|
||||||
Vendored
+21
@@ -259,6 +259,27 @@ case "$1" in
|
|||||||
dump-stats)
|
dump-stats)
|
||||||
kill -s USR1 `cat /var/run/dnsmasq/$NAME.pid`
|
kill -s USR1 `cat /var/run/dnsmasq/$NAME.pid`
|
||||||
;;
|
;;
|
||||||
|
systemd-start-resolvconf)
|
||||||
|
start_resolvconf
|
||||||
|
;;
|
||||||
|
systemd-stop-resolvconf)
|
||||||
|
stop_resolvconf
|
||||||
|
;;
|
||||||
|
systemd-exec)
|
||||||
|
# --pid-file without argument disables writing a PIDfile, we don't need one with sytemd.
|
||||||
|
# Enable DBus by default because we use DBus activation with systemd.
|
||||||
|
exec $DAEMON --keep-in-foreground --pid-file --enable-dbus \
|
||||||
|
${MAILHOSTNAME:+ -m $MAILHOSTNAME} \
|
||||||
|
${MAILTARGET:+ -t $MAILTARGET} \
|
||||||
|
${DNSMASQ_USER:+ -u $DNSMASQ_USER} \
|
||||||
|
${DNSMASQ_INTERFACES:+ $DNSMASQ_INTERFACES} \
|
||||||
|
${DHCP_LEASE:+ -l $DHCP_LEASE} \
|
||||||
|
${DOMAIN_SUFFIX:+ -s $DOMAIN_SUFFIX} \
|
||||||
|
${RESOLV_CONF:+ -r $RESOLV_CONF} \
|
||||||
|
${CACHESIZE:+ -c $CACHESIZE} \
|
||||||
|
${CONFIG_DIR:+ -7 $CONFIG_DIR} \
|
||||||
|
${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|dump-stats|status}" >&2
|
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|dump-stats|status}" >&2
|
||||||
exit 3
|
exit 3
|
||||||
|
|||||||
Vendored
+11
-10
@@ -11,14 +11,14 @@
|
|||||||
|
|
||||||
package=dnsmasq-base
|
package=dnsmasq-base
|
||||||
|
|
||||||
# policy manual, section 10.1
|
CFLAGS = $(shell export DEB_BUILD_OPTIONS=$(DEB_BUILD_OPTIONS); dpkg-buildflags --get CFLAGS)
|
||||||
ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
|
CFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
|
||||||
CFLAGS = -g -O0 -Wall -W
|
CFLAGS += -Wall -W
|
||||||
else
|
|
||||||
CFLAGS = -g -O2 -Wall -W
|
LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
|
||||||
endif
|
|
||||||
|
|
||||||
COPTS =
|
COPTS =
|
||||||
|
|
||||||
TARGET = install-i18n
|
TARGET = install-i18n
|
||||||
|
|
||||||
DEB_BUILD_ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
|
DEB_BUILD_ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
|
||||||
@@ -85,7 +85,6 @@ binary-indep: checkroot
|
|||||||
-d debian/daemon/etc/resolvconf/update.d \
|
-d debian/daemon/etc/resolvconf/update.d \
|
||||||
-d debian/daemon/usr/lib/resolvconf/dpkg-event.d \
|
-d debian/daemon/usr/lib/resolvconf/dpkg-event.d \
|
||||||
-d debian/daemon/etc/default \
|
-d debian/daemon/etc/default \
|
||||||
-d debian/daemon/etc/dbus-1/system.d \
|
|
||||||
-d debian/daemon/lib/systemd/system \
|
-d debian/daemon/lib/systemd/system \
|
||||||
-d debian/daemon/etc/insserv.conf.d
|
-d debian/daemon/etc/insserv.conf.d
|
||||||
install -m 644 debian/conffiles debian/daemon/DEBIAN
|
install -m 644 debian/conffiles debian/daemon/DEBIAN
|
||||||
@@ -96,7 +95,6 @@ binary-indep: checkroot
|
|||||||
install -m 644 debian/default debian/daemon/etc/default/dnsmasq
|
install -m 644 debian/default debian/daemon/etc/default/dnsmasq
|
||||||
install -m 644 dnsmasq.conf.example debian/daemon/etc/dnsmasq.conf
|
install -m 644 dnsmasq.conf.example debian/daemon/etc/dnsmasq.conf
|
||||||
install -m 644 debian/readme.dnsmasq.d debian/daemon/etc/dnsmasq.d/README
|
install -m 644 debian/readme.dnsmasq.d debian/daemon/etc/dnsmasq.d/README
|
||||||
install -m 644 debian/dbus.conf debian/daemon/etc/dbus-1/system.d/dnsmasq.conf
|
|
||||||
install -m 644 debian/systemd.service debian/daemon/lib/systemd/system/dnsmasq.service
|
install -m 644 debian/systemd.service debian/daemon/lib/systemd/system/dnsmasq.service
|
||||||
install -m 644 debian/insserv debian/daemon/etc/insserv.conf.d/dnsmasq
|
install -m 644 debian/insserv debian/daemon/etc/insserv.conf.d/dnsmasq
|
||||||
ln -s $(package) debian/daemon/usr/share/doc/dnsmasq
|
ln -s $(package) debian/daemon/usr/share/doc/dnsmasq
|
||||||
@@ -111,11 +109,12 @@ binary-arch: checkroot
|
|||||||
rm -rf debian/base
|
rm -rf debian/base
|
||||||
install -m 755 \
|
install -m 755 \
|
||||||
-d debian/base/DEBIAN \
|
-d debian/base/DEBIAN \
|
||||||
|
-d debian/base/etc/dbus-1/system.d \
|
||||||
-d debian/base/usr/share/doc/$(package) \
|
-d debian/base/usr/share/doc/$(package) \
|
||||||
-d debian/base/usr/share/doc/$(package)/examples \
|
-d debian/base/usr/share/doc/$(package)/examples \
|
||||||
-d debian/base/var/run \
|
-d debian/base/var/run \
|
||||||
-d debian/base/var/lib/misc
|
-d debian/base/var/lib/misc
|
||||||
make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" COPTS="$(COPTS)" CC=gcc
|
make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(COPTS)" CC=gcc
|
||||||
ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
|
ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
|
||||||
install -m 644 doc.html debian/base/usr/share/doc/$(package)/.
|
install -m 644 doc.html debian/base/usr/share/doc/$(package)/.
|
||||||
install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
|
install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
|
||||||
@@ -129,10 +128,12 @@ ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
|
|||||||
install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
|
install -m 644 dbus/DBus-interface debian/base/usr/share/doc/$(package)/.
|
||||||
gzip -9 debian/base/usr/share/doc/$(package)/DBus-interface
|
gzip -9 debian/base/usr/share/doc/$(package)/DBus-interface
|
||||||
endif
|
endif
|
||||||
|
install -m 644 debian/dnsmasq-base.conffiles debian/base/DEBIAN/conffiles
|
||||||
install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
|
install -m 644 debian/changelog debian/base/usr/share/doc/$(package)/changelog.Debian
|
||||||
gzip -9 debian/base/usr/share/doc/$(package)/changelog.Debian
|
gzip -9 debian/base/usr/share/doc/$(package)/changelog.Debian
|
||||||
install -m 644 debian/readme debian/base/usr/share/doc/$(package)/README.Debian
|
install -m 644 debian/readme debian/base/usr/share/doc/$(package)/README.Debian
|
||||||
install -m 644 debian/copyright debian/base/usr/share/doc/$(package)/copyright
|
install -m 644 debian/copyright debian/base/usr/share/doc/$(package)/copyright
|
||||||
|
install -m 644 debian/dbus.conf debian/base/etc/dbus-1/system.d/dnsmasq.conf
|
||||||
gzip -9 debian/base/usr/share/man/man8/dnsmasq.8
|
gzip -9 debian/base/usr/share/man/man8/dnsmasq.8
|
||||||
for f in debian/base/usr/share/man/*; do \
|
for f in debian/base/usr/share/man/*; do \
|
||||||
if [ -f $$f/man8/dnsmasq.8 ]; then \
|
if [ -f $$f/man8/dnsmasq.8 ]; then \
|
||||||
@@ -155,7 +156,7 @@ ifeq ($(DEB_BUILD_ARCH_OS),linux)
|
|||||||
-d debian/utils/usr/share/man/man1 \
|
-d debian/utils/usr/share/man/man1 \
|
||||||
-d debian/utils/usr/bin \
|
-d debian/utils/usr/bin \
|
||||||
-d debian/utils/usr/share/doc/dnsmasq-utils
|
-d debian/utils/usr/share/doc/dnsmasq-utils
|
||||||
make -C contrib/wrt PREFIX=/usr DESTDIR=`pwd`/debian/utils CFLAGS="$(CFLAGS)" COPTS="$(COPTS)" CC=gcc
|
make -C contrib/wrt PREFIX=/usr DESTDIR=`pwd`/debian/utils CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(COPTS)" CC=gcc
|
||||||
install -m 755 contrib/wrt/dhcp_release debian/utils/usr/bin/dhcp_release
|
install -m 755 contrib/wrt/dhcp_release debian/utils/usr/bin/dhcp_release
|
||||||
install -m 644 contrib/wrt/dhcp_release.1 debian/utils/usr/share/man/man1/dhcp_release.1
|
install -m 644 contrib/wrt/dhcp_release.1 debian/utils/usr/share/man/man1/dhcp_release.1
|
||||||
gzip -9 debian/utils/usr/share/man/man1/dhcp_release.1
|
gzip -9 debian/utils/usr/share/man/man1/dhcp_release.1
|
||||||
|
|||||||
Vendored
+16
-14
@@ -8,22 +8,24 @@ BusName=uk.org.thekelleys.dnsmasq
|
|||||||
# Test the config file and refuse starting if it is not valid.
|
# Test the config file and refuse starting if it is not valid.
|
||||||
ExecStartPre=/usr/sbin/dnsmasq --test
|
ExecStartPre=/usr/sbin/dnsmasq --test
|
||||||
|
|
||||||
# Enable DBus by default because we use DBus activation.
|
# We run dnsmasq via the /etc/init.d/dnsmasq script which acts as a
|
||||||
|
# wrapper picking up extra configuration files and then execs dnsmasq
|
||||||
|
# itself, when called with the "systemd-exec" function.
|
||||||
#
|
#
|
||||||
# Drop privileges and become the 'dnsmasq' user. It is recommended by dnsmasq
|
# It also adds the command-line flags
|
||||||
# upstream to run dnsmasq as an isolated user that does not run any other
|
# --keep-in-foreground --pid-file --enable-dbus
|
||||||
# processes, owns no files and has no shell. The default 'nobody' user has a
|
# to disable writing a pid-file (not needed with systemd) and
|
||||||
# shell and might be used for other processes.
|
# enable DBus by default because we use DBus activation.
|
||||||
#
|
#
|
||||||
# Debian-specific: add /etc/dnsmasq.d to config search path (with the exception
|
ExecStart=/etc/init.d/dnsmasq systemd-exec
|
||||||
# of .dpkg-*). Packages such as libvirt leave config files there.
|
|
||||||
#
|
# The systemd-*-resolvconf functions configure (and deconfigure)
|
||||||
# --pid-file without argument disables writing a PIDfile, we don't need one.
|
# resolvconf to work with the dnsmasq DNS server. They're called liek
|
||||||
ExecStart=/usr/sbin/dnsmasq -k \
|
# this to get correct error handling (ie don't start-resolvconf if the
|
||||||
--enable-dbus \
|
# dnsmasq daemon fails to start.
|
||||||
--user=dnsmasq \
|
ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
|
||||||
-7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new \
|
ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf
|
||||||
--pid-file
|
|
||||||
|
|
||||||
ExecReload=/bin/kill -HUP $MAINPID
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
|
||||||
|
|||||||
@@ -326,6 +326,9 @@
|
|||||||
# dnsmasq and another.
|
# dnsmasq and another.
|
||||||
#dhcp-option=option6:dns-server,[::],[1234::88]
|
#dhcp-option=option6:dns-server,[::],[1234::88]
|
||||||
|
|
||||||
|
# Ask client to poll for option changes every six hours. (RFC4242)
|
||||||
|
#dhcp-option=option6:information-refresh-time,6h
|
||||||
|
|
||||||
# Set the NTP time server address to be the same machine as
|
# Set the NTP time server address to be the same machine as
|
||||||
# is running dnsmasq
|
# is running dnsmasq
|
||||||
#dhcp-option=42,0.0.0.0
|
#dhcp-option=42,0.0.0.0
|
||||||
@@ -522,7 +525,7 @@
|
|||||||
# If you want to disable negative caching, uncomment this.
|
# If you want to disable negative caching, uncomment this.
|
||||||
#no-negcache
|
#no-negcache
|
||||||
|
|
||||||
# Normally responses which come form /etc/hosts and the DHCP lease
|
# Normally responses which come from /etc/hosts and the DHCP lease
|
||||||
# file have Time-To-Live set as zero, which conventionally means
|
# file have Time-To-Live set as zero, which conventionally means
|
||||||
# do not cache further. If you are happy to trade lower load on the
|
# do not cache further. If you are happy to trade lower load on the
|
||||||
# server for potentially stale date, you can set a time-to-live (in
|
# server for potentially stale date, you can set a time-to-live (in
|
||||||
|
|||||||
+28
-56
@@ -204,6 +204,17 @@ running another nameserver (or another instance of dnsmasq) on the
|
|||||||
same machine. Setting this option also enables multiple instances of
|
same machine. Setting this option also enables multiple instances of
|
||||||
dnsmasq which provide DHCP service to run in the same machine.
|
dnsmasq which provide DHCP service to run in the same machine.
|
||||||
.TP
|
.TP
|
||||||
|
.B --bind-dynamic
|
||||||
|
Enable a network mode which is a hybrid between
|
||||||
|
.B --bind-interfaces
|
||||||
|
and the default. Dnsmasq binds the address of individual interfaces,
|
||||||
|
allowing multiple dnsmasq instances, but if new interfaces or
|
||||||
|
addresses appear, it automatically listens on those (subject to any
|
||||||
|
access-control configuration). This makes dynamically created
|
||||||
|
interfaces work in the same way as the default. Implementing this
|
||||||
|
option requires non-standard networking APIs and it is only available
|
||||||
|
under Linux. On other platforms it falls-back to --bind-interfaces mode.
|
||||||
|
.TP
|
||||||
.B \-y, --localise-queries
|
.B \-y, --localise-queries
|
||||||
Return answers to DNS queries from /etc/hosts which depend on the interface over which the query was
|
Return answers to DNS queries from /etc/hosts which depend on the interface over which the query was
|
||||||
received. If a name in /etc/hosts has more than one address associated with
|
received. If a name in /etc/hosts has more than one address associated with
|
||||||
@@ -260,11 +271,13 @@ time is the one used.
|
|||||||
Don't read /etc/resolv.conf. Get upstream servers only from the command
|
Don't read /etc/resolv.conf. Get upstream servers only from the command
|
||||||
line or the dnsmasq configuration file.
|
line or the dnsmasq configuration file.
|
||||||
.TP
|
.TP
|
||||||
.B \-1, --enable-dbus
|
.B \-1, --enable-dbus[=<service-name>]
|
||||||
Allow dnsmasq configuration to be updated via DBus method calls. The
|
Allow dnsmasq configuration to be updated via DBus method calls. The
|
||||||
configuration which can be changed is upstream DNS servers (and
|
configuration which can be changed is upstream DNS servers (and
|
||||||
corresponding domains) and cache clear. Requires that dnsmasq has
|
corresponding domains) and cache clear. Requires that dnsmasq has
|
||||||
been built with DBus support.
|
been built with DBus support. If the service name is given, dnsmasq
|
||||||
|
provides service at that name, rather than the default which is
|
||||||
|
.B uk.org.thekelleys.dnsmasq
|
||||||
.TP
|
.TP
|
||||||
.B \-o, --strict-order
|
.B \-o, --strict-order
|
||||||
By default, dnsmasq will send queries to any of the upstream servers
|
By default, dnsmasq will send queries to any of the upstream servers
|
||||||
@@ -450,10 +463,18 @@ Return an NAPTR DNS record, as specified in RFC3403.
|
|||||||
Return a CNAME record which indicates that <cname> is really
|
Return a CNAME record which indicates that <cname> is really
|
||||||
<target>. There are significant limitations on the target; it must be a
|
<target>. There are significant limitations on the target; it must be a
|
||||||
DNS name which is known to dnsmasq from /etc/hosts (or additional
|
DNS name which is known to dnsmasq from /etc/hosts (or additional
|
||||||
hosts files) or from DHCP. If the target does not satisfy this
|
hosts files), from DHCP or from another
|
||||||
|
.B --cname.
|
||||||
|
If the target does not satisfy this
|
||||||
criteria, the whole cname is ignored. The cname must be unique, but it
|
criteria, the whole cname is ignored. The cname must be unique, but it
|
||||||
is permissable to have more than one cname pointing to the same target.
|
is permissable to have more than one cname pointing to the same target.
|
||||||
.TP
|
.TP
|
||||||
|
.B --dns-rr=<name>,<RR-number>,[<hex data>]
|
||||||
|
Return an arbitrary DNS Resource Record. The number is the type of the
|
||||||
|
record (which is always in the C_IN class). The value of the record is
|
||||||
|
given by the hex data, which may be of the form 01:23:45 or 01 23 45 or
|
||||||
|
012345 or any mixture of these.
|
||||||
|
.TP
|
||||||
.B --interface-name=<name>,<interface>
|
.B --interface-name=<name>,<interface>
|
||||||
Return a DNS record associating the name with the primary address on
|
Return a DNS record associating the name with the primary address on
|
||||||
the given interface. This flag specifies an A record for the given
|
the given interface. This flag specifies an A record for the given
|
||||||
@@ -512,9 +533,9 @@ compiled in and the kernel must have conntrack support
|
|||||||
included and configured. This option cannot be combined with
|
included and configured. This option cannot be combined with
|
||||||
--query-port.
|
--query-port.
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-addr>[,<end-addr>][,<mode>][,<netmask>[,<broadcast>]][,<lease time>]
|
.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag],]<start-addr>[,<end-addr>][,<mode>][,<netmask>[,<broadcast>]][,<lease time>]
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-IPv6addr>[,<end-IPv6addr>][,<mode>][,<prefix-len>][,<lease time>]
|
.B \-F, --dhcp-range=[tag:<tag>[,tag:<tag>],][set:<tag],]<start-IPv6addr>[,<end-IPv6addr>][,<mode>][,<prefix-len>][,<lease time>]
|
||||||
|
|
||||||
Enable the DHCP server. Addresses will be given out from the range
|
Enable the DHCP server. Addresses will be given out from the range
|
||||||
<start-addr> to <end-addr> and from statically defined addresses given
|
<start-addr> to <end-addr> and from statically defined addresses given
|
||||||
@@ -607,8 +628,6 @@ can be combined with
|
|||||||
and
|
and
|
||||||
.B slaac.
|
.B slaac.
|
||||||
|
|
||||||
The interface:<interface name> section is not normally used. See the
|
|
||||||
NOTES section for details of this.
|
|
||||||
.TP
|
.TP
|
||||||
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
|
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
|
||||||
Specify per host parameters for the DHCP server. This allows a machine
|
Specify per host parameters for the DHCP server. This allows a machine
|
||||||
@@ -1352,12 +1371,11 @@ the relevant link-local address of the machine running dnsmasq is sent
|
|||||||
as recursive DNS server. If provided, the DHCPv6 options dns-server and
|
as recursive DNS server. If provided, the DHCPv6 options dns-server and
|
||||||
domain-search are used for RDNSS and DNSSL.
|
domain-search are used for RDNSS and DNSSL.
|
||||||
.TP
|
.TP
|
||||||
.B --enable-tftp[=<interface>]
|
.B --enable-tftp
|
||||||
Enable the TFTP server function. This is deliberately limited to that
|
Enable the TFTP server function. This is deliberately limited to that
|
||||||
needed to net-boot a client. Only reading is allowed; the tsize and
|
needed to net-boot a client. Only reading is allowed; the tsize and
|
||||||
blksize extensions are supported (tsize is only supported in octet
|
blksize extensions are supported (tsize is only supported in octet
|
||||||
mode). See NOTES section for use of the interface argument.
|
mode).
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --tftp-root=<directory>[,<interface>]
|
.B --tftp-root=<directory>[,<interface>]
|
||||||
Look for files to transfer using TFTP relative to the given
|
Look for files to transfer using TFTP relative to the given
|
||||||
@@ -1621,52 +1639,6 @@ parameter in a BOOTP request is used as a tag,
|
|||||||
as is the tag "bootp", allowing some control over the options returned to
|
as is the tag "bootp", allowing some control over the options returned to
|
||||||
different classes of hosts.
|
different classes of hosts.
|
||||||
|
|
||||||
.B dhcp-range
|
|
||||||
may have an interface name supplied as
|
|
||||||
"interface:<interface-name>". The semantics if this are as follows:
|
|
||||||
For DHCP, if any other dhcp-range exists _without_ an interface name,
|
|
||||||
then the interface name is ignored and and dnsmasq behaves as if the
|
|
||||||
interface parts did not exist, otherwise DHCP is only provided to
|
|
||||||
interfaces mentioned in dhcp-range
|
|
||||||
declarations. For DNS, if there are no
|
|
||||||
.B --interface
|
|
||||||
or
|
|
||||||
.B --listen-address
|
|
||||||
flags, behaviour is unchanged by the interface part. If either of
|
|
||||||
these flags are present, the interfaces mentioned in
|
|
||||||
dhcp-ranges are added to the set which get DNS service.
|
|
||||||
|
|
||||||
Similarly,
|
|
||||||
.B enable-tftp
|
|
||||||
may take an interface name, which enables TFTP only for a particular
|
|
||||||
interface, ignoring
|
|
||||||
.B --interface
|
|
||||||
or
|
|
||||||
.B --listen-address
|
|
||||||
flags. In addition
|
|
||||||
.B --tftp-secure
|
|
||||||
and
|
|
||||||
.B --tftp-unique-root
|
|
||||||
and
|
|
||||||
.B --tftp-no-blocksize
|
|
||||||
are ignored for requests from such interfaces. (A
|
|
||||||
.B --tftp-root
|
|
||||||
directive giving a root path and an interface should be
|
|
||||||
provided too.)
|
|
||||||
|
|
||||||
These rules may seem odd at first sight, but they
|
|
||||||
allow a single line of the form "dhcp-range=interface:virt0,192.168.0.4,192.168.0.200"
|
|
||||||
to be added to dnsmasq configuration which then supplies
|
|
||||||
DHCP and DNS services to that interface, without affecting
|
|
||||||
what services are supplied to other interfaces and irrespective of
|
|
||||||
the existance or lack of "interface=<interface>"
|
|
||||||
lines elsewhere in the dnsmasq configuration.
|
|
||||||
"enable-tftp=virt0" and "tftp-root=<root>,virt0" do the same job for TFTP.
|
|
||||||
The idea is
|
|
||||||
that such a line can be added automatically by libvirt
|
|
||||||
or equivalent systems, without disturbing any manual
|
|
||||||
configuration.
|
|
||||||
|
|
||||||
.SH EXIT CODES
|
.SH EXIT CODES
|
||||||
.PP
|
.PP
|
||||||
0 - Dnsmasq successfully forked into the background, or terminated
|
0 - Dnsmasq successfully forked into the background, or terminated
|
||||||
|
|||||||
+34
-55
@@ -232,6 +232,18 @@ autre serveur de nom (ou une autre instance de Dnsmasq) tourne sur la même
|
|||||||
machine. Utiliser cette option permet également d'avoir plusieurs instances de
|
machine. Utiliser cette option permet également d'avoir plusieurs instances de
|
||||||
Dnsmasq fournissant un service DHCP sur la même machine.
|
Dnsmasq fournissant un service DHCP sur la même machine.
|
||||||
.TP
|
.TP
|
||||||
|
.B --bind-dynamic
|
||||||
|
Autorise un mode réseau intermédiaire entre
|
||||||
|
.B --bind-interfaces
|
||||||
|
et le mode par défaut. Dnsmasq s'associe à une seule interface, ce qui permet
|
||||||
|
plusieurs instances de dnsmasq, mais si une interface ou adresse apparaissent,
|
||||||
|
il se mettra automatiquement à écouter sur celles-ci (les règles de contrôle
|
||||||
|
d'accès s'appliquent).
|
||||||
|
De fait, les interfaces créées dynamiquement fonctionnent de la même façon que
|
||||||
|
dans le comportement par défaut. Ce fonctionnement nécessite des APIs réseau
|
||||||
|
non standard et n'est disponible que sous Linux. Sur les autres plateformes,
|
||||||
|
le fonctionnement est celui du mode --bind-interfaces.
|
||||||
|
.TP
|
||||||
.B \-y, --localise-queries
|
.B \-y, --localise-queries
|
||||||
Retourne des réponses aux requêtes DNS dépendantes de l'interface sur laquelle
|
Retourne des réponses aux requêtes DNS dépendantes de l'interface sur laquelle
|
||||||
la requête a été reçue, à partir du fichier /etc/hosts. Si un nom dans
|
la requête a été reçue, à partir du fichier /etc/hosts. Si un nom dans
|
||||||
@@ -532,9 +544,17 @@ Retourne un enregistrement de type NAPTR, tel que spécifié dans le RFC3403.
|
|||||||
Retourne un enregistrement de type CNAME qui indique que <cname> est en
|
Retourne un enregistrement de type CNAME qui indique que <cname> est en
|
||||||
réalité <cible>. Il existe des contraintes significatives sur la valeur
|
réalité <cible>. Il existe des contraintes significatives sur la valeur
|
||||||
de cible; il doit s'agir d'un nom DNS qui est connu de dnsmasq via /etc/hosts
|
de cible; il doit s'agir d'un nom DNS qui est connu de dnsmasq via /etc/hosts
|
||||||
(ou un fichier hôtes additionnel) ou via DHCP. Si une cible ne satisfait
|
(ou un fichier hôtes additionnel), ou via DHCP, ou par un autre
|
||||||
pas ces critères, le CNAME est ignoré. Le CNAME doit être unique, mais
|
.B --cname.
|
||||||
il est autorisé d'avoir plus d'un CNAME pointant vers la même cible.
|
Si une cible ne satisfait pas ces critères, le CNAME est ignoré. Le CNAME
|
||||||
|
doit être unique, mais il est autorisé d'avoir plus d'un CNAME pointant
|
||||||
|
vers la même cible.
|
||||||
|
.TP
|
||||||
|
.B --dns-rr=<nom>,<numéro-RR>,[<données hexadécimales>]
|
||||||
|
Retourne un enregistrement DNS arbitraire. Le numéro correspond au type
|
||||||
|
d'enregistrement (qui est toujours de la classe C_IN). La valeur de
|
||||||
|
l'enregistrement est donnée dans les données hexadécimales, qui peuvent
|
||||||
|
être de la forme 01:23:45, 01 23 45,+012345 ou n'importe quelle combinaison.
|
||||||
.TP
|
.TP
|
||||||
.B --interface-name=<nom>,<interface>
|
.B --interface-name=<nom>,<interface>
|
||||||
Définit un entregistrement DNS associant le nom avec l'adresse primaire sur
|
Définit un entregistrement DNS associant le nom avec l'adresse primaire sur
|
||||||
@@ -601,9 +621,9 @@ avec le support conntrack, le noyau doit également inclure conntrack et être
|
|||||||
configuré pour cela. Cette option ne peut pas être combinée avec
|
configuré pour cela. Cette option ne peut pas être combinée avec
|
||||||
--query-port.
|
--query-port.
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[interface:<interface>,][tag:<label>[,tag:<label>],][set:<label>],]<adresse de début>[,<adresse de fin>][,<mode>][,<masque de réseau>[,<broadcast>]][,<durée de bail>]
|
.B \-F, --dhcp-range=[tag:<label>[,tag:<label>],][set:<label>],]<adresse de début>[,<adresse de fin>][,<mode>][,<masque de réseau>[,<broadcast>]][,<durée de bail>]
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[interface:<interface>,][tag:<label>[,tag:<label>],][set:<label>],]<addresse IPv6 de début>[,<adresse IPv6 de fin>][,<mode>][,<longueur de préfixe>][,<durée de bail>]
|
.B \-F, --dhcp-range=[tag:<label>[,tag:<label>],][set:<label>],]<addresse IPv6 de début>[,<adresse IPv6 de fin>][,<mode>][,<longueur de préfixe>][,<durée de bail>]
|
||||||
Active le serveur DHCP. Les adresses seront données dans la plage comprise entre
|
Active le serveur DHCP. Les adresses seront données dans la plage comprise entre
|
||||||
<adresse de début> et <adresse de fin> et à partir des adresses définies
|
<adresse de début> et <adresse de fin> et à partir des adresses définies
|
||||||
statiquement dans l'option
|
statiquement dans l'option
|
||||||
@@ -705,8 +725,6 @@ peut-être combiné avec
|
|||||||
et
|
et
|
||||||
.B slaac.
|
.B slaac.
|
||||||
|
|
||||||
La section interface:<nom d'interface> n'est normalement pas utilisée. Se
|
|
||||||
référer aux indications de la section NOTES pour plus de détail à ce sujet.
|
|
||||||
.TP
|
.TP
|
||||||
.B \-G, --dhcp-host=[<adresse matérielle>][,id:<identifiant client>|*][,set:<label>][,<adresse IP>][,<nom d'hôte>][,<durée de bail>][,ignore]
|
.B \-G, --dhcp-host=[<adresse matérielle>][,id:<identifiant client>|*][,set:<label>][,<adresse IP>][,<nom d'hôte>][,<durée de bail>][,ignore]
|
||||||
Spécifie les paramètres DHCP relatifs à un hôte. Cela permet à une machine
|
Spécifie les paramètres DHCP relatifs à un hôte. Cela permet à une machine
|
||||||
@@ -1517,12 +1535,11 @@ dnsmasq est spécifiée comme DNS récursif. Si elles sont fournies, les
|
|||||||
options dns-server et domain-search sont utilisées respectivement pour RDNSS et
|
options dns-server et domain-search sont utilisées respectivement pour RDNSS et
|
||||||
DNSSL.
|
DNSSL.
|
||||||
.TP
|
.TP
|
||||||
.B --enable-tftp[=<interface>]
|
.B --enable-tftp
|
||||||
Active la fonction serveur TFTP. Celui-ci est de manière délibérée limité aux
|
Active la fonction serveur TFTP. Celui-ci est de manière délibérée limité aux
|
||||||
fonctions nécessaires au démarrage par le réseau ("net-boot") d'un client. Seul
|
fonctions nécessaires au démarrage par le réseau ("net-boot") d'un client. Seul
|
||||||
un accès en lecture est possible; les extensions tsize et blksize sont supportées
|
un accès en lecture est possible; les extensions tsize et blksize sont supportées
|
||||||
(tsize est seulement supporté en mode octet). Voir dans la section NOTES les
|
(tsize est seulement supporté en mode octet).
|
||||||
informations relatives à la spécification de l'interface.
|
|
||||||
.TP
|
.TP
|
||||||
.B --tftp-root=<répertoire>[,<interface>]
|
.B --tftp-root=<répertoire>[,<interface>]
|
||||||
Les fichiers à fournir dans les transferts TFTP seront cherchés en prenant le
|
Les fichiers à fournir dans les transferts TFTP seront cherchés en prenant le
|
||||||
@@ -1560,6 +1577,13 @@ Sans cela, en effet, l'accès de tous les fichiers du serveur pour lequel le
|
|||||||
droit de lecture pour tout le monde est positionné ("world-readable") devient
|
droit de lecture pour tout le monde est positionné ("world-readable") devient
|
||||||
possible par n'importe quel hôte sur le réseau.
|
possible par n'importe quel hôte sur le réseau.
|
||||||
.TP
|
.TP
|
||||||
|
.B --tftp-lowercase
|
||||||
|
Converti les noms de fichiers des requêtes TFTP en minuscules. Cela est utile
|
||||||
|
pour les requêtes effectuées depuis les machines Windows, dont les systèmes
|
||||||
|
de fichiers sont insensibles à la casse et pour lesquels la détermination
|
||||||
|
de la casse est parfois un peu aléatoire. A noter que le serveur tftp de
|
||||||
|
dnsmasq converti systématiquement les "\\" en "/" dans les noms de fichiers.
|
||||||
|
.TP
|
||||||
.B --tftp-max=<connexions>
|
.B --tftp-max=<connexions>
|
||||||
Définit le nombre maximum de connexions TFTP simultanées autorisées. La valeur
|
Définit le nombre maximum de connexions TFTP simultanées autorisées. La valeur
|
||||||
par défaut est de 50. Lorsqu'un grand nombre de connexions TFTP est spécifié,
|
par défaut est de 50. Lorsqu'un grand nombre de connexions TFTP est spécifié,
|
||||||
@@ -1823,51 +1847,6 @@ supprime la nécessité des associations statiques). Le paramètre
|
|||||||
que le label "bootp", permettant un certain contrôle sur les options retournées
|
que le label "bootp", permettant un certain contrôle sur les options retournées
|
||||||
aux différentes classes d'hôtes.
|
aux différentes classes d'hôtes.
|
||||||
|
|
||||||
Il est possible de spécifier un nom d'interface à
|
|
||||||
.B dhcp-range
|
|
||||||
sous la forme "interface:<nom d'interface>". La sémantique est comme suit :
|
|
||||||
Pour le DHCP, s'il existe une autre valeur de dhcp-range pour laquelle
|
|
||||||
_aucun_ nom d'interface n'est donné, alors le nom d'interface est ignoré
|
|
||||||
et dnsmasq se comporte comme si la partie spécifiant l'interface n'existait
|
|
||||||
pas, sinon le service DHCP n'est fourni qu'aux interfaces mentionnées dans
|
|
||||||
les déclarations dhcp-range. Pour le DNS, si il n'y a pas d'option
|
|
||||||
.B --interface
|
|
||||||
ou
|
|
||||||
.B --listen-address
|
|
||||||
, alors le comportement n'est pas impacté par la spécification d'interface. Si
|
|
||||||
l'une ou l'autre de ces options est présente, alors les interfaces mentionnées
|
|
||||||
dans les plages d'adresses dhcp-range sont rajoutées à la liste de celles
|
|
||||||
où le service DNS est assuré.
|
|
||||||
|
|
||||||
De manière similaire,
|
|
||||||
.B enable-tftp
|
|
||||||
peut prendre un nom d'interface, ce qui active le TFTP pour cette seule
|
|
||||||
interface, en ignorant les options
|
|
||||||
.B --interface
|
|
||||||
ou
|
|
||||||
.B --listen-address
|
|
||||||
De plus,
|
|
||||||
.B --tftp-secure
|
|
||||||
,
|
|
||||||
.B --tftp-unique-root
|
|
||||||
et
|
|
||||||
.B --tftp-no-blocksize
|
|
||||||
sont ignorées pour les requêtes sur de telles interfaces. (une directive
|
|
||||||
.B --tftp-root
|
|
||||||
donnant le chemin de la racine et une interface doit-être fournie).
|
|
||||||
|
|
||||||
Ces règles peuvent paraître étrange à première vue, mais elles permettent
|
|
||||||
d'ajouter à la configuration de dnsmasq des lignes de configuration de la
|
|
||||||
forme "dhcp-range=interface:virt0,192.168.0.4,192.168.0.200" afin de fournir
|
|
||||||
un service DHCP et DNS sur cette interface, sans pour autant affecter les
|
|
||||||
services fournis sur d'autres interfaces, malgré l'absence de paramètres
|
|
||||||
"interface=<interface>" sur les autres lignes de configuration.
|
|
||||||
"enable-tftp=virt0" et "tftp-root=<root>,virt0" effectuent la même chose pour
|
|
||||||
TFTP.
|
|
||||||
L'idée de tout cela est de permettre l'addition de telles lignes
|
|
||||||
automatiquement par libvirt ou un système équivalent, sans perturbation
|
|
||||||
d'une configuration manuelle existant par ailleurs.
|
|
||||||
|
|
||||||
.SH CODES DE SORTIE
|
.SH CODES DE SORTIE
|
||||||
.PP
|
.PP
|
||||||
0 - Dnsmasq s'est correctement lancé en tâche de fond, ou alors s'est
|
0 - Dnsmasq s'est correctement lancé en tâche de fond, ou alors s'est
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
|
|
||||||
#if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
|
#if defined(HAVE_BSD_NETWORK) && !defined(__APPLE__)
|
||||||
|
#include <sys/param.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
#include <net/if_dl.h>
|
#include <net/if_dl.h>
|
||||||
|
|||||||
+51
-37
@@ -243,7 +243,7 @@ static int is_outdated_cname_pointer(struct crec *crecp)
|
|||||||
/* NB. record may be reused as DS or DNSKEY, where uid is
|
/* NB. record may be reused as DS or DNSKEY, where uid is
|
||||||
overloaded for something completely different */
|
overloaded for something completely different */
|
||||||
if (crecp->addr.cname.cache &&
|
if (crecp->addr.cname.cache &&
|
||||||
(crecp->addr.cname.cache->flags & (F_IPV4 | F_IPV6)) &&
|
(crecp->addr.cname.cache->flags & (F_IPV4 | F_IPV6 | F_CNAME)) &&
|
||||||
crecp->addr.cname.uid == crecp->addr.cname.cache->uid)
|
crecp->addr.cname.uid == crecp->addr.cname.cache->uid)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -645,13 +645,29 @@ struct crec *cache_find_by_addr(struct crec *crecp, struct all_addr *addr,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_hosts_cname(struct crec *target)
|
||||||
|
{
|
||||||
|
struct crec *crec;
|
||||||
|
struct cname *a;
|
||||||
|
|
||||||
|
for (a = daemon->cnames; a; a = a->next)
|
||||||
|
if (hostname_isequal(cache_get_name(target), a->target) &&
|
||||||
|
(crec = whine_malloc(sizeof(struct crec))))
|
||||||
|
{
|
||||||
|
crec->flags = F_FORWARD | F_IMMORTAL | F_NAMEP | F_HOSTS | F_CNAME;
|
||||||
|
crec->name.namep = a->alias;
|
||||||
|
crec->addr.cname.cache = target;
|
||||||
|
crec->addr.cname.uid = target->uid;
|
||||||
|
cache_hash(crec);
|
||||||
|
add_hosts_cname(crec); /* handle chains */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrlen,
|
static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrlen,
|
||||||
int index, struct crec **rhash, int hashsz)
|
int index, struct crec **rhash, int hashsz)
|
||||||
{
|
{
|
||||||
struct crec *lookup = cache_find_by_name(NULL, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6));
|
struct crec *lookup = cache_find_by_name(NULL, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6));
|
||||||
int i, nameexists = 0;
|
int i, nameexists = 0;
|
||||||
struct cname *a;
|
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
||||||
/* Remove duplicates in hosts files. */
|
/* Remove duplicates in hosts files. */
|
||||||
@@ -702,16 +718,7 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
|
|||||||
|
|
||||||
/* don't need to do alias stuff for second and subsequent addresses. */
|
/* don't need to do alias stuff for second and subsequent addresses. */
|
||||||
if (!nameexists)
|
if (!nameexists)
|
||||||
for (a = daemon->cnames; a; a = a->next)
|
add_hosts_cname(cache);
|
||||||
if (hostname_isequal(cache_get_name(cache), a->target) &&
|
|
||||||
(lookup = whine_malloc(sizeof(struct crec))))
|
|
||||||
{
|
|
||||||
lookup->flags = F_FORWARD | F_IMMORTAL | F_NAMEP | F_HOSTS | F_CNAME;
|
|
||||||
lookup->name.namep = a->alias;
|
|
||||||
lookup->addr.cname.cache = cache;
|
|
||||||
lookup->addr.cname.uid = index;
|
|
||||||
cache_hash(lookup);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eatspace(FILE *f)
|
static int eatspace(FILE *f)
|
||||||
@@ -1003,13 +1010,41 @@ void cache_unhash_dhcp(void)
|
|||||||
up = &cache->hash_next;
|
up = &cache->hash_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void add_dhcp_cname(struct crec *target, time_t ttd)
|
||||||
|
{
|
||||||
|
struct crec *aliasc;
|
||||||
|
struct cname *a;
|
||||||
|
|
||||||
|
for (a = daemon->cnames; a; a = a->next)
|
||||||
|
if (hostname_isequal(cache_get_name(target), a->target))
|
||||||
|
{
|
||||||
|
if ((aliasc = dhcp_spare))
|
||||||
|
dhcp_spare = dhcp_spare->next;
|
||||||
|
else /* need new one */
|
||||||
|
aliasc = whine_malloc(sizeof(struct crec));
|
||||||
|
|
||||||
|
if (aliasc)
|
||||||
|
{
|
||||||
|
aliasc->flags = F_FORWARD | F_NAMEP | F_DHCP | F_CNAME;
|
||||||
|
if (ttd == 0)
|
||||||
|
aliasc->flags |= F_IMMORTAL;
|
||||||
|
else
|
||||||
|
aliasc->ttd = ttd;
|
||||||
|
aliasc->name.namep = a->alias;
|
||||||
|
aliasc->addr.cname.cache = target;
|
||||||
|
aliasc->addr.cname.uid = target->uid;
|
||||||
|
cache_hash(aliasc);
|
||||||
|
add_dhcp_cname(aliasc, ttd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cache_add_dhcp_entry(char *host_name, int prot,
|
void cache_add_dhcp_entry(char *host_name, int prot,
|
||||||
struct all_addr *host_address, time_t ttd)
|
struct all_addr *host_address, time_t ttd)
|
||||||
{
|
{
|
||||||
struct crec *crec = NULL, *aliasc;
|
struct crec *crec = NULL;
|
||||||
unsigned short flags = F_IPV4;
|
unsigned short flags = F_IPV4;
|
||||||
int in_hosts = 0;
|
int in_hosts = 0;
|
||||||
struct cname *a;
|
|
||||||
size_t addrlen = sizeof(struct in_addr);
|
size_t addrlen = sizeof(struct in_addr);
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
@@ -1030,7 +1065,6 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
|
|
||||||
inet_ntop(prot, host_address, daemon->addrbuff, ADDRSTRLEN);
|
inet_ntop(prot, host_address, daemon->addrbuff, ADDRSTRLEN);
|
||||||
if (crec->flags & F_CNAME)
|
if (crec->flags & F_CNAME)
|
||||||
|
|
||||||
my_syslog(MS_DHCP | LOG_WARNING,
|
my_syslog(MS_DHCP | LOG_WARNING,
|
||||||
_("%s is a CNAME, not giving it to the DHCP lease of %s"),
|
_("%s is a CNAME, not giving it to the DHCP lease of %s"),
|
||||||
host_name, daemon->addrbuff);
|
host_name, daemon->addrbuff);
|
||||||
@@ -1083,27 +1117,7 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
crec->uid = uid++;
|
crec->uid = uid++;
|
||||||
cache_hash(crec);
|
cache_hash(crec);
|
||||||
|
|
||||||
for (a = daemon->cnames; a; a = a->next)
|
add_dhcp_cname(crec, ttd);
|
||||||
if (hostname_isequal(host_name, a->target))
|
|
||||||
{
|
|
||||||
if ((aliasc = dhcp_spare))
|
|
||||||
dhcp_spare = dhcp_spare->next;
|
|
||||||
else /* need new one */
|
|
||||||
aliasc = whine_malloc(sizeof(struct crec));
|
|
||||||
|
|
||||||
if (aliasc)
|
|
||||||
{
|
|
||||||
aliasc->flags = F_FORWARD | F_NAMEP | F_DHCP | F_CNAME;
|
|
||||||
if (ttd == 0)
|
|
||||||
aliasc->flags |= F_IMMORTAL;
|
|
||||||
else
|
|
||||||
aliasc->ttd = ttd;
|
|
||||||
aliasc->name.namep = a->alias;
|
|
||||||
aliasc->addr.cname.cache = crec;
|
|
||||||
aliasc->addr.cname.uid = crec->uid;
|
|
||||||
cache_hash(aliasc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+8
-3
@@ -33,7 +33,6 @@
|
|||||||
#define SMALLDNAME 40 /* most domain names are smaller than this */
|
#define SMALLDNAME 40 /* most domain names are smaller than this */
|
||||||
#define HOSTSFILE "/etc/hosts"
|
#define HOSTSFILE "/etc/hosts"
|
||||||
#define ETHERSFILE "/etc/ethers"
|
#define ETHERSFILE "/etc/ethers"
|
||||||
#define RUNFILE "/var/run/dnsmasq.pid"
|
|
||||||
#define DEFLEASE 3600 /* default lease time, 1 hour */
|
#define DEFLEASE 3600 /* default lease time, 1 hour */
|
||||||
#define CHUSER "nobody"
|
#define CHUSER "nobody"
|
||||||
#define CHGRP "dip"
|
#define CHGRP "dip"
|
||||||
@@ -41,7 +40,7 @@
|
|||||||
#define LOG_MAX 5 /* log-queue length */
|
#define LOG_MAX 5 /* log-queue length */
|
||||||
#define RANDFILE "/dev/urandom"
|
#define RANDFILE "/dev/urandom"
|
||||||
#define EDNS0_OPTION_MAC 5 /* dyndns.org temporary assignment */
|
#define EDNS0_OPTION_MAC 5 /* dyndns.org temporary assignment */
|
||||||
#define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* DBUS interface specifics */
|
#define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* Default - may be overridden by config */
|
||||||
#define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
|
#define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"
|
||||||
|
|
||||||
/* compile-time options: uncomment below to enable or do eg.
|
/* compile-time options: uncomment below to enable or do eg.
|
||||||
@@ -158,7 +157,13 @@ RESOLVFILE
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef RUNFILE
|
||||||
|
# if defined(__ANDROID__)
|
||||||
|
# define RUNFILE "/data/dnsmasq.pid"
|
||||||
|
# else
|
||||||
|
# define RUNFILE "/var/run/dnsmasq.pid"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* platform dependent options: these are determined automatically below
|
/* platform dependent options: these are determined automatically below
|
||||||
|
|
||||||
|
|||||||
+21
-9
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
const char* introspection_xml =
|
const char* introspection_xml_template =
|
||||||
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
|
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
|
||||||
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
|
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
|
||||||
"<node name=\"" DNSMASQ_PATH "\">\n"
|
"<node name=\"" DNSMASQ_PATH "\">\n"
|
||||||
@@ -29,7 +29,7 @@ const char* introspection_xml =
|
|||||||
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
|
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" </interface>\n"
|
" </interface>\n"
|
||||||
" <interface name=\"" DNSMASQ_SERVICE "\">\n"
|
" <interface name=\"%s\">\n"
|
||||||
" <method name=\"ClearCache\">\n"
|
" <method name=\"ClearCache\">\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
" <method name=\"GetVersion\">\n"
|
" <method name=\"GetVersion\">\n"
|
||||||
@@ -56,6 +56,8 @@ const char* introspection_xml =
|
|||||||
" </interface>\n"
|
" </interface>\n"
|
||||||
"</node>\n";
|
"</node>\n";
|
||||||
|
|
||||||
|
static char *introspection_xml = NULL;
|
||||||
|
|
||||||
struct watch {
|
struct watch {
|
||||||
DBusWatch *watch;
|
DBusWatch *watch;
|
||||||
struct watch *next;
|
struct watch *next;
|
||||||
@@ -266,11 +268,21 @@ DBusHandlerResult message_handler(DBusConnection *connection,
|
|||||||
|
|
||||||
if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
|
if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
|
||||||
{
|
{
|
||||||
DBusMessage *reply = dbus_message_new_method_return(message);
|
DBusMessage *reply;
|
||||||
|
|
||||||
dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection_xml, DBUS_TYPE_INVALID);
|
/* string length: "%s" provides space for termination zero */
|
||||||
dbus_connection_send (connection, reply, NULL);
|
if (!introspection_xml &&
|
||||||
dbus_message_unref (reply);
|
(introspection_xml = whine_malloc(strlen(introspection_xml_template) + strlen(daemon->dbus_name))))
|
||||||
|
sprintf(introspection_xml, introspection_xml_template, daemon->dbus_name);
|
||||||
|
|
||||||
|
if (introspection_xml)
|
||||||
|
{
|
||||||
|
reply = dbus_message_new_method_return(message);
|
||||||
|
|
||||||
|
dbus_message_append_args(reply, DBUS_TYPE_STRING, &introspection_xml, DBUS_TYPE_INVALID);
|
||||||
|
dbus_connection_send (connection, reply, NULL);
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(method, "GetVersion") == 0)
|
else if (strcmp(method, "GetVersion") == 0)
|
||||||
{
|
{
|
||||||
@@ -315,7 +327,7 @@ char *dbus_init(void)
|
|||||||
dbus_connection_set_watch_functions(connection, add_watch, remove_watch,
|
dbus_connection_set_watch_functions(connection, add_watch, remove_watch,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
dbus_error_init (&dbus_error);
|
dbus_error_init (&dbus_error);
|
||||||
dbus_bus_request_name (connection, DNSMASQ_SERVICE, 0, &dbus_error);
|
dbus_bus_request_name (connection, daemon->dbus_name, 0, &dbus_error);
|
||||||
if (dbus_error_is_set (&dbus_error))
|
if (dbus_error_is_set (&dbus_error))
|
||||||
return (char *)dbus_error.message;
|
return (char *)dbus_error.message;
|
||||||
|
|
||||||
@@ -325,7 +337,7 @@ char *dbus_init(void)
|
|||||||
|
|
||||||
daemon->dbus = connection;
|
daemon->dbus = connection;
|
||||||
|
|
||||||
if ((message = dbus_message_new_signal(DNSMASQ_PATH, DNSMASQ_SERVICE, "Up")))
|
if ((message = dbus_message_new_signal(DNSMASQ_PATH, daemon->dbus_name, "Up")))
|
||||||
{
|
{
|
||||||
dbus_connection_send(connection, message, NULL);
|
dbus_connection_send(connection, message, NULL);
|
||||||
dbus_message_unref(message);
|
dbus_message_unref(message);
|
||||||
@@ -430,7 +442,7 @@ void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname)
|
|||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(message = dbus_message_new_signal(DNSMASQ_PATH, DNSMASQ_SERVICE, action_str)))
|
if (!(message = dbus_message_new_signal(DNSMASQ_PATH, daemon->dbus_name, action_str)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dbus_message_iter_init_append(message, &args);
|
dbus_message_iter_init_append(message, &args);
|
||||||
|
|||||||
+9
-48
@@ -246,40 +246,6 @@ int match_bytes(struct dhcp_opt *o, unsigned char *p, int len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_dhcp_hosts(int fatal)
|
|
||||||
{
|
|
||||||
/* If the same IP appears in more than one host config, then DISCOVER
|
|
||||||
for one of the hosts will get the address, but REQUEST will be NAKed,
|
|
||||||
since the address is reserved by the other one -> protocol loop.
|
|
||||||
Also check that FQDNs match the domain we are using. */
|
|
||||||
|
|
||||||
struct dhcp_config *configs, *cp;
|
|
||||||
|
|
||||||
for (configs = daemon->dhcp_conf; configs; configs = configs->next)
|
|
||||||
{
|
|
||||||
char *domain;
|
|
||||||
|
|
||||||
if ((configs->flags & DHOPT_BANK) || fatal)
|
|
||||||
{
|
|
||||||
for (cp = configs->next; cp; cp = cp->next)
|
|
||||||
if ((configs->flags & cp->flags & CONFIG_ADDR) && configs->addr.s_addr == cp->addr.s_addr)
|
|
||||||
{
|
|
||||||
if (fatal)
|
|
||||||
die(_("duplicate IP address %s in dhcp-config directive."),
|
|
||||||
inet_ntoa(cp->addr), EC_BADCONF);
|
|
||||||
else
|
|
||||||
my_syslog(MS_DHCP | LOG_ERR, _("duplicate IP address %s in %s."),
|
|
||||||
inet_ntoa(cp->addr), daemon->dhcp_hosts_file);
|
|
||||||
configs->flags &= ~CONFIG_ADDR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* split off domain part */
|
|
||||||
if ((configs->flags & CONFIG_NAME) && (domain = strip_hostname(configs->hostname)))
|
|
||||||
configs->domain = domain;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dhcp_update_configs(struct dhcp_config *configs)
|
void dhcp_update_configs(struct dhcp_config *configs)
|
||||||
{
|
{
|
||||||
/* Some people like to keep all static IP addresses in /etc/hosts.
|
/* Some people like to keep all static IP addresses in /etc/hosts.
|
||||||
@@ -372,7 +338,6 @@ static int join_multicast_worker(struct in6_addr *local, int prefix,
|
|||||||
char ifrn_name[IFNAMSIZ];
|
char ifrn_name[IFNAMSIZ];
|
||||||
struct ipv6_mreq mreq;
|
struct ipv6_mreq mreq;
|
||||||
int fd, i, max = *((int *)vparam);
|
int fd, i, max = *((int *)vparam);
|
||||||
struct dhcp_context *context;
|
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
|
|
||||||
(void)prefix;
|
(void)prefix;
|
||||||
@@ -406,14 +371,6 @@ static int join_multicast_worker(struct in6_addr *local, int prefix,
|
|||||||
if (tmp->name && (strcmp(tmp->name, ifrn_name) == 0))
|
if (tmp->name && (strcmp(tmp->name, ifrn_name) == 0))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* weird libvirt-inspired access control */
|
|
||||||
for (context = daemon->dhcp6; context; context = context->next)
|
|
||||||
if (!context->interface || strcmp(context->interface, ifrn_name) == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!context)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
mreq.ipv6mr_interface = if_index;
|
mreq.ipv6mr_interface = if_index;
|
||||||
|
|
||||||
inet_pton(AF_INET6, ALL_RELAY_AGENTS_AND_SERVERS, &mreq.ipv6mr_multiaddr);
|
inet_pton(AF_INET6, ALL_RELAY_AGENTS_AND_SERVERS, &mreq.ipv6mr_multiaddr);
|
||||||
@@ -530,15 +487,15 @@ static const struct opttab_t {
|
|||||||
{ "x-windows-fs", 48, OT_ADDR_LIST },
|
{ "x-windows-fs", 48, OT_ADDR_LIST },
|
||||||
{ "x-windows-dm", 49, OT_ADDR_LIST },
|
{ "x-windows-dm", 49, OT_ADDR_LIST },
|
||||||
{ "requested-address", 50, OT_INTERNAL | OT_ADDR_LIST },
|
{ "requested-address", 50, OT_INTERNAL | OT_ADDR_LIST },
|
||||||
{ "lease-time", 51, OT_INTERNAL | OT_DEC },
|
{ "lease-time", 51, OT_INTERNAL | OT_TIME },
|
||||||
{ "option-overload", 52, OT_INTERNAL },
|
{ "option-overload", 52, OT_INTERNAL },
|
||||||
{ "message-type", 53, OT_INTERNAL | OT_DEC },
|
{ "message-type", 53, OT_INTERNAL | OT_DEC },
|
||||||
{ "server-identifier", 54, OT_INTERNAL | OT_ADDR_LIST },
|
{ "server-identifier", 54, OT_INTERNAL | OT_ADDR_LIST },
|
||||||
{ "parameter-request", 55, OT_INTERNAL },
|
{ "parameter-request", 55, OT_INTERNAL },
|
||||||
{ "message", 56, OT_INTERNAL },
|
{ "message", 56, OT_INTERNAL },
|
||||||
{ "max-message-size", 57, OT_INTERNAL },
|
{ "max-message-size", 57, OT_INTERNAL },
|
||||||
{ "T1", 58, OT_INTERNAL | OT_DEC},
|
{ "T1", 58, OT_INTERNAL | OT_TIME},
|
||||||
{ "T2", 59, OT_INTERNAL | OT_DEC},
|
{ "T2", 59, OT_INTERNAL | OT_TIME},
|
||||||
{ "vendor-class", 60, 0 },
|
{ "vendor-class", 60, 0 },
|
||||||
{ "client-id", 61, OT_INTERNAL },
|
{ "client-id", 61, OT_INTERNAL },
|
||||||
{ "nis+-domain", 64, OT_NAME },
|
{ "nis+-domain", 64, OT_NAME },
|
||||||
@@ -589,6 +546,7 @@ static const struct opttab_t opttab6[] = {
|
|||||||
{ "nis-domain", 29, OT_RFC1035_NAME },
|
{ "nis-domain", 29, OT_RFC1035_NAME },
|
||||||
{ "nis+-domain", 30, OT_RFC1035_NAME },
|
{ "nis+-domain", 30, OT_RFC1035_NAME },
|
||||||
{ "sntp-server", 31, OT_ADDR_LIST },
|
{ "sntp-server", 31, OT_ADDR_LIST },
|
||||||
|
{ "information-refresh-time", 32, OT_TIME },
|
||||||
{ "FQDN", 39, OT_INTERNAL | OT_RFC1035_NAME },
|
{ "FQDN", 39, OT_INTERNAL | OT_RFC1035_NAME },
|
||||||
{ "ntp-server", 56, OT_ADDR_LIST },
|
{ "ntp-server", 56, OT_ADDR_LIST },
|
||||||
{ "bootfile-url", 59, OT_NAME },
|
{ "bootfile-url", 59, OT_NAME },
|
||||||
@@ -753,14 +711,17 @@ char *option_string(int prot, unsigned int opt, unsigned char *val, int opt_len,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if ((ot[o].size & OT_DEC) && opt_len != 0)
|
else if ((ot[o].size & (OT_DEC | OT_TIME)) && opt_len != 0)
|
||||||
{
|
{
|
||||||
unsigned int dec = 0;
|
unsigned int dec = 0;
|
||||||
|
|
||||||
for (i = 0; i < opt_len; i++)
|
for (i = 0; i < opt_len; i++)
|
||||||
dec = (dec << 8) | val[i];
|
dec = (dec << 8) | val[i];
|
||||||
|
|
||||||
sprintf(buf, "%u", dec);
|
if (ot[o].size & OT_TIME)
|
||||||
|
prettyprint_time(buf, dec);
|
||||||
|
else
|
||||||
|
sprintf(buf, "%u", dec);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nodecode = 1;
|
nodecode = 1;
|
||||||
|
|||||||
+3
-13
@@ -66,7 +66,7 @@ static int make_fd(int port)
|
|||||||
/* When bind-interfaces is set, there might be more than one dnmsasq
|
/* When bind-interfaces is set, there might be more than one dnmsasq
|
||||||
instance binding port 67. That's OK if they serve different networks.
|
instance binding port 67. That's OK if they serve different networks.
|
||||||
Need to set REUSEADDR to make this posible, or REUSEPORT on *BSD. */
|
Need to set REUSEADDR to make this posible, or REUSEPORT on *BSD. */
|
||||||
if (option_bool(OPT_NOWILD))
|
if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
|
||||||
{
|
{
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
int rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt));
|
int rc = setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &oneopt, sizeof(oneopt));
|
||||||
@@ -116,9 +116,7 @@ void dhcp_init(void)
|
|||||||
|
|
||||||
/* Make BPF raw send socket */
|
/* Make BPF raw send socket */
|
||||||
init_bpf();
|
init_bpf();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
check_dhcp_hosts(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dhcp_packet(time_t now, int pxe_fd)
|
void dhcp_packet(time_t now, int pxe_fd)
|
||||||
@@ -257,14 +255,6 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* weird libvirt-inspired access control */
|
|
||||||
for (context = daemon->dhcp; context; context = context->next)
|
|
||||||
if (!context->interface || strcmp(context->interface, ifr.ifr_name) == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!context)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* unlinked contexts are marked by context->current == context */
|
/* unlinked contexts are marked by context->current == context */
|
||||||
for (context = daemon->dhcp; context; context = context->next)
|
for (context = daemon->dhcp; context; context = context->next)
|
||||||
context->current = context;
|
context->current = context;
|
||||||
@@ -277,7 +267,7 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
/* If we failed to match the primary address of the interface, see if we've got a --listen-address
|
/* If we failed to match the primary address of the interface, see if we've got a --listen-address
|
||||||
for a secondary */
|
for a secondary */
|
||||||
struct match_param match;
|
struct match_param match;
|
||||||
|
|
||||||
match.matched = 0;
|
match.matched = 0;
|
||||||
match.ind = iface_index;
|
match.ind = iface_index;
|
||||||
|
|
||||||
|
|||||||
@@ -111,14 +111,6 @@ void dhcp6_packet(time_t now)
|
|||||||
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* weird libvirt-inspired access control */
|
|
||||||
for (context = daemon->dhcp6; context; context = context->next)
|
|
||||||
if (!context->interface || strcmp(context->interface, ifr.ifr_name) == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!context)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* unlinked contexts are marked by context->current == context */
|
/* unlinked contexts are marked by context->current == context */
|
||||||
for (context = daemon->dhcp6; context; context = context->next)
|
for (context = daemon->dhcp6; context; context = context->next)
|
||||||
{
|
{
|
||||||
|
|||||||
+57
-14
@@ -114,10 +114,18 @@ int main (int argc, char **argv)
|
|||||||
set_option_bool(OPT_NOWILD);
|
set_option_bool(OPT_NOWILD);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
/* -- bind-dynamic not supported on !Linux, fall back to --bind-interfaces */
|
||||||
|
if (option_bool(OPT_CLEVERBIND))
|
||||||
|
{
|
||||||
|
bind_fallback = 1;
|
||||||
|
set_option_bool(OPT_NOWILD);
|
||||||
|
reset_option_bool(OPT_CLEVERBIND);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_TFTP
|
#ifndef HAVE_TFTP
|
||||||
if (daemon->tftp_unlimited || daemon->tftp_interfaces)
|
if (option_bool(OPT_TFTP))
|
||||||
die(_("TFTP server not available: set HAVE_TFTP in src/config.h"), NULL, EC_BADCONF);
|
die(_("TFTP server not available: set HAVE_TFTP in src/config.h"), NULL, EC_BADCONF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -185,6 +193,9 @@ int main (int argc, char **argv)
|
|||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
/* After lease_init */
|
/* After lease_init */
|
||||||
netlink_init();
|
netlink_init();
|
||||||
|
|
||||||
|
if (option_bool(OPT_NOWILD) && option_bool(OPT_CLEVERBIND))
|
||||||
|
die(_("cannot set --bind-interfaces and --bind-dynamic"), NULL, EC_BADCONF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
@@ -202,13 +213,14 @@ int main (int argc, char **argv)
|
|||||||
if (!enumerate_interfaces())
|
if (!enumerate_interfaces())
|
||||||
die(_("failed to find list of interfaces: %s"), NULL, EC_MISC);
|
die(_("failed to find list of interfaces: %s"), NULL, EC_MISC);
|
||||||
|
|
||||||
if (option_bool(OPT_NOWILD))
|
if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
|
||||||
{
|
{
|
||||||
create_bound_listeners(1);
|
create_bound_listeners(1);
|
||||||
|
|
||||||
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
if (!option_bool(OPT_CLEVERBIND))
|
||||||
if (if_tmp->name && !if_tmp->used)
|
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
||||||
die(_("unknown interface %s"), if_tmp->name, EC_BADNET);
|
if (if_tmp->name && !if_tmp->used)
|
||||||
|
die(_("unknown interface %s"), if_tmp->name, EC_BADNET);
|
||||||
|
|
||||||
#if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP)
|
#if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP)
|
||||||
/* after enumerate_interfaces() */
|
/* after enumerate_interfaces() */
|
||||||
@@ -425,8 +437,9 @@ int main (int argc, char **argv)
|
|||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
/* On linux, we keep CAP_NETADMIN (for ARP-injection) and
|
/* On linux, we keep CAP_NETADMIN (for ARP-injection) and
|
||||||
CAP_NET_RAW (for icmp) if we're doing dhcp. If we have yet to bind
|
CAP_NET_RAW (for icmp) if we're doing dhcp. If we have yet to bind
|
||||||
ports because of DAD, we need CAP_NET_BIND_SERVICE too. */
|
ports because of DAD, or we're doing it dynamically,
|
||||||
if (is_dad_listeners())
|
we need CAP_NET_BIND_SERVICE too. */
|
||||||
|
if (is_dad_listeners() || option_bool(OPT_CLEVERBIND))
|
||||||
data->effective = data->permitted = data->inheritable =
|
data->effective = data->permitted = data->inheritable =
|
||||||
(1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW) |
|
(1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW) |
|
||||||
(1 << CAP_SETUID) | (1 << CAP_NET_BIND_SERVICE);
|
(1 << CAP_SETUID) | (1 << CAP_NET_BIND_SERVICE);
|
||||||
@@ -474,7 +487,7 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
if (is_dad_listeners())
|
if (is_dad_listeners() || option_bool(OPT_CLEVERBIND))
|
||||||
data->effective = data->permitted =
|
data->effective = data->permitted =
|
||||||
(1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW) | (1 << CAP_NET_BIND_SERVICE);
|
(1 << CAP_NET_ADMIN) | (1 << CAP_NET_RAW) | (1 << CAP_NET_BIND_SERVICE);
|
||||||
else
|
else
|
||||||
@@ -498,6 +511,34 @@ int main (int argc, char **argv)
|
|||||||
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
|
prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_TFTP
|
||||||
|
if (option_bool(OPT_TFTP))
|
||||||
|
{
|
||||||
|
DIR *dir;
|
||||||
|
struct tftp_prefix *p;
|
||||||
|
|
||||||
|
if (daemon->tftp_prefix)
|
||||||
|
{
|
||||||
|
if (!((dir = opendir(daemon->tftp_prefix))))
|
||||||
|
{
|
||||||
|
send_event(err_pipe[1], EVENT_TFTP_ERR, errno, daemon->tftp_prefix);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (p = daemon->if_prefix; p; p = p->next)
|
||||||
|
{
|
||||||
|
if (!((dir = opendir(p->prefix))))
|
||||||
|
{
|
||||||
|
send_event(err_pipe[1], EVENT_TFTP_ERR, errno, p->prefix);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (daemon->port == 0)
|
if (daemon->port == 0)
|
||||||
my_syslog(LOG_INFO, _("started, version %s DNS disabled"), VERSION);
|
my_syslog(LOG_INFO, _("started, version %s DNS disabled"), VERSION);
|
||||||
else if (daemon->cachesize != 0)
|
else if (daemon->cachesize != 0)
|
||||||
@@ -627,7 +668,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_TFTP
|
#ifdef HAVE_TFTP
|
||||||
if (daemon->tftp_unlimited || daemon->tftp_interfaces)
|
if (option_bool(OPT_TFTP))
|
||||||
{
|
{
|
||||||
#ifdef FD_SETSIZE
|
#ifdef FD_SETSIZE
|
||||||
if (FD_SETSIZE < (unsigned)max_fd)
|
if (FD_SETSIZE < (unsigned)max_fd)
|
||||||
@@ -995,6 +1036,9 @@ static void fatal_event(struct event_desc *ev, char *msg)
|
|||||||
|
|
||||||
case EVENT_LUA_ERR:
|
case EVENT_LUA_ERR:
|
||||||
die(_("failed to load Lua script: %s"), msg, EC_MISC);
|
die(_("failed to load Lua script: %s"), msg, EC_MISC);
|
||||||
|
|
||||||
|
case EVENT_TFTP_ERR:
|
||||||
|
die(_("TFTP directory %s inaccessible: %s"), msg, EC_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1199,7 +1243,6 @@ void clear_cache_and_reload(time_t now)
|
|||||||
dhcp_read_ethers();
|
dhcp_read_ethers();
|
||||||
reread_dhcp();
|
reread_dhcp();
|
||||||
dhcp_update_configs(daemon->dhcp_conf);
|
dhcp_update_configs(daemon->dhcp_conf);
|
||||||
check_dhcp_hosts(0);
|
|
||||||
lease_update_from_configs();
|
lease_update_from_configs();
|
||||||
lease_update_file(now);
|
lease_update_file(now);
|
||||||
lease_update_dns(1);
|
lease_update_dns(1);
|
||||||
@@ -1321,7 +1364,7 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
getsockname(confd, (struct sockaddr *)&tcp_addr, &tcp_len) == -1)
|
getsockname(confd, (struct sockaddr *)&tcp_addr, &tcp_len) == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (option_bool(OPT_NOWILD))
|
if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
|
||||||
iface = listener->iface; /* May be NULL */
|
iface = listener->iface; /* May be NULL */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1338,7 +1381,7 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iface && !option_bool(OPT_NOWILD))
|
if (!iface && !(option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND)))
|
||||||
{
|
{
|
||||||
shutdown(confd, SHUT_RDWR);
|
shutdown(confd, SHUT_RDWR);
|
||||||
close(confd);
|
close(confd);
|
||||||
|
|||||||
+9
-13
@@ -159,6 +159,7 @@ struct event_desc {
|
|||||||
#define EVENT_LOG_ERR 17
|
#define EVENT_LOG_ERR 17
|
||||||
#define EVENT_FORK_ERR 18
|
#define EVENT_FORK_ERR 18
|
||||||
#define EVENT_LUA_ERR 19
|
#define EVENT_LUA_ERR 19
|
||||||
|
#define EVENT_TFTP_ERR 20
|
||||||
|
|
||||||
/* Exit codes. */
|
/* Exit codes. */
|
||||||
#define EC_GOOD 0
|
#define EC_GOOD 0
|
||||||
@@ -218,7 +219,9 @@ struct event_desc {
|
|||||||
#define OPT_FQDN_UPDATE 36
|
#define OPT_FQDN_UPDATE 36
|
||||||
#define OPT_RA 37
|
#define OPT_RA 37
|
||||||
#define OPT_TFTP_LC 38
|
#define OPT_TFTP_LC 38
|
||||||
#define OPT_LAST 39
|
#define OPT_CLEVERBIND 39
|
||||||
|
#define OPT_TFTP 40
|
||||||
|
#define OPT_LAST 41
|
||||||
|
|
||||||
/* extra flags for my_syslog, we use a couple of facilities since they are known
|
/* extra flags for my_syslog, we use a couple of facilities since they are known
|
||||||
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
|
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
|
||||||
@@ -424,7 +427,7 @@ struct listener {
|
|||||||
struct iname {
|
struct iname {
|
||||||
char *name;
|
char *name;
|
||||||
union mysockaddr addr;
|
union mysockaddr addr;
|
||||||
int isloop, used;
|
int used;
|
||||||
struct iname *next;
|
struct iname *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -472,7 +475,7 @@ struct frec {
|
|||||||
#define OT_NAME 0x1000
|
#define OT_NAME 0x1000
|
||||||
#define OT_CSTRING 0x0800
|
#define OT_CSTRING 0x0800
|
||||||
#define OT_DEC 0x0400
|
#define OT_DEC 0x0400
|
||||||
|
#define OT_TIME 0x0200
|
||||||
|
|
||||||
/* actions in the daemon->helper RPC */
|
/* actions in the daemon->helper RPC */
|
||||||
#define ACTION_DEL 1
|
#define ACTION_DEL 1
|
||||||
@@ -662,7 +665,6 @@ struct dhcp_context {
|
|||||||
time_t ra_time;
|
time_t ra_time;
|
||||||
#endif
|
#endif
|
||||||
int flags;
|
int flags;
|
||||||
char *interface;
|
|
||||||
struct dhcp_netid netid, *filter;
|
struct dhcp_netid netid, *filter;
|
||||||
struct dhcp_context *next, *current;
|
struct dhcp_context *next, *current;
|
||||||
};
|
};
|
||||||
@@ -710,11 +712,6 @@ struct addr_list {
|
|||||||
struct addr_list *next;
|
struct addr_list *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct interface_list {
|
|
||||||
char *interface;
|
|
||||||
struct interface_list *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct tftp_prefix {
|
struct tftp_prefix {
|
||||||
char *interface;
|
char *interface;
|
||||||
char *prefix;
|
char *prefix;
|
||||||
@@ -732,7 +729,7 @@ extern struct daemon {
|
|||||||
time_t last_resolv;
|
time_t last_resolv;
|
||||||
struct mx_srv_record *mxnames;
|
struct mx_srv_record *mxnames;
|
||||||
struct naptr *naptr;
|
struct naptr *naptr;
|
||||||
struct txt_record *txt;
|
struct txt_record *txt, *rr;
|
||||||
struct ptr_record *ptr;
|
struct ptr_record *ptr;
|
||||||
struct host_record *host_records, *host_records_tail;
|
struct host_record *host_records, *host_records_tail;
|
||||||
struct cname *cnames;
|
struct cname *cnames;
|
||||||
@@ -778,10 +775,9 @@ extern struct daemon {
|
|||||||
unsigned short edns_pktsz;
|
unsigned short edns_pktsz;
|
||||||
char *tftp_prefix;
|
char *tftp_prefix;
|
||||||
struct tftp_prefix *if_prefix; /* per-interface TFTP prefixes */
|
struct tftp_prefix *if_prefix; /* per-interface TFTP prefixes */
|
||||||
struct interface_list *tftp_interfaces; /* interfaces for limited TFTP service */
|
|
||||||
int tftp_unlimited;
|
|
||||||
unsigned int duid_enterprise, duid_config_len;
|
unsigned int duid_enterprise, duid_config_len;
|
||||||
unsigned char *duid_config;
|
unsigned char *duid_config;
|
||||||
|
char *dbus_name;
|
||||||
|
|
||||||
/* globally used stuff for DNS */
|
/* globally used stuff for DNS */
|
||||||
char *packet; /* packet buffer */
|
char *packet; /* packet buffer */
|
||||||
@@ -930,6 +926,7 @@ char *option_string(int prot, unsigned int opt, unsigned char *val,
|
|||||||
int opt_len, char *buf, int buf_len);
|
int opt_len, char *buf, int buf_len);
|
||||||
void reread_dhcp(void);
|
void reread_dhcp(void);
|
||||||
void set_option_bool(unsigned int opt);
|
void set_option_bool(unsigned int opt);
|
||||||
|
void reset_option_bool(unsigned int opt);
|
||||||
struct hostsfile *expand_filelist(struct hostsfile *list);
|
struct hostsfile *expand_filelist(struct hostsfile *list);
|
||||||
|
|
||||||
/* forward.c */
|
/* forward.c */
|
||||||
@@ -1127,7 +1124,6 @@ char *strip_hostname(char *hostname);
|
|||||||
void log_tags(struct dhcp_netid *netid, u32 xid);
|
void log_tags(struct dhcp_netid *netid, u32 xid);
|
||||||
int match_bytes(struct dhcp_opt *o, unsigned char *p, int len);
|
int match_bytes(struct dhcp_opt *o, unsigned char *p, int len);
|
||||||
void dhcp_update_configs(struct dhcp_config *configs);
|
void dhcp_update_configs(struct dhcp_config *configs);
|
||||||
void check_dhcp_hosts(int fatal);
|
|
||||||
void display_opts(void);
|
void display_opts(void);
|
||||||
u16 lookup_dhcp_opt(int prot, char *name);
|
u16 lookup_dhcp_opt(int prot, char *name);
|
||||||
u16 lookup_dhcp_len(int prot, u16 val);
|
u16 lookup_dhcp_len(int prot, u16 val);
|
||||||
|
|||||||
+4
-4
@@ -436,7 +436,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
if (udpfd != -1)
|
if (udpfd != -1)
|
||||||
{
|
{
|
||||||
plen = setup_reply(header, plen, addrp, flags, daemon->local_ttl);
|
plen = setup_reply(header, plen, addrp, flags, daemon->local_ttl);
|
||||||
send_from(udpfd, option_bool(OPT_NOWILD), (char *)header, plen, udpaddr, dst_addr, dst_iface);
|
send_from(udpfd, option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND), (char *)header, plen, udpaddr, dst_addr, dst_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -624,7 +624,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
{
|
{
|
||||||
header->id = htons(forward->orig_id);
|
header->id = htons(forward->orig_id);
|
||||||
header->hb4 |= HB4_RA; /* recursion if available */
|
header->hb4 |= HB4_RA; /* recursion if available */
|
||||||
send_from(forward->fd, option_bool(OPT_NOWILD), daemon->packet, nn,
|
send_from(forward->fd, option_bool(OPT_NOWILD) || option_bool (OPT_CLEVERBIND), daemon->packet, nn,
|
||||||
&forward->source, &forward->dest, forward->iface);
|
&forward->source, &forward->dest, forward->iface);
|
||||||
}
|
}
|
||||||
free_frec(forward); /* cancel */
|
free_frec(forward); /* cancel */
|
||||||
@@ -819,8 +819,8 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
dst_addr_4, netmask, now);
|
dst_addr_4, netmask, now);
|
||||||
if (m >= 1)
|
if (m >= 1)
|
||||||
{
|
{
|
||||||
send_from(listen->fd, option_bool(OPT_NOWILD), (char *)header,
|
send_from(listen->fd, option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND),
|
||||||
m, &source_addr, &dst_addr, if_index);
|
(char *)header, m, &source_addr, &dst_addr, if_index);
|
||||||
daemon->local_answer++;
|
daemon->local_answer++;
|
||||||
}
|
}
|
||||||
else if (forward_query(listen->fd, &source_addr, &dst_addr, if_index,
|
else if (forward_query(listen->fd, &source_addr, &dst_addr, if_index,
|
||||||
|
|||||||
+79
-58
@@ -38,8 +38,7 @@
|
|||||||
static struct iovec iov;
|
static struct iovec iov;
|
||||||
static u32 netlink_pid;
|
static u32 netlink_pid;
|
||||||
|
|
||||||
static void nl_err(struct nlmsghdr *h);
|
static int nl_async(struct nlmsghdr *h);
|
||||||
static void nl_routechange(struct nlmsghdr *h);
|
|
||||||
|
|
||||||
void netlink_init(void)
|
void netlink_init(void)
|
||||||
{
|
{
|
||||||
@@ -49,10 +48,13 @@ void netlink_init(void)
|
|||||||
addr.nl_family = AF_NETLINK;
|
addr.nl_family = AF_NETLINK;
|
||||||
addr.nl_pad = 0;
|
addr.nl_pad = 0;
|
||||||
addr.nl_pid = 0; /* autobind */
|
addr.nl_pid = 0; /* autobind */
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
addr.nl_groups = RTMGRP_IPV4_ROUTE | RTMGRP_IPV6_ROUTE;
|
|
||||||
#else
|
|
||||||
addr.nl_groups = RTMGRP_IPV4_ROUTE;
|
addr.nl_groups = RTMGRP_IPV4_ROUTE;
|
||||||
|
if (option_bool(OPT_CLEVERBIND))
|
||||||
|
addr.nl_groups |= RTMGRP_IPV4_IFADDR;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
addr.nl_groups |= RTMGRP_IPV6_ROUTE;
|
||||||
|
if (daemon->ra_contexts || option_bool(OPT_CLEVERBIND))
|
||||||
|
addr.nl_groups |= RTMGRP_IPV6_IFADDR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* May not be able to have permission to set multicast groups don't die in that case */
|
/* May not be able to have permission to set multicast groups don't die in that case */
|
||||||
@@ -136,7 +138,7 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
struct nlmsghdr *h;
|
struct nlmsghdr *h;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
static unsigned int seq = 0;
|
static unsigned int seq = 0;
|
||||||
int callback_ok = 1;
|
int callback_ok = 1, newaddr = 0;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr nlh;
|
struct nlmsghdr nlh;
|
||||||
@@ -182,12 +184,24 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
|
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
|
||||||
if (h->nlmsg_seq != seq || h->nlmsg_pid != netlink_pid)
|
if (h->nlmsg_seq != seq || h->nlmsg_pid != netlink_pid || h->nlmsg_type == NLMSG_ERROR)
|
||||||
nl_routechange(h); /* May be multicast arriving async */
|
{
|
||||||
else if (h->nlmsg_type == NLMSG_ERROR)
|
/* May be multicast arriving async */
|
||||||
nl_err(h);
|
if (nl_async(h) && option_bool(OPT_CLEVERBIND))
|
||||||
|
newaddr = 1;
|
||||||
|
}
|
||||||
else if (h->nlmsg_type == NLMSG_DONE)
|
else if (h->nlmsg_type == NLMSG_DONE)
|
||||||
return callback_ok;
|
{
|
||||||
|
/* handle async new interface address arrivals, these have to be done
|
||||||
|
after we complete as we're not re-entrant */
|
||||||
|
if (newaddr)
|
||||||
|
{
|
||||||
|
enumerate_interfaces();
|
||||||
|
create_bound_listeners(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return callback_ok;
|
||||||
|
}
|
||||||
else if (h->nlmsg_type == RTM_NEWADDR && family != AF_UNSPEC && family != AF_LOCAL)
|
else if (h->nlmsg_type == RTM_NEWADDR && family != AF_UNSPEC && family != AF_LOCAL)
|
||||||
{
|
{
|
||||||
struct ifaddrmsg *ifa = NLMSG_DATA(h);
|
struct ifaddrmsg *ifa = NLMSG_DATA(h);
|
||||||
@@ -295,7 +309,7 @@ void netlink_multicast(void)
|
|||||||
{
|
{
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
struct nlmsghdr *h;
|
struct nlmsghdr *h;
|
||||||
int flags;
|
int flags, newaddr = 0;
|
||||||
|
|
||||||
/* don't risk blocking reading netlink messages here. */
|
/* don't risk blocking reading netlink messages here. */
|
||||||
if ((flags = fcntl(daemon->netlinkfd, F_GETFL)) == -1 ||
|
if ((flags = fcntl(daemon->netlinkfd, F_GETFL)) == -1 ||
|
||||||
@@ -303,45 +317,62 @@ void netlink_multicast(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if ((len = netlink_recv()) != -1)
|
if ((len = netlink_recv()) != -1)
|
||||||
{
|
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
|
||||||
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
|
if (nl_async(h) && option_bool(OPT_CLEVERBIND))
|
||||||
if (h->nlmsg_type == NLMSG_ERROR)
|
newaddr = 1;
|
||||||
nl_err(h);
|
|
||||||
else
|
|
||||||
nl_routechange(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* restore non-blocking status */
|
|
||||||
fcntl(daemon->netlinkfd, F_SETFL, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nl_err(struct nlmsghdr *h)
|
|
||||||
{
|
|
||||||
struct nlmsgerr *err = NLMSG_DATA(h);
|
|
||||||
|
|
||||||
if (err->error != 0)
|
/* restore non-blocking status */
|
||||||
my_syslog(LOG_ERR, _("netlink returns error: %s"), strerror(-(err->error)));
|
fcntl(daemon->netlinkfd, F_SETFL, flags);
|
||||||
|
|
||||||
|
if (newaddr)
|
||||||
|
{
|
||||||
|
enumerate_interfaces();
|
||||||
|
create_bound_listeners(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We arrange to receive netlink multicast messages whenever the network route is added.
|
static int nl_async(struct nlmsghdr *h)
|
||||||
If this happens and we still have a DNS packet in the buffer, we re-send it.
|
|
||||||
This helps on DoD links, where frequently the packet which triggers dialling is
|
|
||||||
a DNS query, which then gets lost. By re-sending, we can avoid the lookup
|
|
||||||
failing. Note that we only accept these messages from the kernel (pid == 0) */
|
|
||||||
static void nl_routechange(struct nlmsghdr *h)
|
|
||||||
{
|
{
|
||||||
if (h->nlmsg_pid == 0 && h->nlmsg_type == RTM_NEWROUTE)
|
if (h->nlmsg_type == NLMSG_ERROR)
|
||||||
{
|
{
|
||||||
|
struct nlmsgerr *err = NLMSG_DATA(h);
|
||||||
|
my_syslog(LOG_ERR, _("netlink returns error: %s"), strerror(-(err->error)));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (h->nlmsg_pid == 0 && h->nlmsg_type == RTM_NEWROUTE)
|
||||||
|
{
|
||||||
|
/* We arrange to receive netlink multicast messages whenever the network route is added.
|
||||||
|
If this happens and we still have a DNS packet in the buffer, we re-send it.
|
||||||
|
This helps on DoD links, where frequently the packet which triggers dialling is
|
||||||
|
a DNS query, which then gets lost. By re-sending, we can avoid the lookup
|
||||||
|
failing. */
|
||||||
struct rtmsg *rtm = NLMSG_DATA(h);
|
struct rtmsg *rtm = NLMSG_DATA(h);
|
||||||
int fd;
|
|
||||||
|
|
||||||
if (rtm->rtm_type != RTN_UNICAST || rtm->rtm_scope != RT_SCOPE_LINK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Force re-reading resolv file right now, for luck. */
|
|
||||||
daemon->last_resolv = 0;
|
|
||||||
|
|
||||||
|
if (rtm->rtm_type == RTN_UNICAST && rtm->rtm_scope == RT_SCOPE_LINK)
|
||||||
|
{
|
||||||
|
/* Force re-reading resolv file right now, for luck. */
|
||||||
|
daemon->last_resolv = 0;
|
||||||
|
|
||||||
|
if (daemon->srv_save)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if (daemon->srv_save->sfd)
|
||||||
|
fd = daemon->srv_save->sfd->fd;
|
||||||
|
else if (daemon->rfd_save && daemon->rfd_save->refcount != 0)
|
||||||
|
fd = daemon->rfd_save->fd;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
while(sendto(fd, daemon->packet, daemon->packet_len, 0,
|
||||||
|
&daemon->srv_save->addr.sa, sa_len(&daemon->srv_save->addr)) == -1 && retry_send());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
|
else if (h->nlmsg_type == RTM_NEWADDR)
|
||||||
|
{
|
||||||
/* force RAs to sync new network and pick up new interfaces. */
|
/* force RAs to sync new network and pick up new interfaces. */
|
||||||
if (daemon->ra_contexts)
|
if (daemon->ra_contexts)
|
||||||
{
|
{
|
||||||
@@ -351,23 +382,13 @@ static void nl_routechange(struct nlmsghdr *h)
|
|||||||
iface_enumerate and can't re-enter it now */
|
iface_enumerate and can't re-enter it now */
|
||||||
send_alarm(0, 0);
|
send_alarm(0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
return 1; /* clever bind mode - rescan */
|
||||||
|
|
||||||
if (daemon->srv_save)
|
|
||||||
{
|
|
||||||
if (daemon->srv_save->sfd)
|
|
||||||
fd = daemon->srv_save->sfd->fd;
|
|
||||||
else if (daemon->rfd_save && daemon->rfd_save->refcount != 0)
|
|
||||||
fd = daemon->rfd_save->fd;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
while(sendto(fd, daemon->packet, daemon->packet_len, 0,
|
|
||||||
&daemon->srv_save->addr.sa, sa_len(&daemon->srv_save->addr)) == -1 && retry_send());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
+42
-57
@@ -117,18 +117,8 @@ int iface_check(int family, struct all_addr *addr, char *name)
|
|||||||
|
|
||||||
if (daemon->if_names || daemon->if_addrs)
|
if (daemon->if_names || daemon->if_addrs)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DHCP
|
|
||||||
struct dhcp_context *range;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
#ifdef HAVE_DHCP
|
|
||||||
for (range = daemon->dhcp; range; range = range->next)
|
|
||||||
if (range->interface && strcmp(range->interface, name) == 0)
|
|
||||||
ret = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (tmp = daemon->if_names; tmp; tmp = tmp->next)
|
for (tmp = daemon->if_names; tmp; tmp = tmp->next)
|
||||||
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
||||||
ret = tmp->used = 1;
|
ret = tmp->used = 1;
|
||||||
@@ -161,12 +151,11 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
struct irec *iface;
|
struct irec *iface;
|
||||||
int fd, mtu = 0, loopback;
|
int fd, mtu = 0, loopback;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int tftp_ok = daemon->tftp_unlimited;
|
int tftp_ok = !!option_bool(OPT_TFTP);
|
||||||
int dhcp_ok = 1;
|
int dhcp_ok = 1;
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
#endif
|
#endif
|
||||||
struct interface_list *ir = NULL;
|
|
||||||
|
|
||||||
/* check whether the interface IP has been added already
|
/* check whether the interface IP has been added already
|
||||||
we call this routine multiple times. */
|
we call this routine multiple times. */
|
||||||
@@ -207,53 +196,38 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
struct iname *lo;
|
struct iname *lo;
|
||||||
for (lo = daemon->if_names; lo; lo = lo->next)
|
for (lo = daemon->if_names; lo; lo = lo->next)
|
||||||
if (lo->name && strcmp(lo->name, ifr.ifr_name) == 0)
|
if (lo->name && strcmp(lo->name, ifr.ifr_name) == 0)
|
||||||
{
|
break;
|
||||||
lo->isloop = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!lo &&
|
if (!lo &&
|
||||||
(lo = whine_malloc(sizeof(struct iname))) &&
|
(lo = whine_malloc(sizeof(struct iname))) &&
|
||||||
(lo->name = whine_malloc(strlen(ifr.ifr_name)+1)))
|
(lo->name = whine_malloc(strlen(ifr.ifr_name)+1)))
|
||||||
{
|
{
|
||||||
strcpy(lo->name, ifr.ifr_name);
|
strcpy(lo->name, ifr.ifr_name);
|
||||||
lo->isloop = lo->used = 1;
|
lo->used = 1;
|
||||||
lo->next = daemon->if_names;
|
lo->next = daemon->if_names;
|
||||||
daemon->if_names = lo;
|
daemon->if_names = lo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_TFTP
|
if (addr->sa.sa_family == AF_INET &&
|
||||||
/* implement wierd TFTP service rules */
|
!iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, ifr.ifr_name))
|
||||||
for (ir = daemon->tftp_interfaces; ir; ir = ir->next)
|
return 1;
|
||||||
if (strcmp(ir->interface, ifr.ifr_name) == 0)
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
|
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
||||||
{
|
{
|
||||||
tftp_ok = 1;
|
tftp_ok = 0;
|
||||||
break;
|
dhcp_ok = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ir)
|
|
||||||
{
|
|
||||||
if (addr->sa.sa_family == AF_INET &&
|
|
||||||
!iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, ifr.ifr_name))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
#ifdef HAVE_DHCP
|
|
||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
|
||||||
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
|
||||||
{
|
|
||||||
tftp_ok = 0;
|
|
||||||
dhcp_ok = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (addr->sa.sa_family == AF_INET6 &&
|
if (addr->sa.sa_family == AF_INET6 &&
|
||||||
!iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, ifr.ifr_name))
|
!iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, ifr.ifr_name))
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
/* add to list */
|
/* add to list */
|
||||||
if ((iface = whine_malloc(sizeof(struct irec))))
|
if ((iface = whine_malloc(sizeof(struct irec))))
|
||||||
@@ -350,6 +324,7 @@ static int make_sock(union mysockaddr *addr, int type, int dienow)
|
|||||||
if ((fd = socket(family, type, 0)) == -1)
|
if ((fd = socket(family, type, 0)) == -1)
|
||||||
{
|
{
|
||||||
int port;
|
int port;
|
||||||
|
char *s;
|
||||||
|
|
||||||
/* No error if the kernel just doesn't support this IP flavour */
|
/* No error if the kernel just doesn't support this IP flavour */
|
||||||
if (errno == EPROTONOSUPPORT ||
|
if (errno == EPROTONOSUPPORT ||
|
||||||
@@ -358,18 +333,27 @@ static int make_sock(union mysockaddr *addr, int type, int dienow)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
port = prettyprint_addr(addr, daemon->addrbuff);
|
||||||
|
if (!option_bool(OPT_NOWILD) && !option_bool(OPT_CLEVERBIND))
|
||||||
|
sprintf(daemon->addrbuff, "port %d", port);
|
||||||
|
s = _("failed to create listening socket for %s: %s");
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
|
close (fd);
|
||||||
|
|
||||||
if (dienow)
|
if (dienow)
|
||||||
{
|
{
|
||||||
port = prettyprint_addr(addr, daemon->namebuff);
|
/* failure to bind addresses given by --listen-address at this point
|
||||||
if (!option_bool(OPT_NOWILD))
|
is OK if we're doing bind-dynamic */
|
||||||
sprintf(daemon->namebuff, "port %d", port);
|
if (!option_bool(OPT_CLEVERBIND))
|
||||||
die(_("failed to create listening socket for %s: %s"),
|
die(s, daemon->addrbuff, EC_BADNET);
|
||||||
daemon->namebuff, EC_BADNET);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
my_syslog(LOG_WARNING, s, daemon->addrbuff, strerror(errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 || !fix_fd(fd))
|
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) == -1 || !fix_fd(fd))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@@ -487,8 +471,7 @@ static struct listener *create_listeners(union mysockaddr *addr, int do_tftp, in
|
|||||||
void create_wildcard_listeners(void)
|
void create_wildcard_listeners(void)
|
||||||
{
|
{
|
||||||
union mysockaddr addr;
|
union mysockaddr addr;
|
||||||
struct listener *l;
|
struct listener *l, *l6;
|
||||||
int tftp_enabled = daemon->tftp_unlimited || daemon->tftp_interfaces;
|
|
||||||
|
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||||
@@ -498,7 +481,7 @@ void create_wildcard_listeners(void)
|
|||||||
addr.in.sin_addr.s_addr = INADDR_ANY;
|
addr.in.sin_addr.s_addr = INADDR_ANY;
|
||||||
addr.in.sin_port = htons(daemon->port);
|
addr.in.sin_port = htons(daemon->port);
|
||||||
|
|
||||||
l = create_listeners(&addr, tftp_enabled, 1);
|
l = create_listeners(&addr, !!option_bool(OPT_TFTP), 1);
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
@@ -508,11 +491,12 @@ void create_wildcard_listeners(void)
|
|||||||
addr.in6.sin6_family = AF_INET6;
|
addr.in6.sin6_family = AF_INET6;
|
||||||
addr.in6.sin6_addr = in6addr_any;
|
addr.in6.sin6_addr = in6addr_any;
|
||||||
addr.in6.sin6_port = htons(daemon->port);
|
addr.in6.sin6_port = htons(daemon->port);
|
||||||
|
|
||||||
|
l6 = create_listeners(&addr, !!option_bool(OPT_TFTP), 1);
|
||||||
if (l)
|
if (l)
|
||||||
l->next = create_listeners(&addr, tftp_enabled, 1);
|
l->next = l6;
|
||||||
else
|
else
|
||||||
l = create_listeners(&addr, tftp_enabled, 1);
|
l = l6;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
daemon->listeners = l;
|
daemon->listeners = l;
|
||||||
@@ -538,7 +522,8 @@ void create_bound_listeners(int dienow)
|
|||||||
no interface with a matching address. These may be valid: eg it's possible
|
no interface with a matching address. These may be valid: eg it's possible
|
||||||
to listen on 127.0.1.1 even if the loopback interface is 127.0.0.1
|
to listen on 127.0.1.1 even if the loopback interface is 127.0.0.1
|
||||||
|
|
||||||
If the address isn't valid the bind() will fail and we'll die().
|
If the address isn't valid the bind() will fail and we'll die()
|
||||||
|
(except in bind-dynamic mode, when we'll complain but keep trying.)
|
||||||
|
|
||||||
The resulting listeners have the ->iface field NULL, and this has to be
|
The resulting listeners have the ->iface field NULL, and this has to be
|
||||||
handled by the DNS and TFTP code. It disables --localise-queries processing
|
handled by the DNS and TFTP code. It disables --localise-queries processing
|
||||||
@@ -546,7 +531,7 @@ void create_bound_listeners(int dienow)
|
|||||||
|
|
||||||
for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next)
|
for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next)
|
||||||
if (!if_tmp->used &&
|
if (!if_tmp->used &&
|
||||||
(new = create_listeners(&if_tmp->addr, 1, dienow)))
|
(new = create_listeners(&if_tmp->addr, !!option_bool(OPT_TFTP), dienow)))
|
||||||
{
|
{
|
||||||
new->iface = NULL;
|
new->iface = NULL;
|
||||||
new->next = daemon->listeners;
|
new->next = daemon->listeners;
|
||||||
|
|||||||
+410
-345
File diff suppressed because it is too large.
Load diff
+13
-17
@@ -119,7 +119,6 @@ void icmp6_packet(void)
|
|||||||
struct sockaddr_in6 from;
|
struct sockaddr_in6 from;
|
||||||
unsigned char *packet;
|
unsigned char *packet;
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
struct dhcp_context *context;
|
|
||||||
|
|
||||||
/* Note: use outpacket for input buffer */
|
/* Note: use outpacket for input buffer */
|
||||||
msg.msg_control = control_u.control6;
|
msg.msg_control = control_u.control6;
|
||||||
@@ -157,14 +156,9 @@ void icmp6_packet(void)
|
|||||||
if (tmp->name && (strcmp(tmp->name, interface) == 0))
|
if (tmp->name && (strcmp(tmp->name, interface) == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* weird libvirt-inspired access control */
|
if (packet[1] != 0)
|
||||||
for (context = daemon->dhcp6; context; context = context->next)
|
|
||||||
if (!context->interface || strcmp(context->interface, interface) == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!context || packet[1] != 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (packet[0] == ICMP6_ECHO_REPLY)
|
if (packet[0] == ICMP6_ECHO_REPLY)
|
||||||
lease_ping_reply(&from.sin6_addr, packet, interface);
|
lease_ping_reply(&from.sin6_addr, packet, interface);
|
||||||
else if (packet[0] == ND_ROUTER_SOLICIT)
|
else if (packet[0] == ND_ROUTER_SOLICIT)
|
||||||
@@ -379,13 +373,6 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
if (context->flags & CONTEXT_DEPRECATE)
|
if (context->flags & CONTEXT_DEPRECATE)
|
||||||
deprecate = 1;
|
deprecate = 1;
|
||||||
|
|
||||||
/* subsequent prefixes on the same interface
|
|
||||||
and subsequent instances of this prefix don't need timers */
|
|
||||||
if (!param->first)
|
|
||||||
context->ra_time = 0;
|
|
||||||
param->first = 0;
|
|
||||||
param->found_context = 1;
|
|
||||||
|
|
||||||
/* collect dhcp-range tags */
|
/* collect dhcp-range tags */
|
||||||
if (context->netid.next == &context->netid && context->netid.net)
|
if (context->netid.next == &context->netid && context->netid.net)
|
||||||
{
|
{
|
||||||
@@ -393,11 +380,20 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
param->tags = &context->netid;
|
param->tags = &context->netid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* subsequent prefixes on the same interface
|
||||||
|
and subsequent instances of this prefix don't need timers.
|
||||||
|
Be careful not to find the same prefix twice with different
|
||||||
|
addresses. */
|
||||||
if (!(context->flags & CONTEXT_RA_DONE))
|
if (!(context->flags & CONTEXT_RA_DONE))
|
||||||
{
|
{
|
||||||
|
if (!param->first)
|
||||||
|
context->ra_time = 0;
|
||||||
context->flags |= CONTEXT_RA_DONE;
|
context->flags |= CONTEXT_RA_DONE;
|
||||||
do_prefix = 1;
|
do_prefix = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
param->first = 0;
|
||||||
|
param->found_context = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_prefix)
|
if (do_prefix)
|
||||||
@@ -416,8 +412,8 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
opt->type = ICMP6_OPT_PREFIX;
|
opt->type = ICMP6_OPT_PREFIX;
|
||||||
opt->len = 4;
|
opt->len = 4;
|
||||||
opt->prefix_len = prefix;
|
opt->prefix_len = prefix;
|
||||||
/* autonomous only if we're not doing dhcp */
|
/* autonomous only if we're not doing dhcp, always set "on-link" */
|
||||||
opt->flags = do_slaac ? 0x40 : 0x00;
|
opt->flags = do_slaac ? 0xC0 : 0x80;
|
||||||
opt->valid_lifetime = htonl(time);
|
opt->valid_lifetime = htonl(time);
|
||||||
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
|
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
|
||||||
opt->reserved = 0;
|
opt->reserved = 0;
|
||||||
|
|||||||
+18
-1
@@ -1250,7 +1250,8 @@ static int add_resource_record(struct dns_header *header, char *limit, int *trun
|
|||||||
case 't':
|
case 't':
|
||||||
usval = va_arg(ap, int);
|
usval = va_arg(ap, int);
|
||||||
sval = va_arg(ap, char *);
|
sval = va_arg(ap, char *);
|
||||||
memcpy(p, sval, usval);
|
if (usval != 0)
|
||||||
|
memcpy(p, sval, usval);
|
||||||
p += usval;
|
p += usval;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1393,6 +1394,22 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
|
|
||||||
if (qclass == C_IN)
|
if (qclass == C_IN)
|
||||||
{
|
{
|
||||||
|
struct txt_record *t;
|
||||||
|
|
||||||
|
for (t = daemon->rr; t; t = t->next)
|
||||||
|
if ((t->class == qtype || qtype == T_ANY) && hostname_isequal(name, t->name))
|
||||||
|
{
|
||||||
|
ans = 1;
|
||||||
|
if (!dryrun)
|
||||||
|
{
|
||||||
|
log_query(F_CONFIG | F_RRNAME, name, NULL, "<RR>");
|
||||||
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
|
daemon->local_ttl, NULL,
|
||||||
|
t->class, C_IN, "t", t->len, t->txt))
|
||||||
|
anscount ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (qtype == T_PTR || qtype == T_ANY)
|
if (qtype == T_PTR || qtype == T_ANY)
|
||||||
{
|
{
|
||||||
/* see if it's w.z.y.z.in-addr.arpa format */
|
/* see if it's w.z.y.z.in-addr.arpa format */
|
||||||
|
|||||||
+19
-35
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#ifdef HAVE_TFTP
|
#ifdef HAVE_TFTP
|
||||||
|
|
||||||
static struct tftp_file *check_tftp_fileperm(ssize_t *len, char *prefix, int special);
|
static struct tftp_file *check_tftp_fileperm(ssize_t *len, char *prefix);
|
||||||
static void free_transfer(struct tftp_transfer *transfer);
|
static void free_transfer(struct tftp_transfer *transfer);
|
||||||
static ssize_t tftp_err(int err, char *packet, char *mess, char *file);
|
static ssize_t tftp_err(int err, char *packet, char *mess, char *file);
|
||||||
static ssize_t tftp_err_oops(char *packet, char *file);
|
static ssize_t tftp_err_oops(char *packet, char *file);
|
||||||
@@ -48,7 +48,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int is_err = 1, if_index = 0, mtu = 0, special = 0;
|
int is_err = 1, if_index = 0, mtu = 0;
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
#endif
|
#endif
|
||||||
@@ -61,7 +61,6 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
char *prefix = daemon->tftp_prefix;
|
char *prefix = daemon->tftp_prefix;
|
||||||
struct tftp_prefix *pref;
|
struct tftp_prefix *pref;
|
||||||
struct interface_list *ir;
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct cmsghdr align; /* this ensures alignment */
|
struct cmsghdr align; /* this ensures alignment */
|
||||||
@@ -114,8 +113,6 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct cmsghdr *cmptr;
|
struct cmsghdr *cmptr;
|
||||||
int check;
|
|
||||||
struct interface_list *ir;
|
|
||||||
|
|
||||||
if (msg.msg_controllen < sizeof(struct cmsghdr))
|
if (msg.msg_controllen < sizeof(struct cmsghdr))
|
||||||
return;
|
return;
|
||||||
@@ -195,29 +192,22 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (listen->family == AF_INET6)
|
if (listen->family == AF_INET6)
|
||||||
check = iface_check(AF_INET6, (struct all_addr *)&addr.in6.sin6_addr, name);
|
{
|
||||||
|
if (!iface_check(AF_INET6, (struct all_addr *)&addr.in6.sin6_addr, name))
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
check = iface_check(AF_INET, (struct all_addr *)&addr.in.sin_addr, name);
|
if (!iface_check(AF_INET, (struct all_addr *)&addr.in.sin_addr, name))
|
||||||
|
return;
|
||||||
|
|
||||||
/* wierd TFTP service override */
|
|
||||||
for (ir = daemon->tftp_interfaces; ir; ir = ir->next)
|
|
||||||
if (strcmp(ir->interface, name) == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!ir)
|
|
||||||
{
|
|
||||||
if (!daemon->tftp_unlimited || !check)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
/* allowed interfaces are the same as for DHCP */
|
/* allowed interfaces are the same as for DHCP */
|
||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
||||||
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
|
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
|
||||||
mtu = ifr.ifr_mtu;
|
mtu = ifr.ifr_mtu;
|
||||||
@@ -228,12 +218,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
/* check for per-interface prefix */
|
/* check for per-interface prefix */
|
||||||
for (pref = daemon->if_prefix; pref; pref = pref->next)
|
for (pref = daemon->if_prefix; pref; pref = pref->next)
|
||||||
if (strcmp(pref->interface, name) == 0)
|
if (strcmp(pref->interface, name) == 0)
|
||||||
prefix = pref->prefix;
|
prefix = pref->prefix;
|
||||||
|
|
||||||
/* wierd TFTP interfaces disable special options. */
|
|
||||||
for (ir = daemon->tftp_interfaces; ir; ir = ir->next)
|
|
||||||
if (strcmp(ir->interface, name) == 0)
|
|
||||||
special = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listen->family == AF_INET)
|
if (listen->family == AF_INET)
|
||||||
@@ -325,8 +310,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
{
|
{
|
||||||
if (strcasecmp(opt, "blksize") == 0)
|
if (strcasecmp(opt, "blksize") == 0)
|
||||||
{
|
{
|
||||||
if ((opt = next(&p, end)) &&
|
if ((opt = next(&p, end)) && !option_bool(OPT_TFTP_NOBLOCK))
|
||||||
(special || !option_bool(OPT_TFTP_NOBLOCK)))
|
|
||||||
{
|
{
|
||||||
transfer->blocksize = atoi(opt);
|
transfer->blocksize = atoi(opt);
|
||||||
if (transfer->blocksize < 1)
|
if (transfer->blocksize < 1)
|
||||||
@@ -363,7 +347,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
if (prefix[strlen(prefix)-1] != '/')
|
if (prefix[strlen(prefix)-1] != '/')
|
||||||
strncat(daemon->namebuff, "/", (MAXDNAME-1) - strlen(daemon->namebuff));
|
strncat(daemon->namebuff, "/", (MAXDNAME-1) - strlen(daemon->namebuff));
|
||||||
|
|
||||||
if (!special && option_bool(OPT_TFTP_APREF))
|
if (option_bool(OPT_TFTP_APREF))
|
||||||
{
|
{
|
||||||
size_t oldlen = strlen(daemon->namebuff);
|
size_t oldlen = strlen(daemon->namebuff);
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
@@ -390,7 +374,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
strncat(daemon->namebuff, filename, (MAXDNAME-1) - strlen(daemon->namebuff));
|
strncat(daemon->namebuff, filename, (MAXDNAME-1) - strlen(daemon->namebuff));
|
||||||
|
|
||||||
/* check permissions and open file */
|
/* check permissions and open file */
|
||||||
if ((transfer->file = check_tftp_fileperm(&len, prefix, special)))
|
if ((transfer->file = check_tftp_fileperm(&len, prefix)))
|
||||||
{
|
{
|
||||||
if ((len = get_block(packet, transfer)) == -1)
|
if ((len = get_block(packet, transfer)) == -1)
|
||||||
len = tftp_err_oops(packet, daemon->namebuff);
|
len = tftp_err_oops(packet, daemon->namebuff);
|
||||||
@@ -411,7 +395,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct tftp_file *check_tftp_fileperm(ssize_t *len, char *prefix, int special)
|
static struct tftp_file *check_tftp_fileperm(ssize_t *len, char *prefix)
|
||||||
{
|
{
|
||||||
char *packet = daemon->packet, *namebuff = daemon->namebuff;
|
char *packet = daemon->packet, *namebuff = daemon->namebuff;
|
||||||
struct tftp_file *file;
|
struct tftp_file *file;
|
||||||
@@ -448,7 +432,7 @@ static struct tftp_file *check_tftp_fileperm(ssize_t *len, char *prefix, int spe
|
|||||||
goto perm;
|
goto perm;
|
||||||
}
|
}
|
||||||
/* in secure mode, must be owned by user running dnsmasq */
|
/* in secure mode, must be owned by user running dnsmasq */
|
||||||
else if (!special && option_bool(OPT_TFTP_SECURE) && uid != statbuf.st_uid)
|
else if (option_bool(OPT_TFTP_SECURE) && uid != statbuf.st_uid)
|
||||||
goto perm;
|
goto perm;
|
||||||
|
|
||||||
/* If we're doing many tranfers from the same file, only
|
/* If we're doing many tranfers from the same file, only
|
||||||
|
|||||||
+22
-5
@@ -426,7 +426,7 @@ int parse_hex(char *in, unsigned char *out, int maxlen,
|
|||||||
|
|
||||||
while (maxlen == -1 || i < maxlen)
|
while (maxlen == -1 || i < maxlen)
|
||||||
{
|
{
|
||||||
for (r = in; *r != 0 && *r != ':' && *r != '-'; r++)
|
for (r = in; *r != 0 && *r != ':' && *r != '-' && *r != ' '; r++)
|
||||||
if (*r != '*' && !isxdigit((unsigned char)*r))
|
if (*r != '*' && !isxdigit((unsigned char)*r))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -444,12 +444,29 @@ int parse_hex(char *in, unsigned char *out, int maxlen,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
*r = 0;
|
*r = 0;
|
||||||
mask = mask << 1;
|
|
||||||
if (strcmp(in, "*") == 0)
|
if (strcmp(in, "*") == 0)
|
||||||
mask |= 1;
|
{
|
||||||
|
mask = (mask << 1) | 1;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
out[i] = strtol(in, NULL, 16);
|
{
|
||||||
i++;
|
int j, bytes = (1 + (r - in))/2;
|
||||||
|
for (j = 0; j < bytes; j++)
|
||||||
|
{
|
||||||
|
char sav;
|
||||||
|
if (j < bytes - 1)
|
||||||
|
{
|
||||||
|
sav = in[(j+1)*2];
|
||||||
|
in[(j+1)*2] = 0;
|
||||||
|
}
|
||||||
|
out[i] = strtol(&in[j*2], NULL, 16);
|
||||||
|
mask = mask << 1;
|
||||||
|
i++;
|
||||||
|
if (j < bytes - 1)
|
||||||
|
in[(j+1)*2] = sav;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in = r+1;
|
in = r+1;
|
||||||
|
|||||||
Reference in new issue
Block a user