Compare commits

...
4 Commits
Author SHA1 Message Date
Simon Kelley 316e2730ac import of dnsmasq-2.52.tar.gz 2012-01-05 17:31:15 +00:00
Simon Kelley 1f15b81d61 import of dnsmasq-2.51.tar.gz 2012-01-05 17:31:14 +00:00
Simon Kelley 77e94da7bb import of dnsmasq-2.50.tar.gz 2012-01-05 17:31:14 +00:00
Simon Kelley 03a97b6170 import of dnsmasq-2.49.tar.gz 2012-01-05 17:31:14 +00:00
46 changed files with 4101 additions and 2805 deletions

No files matched your search

+209
View File
@@ -1,3 +1,207 @@
version 2.52
Work around a Linux kernel bug which insists that the
length of the option passed to setsockopt must be at least
sizeof(int) bytes, even if we're calling SO_BINDTODEVICE
and the device name is "lo". Note that this is fixed
in kernel 2.6.31, but the workaround is harmless and
allows earlier kernels to be used. Also fix dnsmasq
bug which reported the wrong address when this failed.
Thanks to Fedor for finding this.
The API for IPv6 PKTINFO changed around Linux kernel
2.6.14. Workaround the case where dnsmasq is compiled
against newer headers, but then run on an old kernel:
necessary for some *WRT distros.
Re-read the set of network interfaces when re-loading
/etc/resolv.conf if --bind-interfaces is not set. This
handles the case that loopback interfaces do not exist
when dnsmasq is first started.
Tweak the PXE code to support port 4011. This should
reduce broadcasts and make things more reliable when other
servers are around. It also improves inter-operability
with certain clients.
Make a pxe-service configuration with no filename or boot
service type legal: this does a local boot. eg.
pxe-service=x86PC, "Local boot"
Be more conservative in detecting "A for A"
queries. Dnsmasq checks if the name in a type=A query looks
like a dotted-quad IP address and answers the query itself
if so, rather than forwarding it. Previously dnsmasq
relied in the library function inet_addr() to convert
addresses, and that will accept some things which are
confusing in this context, like 1.2.3 or even just
1234. Now we only do A for A processing for four decimal
numbers delimited by dots.
A couple of tweaks to fix compilation on Solaris. Thanks
to Joel Macklow for help with this.
Another Solaris compilation tweak, needed for Solaris
2009.06. Thanks to Lee Essen for that.
Added extract packaging stuff from Lee Essen to
contrib/Solaris10.
Increased the default limit on number of leases to 1000
(from 150). This is mainly a defence against DoS attacks,
and for the average "one for two class C networks"
installation, IP address exhaustion does that just as
well. Making the limit greater than the number of IP
addresses available in such an installation removes a
surprise which otherwise can catch people out.
Removed extraneous trailing space in the value of the
DNSMASQ_TIME_REMAINING DNSMASQ_LEASE_LENGTH and
DNSMASQ_LEASE_EXPIRES environment variables. Thanks to
Gildas Le Nadan for spotting this.
Provide the network-id tags for a DHCP transaction to
the lease-change script in the environment variable
DNSMASQ_TAGS. A good suggestion from Gildas Le Nadan.
Add support for RFC3925 "Vendor-Identifying Vendor
Options". The syntax looks like this:
--dhcp-option=vi-encap:<enterprise number>, .........
Add support to --dhcp-match to allow matching against
RFC3925 "Vendor-Identifying Vendor Classes". The syntax
looks like this:
--dhcp-match=tag,vi-encap<enterprise number>, <value>
Add some application specific code to assist in
implementing the Broadband forum TR069 CPE-WAN
specification. The details are in contrib/CPE-WAN/README
Increase the default DNS packet size limit to 4096, as
recommended by RFC5625 section 4.4.3. This can be
reconfigured using --edns-packet-max if needed. Thanks to
Francis Dupont for pointing this out.
Rewrite query-ids even for DNSSEC signed packets, since
this is allowed by RFC5625 section 4.5.
Use getopt_long by default on OS X. It has been supported
since version 10.3.0. Thanks to Arek Dreyer for spotting
this.
Added up-to-date startup configuration for MacOSX/launchd
in contrib/MacOSX-launchd. Thanks to Arek Dreyer for
providing this.
Fix link error when including Dbus but excluding DHCP.
Thanks to Oschtan for the bug report.
Updated French translation. Thanks to Gildas Le Nadan.
Updated Polish translation. Thanks to Jan Psota.
Updated Spanish translation. Thanks to Chris Chatham.
version 2.51
Add support for internationalised DNS. Non-ASCII characters
in domain names found in /etc/hosts, /etc/ethers and
/etc/dnsmasq.conf will be correctly handled by translation to
punycode, as specified in RFC3490. This function is only
available if dnsmasq is compiled with internationalisation
support, and adds a dependency on GNU libidn. Without i18n
support, dnsmasq continues to be compilable with just
standard tools. Thanks to Yves Dorfsman for the
suggestion.
Add two more environment variables for lease-change scripts:
First, DNSMASQ_SUPPLIED_HOSTNAME; this is set to the hostname
supplied by a client, even if the actual hostname used is
over-ridden by dhcp-host or dhcp-ignore-names directives.
Also DNSMASQ_RELAY_ADDRESS which gives the address of
a DHCP relay, if used.
Suggestions from Michael Rack.
Fix regression which broke echo of relay-agent
options. Thanks to Michael Rack for spotting this.
Don't treat option 67 as being interchangeable with
dhcp-boot parameters if it's specified as
dhcp-option-force.
Make the code to call scripts on lease-change compile-time
optional. It can be switched off by editing src/config.h
or building with "make COPTS=-DNO_SCRIPT".
Make the TFTP server cope with filenames from Windows/DOS
which use '\' as pathname separator. Thanks to Ralf for
the patch.
Updated Polish translation. Thanks to Jan Psota.
Warn if an IP address is duplicated in /etc/ethers. Thanks
to Felix Schwarz for pointing this out.
Teach --conf-dir to take an option list of file suffices
which will be ignored when scanning the directory. Useful
for backup files etc. Thanks to Helmut Hullen for the
suggestion.
Add new DHCP option named tftpserver-address, which
corresponds to the third argument of dhcp-boot. This
allows the complete functionality of dhcp-boot to be
replicated with dhcp-option. Useful when using
dhcp-optsfile.
Test which upstream nameserver to use every 10 seconds
or 50 queries and not just when a query times out and
is retried. This should improve performance when there
is a slow nameserver in the list. Thanks to Joe for the
suggestion.
Don't do any PXE processing, even for clients with the
correct vendorclass, unless at least one pxe-prompt or
pxe-service option is given. This stops dnsmasq
interfering with proxy PXE subsystems when it is just
the DHCP server. Thanks to Spencer Clark for spotting this.
Limit the blocksize used for TFTP transfers to a value
which avoids packet fragmentation, based on the MTU of the
local interface. Many netboot ROMs can't cope with
fragmented packets.
Honour dhcp-ignore configuration for PXE and proxy-PXE
requests. Thanks to Niels Basjes for the bug report.
Updated French translation. Thanks to Gildas Le Nadan.
version 2.50
Fix security problem which allowed any host permitted to
do TFTP to possibly compromise dnsmasq by remote buffer
overflow when TFTP enabled. Thanks to Core Security
Technologies and Iván Arce, Pablo Hernán Jorge, Alejandro
Pablo Rodriguez, Martín Coco, Alberto Soliño Testa and
Pablo Annetta. This problem has Bugtraq id: 36121
and CVE: 2009-2957
Fix a problem which allowed a malicious TFTP client to
crash dnsmasq. Thanks to Steve Grubb at Red Hat for
spotting this. This problem has Bugtraq id: 36120 and
CVE: 2009-2958
version 2.49
Fix regression in 2.48 which disables the lease-change
script. Thanks to Jose Luis Duran for spotting this.
Log TFTP "file not found" errors. These were not logged,
since a normal PXELinux boot generates many of them, but
the lack of the messages seems to be more confusing than
routinely seeing them when there is no real error.
Update Spanish translation. Thanks to Chris Chatham.
version 2.48 version 2.48
Archived the extensive, backwards, changelog to Archived the extensive, backwards, changelog to
CHANGELOG.archive. The current changelog now runs from CHANGELOG.archive. The current changelog now runs from
@@ -331,3 +535,8 @@ version 2.43
ports. Thanks to Patrick McLean for spotting this. ports. Thanks to Patrick McLean for spotting this.
Updated French translation. Thanks to Gildas Le Nadan. Updated French translation. Thanks to Gildas Le Nadan.
version 2.42
The changelog for version 2.42 and earlier is
available in CHANGELOG.archive.
+50 -26
View File
@@ -1,4 +1,4 @@
# dnsmasq is Copyright (c) 2000-2009 Simon Kelley # dnsmasq is Copyright (c) 2000-2010 Simon Kelley
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -18,25 +18,33 @@ BINDIR = ${PREFIX}/sbin
MANDIR = ${PREFIX}/share/man MANDIR = ${PREFIX}/share/man
LOCALEDIR = ${PREFIX}/share/locale LOCALEDIR = ${PREFIX}/share/locale
PKG_CONFIG = pkg-config
INSTALL = install
MSGMERGE = msgmerge
MSGFMT = msgfmt
XGETTEXT = xgettext
CFLAGS = -Wall -W -O2
#################################################################
SRC = src SRC = src
PO = po PO = po
MAN = man MAN = man
PKG_CONFIG = pkg-config DNSMASQ_CFLAGS=`echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --cflags dbus-1`
INSTALL = install DNSMASQ_LIBS= `echo $(COPTS) | ../bld/pkg-wrapper HAVE_DBUS $(PKG_CONFIG) --libs dbus-1`
SUNOS_LIBS= `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi`
DBUS_CFLAGS="`echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --cflags dbus-1`" OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \
DBUS_LIBS=" `echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --libs dbus-1`" dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
SUNOS_LIBS=" `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi `" helper.o tftp.o log.o
all : dnsmasq all :
@cd $(SRC) && $(MAKE) \
dnsmasq : BUILD_CFLAGS="$(DNSMASQ_CFLAGS)" \
cd $(SRC) && $(MAKE) \ BUILD_LIBS="$(DNSMASQ_LIBS) $(SUNOS_LIBS)" \
DBUS_CFLAGS=$(DBUS_CFLAGS) \ -f ../Makefile dnsmasq
DBUS_LIBS=$(DBUS_LIBS) \
SUNOS_LIBS=$(SUNOS_LIBS) \
-f ../bld/Makefile dnsmasq
clean : clean :
rm -f *~ $(SRC)/*.mo contrib/*/*~ */*~ $(SRC)/*.pot rm -f *~ $(SRC)/*.mo contrib/*/*~ */*~ $(SRC)/*.pot
@@ -50,24 +58,40 @@ install-common :
$(INSTALL) -m 755 $(SRC)/dnsmasq $(DESTDIR)$(BINDIR) $(INSTALL) -m 755 $(SRC)/dnsmasq $(DESTDIR)$(BINDIR)
all-i18n : all-i18n :
cd $(SRC) && $(MAKE) \ @cd $(SRC) && $(MAKE) \
I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' \ I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' \
DBUS_CFLAGS=$(DBUS_CFLAGS) \ BUILD_CFLAGS="$(DNSMASQ_CFLAGS) `$(PKG_CONFIG) --cflags libidn`" \
DBUS_LIBS=$(DBUS_LIBS) \ BUILD_LIBS="$(DNSMASQ_LIBS) $(SUNOS_LIBS) `$(PKG_CONFIG) --libs libidn`" \
SUNOS_LIBS=$(SUNOS_LIBS) \ -f ../Makefile dnsmasq
-f ../bld/Makefile dnsmasq @cd $(PO); for f in *.po; do \
cd $(PO); for f in *.po; do \ cd ../$(SRC) && $(MAKE) \
cd ../$(SRC) && $(MAKE) -f ../bld/Makefile $${f%.po}.mo; \ -f ../Makefile $${f%.po}.mo; \
done done
install-i18n : all-i18n install-common install-i18n : all-i18n install-common
cd $(SRC); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) cd $(SRC); ../bld/install-mo $(DESTDIR)$(LOCALEDIR) $(INSTALL)
cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR) $(INSTALL)
merge : merge :
$(MAKE) I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' -f ../bld/Makefile -C $(SRC) dnsmasq.pot @cd $(SRC) && $(MAKE) -f ../Makefile dnsmasq.pot
cd $(PO); for f in *.po; do \ @cd $(PO); for f in *.po; do \
msgmerge --no-wrap -U $$f ../$(SRC)/dnsmasq.pot; \ echo -n msgmerge $$f && $(MSGMERGE) --no-wrap -U $$f ../$(SRC)/dnsmasq.pot; \
done done
# rules below are targets in recusive makes with cwd=$(SRC)
.c.o:
$(CC) $(CFLAGS) $(COPTS) $(I18N) $(BUILD_CFLAGS) $(RPM_OPT_FLAGS) -c $<
dnsmasq : $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(BUILD_LIBS) $(LIBS)
dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h
$(XGETTEXT) -d dnsmasq --foreign-user --omit-header --keyword=_ -o $@ -i $(OBJS:.o=.c)
%.mo : ../po/%.po dnsmasq.pot
$(MSGMERGE) -o - ../po/$*.po dnsmasq.pot | $(MSGFMT) -o $*.mo -
.PHONY : all clean install install-common all-i18n install-i18n merge
-17
View File
@@ -1,17 +0,0 @@
CFLAGS = -Wall -W -O2
OBJS = cache.o rfc1035.o util.o option.o forward.o network.o \
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
helper.o tftp.o log.o
.c.o:
$(CC) $(CFLAGS) $(COPTS) $(DBUS_MINOR) $(I18N) $(DBUS_CFLAGS) $(SUNOS_VER) $(RPM_OPT_FLAGS) -c $<
dnsmasq : $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(DBUS_LIBS) $(SUNOS_LIBS) $(LIBS)
dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h
xgettext -d dnsmasq --foreign-user --keyword=_ -o dnsmasq.pot -i $(OBJS:.o=.c)
%.mo : ../po/%.po dnsmasq.pot
msgmerge -o - ../po/$*.po dnsmasq.pot | msgfmt -o $*.mo -
+2 -2
View File
@@ -2,8 +2,8 @@
for f in *; do for f in *; do
if [ -d $f ]; then if [ -d $f ]; then
install -m 755 -d $1/$f/man8 $2 -m 755 -d $1/$f/man8
install -m 644 $f/dnsmasq.8 $1/$f/man8 $2 -m 644 $f/dnsmasq.8 $1/$f/man8
echo installing $1/$f/man8/dnsmasq.8 echo installing $1/$f/man8/dnsmasq.8
fi fi
done done
+2 -2
View File
@@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
for f in *.mo; do for f in *.mo; do
install -m 755 -d $1/${f%.mo}/LC_MESSAGES $2 -m 755 -d $1/${f%.mo}/LC_MESSAGES
install -m 644 $f $1/${f%.mo}/LC_MESSAGES/dnsmasq.mo $2 -m 644 $f $1/${f%.mo}/LC_MESSAGES/dnsmasq.mo
echo installing $1/${f%.mo}/LC_MESSAGES/dnsmasq.mo echo installing $1/${f%.mo}/LC_MESSAGES/dnsmasq.mo
done done
+5 -2
View File
@@ -1,7 +1,10 @@
#!/bin/sh #!/bin/sh
if grep "^\#.*define.*HAVE_DBUS" config.h 2>&1 >/dev/null || \ search=$1
grep HAVE_DBUS 2>&1 >/dev/null ; then shift
if grep "^\#.*define.*$search" config.h 2>&1 >/dev/null || \
grep $search 2>&1 >/dev/null ; then
exec $* exec $*
fi fi
+36
View File
@@ -0,0 +1,36 @@
Dnsmasq from version 2.52 has a couple of rather application-specific
features designed to allow for implementation of the DHCP part of CPE
WAN management protocol.
http://www.broadband-forum.org/technical/download/TR-069_Amendment-2.pdf
http://en.wikipedia.org/wiki/TR-069
The relevant sections are F.2.1 "Gateway Requirements" and F.2.5 "DHCP
Vendor Options".
First, dnsmasq checks for DHCP requests which contain an option-125
vendor-class option which in turn holds a vendor section for IANA
enterprise number 3561 which contains sub-options codes 1 and 2. If
this is present then the network-tag "cpewan-id" is set.
This allows dnsmasq to be configured to reply with the correct
GatewayManufacturerOUI, GatewaySerialNumber and GatewayProductClass like this:
dhcp-option=cpewan-id,vi-encap:3561,4,"<GatewayManufacturerOUI>"
dhcp-option=cpewan-id,vi-encap:3561,5,"<SerialNumber>"
dhcp-option=cpewan-id,vi-encap:3561,6,"<ProductClass>"
Second, the received sub-options 1, 2, and 3 are passed to the DHCP
lease-change script as the environment variables DNSMASQ_CPEWAN_OUI,
DNSMASQ_CPEWAN_SERIAL, and DNSMASQ_CPEWAN_CLASS respectively. This allows
the script to be used to maintain a ManageableDevice table as
specified in F.2.1. Note that this data is not retained in dnsmasq's
internal DHCP lease database, so it is not available on every call to
the script (this is the same as some other data such as vendor and
user classes). It will however be available for at least the "add"
call, and should be stored then against the IP address as primary
key for future use.
This feature was added to dnsmasq under sponsorship from Ericsson.
+38
View File
@@ -0,0 +1,38 @@
This is a launchd item for Mac OS X and Mac OS X Server.
For more information about launchd, the
"System wide and per-user daemon/agent manager", see the launchd
man page, or the wikipedia page: http://en.wikipedia.org/wiki/Launchd
This launchd item uses the following flags:
--keep-in-foreground - this is crucial for use with launchd
--log-queries - this is optional and you can remove it
--log-facility=/var/log/dnsmasq.log - again optional instead of system.log
To use this launchd item for dnsmasq:
If you don't already have a folder /Library/LaunchDaemons, then create one:
sudo mkdir /Library/LaunchDaemons
sudo chown root:admin /Library/LaunchDaemons
sudo chmod 775 /Library/LaunchDaemons
Copy uk.org.thekelleys.dnsmasq.plist there and then set ownership/permissions:
sudo cp uk.org.thekelleys.dnsmasq.plist /Library/LaunchDaemons/
sudo chown root:admin /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
sudo chmod 644 /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
Optionally, edit your dnsmasq configuration file to your liking.
To start the launchd job, which starts dnsmaq, reboot or use the command:
sudo launchctl load /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
To stop the launchd job, which stops dnsmasq, use the command:
sudo launchctl unload /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
If you want to permanently stop the launchd job, so it doesn't start the job even after a reboot, use the following command:
sudo launchctl unload -w /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
If you make a change to the configuration file, you should relaunch dnsmasq;
to do this unload and then load again:
sudo launchctl unload /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
sudo launchctl load /Library/LaunchDaemons/uk.org.thekelleys.dnsmasq.plist
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>uk.org.thekelleys.dnsmasq</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/sbin/dnsmasq</string>
<string>--keep-in-foreground</string>
<string>--log-queries</string>
<string>--log-facility=/var/log/dnsmasq.log</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
+25
View File
@@ -0,0 +1,25 @@
Ok, script attached ... seems to be working ok for me,
tried to install and remove a few times. It does the
right thing with the smf when installing, you can then
simply enable the service. Upon removal it cleans up the
files but won't clean up the services (I think until
a reboot) ... I've only started looking at the new
packages stuff in the last day or two, so I could be
missing something, but I can't find any way to force
a proper cleanup.
It requires that you have a writable repository setup
as per the docs on the opensolaris website and it will
create a dnsmasq package (package name is a variable
in the script). The script takes a version number for
the package and assumes that it's in the contrib/Solaris10
directory, it then works out the base tree directory
from $0.
i.e. $ contrib/Solaris10/create_package 2.52-1
or $ cd contrib/Solaris10; ./create_package 2.52-1
It's a bit more complex than it could be because I
prefer putting the daemon in /usr/sbin and the config
in /etc, so the script will actually create a new
version of the existing contrib dnsmasq.xml.
+87
View File
@@ -0,0 +1,87 @@
#!/bin/sh
#
# For our package, and for the SMF script, we need to define where we
# want things to go...
#
BIN_DIR="/usr/sbin"
CONF_DIR="/etc"
MAN_DIR="/usr/man/man8"
PACKAGE_NAME="dnsmasq"
#
# Since we know we are in the contrib directory we can work out where
# the rest of the tree is...
#
BASEDIR="`dirname $0`/../.."
#
# We need a version number to use for the package creation...
#
if [ $# != 1 ]; then
echo "Usage: $0 <package_version_number>" >&2
exit 1
fi
VERSION="$1"
#
# First thing we do is fix-up the smf file to use the paths we prefer...
#
if [ ! -f "${BASEDIR}/contrib/Solaris10/dnsmasq.xml" ]; then
echo "$0: unable to find contrib/Solaris10/dnsmasq.xml" >&2
exit 1
fi
echo "Fixing up smf file ... \c"
cat "${BASEDIR}/contrib/Solaris10/dnsmasq.xml" | \
sed -e "s%/usr/local/etc%${CONF_DIR}%" \
-e "s%/usr/local/sbin%${BIN_DIR}%" \
-e "s%/usr/local/man%${MAN_DIR}%" > ${BASEDIR}/contrib/Solaris10/dnsmasq-pkg.xml
echo "done."
echo "Creating packaging file ... \c"
cat <<EOF >${BASEDIR}/contrib/Solaris10/dnsmasq_package.inc
#
# header
#
set name=pkg.name value="dnsmasq"
set name=pkg.description value="dnsmasq daemon - dns, dhcp, tftp etc"
set name=pkg.detailed_url value="http://www.thekelleys.org.uk/dnsmasq/doc.html"
set name=info.maintainer value="TBD (tbd@tbd.com)"
set name=info.upstream value="dnsmasq-discuss@lists.thekelleys.org.uk"
set name=info.upstream_url value="http://www.thekelleys.org.uk/dnsmasq/doc.html"
#
# dependencies ... none?
#
#
# directories
#
dir mode=0755 owner=root group=bin path=${BIN_DIR}/
dir mode=0755 owner=root group=sys path=${CONF_DIR}/
dir mode=0755 owner=root group=sys path=${MAN_DIR}/
dir mode=0755 owner=root group=sys path=/var/
dir mode=0755 owner=root group=sys path=/var/svc
dir mode=0755 owner=root group=sys path=/var/svc/manifest
dir mode=0755 owner=root group=sys path=/var/svc/manifest/network
#
# files
#
file ${BASEDIR}/src/dnsmasq mode=0555 owner=root group=bin path=${BIN_DIR}/dnsmasq
file ${BASEDIR}/man/dnsmasq.8 mode=0555 owner=root group=bin path=${MAN_DIR}/dnsmasq.8
file ${BASEDIR}/dnsmasq.conf.example mode=0644 owner=root group=sys path=${CONF_DIR}/dnsmasq.conf preserve=strawberry
file ${BASEDIR}/contrib/Solaris10/dnsmasq-pkg.xml mode=0644 owner=root group=sys path=/var/svc/manifest/network/dnsmasq.xml restart_fmri=svc:/system/manifest-import:default
EOF
echo "done."
echo "Creating package..."
eval `pkgsend open ${PACKAGE_NAME}@${VERSION}`
pkgsend include ${BASEDIR}/contrib/Solaris10/dnsmasq_package.inc
if [ "$?" = 0 ]; then
pkgsend close
else
echo "Errors"
fi
File renamed without changes.
File renamed without changes.
+6 -1
View File
@@ -365,7 +365,7 @@
#pxe-prompt="Press F8 for menu.", 60 #pxe-prompt="Press F8 for menu.", 60
# Available boot services. for PXE. # Available boot services. for PXE.
#pxe-service=x86PC, "Boot from local disk", 0 #pxe-service=x86PC, "Boot from local disk"
# Loads <tftp-root>/pxelinux.0 from dnsmasq TFTP server. # Loads <tftp-root>/pxelinux.0 from dnsmasq TFTP server.
#pxe-service=x86PC, "Install Linux", pxelinux #pxe-service=x86PC, "Install Linux", pxelinux
@@ -396,6 +396,11 @@
# the user dnsmasq is running as will be send over the net. # the user dnsmasq is running as will be send over the net.
#tftp-secure #tftp-secure
# This option stops dnsmasq from negotiating a larger blocksize for TFTP
# transfers. It will slow things down, but may rescue some broken TFTP
# clients.
#tftp-no-blocksize
# Set the boot file name only when the "red" tag is set. # Set the boot file name only when the "red" tag is set.
#dhcp-boot=net:red,pxelinux.red-net #dhcp-boot=net:red,pxelinux.red-net
+56 -17
View File
@@ -45,7 +45,8 @@ additional hosts file. If a directory is given, then read all the files containe
.TP .TP
.B \-E, --expand-hosts .B \-E, --expand-hosts
Add the domain to simple names (without a period) in /etc/hosts Add the domain to simple names (without a period) in /etc/hosts
in the same way as for DHCP-derived names. in the same way as for DHCP-derived names. Note that this does not
apply to domain names in cnames, PTR records, TXT records etc.
.TP .TP
.B \-T, --local-ttl=<time> .B \-T, --local-ttl=<time>
When replying with information from /etc/hosts or the DHCP leases When replying with information from /etc/hosts or the DHCP leases
@@ -122,8 +123,7 @@ to zero completely disables DNS function, leaving only DHCP and/or TFTP.
.TP .TP
.B \-P, --edns-packet-max=<size> .B \-P, --edns-packet-max=<size>
Specify the largest EDNS.0 UDP packet which is supported by the DNS Specify the largest EDNS.0 UDP packet which is supported by the DNS
forwarder. Defaults to 1280, which is the RFC2671-recommended maximum forwarder. Defaults to 4096, which is the RFC5625-recommended size.
for ethernet.
.TP .TP
.B \-Q, --query-port=<query_port> .B \-Q, --query-port=<query_port>
Send outbound DNS queries from, and listen for their replies on, the Send outbound DNS queries from, and listen for their replies on, the
@@ -426,7 +426,7 @@ Set the maximum number of concurrent DNS queries. The default value is
where this needs to be increased is when using web-server log file where this needs to be increased is when using web-server log file
resolvers, which can generate large numbers of concurrent queries. resolvers, which can generate large numbers of concurrent queries.
.TP .TP
.B \-F, --dhcp-range=[[net:]network-id,]<start-addr>,<end-addr>[[,<netmask>],<broadcast>][,<lease time>] .B \-F, --dhcp-range=[[net:]network-id,]<start-addr>,<end-addr>[,<netmask>[,<broadcast>]][,<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
in in
@@ -547,7 +547,12 @@ the file will be re-read when dnsmasq receives SIGHUP.
.B --dhcp-optsfile=<file> .B --dhcp-optsfile=<file>
Read DHCP option information from the specified file. The advantage of Read DHCP option information from the specified file. The advantage of
using this option is the same as for --dhcp-hostsfile: the using this option is the same as for --dhcp-hostsfile: the
dhcp-optsfile will be re-read when dnsmasq receives SIGHUP. dhcp-optsfile will be re-read when dnsmasq receives SIGHUP. Note that
it is possible to encode the information in a
.B --dhcp-boot
flag as DHCP options, using the options names bootfile-name,
server-ip-address and tftp-server. This allows these to be included
in a dhcp-optsfile.
.TP .TP
.B \-Z, --read-ethers .B \-Z, --read-ethers
Read /etc/ethers for information about hosts for the DHCP server. The Read /etc/ethers for information about hosts for the DHCP server. The
@@ -558,7 +563,7 @@ have exactly the same effect as
options containing the same information. /etc/ethers is re-read when options containing the same information. /etc/ethers is re-read when
dnsmasq receives SIGHUP. dnsmasq receives SIGHUP.
.TP .TP
.B \-O, --dhcp-option=[<network-id>,[<network-id>,]][encap:<opt>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]] .B \-O, --dhcp-option=[<network-id>,[<network-id>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
Specify different or extra options to DHCP clients. By default, Specify different or extra options to DHCP clients. By default,
dnsmasq sends some standard options to DHCP clients, the netmask and dnsmasq sends some standard options to DHCP clients, the netmask and
broadcast address are set to the same as the host running dnsmasq, and broadcast address are set to the same as the host running dnsmasq, and
@@ -626,10 +631,16 @@ options are given which are encapsulated with the same option number
then they will be correctly combined into one encapsulated option. then they will be correctly combined into one encapsulated option.
encap: and vendor: are may not both be set in the same dhcp-option. encap: and vendor: are may not both be set in the same dhcp-option.
The final variant on encapsulated options is "Vendor-Identifying
Vendor Options" as specified by RFC3925. These are denoted like this:
.B --dhcp-option=vi-encap:2, 10, "text"
The number in the vi-encap: section is the IANA enterprise number
used to identify this option.
The address 0.0.0.0 is not treated specially in The address 0.0.0.0 is not treated specially in
encapsulated options. encapsulated options.
.TP .TP
.B --dhcp-option-force=[<network-id>,[<network-id>,]][encap:<opt>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]] .B --dhcp-option-force=[<network-id>,[<network-id>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
This works in exactly the same way as This works in exactly the same way as
.B --dhcp-option .B --dhcp-option
except that the option will always be sent, even if the client does except that the option will always be sent, even if the client does
@@ -681,7 +692,7 @@ agent ID and one provided by a relay agent, the network-id tag is set.
.B --dhcp-subscrid=<network-id>,<subscriber-id> .B --dhcp-subscrid=<network-id>,<subscriber-id>
Map from RFC3993 subscriber-id relay agent options to network-id tags. Map from RFC3993 subscriber-id relay agent options to network-id tags.
.TP .TP
.B --dhcp-match=<network-id>,<option number>|option:<option name>[,<value>] .B --dhcp-match=<network-id>,<option number>|option:<option name>|vi-encap:<enterprise>[,<value>]
Without a value, set the network-id tag if the client sends a DHCP Without a value, set the network-id tag if the client sends a DHCP
option of the given number or name. When a value is given, set the tag only if option of the given number or name. When a value is given, set the tag only if
the option is sent and matches the value. The value may be of the form the option is sent and matches the value. The value may be of the form
@@ -697,6 +708,10 @@ must match, so
will set the tag "efi-ia32" if the the number 6 appears in the list of will set the tag "efi-ia32" if the the number 6 appears in the list of
architectures sent by the client in option 93. (See RFC 4578 for architectures sent by the client in option 93. (See RFC 4578 for
details.) If the value is a string, substring matching is used. details.) If the value is a string, substring matching is used.
The special form with vi-encap:<enterpise number> matches against
vendor-identifying vendor classes for the specified enterprise. Please
see RFC 3925 for more details of the rare and interesting beasts.
.TP .TP
.B \-J, --dhcp-ignore=<network-id>[,<network-id>] .B \-J, --dhcp-ignore=<network-id>[,<network-id>]
When all the given network-ids match the set of network-ids derived When all the given network-ids match the set of network-ids derived
@@ -730,7 +745,7 @@ If the optional network-id(s) are given,
they must match for this configuration to be sent. Note that they must match for this configuration to be sent. Note that
network-ids are prefixed by "net:" to distinguish them. network-ids are prefixed by "net:" to distinguish them.
.TP .TP
.B --pxe-service=[net:<network-id>,]<CSA>,<menu text>,<basename>|<bootservicetype>[,<server address>] .B --pxe-service=[net:<network-id>,]<CSA>,<menu text>[,<basename>|<bootservicetype>][,<server address>]
Most uses of PXE boot-ROMS simply allow the PXE Most uses of PXE boot-ROMS simply allow the PXE
system to obtain an IP address and then download the file specified by system to obtain an IP address and then download the file specified by
.B dhcp-boot .B dhcp-boot
@@ -753,8 +768,9 @@ suffix (normally ".0") is supplied by PXE, and should not be added to
the basename. If an integer boot service type, rather than a basename the basename. If an integer boot service type, rather than a basename
is given, then the PXE client will search for a is given, then the PXE client will search for a
suitable boot service for that type on the network. This search may be done suitable boot service for that type on the network. This search may be done
by multicast or broadcast, or direct to a server if its IP address is provided. A boot service by broadcast, or direct to a server if its IP address is provided.
type of 0 is special, and will abort the net boot procedure and If no boot service type or filename is provided (or a boot service type of 0 is specified)
then the menu entry will abort the net boot procedure and
continue booting from local media. continue booting from local media.
.TP .TP
.B --pxe-prompt=[net:<network-id>,]<prompt>[,<timeout>] .B --pxe-prompt=[net:<network-id>,]<prompt>[,<timeout>]
@@ -842,8 +858,9 @@ The environment is inherited from the invoker of dnsmasq, and if the
host provided a client-id, this is stored in the environment variable host provided a client-id, this is stored in the environment variable
DNSMASQ_CLIENT_ID. If the fully-qualified domain name of the host is DNSMASQ_CLIENT_ID. If the fully-qualified domain name of the host is
known, the domain part is stored in DNSMASQ_DOMAIN. known, the domain part is stored in DNSMASQ_DOMAIN.
If the client provides vendor-class or user-class If the client provides vendor-class, hostname or user-class,
information, these are provided in DNSMASQ_VENDOR_CLASS and these are provided in DNSMASQ_VENDOR_CLASS
DNSMASQ_SUPPLIED_HOSTNAME and
DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn variables, but only for DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn variables, but only for
"add" actions or "old" actions when a host resumes an existing lease, "add" actions or "old" actions when a host resumes an existing lease,
since these data are not held in dnsmasq's lease since these data are not held in dnsmasq's lease
@@ -857,7 +874,10 @@ removed, an "old" event is generated with the new state of the lease,
ie no name, and the former name is provided in the environment ie no name, and the former name is provided in the environment
variable DNSMASQ_OLD_HOSTNAME. DNSMASQ_INTERFACE stores the name of variable DNSMASQ_OLD_HOSTNAME. DNSMASQ_INTERFACE stores the name of
the interface on which the request arrived; this is not set for "old" the interface on which the request arrived; this is not set for "old"
actions when dnsmasq restarts. actions when dnsmasq restarts. DNSMASQ_RELAY_ADDRESS is set if the client
used a DHCP relay to contact dnsmasq and the IP address of the relay
is known. DNSMASQ_TAGS contains all the network-id tags set during the
DHCP transaction, separated by spaces.
All file descriptors are All file descriptors are
closed except stdin, stdout and stderr which are open to /dev/null closed except stdin, stdout and stderr which are open to /dev/null
(except in debug mode). (except in debug mode).
@@ -995,10 +1015,11 @@ of concurrent TFTP connections is limited by the size of the port range.
Specify a different configuration file. The conf-file option is also allowed in Specify a different configuration file. The conf-file option is also allowed in
configuration files, to include multiple configuration files. configuration files, to include multiple configuration files.
.TP .TP
.B \-7, --conf-dir=<directory> .B \-7, --conf-dir=<directory>[,<file-extension>......]
Read all the files in the given directory as configuration Read all the files in the given directory as configuration
files. Files whose names end in ~ or start with . or start and end files. If extension(s) are given, any files which end in those
with # are skipped. This flag may be given on the command extensions are skipped. Any files whose names end in ~ or start with . or start and end
with # are always skipped. This flag may be given on the command
line or in a configuration file. line or in a configuration file.
.SH CONFIG FILE .SH CONFIG FILE
At startup, dnsmasq reads At startup, dnsmasq reads
@@ -1238,6 +1259,24 @@ or an additional hosts file. The list can be very long,
dnsmasq has been tested successfully with one million names. That size dnsmasq has been tested successfully with one million names. That size
file needs a 1GHz processor and about 60Mb of RAM. file needs a 1GHz processor and about 60Mb of RAM.
.SH INTERNATIONALISATION
Dnsmasq can be compiled to support internationalisation. To do this,
the make targets "all-i18n" and "install-i18n" should be used instead of
the standard targets "all" and "install". When internationalisation
is compiled in, dnsmasq will produce log messages in the local
language and support internationalised domain names (IDN). Domain
names in /etc/hosts, /etc/ethers and /etc/dnsmasq.conf which contain
non-ASCII characters will be translated to the DNS-internal punycode
representation. Note that
dnsmasq determines both the language for messages and the assumed
charset for configuration
files from the LANG environment variable. This should be set to the system
default value by the script which is responsible for starting
dnsmasq. When editing the configuration files, be careful to do so
using only the system-default locale and not user-specific one, since
dnsmasq has no direct way of determining the charset in use, and must
assume that it is the system default.
.SH FILES .SH FILES
.IR /etc/dnsmasq.conf .IR /etc/dnsmasq.conf
+171 -55
View File
@@ -17,9 +17,8 @@ resueltos. Tambi
vía DHCP. vía DHCP.
.PP .PP
El servidor DHCP dnsmasq incluye soporte para asignación de direcciones El servidor DHCP dnsmasq incluye soporte para asignación de direcciones
estáticas, redes múltiples, DHCP-relay y especificadores de subredes estáticas y redes múltiples. Automáticamente envía un predeterminado sensible de
RFC3011. Automáticamente envía un predeterminado sensible de opciones opciones DHCP, y puede ser configurado para enviar cualquier opciones DHCP deseadas,
DHCP, y puede ser configurado para enviar cualquier opciones DHCP deseadas,
incluyendo opciones encapsuladas por vendedores. Incluye un servidor seguro incluyendo opciones encapsuladas por vendedores. Incluye un servidor seguro
TFTP solo-lectura para permitir el inicio vía red/PXE de hosts DHCP. Tambíen TFTP solo-lectura para permitir el inicio vía red/PXE de hosts DHCP. Tambíen
incluye soporte para BOOTP. incluye soporte para BOOTP.
@@ -33,17 +32,25 @@ archivo PID. En BSD, a menos que la librer
la forma larga de las opciones no funciona en la línea de comandos, la forma larga de las opciones no funciona en la línea de comandos,
pero todavía es reconocida en el archivo de configuración. pero todavía es reconocida en el archivo de configuración.
.TP .TP
.B --test
Leer archivo(s) de configuración y revisar su sintaxis. Salir con código
0 si todo está bien, o un código no-cero en cualquier otro caso. No
iniciar dnsmasq.
.TP
.B \-h, --no-hosts .B \-h, --no-hosts
No leer los nombres de hosts en /etc/hosts. No leer los nombres de hosts en /etc/hosts.
.TP .TP
.B \-H, --addn-hosts=<archivo> .B \-H, --addn-hosts=<archivo>
Archivo de hosts adicional. Leer el archivo especificado adicionalmente Archivo de hosts adicional. Leer el archivo especificado adicionalmente
a /etc/hosts. Si se brinda -h, leer solo el archivo especificado. Esta a /etc/hosts. Si se brinda -h, leer solo el archivo especificado. Esta
opción puede ser repetida para más de un archivo de hosts adicional. opción puede ser repetida para más de un archivo de hosts adicional. Si
un directorio es brindado, entonces leer todos los archivos contenidos en
ese directorio.
.TP .TP
.B \-E, --expand-hosts .B \-E, --expand-hosts
Agregar el dominio a nombres sencillos (sin punto) en /etc/hosts de la Agregar el dominio a nombres sencillos (sin punto) en /etc/hosts de la
misma manera que con nombres derivados de DHCP. misma manera que con nombres derivados de DHCP. Nótese que esto no
aplica a nombres de dominio en cnames, expedientes PTR, TXT, etc.
.TP .TP
.B \-T, --local-ttl=<tiempo> .B \-T, --local-ttl=<tiempo>
Al responder con información desde /etc/hosts o desde el archivo Al responder con información desde /etc/hosts o desde el archivo
@@ -127,8 +134,8 @@ solo DHCP y/o TFTP.
.TP .TP
.B \-P, --edns-packet-max=<tamaño> .B \-P, --edns-packet-max=<tamaño>
Especificar el paquete UDP EDNS.0 más grande que es soportado por Especificar el paquete UDP EDNS.0 más grande que es soportado por
el reenviador DNS. Por predeterminado es 1280, lo cual es el el reenviador DNS. Por predeterminado es 4096, lo cual es el
máximo recomendado en RFC2671 para ethernet. tamaño recomendado en RFC5625.
.TP .TP
.B \-Q, --query-port=<puerto> .B \-Q, --query-port=<puerto>
Enviar búsquedas outbound desde, y escuchar por respuestas en, Enviar búsquedas outbound desde, y escuchar por respuestas en,
@@ -225,14 +232,18 @@ privados (192.168.x.x, etc.) los cuales no se encuentren en
/etc/hosts o en el archivo de arriendos DHCP es respondida con /etc/hosts o en el archivo de arriendos DHCP es respondida con
"dominio no existente" en vez de ser reenviada upstream. "dominio no existente" en vez de ser reenviada upstream.
.TP .TP
.B \-V, --alias=<IP viejo>,<IP nuevo>[,<máscara>] .B \-V, --alias=[<IP viejo>]|[<IP inicio>-<IP final>],<IP nuevo>[,<máscara>]
Modificar direcciones IPv4 retornadas desde servidores DNS upstream; Modificar direcciones IPv4 retornadas desde servidores DNS upstream;
<IP viejo> es remplazado con <IP nuevo>. Si la máscara opcional <IP viejo> es remplazado con <IP nuevo>. Si la máscara opcional
es brindada, entonces cualquier dirección que coincida con el es brindada, entonces cualquier dirección que coincida con el
<IP viejo> enmascarado será re-escrita. Así que, por ejemplo, <IP viejo> enmascarado será re-escrita. Así que, por ejemplo,
.B --alias=1.2.3.0,6.7.8.0,255.255.255.0 trazará 1.2.3.56 a 6.7.8.56 .B --alias=1.2.3.0,6.7.8.0,255.255.255.0 trazará 1.2.3.56 a 6.7.8.56
y 1.2.3.67 a 6.7.8.67. Esto es lo que y 1.2.3.67 a 6.7.8.67. Esto es lo que
ruteadores Cisco PIX llaman "DNS doctoring". ruteadores Cisco PIX llaman "DNS doctoring". Si la dirección vieja es
brindada como un rango, entonces solo direcciones en ese rango, y no
la subred entera, son re-escritas. De tal manera que
.B --alias=192.168.0.10-192.168.0.40,10.0.0.0,255.255.255.0
relaciona 192.168.0.10->192.168.0.40 a 10.0.0.10->10.0.0.40
.TP .TP
.B \-B, --bogus-nxdomain=<dirección IP> .B \-B, --bogus-nxdomain=<dirección IP>
Transformar respuestas que contienen la dirección IP brindada a Transformar respuestas que contienen la dirección IP brindada a
@@ -449,39 +460,43 @@ de casos. La
es al usar resolvedores de bitácoras de servidores web, los cuales pueden es al usar resolvedores de bitácoras de servidores web, los cuales pueden
generar un número inmenso de búsquedas simultáneas. generar un número inmenso de búsquedas simultáneas.
.TP .TP
.B \-F, --dhcp-range=[[net:]network-id,]<dirección-inicio>,<dirección-final>[[,<máscara>],<broadcast>][,<tiempo de arriendo predeterminado>] .B \-F, --dhcp-range=[[net:]network-id,]<dirección-inicio>,<dirección-final>[,<máscara>[,<broadcast>]][,<tiempo de arriendo>]
Habilitar el servidor DHCP. Direcciones serán distribuidas desde el Habilitar el servidor DHCP. Direcciones serán distribuidas desde el
rango <dirección-inicio> hasta <dirección-final> y desde direcciones definidas rango <dirección-inicio> hasta <dirección-final> y desde direcciones definidas
estáticamente en opciones estáticamente en opciones
.B dhcp-host .B dhcp-host
Si el tiempo de arriendo es especificado, entonces arriendos serán Si el tiempo de arriendo es especificado, entonces arriendos serán
otorgados por esa cantidad de tiempo. El tiempo de arriendo es en otorgados por esa cantidad de tiempo. El tiempo de arriendo es en
segundos, o minutos (por ejemplo, 45m), o horas (por ejemplo, 1h), o el segundos, o minutos (por ejemplo, 45m), u horas (por ejemplo, 1h), o
literal "infinite". Esta opción puede ser repetida, con diferentes "infinite". Si no es brindada, el tiempo de arriendo predeterminado
es de una hora. El tiempo de arriendo mínimo es de dos minutos.
Esta opción puede ser repetida, con diferentes
direcciones, para habilitar servicio DHCP en más de una red. Para direcciones, para habilitar servicio DHCP en más de una red. Para
redes conectadas diréctamente (en otras palabras, redes en las redes conectadas diréctamente (en otras palabras, redes en las
cuales la máquina corriendo dnsmasq tiene una interface) la cuales la máquina corriendo dnsmasq tiene una interface) la
máscara de subred es opcional. Pero, es requerida para redes que máscara de subred es opcional. Pero, es requerida para redes que
reciben servicio DHCP vía un agente de relay. La dirección de reciben servicio DHCP vía un agente de relay. La dirección de
broadcast siempre es opcional. En algunos sistemas rotos, dnsmasq broadcast siempre es opcional. Siempre se permite tener más de
solo puede escuchar en una interface cuando se usa DHCP, y el un rango dhcp (dhcp-range) en una subred. El parámetro opcional
nombre de esa interface debe ser brindado usando la opción network-id es una etiqueta alfanumérica la cual marca esta red de
.B interface tal forma que opciones dhcp puedan ser especificadas en base a cada red.
Esta limitación actualmente afecta a OpenBSD antes de versión 4.0.
Siempre se permite tener más de un rango dhcp (dhcp-range) en una
subred. El parámetro opcional network-id es una etiqueta alfanumérica
la cual marca esta red de tal forma que opciones dhcp puedan ser
especificadas en base a cada red.
Cuando es prefijada con 'net:' entonces el significado cambia Cuando es prefijada con 'net:' entonces el significado cambia
de "fijar etiqueta" a "coincidir con etiqueta". Solo una etiqueta puede de "fijar etiqueta" a "coincidir con etiqueta". Solo una etiqueta puede
ser fijada, pero más de una puede ser revisada por coincidencias. La ser fijada, pero más de una puede ser revisada por coincidencias. La
dirección final puede ser remplazada por la palabra clave dirección final puede ser remplazada por la palabra clave
.B static .B static
la cual le dice a dnsmasq que debe habilitar DHCP para la red la cual le dice a dnsmasq que debe habilitar DHCP para la red
especificada, pero no alocar dinámicamente direcciones IP. especificada, pero no alocar dinámicamente direcciones IP:
Solo hosts que tienen direcciones estáticas brindadas vía Solo hosts que tienen direcciones estáticas brindadas vía
.B dhcp-host .B dhcp-host
o desde /etc/ethers serán servidas. o desde /etc/ethers serán servidas. La dirección final puede ser
remplazada por la palabra clave
.B proxy
caso en el cual dnsmasq proveerá proxy-DHCP en la subred especificada. (Ver
.B pxe-prompt
y
.B pxe-service
para detalles.)
.TP .TP
.B \-G, --dhcp-host=[<dirección de hardware>][,id:<client_id>|*][,net:<netid>][,<dirección IP>][,<nombre de host>][,<tiempo de arriendo>][,ignore] .B \-G, --dhcp-host=[<dirección de hardware>][,id:<client_id>|*][,net:<netid>][,<dirección IP>][,<nombre de host>][,<tiempo de arriendo>][,ignore]
Especificar parámetros por host para el servidor DHCP. Esto permite Especificar parámetros por host para el servidor DHCP. Esto permite
@@ -546,14 +561,16 @@ solo coincidir
el tipo ARP para Token-Ring es 6. el tipo ARP para Token-Ring es 6.
Como caso especial, es posible incluir más de una dirección de Como caso especial, es posible incluir más de una dirección de
hardware. Esto permite que una dirección IP sea asociada con hardware. Ejemplo:
.B --dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.2
Esto permite que una dirección IP sea asociada con
direcciones de hardware múltiples, y le brinda a dnsmasq permiso direcciones de hardware múltiples, y le brinda a dnsmasq permiso
para abandonar un arriendo DHCP a una de las direcciones de hardware para abandonar un arriendo DHCP a una de las direcciones de hardware
cuando otra pide un arriendo. Nótese que esto es algo peligroso, cuando otra pide un arriendo. Nótese que esto es algo peligroso,
sólo funcionará dependiblemente si una de las direcciones de hardware sólo funcionará dependiblemente si una de las direcciones de hardware
está activa en cualquier momento y dnsmasq no tiene forma de enforzar está activa en cualquier momento y dnsmasq no tiene forma de enforzar
esto. Pero es útil, por ejemplo, para alocar una dirección IP estable esto. Pero es útil, por ejemplo, para alocar una dirección IP estable
a una laptop que tiene interfaces alámbricas e inalámbricas. a una laptop que tiene interface alámbrica e inalámbrica.
.TP .TP
.B --dhcp-hostsfile=<archivo> .B --dhcp-hostsfile=<archivo>
Leer información host DHCP desde el archivo especificado. El archivo contiene información de un host por línea. El formato de una línea es igual que texto hacia la derecha de '=' en --dhcp-host. La ventaja de almacenar información host DHCP en este archivo es que puede ser cambiada sin tener que reiniciar dnsmasq. El archivo será re-leído cuando dnsmasq recibe un SIGHUP. Leer información host DHCP desde el archivo especificado. El archivo contiene información de un host por línea. El formato de una línea es igual que texto hacia la derecha de '=' en --dhcp-host. La ventaja de almacenar información host DHCP en este archivo es que puede ser cambiada sin tener que reiniciar dnsmasq. El archivo será re-leído cuando dnsmasq recibe un SIGHUP.
@@ -562,6 +579,11 @@ Leer informaci
Leer información sobre opciones DHCP desde el archivo especificado. La Leer información sobre opciones DHCP desde el archivo especificado. La
ventaja de usar esta opción es la misma que con --dhcp-hostsfile: el ventaja de usar esta opción es la misma que con --dhcp-hostsfile: el
archivo dhcp-optsfile será re-leído cuando dnsmasq recibe un SIGHUP. archivo dhcp-optsfile será re-leído cuando dnsmasq recibe un SIGHUP.
Nótese que es posible colocar la información mediante
.B --dhcp-boot
como opciones DHCP, usando los nombres de opción bootfile-name,
server-ip-address, y tftp-server. Esto permite que sean incluidas en
un archivo dhcp-optsfile.
.TP .TP
.B \-Z, --read-ethers .B \-Z, --read-ethers
Leer /etc/ethers en busca de información sobre hosts para el servidor Leer /etc/ethers en busca de información sobre hosts para el servidor
@@ -571,7 +593,7 @@ dnsmasq, estas l
.B --dhcp-host .B --dhcp-host
que contienen la misma información. /etc/ethers es re-leída cuando dnsmasq recibe un SIGHUP. que contienen la misma información. /etc/ethers es re-leída cuando dnsmasq recibe un SIGHUP.
.TP .TP
.B \-O, --dhcp-option=[<network-id>,[<network-id>,]][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]] .B \-O, --dhcp-option=[<network-id>,[<network-id>,]][encap:<opt>,][vi-encap:<enterprise>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<valor>[,<valor>]]
Especificar opciones diferentes o extra a clientes DHCP. Por Especificar opciones diferentes o extra a clientes DHCP. Por
predeterminado, dnsmasq envía algunas opciones estándar a clientes predeterminado, dnsmasq envía algunas opciones estándar a clientes
DHCP. La máscara de subred y dirección broadcast son fijadas igual DHCP. La máscara de subred y dirección broadcast son fijadas igual
@@ -634,11 +656,23 @@ vendor-class (n
seleccionar opciones encapsuladas en preferencia sobre cualquiera enviada seleccionar opciones encapsuladas en preferencia sobre cualquiera enviada
por el cliente. Es posible omitir el vendorclass completamente; por el cliente. Es posible omitir el vendorclass completamente;
.B --dhcp-option=vendor:,1,0.0.0.0 .B --dhcp-option=vendor:,1,0.0.0.0
caso en el cuál la opción encapsulada siempre es enviada. La dirección caso en el cuál la opción encapsulada siempre es enviada.
0.0.0.0 no es tratada de forma especial en opciones de clase de vendedor Opciones pueden ser encapsuladas dentro de otras opciones, por ejemplo:
encapsuladas. .B --dhcp-option=encap:175, 190, "iscsi-client0"
enviará opción 175, dentro de la cual está opción 190. Si múltiples
opciones son brindadas que están encapsuladas con el mismo número de
opción entonces serán correctamente combinadas en una opción encapsulada.
encap: y vendor: no pueden ser fijadas ambas dentro de la misma opción dhcp-option.
La variante final en opciones encapsuladas es "Vendor-Identifying Vendor Options"
como especificado en RFC3925. Estos son denotados así:
.B --dhcp-option=rfc3925-encap:2, 10, "text"
El número en la sección rfc3925-encap: es el número enterprise usado
para identificar esta opción.
La dirección 0.0.0.0 no es tratada de forma especial en opciones encapsuladas.
.TP .TP
.B --dhcp-option-force=[<network-id>,[<network-id>,]][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]] .B --dhcp-option-force=[<network-id>,[<network-id>,]][encap:<opt>,][rfc3925-encap:<enterprise>,][vendor:[<vendor-class>],]<opt>,[<valor>[,<valor>]]
Esto funciona exáctamente de la misma forma que Esto funciona exáctamente de la misma forma que
.B --dhcp-option .B --dhcp-option
excepto que la opción siempre será enviada, aún si el cliente no la pide en excepto que la opción siempre será enviada, aún si el cliente no la pide en
@@ -692,10 +726,26 @@ network-id es fijado.
.B --dhcp-subscrid=<network-id>,<subscriber-id> .B --dhcp-subscrid=<network-id>,<subscriber-id>
Trazar de opciones relay subscriber-id RFC3993 a opciones network-id. Trazar de opciones relay subscriber-id RFC3993 a opciones network-id.
.TP .TP
.B --dhcp-match=<network-id>,<número de opción> .B --dhcp-match=<network-id>,<option number>|option:<option name>|vi-encap:<enterprise>[,<valor>]
Fijar la opción network-id si el cliente envía un opción DHCP del nombre Sin un valor, fijar la etiqueta network-id si el cliente envía una opción
brindado. Esto puede ser utilizado para identificar clientes particulares DHCP del número o valor brindado. Cuando un valor es brindado, fijar la
que envían información usando números privados de opciones. etiqueta solo si la opción es enviada y coincide con el valor. El valor puede
ser de la forma "01:ff:*:02", caso en el cual el valor debe coincidir (aparte
de los comodines) pero la opción enviada puede tener data que no coincide despues
del final del valor. El valor también puede ser de la misma forma que
.B dhcp-option
caso en el cual la opción enviada es tratada como un array, y un elemento debe
coincidir, así que
--dhcp-match=efi-ia32,option:client-arch,6
fijará la etiqueta a "efi-ia32" si el número 6 aparece en la lista de
architecturas enviada por los clientes en opción 93. (Ver RFC 4578 para
detalles.) Si el valor es un string, coincidencia substring es usada.
La forma especial con vi-encap:<enterpise number> busca coincidencia con
clases de vendedor identificadoras para el enterprise especificado. Por
favor ver RFC 3925 para mas detalles sobre las bestias raras e interesantes.
.TP .TP
.B \-J, --dhcp-ignore=<network-id>[,<network-id>] .B \-J, --dhcp-ignore=<network-id>[,<network-id>]
Cuando todos los network ids brindados coincidan con el juego de Cuando todos los network ids brindados coincidan con el juego de
@@ -730,6 +780,58 @@ el inicio atrav
ellas deberán coincidir para que esta configuración sea enviada. Nótese ellas deberán coincidir para que esta configuración sea enviada. Nótese
que network-ids están prefijadas con "net:" para distinguirlas. que network-ids están prefijadas con "net:" para distinguirlas.
.TP .TP
.B --pxe-service=[net:<network-id>,]<CSA>,<texto de menú>[,<nombre base>|<tipo de servicio boot>][,<dirección de servidor>]
La mayoría de usos para boot-ROMS PXE simplemente permiten al sistema PXE
obtener una dirección IP y entonces bajar el archivo especificado por
.B dhcp-boot
y ejecutarlo. Sin embargo, el sistema PXE es capaz de llevar
a cabo funciones más complejas cuando están soportadas por un
servidor DHCP adecuado.
Esto especifica una opción boot que puede aparecer en un menú de boot
PXE. <CSA> es tipo de sistema de cliente, solo servicios del tipo correcto
aparecerán en un menú. Los tipos conocidos son x86PC, PC98, IA64_EFI,
Alpha, Arc_x86, Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI y X86-64_EFI;
un número entero puede ser utilizado para otros tipos. El parámetro después
del texto de menú puede ser un nombre de archivo, caso en el cuál dnsmasq
actúa como un servidor boot y le ordena al cliente PXE bajar el archivo
vía TFTP, ya sea de sí mismo (
.B enable-tftp
debe estar fijado para que esto funcione) o desde otro servidor TFTP si la
dirección IP final es brindada.
Nótese que el sufijo "layer" (normalmente ".0") es brindado por PXE, y
no debe ser agregado al nombre base. Si un número entero es brindado en vez
de un nombre base, entonces el cliente PXE buscará un servicio boot adecuado
para ese tipo de red. Esta búsqueda puede ser hecha mediante broadcast,
o directamente a un servidor si la dirección IP es brindada. Si ningún tipo
de servicio boot o nombre de archivo es brindado (o un tipo de servicio boot
de 0 es especificado), entonces la opción de menú abortará el proceso net boot
y continuará desde el medio local.
.TP
.B --pxe-prompt=[net:<network-id>,]<prompt>[,<timeout>]
Fijar esto hace que un aviso sea expuesto despues del boot PXE. Si el timeout
es brindado, entonces despues que el timeout se haya vencido sin input del
teclado, la primera opción del menú sera automaticamente ejecutada. Si el
timeout es cero entonces la primera opción del menú sera automaticamente
ejecutada. Si
.B pxe-prompt
es omitido, el sistema esperará para el input del usuario si hay múltiples
artículos en el menú, pero hará boot imediatamente si hay solo uno. Ver
.B pxe-service
para detalles sobre artículos de menu.
Dnsmasq tiene soporte para "proxy-DHCP" PXE, en este caso otro servidor
DHCP en la red es responsable por asignar direcciones IP, y dnsmasq
simplemente provee la dirección brindada en
.B pxe-prompt
y
.B pxe-service
para permitir boot a travez de la red. Este modo es habilitado usando
la palabra clave
.B proxy
en
.B dhcp-range.
.TP
.B \-X, --dhcp-lease-max=<número> .B \-X, --dhcp-lease-max=<número>
Limita a dnsmasq a el número especificado de arriendos DHCP. El Limita a dnsmasq a el número especificado de arriendos DHCP. El
predeterminado es 150. El limite es para prevenir ataques DoS desde predeterminado es 150. El limite es para prevenir ataques DoS desde
@@ -776,15 +878,7 @@ clientes DHCP y las etiquetas netid usadas para determinarlos.
.TP .TP
.B \-l, --dhcp-leasefile=<path> .B \-l, --dhcp-leasefile=<path>
Usar el archivo especificado para almacenar información de arriendos Usar el archivo especificado para almacenar información de arriendos
DHCP. Si esta opción es brindada, pero ninguna opcion dhcp-range es DHCP.
brindada, entonces se activa comportamiento tipo dnsmasq versión 1.
El archivo brindado se asume es un archivo de arriendos dhcpd ISC y
es analizado en busca de arriendos los cuales son agregados al sistema
DNS si tienen un nombre de host. Esta funcionalidad pudo haber sido
excluida de dnsmasq a la hora de compilación, y en tal caso ocurrirá
un error. Nótese que la integración de archivos de
arriendo ISC es una caracterísctica depreciada. No debería ser usada
en instalaciones nuevas, y será eliminada en una versión futura.
.TP .TP
.B \-6 --dhcp-script=<path> .B \-6 --dhcp-script=<path>
Cuando un arriendo DHCP nuevo es creado, o uno viejo es Cuando un arriendo DHCP nuevo es creado, o uno viejo es
@@ -804,10 +898,11 @@ El ambiente es heredado del usuario que ha invocado a dnsmasq, y si el
host brindó un client-id, es almacenado en la variable de ambiente host brindó un client-id, es almacenado en la variable de ambiente
DNSMASQ_CLIENT_ID. Si el dominio completamente calificado del host DNSMASQ_CLIENT_ID. Si el dominio completamente calificado del host
es conocido, la parte de dominio es almacenada en DNSMASQ_DOMAIN. Si es conocido, la parte de dominio es almacenada en DNSMASQ_DOMAIN. Si
el cliente brinda información de clase de vendedoro usuario, el cliente brinda información de clase de vendedor, nombre de host,
estos son brindados en las variables DNSMASQ_VENDOR_CLASS y o clase de usuario, estos son brindados en las variables
DNSMASQ_VENDOR_CLASS, DNSMASQ_SUPPLIED_HOSTNAME, y
DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn, pero solo para acciones "add" DNSMASQ_USER_CLASS0..DNSMASQ_USER_CLASSn, pero solo para acciones "add"
y "old" cuando un host resume un arriendo existente, dado a que estos y "old" cuando un host reanuda un arriendo existente, dado a que estos
datos no son almacenados en la base de datos de arriendos de dnsmasq. datos no son almacenados en la base de datos de arriendos de dnsmasq.
Si dnsmasq fue compilado con HAVE_BROKEN_RTC, entonces la duración del Si dnsmasq fue compilado con HAVE_BROKEN_RTC, entonces la duración del
arriendo (en segundos) es almacenada en DNSMASQ_LEASE_LENGTH, de otra arriendo (en segundos) es almacenada en DNSMASQ_LEASE_LENGTH, de otra
@@ -819,7 +914,10 @@ evento "old" es generado con el nuevo estado del arriendo, (por ejemplo, sin
nombre), y el nombre anterior es brindado en la variable de ambiente nombre), y el nombre anterior es brindado en la variable de ambiente
DNSMASQ_OLD_HOSTNAME. DNSMASQ_INTERFACE almacena el nombre de la interface DNSMASQ_OLD_HOSTNAME. DNSMASQ_INTERFACE almacena el nombre de la interface
en la cual llegó el pedido; esto no es fijado para acciones "viejas" en la cual llegó el pedido; esto no es fijado para acciones "viejas"
cuando dnsmasq re-inicia. cuando dnsmasq re-inicia. DNSMASQ_RELAY_ADDRESS es fijado si el cliente
usó un relay DHCP para contactar a dnsmasq y la dirección IP del relay
es conocida. DNSMASQ_TAGS contiene todas las etiquetas network-id fijadas
durante la transacción DHCP, separadas por espacios.
Todos los descriptores de archivo están cerrados Todos los descriptores de archivo están cerrados
excepto stdin, stdout, y stderr los cuales están abiertos a /dev/null excepto stdin, stdout, y stderr los cuales están abiertos a /dev/null
(excepto en modo debug). (excepto en modo debug).
@@ -853,10 +951,9 @@ cuando hay cambios hechos a el client-id y tiempos de arriendo y vencimiento.
.TP .TP
.B --bridge-interface=<nombre de interface>,<alias>[,<alias>] .B --bridge-interface=<nombre de interface>,<alias>[,<alias>]
Tratar paquetes de pedidos DHCP que llegan a cualquiera de las interfaces <alias> Tratar paquetes de pedidos DHCP que llegan a cualquiera de las interfaces <alias>
como si hubieran llegado a la interface <nombre de interface>. Esta opción solo como si hubieran llegado a la interface <nombre de interface>. Esta opción
está disponible en plataformas BSD, y es necesaria cuando se usan es necesaria al usar bridging estilo viejo en plataformas BSD, dado a que
puentes "estilo viejo", ya que los paquetes llegan a interfaces tap que no los paquetes llegan a interfaces tap que no tienen una dirección IP.
tienen una dirección IP.
.TP .TP
.B \-s, --domain=<dominio>[,<rango de IPs>] .B \-s, --domain=<dominio>[,<rango de IPs>]
Especifica los dominios DNS para el servidor DHCP. Dominios pueden ser Especifica los dominios DNS para el servidor DHCP. Dominios pueden ser
@@ -966,11 +1063,13 @@ Especificar un archivo de configuraci
también es permitida en archivos de configuración, para incluir múltiples también es permitida en archivos de configuración, para incluir múltiples
archivos de configuración. archivos de configuración.
.TP .TP
.B \-7, --conf-dir=<directorio> .B \-7, --conf-dir=<directorio>[,<file-extension>......]
Leer todos los archivos dentro del directorio brindado como archivos Leer todos los archivos dentro del directorio brindado como archivos
de configuración. Archivos cuyos nombres terminen con ~ o comienzen de configuración. Si extensiones son brindadas, cualquier archivo que
con . o comienzen y terminen con # son ignorados. Esta opción puede termine en esas extensiones son ignorados. Cualquier archivos cuyos nombres
ser brindada en la línea de comandos o en un archivo de configuración. terminen con ~ o comienzen con . o comienzen y terminen con # siempre son
ignorados. Esta opción puede ser brindada en la línea de comandos o en un
archivo de configuración.
.SH ARCHIVO DE CONFIGURACION .SH ARCHIVO DE CONFIGURACION
Al inicio, dnsmasq lee Al inicio, dnsmasq lee
.I /etc/dnsmasq.conf, .I /etc/dnsmasq.conf,
@@ -1211,6 +1310,23 @@ o en un archivo hosts adicional. La lista puede ser muy larga. Dnsmasq ha sido
probado exitósamente con un millón de nombres. Ese tamaño de archivo necesita probado exitósamente con un millón de nombres. Ese tamaño de archivo necesita
un CPU de 1GHz y aproximadamente 60MB de RAM. un CPU de 1GHz y aproximadamente 60MB de RAM.
.SH INTERNACIONALIZACION
Dnsmasq puede ser compilado con soporte para internacionalización. Para hacer esto,
los targets make "all-i18n" y "install-i18n" deberán ser usados en vez de
los targets estándares "all" y "install". Cuando internacionalización es
compilada, dnsmasq producirá mensajes de bitácora en el lenguaje local y soportará
dominios internacionalizados (IDN). Nombres de dominio en /etc/hosts, /etc/ethers,
y /etc/dnsmasq.conf que contienen carácteres no-ASCII serán traducidos a
representación interna DNS punycode. Nótese que dnsmasq determina ambos el
lenguaje para mensajes y el juego de carácteres asumido para archivos de configuración
de la variable ambiental LANG. Esto debe estar fijado al valor predeterminado del sistema
por el guión responsable de iniciar dnsmasq. Al editar archivos de configuración,
tener cuidado de hacerlo usando solo el locale predeterminado del sistema y no
uno especifico del usuario, dado a que dnsmasq no tiene ninguna manera directa de
determinar el juego de caracteres en uso, y debe asumir que es el predeterminado
del sistema.
.SH ARCHIVOS .SH ARCHIVOS
.IR /etc/dnsmasq.conf .IR /etc/dnsmasq.conf
+76 -32
View File
@@ -51,7 +51,8 @@ fichiers contenus dans ce répertoire.
.B \-E, --expand-hosts .B \-E, --expand-hosts
Ajoute le nom de domaine aux noms simples (ne contenant pas de point dans le Ajoute le nom de domaine aux noms simples (ne contenant pas de point dans le
nom) contenus dans le fichier /etc/hosts, de la même façon que pour le service nom) contenus dans le fichier /etc/hosts, de la même façon que pour le service
DHCP. DHCP. Notez que cela ne s'applique pas au nom de domaine dans les CNAME, les
enregistrements PTR, TXT, etc...
.TP .TP
.B \-T, --local-ttl=<durée> .B \-T, --local-ttl=<durée>
Lorsque Dnsmasq répond avec une information provenant du fichier /etc/hosts ou Lorsque Dnsmasq répond avec une information provenant du fichier /etc/hosts ou
@@ -139,8 +140,7 @@ que le DHCP ou le TFTP.
.TP .TP
.B \-P, --edns-packet-max=<taille> .B \-P, --edns-packet-max=<taille>
Spécifie la taille maximum de paquet UDP EDNS.0 supporté par le relai DNS. Le Spécifie la taille maximum de paquet UDP EDNS.0 supporté par le relai DNS. Le
défaut est de 1280, qui est la valeur maximale défaut est de 4096, qui est la valeur recommandée dans la RFC5625.
recommandée pour ethernet dans la RFC2671.
.TP .TP
.B \-Q, --query-port=<numéro de port> .B \-Q, --query-port=<numéro de port>
Envoie et écoute les requêtes DNS sortantes depuis le port UDP spécifié par Envoie et écoute les requêtes DNS sortantes depuis le port UDP spécifié par
@@ -502,7 +502,7 @@ lorsqu'un serveur web a la résolution de nom activée pour l'enregistrement de
son journal des requêtes, ce qui peut générer un nombre important de requêtes son journal des requêtes, ce qui peut générer un nombre important de requêtes
simultanées. simultanées.
.TP .TP
.B \-F, --dhcp-range=[[net:]identifiant de réseau,]<adresse de début>,<adresse de fin>[[,<masque de réseau>],<broadcast>][,<durée de bail>] .B \-F, --dhcp-range=[[net:]identifiant de réseau,]<adresse de début>,<adresse de fin>[,<masque de réseau>[,<broadcast>]][,<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
@@ -634,7 +634,11 @@ relu lorsque Dnsmasq reçoit un signal SIGHUP.
.B --dhcp-optsfile=<fichier> .B --dhcp-optsfile=<fichier>
Lis les informations relatives aux options DHCP dans le fichier spécifié. Lis les informations relatives aux options DHCP dans le fichier spécifié.
L'intérêt d'utiliser cette option est le même que pour --dhcp-hostsfile : le L'intérêt d'utiliser cette option est le même que pour --dhcp-hostsfile : le
fichier spécifié ser rechargé à la réception par dnsmasq d'un signal SIGHUP. fichier spécifié sera rechargé à la réception par dnsmasq d'un signal SIGHUP.
Notez qu'il est possible d'encoder l'information via
.B --dhcp-boot
en utilisant les noms optionnels bootfile-name, server-ip-address et
tftp-server. Ceci permet d'inclure ces options dans un fichier "dhcp-optsfile".DNSMASQ_SUPPLIED_HOSTNAME
.TP .TP
.B \-Z, --read-ethers .B \-Z, --read-ethers
Lis les informations d'hôtes DHCP dans le fichier /etc/ethers. Le format de Lis les informations d'hôtes DHCP dans le fichier /etc/ethers. Le format de
@@ -645,7 +649,7 @@ par Dnsmasq, ces lignes ont exactement le même effet que l'option
contenant les mêmes informations. /etc/ethers est relu à la réception d'un contenant les mêmes informations. /etc/ethers est relu à la réception d'un
signal SIGHUP par Dnsmasq. signal SIGHUP par Dnsmasq.
.TP .TP
.B \-O, --dhcp-option=[<identifiant_de_réseau>,[<identifiant_de_réseau>,]][encap:<option>,][vendor:[<classe_vendeur>],][<option>|option:<nom d'option>],[<valeur>[,<valeur>]] .B \-O, --dhcp-option=[<identifiant_de_réseau>,[<identifiant_de_réseau>,]][encap:<option>,][vi-encap:<entreprise>,][vendor:[<classe_vendeur>],][<option>|option:<nom d'option>],[<valeur>[,<valeur>]]
Spécifie des options différentes ou supplémentaires pour des clients DHCP. Par Spécifie des options différentes ou supplémentaires pour des clients DHCP. Par
défaut, Dnsmasq envoie un ensemble standard d'options aux clients DHCP : le défaut, Dnsmasq envoie un ensemble standard d'options aux clients DHCP : le
masque de réseau et l'adresse de broadcast sont les mêmes que pour l'hôte masque de réseau et l'adresse de broadcast sont les mêmes que pour l'hôte
@@ -724,10 +728,17 @@ Plusieurs options encapsulées avec le même numéro d'option seront correctemen
combinées au sein d'une seule option encapsulée. Il n'est pas possible de combinées au sein d'une seule option encapsulée. Il n'est pas possible de
spécifier encap: et vendor: au sein d'une même option dhcp. spécifier encap: et vendor: au sein d'une même option dhcp.
La dernière variante pour les options encapsulées est "l'option de Vendeur
identifiant le vendeur" ("Vendor-Identifying Vendor Options") telle que
décrite dans le RFC3925. Celles-ci sont spécifiées comme suit :
.B --dhcp-option=vi-encap:2, 10, "text"
Le numéro dans la section vi-encap: est le numéro IANA de l'entreprise servant
à identifier cette option.
L'adresse 0.0.0.0 n'est pas traitée de manière particulière lorsque fournie dans L'adresse 0.0.0.0 n'est pas traitée de manière particulière lorsque fournie dans
une option encapsulée. une option encapsulée.
.TP .TP
.B --dhcp-option-force=[<identifiant de réseau>,[<identifiant de réseau>,]][encap:<option>,][vendor:[<classe de vendeur>],]<option>,[<valeur>[,<valeur>]] .B --dhcp-option-force=[<identifiant de réseau>,[<identifiant de réseau>,]][encap:<option>,][vi-encap:<entreprise>,][vendor:[<classe de vendeur>],]<option>,[<valeur>[,<valeur>]]
Cela fonctionne exactement de la même façon que Cela fonctionne exactement de la même façon que
.B --dhcp-option .B --dhcp-option
sauf que cette option sera toujours envoyée, même si le client ne la demande pas sauf que cette option sera toujours envoyée, même si le client ne la demande pas
@@ -789,7 +800,7 @@ relais DHCP, alors l'identifiant de réseau est positionné.
Associe des options de relais DHCP issues de la RFC3993 à des identifiants de Associe des options de relais DHCP issues de la RFC3993 à des identifiants de
réseau. réseau.
.TP .TP
.B --dhcp-match=<identifiant de réseau>,<numéro d'option>|option:<nom d'option>[,<valeur>] .B --dhcp-match=<identifiant de réseau>,<numéro d'option>|option:<nom d'option>|vi-encap:<entreprise>[,<valeur>]
Si aucune valeur n'est spécifiée, associe l'identifiant de réseau si le client Si aucune valeur n'est spécifiée, associe l'identifiant de réseau si le client
envoie une option DHCP avec le numéro ou le nom spécifié. Lorsqu'une valeur est envoie une option DHCP avec le numéro ou le nom spécifié. Lorsqu'une valeur est
fournie, positionne le label seulement dans le cas où l'option est fournie et fournie, positionne le label seulement dans le cas où l'option est fournie et
@@ -806,6 +817,11 @@ spécifie le label "efi-ia32" si le numéro 6 apparaît dnas la liste
d'architectures envoyé par le client au sein de l'option 93. (se réferer d'architectures envoyé par le client au sein de l'option 93. (se réferer
au RFC 4578 pour plus de détails). Si la valeur est un chaine de caractères, au RFC 4578 pour plus de détails). Si la valeur est un chaine de caractères,
celle-ci est recherchée (correspondance en temps que sous-chaîne). celle-ci est recherchée (correspondance en temps que sous-chaîne).
Pour la forme particulière vi-encap:<numéro d'entreprise>, la comparaison se
fait avec les classes de vendeur "identifiant de vendeur" ("vendor-identifying
vendor classes") pour l'entreprise dont le numéro est fourni en option.
Veuillez vous réferer à la RFC 3925 pour plus de détail.
.TP .TP
.B \-J, --dhcp-ignore=<identifiant de réseau>[,<identifiant de réseau>] .B \-J, --dhcp-ignore=<identifiant de réseau>[,<identifiant de réseau>]
Lorsque tous les identifiants de réseau fournis coïncident avec la liste Lorsque tous les identifiants de réseau fournis coïncident avec la liste
@@ -842,7 +858,7 @@ Si d'éventuels identifiants de réseau sont fournis, ils doivent coïncider ave
ceux du client pour que cet élement de configuration lui soit envoyé. Il est à ceux du client pour que cet élement de configuration lui soit envoyé. Il est à
noter que les identifiants de réseau doivent-être préfixés par "net:". noter que les identifiants de réseau doivent-être préfixés par "net:".
.TP .TP
.B --pxe-service=[net:<identifiant de réseau>,]<CSA>,<entrée de menu>,<nom de fichier>|<type de service de démarrage>[,<adresse de serveur>] .B --pxe-service=[net:<identifiant de réseau>,]<CSA>,<entrée de menu>[,<nom de fichier>|<type de service de démarrage>][,<adresse de serveur>]
La plupart des ROMS de démarrage PXE ne permettent au système PXE que la simple La plupart des ROMS de démarrage PXE ne permettent au système PXE que la simple
obtention d'une adresse IP, le téléchargement du fichier spécifié dans obtention d'une adresse IP, le téléchargement du fichier spécifié dans
.B dhcp-boot .B dhcp-boot
@@ -865,10 +881,12 @@ Veuillez noter que le suffixe de "couche" (en principe ".0") est fourni par PXE
et ne doit pas être rajouté au nom de fichier. Si une valeur numérique entière et ne doit pas être rajouté au nom de fichier. Si une valeur numérique entière
est fournir pour le type de démarrage, en remplacement du nom de fichier, le est fournir pour le type de démarrage, en remplacement du nom de fichier, le
client PXE devra chercher un service de démarrage de ce type sur le réseau. client PXE devra chercher un service de démarrage de ce type sur le réseau.
Cette recherche peut être faite via multicast ou broadcast, ou directement Cette recherche peut être faite via broadcast ou directement auprès d'un
auprès d'un serveur si son adresse IP est fournie dans l'option. Un service de serveur si son adresse IP est fournie dans l'option.
démarrage de type 0 est spécial et provoquera une interruption du démarrage par Si aucun nom de fichier n'est donné ni aucune valeur de type de service de
le réseau ainsi que la poursuite du démarrage sur un média local. démarrage n'est fournie (ou qu'une valeur de 0 est donnée pour le type de
service), alors l'entrée de menu provoque l'interruption du démarrage par
le réseau et la poursuite du démarrage sur un média local.
.TP .TP
.B --pxe-prompt=[net:<identifiant de réseau>,]<invite>[,<délai>] .B --pxe-prompt=[net:<identifiant de réseau>,]<invite>[,<délai>]
Cette option permet d'afficher une invite à la suite du démarrage PXE. Si un Cette option permet d'afficher une invite à la suite du démarrage PXE. Si un
@@ -961,22 +979,27 @@ L'environnement est hérité de celui de l'invocation du processus Dnsmasq, et
si l'hôte fournit un identifiant de client, celui-ci est stocké dans la si l'hôte fournit un identifiant de client, celui-ci est stocké dans la
variable d'environnement DNSMASQ_CLIENT_ID. Si un nom de domaine pleinement variable d'environnement DNSMASQ_CLIENT_ID. Si un nom de domaine pleinement
qualifié (FQDN) est connu pour l'hôte, la part relative au domaine est stockée qualifié (FQDN) est connu pour l'hôte, la part relative au domaine est stockée
dans DNSMASQ_DOMAIN. Si le client fournit une information de classe de vendeur dans DNSMASQ_DOMAIN. Si le client fournit une information de classe de vendeur,
ou de classe d'utilisateur, celles-ci sont positionnées dans les variables de classe d'utilisateur ou un nom d'hôte, celles-ci sont positionnées dans les
DNSMASQ_VENDOR_CLASS et DNSMASQ_USER_CLASS0 à DNSMASQ_USER_CLASSn variables DNSMASQ_VENDOR_CLASS et DNSMASQ_USER_CLASS0 à DNSMASQ_USER_CLASSn
respectivement, mais seulement pour les actions "add" et "old" lorsqu'un hôte et DNSMASQ_SUPPLIED_HOSTNAME respectivement, mais seulement pour les actions
reprend un bail existant, ces variables n'étant pas stockées dans la base de "add" et "old" lorsqu'un hôte reprend un bail existant, ces variables n'étant
baux de Dnsmasq. Si Dnsmasq a été compilé avec l'option HAVE_BROKEN_RTC pas stockées dans la base de baux de Dnsmasq. Si Dnsmasq a été compilé avec
("horloge RTC défectueuse"), alors la durée du bail (en secondes) est stockée l'option HAVE_BROKEN_RTC ("horloge RTC défectueuse"), alors la durée du bail
dans la variable DNSMASQ_LEASE_LENGTH, sinon la date d'expiration du bail est (en secondes) est stockée dans la variable DNSMASQ_LEASE_LENGTH, sinon la date
toujours stocké dans la variable d'environnement DNSMASQ_LEASE_EXPIRES. Le d'expiration du bail est toujours stocké dans la variable d'environnement
nombre de secondes avant expiration est toujours stocké dans DNSMASQ_LEASE_EXPIRES. Le nombre de secondes avant expiration est toujours
DNSMASQ_TIME_REMAINING. Si un bail était associé à un nom d'hôte et que celui-ci stocké dans DNSMASQ_TIME_REMAINING. Si un bail était associé à un nom d'hôte et
est supprimé, un évênement de type "old" est généré avec le nouveau statut du que celui-ci est supprimé, un évênement de type "old" est généré avec le
bail, c-à-d sans nom d'hôte, et le nom initial est fourni dans la variable nouveau statut du bail, c-à-d sans nom d'hôte, et le nom initial est fourni
d'environnement DNSMASQ_OLD_HOSTNAME. La variable DNSMASQ_INTERFACE contient le nom de dans la variable d'environnement DNSMASQ_OLD_HOSTNAME. La variable
l'interface sur laquelle la requête est arrivée; ceci n'est pas renseigné DNSMASQ_INTERFACE contient le nom de l'interface sur laquelle la requête est
dans le cas des actions "old" ayant lieu après un redémarrage de dnsmasq. arrivée; ceci n'est pas renseigné dans le cas des actions "old" ayant lieu
après un redémarrage de dnsmasq. La variable DNSMASQ_RELAY_ADDRESS est
renseignée si le client a utilisé un relai DHCP pour contacter Dnsmasq, si
l'adresse IP du relai est connue. DNSMASQ_TAGS contient tous les labels
d'identifiants de réseau fournis pendant la transaction DHCP, séparés par des
espaces.
Tous les descripteurs de fichiers sont fermés, sauf stdin, stdout et stderr qui Tous les descripteurs de fichiers sont fermés, sauf stdin, stdout et stderr qui
sont ouverts sur /dev/null (sauf en mode déverminage). sont ouverts sur /dev/null (sauf en mode déverminage).
Le script n'est pas lancé de manière concurrente : si un autre changement de Le script n'est pas lancé de manière concurrente : si un autre changement de
@@ -1152,10 +1175,12 @@ Spécifie un fichier de configuration différent. L'option "conf-file" est
également autorisée dans des fichiers de configuration, ce qui permet également autorisée dans des fichiers de configuration, ce qui permet
l'inclusion de multiples fichiers de configuration. l'inclusion de multiples fichiers de configuration.
.TP .TP
.B \-7, --conf-dir=<répertoire> .B \-7, --conf-dir=<répertoire>[,<extension de fichier>...]
Lis tous les fichiers du répertoire spécifié et les traite comme des fichiers de Lis tous les fichiers du répertoire spécifié et les traite comme des fichiers de
configuration. Les fichiers dont les noms se terminent en ~ ou commençant par ., configuration. Si des extensions sont données, tout fichier finissant par ces
ainsi que ceux commençant ou se terminant par # ne sont pas pris en compte. extensions seront ignorés. Tout fichier dont le nom se termine en ~ ou commence
par ., ainsi que ceux commençant ou se terminant par # seront systématiquement
ignorés.
Cette option peut être donnée en ligne de commande ou dans un fichier de Cette option peut être donnée en ligne de commande ou dans un fichier de
configuration. configuration.
.SH FICHIER DE CONFIGURATION .SH FICHIER DE CONFIGURATION
@@ -1411,6 +1436,25 @@ ou d'un fichier d'hôte additionnel. Cette liste peut-être très longue, Dnsmas
ayant été testé avec succès avec un million de noms. Cette taille de fichier ayant été testé avec succès avec un million de noms. Cette taille de fichier
nécessite un processeur à 1 Ghz et environ 60 Mo de RAM. nécessite un processeur à 1 Ghz et environ 60 Mo de RAM.
.SH INTERNATIONALISATION
Dnsmasq peut être compilé pour supporter l'internationalisation. Pour cela,
les cibles "all-i18n" et "install-i18n" doivent être données à make, en lieu
et place des cibles standards "all" et "install". Lorsque compilé avec le
support de l'internationalisation, dnsmasq supporte les noms de domaines
internationalisés ("internationalised domain names" ou IDN), et les messages de
traces ("logs") sont écrits dans la langue locale. Les noms de domaines dans
/etc/hosts, /etc/ethers et /etc/dnsmasq.conf contenant des caractères
non-ASCII seront transformés selon la représentation punycode interne
aux DNS. Veuillez noter que dnsmasq détermine la langue pour les messages
ainsi que le jeu de caractères susceptible d'être utilisé dans les fichiers
de configuration à partir de la variable d'environnement LANG. Ceci devrait
être configuré à la valeur par défaut du système par les scripts démarrant
dnsmasq. Lorsque les fichiers de configuration sont édités, veuillez faire
attention à le faire en utilisant la valeur de locale par défaut du système
et non une valeur spécifique à l'utilisateur, puisque dnsmasq n'a aucun
moyen de déterminer directement la valeur de jeu de caractère utilisé,
et assume de ce fait qu'il s'agit de la valeur par défaut du système.
.SH FICHIERS .SH FICHIERS
.IR /etc/dnsmasq.conf .IR /etc/dnsmasq.conf
+238 -216
View File
File diff suppressed because it is too large. Load diff
+241 -218
View File
File diff suppressed because it is too large. Load diff
+238 -216
View File
File diff suppressed because it is too large. Load diff
+228 -206
View File
File diff suppressed because it is too large. Load diff
+226 -202
View File
File diff suppressed because it is too large. Load diff
+238 -216
View File
File diff suppressed because it is too large. Load diff
+224 -201
View File
File diff suppressed because it is too large. Load diff
+260 -242
View File
File diff suppressed because it is too large. Load diff
+238 -216
View File
File diff suppressed because it is too large. Load diff
+224 -201
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
+20 -17
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -226,7 +226,7 @@ char *cache_get_name(struct crec *crecp)
{ {
if (crecp->flags & F_BIGNAME) if (crecp->flags & F_BIGNAME)
return crecp->name.bname->name; return crecp->name.bname->name;
else if (crecp->flags & F_DHCP) else if (crecp->flags & (F_DHCP | F_CONFIG))
return crecp->name.namep; return crecp->name.namep;
return crecp->name.sname; return crecp->name.sname;
@@ -366,7 +366,7 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
log_query(flags | F_UPSTREAM, name, addr, NULL); log_query(flags | F_UPSTREAM, name, addr, NULL);
/* CONFIG bit no needed except for logging */ /* CONFIG bit means something else when stored in cache entries */
flags &= ~F_CONFIG; flags &= ~F_CONFIG;
/* if previous insertion failed give up now. */ /* if previous insertion failed give up now. */
@@ -693,10 +693,10 @@ static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrl
if (!nameexists) if (!nameexists)
for (a = daemon->cnames; a; a = a->next) for (a = daemon->cnames; a; a = a->next)
if (hostname_isequal(cache->name.sname, a->target) && if (hostname_isequal(cache->name.sname, a->target) &&
(lookup = whine_malloc(sizeof(struct crec) + strlen(a->alias)+1-SMALLDNAME))) (lookup = whine_malloc(sizeof(struct crec))))
{ {
lookup->flags = F_FORWARD | F_IMMORTAL | F_HOSTS | F_CNAME; lookup->flags = F_FORWARD | F_IMMORTAL | F_CONFIG | F_HOSTS | F_CNAME;
strcpy(lookup->name.sname, a->alias); lookup->name.namep = a->alias;
lookup->addr.cname.cache = cache; lookup->addr.cname.cache = cache;
lookup->addr.cname.uid = index; lookup->addr.cname.uid = index;
cache_hash(lookup); cache_hash(lookup);
@@ -821,35 +821,38 @@ static int read_hostsfile(char *filename, int index, int cache_size)
while (atnl == 0) while (atnl == 0)
{ {
struct crec *cache; struct crec *cache;
int fqdn; int fqdn, nomem;
char *canon;
if ((atnl = gettok(f, token)) == EOF) if ((atnl = gettok(f, token)) == EOF)
break; break;
fqdn = !!strchr(token, '.'); fqdn = !!strchr(token, '.');
if (canonicalise(token)) if ((canon = canonicalise(token, &nomem)))
{ {
/* If set, add a version of the name with a default domain appended */ /* If set, add a version of the name with a default domain appended */
if ((daemon->options & OPT_EXPAND) && domain_suffix && !fqdn && if ((daemon->options & OPT_EXPAND) && domain_suffix && !fqdn &&
(cache = whine_malloc(sizeof(struct crec) + (cache = whine_malloc(sizeof(struct crec) +
strlen(token)+2+strlen(domain_suffix)-SMALLDNAME))) strlen(canon)+2+strlen(domain_suffix)-SMALLDNAME)))
{ {
strcpy(cache->name.sname, token); strcpy(cache->name.sname, canon);
strcat(cache->name.sname, "."); strcat(cache->name.sname, ".");
strcat(cache->name.sname, domain_suffix); strcat(cache->name.sname, domain_suffix);
add_hosts_entry(cache, &addr, addrlen, flags, index, addr_dup); add_hosts_entry(cache, &addr, addrlen, flags, index, addr_dup);
addr_dup = 1; addr_dup = 1;
name_count++; name_count++;
} }
if ((cache = whine_malloc(sizeof(struct crec) + strlen(token)+1-SMALLDNAME))) if ((cache = whine_malloc(sizeof(struct crec) + strlen(canon)+1-SMALLDNAME)))
{ {
strcpy(cache->name.sname, token); strcpy(cache->name.sname, canon);
add_hosts_entry(cache, &addr, addrlen, flags, index, addr_dup); add_hosts_entry(cache, &addr, addrlen, flags, index, addr_dup);
name_count++; name_count++;
} }
free(canon);
} }
else else if (!nomem)
my_syslog(LOG_ERR, _("bad name at %s line %d"), filename, lineno); my_syslog(LOG_ERR, _("bad name at %s line %d"), filename, lineno);
} }
} }
@@ -1103,7 +1106,7 @@ void cache_add_dhcp_entry(char *host_name,
if (aliasc) if (aliasc)
{ {
aliasc->flags = F_FORWARD | F_DHCP | F_CNAME; aliasc->flags = F_FORWARD | F_CONFIG | F_DHCP | F_CNAME;
if (ttd == 0) if (ttd == 0)
aliasc->flags |= F_IMMORTAL; aliasc->flags |= F_IMMORTAL;
else else
@@ -1285,12 +1288,12 @@ void log_query(unsigned short flags, char *name, struct all_addr *addr, char *ar
dest = "<CNAME>"; dest = "<CNAME>";
} }
if (flags & F_DHCP) if (flags & F_CONFIG)
source = "config";
else if (flags & F_DHCP)
source = "DHCP"; source = "DHCP";
else if (flags & F_HOSTS) else if (flags & F_HOSTS)
source = arg; source = arg;
else if (flags & F_CONFIG)
source = "config";
else if (flags & F_UPSTREAM) else if (flags & F_UPSTREAM)
source = "reply"; source = "reply";
else if (flags & F_SERVER) else if (flags & F_SERVER)
+24 -7
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -14,17 +14,19 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define VERSION "2.48" #define VERSION "2.52"
#define FTABSIZ 150 /* max number of outstanding requests (default) */ #define FTABSIZ 150 /* max number of outstanding requests (default) */
#define MAX_PROCS 20 /* max no children for TCP requests */ #define MAX_PROCS 20 /* max no children for TCP requests */
#define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */ #define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */
#define EDNS_PKTSZ 1280 /* default max EDNS.0 UDP packet from RFC2671 */ #define EDNS_PKTSZ 4096 /* default max EDNS.0 UDP packet from RFC5625 */
#define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */ #define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
#define FORWARD_TEST 50 /* try all servers every 50 queries */
#define FORWARD_TIME 10 /* or 10 seconds */
#define RANDOM_SOCKS 64 /* max simultaneous random ports */ #define RANDOM_SOCKS 64 /* max simultaneous random ports */
#define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */ #define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
#define CACHESIZ 150 /* default cache size */ #define CACHESIZ 150 /* default cache size */
#define MAXLEASES 150 /* maximum number of DHCP leases */ #define MAXLEASES 1000 /* maximum number of DHCP leases */
#define PING_WAIT 3 /* wait for ping address-in-use test */ #define PING_WAIT 3 /* wait for ping address-in-use test */
#define PING_CACHE_TIME 30 /* Ping test assumed to be valid this long. */ #define PING_CACHE_TIME 30 /* Ping test assumed to be valid this long. */
#define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */ #define DECLINE_BACKOFF 600 /* disable DECLINEd static addresses for this long */
@@ -64,6 +66,7 @@
#define DHCP_CLIENT_PORT 68 #define DHCP_CLIENT_PORT 68
#define DHCP_SERVER_ALTPORT 1067 #define DHCP_SERVER_ALTPORT 1067
#define DHCP_CLIENT_ALTPORT 1068 #define DHCP_CLIENT_ALTPORT 1068
#define PXE_PORT 4011
#define TFTP_PORT 69 #define TFTP_PORT 69
#define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */ #define TFTP_MAX_CONNECTIONS 50 /* max simultaneous connections */
#define LOG_MAX 5 /* log-queue length */ #define LOG_MAX 5 /* log-queue length */
@@ -126,6 +129,9 @@ HAVE_TFTP
HAVE_DHCP HAVE_DHCP
define this to get dnsmasq's DHCP server. define this to get dnsmasq's DHCP server.
HAVE_SCRIPT
define this to get the ability to call scripts on lease-change
HAVE_GETOPT_LONG HAVE_GETOPT_LONG
define this if you have GNU libc or GNU getopt. define this if you have GNU libc or GNU getopt.
@@ -162,6 +168,7 @@ NOTES:
/* platform independent options- uncomment to enable */ /* platform independent options- uncomment to enable */
#define HAVE_DHCP #define HAVE_DHCP
#define HAVE_TFTP #define HAVE_TFTP
#define HAVE_SCRIPT
/* #define HAVE_BROKEN_RTC */ /* #define HAVE_BROKEN_RTC */
/* #define HAVE_DBUS */ /* #define HAVE_DBUS */
@@ -175,6 +182,13 @@ NOTES:
#undef HAVE_DHCP #undef HAVE_DHCP
#endif #endif
/* Allow scripts to be disabled with COPTS=-DNO_SCRIPT */
#ifdef NO_SCRIPT
#undef HAVE_SCRIPT
#endif
/* platform dependent options. */ /* platform dependent options. */
/* Must preceed __linux__ since uClinux defines __linux__ too. */ /* Must preceed __linux__ since uClinux defines __linux__ too. */
@@ -229,7 +243,7 @@ NOTES:
#elif defined(__APPLE__) #elif defined(__APPLE__)
#define HAVE_BSD_NETWORK #define HAVE_BSD_NETWORK
#undef HAVE_GETOPT_LONG #define HAVE_GETOPT_LONG
#define HAVE_ARC4RANDOM #define HAVE_ARC4RANDOM
#define HAVE_SOCKADDR_SA_LEN #define HAVE_SOCKADDR_SA_LEN
/* Define before sys/socket.h is included so we get socklen_t */ /* Define before sys/socket.h is included so we get socklen_t */
@@ -246,8 +260,6 @@ NOTES:
#define HAVE_GETOPT_LONG #define HAVE_GETOPT_LONG
#undef HAVE_ARC4RANDOM #undef HAVE_ARC4RANDOM
#undef HAVE_SOCKADDR_SA_LEN #undef HAVE_SOCKADDR_SA_LEN
#define _XPG4_2
#define __EXTENSIONS__
#define ETHER_ADDR_LEN 6 #define ETHER_ADDR_LEN 6
#endif #endif
@@ -273,3 +285,8 @@ NOTES:
# define ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */ # define ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */
#endif #endif
/* Can't do scripts without fork */
#ifdef NOFORK
# undef HAVE_SCRIPT
#endif
+16 -3
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -390,16 +390,26 @@ void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset)
} }
} }
void emit_dbus_signal(int action, char *mac, char *hostname, char *addr) #ifdef HAVE_DHCP
void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname)
{ {
DBusConnection *connection = (DBusConnection *)daemon->dbus; DBusConnection *connection = (DBusConnection *)daemon->dbus;
DBusMessage* message = NULL; DBusMessage* message = NULL;
DBusMessageIter args; DBusMessageIter args;
const char *action_str; char *action_str, *addr, *mac = daemon->namebuff;
unsigned char *p;
int i;
if (!connection) if (!connection)
return; return;
if (!hostname)
hostname = "";
p = extended_hwaddr(lease->hwaddr_type, lease->hwaddr_len,
lease->hwaddr, lease->clid_len, lease->clid, &i);
print_mac(mac, p, i);
if (action == ACTION_DEL) if (action == ACTION_DEL)
action_str = "DhcpLeaseDeleted"; action_str = "DhcpLeaseDeleted";
else if (action == ACTION_ADD) else if (action == ACTION_ADD)
@@ -409,6 +419,8 @@ void emit_dbus_signal(int action, char *mac, char *hostname, char *addr)
else else
return; return;
addr = inet_ntoa(lease->addr);
if (!(message = dbus_message_new_signal(DNSMASQ_PATH, DNSMASQ_SERVICE, action_str))) if (!(message = dbus_message_new_signal(DNSMASQ_PATH, DNSMASQ_SERVICE, action_str)))
return; return;
@@ -421,5 +433,6 @@ void emit_dbus_signal(int action, char *mac, char *hostname, char *addr)
dbus_message_unref(message); dbus_message_unref(message);
} }
#endif
#endif #endif
+52 -20
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ struct iface_param {
static int complete_context(struct in_addr local, int if_index, static int complete_context(struct in_addr local, int if_index,
struct in_addr netmask, struct in_addr broadcast, void *vparam); struct in_addr netmask, struct in_addr broadcast, void *vparam);
void dhcp_init(void) static int make_fd(int port)
{ {
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
struct sockaddr_in saddr; struct sockaddr_in saddr;
@@ -67,7 +67,7 @@ void dhcp_init(void)
memset(&saddr, 0, sizeof(saddr)); memset(&saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET; saddr.sin_family = AF_INET;
saddr.sin_port = htons(daemon->dhcp_server_port); saddr.sin_port = htons(port);
saddr.sin_addr.s_addr = INADDR_ANY; saddr.sin_addr.s_addr = INADDR_ANY;
#ifdef HAVE_SOCKADDR_SA_LEN #ifdef HAVE_SOCKADDR_SA_LEN
saddr.sin_len = sizeof(struct sockaddr_in); saddr.sin_len = sizeof(struct sockaddr_in);
@@ -76,7 +76,20 @@ void dhcp_init(void)
if (bind(fd, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in))) if (bind(fd, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)))
die(_("failed to bind DHCP server socket: %s"), NULL, EC_BADNET); die(_("failed to bind DHCP server socket: %s"), NULL, EC_BADNET);
daemon->dhcpfd = fd; return fd;
}
void dhcp_init(void)
{
#if defined(HAVE_BSD_NETWORK)
int oneopt = 1;
#endif
daemon->dhcpfd = make_fd(daemon->dhcp_server_port);
if (daemon->enable_pxe)
daemon->pxefd = make_fd(PXE_PORT);
else
daemon->pxefd = -1;
#if defined(HAVE_BSD_NETWORK) #if defined(HAVE_BSD_NETWORK)
/* When we're not using capabilities, we need to do this here before /* When we're not using capabilities, we need to do this here before
@@ -99,8 +112,9 @@ void dhcp_init(void)
daemon->dhcp_packet.iov_base = safe_malloc(daemon->dhcp_packet.iov_len); daemon->dhcp_packet.iov_base = safe_malloc(daemon->dhcp_packet.iov_len);
} }
void dhcp_packet(time_t now) void dhcp_packet(time_t now, int pxe_fd)
{ {
int fd = pxe_fd ? daemon->pxefd : daemon->dhcpfd;
struct dhcp_packet *mess; struct dhcp_packet *mess;
struct dhcp_context *context; struct dhcp_context *context;
struct iname *tmp; struct iname *tmp;
@@ -135,7 +149,7 @@ void dhcp_packet(time_t now)
while (1) while (1)
{ {
msg.msg_flags = 0; msg.msg_flags = 0;
while ((sz = recvmsg(daemon->dhcpfd, &msg, MSG_PEEK | MSG_TRUNC)) == -1 && errno == EINTR); while ((sz = recvmsg(fd, &msg, MSG_PEEK | MSG_TRUNC)) == -1 && errno == EINTR);
if (sz == -1) if (sz == -1)
return; return;
@@ -165,7 +179,7 @@ void dhcp_packet(time_t now)
msg.msg_name = &dest; msg.msg_name = &dest;
msg.msg_namelen = sizeof(dest); msg.msg_namelen = sizeof(dest);
while ((sz = recvmsg(daemon->dhcpfd, &msg, 0)) == -1 && errno == EINTR); while ((sz = recvmsg(fd, &msg, 0)) == -1 && errno == EINTR);
if ((msg.msg_flags & MSG_TRUNC) || sz < (ssize_t)(sizeof(*mess) - sizeof(mess->options))) if ((msg.msg_flags & MSG_TRUNC) || sz < (ssize_t)(sizeof(*mess) - sizeof(mess->options)))
return; return;
@@ -243,7 +257,7 @@ void dhcp_packet(time_t now)
return; return;
lease_prune(NULL, now); /* lose any expired leases */ lease_prune(NULL, now); /* lose any expired leases */
iov.iov_len = dhcp_reply(parm.current, ifr.ifr_name, iface_index, (size_t)sz, iov.iov_len = dhcp_reply(parm.current, ifr.ifr_name, iface_index, (size_t)sz,
now, unicast_dest, &is_inform); now, unicast_dest, &is_inform, pxe_fd);
lease_update_file(now); lease_update_file(now);
lease_update_dns(); lease_update_dns();
@@ -264,7 +278,12 @@ void dhcp_packet(time_t now)
dest.sin_len = sizeof(struct sockaddr_in); dest.sin_len = sizeof(struct sockaddr_in);
#endif #endif
if (mess->giaddr.s_addr) if (pxe_fd)
{
if (mess->ciaddr.s_addr != 0)
dest.sin_addr = mess->ciaddr;
}
else if (mess->giaddr.s_addr)
{ {
/* Send to BOOTP relay */ /* Send to BOOTP relay */
dest.sin_port = htons(daemon->dhcp_server_port); dest.sin_port = htons(daemon->dhcp_server_port);
@@ -348,10 +367,10 @@ void dhcp_packet(time_t now)
#endif #endif
#ifdef HAVE_SOLARIS_NETWORK #ifdef HAVE_SOLARIS_NETWORK
setsockopt(daemon->dhcpfd, IPPROTO_IP, IP_BOUND_IF, &iface_index, sizeof(iface_index)); setsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &iface_index, sizeof(iface_index));
#endif #endif
while(sendmsg(daemon->dhcpfd, &msg, 0) == -1 && retry_send()); while(sendmsg(fd, &msg, 0) == -1 && retry_send());
} }
/* This is a complex routine: it gets called with each (address,netmask,broadcast) triple /* This is a complex routine: it gets called with each (address,netmask,broadcast) triple
@@ -754,6 +773,8 @@ void dhcp_read_ethers(void)
while (fgets(buff, MAXDNAME, f)) while (fgets(buff, MAXDNAME, f))
{ {
char *host = NULL;
lineno++; lineno++;
while (strlen(buff) > 0 && isspace((int)buff[strlen(buff)-1])) while (strlen(buff) > 0 && isspace((int)buff[strlen(buff)-1]))
@@ -792,19 +813,28 @@ void dhcp_read_ethers(void)
} }
else else
{ {
if (!canonicalise(ip)) int nomem;
if (!(host = canonicalise(ip, &nomem)) || !legal_hostname(host))
{ {
my_syslog(MS_DHCP | LOG_ERR, _("bad name at %s line %d"), ETHERSFILE, lineno); if (!nomem)
my_syslog(MS_DHCP | LOG_ERR, _("bad name at %s line %d"), ETHERSFILE, lineno);
free(host);
continue; continue;
} }
flags = CONFIG_NAME; flags = CONFIG_NAME;
for (config = daemon->dhcp_conf; config; config = config->next) for (config = daemon->dhcp_conf; config; config = config->next)
if ((config->flags & CONFIG_NAME) && hostname_isequal(config->hostname, ip)) if ((config->flags & CONFIG_NAME) && hostname_isequal(config->hostname, host))
break; break;
} }
if (config && (config->flags & CONFIG_FROM_ETHERS))
{
my_syslog(MS_DHCP | LOG_ERR, _("ignoring %s line %d, duplicate name or IP address"), ETHERSFILE, lineno);
continue;
}
if (!config) if (!config)
{ {
for (config = daemon->dhcp_conf; config; config = config->next) for (config = daemon->dhcp_conf; config; config = config->next)
@@ -834,10 +864,8 @@ void dhcp_read_ethers(void)
if (flags & CONFIG_NAME) if (flags & CONFIG_NAME)
{ {
if ((config->hostname = whine_malloc(strlen(ip)+1))) config->hostname = host;
strcpy(config->hostname, ip); host = NULL;
else
config->flags &= ~CONFIG_NAME;
} }
if (flags & CONFIG_ADDR) if (flags & CONFIG_ADDR)
@@ -856,6 +884,9 @@ void dhcp_read_ethers(void)
config->hwaddr->next = NULL; config->hwaddr->next = NULL;
} }
count++; count++;
free(host);
} }
fclose(f); fclose(f);
@@ -945,7 +976,8 @@ void dhcp_update_configs(struct dhcp_config *configs)
/* If we've not found a hostname any other way, try and see if there's one in /etc/hosts /* If we've not found a hostname any other way, try and see if there's one in /etc/hosts
for this address. If it has a domain part, that must match the set domain and for this address. If it has a domain part, that must match the set domain and
it gets stripped. */ it gets stripped. The set of legal domain names is bigger than the set of legal hostnames
so check here that the domain name is legal as a hostname. */
char *host_from_dns(struct in_addr addr) char *host_from_dns(struct in_addr addr)
{ {
struct crec *lookup; struct crec *lookup;
@@ -963,7 +995,7 @@ char *host_from_dns(struct in_addr addr)
hostname[255] = 0; hostname[255] = 0;
d1 = strip_hostname(hostname); d1 = strip_hostname(hostname);
d2 = get_domain(addr); d2 = get_domain(addr);
if (d1 && (!d2 || hostname_isequal(d1, d2))) if (!legal_hostname(hostname) || (d1 && (!d2 || !hostname_isequal(d1, d2))))
hostname = NULL; hostname = NULL;
} }
+24 -9
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -45,11 +45,16 @@ static char *compile_opts =
"no-" "no-"
#endif #endif
"DHCP " "DHCP "
#if defined(HAVE_DHCP) && !defined(HAVE_SCRIPT)
"no-scripts "
#endif
#ifndef HAVE_TFTP #ifndef HAVE_TFTP
"no-" "no-"
#endif #endif
"TFTP"; "TFTP";
static volatile pid_t pid = 0; static volatile pid_t pid = 0;
static volatile int pipewrite; static volatile int pipewrite;
@@ -68,7 +73,7 @@ int main (int argc, char **argv)
struct iname *if_tmp; struct iname *if_tmp;
int piperead, pipefd[2], err_pipe[2]; int piperead, pipefd[2], err_pipe[2];
struct passwd *ent_pw = NULL; struct passwd *ent_pw = NULL;
#ifdef HAVE_DHCP #if defined(HAVE_DHCP) && defined(HAVE_SCRIPT)
uid_t script_uid = 0; uid_t script_uid = 0;
gid_t script_gid = 0; gid_t script_gid = 0;
#endif #endif
@@ -202,7 +207,7 @@ int main (int argc, char **argv)
if (daemon->port != 0) if (daemon->port != 0)
pre_allocate_sfds(); pre_allocate_sfds();
#ifdef HAVE_DHCP #if defined(HAVE_DHCP) && defined(HAVE_SCRIPT)
/* Note getpwnam returns static storage */ /* Note getpwnam returns static storage */
if (daemon->dhcp && daemon->lease_change_command && daemon->scriptuser) if (daemon->dhcp && daemon->lease_change_command && daemon->scriptuser)
{ {
@@ -352,7 +357,7 @@ int main (int argc, char **argv)
/* if we are to run scripts, we need to fork a helper before dropping root. */ /* if we are to run scripts, we need to fork a helper before dropping root. */
daemon->helperfd = -1; daemon->helperfd = -1;
#if defined(HAVE_DHCP) && !defined(NO_FORK) #if defined(HAVE_DHCP) && defined(HAVE_SCRIPT)
if (daemon->dhcp && daemon->lease_change_command) if (daemon->dhcp && daemon->lease_change_command)
daemon->helperfd = create_helper(pipewrite, err_pipe[1], script_uid, script_gid, max_fd); daemon->helperfd = create_helper(pipewrite, err_pipe[1], script_uid, script_gid, max_fd);
#endif #endif
@@ -591,6 +596,11 @@ int main (int argc, char **argv)
{ {
FD_SET(daemon->dhcpfd, &rset); FD_SET(daemon->dhcpfd, &rset);
bump_maxfd(daemon->dhcpfd, &maxfd); bump_maxfd(daemon->dhcpfd, &maxfd);
if (daemon->pxefd != -1)
{
FD_SET(daemon->pxefd, &rset);
bump_maxfd(daemon->pxefd, &maxfd);
}
} }
#endif #endif
@@ -603,7 +613,7 @@ int main (int argc, char **argv)
bump_maxfd(piperead, &maxfd); bump_maxfd(piperead, &maxfd);
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
# ifdef NO_FORK # ifdef HAVE_SCRIPT
while (helper_buf_empty() && do_script_run(now)); while (helper_buf_empty() && do_script_run(now));
if (!helper_buf_empty()) if (!helper_buf_empty())
@@ -671,10 +681,15 @@ int main (int argc, char **argv)
#endif #endif
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
if (daemon->dhcp && FD_ISSET(daemon->dhcpfd, &rset)) if (daemon->dhcp)
dhcp_packet(now); {
if (FD_ISSET(daemon->dhcpfd, &rset))
dhcp_packet(now, 0);
if (daemon->pxefd != -1 && FD_ISSET(daemon->pxefd, &rset))
dhcp_packet(now, 1);
}
# ifndef NO_FORK # ifdef HAVE_SCRIPT
if (daemon->helperfd != -1 && FD_ISSET(daemon->helperfd, &wset)) if (daemon->helperfd != -1 && FD_ISSET(daemon->helperfd, &wset))
helper_write(); helper_write();
# endif # endif
@@ -857,7 +872,7 @@ static void async_event(int pipe, time_t now)
if (daemon->tcp_pids[i] != 0) if (daemon->tcp_pids[i] != 0)
kill(daemon->tcp_pids[i], SIGALRM); kill(daemon->tcp_pids[i], SIGALRM);
#if defined(HAVE_DHCP) && !defined(NO_FORK) #if defined(HAVE_DHCP) && defined(HAVE_SCRIPT)
/* handle pending lease transitions */ /* handle pending lease transitions */
if (daemon->helperfd != -1) if (daemon->helperfd != -1)
{ {
+31 -14
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define COPYRIGHT "Copyright (C) 2000-2009 Simon Kelley" #define COPYRIGHT "Copyright (c) 2000-2010 Simon Kelley"
#ifndef NO_LARGEFILE #ifndef NO_LARGEFILE
/* Ensure we can use files >2GB (log files may grow this big) */ /* Ensure we can use files >2GB (log files may grow this big) */
@@ -28,8 +28,15 @@
# include <features.h> # include <features.h>
#endif #endif
/* Need these defined early */
#if defined(__sun) || defined(__sun__)
# define _XPG4_2
# define __EXTENSIONS__
#endif
/* get these before config.h for IPv6 stuff... */ /* get these before config.h for IPv6 stuff... */
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#ifdef __APPLE__ #ifdef __APPLE__
@@ -55,10 +62,9 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/socket.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#if defined(HAVE_SOLARIS_NETWORK) #if defined(HAVE_SOLARIS_NETWORK)
#include <sys/sockio.h> # include <sys/sockio.h>
#endif #endif
#include <sys/select.h> #include <sys/select.h>
#include <sys/wait.h> #include <sys/wait.h>
@@ -66,6 +72,10 @@
#include <sys/un.h> #include <sys/un.h>
#include <limits.h> #include <limits.h>
#include <net/if.h> #include <net/if.h>
#if defined(HAVE_SOLARIS_NETWORK) && !defined(ifr_mtu)
/* Some solaris net/if./h omit this. */
# define ifr_mtu ifr_ifru.ifru_metric
#endif
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -335,7 +345,7 @@ struct server {
struct irec { struct irec {
union mysockaddr addr; union mysockaddr addr;
struct in_addr netmask; /* only valid for IPv4 */ struct in_addr netmask; /* only valid for IPv4 */
int dhcp_ok; int dhcp_ok, mtu;
struct irec *next; struct irec *next;
}; };
@@ -410,9 +420,9 @@ struct dhcp_lease {
#endif #endif
int hwaddr_len, hwaddr_type; int hwaddr_len, hwaddr_type;
unsigned char hwaddr[DHCP_CHADDR_MAX]; unsigned char hwaddr[DHCP_CHADDR_MAX];
struct in_addr addr, override; struct in_addr addr, override, giaddr;
unsigned char *vendorclass, *userclass; unsigned char *extradata;
unsigned int vendorclass_len, userclass_len; unsigned int extradata_len, extradata_size;
int last_interface; int last_interface;
struct dhcp_lease *next; struct dhcp_lease *next;
}; };
@@ -482,6 +492,7 @@ struct dhcp_opt {
#define DHOPT_VENDOR 256 #define DHOPT_VENDOR 256
#define DHOPT_HEX 512 #define DHOPT_HEX 512
#define DHOPT_VENDOR_MATCH 1024 #define DHOPT_VENDOR_MATCH 1024
#define DHOPT_RFC3925 2048
struct dhcp_boot { struct dhcp_boot {
char *file, *sname; char *file, *sname;
@@ -626,6 +637,7 @@ extern struct daemon {
struct dhcp_mac *dhcp_macs; struct dhcp_mac *dhcp_macs;
struct dhcp_boot *boot_config; struct dhcp_boot *boot_config;
struct pxe_service *pxe_services; struct pxe_service *pxe_services;
int enable_pxe;
struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *force_broadcast, *bootp_dynamic; struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *force_broadcast, *bootp_dynamic;
char *dhcp_hosts_file, *dhcp_opts_file; char *dhcp_hosts_file, *dhcp_opts_file;
int dhcp_max, tftp_max; int dhcp_max, tftp_max;
@@ -646,14 +658,17 @@ extern struct daemon {
struct irec *interfaces; struct irec *interfaces;
struct listener *listeners; struct listener *listeners;
struct server *last_server; struct server *last_server;
time_t forwardtime;
int forwardcount;
struct server *srv_save; /* Used for resend on DoD */ struct server *srv_save; /* Used for resend on DoD */
size_t packet_len; /* " " */ size_t packet_len; /* " " */
struct randfd *rfd_save; /* " " */ struct randfd *rfd_save; /* " " */
pid_t tcp_pids[MAX_PROCS]; pid_t tcp_pids[MAX_PROCS];
struct randfd randomsocks[RANDOM_SOCKS]; struct randfd randomsocks[RANDOM_SOCKS];
int v6pktinfo;
/* DHCP state */ /* DHCP state */
int dhcpfd, helperfd; int dhcpfd, helperfd, pxefd;
#if defined(HAVE_LINUX_NETWORK) #if defined(HAVE_LINUX_NETWORK)
int netlinkfd; int netlinkfd;
#elif defined(HAVE_BSD_NETWORK) #elif defined(HAVE_BSD_NETWORK)
@@ -719,8 +734,8 @@ size_t resize_packet(HEADER *header, size_t plen,
/* util.c */ /* util.c */
void rand_init(void); void rand_init(void);
unsigned short rand16(void); unsigned short rand16(void);
int legal_char(char c); int legal_hostname(char *c);
int canonicalise(char *s); char *canonicalise(char *s, int *nomem);
unsigned char *do_rfc1035_name(unsigned char *p, char *sval); unsigned char *do_rfc1035_name(unsigned char *p, char *sval);
void *safe_malloc(size_t size); void *safe_malloc(size_t size);
void safe_pipe(int *fd, int read_noblock); void safe_pipe(int *fd, int read_noblock);
@@ -781,7 +796,7 @@ struct in_addr get_ifaddr(char *intr);
/* dhcp.c */ /* dhcp.c */
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
void dhcp_init(void); void dhcp_init(void);
void dhcp_packet(time_t now); void dhcp_packet(time_t now, int pxe_fd);
struct dhcp_context *address_available(struct dhcp_context *context, struct dhcp_context *address_available(struct dhcp_context *context,
struct in_addr addr, struct in_addr addr,
struct dhcp_netid *netids); struct dhcp_netid *netids);
@@ -829,7 +844,7 @@ void rerun_scripts(void);
/* rfc2131.c */ /* rfc2131.c */
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
size_t sz, time_t now, int unicast_dest, int *is_inform); size_t sz, time_t now, int unicast_dest, int *is_inform, int pxe_fd);
unsigned char *extended_hwaddr(int hwtype, int hwlen, unsigned char *hwaddr, unsigned char *extended_hwaddr(int hwtype, int hwlen, unsigned char *hwaddr,
int clid_len, unsigned char *clid, int *len_out); int clid_len, unsigned char *clid, int *len_out);
#endif #endif
@@ -863,7 +878,9 @@ int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)());
char *dbus_init(void); char *dbus_init(void);
void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset); void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset);
void set_dbus_listeners(int *maxfdp, fd_set *rset, fd_set *wset, fd_set *eset); void set_dbus_listeners(int *maxfdp, fd_set *rset, fd_set *wset, fd_set *eset);
void emit_dbus_signal(int action, char *mac, char *hostname, char *addr); # ifdef HAVE_DHCP
void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname);
# endif
#endif #endif
/* helper.c */ /* helper.c */
+13 -23
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@ static struct frec *lookup_frec(unsigned short id, unsigned int crc);
static struct frec *lookup_frec_by_sender(unsigned short id, static struct frec *lookup_frec_by_sender(unsigned short id,
union mysockaddr *addr, union mysockaddr *addr,
unsigned int crc); unsigned int crc);
static unsigned short get_id(int force, unsigned short force_id, unsigned int crc); static unsigned short get_id(unsigned int crc);
static void free_frec(struct frec *f); static void free_frec(struct frec *f);
static struct randfd *allocate_rfd(int family); static struct randfd *allocate_rfd(int family);
@@ -86,7 +86,7 @@ static void send_from(int fd, int nowild, char *packet, size_t len,
pkt->ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */ pkt->ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */
pkt->ipi6_addr = source->addr.addr6; pkt->ipi6_addr = source->addr.addr6;
msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo)); msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
cmptr->cmsg_type = IPV6_PKTINFO; cmptr->cmsg_type = daemon->v6pktinfo;
cmptr->cmsg_level = IPV6_LEVEL; cmptr->cmsg_level = IPV6_LEVEL;
} }
#else #else
@@ -242,15 +242,11 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
if (forward) if (forward)
{ {
/* force unchanging id for signed packets */
int is_sign;
find_pseudoheader(header, plen, NULL, NULL, &is_sign);
forward->source = *udpaddr; forward->source = *udpaddr;
forward->dest = *dst_addr; forward->dest = *dst_addr;
forward->iface = dst_iface; forward->iface = dst_iface;
forward->orig_id = ntohs(header->id); forward->orig_id = ntohs(header->id);
forward->new_id = get_id(is_sign, forward->orig_id, crc); forward->new_id = get_id(crc);
forward->fd = udpfd; forward->fd = udpfd;
forward->crc = crc; forward->crc = crc;
forward->forwardall = 0; forward->forwardall = 0;
@@ -262,10 +258,14 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
if (type != 0 || (daemon->options & OPT_ORDER)) if (type != 0 || (daemon->options & OPT_ORDER))
start = daemon->servers; start = daemon->servers;
else if (!(start = daemon->last_server)) else if (!(start = daemon->last_server) ||
daemon->forwardcount++ > FORWARD_TEST ||
difftime(now, daemon->forwardtime) > FORWARD_TIME)
{ {
start = daemon->servers; start = daemon->servers;
forward->forwardall = 1; forward->forwardall = 1;
daemon->forwardcount = 0;
daemon->forwardtime = now;
} }
} }
} }
@@ -657,7 +657,7 @@ void receive_query(struct listener *listen, time_t now)
if (listen->family == AF_INET6) if (listen->family == AF_INET6)
{ {
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr)) for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
if (cmptr->cmsg_level == IPV6_LEVEL && cmptr->cmsg_type == IPV6_PKTINFO) if (cmptr->cmsg_level == IPV6_LEVEL && cmptr->cmsg_type == daemon->v6pktinfo)
{ {
dst_addr.addr.addr6 = ((struct in6_pktinfo *)CMSG_DATA(cmptr))->ipi6_addr; dst_addr.addr.addr6 = ((struct in6_pktinfo *)CMSG_DATA(cmptr))->ipi6_addr;
if_index =((struct in6_pktinfo *)CMSG_DATA(cmptr))->ipi6_ifindex; if_index =((struct in6_pktinfo *)CMSG_DATA(cmptr))->ipi6_ifindex;
@@ -1062,22 +1062,12 @@ void server_gone(struct server *server)
daemon->srv_save = NULL; daemon->srv_save = NULL;
} }
/* return unique random ids. /* return unique random ids. */
For signed packets we can't change the ID without breaking the static unsigned short get_id(unsigned int crc)
signing, so we keep the same one. In this case force is set, and this
routine degenerates into killing any conflicting forward record. */
static unsigned short get_id(int force, unsigned short force_id, unsigned int crc)
{ {
unsigned short ret = 0; unsigned short ret = 0;
if (force) do
{
struct frec *f = lookup_frec(force_id, crc);
if (f)
free_frec(f); /* free */
ret = force_id;
}
else do
ret = rand16(); ret = rand16();
while (lookup_frec(ret, crc)); while (lookup_frec(ret, crc));
+79 -86
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -28,15 +28,16 @@
main process. main process.
*/ */
#if defined(HAVE_DHCP) && !defined(NO_FORK) #if defined(HAVE_DHCP) && defined(HAVE_SCRIPT)
static void my_setenv(const char *name, const char *value, int *error); static void my_setenv(const char *name, const char *value, int *error);
static unsigned char *grab_extradata(unsigned char *buf, unsigned char *end, char *env, int *err);
struct script_data struct script_data
{ {
unsigned char action, hwaddr_len, hwaddr_type; unsigned char action, hwaddr_len, hwaddr_type;
unsigned char clid_len, hostname_len, uclass_len, vclass_len; unsigned char clid_len, hostname_len, ed_len;
struct in_addr addr; struct in_addr addr, giaddr;
unsigned int remaining_time; unsigned int remaining_time;
#ifdef HAVE_BROKEN_RTC #ifdef HAVE_BROKEN_RTC
unsigned int length; unsigned int length;
@@ -101,7 +102,7 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
/* close all the sockets etc, we don't need them here. This closes err_fd, so that /* close all the sockets etc, we don't need them here. This closes err_fd, so that
main process can return. */ main process can return. */
for (max_fd--; max_fd > 0; max_fd--) for (max_fd--; max_fd >= 0; max_fd--)
if (max_fd != STDOUT_FILENO && max_fd != STDERR_FILENO && if (max_fd != STDOUT_FILENO && max_fd != STDERR_FILENO &&
max_fd != STDIN_FILENO && max_fd != pipefd[0] && max_fd != event_fd) max_fd != STDIN_FILENO && max_fd != pipefd[0] && max_fd != event_fd)
close(max_fd); close(max_fd);
@@ -112,6 +113,7 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
struct script_data data; struct script_data data;
char *p, *action_str, *hostname = NULL; char *p, *action_str, *hostname = NULL;
unsigned char *buf = (unsigned char *)daemon->namebuff; unsigned char *buf = (unsigned char *)daemon->namebuff;
unsigned char *end, *alloc_buff = NULL;
int err = 0; int err = 0;
/* we read zero bytes when pipe closed: this is our signal to exit */ /* we read zero bytes when pipe closed: this is our signal to exit */
@@ -138,8 +140,8 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
p += sprintf(p, ":"); p += sprintf(p, ":");
} }
/* and CLID into packet */ /* and CLID into packet, avoid overwrite from bad data */
if (!read_write(pipefd[0], buf, data.clid_len, 1)) if ((data.clid_len > daemon->packet_buff_sz) || !read_write(pipefd[0], buf, data.clid_len, 1))
continue; continue;
for (p = daemon->packet, i = 0; i < data.clid_len; i++) for (p = daemon->packet, i = 0; i < data.clid_len; i++)
{ {
@@ -150,18 +152,26 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
/* and expiry or length into dhcp_buff2 */ /* and expiry or length into dhcp_buff2 */
#ifdef HAVE_BROKEN_RTC #ifdef HAVE_BROKEN_RTC
sprintf(daemon->dhcp_buff2, "%u ", data.length); sprintf(daemon->dhcp_buff2, "%u", data.length);
#else #else
sprintf(daemon->dhcp_buff2, "%lu ", (unsigned long)data.expires); sprintf(daemon->dhcp_buff2, "%lu", (unsigned long)data.expires);
#endif #endif
if (!read_write(pipefd[0], buf, data.hostname_len + data.uclass_len + data.vclass_len, 1)) /* supplied data may just exceed normal buffer (unlikely) */
if ((data.hostname_len + data.ed_len) > daemon->packet_buff_sz &&
!(alloc_buff = buf = malloc(data.hostname_len + data.ed_len)))
continue;
if (!read_write(pipefd[0], buf,
data.hostname_len + data.ed_len, 1))
continue; continue;
/* possible fork errors are all temporary resource problems */ /* possible fork errors are all temporary resource problems */
while ((pid = fork()) == -1 && (errno == EAGAIN || errno == ENOMEM)) while ((pid = fork()) == -1 && (errno == EAGAIN || errno == ENOMEM))
sleep(2); sleep(2);
free(alloc_buff);
if (pid == -1) if (pid == -1)
continue; continue;
@@ -203,52 +213,41 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
my_setenv("DNSMASQ_LEASE_EXPIRES", daemon->dhcp_buff2, &err); my_setenv("DNSMASQ_LEASE_EXPIRES", daemon->dhcp_buff2, &err);
#endif #endif
if (data.vclass_len != 0)
{
buf[data.vclass_len - 1] = 0; /* don't trust zero-term */
/* cannot have = chars in env - truncate if found . */
if ((p = strchr((char *)buf, '=')))
*p = 0;
my_setenv("DNSMASQ_VENDOR_CLASS", (char *)buf, &err);
buf += data.vclass_len;
}
if (data.uclass_len != 0)
{
unsigned char *end = buf + data.uclass_len;
buf[data.uclass_len - 1] = 0; /* don't trust zero-term */
for (i = 0; buf < end;)
{
size_t len = strlen((char *)buf) + 1;
if ((p = strchr((char *)buf, '=')))
*p = 0;
if (strlen((char *)buf) != 0)
{
sprintf(daemon->dhcp_buff2, "DNSMASQ_USER_CLASS%i", i++);
my_setenv(daemon->dhcp_buff2, (char *)buf, &err);
}
buf += len;
}
}
sprintf(daemon->dhcp_buff2, "%u ", data.remaining_time);
my_setenv("DNSMASQ_TIME_REMAINING", daemon->dhcp_buff2, &err);
if (data.hostname_len != 0) if (data.hostname_len != 0)
{ {
char *dot; char *dot;
hostname = (char *)buf; hostname = (char *)buf;
hostname[data.hostname_len - 1] = 0; hostname[data.hostname_len - 1] = 0;
if (!canonicalise(hostname)) if (!legal_hostname(hostname))
hostname = NULL; hostname = NULL;
else if ((dot = strchr(hostname, '.'))) else if ((dot = strchr(hostname, '.')))
{ {
my_setenv("DNSMASQ_DOMAIN", dot+1, &err); my_setenv("DNSMASQ_DOMAIN", dot+1, &err);
*dot = 0; *dot = 0;
} }
buf += data.hostname_len;
} }
end = buf + data.ed_len;
buf = grab_extradata(buf, end, "DNSMASQ_VENDOR_CLASS", &err);
buf = grab_extradata(buf, end, "DNSMASQ_SUPPLIED_HOSTNAME", &err);
buf = grab_extradata(buf, end, "DNSMASQ_CPEWAN_OUI", &err);
buf = grab_extradata(buf, end, "DNSMASQ_CPEWAN_SERIAL", &err);
buf = grab_extradata(buf, end, "DNSMASQ_CPEWAN_CLASS", &err);
buf = grab_extradata(buf, end, "DNSMASQ_TAGS", &err);
for (i = 0; buf; i++)
{
sprintf(daemon->dhcp_buff2, "DNSMASQ_USER_CLASS%i", i);
buf = grab_extradata(buf, end, daemon->dhcp_buff2, &err);
}
if (data.giaddr.s_addr != 0)
my_setenv("DNSMASQ_RELAY_ADDRESS", inet_ntoa(data.giaddr), &err);
sprintf(daemon->dhcp_buff2, "%u", data.remaining_time);
my_setenv("DNSMASQ_TIME_REMAINING", daemon->dhcp_buff2, &err);
if (data.action == ACTION_OLD_HOSTNAME && hostname) if (data.action == ACTION_OLD_HOSTNAME && hostname)
{ {
my_setenv("DNSMASQ_OLD_HOSTNAME", hostname, &err); my_setenv("DNSMASQ_OLD_HOSTNAME", hostname, &err);
@@ -280,35 +279,48 @@ static void my_setenv(const char *name, const char *value, int *error)
*error = errno; *error = errno;
} }
static unsigned char *grab_extradata(unsigned char *buf, unsigned char *end, char *env, int *err)
{
unsigned char *next;
if (!buf || (buf == end))
return NULL;
for (next = buf; *next != 0; next++)
if (next == end)
return NULL;
if (next != buf)
{
char *p;
/* No "=" in value */
if ((p = strchr((char *)buf, '=')))
*p = 0;
my_setenv(env, (char *)buf, err);
}
return next + 1;
}
/* pack up lease data into a buffer */ /* pack up lease data into a buffer */
void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t now) void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t now)
{ {
unsigned char *p; unsigned char *p;
size_t size; size_t size;
int i; unsigned int hostname_len = 0, clid_len = 0, ed_len = 0;
unsigned int hostname_len = 0, clid_len = 0, vclass_len = 0, uclass_len = 0;
#ifdef HAVE_DBUS
p = extended_hwaddr(lease->hwaddr_type, lease->hwaddr_len,
lease->hwaddr, lease->clid_len, lease->clid, &i);
print_mac(daemon->namebuff, p, i);
emit_dbus_signal(action, daemon->namebuff, hostname ? hostname : "", inet_ntoa(lease->addr));
#endif
/* no script */ /* no script */
if (daemon->helperfd == -1) if (daemon->helperfd == -1)
return; return;
if (lease->vendorclass) if (lease->extradata)
vclass_len = lease->vendorclass_len; ed_len = lease->extradata_len;
if (lease->userclass)
uclass_len = lease->userclass_len;
if (lease->clid) if (lease->clid)
clid_len = lease->clid_len; clid_len = lease->clid_len;
if (hostname) if (hostname)
hostname_len = strlen(hostname) + 1; hostname_len = strlen(hostname) + 1;
size = sizeof(struct script_data) + clid_len + vclass_len + uclass_len + hostname_len; size = sizeof(struct script_data) + clid_len + ed_len + hostname_len;
if (size > buf_size) if (size > buf_size)
{ {
@@ -330,24 +342,13 @@ void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t n
buf->hwaddr_len = lease->hwaddr_len; buf->hwaddr_len = lease->hwaddr_len;
buf->hwaddr_type = lease->hwaddr_type; buf->hwaddr_type = lease->hwaddr_type;
buf->clid_len = clid_len; buf->clid_len = clid_len;
buf->vclass_len = vclass_len; buf->ed_len = ed_len;
buf->uclass_len = uclass_len;
buf->hostname_len = hostname_len; buf->hostname_len = hostname_len;
buf->addr = lease->addr; buf->addr = lease->addr;
buf->giaddr = lease->giaddr;
memcpy(buf->hwaddr, lease->hwaddr, lease->hwaddr_len); memcpy(buf->hwaddr, lease->hwaddr, lease->hwaddr_len);
buf->interface[0] = 0; if (!indextoname(daemon->dhcpfd, lease->last_interface, buf->interface))
#ifdef HAVE_LINUX_NETWORK buf->interface[0] = 0;
if (lease->last_interface != 0)
{
struct ifreq ifr;
ifr.ifr_ifindex = lease->last_interface;
if (ioctl(daemon->dhcpfd, SIOCGIFNAME, &ifr) != -1)
strncpy(buf->interface, ifr.ifr_name, IF_NAMESIZE);
}
#else
if (lease->last_interface != 0)
if_indextoname(lease->last_interface, buf->interface);
#endif
#ifdef HAVE_BROKEN_RTC #ifdef HAVE_BROKEN_RTC
buf->length = lease->length; buf->length = lease->length;
@@ -362,24 +363,16 @@ void queue_script(int action, struct dhcp_lease *lease, char *hostname, time_t n
memcpy(p, lease->clid, clid_len); memcpy(p, lease->clid, clid_len);
p += clid_len; p += clid_len;
} }
if (vclass_len != 0) if (hostname_len != 0)
{ {
memcpy(p, lease->vendorclass, vclass_len); memcpy(p, hostname, hostname_len);
p += vclass_len; p += hostname_len;
} }
if (uclass_len != 0) if (ed_len != 0)
{ {
memcpy(p, lease->userclass, uclass_len); memcpy(p, lease->extradata, ed_len);
p += uclass_len; p += ed_len;
} }
/* substitute * for space: spaces are allowed in hostnames (for DNS-SD)
and are likley to be a security hole in most scripts. */
for (i = 0; i < (int)hostname_len; i++)
if ((daemon->options & OPT_LEASE_RO) && hostname[i] == ' ')
*(p++) = '*';
else
*(p++) = hostname[i];
bytes_in_buf = p - (unsigned char *)buf; bytes_in_buf = p - (unsigned char *)buf;
} }
+32 -35
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -42,14 +42,20 @@ void lease_init(time_t now)
initial state of the database. If leasefile-ro is initial state of the database. If leasefile-ro is
set without a script, we just do without any set without a script, we just do without any
lease database. */ lease database. */
if (!daemon->lease_change_command) #ifdef HAVE_SCRIPT
if (daemon->lease_change_command)
{ {
file_dirty = dns_dirty = 0; strcpy(daemon->dhcp_buff, daemon->lease_change_command);
return; strcat(daemon->dhcp_buff, " init");
leasestream = popen(daemon->dhcp_buff, "r");
} }
strcpy(daemon->dhcp_buff, daemon->lease_change_command); else
strcat(daemon->dhcp_buff, " init"); #endif
leasestream = popen(daemon->dhcp_buff, "r"); {
file_dirty = dns_dirty = 0;
return;
}
} }
else else
{ {
@@ -100,19 +106,14 @@ void lease_init(time_t now)
lease_set_hwaddr(lease, (unsigned char *)daemon->dhcp_buff2, (unsigned char *)daemon->packet, hw_len, hw_type, clid_len); lease_set_hwaddr(lease, (unsigned char *)daemon->dhcp_buff2, (unsigned char *)daemon->packet, hw_len, hw_type, clid_len);
if (strcmp(daemon->dhcp_buff, "*") != 0) if (strcmp(daemon->dhcp_buff, "*") != 0)
{ lease_set_hostname(lease, daemon->dhcp_buff, 0);
char *p;
/* unprotect spaces */
for (p = strchr(daemon->dhcp_buff, '*'); p; p = strchr(p, '*'))
*p = ' ';
lease_set_hostname(lease, daemon->dhcp_buff, 0);
}
/* set these correctly: the "old" events are generated later from /* set these correctly: the "old" events are generated later from
the startup synthesised SIGHUP. */ the startup synthesised SIGHUP. */
lease->new = lease->changed = 0; lease->new = lease->changed = 0;
} }
#ifdef HAVE_SCRIPT
if (!daemon->lease_stream) if (!daemon->lease_stream)
{ {
int rc = 0; int rc = 0;
@@ -133,6 +134,7 @@ void lease_init(time_t now)
die(_("lease-init script returned exit code %s"), daemon->dhcp_buff, WEXITSTATUS(rc) + EC_INIT_OFFSET); die(_("lease-init script returned exit code %s"), daemon->dhcp_buff, WEXITSTATUS(rc) + EC_INIT_OFFSET);
} }
} }
#endif
/* Some leases may have expired */ /* Some leases may have expired */
file_dirty = 0; file_dirty = 0;
@@ -173,7 +175,6 @@ void lease_update_file(time_t now)
struct dhcp_lease *lease; struct dhcp_lease *lease;
time_t next_event; time_t next_event;
int i, err = 0; int i, err = 0;
char *p;
if (file_dirty != 0 && daemon->lease_stream) if (file_dirty != 0 && daemon->lease_stream)
{ {
@@ -199,14 +200,7 @@ void lease_update_file(time_t now)
} }
ourprintf(&err, " %s ", inet_ntoa(lease->addr)); ourprintf(&err, " %s ", inet_ntoa(lease->addr));
ourprintf(&err, "%s ", lease->hostname ? lease->hostname : "*");
/* substitute * for space: "*" is an illegal name, as is " " */
if (lease->hostname)
for (p = lease->hostname; *p; p++)
ourprintf(&err, "%c", *p == ' ' ? '*' : *p);
else
ourprintf(&err, "*");
ourprintf(&err, " ");
if (lease->clid && lease->clid_len != 0) if (lease->clid && lease->clid_len != 0)
{ {
@@ -550,7 +544,7 @@ int do_script_run(time_t now)
/* If the lease still has an old_hostname, do the "old" action on that first */ /* If the lease still has an old_hostname, do the "old" action on that first */
if (lease->old_hostname) if (lease->old_hostname)
{ {
#ifndef NO_FORK #ifdef HAVE_SCRIPT
queue_script(ACTION_OLD_HOSTNAME, lease, lease->old_hostname, now); queue_script(ACTION_OLD_HOSTNAME, lease, lease->old_hostname, now);
#endif #endif
free(lease->old_hostname); free(lease->old_hostname);
@@ -560,15 +554,17 @@ int do_script_run(time_t now)
else else
{ {
kill_name(lease); kill_name(lease);
#ifndef NO_FORK #ifdef HAVE_SCRIPT
queue_script(ACTION_DEL, lease, lease->old_hostname, now); queue_script(ACTION_DEL, lease, lease->old_hostname, now);
#endif
#ifdef HAVE_DBUS
emit_dbus_signal(ACTION_DEL, lease, lease->old_hostname);
#endif #endif
old_leases = lease->next; old_leases = lease->next;
free(lease->old_hostname); free(lease->old_hostname);
free(lease->clid); free(lease->clid);
free(lease->vendorclass); free(lease->extradata);
free(lease->userclass);
free(lease); free(lease);
return 1; return 1;
@@ -579,7 +575,7 @@ int do_script_run(time_t now)
for (lease = leases; lease; lease = lease->next) for (lease = leases; lease; lease = lease->next)
if (lease->old_hostname) if (lease->old_hostname)
{ {
#ifndef NO_FORK #ifdef HAVE_SCRIPT
queue_script(ACTION_OLD_HOSTNAME, lease, lease->old_hostname, now); queue_script(ACTION_OLD_HOSTNAME, lease, lease->old_hostname, now);
#endif #endif
free(lease->old_hostname); free(lease->old_hostname);
@@ -591,18 +587,19 @@ int do_script_run(time_t now)
if (lease->new || lease->changed || if (lease->new || lease->changed ||
(lease->aux_changed && (daemon->options & OPT_LEASE_RO))) (lease->aux_changed && (daemon->options & OPT_LEASE_RO)))
{ {
#ifndef NO_FORK #ifdef HAVE_SCRIPT
queue_script(lease->new ? ACTION_ADD : ACTION_OLD, lease, queue_script(lease->new ? ACTION_ADD : ACTION_OLD, lease,
lease->fqdn ? lease->fqdn : lease->hostname, now); lease->fqdn ? lease->fqdn : lease->hostname, now);
#endif
#ifdef HAVE_DBUS
emit_dbus_signal(lease->new ? ACTION_ADD : ACTION_OLD, lease,
lease->fqdn ? lease->fqdn : lease->hostname);
#endif #endif
lease->new = lease->changed = lease->aux_changed = 0; lease->new = lease->changed = lease->aux_changed = 0;
/* these are used for the "add" call, then junked, since they're not in the database */ /* this is used for the "add" call, then junked, since they're not in the database */
free(lease->vendorclass); free(lease->extradata);
lease->vendorclass = NULL; lease->extradata = NULL;
free(lease->userclass);
lease->userclass = NULL;
return 1; return 1;
} }
+6 -1
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -267,7 +267,12 @@ void my_syslog(int priority, const char *format, ...)
else if ((LOG_FACMASK & priority) == MS_DHCP) else if ((LOG_FACMASK & priority) == MS_DHCP)
func = "-dhcp"; func = "-dhcp";
#ifdef LOG_PRI
priority = LOG_PRI(priority); priority = LOG_PRI(priority);
#else
/* Solaris doesn't have LOG_PRI */
priority &= LOG_PRIMASK;
#endif
if (log_stderr) if (log_stderr)
{ {
+1 -1
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
+39 -10
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -119,7 +119,7 @@ static int iface_allowed(struct irec **irecp, int if_index,
union mysockaddr *addr, struct in_addr netmask) union mysockaddr *addr, struct in_addr netmask)
{ {
struct irec *iface; struct irec *iface;
int fd; int fd, mtu = 0, loopback;
struct ifreq ifr; struct ifreq ifr;
int dhcp_ok = 1; int dhcp_ok = 1;
struct iname *tmp; struct iname *tmp;
@@ -143,11 +143,16 @@ static int iface_allowed(struct irec **irecp, int if_index,
return 0; return 0;
} }
loopback = ifr.ifr_flags & IFF_LOOPBACK;
if (ioctl(fd, SIOCGIFMTU, &ifr) != -1)
mtu = ifr.ifr_mtu;
close(fd); close(fd);
/* If we are restricting the set of interfaces to use, make /* If we are restricting the set of interfaces to use, make
sure that loopback interfaces are in that set. */ sure that loopback interfaces are in that set. */
if (daemon->if_names && (ifr.ifr_flags & IFF_LOOPBACK)) if (daemon->if_names && loopback)
{ {
struct iname *lo; struct iname *lo;
for (lo = daemon->if_names; lo; lo = lo->next) for (lo = daemon->if_names; lo; lo = lo->next)
@@ -188,6 +193,7 @@ static int iface_allowed(struct irec **irecp, int if_index,
iface->addr = *addr; iface->addr = *addr;
iface->netmask = netmask; iface->netmask = netmask;
iface->dhcp_ok = dhcp_ok; iface->dhcp_ok = dhcp_ok;
iface->mtu = mtu;
iface->next = *irecp; iface->next = *irecp;
*irecp = iface; *irecp = iface;
return 1; return 1;
@@ -288,16 +294,35 @@ static int create_ipv6_listener(struct listener **link, int port)
setsockopt(tcpfd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 || setsockopt(tcpfd, IPV6_LEVEL, IPV6_V6ONLY, &opt, sizeof(opt)) == -1 ||
!fix_fd(fd) || !fix_fd(fd) ||
!fix_fd(tcpfd) || !fix_fd(tcpfd) ||
#ifdef IPV6_RECVPKTINFO
setsockopt(fd, IPV6_LEVEL, IPV6_RECVPKTINFO, &opt, sizeof(opt)) == -1 ||
#else
setsockopt(fd, IPV6_LEVEL, IPV6_PKTINFO, &opt, sizeof(opt)) == -1 ||
#endif
bind(tcpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1 || bind(tcpfd, (struct sockaddr *)&addr, sa_len(&addr)) == -1 ||
listen(tcpfd, 5) == -1 || listen(tcpfd, 5) == -1 ||
bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == -1) bind(fd, (struct sockaddr *)&addr, sa_len(&addr)) == -1)
return 0; return 0;
/* The API changed around Linux 2.6.14 but the old ABI is still supported:
handle all combinations of headers and kernel.
OpenWrt note that this fixes the problem addressed by your very broken patch. */
daemon->v6pktinfo = IPV6_PKTINFO;
#ifdef IPV6_RECVPKTINFO
# ifdef IPV6_2292PKTINFO
if (setsockopt(fd, IPV6_LEVEL, IPV6_RECVPKTINFO, &opt, sizeof(opt)) == -1)
{
if (errno == ENOPROTOOPT && setsockopt(fd, IPV6_LEVEL, IPV6_2292PKTINFO, &opt, sizeof(opt)) != -1)
daemon->v6pktinfo = IPV6_2292PKTINFO;
else
return 0;
}
# else
if (setsockopt(fd, IPV6_LEVEL, IPV6_RECVPKTINFO, &opt, sizeof(opt)) == -1)
return 0;
# endif
#else
if (setsockopt(fd, IPV6_LEVEL, IPV6_PKTINFO, &opt, sizeof(opt)) == -1)
return 0;
#endif
l = safe_malloc(sizeof(struct listener)); l = safe_malloc(sizeof(struct listener));
l->fd = fd; l->fd = fd;
l->tcpfd = tcpfd; l->tcpfd = tcpfd;
@@ -547,7 +572,7 @@ int local_bind(int fd, union mysockaddr *addr, char *intname, int is_tcp)
#if defined(SO_BINDTODEVICE) #if defined(SO_BINDTODEVICE)
if (intname[0] != 0 && if (intname[0] != 0 &&
setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, intname, strlen(intname)) == -1) setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, intname, IF_NAMESIZE) == -1)
return 0; return 0;
#endif #endif
@@ -646,7 +671,7 @@ void pre_allocate_sfds(void)
errno != 0 && errno != 0 &&
(daemon->options & OPT_NOWILD)) (daemon->options & OPT_NOWILD))
{ {
prettyprint_addr(&srv->addr, daemon->namebuff); prettyprint_addr(&srv->source_addr, daemon->namebuff);
if (srv->interface[0] != 0) if (srv->interface[0] != 0)
{ {
strcat(daemon->namebuff, " "); strcat(daemon->namebuff, " ");
@@ -664,6 +689,10 @@ void check_servers(void)
struct server *new, *tmp, *ret = NULL; struct server *new, *tmp, *ret = NULL;
int port = 0; int port = 0;
/* interface may be new since startup */
if (!(daemon->options & OPT_NOWILD))
enumerate_interfaces();
for (new = daemon->servers; new; new = tmp) for (new = daemon->servers; new; new = tmp)
{ {
tmp = new->next; tmp = new->next;
+166 -93
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -406,6 +406,8 @@ static const struct {
{ "domain-search", 119, 0 }, { "domain-search", 119, 0 },
{ "sip-server", 120, 0 }, { "sip-server", 120, 0 },
{ "classless-static-route", 121, 0 }, { "classless-static-route", 121, 0 },
{ "vendor-id-encap", 125, 0 },
{ "server-ip-address", 255, OT_ADDR_LIST }, /* special, internal only, sets siaddr */
{ NULL, 0, 0 } { NULL, 0, 0 }
}; };
@@ -530,13 +532,24 @@ static char *split(char *s)
return split_chr(s, ','); return split_chr(s, ',');
} }
static int canonicalise_opt(char *s) static char *canonicalise_opt(char *s)
{ {
char *ret;
int nomem;
if (!s) if (!s)
return 0; return 0;
unhide_metas(s); unhide_metas(s);
return canonicalise(s); if (!(ret = canonicalise(s, &nomem)) && nomem)
{
if (mem_recover)
longjmp(mem_jmp, 1);
else
die(_("could not get memory"), NULL, EC_NOMEM);
}
return ret;
} }
static int atoi_check(char *a, int *res) static int atoi_check(char *a, int *res)
@@ -646,7 +659,7 @@ static void display_opts(void)
printf(_("Known DHCP options:\n")); printf(_("Known DHCP options:\n"));
for (i = 0; opttab[i].name; i++) for (i = 0; opttab[i].name; i++)
if (opttab[i].size != OT_INTERNAL) if (!(opttab[i].size & OT_INTERNAL))
printf("%3d %s\n", opttab[i].val, opttab[i].name); printf("%3d %s\n", opttab[i].val, opttab[i].name);
} }
@@ -684,7 +697,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
if (strstr(arg, "option:") == arg) if (strstr(arg, "option:") == arg)
{ {
for (i = 0; opttab[i].name; i++) for (i = 0; opttab[i].name; i++)
if (opttab[i].size != OT_INTERNAL && if (!(opttab[i].size & OT_INTERNAL) &&
strcasecmp(opttab[i].name, arg+7) == 0) strcasecmp(opttab[i].name, arg+7) == 0)
{ {
new->opt = opttab[i].val; new->opt = opttab[i].val;
@@ -704,6 +717,16 @@ static char *parse_dhcp_opt(char *arg, int flags)
new->u.encap = atoi(arg+6); new->u.encap = atoi(arg+6);
new->flags |= DHOPT_ENCAPSULATE; new->flags |= DHOPT_ENCAPSULATE;
} }
else if (strstr(arg, "vi-encap:") == arg)
{
new->u.encap = atoi(arg+9);
new->flags |= DHOPT_RFC3925;
if (flags == DHOPT_MATCH)
{
new->opt = 1; /* avoid error below */
break;
}
}
else else
{ {
new->netid = opt_malloc(sizeof (struct dhcp_netid)); new->netid = opt_malloc(sizeof (struct dhcp_netid));
@@ -719,6 +742,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
arg = comma; arg = comma;
} }
/* option may be missing with rfc3925 match */
if (new->opt == 0) if (new->opt == 0)
problem = _("bad dhcp-option"); problem = _("bad dhcp-option");
else if (comma) else if (comma)
@@ -823,7 +847,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
new->val = op = opt_malloc((5 * addrs) + 1); new->val = op = opt_malloc((5 * addrs) + 1);
new->flags |= DHOPT_ADDR; new->flags |= DHOPT_ADDR;
if (!(new->flags & DHOPT_ENCAPSULATE) && new->opt == 120) if (!(new->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925)) && new->opt == 120)
{ {
*(op++) = 1; /* RFC 3361 "enc byte" */ *(op++) = 1; /* RFC 3361 "enc byte" */
new->flags &= ~DHOPT_ADDR; new->flags &= ~DHOPT_ADDR;
@@ -860,7 +884,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
else if (is_string) else if (is_string)
{ {
/* text arg */ /* text arg */
if ((new->opt == 119 || new->opt == 120) && !(new->flags & DHOPT_ENCAPSULATE)) if ((new->opt == 119 || new->opt == 120) && !(new->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925)))
{ {
/* dns search, RFC 3397, or SIP, RFC 3361 */ /* dns search, RFC 3397, or SIP, RFC 3361 */
unsigned char *q, *r, *tail; unsigned char *q, *r, *tail;
@@ -873,7 +897,8 @@ static char *parse_dhcp_opt(char *arg, int flags)
while (arg && *arg) while (arg && *arg)
{ {
if (!canonicalise_opt(arg)) char *dom;
if (!(dom = arg = canonicalise_opt(arg)))
{ {
problem = _("bad domain in dhcp-option"); problem = _("bad domain in dhcp-option");
break; break;
@@ -898,6 +923,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
arg++; arg++;
} }
*q++ = 0; *q++ = 0;
free(dom);
/* Now tail-compress using earlier names. */ /* Now tail-compress using earlier names. */
newlen = q - p; newlen = q - p;
@@ -932,7 +958,9 @@ static char *parse_dhcp_opt(char *arg, int flags)
} }
} }
if ((new->len > 255) || (new->len > 253 && (new->flags & (DHOPT_VENDOR | DHOPT_ENCAPSULATE)))) if ((new->len > 255) ||
(new->len > 253 && (new->flags & (DHOPT_VENDOR | DHOPT_ENCAPSULATE))) ||
(new->len > 250 && (new->flags & DHOPT_RFC3925)))
problem = _("dhcp-option too long"); problem = _("dhcp-option too long");
if (!problem) if (!problem)
@@ -1018,10 +1046,25 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
DIR *dir_stream; DIR *dir_stream;
struct dirent *ent; struct dirent *ent;
char *directory, *path; char *directory, *path;
struct list {
char *suffix;
struct list *next;
} *ignore_suffix = NULL, *li;
comma = split(arg);
if (!(directory = opt_string_alloc(arg))) if (!(directory = opt_string_alloc(arg)))
break; break;
for (arg = comma; arg; arg = comma)
{
comma = split(arg);
li = opt_malloc(sizeof(struct list));
li->next = ignore_suffix;
ignore_suffix = li;
/* Have to copy: buffer is overwritten */
li->suffix = opt_string_alloc(arg);
};
if (!(dir_stream = opendir(directory))) if (!(dir_stream = opendir(directory)))
die(_("cannot access directory %s: %s"), directory, EC_FILE); die(_("cannot access directory %s: %s"), directory, EC_FILE);
@@ -1030,13 +1073,24 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
size_t len = strlen(ent->d_name); size_t len = strlen(ent->d_name);
struct stat buf; struct stat buf;
/* ignore emacs backups and dotfiles */ /* ignore emacs backups and dotfiles */
if (len == 0 || if (len == 0 ||
ent->d_name[len - 1] == '~' || ent->d_name[len - 1] == '~' ||
(ent->d_name[0] == '#' && ent->d_name[len - 1] == '#') || (ent->d_name[0] == '#' && ent->d_name[len - 1] == '#') ||
ent->d_name[0] == '.') ent->d_name[0] == '.')
continue; continue;
for (li = ignore_suffix; li; li = li->next)
{
/* check for proscribed suffices */
size_t ls = strlen(li->suffix);
if (len > ls &&
strcmp(li->suffix, &ent->d_name[len - ls]) == 0)
break;
}
if (li)
continue;
path = opt_malloc(strlen(directory) + len + 2); path = opt_malloc(strlen(directory) + len + 2);
strcpy(path, directory); strcpy(path, directory);
strcat(path, "/"); strcat(path, "/");
@@ -1055,6 +1109,13 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
closedir(dir_stream); closedir(dir_stream);
free(directory); free(directory);
for(; ignore_suffix; ignore_suffix = li)
{
li = ignore_suffix->next;
free(ignore_suffix->suffix);
free(ignore_suffix);
}
break; break;
} }
@@ -1127,32 +1188,32 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
{ {
int pref = 1; int pref = 1;
struct mx_srv_record *new; struct mx_srv_record *new;
char *name, *target = NULL;
if ((comma = split(arg))) if ((comma = split(arg)))
{ {
char *prefstr; char *prefstr;
if ((prefstr=split(comma)) && !atoi_check16(prefstr, &pref)) if ((prefstr = split(comma)) && !atoi_check16(prefstr, &pref))
problem = _("bad MX preference"); problem = _("bad MX preference");
} }
if (!canonicalise_opt(arg) || (comma && !canonicalise_opt(comma))) if (!(name = canonicalise_opt(arg)) ||
(comma && !(target = canonicalise_opt(comma))))
problem = _("bad MX name"); problem = _("bad MX name");
new = opt_malloc(sizeof(struct mx_srv_record)); new = opt_malloc(sizeof(struct mx_srv_record));
new->next = daemon->mxnames; new->next = daemon->mxnames;
daemon->mxnames = new; daemon->mxnames = new;
new->issrv = 0; new->issrv = 0;
new->name = opt_string_alloc(arg); new->name = name;
new->target = opt_string_alloc(comma); /* may be NULL */ new->target = target; /* may be NULL */
new->weight = pref; new->weight = pref;
break; break;
} }
case 't': /* --mx-target */ case 't': /* --mx-target */
if (!canonicalise_opt(arg)) if (!(daemon->mxtarget = canonicalise_opt(arg)))
problem = _("bad MX target"); problem = _("bad MX target");
else
daemon->mxtarget = opt_string_alloc(arg);
break; break;
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
@@ -1161,8 +1222,10 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
break; break;
case '6': /* --dhcp-script */ case '6': /* --dhcp-script */
# ifdef NO_FORK # if defined(NO_FORK)
problem = _("cannot run scripts under uClinux"); problem = _("cannot run scripts under uClinux");
# elif !defined(HAVE_SCRIPT)
problem = _("recompile with HAVE_SCRIPT defined to enable lease-change scripts");
# else # else
daemon->lease_change_command = opt_string_alloc(arg); daemon->lease_change_command = opt_string_alloc(arg);
# endif # endif
@@ -1186,12 +1249,12 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
daemon->options |= OPT_RESOLV_DOMAIN; daemon->options |= OPT_RESOLV_DOMAIN;
else else
{ {
char *d;
comma = split(arg); comma = split(arg);
if (!canonicalise_opt(arg)) if (!(d = canonicalise_opt(arg)))
option = '?'; option = '?';
else else
{ {
char *d = opt_string_alloc(arg);
if (comma) if (comma)
{ {
struct cond_domain *new = safe_malloc(sizeof(struct cond_domain)); struct cond_domain *new = safe_malloc(sizeof(struct cond_domain));
@@ -1346,10 +1409,8 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
/* # matches everything and becomes a zero length domain string */ /* # matches everything and becomes a zero length domain string */
if (strcmp(arg, "#") == 0) if (strcmp(arg, "#") == 0)
domain = ""; domain = "";
else if (!canonicalise_opt(arg) && strlen(arg) != 0) else if (strlen (arg) != 0 && !(domain = canonicalise_opt(arg)))
option = '?'; option = '?';
else
domain = opt_string_alloc(arg); /* NULL if strlen is zero */
serv = opt_malloc(sizeof(struct server)); serv = opt_malloc(sizeof(struct server));
memset(serv, 0, sizeof(struct server)); memset(serv, 0, sizeof(struct server));
serv->next = newlist; serv->next = newlist;
@@ -1413,7 +1474,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
{ {
#if defined(SO_BINDTODEVICE) #if defined(SO_BINDTODEVICE)
newlist->source_addr.in.sin_addr.s_addr = INADDR_ANY; newlist->source_addr.in.sin_addr.s_addr = INADDR_ANY;
strncpy(newlist->interface, source, IF_NAMESIZE); strncpy(newlist->interface, source, IF_NAMESIZE - 1);
#else #else
problem = _("interface binding not supported"); problem = _("interface binding not supported");
#endif #endif
@@ -1438,7 +1499,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
{ {
#if defined(SO_BINDTODEVICE) #if defined(SO_BINDTODEVICE)
newlist->source_addr.in6.sin6_addr = in6addr_any; newlist->source_addr.in6.sin6_addr = in6addr_any;
strncpy(newlist->interface, source, IF_NAMESIZE); strncpy(newlist->interface, source, IF_NAMESIZE - 1);
#else #else
problem = _("interface binding not supported"); problem = _("interface binding not supported");
#endif #endif
@@ -1576,13 +1637,13 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
case LOPT_BRIDGE: /* --bridge-interface */ case LOPT_BRIDGE: /* --bridge-interface */
{ {
struct dhcp_bridge *new = opt_malloc(sizeof(struct dhcp_bridge)); struct dhcp_bridge *new = opt_malloc(sizeof(struct dhcp_bridge));
if (!(comma = split(arg))) if (!(comma = split(arg)) || strlen(arg) > IF_NAMESIZE - 1 )
{ {
problem = _("bad bridge-interface"); problem = _("bad bridge-interface");
break; break;
} }
strncpy(new->iface, arg, IF_NAMESIZE); strcpy(new->iface, arg);
new->alias = NULL; new->alias = NULL;
new->next = daemon->bridges; new->next = daemon->bridges;
daemon->bridges = new; daemon->bridges = new;
@@ -1590,12 +1651,12 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
do { do {
arg = comma; arg = comma;
comma = split(arg); comma = split(arg);
if (strlen(arg) != 0) if (strlen(arg) != 0 && strlen(arg) <= IF_NAMESIZE - 1)
{ {
struct dhcp_bridge *b = opt_malloc(sizeof(struct dhcp_bridge)); struct dhcp_bridge *b = opt_malloc(sizeof(struct dhcp_bridge));
b->next = new->alias; b->next = new->alias;
new->alias = b; new->alias = b;
strncpy(b->iface, arg, IF_NAMESIZE); strcpy(b->iface, arg);
} }
} while (comma); } while (comma);
@@ -1662,7 +1723,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
if (!(a[k] = split(a[k-1]))) if (!(a[k] = split(a[k-1])))
break; break;
if (option == '?' || (k < 2) || ((new->start.s_addr = inet_addr(a[0])) == (in_addr_t)-1)) if ((k < 2) || ((new->start.s_addr = inet_addr(a[0])) == (in_addr_t)-1))
option = '?'; option = '?';
else if (strcmp(a[1], "static") == 0) else if (strcmp(a[1], "static") == 0)
{ {
@@ -1860,15 +1921,12 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
new->flags |= CONFIG_DISABLE; new->flags |= CONFIG_DISABLE;
else else
{ {
int len = strlen(a[j]) + 1; if (!(new->hostname = canonicalise_opt(a[j])) ||
if (!canonicalise_opt(a[j])) !legal_hostname(new->hostname))
problem = _("bad DHCP host name"); problem = _("bad DHCP host name");
else if ((new->hostname = opt_malloc(len))) else
{ new->flags |= CONFIG_NAME;
new->flags |= CONFIG_NAME; new->domain = NULL;
strcpy(new->hostname, a[j]);
new->domain = NULL;
}
} }
} }
else else
@@ -1983,6 +2041,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
new->next = daemon->dhcp_opts; new->next = daemon->dhcp_opts;
daemon->dhcp_opts = new; daemon->dhcp_opts = new;
daemon->enable_pxe = 1;
} }
break; break;
@@ -2022,7 +2081,12 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
new->CSA = i; new->CSA = i;
new->menu = opt_string_alloc(arg); new->menu = opt_string_alloc(arg);
if (comma) if (!comma)
{
new->type = 0; /* local boot */
new->basename = NULL;
}
else
{ {
arg = comma; arg = comma;
comma = split(arg); comma = split(arg);
@@ -2039,20 +2103,22 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
if (comma && (new->server.s_addr = inet_addr(comma)) == (in_addr_t)-1) if (comma && (new->server.s_addr = inet_addr(comma)) == (in_addr_t)-1)
option = '?'; option = '?';
/* Order matters */
new->next = NULL;
if (!daemon->pxe_services)
daemon->pxe_services = new;
else
{
struct pxe_service *s;
for (s = daemon->pxe_services; s->next; s = s->next);
s->next = new;
}
break;
} }
/* Order matters */
new->next = NULL;
if (!daemon->pxe_services)
daemon->pxe_services = new;
else
{
struct pxe_service *s;
for (s = daemon->pxe_services; s->next; s = s->next);
s->next = new;
}
daemon->enable_pxe = 1;
break;
} }
} }
@@ -2243,10 +2309,11 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
case LOPT_INTNAME: /* --interface-name */ case LOPT_INTNAME: /* --interface-name */
{ {
struct interface_name *new, **up; struct interface_name *new, **up;
char *domain = NULL;
comma = split(arg); comma = split(arg);
if (!comma || !canonicalise_opt(arg)) if (!comma || !(domain = canonicalise_opt(arg)))
problem = _("bad interface name"); problem = _("bad interface name");
new = opt_malloc(sizeof(struct interface_name)); new = opt_malloc(sizeof(struct interface_name));
@@ -2255,7 +2322,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
of an interface is used for PTR lookups. */ of an interface is used for PTR lookups. */
for (up = &daemon->int_names; *up; up = &((*up)->next)); for (up = &daemon->int_names; *up; up = &((*up)->next));
*up = new; *up = new;
new->name = opt_string_alloc(arg); new->name = domain;
new->intr = opt_string_alloc(comma); new->intr = opt_string_alloc(comma);
break; break;
} }
@@ -2268,14 +2335,22 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
option = '?'; option = '?';
else else
{ {
for (new = daemon->cnames; new; new = new->next) char *alias = canonicalise_opt(arg);
if (hostname_isequal(new->alias, arg)) char *target = canonicalise_opt(comma);
problem = _("duplicate CNAME");
new = opt_malloc(sizeof(struct cname)); if (!alias || !target)
new->next = daemon->cnames; problem = _("bad CNAME");
daemon->cnames = new; else
new->alias = opt_string_alloc(arg); {
new->target = opt_string_alloc(comma); for (new = daemon->cnames; new; new = new->next)
if (hostname_isequal(new->alias, arg))
problem = _("duplicate CNAME");
new = opt_malloc(sizeof(struct cname));
new->next = daemon->cnames;
daemon->cnames = new;
new->alias = alias;
new->target = target;
}
} }
break; break;
} }
@@ -2283,19 +2358,21 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
case LOPT_PTR: /* --ptr-record */ case LOPT_PTR: /* --ptr-record */
{ {
struct ptr_record *new; struct ptr_record *new;
char *dom, *target = NULL;
comma = split(arg); comma = split(arg);
if (!canonicalise_opt(arg)) if (!(dom = canonicalise_opt(arg)) ||
(comma && !(target = canonicalise_opt(comma))))
problem = _("bad PTR record"); problem = _("bad PTR record");
else
new = opt_malloc(sizeof(struct ptr_record)); {
new->next = daemon->ptr; new = opt_malloc(sizeof(struct ptr_record));
daemon->ptr = new; new->next = daemon->ptr;
new->name = opt_string_alloc(arg); daemon->ptr = new;
new->ptr = NULL; new->name = dom;
if (comma) new->ptr = target;
new->ptr = opt_string_alloc(comma); }
break; break;
} }
@@ -2305,6 +2382,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
int k = 0; int k = 0;
struct naptr *new; struct naptr *new;
int order, pref; int order, pref;
char *name, *replace = NULL;
if ((a[0] = arg)) if ((a[0] = arg))
for (k = 1; k < 7; k++) for (k = 1; k < 7; k++)
@@ -2313,22 +2391,21 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
if (k < 6 || if (k < 6 ||
!canonicalise_opt(a[0]) || !(name = canonicalise_opt(a[0])) ||
!atoi_check16(a[1], &order) || !atoi_check16(a[1], &order) ||
!atoi_check16(a[2], &pref) || !atoi_check16(a[2], &pref) ||
(k == 7 && !canonicalise_opt(a[6]))) (k == 7 && !(replace = canonicalise_opt(a[6]))))
problem = _("bad NAPTR record"); problem = _("bad NAPTR record");
else else
{ {
new = opt_malloc(sizeof(struct naptr)); new = opt_malloc(sizeof(struct naptr));
new->next = daemon->naptr; new->next = daemon->naptr;
daemon->naptr = new; daemon->naptr = new;
new->name = opt_string_alloc(a[0]); new->name = name;
new->flags = opt_string_alloc(a[3]); new->flags = opt_string_alloc(a[3]);
new->services = opt_string_alloc(a[4]); new->services = opt_string_alloc(a[4]);
new->regexp = opt_string_alloc(a[5]); new->regexp = opt_string_alloc(a[5]);
if (k == 7) new->replace = replace;
new->replace = opt_string_alloc(a[6]);
new->order = order; new->order = order;
new->pref = pref; new->pref = pref;
} }
@@ -2345,12 +2422,6 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
gen_prob = _("TXT record string too long"); gen_prob = _("TXT record string too long");
if (!canonicalise_opt(arg))
{
problem = _("bad TXT record");
break;
}
if ((q = (unsigned char *)comma)) if ((q = (unsigned char *)comma))
while (1) while (1)
{ {
@@ -2394,7 +2465,13 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
/* ensure arg is terminated */ /* ensure arg is terminated */
if (comma) if (comma)
*comma = 0; *comma = 0;
new->name = opt_string_alloc(arg);
if (!(new->name = canonicalise_opt(arg)))
{
problem = _("bad TXT record");
break;
}
break; break;
} }
@@ -2406,19 +2483,16 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
comma = split(arg); comma = split(arg);
if (!canonicalise_opt(arg)) if (!(name = canonicalise_opt(arg)))
problem = _("bad SRV record"); problem = _("bad SRV record");
name = opt_string_alloc(arg);
if (comma) if (comma)
{ {
arg = comma; arg = comma;
comma = split(arg); comma = split(arg);
if (!canonicalise_opt(arg)) if (!(target = canonicalise_opt(arg))
problem = _("bad SRV target"); ) problem = _("bad SRV target");
target = opt_string_alloc(arg);
if (comma) if (comma)
{ {
arg = comma; arg = comma;
@@ -2683,7 +2757,7 @@ void reread_dhcp(void)
} }
one_file(daemon->dhcp_hosts_file, 1, LOPT_BANK); one_file(daemon->dhcp_hosts_file, 1, LOPT_BANK);
my_syslog(LOG_INFO, _("read %s"), daemon->dhcp_hosts_file); my_syslog(MS_DHCP | LOG_INFO, _("read %s"), daemon->dhcp_hosts_file);
} }
if (daemon->dhcp_opts_file) if (daemon->dhcp_opts_file)
@@ -2714,7 +2788,7 @@ void reread_dhcp(void)
} }
one_file(daemon->dhcp_opts_file, 1, LOPT_OPTS); one_file(daemon->dhcp_opts_file, 1, LOPT_OPTS);
my_syslog(LOG_INFO, _("read %s"), daemon->dhcp_opts_file); my_syslog(MS_DHCP | LOG_INFO, _("read %s"), daemon->dhcp_opts_file);
} }
} }
#endif #endif
@@ -2898,8 +2972,7 @@ void read_opts(int argc, char **argv, char *compile_opts)
continue; continue;
if ((token = strtok(NULL, " \t\n\r")) && if ((token = strtok(NULL, " \t\n\r")) &&
canonicalise_opt(token) && (daemon->domain_suffix = canonicalise_opt(token)))
(daemon->domain_suffix = opt_string_alloc(token)))
break; break;
} }
+35 -11
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -138,7 +138,8 @@ static int extract_name(HEADER *header, size_t plen, unsigned char **pp,
for(j=0; j<l; j++, p++) for(j=0; j<l; j++, p++)
if (isExtract) if (isExtract)
{ {
if (legal_char(*p)) unsigned char c = *p;
if (isascii(c) && !iscntrl(c) && c != '.')
*cp++ = *p; *cp++ = *p;
else else
return 0; return 0;
@@ -1326,18 +1327,41 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
if (qtype != type && qtype != T_ANY) if (qtype != type && qtype != T_ANY)
continue; continue;
/* Check for "A for A" queries */ /* Check for "A for A" queries; be rather conservative
if (qtype == T_A && (addr.addr.addr4.s_addr = inet_addr(name)) != (in_addr_t) -1) about what looks like dotted-quad. */
if (qtype == T_A)
{ {
ans = 1; char *cp;
if (!dryrun) unsigned int i, a;
int x;
for (cp = name, i = 0, a = 0; *cp; i++)
{ {
log_query(F_FORWARD | F_CONFIG | F_IPV4, name, &addr, NULL); if (!isdigit(*cp) || (x = strtol(cp, &cp, 10)) > 255)
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp, {
daemon->local_ttl, NULL, type, C_IN, "4", &addr)) i = 5;
anscount++; break;
}
a = (a << 8) + x;
if (*cp == '.')
cp++;
}
if (i == 4)
{
ans = 1;
if (!dryrun)
{
addr.addr.addr4.s_addr = htonl(a);
log_query(F_FORWARD | F_CONFIG | F_IPV4, name, &addr, NULL);
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
daemon->local_ttl, NULL, type, C_IN, "4", &addr))
anscount++;
}
continue;
} }
continue;
} }
/* interface name stuff */ /* interface name stuff */
+296 -133
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -54,6 +54,8 @@
#define OPTION_ARCH 93 #define OPTION_ARCH 93
#define OPTION_PXE_UUID 97 #define OPTION_PXE_UUID 97
#define OPTION_SUBNET_SELECT 118 #define OPTION_SUBNET_SELECT 118
#define OPTION_VENDOR_IDENT 124
#define OPTION_VENDOR_IDENT_OPT 125
#define OPTION_END 255 #define OPTION_END 255
#define SUBOPT_CIRCUIT_ID 1 #define SUBOPT_CIRCUIT_ID 1
@@ -77,10 +79,17 @@
#define DHCPRELEASE 7 #define DHCPRELEASE 7
#define DHCPINFORM 8 #define DHCPINFORM 8
#define BRDBAND_FORUM_IANA 3561 /* Broadband forum IANA enterprise */
#define have_config(config, mask) ((config) && ((config)->flags & (mask))) #define have_config(config, mask) ((config) && ((config)->flags & (mask)))
#define option_len(opt) ((int)(((unsigned char *)(opt))[1])) #define option_len(opt) ((int)(((unsigned char *)(opt))[1]))
#define option_ptr(opt, i) ((void *)&(((unsigned char *)(opt))[2u+(unsigned int)(i)])) #define option_ptr(opt, i) ((void *)&(((unsigned char *)(opt))[2u+(unsigned int)(i)]))
#ifdef HAVE_SCRIPT
static void add_extradata_data(struct dhcp_lease *lease, unsigned char *data, size_t len, int delim);
static void add_extradata_opt(struct dhcp_lease *lease, unsigned char *opt);
#endif
static int match_bytes(struct dhcp_opt *o, unsigned char *p, int len);
static int sanitise(unsigned char *opt, char *buf); static int sanitise(unsigned char *opt, char *buf);
static struct in_addr server_id(struct dhcp_context *context, struct in_addr override, struct in_addr fallback); static struct in_addr server_id(struct dhcp_context *context, struct in_addr override, struct in_addr fallback);
static unsigned int calc_time(struct dhcp_context *context, struct dhcp_config *config, unsigned char *opt); static unsigned int calc_time(struct dhcp_context *context, struct dhcp_config *config, unsigned char *opt);
@@ -114,12 +123,12 @@ static void match_vendor_opts(unsigned char *opt, struct dhcp_opt *dopt);
static void do_encap_opts(struct dhcp_opt *opts, int encap, int flag, struct dhcp_packet *mess, unsigned char *end, int null_term); static void do_encap_opts(struct dhcp_opt *opts, int encap, int flag, struct dhcp_packet *mess, unsigned char *end, int null_term);
static void pxe_misc(struct dhcp_packet *mess, unsigned char *end, unsigned char *uuid); static void pxe_misc(struct dhcp_packet *mess, unsigned char *end, unsigned char *uuid);
static int prune_vendor_opts(struct dhcp_netid *netid); static int prune_vendor_opts(struct dhcp_netid *netid);
static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid); static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid, struct in_addr local);
struct dhcp_boot *find_boot(struct dhcp_netid *netid); struct dhcp_boot *find_boot(struct dhcp_netid *netid);
size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
size_t sz, time_t now, int unicast_dest, int *is_inform) size_t sz, time_t now, int unicast_dest, int *is_inform, int pxe)
{ {
unsigned char *opt, *clid = NULL; unsigned char *opt, *clid = NULL;
struct dhcp_lease *ltmp, *lease = NULL; struct dhcp_lease *ltmp, *lease = NULL;
@@ -144,9 +153,10 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
unsigned char *agent_id = NULL, *uuid = NULL; unsigned char *agent_id = NULL, *uuid = NULL;
unsigned char *emac = NULL; unsigned char *emac = NULL;
int emac_len = 0; int emac_len = 0;
struct dhcp_netid known_id, iface_id; struct dhcp_netid known_id, iface_id, cpewan_id;
struct dhcp_opt *o; struct dhcp_opt *o;
unsigned char pxe_uuid[17]; unsigned char pxe_uuid[17];
unsigned char *oui = NULL, *serial = NULL, *class = NULL;
subnet_addr.s_addr = override.s_addr = 0; subnet_addr.s_addr = override.s_addr = 0;
@@ -194,6 +204,35 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
if ((option_find(mess, sz, OPTION_REQUESTED_IP, INADDRSZ) || mess_type == DHCPDISCOVER)) if ((option_find(mess, sz, OPTION_REQUESTED_IP, INADDRSZ) || mess_type == DHCPDISCOVER))
mess->ciaddr.s_addr = 0; mess->ciaddr.s_addr = 0;
/* search for device identity from CPEWAN devices, we pass this through to the script */
if ((opt = option_find(mess, sz, OPTION_VENDOR_IDENT_OPT, 5)))
{
unsigned int elen, offset, len = option_len(opt);
for (offset = 0; offset < (len - 5); offset += elen + 5)
{
elen = option_uint(opt, offset + 4 , 1);
if (option_uint(opt, offset, 4) == BRDBAND_FORUM_IANA)
{
unsigned char *x = option_ptr(opt, offset + 5);
unsigned char *y = option_ptr(opt, offset + elen + 5);
oui = option_find1(x, y, 1, 1);
serial = option_find1(x, y, 2, 1);
class = option_find1(x, y, 3, 1);
/* If TR069-id is present set the tag "cpewan-id" to facilitate echoing
the gateway id back. Note that the device class is optional */
if (oui && serial)
{
cpewan_id.net = "cpewan-id";
cpewan_id.next = netid;
netid = &cpewan_id;
}
break;
}
}
}
if ((opt = option_find(mess, sz, OPTION_AGENT_ID, 1))) if ((opt = option_find(mess, sz, OPTION_AGENT_ID, 1)))
{ {
/* Any agent-id needs to be copied back out, verbatim, as the last option /* Any agent-id needs to be copied back out, verbatim, as the last option
@@ -370,7 +409,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
netid = &known_id; netid = &known_id;
} }
if (mess_type == 0) if (mess_type == 0 && !pxe)
{ {
/* BOOTP request */ /* BOOTP request */
struct dhcp_netid id, bootp_id; struct dhcp_netid id, bootp_id;
@@ -415,7 +454,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
for (id_list = daemon->dhcp_ignore; id_list; id_list = id_list->next) for (id_list = daemon->dhcp_ignore; id_list; id_list = id_list->next)
if (match_netid(id_list->list, netid, 0)) if (match_netid(id_list->list, netid, 0))
message = _("disabled"); message = _("ignored");
if (!message) if (!message)
{ {
@@ -536,7 +575,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
*pq = 0; *pq = 0;
if (canonicalise(daemon->dhcp_buff)) if (legal_hostname(daemon->dhcp_buff))
offer_hostname = client_hostname = daemon->dhcp_buff; offer_hostname = client_hostname = daemon->dhcp_buff;
} }
else if ((opt = option_find(mess, sz, OPTION_HOSTNAME, 1))) else if ((opt = option_find(mess, sz, OPTION_HOSTNAME, 1)))
@@ -550,7 +589,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
borken_opt = 1; borken_opt = 1;
else else
daemon->dhcp_buff[len] = 0; daemon->dhcp_buff[len] = 0;
if (canonicalise(daemon->dhcp_buff)) if (legal_hostname(daemon->dhcp_buff))
client_hostname = daemon->dhcp_buff; client_hostname = daemon->dhcp_buff;
} }
@@ -601,38 +640,44 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
/* dhcp-match. If we have hex-and-wildcards, look for a left-anchored match. /* dhcp-match. If we have hex-and-wildcards, look for a left-anchored match.
Otherwise assume the option is an array, and look for a matching element. Otherwise assume the option is an array, and look for a matching element.
If no data given, existance of the option is enough. */ If no data given, existance of the option is enough. This code handles
rfc3925 V-I classes too. */
for (o = daemon->dhcp_match; o; o = o->next) for (o = daemon->dhcp_match; o; o = o->next)
{ {
int i, matched = 0; unsigned int len, elen, match = 0;
size_t offset, o2;
if (!(opt = option_find(mess, sz, o->opt, 1)) || if (o->flags & DHOPT_RFC3925)
o->len > option_len(opt))
continue;
if (o->len == 0)
matched = 1;
else if (o->flags & DHOPT_HEX)
{ {
if (memcmp_masked(o->val, option_ptr(opt, 0), o->len, o->u.wildcard_mask)) if (!(opt = option_find(mess, sz, OPTION_VENDOR_IDENT, 5)))
matched = 1; continue;
for (offset = 0; offset < (option_len(opt) - 5u); offset += len + 5)
{
len = option_uint(opt, offset + 4 , 1);
/* Need to take care that bad data can't run us off the end of the packet */
if ((offset + len + 5 <= (option_len(opt))) &&
(option_uint(opt, offset, 4) == (unsigned int)o->u.encap))
for (o2 = offset + 5; o2 < offset + len + 5; o2 += elen + 1)
{
elen = option_uint(opt, o2, 1);
if ((o2 + elen + 1 <= option_len(opt)) &&
(match = match_bytes(o, option_ptr(opt, o2 + 1), elen)))
break;
}
if (match)
break;
}
} }
else else
for (i = 0; i <= (option_len(opt) - o->len); ) {
{ if (!(opt = option_find(mess, sz, o->opt, 1)))
if (memcmp(o->val, option_ptr(opt, i), o->len) == 0) continue;
{
matched = 1;
break;
}
if (o->flags & DHOPT_STRING) match = match_bytes(o, option_ptr(opt, 0), option_len(opt));
i++; }
else
i += o->len;
}
if (matched) if (match)
{ {
o->netid->next = netid; o->netid->next = netid;
netid = o->netid; netid = o->netid;
@@ -708,7 +753,8 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
clid = NULL; clid = NULL;
/* Check if client is PXE client. */ /* Check if client is PXE client. */
if ((opt = option_find(mess, sz, OPTION_VENDOR_ID, 9)) && if (daemon->enable_pxe &&
(opt = option_find(mess, sz, OPTION_VENDOR_ID, 9)) &&
strncmp(option_ptr(opt, 0), "PXEClient", 9) == 0) strncmp(option_ptr(opt, 0), "PXEClient", 9) == 0)
{ {
if ((opt = option_find(mess, sz, OPTION_PXE_UUID, 17))) if ((opt = option_find(mess, sz, OPTION_PXE_UUID, 17)))
@@ -728,6 +774,9 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
unsigned char save71[4]; unsigned char save71[4];
struct dhcp_opt opt71; struct dhcp_opt opt71;
if (ignore)
return 0;
if (layer & 0x8000) if (layer & 0x8000)
{ {
my_syslog(MS_DHCP | LOG_ERR, _("PXE BIS not supported")); my_syslog(MS_DHCP | LOG_ERR, _("PXE BIS not supported"));
@@ -774,8 +823,8 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
{ {
pxearch = option_uint(opt, 0, 2); pxearch = option_uint(opt, 0, 2);
/* proxy DHCP here. The DHCPREQUEST stuff is for gPXE */ /* proxy DHCP here. */
if ((mess_type == DHCPDISCOVER || mess_type == DHCPREQUEST) && if ((mess_type == DHCPDISCOVER || (pxe && mess_type == DHCPREQUEST)) &&
(context->flags & CONTEXT_PROXY)) (context->flags & CONTEXT_PROXY))
{ {
struct dhcp_boot *boot = find_boot(netid); struct dhcp_boot *boot = find_boot(netid);
@@ -805,16 +854,16 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, htonl(context->local.s_addr)); option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ, htonl(context->local.s_addr));
pxe_misc(mess, end, uuid); pxe_misc(mess, end, uuid);
prune_vendor_opts(netid); prune_vendor_opts(netid);
do_encap_opts(pxe_opts(pxearch, netid), OPTION_VENDOR_CLASS_OPT, DHOPT_VENDOR_MATCH, mess, end, 0); do_encap_opts(pxe_opts(pxearch, netid, context->local), OPTION_VENDOR_CLASS_OPT, DHOPT_VENDOR_MATCH, mess, end, 0);
log_packet("PXE", NULL, emac, emac_len, iface_name, "proxy", mess->xid); log_packet("PXE", NULL, emac, emac_len, iface_name, ignore ? "proxy-ignored" : "proxy", mess->xid);
return dhcp_packet_size(mess, netid, agent_id, real_end); return ignore ? 0 : dhcp_packet_size(mess, netid, agent_id, real_end);
} }
} }
} }
/* if we're just a proxy server, go no further */ /* if we're just a proxy server, go no further */
if (context->flags & CONTEXT_PROXY) if ((context->flags & CONTEXT_PROXY) || pxe)
return 0; return 0;
if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 0))) if ((opt = option_find(mess, sz, OPTION_REQUESTED_OPTIONS, 0)))
@@ -1131,10 +1180,37 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
} }
else else
{ {
if (do_classes) if (context->netid.net)
{
context->netid.next = netid;
netid = &context->netid;
}
#ifdef HAVE_SCRIPT
if (do_classes && daemon->lease_change_command)
{ {
struct dhcp_netid *n;
if (mess->giaddr.s_addr)
lease->giaddr = mess->giaddr;
lease->changed = 1; lease->changed = 1;
/* copy user-class and vendor class into new lease, for the script */ free(lease->extradata);
lease->extradata_size = lease->extradata_len = 0;
add_extradata_opt(lease, option_find(mess, sz, OPTION_VENDOR_ID, 1));
add_extradata_opt(lease, option_find(mess, sz, OPTION_HOSTNAME, 1));
add_extradata_opt(lease, oui);
add_extradata_opt(lease, serial);
add_extradata_opt(lease, class);
/* space-concat tag set */
if (!netid)
add_extradata_opt(lease, NULL);
else
for (n = netid; n; n = n->next)
add_extradata_data(lease, (unsigned char *)n->net, strlen(n->net), n->next ? ' ' : 0);
if ((opt = option_find(mess, sz, OPTION_USER_CLASS, 1))) if ((opt = option_find(mess, sz, OPTION_USER_CLASS, 1)))
{ {
int len = option_len(opt); int len = option_len(opt);
@@ -1142,27 +1218,11 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
/* If the user-class option started as counted strings, the first byte will be zero. */ /* If the user-class option started as counted strings, the first byte will be zero. */
if (len != 0 && ucp[0] == 0) if (len != 0 && ucp[0] == 0)
ucp++, len--; ucp++, len--;
free(lease->userclass); add_extradata_data(lease, ucp, len, 0);
if ((lease->userclass = whine_malloc(len+1)))
{
memcpy(lease->userclass, ucp, len);
lease->userclass[len] = 0;
lease->userclass_len = len+1;
}
}
if ((opt = option_find(mess, sz, OPTION_VENDOR_ID, 1)))
{
int len = option_len(opt);
unsigned char *ucp = option_ptr(opt, 0);
free(lease->vendorclass);
if ((lease->vendorclass = whine_malloc(len+1)))
{
memcpy(lease->vendorclass, ucp, len);
lease->vendorclass[len] = 0;
lease->vendorclass_len = len+1;
}
} }
} }
#endif
if (!hostname_auth && (client_hostname = host_from_dns(mess->yiaddr))) if (!hostname_auth && (client_hostname = host_from_dns(mess->yiaddr)))
{ {
@@ -1170,12 +1230,6 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
hostname_auth = 1; hostname_auth = 1;
} }
if (context->netid.net)
{
context->netid.next = netid;
netid = &context->netid;
}
time = calc_time(context, config, option_find(mess, sz, OPTION_LEASE_TIME, 4)); time = calc_time(context, config, option_find(mess, sz, OPTION_LEASE_TIME, 4));
lease_set_hwaddr(lease, mess->chaddr, clid, mess->hlen, mess->htype, clid_len); lease_set_hwaddr(lease, mess->chaddr, clid, mess->hlen, mess->htype, clid_len);
@@ -1280,6 +1334,37 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
return 0; return 0;
} }
static int match_bytes(struct dhcp_opt *o, unsigned char *p, int len)
{
int i;
if (o->len > len)
return 0;
if (o->len == 0)
return 1;
if (o->flags & DHOPT_HEX)
{
if (memcmp_masked(o->val, p, o->len, o->u.wildcard_mask))
return 1;
}
else
for (i = 0; i <= (len - o->len); )
{
if (memcmp(o->val, p + i, o->len) == 0)
return 1;
if (o->flags & DHOPT_STRING)
i++;
else
i += o->len;
}
return 0;
}
/* find a good value to use as MAC address for logging and address-allocation hashing. /* find a good value to use as MAC address for logging and address-allocation hashing.
This is normally just the chaddr field from the DHCP packet, This is normally just the chaddr field from the DHCP packet,
but eg Firewire will have hlen == 0 and use the client-id instead. but eg Firewire will have hlen == 0 and use the client-id instead.
@@ -1364,6 +1449,55 @@ static int sanitise(unsigned char *opt, char *buf)
return 1; return 1;
} }
#ifdef HAVE_SCRIPT
static void add_extradata_data(struct dhcp_lease *lease, unsigned char *data, size_t len, int delim)
{
if ((lease->extradata_size - lease->extradata_len) < (len + 1))
{
size_t newsz = lease->extradata_len + len + 100;
unsigned char *new = whine_malloc(newsz);
if (!new)
return;
if (lease->extradata)
{
memcpy(new, lease->extradata, lease->extradata_len);
free(lease->extradata);
}
lease->extradata = new;
lease->extradata_size = newsz;
}
if (len != 0)
memcpy(lease->extradata + lease->extradata_len, data, len);
lease->extradata[lease->extradata_len + len] = delim;
lease->extradata_len += len + 1;
}
static void add_extradata_opt(struct dhcp_lease *lease, unsigned char *opt)
{
if (!opt)
add_extradata_data(lease, NULL, 0, 0);
else
{
size_t i, len = option_len(opt);
unsigned char *ucp = option_ptr(opt, 0);
/* check for embeded NULLs */
for (i = 0; i < len; i++)
if (ucp[i] == 0)
{
len = i;
break;
}
add_extradata_data(lease, ucp, len, 0);
}
}
#endif
static void log_packet(char *type, void *addr, unsigned char *ext_mac, static void log_packet(char *type, void *addr, unsigned char *ext_mac,
int mac_len, char *interface, char *string, u32 xid) int mac_len, char *interface, char *string, u32 xid)
{ {
@@ -1538,7 +1672,6 @@ static size_t dhcp_packet_size(struct dhcp_packet *mess, struct dhcp_netid *neti
/* move agent_id back down to the end of the packet */ /* move agent_id back down to the end of the packet */
if (agent_id) if (agent_id)
{ {
unsigned char *p = dhcp_skip_opts(&mess->options[0] + sizeof(u32));
memmove(p, agent_id, real_end - agent_id); memmove(p, agent_id, real_end - agent_id);
p += real_end - agent_id; p += real_end - agent_id;
memset(p, 0, real_end - p); /* in case of overlap */ memset(p, 0, real_end - p); /* in case of overlap */
@@ -1547,9 +1680,8 @@ static size_t dhcp_packet_size(struct dhcp_packet *mess, struct dhcp_netid *neti
/* We do logging too */ /* We do logging too */
if (netid && (daemon->options & OPT_LOG_OPTS)) if (netid && (daemon->options & OPT_LOG_OPTS))
{ {
char *p = daemon->namebuff; char *s = daemon->namebuff;
*p = 0; for (*s = 0; netid; netid = netid->next)
for (; netid; netid = netid->next)
{ {
/* kill dupes. */ /* kill dupes. */
for (n = netid->next; n; n = n->next) for (n = netid->next; n; n = n->next)
@@ -1558,13 +1690,12 @@ static size_t dhcp_packet_size(struct dhcp_packet *mess, struct dhcp_netid *neti
if (!n) if (!n)
{ {
strncat (p, netid->net, MAXDNAME); strncat (s, netid->net, (MAXDNAME-1) - strlen(s));
if (netid->next) if (netid->next)
strncat (p, ", ", MAXDNAME); strncat (s, ", ", (MAXDNAME-1) - strlen(s));
} }
} }
p[MAXDNAME - 1] = 0; my_syslog(MS_DHCP | LOG_INFO, _("%u tags: %s"), ntohl(mess->xid), s);
my_syslog(MS_DHCP | LOG_INFO, _("%u tags: %s"), ntohl(mess->xid), p);
} }
/* add END options to the regions. */ /* add END options to the regions. */
@@ -1745,7 +1876,7 @@ static struct dhcp_opt *option_find2(struct dhcp_netid *netid, struct dhcp_opt *
{ {
struct dhcp_opt *tmp; struct dhcp_opt *tmp;
for (tmp = opts; tmp; tmp = tmp->next) for (tmp = opts; tmp; tmp = tmp->next)
if (tmp->opt == opt && !(tmp->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR))) if (tmp->opt == opt && !(tmp->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925)))
if (match_netid(tmp->netid, netid, netid ? 0 : 1)) if (match_netid(tmp->netid, netid, netid ? 0 : 1))
return tmp; return tmp;
@@ -1845,7 +1976,7 @@ static int prune_vendor_opts(struct dhcp_netid *netid)
return force; return force;
} }
static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid) static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid, struct in_addr local)
{ {
#define NUM_OPTS 4 #define NUM_OPTS 4
@@ -1853,18 +1984,16 @@ static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid)
struct pxe_service *service; struct pxe_service *service;
static struct dhcp_opt *o, *ret; static struct dhcp_opt *o, *ret;
int i, j = NUM_OPTS - 1; int i, j = NUM_OPTS - 1;
struct in_addr boot_server;
/* We pass back references to these, hence they are declared static */ /* We pass back references to these, hence they are declared static */
static unsigned char discovery_control; static unsigned char discovery_control;
static unsigned char fake_prompt[] = { 0, 'P', 'X', 'E' }; static unsigned char fake_prompt[] = { 0, 'P', 'X', 'E' };
static struct dhcp_opt *fake_opts = NULL; static struct dhcp_opt *fake_opts = NULL;
/* We are found by broadcast, so disable multicast. It gets switched on again /* Disable multicast, since we don't support it, and broadcast
if we point to other servers and don't give a unicast address. Note that unless we need it */
we don't provide our own address for services we are the boot server for because unicast discovery_control = 3;
discovery is to port 4011 and we don't listen there. If you are using proxy DHCP
and DHCP relays, the relay will need to forward to the proxy too. */
discovery_control = 2;
ret = daemon->dhcp_opts; ret = daemon->dhcp_opts;
@@ -1904,26 +2033,25 @@ static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid)
return daemon->dhcp_opts; return daemon->dhcp_opts;
} }
if (!service->basename) boot_server = service->basename ? local : service->server;
{
if (service->server.s_addr != 0)
{
if (q - (unsigned char *)daemon->dhcp_buff2 + 3 + INADDRSZ >= 253)
goto toobig;
/* Boot service with known address - give it */ if (boot_server.s_addr != 0)
*(q++) = service->type >> 8; {
*(q++) = service->type; if (q - (unsigned char *)daemon->dhcp_buff2 + 3 + INADDRSZ >= 253)
*(q++) = 1; goto toobig;
/* dest misaligned */
memcpy(q, &service->server.s_addr, INADDRSZ); /* Boot service with known address - give it */
q += INADDRSZ; *(q++) = service->type >> 8;
} *(q++) = service->type;
else if (service->type != 0) *(q++) = 1;
/* We're not supplying a server, so let the client multicast. /* dest misaligned */
type zero is "local boot" so no need for M/C on that. */ memcpy(q, &boot_server.s_addr, INADDRSZ);
discovery_control = 0; q += INADDRSZ;
} }
else if (service->type != 0)
/* We don't know the server for a service type, so we'll
allow the client to broadcast for it */
discovery_control = 2;
} }
/* if no prompt, wait forever if there's a choice */ /* if no prompt, wait forever if there's a choice */
@@ -1959,13 +2087,10 @@ static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid)
ret->opt = SUBOPT_PXE_MENU_PROMPT; ret->opt = SUBOPT_PXE_MENU_PROMPT;
} }
if (discovery_control != 0) ret = &fake_opts[j--];
{ ret->len = 1;
ret = &fake_opts[j--]; ret->opt = SUBOPT_PXE_DISCOVERY;
ret->len = 1; ret->val= &discovery_control;
ret->opt = SUBOPT_PXE_DISCOVERY;
ret->val= &discovery_control;
}
return ret; return ret;
} }
@@ -2074,21 +2199,26 @@ static void do_options(struct dhcp_context *context,
} }
else else
/* Use the values of the relevant options if no dhcp-boot given and /* Use the values of the relevant options if no dhcp-boot given and
they're not explicitly asked for as options. */ they're not explicitly asked for as options. OPTION_END is used
as an internal way to specify siaddr without using dhcp-boot, for use in
dhcp-optsfile. */
{ {
if ((!req_options || !in_list(req_options, OPTION_FILENAME)) && mess->file[0] == 0 && if ((!req_options || !in_list(req_options, OPTION_FILENAME)) && mess->file[0] == 0 &&
(opt = option_find2(netid, config_opts, OPTION_FILENAME))) (opt = option_find2(netid, config_opts, OPTION_FILENAME)) && !(opt->flags & DHOPT_FORCE))
{ {
strncpy((char *)mess->file, (char *)opt->val, sizeof(mess->file)-1); strncpy((char *)mess->file, (char *)opt->val, sizeof(mess->file)-1);
done_file = 1; done_file = 1;
} }
if ((!req_options || !in_list(req_options, OPTION_SNAME)) && if ((!req_options || !in_list(req_options, OPTION_SNAME)) &&
(opt = option_find2(netid, config_opts, OPTION_SNAME))) (opt = option_find2(netid, config_opts, OPTION_SNAME)) && !(opt->flags & DHOPT_FORCE))
{ {
strncpy((char *)mess->sname, (char *)opt->val, sizeof(mess->sname)-1); strncpy((char *)mess->sname, (char *)opt->val, sizeof(mess->sname)-1);
done_server = 1; done_server = 1;
} }
if ((opt = option_find2(netid, config_opts, OPTION_END)))
mess->siaddr.s_addr = ((struct in_addr *)opt->val)->s_addr;
} }
/* We don't want to do option-overload for BOOTP, so make the file and sname /* We don't want to do option-overload for BOOTP, so make the file and sname
@@ -2249,45 +2379,78 @@ static void do_options(struct dhcp_context *context,
/* Now send options to be encapsulated in arbitrary options, /* Now send options to be encapsulated in arbitrary options,
eg dhcp-option=encap:172,17,....... eg dhcp-option=encap:172,17,.......
Also hand vendor-identifying vendor-encapsulated options,
dhcp-option = rfc3925-encap:13,17,.......
The may be more that one "outer" to do, so group The may be more that one "outer" to do, so group
all the options which match each outer in turn. */ all the options which match each outer in turn. */
for (opt = config_opts; opt; opt = opt->next) for (opt = config_opts; opt; opt = opt->next)
opt->flags &= ~DHOPT_ENCAP_DONE; opt->flags &= ~DHOPT_ENCAP_DONE;
for (opt = config_opts; opt; opt = opt->next) for (opt = config_opts; opt; opt = opt->next)
if ((opt->flags & (DHOPT_ENCAPSULATE | DHOPT_ENCAP_DONE)) == DHOPT_ENCAPSULATE) {
{ int flags;
struct dhcp_opt *o;
int found = 0;
for (o = config_opts; o; o = o->next) if ((flags = (opt->flags & (DHOPT_ENCAPSULATE | DHOPT_RFC3925))))
{ {
o->flags &= ~DHOPT_ENCAP_MATCH; int found = 0;
if ((o->flags & DHOPT_ENCAPSULATE) && opt->u.encap == o->u.encap) struct dhcp_opt *o;
{
o->flags |= DHOPT_ENCAP_DONE;
if (match_netid(o->netid, netid, 1) &&
(o->flags & DHOPT_FORCE || in_list(req_options, o->u.encap)))
{
o->flags |= DHOPT_ENCAP_MATCH;
found = 1;
}
}
}
if (found) if (opt->flags & DHOPT_ENCAP_DONE)
do_encap_opts(config_opts, opt->u.encap, DHOPT_ENCAP_MATCH, mess, end, null_term); continue;
}
for (len = 0, o = config_opts; o; o = o->next)
{
int outer = flags & DHOPT_ENCAPSULATE ? o->u.encap : OPTION_VENDOR_IDENT_OPT;
o->flags &= ~DHOPT_ENCAP_MATCH;
if (!(o->flags & flags) || opt->u.encap != o->u.encap)
continue;
o->flags |= DHOPT_ENCAP_DONE;
if (match_netid(o->netid, netid, 1) &&
((o->flags & DHOPT_FORCE) || in_list(req_options, outer)))
{
o->flags |= DHOPT_ENCAP_MATCH;
found = 1;
len += do_opt(o, NULL, NULL, 0) + 2;
}
}
if (found)
{
if (flags & DHOPT_ENCAPSULATE)
do_encap_opts(config_opts, opt->u.encap, DHOPT_ENCAP_MATCH, mess, end, null_term);
else if (len > 250)
my_syslog(MS_DHCP | LOG_WARNING, _("cannot send RFC3925 option: too many options for enterprise number %d"), opt->u.encap);
else if ((p = free_space(mess, end, OPTION_VENDOR_IDENT_OPT, len + 5)))
{
int swap_ent = htonl(opt->u.encap);
memcpy(p, &swap_ent, 4);
p += 4;
*(p++) = len;
for (o = config_opts; o; o = o->next)
if (o->flags & DHOPT_ENCAP_MATCH)
{
len = do_opt(o, p + 2, NULL, 0);
*(p++) = o->opt;
*(p++) = len;
p += len;
}
}
}
}
}
/* Must precede pxe_opts, since it overwrites req_options */ /* Must precede pxe_opts, since it overwrites req_options */
force_encap = prune_vendor_opts(netid); force_encap = prune_vendor_opts(netid);
if (in_list(req_options, OPTION_VENDOR_CLASS_OPT)) if (in_list(req_options, OPTION_VENDOR_CLASS_OPT))
force_encap = 1; force_encap = 1;
if (pxe_arch != -1) if (context && pxe_arch != -1)
{ {
pxe_misc(mess, end, uuid); pxe_misc(mess, end, uuid);
config_opts = pxe_opts(pxe_arch, netid); config_opts = pxe_opts(pxe_arch, netid, context->local);
} }
if (force_encap) if (force_encap)
+41 -28
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -46,12 +46,13 @@ void tftp_request(struct listener *listen, time_t now)
struct sockaddr_in addr, peer; struct sockaddr_in addr, peer;
struct msghdr msg; struct msghdr msg;
struct iovec iov; struct iovec iov;
int is_err = 1, if_index = 0; struct ifreq ifr;
int is_err = 1, if_index = 0, mtu = 0;
struct iname *tmp; struct iname *tmp;
struct tftp_transfer *transfer; struct tftp_transfer *transfer;
int port = daemon->start_tftp_port; /* may be zero to use ephemeral port */ int port = daemon->start_tftp_port; /* may be zero to use ephemeral port */
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT) #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
int mtu = IP_PMTUDISC_DONT; int mtuflag = IP_PMTUDISC_DONT;
#endif #endif
union { union {
@@ -83,7 +84,10 @@ void tftp_request(struct listener *listen, time_t now)
return; return;
if (daemon->options & OPT_NOWILD) if (daemon->options & OPT_NOWILD)
addr = listen->iface->addr.in; {
addr = listen->iface->addr.in;
mtu = listen->iface->mtu;
}
else else
{ {
char name[IF_NAMESIZE]; char name[IF_NAMESIZE];
@@ -126,6 +130,9 @@ void tftp_request(struct listener *listen, time_t now)
if (tmp->name && (strcmp(tmp->name, name) == 0)) if (tmp->name && (strcmp(tmp->name, name) == 0))
return; return;
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
mtu = ifr.ifr_mtu;
} }
addr.sin_port = htons(port); addr.sin_port = htons(port);
@@ -158,7 +165,7 @@ void tftp_request(struct listener *listen, time_t now)
{ {
if (bind(transfer->sockfd, (struct sockaddr *)&addr, sizeof(addr)) == -1 || if (bind(transfer->sockfd, (struct sockaddr *)&addr, sizeof(addr)) == -1 ||
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT) #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
setsockopt(transfer->sockfd, SOL_IP, IP_MTU_DISCOVER, &mtu, sizeof(mtu)) == -1 || setsockopt(transfer->sockfd, SOL_IP, IP_MTU_DISCOVER, &mtuflag, sizeof(mtuflag)) == -1 ||
#endif #endif
!fix_fd(transfer->sockfd)) !fix_fd(transfer->sockfd))
{ {
@@ -192,42 +199,50 @@ void tftp_request(struct listener *listen, time_t now)
while ((opt = next(&p, end))) while ((opt = next(&p, end)))
{ {
if (strcasecmp(opt, "blksize") == 0 && if (strcasecmp(opt, "blksize") == 0)
(opt = next(&p, end)) &&
!(daemon->options & OPT_TFTP_NOBLOCK))
{ {
transfer->blocksize = atoi(opt); if ((opt = next(&p, end)) &&
if (transfer->blocksize < 1) !(daemon->options & OPT_TFTP_NOBLOCK))
transfer->blocksize = 1; {
if (transfer->blocksize > (unsigned)daemon->packet_buff_sz - 4) transfer->blocksize = atoi(opt);
transfer->blocksize = (unsigned)daemon->packet_buff_sz - 4; if (transfer->blocksize < 1)
transfer->opt_blocksize = 1; transfer->blocksize = 1;
transfer->block = 0; if (transfer->blocksize > (unsigned)daemon->packet_buff_sz - 4)
transfer->blocksize = (unsigned)daemon->packet_buff_sz - 4;
/* 32 bytes for IP, UDP and TFTP headers */
if (mtu != 0 && transfer->blocksize > (unsigned)mtu - 32)
transfer->blocksize = (unsigned)mtu - 32;
transfer->opt_blocksize = 1;
transfer->block = 0;
}
} }
else if (strcasecmp(opt, "tsize") == 0 && next(&p, end) && !transfer->netascii)
if (strcasecmp(opt, "tsize") == 0 && next(&p, end) && !transfer->netascii)
{ {
transfer->opt_transize = 1; transfer->opt_transize = 1;
transfer->block = 0; transfer->block = 0;
} }
} }
/* cope with backslashes from windows boxen. */
while ((p = strchr(filename, '\\')))
*p = '/';
strcpy(daemon->namebuff, "/"); strcpy(daemon->namebuff, "/");
if (daemon->tftp_prefix) if (daemon->tftp_prefix)
{ {
if (daemon->tftp_prefix[0] == '/') if (daemon->tftp_prefix[0] == '/')
daemon->namebuff[0] = 0; daemon->namebuff[0] = 0;
strncat(daemon->namebuff, daemon->tftp_prefix, MAXDNAME); strncat(daemon->namebuff, daemon->tftp_prefix, (MAXDNAME-1) - strlen(daemon->namebuff));
if (daemon->tftp_prefix[strlen(daemon->tftp_prefix)-1] != '/') if (daemon->tftp_prefix[strlen(daemon->tftp_prefix)-1] != '/')
strncat(daemon->namebuff, "/", MAXDNAME); strncat(daemon->namebuff, "/", (MAXDNAME-1) - strlen(daemon->namebuff));
if (daemon->options & OPT_TFTP_APREF) if (daemon->options & OPT_TFTP_APREF)
{ {
size_t oldlen = strlen(daemon->namebuff); size_t oldlen = strlen(daemon->namebuff);
struct stat statbuf; struct stat statbuf;
strncat(daemon->namebuff, inet_ntoa(peer.sin_addr), MAXDNAME); strncat(daemon->namebuff, inet_ntoa(peer.sin_addr), (MAXDNAME-1) - strlen(daemon->namebuff));
strncat(daemon->namebuff, "/", MAXDNAME); strncat(daemon->namebuff, "/", (MAXDNAME-1) - strlen(daemon->namebuff));
/* remove unique-directory if it doesn't exist */ /* remove unique-directory if it doesn't exist */
if (stat(daemon->namebuff, &statbuf) == -1 || !S_ISDIR(statbuf.st_mode)) if (stat(daemon->namebuff, &statbuf) == -1 || !S_ISDIR(statbuf.st_mode))
@@ -245,8 +260,7 @@ void tftp_request(struct listener *listen, time_t now)
} }
else if (filename[0] == '/') else if (filename[0] == '/')
daemon->namebuff[0] = 0; daemon->namebuff[0] = 0;
strncat(daemon->namebuff, filename, MAXDNAME); strncat(daemon->namebuff, filename, (MAXDNAME-1) - strlen(daemon->namebuff));
daemon->namebuff[MAXDNAME-1] = 0;
/* check permissions and open file */ /* check permissions and open file */
if ((transfer->file = check_tftp_fileperm(&len))) if ((transfer->file = check_tftp_fileperm(&len)))
@@ -265,7 +279,7 @@ void tftp_request(struct listener *listen, time_t now)
free_transfer(transfer); free_transfer(transfer);
else else
{ {
my_syslog(MS_TFTP | LOG_INFO, _("TFTP sent %s to %s"), daemon->namebuff, inet_ntoa(peer.sin_addr)); my_syslog(MS_TFTP | LOG_INFO, _("sent %s to %s"), daemon->namebuff, inet_ntoa(peer.sin_addr));
transfer->next = daemon->tftp_trans; transfer->next = daemon->tftp_trans;
daemon->tftp_trans = transfer; daemon->tftp_trans = transfer;
} }
@@ -399,7 +413,7 @@ void check_tftp_listeners(fd_set *rset, time_t now)
*(q++) = *r; *(q++) = *r;
*q = 0; *q = 0;
} }
my_syslog(MS_TFTP | LOG_ERR, _("TFTP error %d %s received from %s"), my_syslog(MS_TFTP | LOG_ERR, _("error %d %s received from %s"),
(int)ntohs(mess->block), err, (int)ntohs(mess->block), err,
inet_ntoa(transfer->peer.sin_addr)); inet_ntoa(transfer->peer.sin_addr));
@@ -430,7 +444,7 @@ void check_tftp_listeners(fd_set *rset, time_t now)
/* don't complain about timeout when we're awaiting the last /* don't complain about timeout when we're awaiting the last
ACK, some clients never send it */ ACK, some clients never send it */
if (len != 0) if (len != 0)
my_syslog(MS_TFTP | LOG_ERR, _("TFTP failed sending %s to %s"), my_syslog(MS_TFTP | LOG_ERR, _("failed sending %s to %s"),
transfer->file->filename, inet_ntoa(transfer->peer.sin_addr)); transfer->file->filename, inet_ntoa(transfer->peer.sin_addr));
len = 0; len = 0;
} }
@@ -489,8 +503,7 @@ static ssize_t tftp_err(int err, char *packet, char *message, char *file)
mess->op = htons(OP_ERR); mess->op = htons(OP_ERR);
mess->err = htons(err); mess->err = htons(err);
ret += (snprintf(mess->message, 500, message, file, errstr) + 1); ret += (snprintf(mess->message, 500, message, file, errstr) + 1);
if (err != ERR_FNF) my_syslog(MS_TFTP | LOG_ERR, "%s", mess->message);
my_syslog(MS_TFTP | LOG_ERR, "TFTP %s", mess->message);
return ret; return ret;
} }
+90 -25
View File
@@ -1,4 +1,4 @@
/* dnsmasq is Copyright (c) 2000-2009 Simon Kelley /* dnsmasq is Copyright (c) 2000-2010 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -24,6 +24,9 @@
#include <sys/times.h> #include <sys/times.h>
#endif #endif
#ifdef LOCALEDIR
#include <idna.h>
#endif
#ifdef HAVE_ARC4RANDOM #ifdef HAVE_ARC4RANDOM
void rand_init(void) void rand_init(void)
@@ -95,48 +98,110 @@ unsigned short rand16(void)
#endif #endif
static int check_name(char *in)
int legal_char(char c)
{ {
/* check for legal char a-z A-Z 0-9 - /* remove trailing .
(also / , used for RFC2317 and _ used in windows queries
and space, for DNS-SD stuff) */
if ((c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
c == '-' || c == '/' || c == '_' || c == ' ')
return 1;
return 0;
}
int canonicalise(char *s)
{
/* check for legal chars and remove trailing .
also fail empty string and label > 63 chars */ also fail empty string and label > 63 chars */
size_t dotgap = 0, l = strlen(s); size_t dotgap = 0, l = strlen(in);
char c; char c;
int nowhite = 0; int nowhite = 0;
if (l == 0 || l > MAXDNAME) return 0; if (l == 0 || l > MAXDNAME) return 0;
if (s[l-1] == '.') if (in[l-1] == '.')
{ {
if (l == 1) return 0; if (l == 1) return 0;
s[l-1] = 0; in[l-1] = 0;
} }
while ((c = *s)) for (; (c = *in); in++)
{ {
if (c == '.') if (c == '.')
dotgap = 0; dotgap = 0;
else if (!legal_char(c) || (++dotgap > MAXLABEL)) else if (++dotgap > MAXLABEL)
return 0; return 0;
else if (isascii(c) && iscntrl(c))
/* iscntrl only gives expected results for ascii */
return 0;
#ifndef LOCALEDIR
else if (!isascii(c))
return 0;
#endif
else if (c != ' ') else if (c != ' ')
nowhite = 1; nowhite = 1;
s++;
} }
return nowhite;
if (!nowhite)
return 0;
return 1;
}
/* Hostnames have a more limited valid charset than domain names
so check for legal char a-z A-Z 0-9 - _
Note that this may receive a FQDN, so only check the first label
for the tighter criteria. */
int legal_hostname(char *name)
{
char c;
if (!check_name(name))
return 0;
for (; (c = *name); name++)
/* check for legal char a-z A-Z 0-9 - _ . */
{
if ((c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
(c >= '0' && c <= '9') ||
c == '-' || c == '_')
continue;
/* end of hostname part */
if (c == '.')
return 1;
return 0;
}
return 1;
}
char *canonicalise(char *in, int *nomem)
{
char *ret = NULL;
#ifdef LOCALEDIR
int rc;
#endif
if (nomem)
*nomem = 0;
if (!check_name(in))
return NULL;
#ifdef LOCALEDIR
if ((rc = idna_to_ascii_lz(in, &ret, 0)) != IDNA_SUCCESS)
{
if (ret)
free(ret);
if (nomem && (rc == IDNA_MALLOC_ERROR || rc == IDNA_DLOPEN_ERROR))
{
my_syslog(LOG_ERR, _("failed to allocate memory"));
*nomem = 1;
}
return NULL;
}
#else
if ((ret = whine_malloc(strlen(in)+1)))
strcpy(ret, in);
else if (nomem)
*nomem = 1;
#endif
return ret;
} }
unsigned char *do_rfc1035_name(unsigned char *p, char *sval) unsigned char *do_rfc1035_name(unsigned char *p, char *sval)