mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-06 15:51:41 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03a97b6170 | ||
|
|
7622fc06ab |
No files matched your search
+2509
File diff suppressed because it is too large.
Load diff
@@ -23,24 +23,19 @@ PO = po
|
|||||||
MAN = man
|
MAN = man
|
||||||
|
|
||||||
PKG_CONFIG = pkg-config
|
PKG_CONFIG = pkg-config
|
||||||
AWK = nawk
|
|
||||||
INSTALL = install
|
INSTALL = install
|
||||||
|
|
||||||
DBUS_MINOR=" `echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --modversion dbus-1 | $(AWK) -F . -- '{ if ($$(NF-1)) print \"-DDBUS_MINOR=\"$$(NF-1) }'`"
|
|
||||||
DBUS_CFLAGS="`echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --cflags dbus-1`"
|
DBUS_CFLAGS="`echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --cflags dbus-1`"
|
||||||
DBUS_LIBS=" `echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --libs dbus-1`"
|
DBUS_LIBS=" `echo $(COPTS) | ../bld/pkg-wrapper $(PKG_CONFIG) --libs dbus-1`"
|
||||||
SUNOS_VER=" `if uname | grep SunOS 2>&1 >/dev/null; then uname -r | $(AWK) -F . -- '{ print \"-DSUNOS_VER=\"$$2 }'; fi`"
|
|
||||||
SUNOS_LIBS=" `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi `"
|
SUNOS_LIBS=" `if uname | grep SunOS 2>&1 >/dev/null; then echo -lsocket -lnsl -lposix4; fi `"
|
||||||
|
|
||||||
all : dnsmasq
|
all : dnsmasq
|
||||||
|
|
||||||
dnsmasq :
|
dnsmasq :
|
||||||
cd $(SRC) && $(MAKE) \
|
cd $(SRC) && $(MAKE) \
|
||||||
DBUS_MINOR=$(DBUS_MINOR) \
|
|
||||||
DBUS_CFLAGS=$(DBUS_CFLAGS) \
|
DBUS_CFLAGS=$(DBUS_CFLAGS) \
|
||||||
DBUS_LIBS=$(DBUS_LIBS) \
|
DBUS_LIBS=$(DBUS_LIBS) \
|
||||||
SUNOS_LIBS=$(SUNOS_LIBS) \
|
SUNOS_LIBS=$(SUNOS_LIBS) \
|
||||||
SUNOS_VER=$(SUNOS_VER) \
|
|
||||||
-f ../bld/Makefile dnsmasq
|
-f ../bld/Makefile dnsmasq
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
@@ -57,11 +52,9 @@ install-common :
|
|||||||
all-i18n :
|
all-i18n :
|
||||||
cd $(SRC) && $(MAKE) \
|
cd $(SRC) && $(MAKE) \
|
||||||
I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' \
|
I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' \
|
||||||
DBUS_MINOR=$(DBUS_MINOR) \
|
|
||||||
DBUS_CFLAGS=$(DBUS_CFLAGS) \
|
DBUS_CFLAGS=$(DBUS_CFLAGS) \
|
||||||
DBUS_LIBS=$(DBUS_LIBS) \
|
DBUS_LIBS=$(DBUS_LIBS) \
|
||||||
SUNOS_LIBS=$(SUNOS_LIBS) \
|
SUNOS_LIBS=$(SUNOS_LIBS) \
|
||||||
SUNOS_VER=$(SUNOS_VER) \
|
|
||||||
-f ../bld/Makefile dnsmasq
|
-f ../bld/Makefile dnsmasq
|
||||||
cd $(PO); for f in *.po; do \
|
cd $(PO); for f in *.po; do \
|
||||||
cd ../$(SRC) && $(MAKE) -f ../bld/Makefile $${f%.po}.mo; \
|
cd ../$(SRC) && $(MAKE) -f ../bld/Makefile $${f%.po}.mo; \
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
A remake of patch Bob Carroll had posted to dnsmasq,
|
||||||
|
now compatible with version 2.47. Hopefully he doesn't
|
||||||
|
mind (sending a copy of this mail to him too).
|
||||||
|
|
||||||
|
Maybe the patch in question is not acceptible
|
||||||
|
as it doesn't add new switch, rather it binds itself to "strict-order".
|
||||||
|
|
||||||
|
What it does is: if you have strict-order in the
|
||||||
|
dnsmasq config file and query a domain that would result
|
||||||
|
in NXDOMAIN, it iterates the whole given nameserver list
|
||||||
|
until the last one says NXDOMAIN.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
diff -ur dnsmasq-2.47/src/forward.c dnsmasq-2.47-patched/src/forward.c
|
||||||
|
--- dnsmasq-2.47/src/forward.c 2009-02-01 17:59:48.000000000 +0200
|
||||||
|
+++ dnsmasq-2.47-patched/src/forward.c 2009-03-18 19:10:22.000000000 +0200
|
||||||
|
@@ -488,9 +488,12 @@
|
||||||
|
return;
|
||||||
|
|
||||||
|
server = forward->sentto;
|
||||||
|
+
|
||||||
|
+ if ( (header->rcode == NXDOMAIN) && ((daemon->options & OPT_ORDER) != 0) && (server->next != NULL) )
|
||||||
|
+ header->rcode = SERVFAIL;
|
||||||
|
|
||||||
|
if ((header->rcode == SERVFAIL || header->rcode == REFUSED) &&
|
||||||
|
- !(daemon->options & OPT_ORDER) &&
|
||||||
|
+ ((daemon->options & OPT_ORDER) != 0) &&
|
||||||
|
forward->forwardall == 0)
|
||||||
|
/* for broken servers, attempt to send to another one. */
|
||||||
|
{
|
||||||
+31
-2
@@ -329,7 +329,7 @@
|
|||||||
# Reboot time. (Note 'i' to send 32-bit value)
|
# Reboot time. (Note 'i' to send 32-bit value)
|
||||||
#dhcp-option-force=211,30i
|
#dhcp-option-force=211,30i
|
||||||
|
|
||||||
# Set the boot filename for BOOTP. You will only need
|
# Set the boot filename for netboot/PXE. You will only need
|
||||||
# this is you want to boot machines over the network and you will need
|
# this is you want to boot machines over the network and you will need
|
||||||
# a TFTP server; either dnsmasq's built in TFTP server or an
|
# a TFTP server; either dnsmasq's built in TFTP server or an
|
||||||
# external one. (See below for how to enable the TFTP server.)
|
# external one. (See below for how to enable the TFTP server.)
|
||||||
@@ -358,6 +358,34 @@
|
|||||||
#dhcp-match=hammers, option:client-arch, 6 #x86-64
|
#dhcp-match=hammers, option:client-arch, 6 #x86-64
|
||||||
#dhcp-match=mactels, option:client-arch, 7 #EFI x86-64
|
#dhcp-match=mactels, option:client-arch, 7 #EFI x86-64
|
||||||
|
|
||||||
|
# Do real PXE, rather than just booting a single file, this is an
|
||||||
|
# alternative to dhcp-boot.
|
||||||
|
#pxe-prompt="What system shall I netboot?"
|
||||||
|
# or with timeout before first available action is taken:
|
||||||
|
#pxe-prompt="Press F8 for menu.", 60
|
||||||
|
|
||||||
|
# Available boot services. for PXE.
|
||||||
|
#pxe-service=x86PC, "Boot from local disk", 0
|
||||||
|
|
||||||
|
# Loads <tftp-root>/pxelinux.0 from dnsmasq TFTP server.
|
||||||
|
#pxe-service=x86PC, "Install Linux", pxelinux
|
||||||
|
|
||||||
|
# Loads <tftp-root>/pxelinux.0 from TFTP server at 1.2.3.4.
|
||||||
|
# Beware this fails on old PXE ROMS.
|
||||||
|
#pxe-service=x86PC, "Install Linux", pxelinux, 1.2.3.4
|
||||||
|
|
||||||
|
# Use bootserver on network, found my multicast or broadcast.
|
||||||
|
#pxe-service=x86PC, "Install windows from RIS server", 1
|
||||||
|
|
||||||
|
# Use bootserver at a known IP address.
|
||||||
|
#pxe-service=x86PC, "Install windows from RIS server", 1, 1.2.3.4
|
||||||
|
|
||||||
|
# If you have multicast-FTP available,
|
||||||
|
# information for that can be passed in a similar way using options 1
|
||||||
|
# to 5. See page 19 of
|
||||||
|
# http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf
|
||||||
|
|
||||||
|
|
||||||
# Enable dnsmasq's built-in TFTP server
|
# Enable dnsmasq's built-in TFTP server
|
||||||
#enable-tftp
|
#enable-tftp
|
||||||
|
|
||||||
@@ -371,8 +399,9 @@
|
|||||||
# 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
|
||||||
|
|
||||||
# An example of dhcp-boot with an external server: the name and IP
|
# An example of dhcp-boot with an external TFTP server: the name and IP
|
||||||
# address of the server are given after the filename.
|
# address of the server are given after the filename.
|
||||||
|
# Can fail with old PXE ROMS. Overridden by --pxe-service.
|
||||||
#dhcp-boot=/var/ftpd/pxelinux.0,boothost,192.168.0.3
|
#dhcp-boot=/var/ftpd/pxelinux.0,boothost,192.168.0.3
|
||||||
|
|
||||||
# Set the limit on DHCP leases, the default is 150
|
# Set the limit on DHCP leases, the default is 150
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP
|
|||||||
server and allows machines with DHCP-allocated addresses
|
server and allows machines with DHCP-allocated addresses
|
||||||
to appear in the DNS with names configured either in each host or
|
to appear in the DNS with names configured either in each host or
|
||||||
in a central configuration file. Dnsmasq supports static and dynamic
|
in a central configuration file. Dnsmasq supports static and dynamic
|
||||||
DHCP leases and BOOTP/TFTP for network booting of diskless machines.
|
DHCP leases and BOOTP/TFTP/PXE for network booting of diskless machines.
|
||||||
<P>
|
<P>
|
||||||
Dnsmasq is targeted at home networks using NAT and
|
Dnsmasq is targeted at home networks using NAT and
|
||||||
connected to the internet via a modem, cable-modem or ADSL
|
connected to the internet via a modem, cable-modem or ADSL
|
||||||
@@ -94,7 +94,10 @@ There is a good article about dnsmasq at <A
|
|||||||
HREF="http://www.enterprisenetworkingplanet.com/netos/article.php/3377351">http://www.enterprisenetworkingplanet.com/netos/article.php/3377351</A>
|
HREF="http://www.enterprisenetworkingplanet.com/netos/article.php/3377351">http://www.enterprisenetworkingplanet.com/netos/article.php/3377351</A>
|
||||||
and another at <A
|
and another at <A
|
||||||
HREF="http://www.linux.com/articles/149040">http://www.linux.com/articles/149040</A>
|
HREF="http://www.linux.com/articles/149040">http://www.linux.com/articles/149040</A>
|
||||||
and Ilya Evseev has an article in Russian about dnsmasq to be found at <A HREF="http://ilya-evseev.narod.ru/articles/dnsmasq"> http://ilya-evseev.narod.ru/articles/dnsmasq</A>
|
and Ilya Evseev has an article in Russian about dnsmasq to be found at
|
||||||
|
<A HREF="http://ilya-evseev.narod.ru/articles/dnsmasq">
|
||||||
|
http://ilya-evseev.narod.ru/articles/dnsmasq</A>. Ismael Ull has an
|
||||||
|
article about dnsmasq in Spanish at <A HREF="http://www.mey-online.com.ar/blog/index.php/archives/guia-rapida-de-dnsmasq">http://www.mey-online.com.ar/blog/index.php/archives/guia-rapida-de-dnsmasq</A>
|
||||||
<H2>License.</H2>
|
<H2>License.</H2>
|
||||||
Dnsmasq is distributed under the GPL. See the file COPYING in the distribution
|
Dnsmasq is distributed under the GPL. See the file COPYING in the distribution
|
||||||
for details.
|
for details.
|
||||||
|
|||||||
+72
-12
@@ -31,13 +31,17 @@ BSD, unless the GNU getopt library is linked, the long form of the
|
|||||||
options does not work on the command line; it is still recognised in
|
options does not work on the command line; it is still recognised in
|
||||||
the configuration file.
|
the configuration file.
|
||||||
.TP
|
.TP
|
||||||
|
.B --test
|
||||||
|
Read and syntax check configuration file(s). Exit with code 0 if all
|
||||||
|
is OK, or a non-zero code otherwise. Do not start up dnsmasq.
|
||||||
|
.TP
|
||||||
.B \-h, --no-hosts
|
.B \-h, --no-hosts
|
||||||
Don't read the hostnames in /etc/hosts.
|
Don't read the hostnames in /etc/hosts.
|
||||||
.TP
|
.TP
|
||||||
.B \-H, --addn-hosts=<file>
|
.B \-H, --addn-hosts=<file>
|
||||||
Additional hosts file. Read the specified file as well as /etc/hosts. If -h is given, read
|
Additional hosts file. Read the specified file as well as /etc/hosts. If -h is given, read
|
||||||
only the specified file. This option may be repeated for more than one
|
only the specified file. This option may be repeated for more than one
|
||||||
additional hosts file.
|
additional hosts file. If a directory is given, then read all the files contained in that directory.
|
||||||
.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
|
||||||
@@ -422,25 +426,22 @@ 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>][,<default 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
|
||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
options. If the lease time is given, then leases
|
options. If the lease time is given, then leases
|
||||||
will be given for that length of time. The lease time is in seconds,
|
will be given for that length of time. The lease time is in seconds,
|
||||||
or minutes (eg 45m) or hours (eg 1h) or the literal "infinite". The
|
or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given,
|
||||||
|
the default lease time is one hour. The
|
||||||
minimum lease time is two minutes. This
|
minimum lease time is two minutes. This
|
||||||
option may be repeated, with different addresses, to enable DHCP
|
option may be repeated, with different addresses, to enable DHCP
|
||||||
service to more than one network. For directly connected networks (ie,
|
service to more than one network. For directly connected networks (ie,
|
||||||
networks on which the machine running dnsmasq has an interface) the
|
networks on which the machine running dnsmasq has an interface) the
|
||||||
netmask is optional. It is, however, required for networks which
|
netmask is optional. It is, however, required for networks which
|
||||||
receive DHCP service via a relay agent. The broadcast address is
|
receive DHCP service via a relay agent. The broadcast address is
|
||||||
always optional. On some broken systems, dnsmasq can listen on only
|
always optional. It is always
|
||||||
one interface when using DHCP, and the name of that interface must be
|
|
||||||
given using the
|
|
||||||
.B interface
|
|
||||||
option. This limitation currently affects OpenBSD before version 4.0. It is always
|
|
||||||
allowed to have more than one dhcp-range in a single subnet. The optional
|
allowed to have more than one dhcp-range in a single subnet. The optional
|
||||||
network-id is a alphanumeric label which marks this network so that
|
network-id is a alphanumeric label which marks this network so that
|
||||||
dhcp options may be specified on a per-network basis.
|
dhcp options may be specified on a per-network basis.
|
||||||
@@ -449,10 +450,18 @@ a tag to matching it. Only one tag may be set, but more than one tag may be matc
|
|||||||
The end address may be replaced by the keyword
|
The end address may be replaced by the keyword
|
||||||
.B static
|
.B static
|
||||||
which tells dnsmasq to enable DHCP for the network specified, but not
|
which tells dnsmasq to enable DHCP for the network specified, but not
|
||||||
to dynamically allocate IP addresses. Only hosts which have static
|
to dynamically allocate IP addresses: only hosts which have static
|
||||||
addresses given via
|
addresses given via
|
||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
or from /etc/ethers will be served.
|
or from /etc/ethers will be served. The end address may be replaced by
|
||||||
|
the keyword
|
||||||
|
.B proxy
|
||||||
|
in which case dnsmasq will provide proxy-DHCP on the specified
|
||||||
|
subnet. (See
|
||||||
|
.B pxe-prompt
|
||||||
|
and
|
||||||
|
.B pxe-service
|
||||||
|
for details.)
|
||||||
.TP
|
.TP
|
||||||
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,net:<netid>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
|
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,net:<netid>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
|
||||||
Specify per host parameters for the DHCP server. This allows a machine
|
Specify per host parameters for the DHCP server. This allows a machine
|
||||||
@@ -720,6 +729,57 @@ is providing a TFTP service (see
|
|||||||
If the optional network-id(s) are given,
|
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
|
||||||
|
.B --pxe-service=[net:<network-id>,]<CSA>,<menu text>,<basename>|<bootservicetype>[,<server address>]
|
||||||
|
Most uses of PXE boot-ROMS simply allow the PXE
|
||||||
|
system to obtain an IP address and then download the file specified by
|
||||||
|
.B dhcp-boot
|
||||||
|
and execute it. However the PXE system is capable of more complex
|
||||||
|
functions when supported by a suitable DHCP server.
|
||||||
|
|
||||||
|
This specifies a boot option which may appear in a PXE boot menu. <CSA> is
|
||||||
|
client system type, only services of the correct type will appear in a
|
||||||
|
menu. The known types are x86PC, PC98, IA64_EFI, Alpha, Arc_x86,
|
||||||
|
Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI and X86-64_EFI; an
|
||||||
|
integer may be used for other types. The
|
||||||
|
parameter after the menu text may be a file name, in which case dnsmasq acts as a
|
||||||
|
boot server and directs the PXE client to download the file by TFTP,
|
||||||
|
either from itself (
|
||||||
|
.B enable-tftp
|
||||||
|
must be set for this to work) or another TFTP server if the final IP
|
||||||
|
address is given.
|
||||||
|
Note that the "layer"
|
||||||
|
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
|
||||||
|
is given, then the PXE client will search for a
|
||||||
|
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
|
||||||
|
type of 0 is special, and will abort the net boot procedure and
|
||||||
|
continue booting from local media.
|
||||||
|
.TP
|
||||||
|
.B --pxe-prompt=[net:<network-id>,]<prompt>[,<timeout>]
|
||||||
|
Setting this provides a prompt to be displayed after PXE boot. If the
|
||||||
|
timeout is given then after the
|
||||||
|
timeout has elapsed with no keyboard input, the first available menu
|
||||||
|
option will be automatically executed. If the timeout is zero then the first available menu
|
||||||
|
item will be executed immediately. If
|
||||||
|
.B pxe-prompt
|
||||||
|
is ommitted the system will wait for user input if there are multiple
|
||||||
|
items in the menu, but boot immediately if
|
||||||
|
there is only one. See
|
||||||
|
.B pxe-service
|
||||||
|
for details of menu items.
|
||||||
|
|
||||||
|
Dnsmasq supports PXE "proxy-DHCP", in this case another DHCP server on
|
||||||
|
the network is responsible for allocating IP addresses, and dnsmasq
|
||||||
|
simply provides the information given in
|
||||||
|
.B pxe-prompt
|
||||||
|
and
|
||||||
|
.B pxe-service
|
||||||
|
to allow netbooting. This mode is enabled using the
|
||||||
|
.B proxy
|
||||||
|
keyword in
|
||||||
|
.B dhcp-range.
|
||||||
.TP
|
.TP
|
||||||
.B \-X, --dhcp-lease-max=<number>
|
.B \-X, --dhcp-lease-max=<number>
|
||||||
Limits dnsmasq to the specified maximum number of DHCP leases. The
|
Limits dnsmasq to the specified maximum number of DHCP leases. The
|
||||||
@@ -829,8 +889,8 @@ to the client-id and lease length and expiry time.
|
|||||||
.TP
|
.TP
|
||||||
.B --bridge-interface=<interface>,<alias>[,<alias>]
|
.B --bridge-interface=<interface>,<alias>[,<alias>]
|
||||||
Treat DHCP request packets arriving at any of the <alias> interfaces
|
Treat DHCP request packets arriving at any of the <alias> interfaces
|
||||||
as if they had arrived at <interface>. This option is only available
|
as if they had arrived at <interface>. This option is necessary when
|
||||||
on BSD platforms, and is necessary when using "old style" bridging, since
|
using "old style" bridging on BSD platforms, since
|
||||||
packets arrive at tap interfaces which don't have an IP address.
|
packets arrive at tap interfaces which don't have an IP address.
|
||||||
.TP
|
.TP
|
||||||
.B \-s, --domain=<domain>[,<address range>]
|
.B \-s, --domain=<domain>[,<address range>]
|
||||||
|
|||||||
+121
-47
@@ -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,13 +32,20 @@ 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
|
||||||
@@ -225,15 +231,19 @@ 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
|
||||||
.TP
|
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
|
||||||
.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
|
||||||
respuestas tipo "Dominio no existe". La intención de esto es actuar
|
respuestas tipo "Dominio no existe". La intención de esto es actuar
|
||||||
@@ -449,39 +459,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 +560,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.
|
||||||
@@ -571,7 +587,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>,][vendor:[<vendor-class>],][<opt>|option:<opt-name>],[<value>[,<value>]]
|
||||||
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 +650,16 @@ 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 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>,][vendor:[<vendor-class>],]<opt>,[<value>[,<value>]]
|
||||||
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,11 +713,22 @@ 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>[,<value>]
|
||||||
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
|
||||||
.TP
|
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.
|
||||||
.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
|
||||||
network ids derivados de las clases net, host, y vendor, ignorar
|
network ids derivados de las clases net, host, y vendor, ignorar
|
||||||
@@ -729,7 +761,58 @@ dnsmasq. Si dnsmasq est
|
|||||||
el inicio atravéz de una red. Si las opcionales network-ids son brindadas,
|
el inicio atravéz de una red. Si las opcionales network-ids son brindadas,
|
||||||
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 multicast o
|
||||||
|
broadcast, o directamente a un servidor si la dirección IP es brindada. Un
|
||||||
|
tipo de servicio boot de 0 es especial, y abortará el proceso boot de red
|
||||||
|
y continuará desde 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 +859,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
|
||||||
@@ -853,10 +928,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
|
||||||
|
|||||||
+82
-17
@@ -16,9 +16,8 @@ fichier /etc/hosts afin que les noms locaux n'apparaissant pas dans les DNS
|
|||||||
globaux soient tout de même résolus, et assure également la résolution de nom
|
globaux soient tout de même résolus, et assure également la résolution de nom
|
||||||
pour les hôtes présents dans le service DHCP.
|
pour les hôtes présents dans le service DHCP.
|
||||||
.PP
|
.PP
|
||||||
Le serveur DHCP Dnsmasq DHCP supporte les définitions d'adresses statiques, les
|
Le serveur DHCP Dnsmasq DHCP supporte les définitions d'adresses statiques et les
|
||||||
réseaux multiples, le relai DHCP et les spécifications de sous-réseaux conformes
|
réseaux multiples. Il envoie par défaut un jeu raisonnable de paramètres DHCP, et
|
||||||
à la RFC3011. Il envoie par défaut un jeu raisonnable de paramètres DHCP, et
|
|
||||||
peut être configuré pour envoyer n'importe quel option DHCP.
|
peut être configuré pour envoyer n'importe quel option DHCP.
|
||||||
Il inclut un serveur TFTP sécurisé en lecture seule permettant le démarrage via
|
Il inclut un serveur TFTP sécurisé en lecture seule permettant le démarrage via
|
||||||
le réseau/PXE de clients DHCP et supporte également le protocole BOOTP.
|
le réseau/PXE de clients DHCP et supporte également le protocole BOOTP.
|
||||||
@@ -33,6 +32,11 @@ Sur BSD, à moins que le logiciel ne soit compilé avec la bibliothèque GNU
|
|||||||
getopt, la forme longue des options ne fonctionne pas en ligne de commande; Elle
|
getopt, la forme longue des options ne fonctionne pas en ligne de commande; Elle
|
||||||
est toujours supportée dans le fichier de configuration.
|
est toujours supportée dans le fichier de configuration.
|
||||||
.TP
|
.TP
|
||||||
|
.B --test
|
||||||
|
Vérifie la syntaxe du ou des fichiers de configurations. Se termine avec le
|
||||||
|
code de retour 0 si tout est OK, ou un code différent de 0 dans le cas
|
||||||
|
contraire. Ne démarre pas Dnsmasq.
|
||||||
|
.TP
|
||||||
.B \-h, --no-hosts
|
.B \-h, --no-hosts
|
||||||
Ne pas charger les noms du fichier /etc/hosts.
|
Ne pas charger les noms du fichier /etc/hosts.
|
||||||
.TP
|
.TP
|
||||||
@@ -41,7 +45,8 @@ Fichiers d'hôtes additionnels. Lire le fichier spécifié en plus de /etc/hosts
|
|||||||
Si
|
Si
|
||||||
.B -h
|
.B -h
|
||||||
est spécifié, lire uniquement le fichier spécifié. Cette option peut être
|
est spécifié, lire uniquement le fichier spécifié. Cette option peut être
|
||||||
répétée afin d'ajouter d'autres fichiers.
|
répétée afin d'ajouter d'autres fichiers. Si un répertoire est donné, lis les
|
||||||
|
fichiers contenus dans ce répertoire.
|
||||||
.TP
|
.TP
|
||||||
.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
|
||||||
@@ -497,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 par défaut>]
|
.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
|
||||||
@@ -505,7 +510,9 @@ statiquement dans l'option
|
|||||||
Si une durée de bail est donnée, alors les baux seront donnés pour cette
|
Si une durée de bail est donnée, alors les baux seront donnés pour cette
|
||||||
durée. La durée de bail est donnée en secondes, en minutes (exemple : 45m),
|
durée. La durée de bail est donnée en secondes, en minutes (exemple : 45m),
|
||||||
en heures (exemple : 1h) ou être la chaine de caractère "infinite" pour une
|
en heures (exemple : 1h) ou être la chaine de caractère "infinite" pour une
|
||||||
durée indéterminée. La valeur minimum pour un bail DHCP est de 2 minutes.
|
durée indéterminée. Si aucune valeur n'est donnée, une durée de bail par défaut
|
||||||
|
de une heure est appliquée. La valeur minimum pour un bail DHCP est de 2
|
||||||
|
minutes.
|
||||||
Cette option peut être répétée, avec différentes adresses,
|
Cette option peut être répétée, avec différentes adresses,
|
||||||
pour activer le service DHCP sur plus d'un réseau. Pour des réseaux directement
|
pour activer le service DHCP sur plus d'un réseau. Pour des réseaux directement
|
||||||
connectés (c'est-à-dire des réseaux dans lesquels la machine sur laquelle tourne
|
connectés (c'est-à-dire des réseaux dans lesquels la machine sur laquelle tourne
|
||||||
@@ -513,11 +520,8 @@ Dnsmasq possède une interface), le masque de réseau est optionnel. Il est par
|
|||||||
contre requis pour les réseaux pour lesquels le service DHCP se fait via un
|
contre requis pour les réseaux pour lesquels le service DHCP se fait via un
|
||||||
relais DHCP ("relay agent"). L'adresse de broadcast est toujours optionnelle.
|
relais DHCP ("relay agent"). L'adresse de broadcast est toujours optionnelle.
|
||||||
|
|
||||||
Sur certains systèmes, Dnsmasq ne peut écouter que sur une interface lorsqu'il
|
Il est toujours possible d'avoir plus d'une plage DHCP pour un même
|
||||||
utilise DHCP, et le nom de l'interface doit être spécifié par l'option
|
sous-réseau.
|
||||||
.B interface.
|
|
||||||
Cette limitation affecte tous les systèmes OpenBSD avant la version 4.0. Il
|
|
||||||
est toujours possible d'avoir plus d'une plage DHCP pour un même sous-réseau.
|
|
||||||
|
|
||||||
L'identifiant de réseau optionnel est un label alphanumérique qui permet de
|
L'identifiant de réseau optionnel est un label alphanumérique qui permet de
|
||||||
marquer ce réseau afin de fournir des options DHCP spécifiques à chaque réseau.
|
marquer ce réseau afin de fournir des options DHCP spécifiques à chaque réseau.
|
||||||
@@ -528,10 +532,19 @@ label, il définit le label pour laquelle la règle s'applique. Un seul label pe
|
|||||||
L'adresse de fin peut être remplacée par le mot-clef
|
L'adresse de fin peut être remplacée par le mot-clef
|
||||||
.B static
|
.B static
|
||||||
("statique") qui indique à Dnsmasq d'activer le service DHCP pour le réseau
|
("statique") qui indique à Dnsmasq d'activer le service DHCP pour le réseau
|
||||||
spécifié, mais de ne pas activer l'allocation dynamique d'adresses IP. Seuls les
|
spécifié, mais de ne pas activer l'allocation dynamique d'adresses IP : Seuls
|
||||||
hôtes possédant des adresses IP statiques fournies via
|
les hôtes possédant des adresses IP statiques fournies via
|
||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
ou présentes dans le fichier /etc/ethers seront alors servis par le DHCP.
|
ou présentes dans le fichier /etc/ethers seront alors servis par le DHCP.
|
||||||
|
|
||||||
|
L'adresse de fin peut-être remplacée par le mot-clef
|
||||||
|
.B proxy
|
||||||
|
, auquel cas Dnsmasq fournira un service de DHCP proxy pour le sous-réseau
|
||||||
|
spécifié. (voir
|
||||||
|
.B pxe-prompt
|
||||||
|
et
|
||||||
|
.B pxe-service
|
||||||
|
pour plus de détails).
|
||||||
.TP
|
.TP
|
||||||
.B \-G, --dhcp-host=[<adresse matérielle>][,id:<identifiant client>|*][,net:<identifiant de réseau>][,<adresse IP>][,<nom d'hôte>][,<durée de bail>][,ignore]
|
.B \-G, --dhcp-host=[<adresse matérielle>][,id:<identifiant client>|*][,net:<identifiant de réseau>][,<adresse IP>][,<nom d'hôte>][,<durée de bail>][,ignore]
|
||||||
Spécifie les paramètres DHCP relatifs à un hôte. Cela permet à une machine
|
Spécifie les paramètres DHCP relatifs à un hôte. Cela permet à une machine
|
||||||
@@ -828,7 +841,59 @@ le réseau.
|
|||||||
Si d'éventuels identifiants de réseau sont fournis, ils doivent coïncider avec
|
Si d'éventuels identifiants de réseau sont fournis, ils doivent coïncider avec
|
||||||
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>]
|
||||||
|
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
|
||||||
|
.B dhcp-boot
|
||||||
|
et son exécution. Cependant, le système PXE est capable de fonctions bien plus
|
||||||
|
complexes pour peu que le serveur DHCP soit adapté.
|
||||||
|
|
||||||
|
Ceci spécifie l'option de démarrage qui apparaitra dans un menu de démarrage
|
||||||
|
PXE. <CSA> est le type du système client. Seuls des types de services valides
|
||||||
|
apparaitront dans un menu. Les types connus sont x86PC, PC98, IA64_EFI, Alpha,
|
||||||
|
Arc_x86, Intel_Lean_Client, IA32_EFI, BC_EFI, Xscale_EFI et X86-64_EFI;
|
||||||
|
D'autres types peuvent-être spécifiés sous la forme d'une valeur entière. Le
|
||||||
|
paramètre après le texte correspondant à l'entrée dans le menu peut être un nom
|
||||||
|
de fichier, auquel cas Dnsmasq agit comme un serveur de démarrage et indique au
|
||||||
|
client PXE qu'il faut télécharger ce fichier via TFTP, soit depuis ce serveur
|
||||||
|
(l'option
|
||||||
|
.B enable-tftp
|
||||||
|
doit être spécifiée pour que cela marche), soit depuis un autre serveur TFTP
|
||||||
|
si une adresse de serveur est fournie.
|
||||||
|
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
|
||||||
|
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.
|
||||||
|
Cette recherche peut être faite via multicast ou broadcast, ou directement
|
||||||
|
auprès d'un serveur si son adresse IP est fournie dans l'option. Un service de
|
||||||
|
démarrage de type 0 est spécial et provoquera une interruption du démarrage par
|
||||||
|
le réseau ainsi que la poursuite du démarrage sur un média local.
|
||||||
|
.TP
|
||||||
|
.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
|
||||||
|
délai est fourni, alors la première entrée du menu de démarrage sera
|
||||||
|
automatiquement exécutée après ce délai. Si le délai vaut 0, alors la première
|
||||||
|
entrée disponible sera exécutée immédiatement. Si
|
||||||
|
.B pxe-prompt
|
||||||
|
est omis, le système attendra un choix de l'utilisateur s'il existe plusieurs
|
||||||
|
entrées dans le menu, ou démarrera immédiatement dans le cas où il n'y a qu'une
|
||||||
|
seule entrée. Voir
|
||||||
|
.B pxe-service
|
||||||
|
pour plus de détails sur les entrées de menu.
|
||||||
|
|
||||||
|
Dnsmasq peut servir de "proxy-DHCP" PXE, dans le cas où un autre serveur DHCP
|
||||||
|
sur le réseau est responsable de l'allocation des adresses IP, auquel cas
|
||||||
|
Dnsmasq se contente de fournir les informations données dans les options
|
||||||
|
.B pxe-prompt
|
||||||
|
et
|
||||||
|
.B pxe-service
|
||||||
|
pour permettre le démarrage par le réseau. Ce mode est activé en utilisant le
|
||||||
|
mot-clef
|
||||||
|
.B proxy
|
||||||
|
dans
|
||||||
|
.B dhcp-range.
|
||||||
|
.TP
|
||||||
.B \-X, --dhcp-lease-max=<nombre>
|
.B \-X, --dhcp-lease-max=<nombre>
|
||||||
Limite Dnsmasq à un maximum de <nombre> baux DHCP. Le défaut est de 150. Cette
|
Limite Dnsmasq à un maximum de <nombre> baux DHCP. Le défaut est de 150. Cette
|
||||||
limite permet d'éviter des attaques de déni de service ("DoS") par des hôtes
|
limite permet d'éviter des attaques de déni de service ("DoS") par des hôtes
|
||||||
@@ -951,9 +1016,9 @@ longueur de bail ou de date d'expiration.
|
|||||||
.B --bridge-interface=<interface>,<alias>[,<alias>]
|
.B --bridge-interface=<interface>,<alias>[,<alias>]
|
||||||
Traiter les requêtes DHCP arrivant sur n'importe laquelle des interfaces <alias>
|
Traiter les requêtes DHCP arrivant sur n'importe laquelle des interfaces <alias>
|
||||||
comme si elles arrivaient de l'interface <interface>. Cette option est
|
comme si elles arrivaient de l'interface <interface>. Cette option est
|
||||||
uniquement disponible sur les plateformes BSD, et est uniquement nécessaire
|
nécessaire lors de l'utilisation de pont ethernet "ancien mode" sur plate-forme
|
||||||
lors de l'utilisation de pont ethernet "ancien mode", puisque dans ce cas les
|
BSD, puisque dans ce cas les paquets arrivent sur des interfaces "tap" n'ont
|
||||||
paquets arrivent sur des interfaces "tap" n'ayant pas d'adresse IP.
|
pas d'adresse IP.
|
||||||
.TP
|
.TP
|
||||||
.B \-s, --domain=<domaine>[,<gamme d'adresses>]
|
.B \-s, --domain=<domaine>[,<gamme d'adresses>]
|
||||||
Spécifie le domaine du serveur DHCP. Le domaine peut être donné de manière
|
Spécifie le domaine du serveur DHCP. Le domaine peut être donné de manière
|
||||||
|
|||||||
+357
-333
File diff suppressed because it is too large.
Load diff
@@ -130,7 +130,7 @@ int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_BSD_NETWORK)
|
#if defined(HAVE_BSD_NETWORK) && defined(HAVE_DHCP)
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
|
|
||||||
void init_bpf(void)
|
void init_bpf(void)
|
||||||
@@ -175,7 +175,7 @@ void send_via_bpf(struct dhcp_packet *mess, size_t len,
|
|||||||
/* Only know how to do ethernet on *BSD */
|
/* Only know how to do ethernet on *BSD */
|
||||||
if (mess->htype != ARPHRD_ETHER || mess->hlen != ETHER_ADDR_LEN)
|
if (mess->htype != ARPHRD_ETHER || mess->hlen != ETHER_ADDR_LEN)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_WARNING, _("DHCP request for unsupported hardware type (%d) received on %s"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("DHCP request for unsupported hardware type (%d) received on %s"),
|
||||||
mess->htype, ifr->ifr_name);
|
mess->htype, ifr->ifr_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+126
-20
@@ -17,7 +17,10 @@
|
|||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
|
|
||||||
static struct crec *cache_head = NULL, *cache_tail = NULL, **hash_table = NULL;
|
static struct crec *cache_head = NULL, *cache_tail = NULL, **hash_table = NULL;
|
||||||
static struct crec *dhcp_spare = NULL, *new_chain = NULL;
|
#ifdef HAVE_DHCP
|
||||||
|
static struct crec *dhcp_spare = NULL;
|
||||||
|
#endif
|
||||||
|
static struct crec *new_chain = NULL;
|
||||||
static int cache_inserted = 0, cache_live_freed = 0, insert_error;
|
static int cache_inserted = 0, cache_live_freed = 0, insert_error;
|
||||||
static union bigname *big_free = NULL;
|
static union bigname *big_free = NULL;
|
||||||
static int bignames_left, hash_size;
|
static int bignames_left, hash_size;
|
||||||
@@ -859,10 +862,11 @@ static int read_hostsfile(char *filename, int index, int cache_size)
|
|||||||
return name_count;
|
return name_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cache_reload(struct hostsfile *addn_hosts)
|
void cache_reload(void)
|
||||||
{
|
{
|
||||||
struct crec *cache, **up, *tmp;
|
struct crec *cache, **up, *tmp;
|
||||||
int i, total_size = daemon->cachesize;
|
int i, total_size = daemon->cachesize;
|
||||||
|
struct hostsfile *ah;
|
||||||
|
|
||||||
cache_inserted = cache_live_freed = 0;
|
cache_inserted = cache_live_freed = 0;
|
||||||
|
|
||||||
@@ -889,7 +893,7 @@ void cache_reload(struct hostsfile *addn_hosts)
|
|||||||
up = &cache->hash_next;
|
up = &cache->hash_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((daemon->options & OPT_NO_HOSTS) && !addn_hosts)
|
if ((daemon->options & OPT_NO_HOSTS) && !daemon->addn_hosts)
|
||||||
{
|
{
|
||||||
if (daemon->cachesize > 0)
|
if (daemon->cachesize > 0)
|
||||||
my_syslog(LOG_INFO, _("cleared cache"));
|
my_syslog(LOG_INFO, _("cleared cache"));
|
||||||
@@ -898,13 +902,116 @@ void cache_reload(struct hostsfile *addn_hosts)
|
|||||||
|
|
||||||
if (!(daemon->options & OPT_NO_HOSTS))
|
if (!(daemon->options & OPT_NO_HOSTS))
|
||||||
total_size = read_hostsfile(HOSTSFILE, 0, total_size);
|
total_size = read_hostsfile(HOSTSFILE, 0, total_size);
|
||||||
while (addn_hosts)
|
|
||||||
|
for (i = 0, ah = daemon->addn_hosts; ah; ah = ah->next)
|
||||||
{
|
{
|
||||||
total_size = read_hostsfile(addn_hosts->fname, addn_hosts->index, total_size);
|
if (i <= ah->index)
|
||||||
addn_hosts = addn_hosts->next;
|
i = ah->index + 1;
|
||||||
}
|
|
||||||
|
if (ah->flags & AH_DIR)
|
||||||
|
ah->flags |= AH_INACTIVE;
|
||||||
|
else
|
||||||
|
ah->flags &= ~AH_INACTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
||||||
|
if (!(ah->flags & AH_INACTIVE))
|
||||||
|
{
|
||||||
|
struct stat buf;
|
||||||
|
if (stat(ah->fname, &buf) != -1 && S_ISDIR(buf.st_mode))
|
||||||
|
{
|
||||||
|
DIR *dir_stream;
|
||||||
|
struct dirent *ent;
|
||||||
|
|
||||||
|
/* don't read this as a file */
|
||||||
|
ah->flags |= AH_INACTIVE;
|
||||||
|
|
||||||
|
if (!(dir_stream = opendir(ah->fname)))
|
||||||
|
my_syslog(LOG_ERR, _("cannot access directory %s: %s"),
|
||||||
|
ah->fname, strerror(errno));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while ((ent = readdir(dir_stream)))
|
||||||
|
{
|
||||||
|
size_t lendir = strlen(ah->fname);
|
||||||
|
size_t lenfile = strlen(ent->d_name);
|
||||||
|
struct hostsfile *ah1;
|
||||||
|
char *path;
|
||||||
|
|
||||||
|
/* ignore emacs backups and dotfiles */
|
||||||
|
if (lenfile == 0 ||
|
||||||
|
ent->d_name[lenfile - 1] == '~' ||
|
||||||
|
(ent->d_name[0] == '#' && ent->d_name[lenfile - 1] == '#') ||
|
||||||
|
ent->d_name[0] == '.')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* see if we have an existing record.
|
||||||
|
dir is ah->fname
|
||||||
|
file is ent->d_name
|
||||||
|
path to match is ah1->fname */
|
||||||
|
|
||||||
|
for (ah1 = daemon->addn_hosts; ah1; ah1 = ah1->next)
|
||||||
|
{
|
||||||
|
if (lendir < strlen(ah1->fname) &&
|
||||||
|
strstr(ah1->fname, ah->fname) == ah1->fname &&
|
||||||
|
ah1->fname[lendir] == '/' &&
|
||||||
|
strcmp(ah1->fname + lendir + 1, ent->d_name) == 0)
|
||||||
|
{
|
||||||
|
ah1->flags &= ~AH_INACTIVE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* make new record */
|
||||||
|
if (!ah1)
|
||||||
|
{
|
||||||
|
if (!(ah1 = whine_malloc(sizeof(struct hostsfile))))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!(path = whine_malloc(lendir + lenfile + 2)))
|
||||||
|
{
|
||||||
|
free(ah1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(path, ah->fname);
|
||||||
|
strcat(path, "/");
|
||||||
|
strcat(path, ent->d_name);
|
||||||
|
ah1->fname = path;
|
||||||
|
ah1->index = i++;
|
||||||
|
ah1->flags = AH_DIR;
|
||||||
|
ah1->next = daemon->addn_hosts;
|
||||||
|
daemon->addn_hosts = ah1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* inactivate record if not regular file */
|
||||||
|
if ((ah1->flags & AH_DIR) && stat(ah1->fname, &buf) != -1 && !S_ISREG(buf.st_mode))
|
||||||
|
ah1->flags |= AH_INACTIVE;
|
||||||
|
|
||||||
|
}
|
||||||
|
closedir(dir_stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
||||||
|
if (!(ah->flags & AH_INACTIVE))
|
||||||
|
total_size = read_hostsfile(ah->fname, ah->index, total_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *get_domain(struct in_addr addr)
|
||||||
|
{
|
||||||
|
struct cond_domain *c;
|
||||||
|
|
||||||
|
for (c = daemon->cond_domain; c; c = c->next)
|
||||||
|
if (ntohl(addr.s_addr) >= ntohl(c->start.s_addr) &&
|
||||||
|
ntohl(addr.s_addr) <= ntohl(c->end.s_addr))
|
||||||
|
return c->domain;
|
||||||
|
|
||||||
|
return daemon->domain_suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
void cache_unhash_dhcp(void)
|
void cache_unhash_dhcp(void)
|
||||||
{
|
{
|
||||||
struct crec *cache, **up;
|
struct crec *cache, **up;
|
||||||
@@ -942,7 +1049,7 @@ void cache_add_dhcp_entry(char *host_name,
|
|||||||
_("not giving name %s to the DHCP lease of %s because "
|
_("not giving name %s to the DHCP lease of %s because "
|
||||||
"the name exists in %s with address %s"),
|
"the name exists in %s with address %s"),
|
||||||
host_name, inet_ntoa(*host_address),
|
host_name, inet_ntoa(*host_address),
|
||||||
record_source(daemon->addn_hosts, crec->uid), daemon->namebuff);
|
record_source(crec->uid), daemon->namebuff);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1009,6 +1116,7 @@ void cache_add_dhcp_entry(char *host_name,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void dump_cache(time_t now)
|
void dump_cache(time_t now)
|
||||||
@@ -1099,20 +1207,18 @@ void dump_cache(time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *record_source(struct hostsfile *addn_hosts, int index)
|
char *record_source(int index)
|
||||||
{
|
{
|
||||||
char *source = HOSTSFILE;
|
struct hostsfile *ah;
|
||||||
while (addn_hosts)
|
|
||||||
{
|
|
||||||
if (addn_hosts->index == index)
|
|
||||||
{
|
|
||||||
source = addn_hosts->fname;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
addn_hosts = addn_hosts->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
return source;
|
if (index == 0)
|
||||||
|
return HOSTSFILE;
|
||||||
|
|
||||||
|
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
||||||
|
if (ah->index == index)
|
||||||
|
return ah->fname;
|
||||||
|
|
||||||
|
return "<unknown>";
|
||||||
}
|
}
|
||||||
|
|
||||||
void querystr(char *str, unsigned short type)
|
void querystr(char *str, unsigned short type)
|
||||||
|
|||||||
+13
-38
@@ -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 VERSION "2.47"
|
#define VERSION "2.49"
|
||||||
|
|
||||||
#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 */
|
||||||
@@ -106,9 +106,6 @@ HAVE_BSD_NETWORK
|
|||||||
HAVE_SOLARIS_NETWORK
|
HAVE_SOLARIS_NETWORK
|
||||||
define exactly one of these to alter interaction with kernel networking.
|
define exactly one of these to alter interaction with kernel networking.
|
||||||
|
|
||||||
HAVE_SOLARIS_PRIVS
|
|
||||||
define for Solaris > 10 which can split privileges.
|
|
||||||
|
|
||||||
HAVE_BROKEN_RTC
|
HAVE_BROKEN_RTC
|
||||||
define this on embedded systems which don't have an RTC
|
define this on embedded systems which don't have an RTC
|
||||||
which keeps time over reboots. Causes dnsmasq to use uptime
|
which keeps time over reboots. Causes dnsmasq to use uptime
|
||||||
@@ -126,6 +123,9 @@ HAVE_BROKEN_RTC
|
|||||||
HAVE_TFTP
|
HAVE_TFTP
|
||||||
define this to get dnsmasq's built-in TFTP server.
|
define this to get dnsmasq's built-in TFTP server.
|
||||||
|
|
||||||
|
HAVE_DHCP
|
||||||
|
define this to get dnsmasq's DHCP server.
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
@@ -141,11 +141,6 @@ HAVE_DBUS
|
|||||||
define some methods to allow (re)configuration of the upstream DNS
|
define some methods to allow (re)configuration of the upstream DNS
|
||||||
servers via DBus.
|
servers via DBus.
|
||||||
|
|
||||||
HAVE_BSD_BRIDGE
|
|
||||||
Define this to enable the --bridge-interface option, useful on some
|
|
||||||
BSD systems.
|
|
||||||
|
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
For Linux you should define
|
For Linux you should define
|
||||||
HAVE_LINUX_NETWORK
|
HAVE_LINUX_NETWORK
|
||||||
@@ -165,6 +160,7 @@ NOTES:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* platform independent options- uncomment to enable */
|
/* platform independent options- uncomment to enable */
|
||||||
|
#define HAVE_DHCP
|
||||||
#define HAVE_TFTP
|
#define HAVE_TFTP
|
||||||
/* #define HAVE_BROKEN_RTC */
|
/* #define HAVE_BROKEN_RTC */
|
||||||
/* #define HAVE_DBUS */
|
/* #define HAVE_DBUS */
|
||||||
@@ -174,6 +170,11 @@ NOTES:
|
|||||||
#undef HAVE_TFTP
|
#undef HAVE_TFTP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Allow DHCP to be disabled with COPTS=-DNO_DHCP */
|
||||||
|
#ifdef NO_DHCP
|
||||||
|
#undef HAVE_DHCP
|
||||||
|
#endif
|
||||||
|
|
||||||
/* platform dependent options. */
|
/* platform dependent options. */
|
||||||
|
|
||||||
/* Must preceed __linux__ since uClinux defines __linux__ too. */
|
/* Must preceed __linux__ since uClinux defines __linux__ too. */
|
||||||
@@ -211,13 +212,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
|
||||||
/* glibc < 2.2 has broken Sockaddr_in6 so we have to use our own. */
|
|
||||||
/* glibc < 2.2 doesn't define in_addr_t */
|
|
||||||
#if defined(__GLIBC__) && (__GLIBC__ == 2) && \
|
|
||||||
defined(__GLIBC_MINOR__) && (__GLIBC_MINOR__ < 2)
|
|
||||||
typedef unsigned long in_addr_t;
|
|
||||||
# define HAVE_BROKEN_SOCKADDR_IN6
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(__FreeBSD__) || \
|
#elif defined(__FreeBSD__) || \
|
||||||
defined(__OpenBSD__) || \
|
defined(__OpenBSD__) || \
|
||||||
@@ -232,7 +226,6 @@ typedef unsigned long in_addr_t;
|
|||||||
# define HAVE_ARC4RANDOM
|
# define HAVE_ARC4RANDOM
|
||||||
#endif
|
#endif
|
||||||
#define HAVE_SOCKADDR_SA_LEN
|
#define HAVE_SOCKADDR_SA_LEN
|
||||||
#define HAVE_BSD_BRIDGE
|
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#define HAVE_BSD_NETWORK
|
#define HAVE_BSD_NETWORK
|
||||||
@@ -247,34 +240,16 @@ typedef unsigned long in_addr_t;
|
|||||||
#define HAVE_GETOPT_LONG
|
#define HAVE_GETOPT_LONG
|
||||||
#undef HAVE_ARC4RANDOM
|
#undef HAVE_ARC4RANDOM
|
||||||
#define HAVE_SOCKADDR_SA_LEN
|
#define HAVE_SOCKADDR_SA_LEN
|
||||||
#define HAVE_BSD_BRIDGE
|
|
||||||
|
|
||||||
#elif defined(__sun) || defined(__sun__)
|
#elif defined(__sun) || defined(__sun__)
|
||||||
#define HAVE_SOLARIS_NETWORK
|
#define HAVE_SOLARIS_NETWORK
|
||||||
/* only Solaris 10 does split privs. */
|
#define HAVE_GETOPT_LONG
|
||||||
#if (SUNOS_VER >= 10)
|
|
||||||
# define HAVE_SOLARIS_PRIVS
|
|
||||||
# define HAVE_GETOPT_LONG
|
|
||||||
#endif
|
|
||||||
/* some CMSG stuff missing on early solaris */
|
|
||||||
#ifndef OSSH_ALIGNBYTES
|
|
||||||
# define OSSH_ALIGNBYTES (sizeof(int) - 1)
|
|
||||||
#endif
|
|
||||||
#ifndef __CMSG_ALIGN
|
|
||||||
# define __CMSG_ALIGN(p) (((u_int)(p) + OSSH_ALIGNBYTES) &~ OSSH_ALIGNBYTES)
|
|
||||||
#endif
|
|
||||||
#ifndef CMSG_LEN
|
|
||||||
# define CMSG_LEN(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
|
|
||||||
#endif
|
|
||||||
#ifndef CMSG_SPACE
|
|
||||||
# define CMSG_SPACE(len) (__CMSG_ALIGN(sizeof(struct cmsghdr)) + __CMSG_ALIGN(len))
|
|
||||||
#endif
|
|
||||||
#undef HAVE_ARC4RANDOM
|
#undef HAVE_ARC4RANDOM
|
||||||
#undef HAVE_SOCKADDR_SA_LEN
|
#undef HAVE_SOCKADDR_SA_LEN
|
||||||
|
|
||||||
#define _XPG4_2
|
#define _XPG4_2
|
||||||
#define __EXTENSIONS__
|
#define __EXTENSIONS__
|
||||||
#define ETHER_ADDR_LEN 6
|
#define ETHER_ADDR_LEN 6
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Decide if we're going to support IPv6 */
|
/* Decide if we're going to support IPv6 */
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
|
|
||||||
#define DBUS_API_SUBJECT_TO_CHANGE
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
const char* introspection_xml =
|
const char* introspection_xml =
|
||||||
@@ -345,11 +344,7 @@ void set_dbus_listeners(int *maxfdp,
|
|||||||
if (dbus_watch_get_enabled(w->watch))
|
if (dbus_watch_get_enabled(w->watch))
|
||||||
{
|
{
|
||||||
unsigned int flags = dbus_watch_get_flags(w->watch);
|
unsigned int flags = dbus_watch_get_flags(w->watch);
|
||||||
#if (DBUS_MINOR > 0)
|
|
||||||
int fd = dbus_watch_get_unix_fd(w->watch);
|
int fd = dbus_watch_get_unix_fd(w->watch);
|
||||||
#else
|
|
||||||
int fd = dbus_watch_get_fd(w->watch);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bump_maxfd(fd, maxfdp);
|
bump_maxfd(fd, maxfdp);
|
||||||
|
|
||||||
@@ -372,11 +367,7 @@ void check_dbus_listeners(fd_set *rset, fd_set *wset, fd_set *eset)
|
|||||||
if (dbus_watch_get_enabled(w->watch))
|
if (dbus_watch_get_enabled(w->watch))
|
||||||
{
|
{
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
#if (DBUS_MINOR > 0)
|
|
||||||
int fd = dbus_watch_get_unix_fd(w->watch);
|
int fd = dbus_watch_get_unix_fd(w->watch);
|
||||||
#else
|
|
||||||
int fd = dbus_watch_get_fd(w->watch);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (FD_ISSET(fd, rset))
|
if (FD_ISSET(fd, rset))
|
||||||
flags |= DBUS_WATCH_READABLE;
|
flags |= DBUS_WATCH_READABLE;
|
||||||
|
|||||||
+76
-82
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
|
|
||||||
struct iface_param {
|
struct iface_param {
|
||||||
struct in_addr relay, primary;
|
struct in_addr relay, primary;
|
||||||
struct dhcp_context *current;
|
struct dhcp_context *current;
|
||||||
@@ -35,7 +37,7 @@ void dhcp_init(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
die (_("cannot create DHCP socket : %s"), NULL, EC_BADNET);
|
die (_("cannot create DHCP socket: %s"), NULL, EC_BADNET);
|
||||||
|
|
||||||
if (!fix_fd(fd) ||
|
if (!fix_fd(fd) ||
|
||||||
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
|
#if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
|
||||||
@@ -43,7 +45,7 @@ void dhcp_init(void)
|
|||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
setsockopt(fd, SOL_IP, IP_PKTINFO, &oneopt, sizeof(oneopt)) == -1 ||
|
setsockopt(fd, SOL_IP, IP_PKTINFO, &oneopt, sizeof(oneopt)) == -1 ||
|
||||||
#elif defined(IP_RECVIF)
|
#else
|
||||||
setsockopt(fd, IPPROTO_IP, IP_RECVIF, &oneopt, sizeof(oneopt)) == -1 ||
|
setsockopt(fd, IPPROTO_IP, IP_RECVIF, &oneopt, sizeof(oneopt)) == -1 ||
|
||||||
#endif
|
#endif
|
||||||
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &oneopt, sizeof(oneopt)) == -1)
|
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &oneopt, sizeof(oneopt)) == -1)
|
||||||
@@ -51,12 +53,7 @@ void dhcp_init(void)
|
|||||||
|
|
||||||
/* When bind-interfaces is set, there might be more than one dnmsasq
|
/* When bind-interfaces is set, there might be more than one dnmsasq
|
||||||
instance binding port 67. That's OK if they serve different networks.
|
instance binding port 67. That's OK if they serve different networks.
|
||||||
Need to set REUSEADDR to make this posible, or REUSEPORT on *BSD.
|
Need to set REUSEADDR to make this posible, or REUSEPORT on *BSD. */
|
||||||
OpenBSD <= 4.0 screws up IP_RECVIF when SO_REUSEPORT is set, but
|
|
||||||
OpenBSD <= 3.9 doesn't have IP_RECVIF anyway, so we just have to elide
|
|
||||||
this for OpenBSD 4.0, if you want more than one instance on oBSD4.0, tough. */
|
|
||||||
|
|
||||||
#ifndef OpenBSD4_0
|
|
||||||
if (daemon->options & OPT_NOWILD)
|
if (daemon->options & OPT_NOWILD)
|
||||||
{
|
{
|
||||||
#ifdef SO_REUSEPORT
|
#ifdef SO_REUSEPORT
|
||||||
@@ -67,7 +64,6 @@ void dhcp_init(void)
|
|||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
die(_("failed to set SO_REUSE{ADDR|PORT} on DHCP socket: %s"), NULL, EC_BADNET);
|
die(_("failed to set SO_REUSE{ADDR|PORT} on DHCP socket: %s"), NULL, EC_BADNET);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
memset(&saddr, 0, sizeof(saddr));
|
memset(&saddr, 0, sizeof(saddr));
|
||||||
saddr.sin_family = AF_INET;
|
saddr.sin_family = AF_INET;
|
||||||
@@ -124,7 +120,7 @@ void dhcp_packet(time_t now)
|
|||||||
char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
||||||
#elif defined(HAVE_SOLARIS_NETWORK)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
char control[CMSG_SPACE(sizeof(unsigned int))];
|
char control[CMSG_SPACE(sizeof(unsigned int))];
|
||||||
#elif defined(IP_RECVIF)
|
#elif defined(HAVE_BSD_NETWORK)
|
||||||
char control[CMSG_SPACE(sizeof(struct sockaddr_dl))];
|
char control[CMSG_SPACE(sizeof(struct sockaddr_dl))];
|
||||||
#endif
|
#endif
|
||||||
} control_u;
|
} control_u;
|
||||||
@@ -136,13 +132,30 @@ void dhcp_packet(time_t now)
|
|||||||
msg.msg_iov = &daemon->dhcp_packet;
|
msg.msg_iov = &daemon->dhcp_packet;
|
||||||
msg.msg_iovlen = 1;
|
msg.msg_iovlen = 1;
|
||||||
|
|
||||||
do
|
while (1)
|
||||||
{
|
{
|
||||||
msg.msg_flags = 0;
|
msg.msg_flags = 0;
|
||||||
while ((sz = recvmsg(daemon->dhcpfd, &msg, MSG_PEEK)) == -1 && errno == EINTR);
|
while ((sz = recvmsg(daemon->dhcpfd, &msg, MSG_PEEK | MSG_TRUNC)) == -1 && errno == EINTR);
|
||||||
|
|
||||||
|
if (sz == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(msg.msg_flags & MSG_TRUNC))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Very new Linux kernels return the actual size needed,
|
||||||
|
older ones always return truncated size */
|
||||||
|
if ((size_t)sz == daemon->dhcp_packet.iov_len)
|
||||||
|
{
|
||||||
|
if (!expand_buf(&daemon->dhcp_packet, sz + 100))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
expand_buf(&daemon->dhcp_packet, sz);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (sz != -1 && (msg.msg_flags & MSG_TRUNC) &&
|
|
||||||
expand_buf(&daemon->dhcp_packet, daemon->dhcp_packet.iov_len + 100));
|
|
||||||
|
|
||||||
/* expand_buf may have moved buffer */
|
/* expand_buf may have moved buffer */
|
||||||
mess = (struct dhcp_packet *)daemon->dhcp_packet.iov_base;
|
mess = (struct dhcp_packet *)daemon->dhcp_packet.iov_base;
|
||||||
@@ -154,7 +167,7 @@ void dhcp_packet(time_t now)
|
|||||||
|
|
||||||
while ((sz = recvmsg(daemon->dhcpfd, &msg, 0)) == -1 && errno == EINTR);
|
while ((sz = recvmsg(daemon->dhcpfd, &msg, 0)) == -1 && errno == EINTR);
|
||||||
|
|
||||||
if (sz < (ssize_t)(sizeof(*mess) - sizeof(mess->options)))
|
if ((msg.msg_flags & MSG_TRUNC) || sz < (ssize_t)(sizeof(*mess) - sizeof(mess->options)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined (HAVE_LINUX_NETWORK)
|
#if defined (HAVE_LINUX_NETWORK)
|
||||||
@@ -166,41 +179,31 @@ void dhcp_packet(time_t now)
|
|||||||
if (((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_addr.s_addr != INADDR_BROADCAST)
|
if (((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_addr.s_addr != INADDR_BROADCAST)
|
||||||
unicast_dest = 1;
|
unicast_dest = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ifr.ifr_ifindex = iface_index) ||
|
#elif defined(HAVE_BSD_NETWORK)
|
||||||
ioctl(daemon->dhcpfd, SIOCGIFNAME, &ifr) == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
#elif defined(IP_RECVIF)
|
|
||||||
if (msg.msg_controllen >= sizeof(struct cmsghdr))
|
if (msg.msg_controllen >= sizeof(struct cmsghdr))
|
||||||
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 == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
|
||||||
iface_index = *((unsigned int *)CMSG_DATA(cmptr));
|
|
||||||
#else
|
|
||||||
iface_index = ((struct sockaddr_dl *)CMSG_DATA(cmptr))->sdl_index;
|
iface_index = ((struct sockaddr_dl *)CMSG_DATA(cmptr))->sdl_index;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!iface_index || !if_indextoname(iface_index, ifr.ifr_name))
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
|
if (msg.msg_controllen >= sizeof(struct cmsghdr))
|
||||||
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
|
iface_index = *((unsigned int *)CMSG_DATA(cmptr));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!indextoname(daemon->dhcpfd, iface_index, ifr.ifr_name))
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef MSG_BCAST
|
#ifdef MSG_BCAST
|
||||||
/* OpenBSD tells us when a packet was broadcast */
|
/* OpenBSD tells us when a packet was broadcast */
|
||||||
if (!(msg.msg_flags & MSG_BCAST))
|
if (!(msg.msg_flags & MSG_BCAST))
|
||||||
unicast_dest = 1;
|
unicast_dest = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
|
||||||
/* fallback for systems without IP_RECVIF - allow only one interface
|
|
||||||
and assume packets arrive from it - yuk. */
|
|
||||||
{
|
|
||||||
struct iname *name;
|
|
||||||
for (name = daemon->if_names; name->isloop; name = name->next);
|
|
||||||
strcpy(ifr.ifr_name, name->name);
|
|
||||||
iface_index = if_nametoindex(name->name);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ifr.ifr_addr.sa_family = AF_INET;
|
ifr.ifr_addr.sa_family = AF_INET;
|
||||||
if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 )
|
if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1 )
|
||||||
{
|
{
|
||||||
@@ -208,7 +211,7 @@ void dhcp_packet(time_t now)
|
|||||||
iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
|
iface_addr = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iface_check(AF_INET, (struct all_addr *)addrp, &ifr, &iface_index))
|
if (!iface_check(AF_INET, (struct all_addr *)addrp, ifr.ifr_name, &iface_index))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
@@ -218,9 +221,9 @@ void dhcp_packet(time_t now)
|
|||||||
/* interface may have been changed by alias in iface_check */
|
/* interface may have been changed by alias in iface_check */
|
||||||
if (!addrp)
|
if (!addrp)
|
||||||
{
|
{
|
||||||
if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) != -1)
|
if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) == -1)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
|
my_syslog(MS_DHCP | LOG_WARNING, _("DHCP packet received on %s which has no address"), ifr.ifr_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -319,7 +322,7 @@ void dhcp_packet(time_t now)
|
|||||||
dest.sin_addr.s_addr = INADDR_BROADCAST;
|
dest.sin_addr.s_addr = INADDR_BROADCAST;
|
||||||
dest.sin_port = htons(daemon->dhcp_client_port);
|
dest.sin_port = htons(daemon->dhcp_client_port);
|
||||||
/* note that we don't specify the interface here: that's done by the
|
/* note that we don't specify the interface here: that's done by the
|
||||||
IP_XMIT_IF sockopt lower down. */
|
IP_BOUND_IF sockopt lower down. */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -345,12 +348,7 @@ void dhcp_packet(time_t now)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
#ifdef HAVE_SOLARIS_NETWORK
|
||||||
/* OpenSolaris eliminates IP_XMIT_IF */
|
|
||||||
# ifdef IP_XMIT_IF
|
|
||||||
setsockopt(daemon->dhcpfd, IPPROTO_IP, IP_XMIT_IF, &iface_index, sizeof(iface_index));
|
|
||||||
# else
|
|
||||||
setsockopt(daemon->dhcpfd, IPPROTO_IP, IP_BOUND_IF, &iface_index, sizeof(iface_index));
|
setsockopt(daemon->dhcpfd, IPPROTO_IP, IP_BOUND_IF, &iface_index, sizeof(iface_index));
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while(sendmsg(daemon->dhcpfd, &msg, 0) == -1 && retry_send());
|
while(sendmsg(daemon->dhcpfd, &msg, 0) == -1 && retry_send());
|
||||||
@@ -384,7 +382,7 @@ static int complete_context(struct in_addr local, int if_index,
|
|||||||
{
|
{
|
||||||
strcpy(daemon->dhcp_buff, inet_ntoa(context->start));
|
strcpy(daemon->dhcp_buff, inet_ntoa(context->start));
|
||||||
strcpy(daemon->dhcp_buff2, inet_ntoa(context->end));
|
strcpy(daemon->dhcp_buff2, inet_ntoa(context->end));
|
||||||
my_syslog(LOG_WARNING, _("DHCP range %s -- %s is not consistent with netmask %s"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("DHCP range %s -- %s is not consistent with netmask %s"),
|
||||||
daemon->dhcp_buff, daemon->dhcp_buff2, inet_ntoa(netmask));
|
daemon->dhcp_buff, daemon->dhcp_buff2, inet_ntoa(netmask));
|
||||||
}
|
}
|
||||||
context->netmask = netmask;
|
context->netmask = netmask;
|
||||||
@@ -474,9 +472,9 @@ struct dhcp_context *narrow_context(struct dhcp_context *context,
|
|||||||
if (!(tmp = address_available(context, taddr, netids)))
|
if (!(tmp = address_available(context, taddr, netids)))
|
||||||
{
|
{
|
||||||
for (tmp = context; tmp; tmp = tmp->current)
|
for (tmp = context; tmp; tmp = tmp->current)
|
||||||
if (is_same_net(taddr, tmp->start, tmp->netmask) &&
|
if (is_same_net(taddr, tmp->start, tmp->netmask) &&
|
||||||
(tmp->flags & CONTEXT_STATIC))
|
(tmp->flags & CONTEXT_STATIC))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
for (tmp = context; tmp; tmp = tmp->current)
|
for (tmp = context; tmp; tmp = tmp->current)
|
||||||
@@ -667,7 +665,8 @@ struct dhcp_config *find_config(struct dhcp_config *configs,
|
|||||||
unsigned char *hwaddr, int hw_len,
|
unsigned char *hwaddr, int hw_len,
|
||||||
int hw_type, char *hostname)
|
int hw_type, char *hostname)
|
||||||
{
|
{
|
||||||
struct dhcp_config *config;
|
int count, new;
|
||||||
|
struct dhcp_config *config, *candidate;
|
||||||
struct hwaddr_config *conf_addr;
|
struct hwaddr_config *conf_addr;
|
||||||
|
|
||||||
if (clid)
|
if (clid)
|
||||||
@@ -699,17 +698,21 @@ struct dhcp_config *find_config(struct dhcp_config *configs,
|
|||||||
hostname_isequal(config->hostname, hostname) &&
|
hostname_isequal(config->hostname, hostname) &&
|
||||||
is_addr_in_context(context, config))
|
is_addr_in_context(context, config))
|
||||||
return config;
|
return config;
|
||||||
|
|
||||||
for (config = configs; config; config = config->next)
|
/* use match with fewest wildcast octets */
|
||||||
for (conf_addr = config->hwaddr; conf_addr; conf_addr = conf_addr->next)
|
for (candidate = NULL, count = 0, config = configs; config; config = config->next)
|
||||||
if (conf_addr->wildcard_mask != 0 &&
|
if (is_addr_in_context(context, config))
|
||||||
conf_addr->hwaddr_len == hw_len &&
|
for (conf_addr = config->hwaddr; conf_addr; conf_addr = conf_addr->next)
|
||||||
(conf_addr->hwaddr_type == hw_type || conf_addr->hwaddr_type == 0) &&
|
if (conf_addr->wildcard_mask != 0 &&
|
||||||
is_addr_in_context(context, config) &&
|
conf_addr->hwaddr_len == hw_len &&
|
||||||
memcmp_masked(conf_addr->hwaddr, hwaddr, hw_len, conf_addr->wildcard_mask))
|
(conf_addr->hwaddr_type == hw_type || conf_addr->hwaddr_type == 0) &&
|
||||||
return config;
|
(new = memcmp_masked(conf_addr->hwaddr, hwaddr, hw_len, conf_addr->wildcard_mask)) > count)
|
||||||
|
{
|
||||||
return NULL;
|
count = new;
|
||||||
|
candidate = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
return candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dhcp_read_ethers(void)
|
void dhcp_read_ethers(void)
|
||||||
@@ -728,7 +731,7 @@ void dhcp_read_ethers(void)
|
|||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_ERR, _("failed to read %s:%s"), ETHERSFILE, strerror(errno));
|
my_syslog(MS_DHCP | LOG_ERR, _("failed to read %s: %s"), ETHERSFILE, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,7 +767,7 @@ void dhcp_read_ethers(void)
|
|||||||
*ip = 0;
|
*ip = 0;
|
||||||
if (!*ip || parse_hex(buff, hwaddr, ETHER_ADDR_LEN, NULL, NULL) != ETHER_ADDR_LEN)
|
if (!*ip || parse_hex(buff, hwaddr, ETHER_ADDR_LEN, NULL, NULL) != ETHER_ADDR_LEN)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_ERR, _("bad line at %s line %d"), ETHERSFILE, lineno);
|
my_syslog(MS_DHCP | LOG_ERR, _("bad line at %s line %d"), ETHERSFILE, lineno);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,7 +780,7 @@ void dhcp_read_ethers(void)
|
|||||||
{
|
{
|
||||||
if ((addr.s_addr = inet_addr(ip)) == (in_addr_t)-1)
|
if ((addr.s_addr = inet_addr(ip)) == (in_addr_t)-1)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_ERR, _("bad address at %s line %d"), ETHERSFILE, lineno);
|
my_syslog(MS_DHCP | LOG_ERR, _("bad address at %s line %d"), ETHERSFILE, lineno);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -791,7 +794,7 @@ void dhcp_read_ethers(void)
|
|||||||
{
|
{
|
||||||
if (!canonicalise(ip))
|
if (!canonicalise(ip))
|
||||||
{
|
{
|
||||||
my_syslog(LOG_ERR, _("bad name at %s line %d"), ETHERSFILE, lineno);
|
my_syslog(MS_DHCP | LOG_ERR, _("bad name at %s line %d"), ETHERSFILE, lineno);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,7 +860,7 @@ void dhcp_read_ethers(void)
|
|||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
my_syslog(LOG_INFO, _("read %s - %d addresses"), ETHERSFILE, count);
|
my_syslog(MS_DHCP | LOG_INFO, _("read %s - %d addresses"), ETHERSFILE, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_dhcp_hosts(int fatal)
|
void check_dhcp_hosts(int fatal)
|
||||||
@@ -882,7 +885,7 @@ void check_dhcp_hosts(int fatal)
|
|||||||
die(_("duplicate IP address %s in dhcp-config directive."),
|
die(_("duplicate IP address %s in dhcp-config directive."),
|
||||||
inet_ntoa(cp->addr), EC_BADCONF);
|
inet_ntoa(cp->addr), EC_BADCONF);
|
||||||
else
|
else
|
||||||
my_syslog(LOG_ERR, _("duplicate IP address %s in %s."),
|
my_syslog(MS_DHCP | LOG_ERR, _("duplicate IP address %s in %s."),
|
||||||
inet_ntoa(cp->addr), daemon->dhcp_hosts_file);
|
inet_ntoa(cp->addr), daemon->dhcp_hosts_file);
|
||||||
configs->flags &= ~CONFIG_ADDR;
|
configs->flags &= ~CONFIG_ADDR;
|
||||||
}
|
}
|
||||||
@@ -925,12 +928,12 @@ void dhcp_update_configs(struct dhcp_config *configs)
|
|||||||
crec = cache_find_by_name(crec, config->hostname, 0, F_IPV4);
|
crec = cache_find_by_name(crec, config->hostname, 0, F_IPV4);
|
||||||
if (!crec)
|
if (!crec)
|
||||||
continue; /* should be never */
|
continue; /* should be never */
|
||||||
my_syslog(LOG_WARNING, _("%s has more than one address in hostsfile, using %s for DHCP"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("%s has more than one address in hostsfile, using %s for DHCP"),
|
||||||
config->hostname, inet_ntoa(crec->addr.addr.addr.addr4));
|
config->hostname, inet_ntoa(crec->addr.addr.addr.addr4));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_find_by_address(configs, crec->addr.addr.addr.addr4))
|
if (config_find_by_address(configs, crec->addr.addr.addr.addr4))
|
||||||
my_syslog(LOG_WARNING, _("duplicate IP address %s (%s) in dhcp-config directive"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("duplicate IP address %s (%s) in dhcp-config directive"),
|
||||||
inet_ntoa(crec->addr.addr.addr.addr4), config->hostname);
|
inet_ntoa(crec->addr.addr.addr.addr4), config->hostname);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -982,14 +985,5 @@ char *strip_hostname(char *hostname)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *get_domain(struct in_addr addr)
|
#endif
|
||||||
{
|
|
||||||
struct cond_domain *c;
|
|
||||||
|
|
||||||
for (c = daemon->cond_domain; c; c = c->next)
|
|
||||||
if (ntohl(addr.s_addr) >= ntohl(c->start.s_addr) &&
|
|
||||||
ntohl(addr.s_addr) <= ntohl(c->end.s_addr))
|
|
||||||
return c->domain;
|
|
||||||
|
|
||||||
return daemon->domain_suffix;
|
|
||||||
}
|
|
||||||
+54
-34
@@ -33,9 +33,6 @@ static char *compile_opts =
|
|||||||
#ifdef NO_FORK
|
#ifdef NO_FORK
|
||||||
"no-MMU "
|
"no-MMU "
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_BSD_BRIDGE
|
|
||||||
"BSD-bridge "
|
|
||||||
#endif
|
|
||||||
#ifndef HAVE_DBUS
|
#ifndef HAVE_DBUS
|
||||||
"no-"
|
"no-"
|
||||||
#endif
|
#endif
|
||||||
@@ -44,6 +41,10 @@ static char *compile_opts =
|
|||||||
"no-"
|
"no-"
|
||||||
#endif
|
#endif
|
||||||
"I18N "
|
"I18N "
|
||||||
|
#ifndef HAVE_DHCP
|
||||||
|
"no-"
|
||||||
|
#endif
|
||||||
|
"DHCP "
|
||||||
#ifndef HAVE_TFTP
|
#ifndef HAVE_TFTP
|
||||||
"no-"
|
"no-"
|
||||||
#endif
|
#endif
|
||||||
@@ -67,9 +68,11 @@ 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
|
||||||
uid_t script_uid = 0;
|
uid_t script_uid = 0;
|
||||||
gid_t script_gid = 0;
|
gid_t script_gid = 0;
|
||||||
struct group *gp= NULL;
|
#endif
|
||||||
|
struct group *gp = NULL;
|
||||||
long i, max_fd = sysconf(_SC_OPEN_MAX);
|
long i, max_fd = sysconf(_SC_OPEN_MAX);
|
||||||
char *baduser = NULL;
|
char *baduser = NULL;
|
||||||
int log_err;
|
int log_err;
|
||||||
@@ -108,11 +111,13 @@ int main (int argc, char **argv)
|
|||||||
daemon->edns_pktsz : DNSMASQ_PACKETSZ;
|
daemon->edns_pktsz : DNSMASQ_PACKETSZ;
|
||||||
daemon->packet = safe_malloc(daemon->packet_buff_sz);
|
daemon->packet = safe_malloc(daemon->packet_buff_sz);
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
if (!daemon->lease_file)
|
if (!daemon->lease_file)
|
||||||
{
|
{
|
||||||
if (daemon->dhcp)
|
if (daemon->dhcp)
|
||||||
daemon->lease_file = LEASEFILE;
|
daemon->lease_file = LEASEFILE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Close any file descriptors we inherited apart from std{in|out|err} */
|
/* Close any file descriptors we inherited apart from std{in|out|err} */
|
||||||
for (i = 0; i < max_fd; i++)
|
for (i = 0; i < max_fd; i++)
|
||||||
@@ -145,23 +150,16 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
now = dnsmasq_time();
|
now = dnsmasq_time();
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp)
|
if (daemon->dhcp)
|
||||||
{
|
{
|
||||||
#if !defined(HAVE_LINUX_NETWORK) && !defined(IP_RECVIF)
|
|
||||||
int c;
|
|
||||||
struct iname *tmp;
|
|
||||||
for (c = 0, tmp = daemon->if_names; tmp; tmp = tmp->next)
|
|
||||||
if (!tmp->isloop)
|
|
||||||
c++;
|
|
||||||
if (c != 1)
|
|
||||||
die(_("must set exactly one interface on broken systems without IP_RECVIF"), NULL, EC_BADCONF);
|
|
||||||
#endif
|
|
||||||
/* Note that order matters here, we must call lease_init before
|
/* Note that order matters here, we must call lease_init before
|
||||||
creating any file descriptors which shouldn't be leaked
|
creating any file descriptors which shouldn't be leaked
|
||||||
to the lease-script init process. */
|
to the lease-script init process. */
|
||||||
lease_init(now);
|
lease_init(now);
|
||||||
dhcp_init();
|
dhcp_init();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!enumerate_interfaces())
|
if (!enumerate_interfaces())
|
||||||
die(_("failed to find list of interfaces: %s"), NULL, EC_MISC);
|
die(_("failed to find list of interfaces: %s"), NULL, EC_MISC);
|
||||||
@@ -204,6 +202,7 @@ int main (int argc, char **argv)
|
|||||||
if (daemon->port != 0)
|
if (daemon->port != 0)
|
||||||
pre_allocate_sfds();
|
pre_allocate_sfds();
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
/* 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)
|
||||||
{
|
{
|
||||||
@@ -215,6 +214,7 @@ int main (int argc, char **argv)
|
|||||||
else
|
else
|
||||||
baduser = daemon->scriptuser;
|
baduser = daemon->scriptuser;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (daemon->username && !(ent_pw = getpwnam(daemon->username)))
|
if (daemon->username && !(ent_pw = getpwnam(daemon->username)))
|
||||||
baduser = daemon->username;
|
baduser = daemon->username;
|
||||||
@@ -290,8 +290,9 @@ int main (int argc, char **argv)
|
|||||||
When startup is complete we close this and the process terminates. */
|
When startup is complete we close this and the process terminates. */
|
||||||
safe_pipe(err_pipe, 0);
|
safe_pipe(err_pipe, 0);
|
||||||
|
|
||||||
if ((pid = fork()) == -1 )
|
if ((pid = fork()) == -1)
|
||||||
die(_("cannot fork into background: %s"), NULL, EC_MISC);
|
/* fd == -1 since we've not forked, never returns. */
|
||||||
|
send_event(-1, EVENT_FORK_ERR, errno);
|
||||||
|
|
||||||
if (pid != 0)
|
if (pid != 0)
|
||||||
{
|
{
|
||||||
@@ -312,9 +313,11 @@ int main (int argc, char **argv)
|
|||||||
/* NO calls to die() from here on. */
|
/* NO calls to die() from here on. */
|
||||||
|
|
||||||
setsid();
|
setsid();
|
||||||
pid = fork();
|
|
||||||
|
if ((pid = fork()) == -1)
|
||||||
if (pid != 0 && pid != -1)
|
send_event(err_pipe[1], EVENT_FORK_ERR, errno);
|
||||||
|
|
||||||
|
if (pid != 0)
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -349,7 +352,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;
|
||||||
#ifndef NO_FORK
|
#if defined(HAVE_DHCP) && !defined(NO_FORK)
|
||||||
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
|
||||||
@@ -380,7 +383,7 @@ int main (int argc, char **argv)
|
|||||||
if (capset(hdr, data) == -1 || prctl(PR_SET_KEEPCAPS, 1) == -1)
|
if (capset(hdr, data) == -1 || prctl(PR_SET_KEEPCAPS, 1) == -1)
|
||||||
bad_capabilities = errno;
|
bad_capabilities = errno;
|
||||||
|
|
||||||
#elif defined(HAVE_SOLARIS_PRIVS)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
/* http://developers.sun.com/solaris/articles/program_privileges.html */
|
/* http://developers.sun.com/solaris/articles/program_privileges.html */
|
||||||
priv_set_t *priv_set;
|
priv_set_t *priv_set;
|
||||||
|
|
||||||
@@ -400,9 +403,6 @@ int main (int argc, char **argv)
|
|||||||
if (priv_set)
|
if (priv_set)
|
||||||
priv_freeset(priv_set);
|
priv_freeset(priv_set);
|
||||||
|
|
||||||
#elif defined(HAVE_SOLARIS_NETWORK)
|
|
||||||
|
|
||||||
bad_capabilities = ENOTSUP;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (bad_capabilities != 0)
|
if (bad_capabilities != 0)
|
||||||
@@ -482,6 +482,7 @@ int main (int argc, char **argv)
|
|||||||
if (daemon->max_logs != 0)
|
if (daemon->max_logs != 0)
|
||||||
my_syslog(LOG_INFO, _("asynchronous logging enabled, queue limit is %d messages"), daemon->max_logs);
|
my_syslog(LOG_INFO, _("asynchronous logging enabled, queue limit is %d messages"), daemon->max_logs);
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp)
|
if (daemon->dhcp)
|
||||||
{
|
{
|
||||||
struct dhcp_context *dhcp_tmp;
|
struct dhcp_context *dhcp_tmp;
|
||||||
@@ -490,13 +491,16 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
prettyprint_time(daemon->dhcp_buff2, dhcp_tmp->lease_time);
|
prettyprint_time(daemon->dhcp_buff2, dhcp_tmp->lease_time);
|
||||||
strcpy(daemon->dhcp_buff, inet_ntoa(dhcp_tmp->start));
|
strcpy(daemon->dhcp_buff, inet_ntoa(dhcp_tmp->start));
|
||||||
my_syslog(LOG_INFO,
|
my_syslog(MS_DHCP | LOG_INFO,
|
||||||
(dhcp_tmp->flags & CONTEXT_STATIC) ?
|
(dhcp_tmp->flags & CONTEXT_STATIC) ?
|
||||||
_("DHCP, static leases only on %.0s%s, lease time %s") :
|
_("DHCP, static leases only on %.0s%s, lease time %s") :
|
||||||
|
(dhcp_tmp->flags & CONTEXT_PROXY) ?
|
||||||
|
_("DHCP, proxy on subnet %.0s%s%.0s") :
|
||||||
_("DHCP, IP range %s -- %s, lease time %s"),
|
_("DHCP, IP range %s -- %s, lease time %s"),
|
||||||
daemon->dhcp_buff, inet_ntoa(dhcp_tmp->end), daemon->dhcp_buff2);
|
daemon->dhcp_buff, inet_ntoa(dhcp_tmp->end), daemon->dhcp_buff2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_TFTP
|
#ifdef HAVE_TFTP
|
||||||
if (daemon->options & OPT_TFTP)
|
if (daemon->options & OPT_TFTP)
|
||||||
@@ -506,7 +510,7 @@ int main (int argc, char **argv)
|
|||||||
max_fd = FD_SETSIZE;
|
max_fd = FD_SETSIZE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
my_syslog(LOG_INFO, "TFTP %s%s %s",
|
my_syslog(MS_TFTP | LOG_INFO, "TFTP %s%s %s",
|
||||||
daemon->tftp_prefix ? _("root is ") : _("enabled"),
|
daemon->tftp_prefix ? _("root is ") : _("enabled"),
|
||||||
daemon->tftp_prefix ? daemon->tftp_prefix: "",
|
daemon->tftp_prefix ? daemon->tftp_prefix: "",
|
||||||
daemon->options & OPT_TFTP_SECURE ? _("secure mode") : "");
|
daemon->options & OPT_TFTP_SECURE ? _("secure mode") : "");
|
||||||
@@ -534,7 +538,7 @@ int main (int argc, char **argv)
|
|||||||
if (daemon->tftp_max > max_fd)
|
if (daemon->tftp_max > max_fd)
|
||||||
{
|
{
|
||||||
daemon->tftp_max = max_fd;
|
daemon->tftp_max = max_fd;
|
||||||
my_syslog(LOG_WARNING,
|
my_syslog(MS_TFTP | LOG_WARNING,
|
||||||
_("restricting maximum simultaneous TFTP transfers to %d"),
|
_("restricting maximum simultaneous TFTP transfers to %d"),
|
||||||
daemon->tftp_max);
|
daemon->tftp_max);
|
||||||
}
|
}
|
||||||
@@ -582,11 +586,13 @@ int main (int argc, char **argv)
|
|||||||
set_dbus_listeners(&maxfd, &rset, &wset, &eset);
|
set_dbus_listeners(&maxfd, &rset, &wset, &eset);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp)
|
if (daemon->dhcp)
|
||||||
{
|
{
|
||||||
FD_SET(daemon->dhcpfd, &rset);
|
FD_SET(daemon->dhcpfd, &rset);
|
||||||
bump_maxfd(daemon->dhcpfd, &maxfd);
|
bump_maxfd(daemon->dhcpfd, &maxfd);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
FD_SET(daemon->netlinkfd, &rset);
|
FD_SET(daemon->netlinkfd, &rset);
|
||||||
@@ -596,7 +602,8 @@ int main (int argc, char **argv)
|
|||||||
FD_SET(piperead, &rset);
|
FD_SET(piperead, &rset);
|
||||||
bump_maxfd(piperead, &maxfd);
|
bump_maxfd(piperead, &maxfd);
|
||||||
|
|
||||||
#ifndef NO_FORK
|
#ifdef HAVE_DHCP
|
||||||
|
# ifndef NO_FORK
|
||||||
while (helper_buf_empty() && do_script_run(now));
|
while (helper_buf_empty() && do_script_run(now));
|
||||||
|
|
||||||
if (!helper_buf_empty())
|
if (!helper_buf_empty())
|
||||||
@@ -604,11 +611,12 @@ int main (int argc, char **argv)
|
|||||||
FD_SET(daemon->helperfd, &wset);
|
FD_SET(daemon->helperfd, &wset);
|
||||||
bump_maxfd(daemon->helperfd, &maxfd);
|
bump_maxfd(daemon->helperfd, &maxfd);
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
/* need this for other side-effects */
|
/* need this for other side-effects */
|
||||||
while (do_script_run(now));
|
while (do_script_run(now));
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* must do this just before select(), when we know no
|
/* must do this just before select(), when we know no
|
||||||
more calls to my_syslog() can occur */
|
more calls to my_syslog() can occur */
|
||||||
set_log_writer(&wset, &maxfd);
|
set_log_writer(&wset, &maxfd);
|
||||||
@@ -662,12 +670,14 @@ int main (int argc, char **argv)
|
|||||||
check_tftp_listeners(&rset, now);
|
check_tftp_listeners(&rset, now);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp && FD_ISSET(daemon->dhcpfd, &rset))
|
if (daemon->dhcp && FD_ISSET(daemon->dhcpfd, &rset))
|
||||||
dhcp_packet(now);
|
dhcp_packet(now);
|
||||||
|
|
||||||
#ifndef NO_FORK
|
# ifndef NO_FORK
|
||||||
if (daemon->helperfd != -1 && FD_ISSET(daemon->helperfd, &wset))
|
if (daemon->helperfd != -1 && FD_ISSET(daemon->helperfd, &wset))
|
||||||
helper_write();
|
helper_write();
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -737,6 +747,9 @@ static void fatal_event(struct event_desc *ev)
|
|||||||
{
|
{
|
||||||
case EVENT_DIE:
|
case EVENT_DIE:
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
|
case EVENT_FORK_ERR:
|
||||||
|
die(_("cannot fork into background: %s"), NULL, EC_MISC);
|
||||||
|
|
||||||
case EVENT_PIPE_ERR:
|
case EVENT_PIPE_ERR:
|
||||||
die(_("failed to create helper: %s"), NULL, EC_MISC);
|
die(_("failed to create helper: %s"), NULL, EC_MISC);
|
||||||
@@ -777,7 +790,9 @@ static void async_event(int pipe, time_t now)
|
|||||||
reload_servers(daemon->resolv_files->name);
|
reload_servers(daemon->resolv_files->name);
|
||||||
check_servers();
|
check_servers();
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
rerun_scripts();
|
rerun_scripts();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_DUMP:
|
case EVENT_DUMP:
|
||||||
@@ -786,11 +801,13 @@ static void async_event(int pipe, time_t now)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_ALARM:
|
case EVENT_ALARM:
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp)
|
if (daemon->dhcp)
|
||||||
{
|
{
|
||||||
lease_prune(NULL, now);
|
lease_prune(NULL, now);
|
||||||
lease_update_file(now);
|
lease_update_file(now);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_CHILD:
|
case EVENT_CHILD:
|
||||||
@@ -840,7 +857,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);
|
||||||
|
|
||||||
#ifndef NO_FORK
|
#if defined(HAVE_DHCP) && !defined(NO_FORK)
|
||||||
/* handle pending lease transitions */
|
/* handle pending lease transitions */
|
||||||
if (daemon->helperfd != -1)
|
if (daemon->helperfd != -1)
|
||||||
{
|
{
|
||||||
@@ -904,7 +921,7 @@ static void poll_resolv()
|
|||||||
warned = 0;
|
warned = 0;
|
||||||
check_servers();
|
check_servers();
|
||||||
if (daemon->options & OPT_RELOAD)
|
if (daemon->options & OPT_RELOAD)
|
||||||
cache_reload(daemon->addn_hosts);
|
cache_reload();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -921,8 +938,9 @@ static void poll_resolv()
|
|||||||
void clear_cache_and_reload(time_t now)
|
void clear_cache_and_reload(time_t now)
|
||||||
{
|
{
|
||||||
if (daemon->port != 0)
|
if (daemon->port != 0)
|
||||||
cache_reload(daemon->addn_hosts);
|
cache_reload();
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp)
|
if (daemon->dhcp)
|
||||||
{
|
{
|
||||||
if (daemon->options & OPT_ETHERS)
|
if (daemon->options & OPT_ETHERS)
|
||||||
@@ -934,6 +952,7 @@ void clear_cache_and_reload(time_t now)
|
|||||||
lease_update_file(now);
|
lease_update_file(now);
|
||||||
lease_update_dns();
|
lease_update_dns();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_dns_listeners(time_t now, fd_set *set, int *maxfdp)
|
static int set_dns_listeners(time_t now, fd_set *set, int *maxfdp)
|
||||||
@@ -1135,7 +1154,7 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
int make_icmp_sock(void)
|
int make_icmp_sock(void)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
@@ -1258,5 +1277,6 @@ int icmp_ping(struct in_addr addr)
|
|||||||
|
|
||||||
return gotreply;
|
return gotreply;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
+40
-28
@@ -106,7 +106,7 @@ extern int capget(cap_user_header_t header, cap_user_data_t data);
|
|||||||
#define LINUX_CAPABILITY_VERSION_3 0x20080522
|
#define LINUX_CAPABILITY_VERSION_3 0x20080522
|
||||||
|
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#elif defined(HAVE_SOLARIS_PRIVS)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
#include <priv.h>
|
#include <priv.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -135,6 +135,7 @@ struct event_desc {
|
|||||||
#define EVENT_GROUP_ERR 15
|
#define EVENT_GROUP_ERR 15
|
||||||
#define EVENT_DIE 16
|
#define EVENT_DIE 16
|
||||||
#define EVENT_LOG_ERR 17
|
#define EVENT_LOG_ERR 17
|
||||||
|
#define EVENT_FORK_ERR 18
|
||||||
|
|
||||||
/* Exit codes. */
|
/* Exit codes. */
|
||||||
#define EC_GOOD 0
|
#define EC_GOOD 0
|
||||||
@@ -185,6 +186,11 @@ struct event_desc {
|
|||||||
#define OPT_NO_OVERRIDE (1u<<30)
|
#define OPT_NO_OVERRIDE (1u<<30)
|
||||||
#define OPT_NO_REBIND (1u<<31)
|
#define OPT_NO_REBIND (1u<<31)
|
||||||
|
|
||||||
|
/* extra flags for my_syslog, we use a couple of facilities since they are known
|
||||||
|
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
|
||||||
|
#define MS_TFTP LOG_USER
|
||||||
|
#define MS_DHCP LOG_DAEMON
|
||||||
|
|
||||||
struct all_addr {
|
struct all_addr {
|
||||||
union {
|
union {
|
||||||
struct in_addr addr4;
|
struct in_addr addr4;
|
||||||
@@ -287,19 +293,7 @@ struct crec {
|
|||||||
union mysockaddr {
|
union mysockaddr {
|
||||||
struct sockaddr sa;
|
struct sockaddr sa;
|
||||||
struct sockaddr_in in;
|
struct sockaddr_in in;
|
||||||
#ifdef HAVE_BROKEN_SOCKADDR_IN6
|
#if defined(HAVE_IPV6)
|
||||||
/* early versions of glibc don't include sin6_scope_id in sockaddr_in6
|
|
||||||
but latest kernels _require_ it to be set. The choice is to have
|
|
||||||
dnsmasq fail to compile on back-level libc or fail to run
|
|
||||||
on latest kernels with IPv6. Or to do this: sorry that it's so gross. */
|
|
||||||
struct my_sockaddr_in6 {
|
|
||||||
sa_family_t sin6_family; /* AF_INET6 */
|
|
||||||
uint16_t sin6_port; /* transport layer port # */
|
|
||||||
uint32_t sin6_flowinfo; /* IPv6 traffic class & flow info */
|
|
||||||
struct in6_addr sin6_addr; /* IPv6 address */
|
|
||||||
uint32_t sin6_scope_id; /* set of interfaces for a scope */
|
|
||||||
} in6;
|
|
||||||
#elif defined(HAVE_IPV6)
|
|
||||||
struct sockaddr_in6 in6;
|
struct sockaddr_in6 in6;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -368,8 +362,11 @@ struct resolvc {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* adn-hosts parms from command-line */
|
/* adn-hosts parms from command-line */
|
||||||
|
#define AH_DIR 1
|
||||||
|
#define AH_INACTIVE 2
|
||||||
struct hostsfile {
|
struct hostsfile {
|
||||||
struct hostsfile *next;
|
struct hostsfile *next;
|
||||||
|
int flags;
|
||||||
char *fname;
|
char *fname;
|
||||||
int index; /* matches to cache entries for logging */
|
int index; /* matches to cache entries for logging */
|
||||||
};
|
};
|
||||||
@@ -484,6 +481,7 @@ struct dhcp_opt {
|
|||||||
#define DHOPT_MATCH 128
|
#define DHOPT_MATCH 128
|
||||||
#define DHOPT_VENDOR 256
|
#define DHOPT_VENDOR 256
|
||||||
#define DHOPT_HEX 512
|
#define DHOPT_HEX 512
|
||||||
|
#define DHOPT_VENDOR_MATCH 1024
|
||||||
|
|
||||||
struct dhcp_boot {
|
struct dhcp_boot {
|
||||||
char *file, *sname;
|
char *file, *sname;
|
||||||
@@ -492,6 +490,14 @@ struct dhcp_boot {
|
|||||||
struct dhcp_boot *next;
|
struct dhcp_boot *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct pxe_service {
|
||||||
|
unsigned short CSA, type;
|
||||||
|
char *menu, *basename;
|
||||||
|
struct in_addr server;
|
||||||
|
struct dhcp_netid *netid;
|
||||||
|
struct pxe_service *next;
|
||||||
|
};
|
||||||
|
|
||||||
#define MATCH_VENDOR 1
|
#define MATCH_VENDOR 1
|
||||||
#define MATCH_USER 2
|
#define MATCH_USER 2
|
||||||
#define MATCH_CIRCUIT 3
|
#define MATCH_CIRCUIT 3
|
||||||
@@ -514,12 +520,10 @@ struct dhcp_mac {
|
|||||||
struct dhcp_mac *next;
|
struct dhcp_mac *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_BSD_BRIDGE
|
|
||||||
struct dhcp_bridge {
|
struct dhcp_bridge {
|
||||||
char iface[IF_NAMESIZE];
|
char iface[IF_NAMESIZE];
|
||||||
struct dhcp_bridge *alias, *next;
|
struct dhcp_bridge *alias, *next;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
struct cond_domain {
|
struct cond_domain {
|
||||||
char *domain;
|
char *domain;
|
||||||
@@ -540,6 +544,7 @@ struct dhcp_context {
|
|||||||
#define CONTEXT_STATIC 1
|
#define CONTEXT_STATIC 1
|
||||||
#define CONTEXT_NETMASK 2
|
#define CONTEXT_NETMASK 2
|
||||||
#define CONTEXT_BRDCAST 4
|
#define CONTEXT_BRDCAST 4
|
||||||
|
#define CONTEXT_PROXY 8
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned char u8;
|
typedef unsigned char u8;
|
||||||
@@ -620,6 +625,7 @@ extern struct daemon {
|
|||||||
struct dhcp_vendor *dhcp_vendors;
|
struct dhcp_vendor *dhcp_vendors;
|
||||||
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 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;
|
||||||
@@ -643,23 +649,21 @@ extern struct daemon {
|
|||||||
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];
|
||||||
|
|
||||||
/* DHCP state */
|
/* DHCP state */
|
||||||
int dhcpfd, helperfd;
|
int dhcpfd, helperfd;
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
int netlinkfd;
|
int netlinkfd;
|
||||||
#else
|
#elif defined(HAVE_BSD_NETWORK)
|
||||||
int dhcp_raw_fd, dhcp_icmp_fd;
|
int dhcp_raw_fd, dhcp_icmp_fd;
|
||||||
#endif
|
#endif
|
||||||
struct iovec dhcp_packet;
|
struct iovec dhcp_packet;
|
||||||
char *dhcp_buff, *dhcp_buff2;
|
char *dhcp_buff, *dhcp_buff2;
|
||||||
struct ping_result *ping_results;
|
struct ping_result *ping_results;
|
||||||
FILE *lease_stream;
|
FILE *lease_stream;
|
||||||
#ifdef HAVE_BSD_BRIDGE
|
|
||||||
struct dhcp_bridge *bridges;
|
struct dhcp_bridge *bridges;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* DBus stuff */
|
/* DBus stuff */
|
||||||
/* void * here to avoid depending on dbus headers outside dbus.c */
|
/* void * here to avoid depending on dbus headers outside dbus.c */
|
||||||
@@ -676,7 +680,7 @@ pid_t tcp_pids[MAX_PROCS];
|
|||||||
/* cache.c */
|
/* cache.c */
|
||||||
void cache_init(void);
|
void cache_init(void);
|
||||||
void log_query(unsigned short flags, char *name, struct all_addr *addr, char *arg);
|
void log_query(unsigned short flags, char *name, struct all_addr *addr, char *arg);
|
||||||
char *record_source(struct hostsfile *addn_hosts, int index);
|
char *record_source(int index);
|
||||||
void querystr(char *str, unsigned short type);
|
void querystr(char *str, unsigned short type);
|
||||||
struct crec *cache_find_by_addr(struct crec *crecp,
|
struct crec *cache_find_by_addr(struct crec *crecp,
|
||||||
struct all_addr *addr, time_t now,
|
struct all_addr *addr, time_t now,
|
||||||
@@ -687,11 +691,12 @@ void cache_end_insert(void);
|
|||||||
void cache_start_insert(void);
|
void cache_start_insert(void);
|
||||||
struct crec *cache_insert(char *name, struct all_addr *addr,
|
struct crec *cache_insert(char *name, struct all_addr *addr,
|
||||||
time_t now, unsigned long ttl, unsigned short flags);
|
time_t now, unsigned long ttl, unsigned short flags);
|
||||||
void cache_reload(struct hostsfile *addn_hosts);
|
void cache_reload(void);
|
||||||
void cache_add_dhcp_entry(char *host_name, struct in_addr *host_address, time_t ttd);
|
void cache_add_dhcp_entry(char *host_name, struct in_addr *host_address, time_t ttd);
|
||||||
void cache_unhash_dhcp(void);
|
void cache_unhash_dhcp(void);
|
||||||
void dump_cache(time_t now);
|
void dump_cache(time_t now);
|
||||||
char *cache_get_name(struct crec *crecp);
|
char *cache_get_name(struct crec *crecp);
|
||||||
|
char *get_domain(struct in_addr addr);
|
||||||
|
|
||||||
/* rfc1035.c */
|
/* rfc1035.c */
|
||||||
unsigned short extract_request(HEADER *header, size_t qlen,
|
unsigned short extract_request(HEADER *header, size_t qlen,
|
||||||
@@ -748,7 +753,7 @@ void flush_log(void);
|
|||||||
|
|
||||||
/* option.c */
|
/* option.c */
|
||||||
void read_opts (int argc, char **argv, char *compile_opts);
|
void read_opts (int argc, char **argv, char *compile_opts);
|
||||||
char *option_string(unsigned char opt);
|
char *option_string(unsigned char opt, int *is_ip, int *is_name);
|
||||||
void reread_dhcp(void);
|
void reread_dhcp(void);
|
||||||
|
|
||||||
/* forward.c */
|
/* forward.c */
|
||||||
@@ -760,6 +765,7 @@ void server_gone(struct server *server);
|
|||||||
struct frec *get_new_frec(time_t now, int *wait);
|
struct frec *get_new_frec(time_t now, int *wait);
|
||||||
|
|
||||||
/* network.c */
|
/* network.c */
|
||||||
|
int indextoname(int fd, int index, char *name);
|
||||||
int local_bind(int fd, union mysockaddr *addr, char *intname, int is_tcp);
|
int local_bind(int fd, union mysockaddr *addr, char *intname, int is_tcp);
|
||||||
int random_sock(int family);
|
int random_sock(int family);
|
||||||
void pre_allocate_sfds(void);
|
void pre_allocate_sfds(void);
|
||||||
@@ -768,15 +774,14 @@ void check_servers(void);
|
|||||||
int enumerate_interfaces();
|
int enumerate_interfaces();
|
||||||
struct listener *create_wildcard_listeners(void);
|
struct listener *create_wildcard_listeners(void);
|
||||||
struct listener *create_bound_listeners(void);
|
struct listener *create_bound_listeners(void);
|
||||||
int iface_check(int family, struct all_addr *addr,
|
int iface_check(int family, struct all_addr *addr, char *name, int *indexp);
|
||||||
struct ifreq *ifr, int *indexp);
|
|
||||||
int fix_fd(int fd);
|
int fix_fd(int fd);
|
||||||
struct in_addr get_ifaddr(char *intr);
|
struct in_addr get_ifaddr(char *intr);
|
||||||
|
|
||||||
/* dhcp.c */
|
/* dhcp.c */
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
void dhcp_init(void);
|
void dhcp_init(void);
|
||||||
void dhcp_packet(time_t now);
|
void dhcp_packet(time_t now);
|
||||||
char *get_domain(struct in_addr addr);
|
|
||||||
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);
|
||||||
@@ -799,8 +804,10 @@ struct dhcp_config *config_find_by_address(struct dhcp_config *configs, struct i
|
|||||||
char *strip_hostname(char *hostname);
|
char *strip_hostname(char *hostname);
|
||||||
char *host_from_dns(struct in_addr addr);
|
char *host_from_dns(struct in_addr addr);
|
||||||
char *get_domain(struct in_addr addr);
|
char *get_domain(struct in_addr addr);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* lease.c */
|
/* lease.c */
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
void lease_update_file(time_t now);
|
void lease_update_file(time_t now);
|
||||||
void lease_update_dns();
|
void lease_update_dns();
|
||||||
void lease_init(time_t now);
|
void lease_init(time_t now);
|
||||||
@@ -817,16 +824,21 @@ void lease_prune(struct dhcp_lease *target, time_t now);
|
|||||||
void lease_update_from_configs(void);
|
void lease_update_from_configs(void);
|
||||||
int do_script_run(time_t now);
|
int do_script_run(time_t now);
|
||||||
void rerun_scripts(void);
|
void rerun_scripts(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* rfc2131.c */
|
/* rfc2131.c */
|
||||||
|
#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);
|
||||||
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
|
||||||
|
|
||||||
/* dnsmasq.c */
|
/* dnsmasq.c */
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
int make_icmp_sock(void);
|
int make_icmp_sock(void);
|
||||||
int icmp_ping(struct in_addr addr);
|
int icmp_ping(struct in_addr addr);
|
||||||
|
#endif
|
||||||
void send_event(int fd, int event, int data);
|
void send_event(int fd, int event, int data);
|
||||||
void clear_cache_and_reload(time_t now);
|
void clear_cache_and_reload(time_t now);
|
||||||
|
|
||||||
@@ -855,7 +867,7 @@ void emit_dbus_signal(int action, char *mac, char *hostname, char *addr);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* helper.c */
|
/* helper.c */
|
||||||
#ifndef NO_FORK
|
#if defined(HAVE_DHCP) && !defined(NO_FORK)
|
||||||
int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd);
|
int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd);
|
||||||
void helper_write(void);
|
void helper_write(void);
|
||||||
void queue_script(int action, struct dhcp_lease *lease,
|
void queue_script(int action, struct dhcp_lease *lease,
|
||||||
|
|||||||
+2
-13
@@ -667,19 +667,8 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
|
|
||||||
/* enforce available interface configuration */
|
/* enforce available interface configuration */
|
||||||
|
|
||||||
if (if_index == 0)
|
if (!indextoname(listen->fd, if_index, ifr.ifr_name) ||
|
||||||
return;
|
!iface_check(listen->family, &dst_addr, ifr.ifr_name, &if_index))
|
||||||
|
|
||||||
#ifdef SIOCGIFNAME
|
|
||||||
ifr.ifr_ifindex = if_index;
|
|
||||||
if (ioctl(listen->fd, SIOCGIFNAME, &ifr) == -1)
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
if (!if_indextoname(if_index, ifr.ifr_name))
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!iface_check(listen->family, &dst_addr, &ifr, &if_index))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (listen->family == AF_INET &&
|
if (listen->family == AF_INET &&
|
||||||
|
|||||||
+3
-23
@@ -28,7 +28,7 @@
|
|||||||
main process.
|
main process.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NO_FORK
|
#if defined(HAVE_DHCP) && !defined(NO_FORK)
|
||||||
|
|
||||||
static void my_setenv(const char *name, const char *value, int *error);
|
static void my_setenv(const char *name, const char *value, int *error);
|
||||||
|
|
||||||
@@ -276,28 +276,8 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
|
|
||||||
static void my_setenv(const char *name, const char *value, int *error)
|
static void my_setenv(const char *name, const char *value, int *error)
|
||||||
{
|
{
|
||||||
if (*error == 0)
|
if (*error == 0 && setenv(name, value, 1) != 0)
|
||||||
{
|
*error = errno;
|
||||||
#if defined(HAVE_SOLARIS_NETWORK) && !defined(HAVE_SOLARIS_PRIVS)
|
|
||||||
/* old Solaris is missing setenv..... */
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (!(p = malloc(strlen(name) + strlen(value) + 2)))
|
|
||||||
*error = ENOMEM;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(p, name);
|
|
||||||
strcat(p, "=");
|
|
||||||
strcat(p, value);
|
|
||||||
|
|
||||||
if (putenv(p) != 0)
|
|
||||||
*error = errno;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (setenv(name, value, 1) != 0)
|
|
||||||
*error = errno;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pack up lease data into a buffer */
|
/* pack up lease data into a buffer */
|
||||||
|
|||||||
+6
-2
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
|
|
||||||
static struct dhcp_lease *leases = NULL, *old_leases = NULL;
|
static struct dhcp_lease *leases = NULL, *old_leases = NULL;
|
||||||
static int dns_dirty, file_dirty, leases_left;
|
static int dns_dirty, file_dirty, leases_left;
|
||||||
|
|
||||||
@@ -57,7 +59,7 @@ void lease_init(time_t now)
|
|||||||
if (!leasestream)
|
if (!leasestream)
|
||||||
die(_("cannot open or create lease file %s: %s"), daemon->lease_file, EC_FILE);
|
die(_("cannot open or create lease file %s: %s"), daemon->lease_file, EC_FILE);
|
||||||
|
|
||||||
/* a+ mode lease pointer at end. */
|
/* a+ mode leaves pointer at end. */
|
||||||
rewind(leasestream);
|
rewind(leasestream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +237,7 @@ void lease_update_file(time_t now)
|
|||||||
if (next_event == 0 || difftime(next_event, LEASE_RETRY + now) > 0.0)
|
if (next_event == 0 || difftime(next_event, LEASE_RETRY + now) > 0.0)
|
||||||
next_event = LEASE_RETRY + now;
|
next_event = LEASE_RETRY + now;
|
||||||
|
|
||||||
my_syslog(LOG_ERR, _("failed to write %s: %s (retry in %us)"),
|
my_syslog(MS_DHCP | LOG_ERR, _("failed to write %s: %s (retry in %us)"),
|
||||||
daemon->lease_file, strerror(err),
|
daemon->lease_file, strerror(err),
|
||||||
(unsigned int)difftime(next_event, now));
|
(unsigned int)difftime(next_event, now));
|
||||||
}
|
}
|
||||||
@@ -607,6 +609,8 @@ int do_script_run(time_t now)
|
|||||||
|
|
||||||
return 0; /* nothing to do */
|
return 0; /* nothing to do */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -248,6 +248,10 @@ static void log_write(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* priority is one of LOG_DEBUG, LOG_INFO, LOG_NOTICE, etc. See sys/syslog.h.
|
||||||
|
OR'd to priority can be MS_TFTP, MS_DHCP, ... to be able to do log separation between
|
||||||
|
DNS, DHCP and TFTP services.
|
||||||
|
*/
|
||||||
void my_syslog(int priority, const char *format, ...)
|
void my_syslog(int priority, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@@ -256,10 +260,18 @@ void my_syslog(int priority, const char *format, ...)
|
|||||||
char *p;
|
char *p;
|
||||||
size_t len;
|
size_t len;
|
||||||
pid_t pid = getpid();
|
pid_t pid = getpid();
|
||||||
|
char *func = "";
|
||||||
|
|
||||||
|
if ((LOG_FACMASK & priority) == MS_TFTP)
|
||||||
|
func = "-tftp";
|
||||||
|
else if ((LOG_FACMASK & priority) == MS_DHCP)
|
||||||
|
func = "-dhcp";
|
||||||
|
|
||||||
|
priority = LOG_PRI(priority);
|
||||||
|
|
||||||
if (log_stderr)
|
if (log_stderr)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "dnsmasq: ");
|
fprintf(stderr, "dnsmasq%s: ", func);
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vfprintf(stderr, format, ap);
|
vfprintf(stderr, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
@@ -305,8 +317,9 @@ void my_syslog(int priority, const char *format, ...)
|
|||||||
p = entry->payload;
|
p = entry->payload;
|
||||||
if (!log_to_file)
|
if (!log_to_file)
|
||||||
p += sprintf(p, "<%d>", priority | log_fac);
|
p += sprintf(p, "<%d>", priority | log_fac);
|
||||||
|
|
||||||
p += sprintf(p, "%.15s dnsmasq[%d]: ", ctime(&time_now) + 4, (int)pid);
|
p += sprintf(p, "%.15s dnsmasq%s[%d]: ", ctime(&time_now) + 4, func, (int)pid);
|
||||||
|
|
||||||
len = p - entry->payload;
|
len = p - entry->payload;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
len += vsnprintf(p, MAX_MESSAGE - len, format, ap) + 1; /* include zero-terminator */
|
len += vsnprintf(p, MAX_MESSAGE - len, format, ap) + 1; /* include zero-terminator */
|
||||||
|
|||||||
+67
-32
@@ -31,6 +31,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct iovec iov;
|
static struct iovec iov;
|
||||||
|
static u32 netlink_pid;
|
||||||
|
|
||||||
static void nl_err(struct nlmsghdr *h);
|
static void nl_err(struct nlmsghdr *h);
|
||||||
static void nl_routechange(struct nlmsghdr *h);
|
static void nl_routechange(struct nlmsghdr *h);
|
||||||
@@ -38,6 +39,7 @@ static void nl_routechange(struct nlmsghdr *h);
|
|||||||
void netlink_init(void)
|
void netlink_init(void)
|
||||||
{
|
{
|
||||||
struct sockaddr_nl addr;
|
struct sockaddr_nl addr;
|
||||||
|
socklen_t slen = sizeof(addr);
|
||||||
|
|
||||||
addr.nl_family = AF_NETLINK;
|
addr.nl_family = AF_NETLINK;
|
||||||
addr.nl_pad = 0;
|
addr.nl_pad = 0;
|
||||||
@@ -59,48 +61,63 @@ void netlink_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (daemon->netlinkfd == -1)
|
if (daemon->netlinkfd == -1 ||
|
||||||
|
getsockname(daemon->netlinkfd, (struct sockaddr *)&addr, &slen) == 1)
|
||||||
die(_("cannot create netlink socket: %s"), NULL, EC_MISC);
|
die(_("cannot create netlink socket: %s"), NULL, EC_MISC);
|
||||||
|
|
||||||
|
/* save pid assigned by bind() and retrieved by getsockname() */
|
||||||
|
netlink_pid = addr.nl_pid;
|
||||||
|
|
||||||
iov.iov_len = 200;
|
iov.iov_len = 100;
|
||||||
iov.iov_base = safe_malloc(iov.iov_len);
|
iov.iov_base = safe_malloc(iov.iov_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t netlink_recv(void)
|
static ssize_t netlink_recv(void)
|
||||||
{
|
{
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
|
struct sockaddr_nl nladdr;
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
|
|
||||||
msg.msg_control = NULL;
|
|
||||||
msg.msg_controllen = 0;
|
|
||||||
msg.msg_name = NULL;
|
|
||||||
msg.msg_namelen = 0;
|
|
||||||
msg.msg_iov = &iov;
|
|
||||||
msg.msg_iovlen = 1;
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
msg.msg_control = NULL;
|
||||||
|
msg.msg_controllen = 0;
|
||||||
|
msg.msg_name = &nladdr;
|
||||||
|
msg.msg_namelen = sizeof(nladdr);
|
||||||
|
msg.msg_iov = &iov;
|
||||||
|
msg.msg_iovlen = 1;
|
||||||
msg.msg_flags = 0;
|
msg.msg_flags = 0;
|
||||||
while ((rc = recvmsg(daemon->netlinkfd, &msg, MSG_PEEK)) == -1 && errno == EINTR);
|
|
||||||
|
|
||||||
/* 2.2.x doesn't suport MSG_PEEK at all, returning EOPNOTSUPP, so we just grab a
|
while ((rc = recvmsg(daemon->netlinkfd, &msg, MSG_PEEK | MSG_TRUNC)) == -1 && errno == EINTR);
|
||||||
big buffer and pray in that case. */
|
|
||||||
if (rc == -1 && errno == EOPNOTSUPP)
|
/* make buffer big enough */
|
||||||
|
if (rc != -1 && (msg.msg_flags & MSG_TRUNC))
|
||||||
{
|
{
|
||||||
if (!expand_buf(&iov, 2000))
|
/* Very new Linux kernels return the actual size needed, older ones always return truncated size */
|
||||||
return -1;
|
if ((size_t)rc == iov.iov_len)
|
||||||
break;
|
{
|
||||||
|
if (expand_buf(&iov, rc + 100))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
expand_buf(&iov, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == -1 || !(msg.msg_flags & MSG_TRUNC))
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!expand_buf(&iov, iov.iov_len + 100))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* finally, read it for real */
|
/* read it for real */
|
||||||
while ((rc = recvmsg(daemon->netlinkfd, &msg, 0)) == -1 && errno == EINTR);
|
msg.msg_flags = 0;
|
||||||
|
while ((rc = recvmsg(daemon->netlinkfd, &msg, 0)) == -1 && errno == EINTR);
|
||||||
|
|
||||||
|
/* Make sure this is from the kernel */
|
||||||
|
if (rc == -1 || nladdr.nl_pid == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* discard stuff which is truncated at this point (expand_buf() may fail) */
|
||||||
|
if (msg.msg_flags & MSG_TRUNC)
|
||||||
|
{
|
||||||
|
rc = -1;
|
||||||
|
errno = ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -141,13 +158,20 @@ int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if ((len = netlink_recv()) == -1)
|
if ((len = netlink_recv()) == -1)
|
||||||
return 0;
|
{
|
||||||
|
if (errno == ENOBUFS)
|
||||||
|
{
|
||||||
|
sleep(1);
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
|
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
|
||||||
if (h->nlmsg_type == NLMSG_ERROR)
|
if (h->nlmsg_seq != seq || h->nlmsg_pid != netlink_pid)
|
||||||
nl_err(h);
|
|
||||||
else if (h->nlmsg_seq != seq)
|
|
||||||
nl_routechange(h); /* May be multicast arriving async */
|
nl_routechange(h); /* May be multicast arriving async */
|
||||||
|
else if (h->nlmsg_type == NLMSG_ERROR)
|
||||||
|
nl_err(h);
|
||||||
else if (h->nlmsg_type == NLMSG_DONE)
|
else if (h->nlmsg_type == NLMSG_DONE)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
@@ -208,10 +232,17 @@ int iface_enumerate(void *parm, int (*ipv4_callback)(), int (*ipv6_callback)())
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void netlink_multicast(void)
|
void netlink_multicast(void)
|
||||||
{
|
{
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
struct nlmsghdr *h;
|
struct nlmsghdr *h;
|
||||||
|
int flags;
|
||||||
|
|
||||||
|
/* don't risk blocking reading netlink messages here. */
|
||||||
|
if ((flags = fcntl(daemon->netlinkfd, F_GETFL)) == -1 ||
|
||||||
|
fcntl(daemon->netlinkfd, F_SETFL, flags | O_NONBLOCK) == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
if ((len = netlink_recv()) != -1)
|
if ((len = netlink_recv()) != -1)
|
||||||
{
|
{
|
||||||
@@ -221,11 +252,15 @@ void netlink_multicast(void)
|
|||||||
else
|
else
|
||||||
nl_routechange(h);
|
nl_routechange(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* restore non-blocking status */
|
||||||
|
fcntl(daemon->netlinkfd, F_SETFL, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nl_err(struct nlmsghdr *h)
|
static void nl_err(struct nlmsghdr *h)
|
||||||
{
|
{
|
||||||
struct nlmsgerr *err = NLMSG_DATA(h);
|
struct nlmsgerr *err = NLMSG_DATA(h);
|
||||||
|
|
||||||
if (err->error != 0)
|
if (err->error != 0)
|
||||||
my_syslog(LOG_ERR, _("netlink returns error: %s"), strerror(-(err->error)));
|
my_syslog(LOG_ERR, _("netlink returns error: %s"), strerror(-(err->error)));
|
||||||
}
|
}
|
||||||
@@ -234,10 +269,10 @@ static void nl_err(struct nlmsghdr *h)
|
|||||||
If this happens and we still have a DNS packet in the buffer, we re-send it.
|
If this happens and we still have a DNS packet in the buffer, we re-send it.
|
||||||
This helps on DoD links, where frequently the packet which triggers dialling is
|
This helps on DoD links, where frequently the packet which triggers dialling is
|
||||||
a DNS query, which then gets lost. By re-sending, we can avoid the lookup
|
a DNS query, which then gets lost. By re-sending, we can avoid the lookup
|
||||||
failing. */
|
failing. Note that we only accept these messages from the kernel (pid == 0) */
|
||||||
static void nl_routechange(struct nlmsghdr *h)
|
static void nl_routechange(struct nlmsghdr *h)
|
||||||
{
|
{
|
||||||
if (h->nlmsg_type == RTM_NEWROUTE)
|
if (h->nlmsg_pid == 0 && h->nlmsg_type == RTM_NEWROUTE)
|
||||||
{
|
{
|
||||||
struct rtmsg *rtm = NLMSG_DATA(h);
|
struct rtmsg *rtm = NLMSG_DATA(h);
|
||||||
int fd;
|
int fd;
|
||||||
|
|||||||
+40
-22
@@ -16,8 +16,37 @@
|
|||||||
|
|
||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
|
|
||||||
int iface_check(int family, struct all_addr *addr,
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
struct ifreq *ifr, int *indexp)
|
|
||||||
|
int indextoname(int fd, int index, char *name)
|
||||||
|
{
|
||||||
|
struct ifreq ifr;
|
||||||
|
|
||||||
|
if (index == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ifr.ifr_ifindex = index;
|
||||||
|
if (ioctl(fd, SIOCGIFNAME, &ifr) == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
strncpy(name, ifr.ifr_name, IF_NAMESIZE);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int indextoname(int fd, int index, char *name)
|
||||||
|
{
|
||||||
|
if (index == 0 || !if_indextoname(index, name))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int iface_check(int family, struct all_addr *addr, char *name, int *indexp)
|
||||||
{
|
{
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
@@ -27,7 +56,6 @@ int iface_check(int family, struct all_addr *addr,
|
|||||||
|
|
||||||
if (indexp)
|
if (indexp)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_BSD_BRIDGE
|
|
||||||
/* One form of bridging on BSD has the property that packets
|
/* One form of bridging on BSD has the property that packets
|
||||||
can be recieved on bridge interfaces which do not have an IP address.
|
can be recieved on bridge interfaces which do not have an IP address.
|
||||||
We allow these to be treated as aliases of another interface which does have
|
We allow these to be treated as aliases of another interface which does have
|
||||||
@@ -36,26 +64,25 @@ int iface_check(int family, struct all_addr *addr,
|
|||||||
for (bridge = daemon->bridges; bridge; bridge = bridge->next)
|
for (bridge = daemon->bridges; bridge; bridge = bridge->next)
|
||||||
{
|
{
|
||||||
for (alias = bridge->alias; alias; alias = alias->next)
|
for (alias = bridge->alias; alias; alias = alias->next)
|
||||||
if (strncmp(ifr->ifr_name, alias->iface, IF_NAMESIZE) == 0)
|
if (strncmp(name, alias->iface, IF_NAMESIZE) == 0)
|
||||||
{
|
{
|
||||||
int newindex;
|
int newindex;
|
||||||
|
|
||||||
if (!(newindex = if_nametoindex(bridge->iface)))
|
if (!(newindex = if_nametoindex(bridge->iface)))
|
||||||
{
|
{
|
||||||
my_syslog(LOG_WARNING, _("unknown interface %s in bridge-interface"), ifr->ifr_name);
|
my_syslog(LOG_WARNING, _("unknown interface %s in bridge-interface"), name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*indexp = newindex;
|
*indexp = newindex;
|
||||||
strncpy(ifr->ifr_name, bridge->iface, IF_NAMESIZE);
|
strncpy(name, bridge->iface, IF_NAMESIZE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (alias)
|
if (alias)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (daemon->if_names || (addr && daemon->if_addrs))
|
if (daemon->if_names || (addr && daemon->if_addrs))
|
||||||
@@ -63,7 +90,7 @@ int iface_check(int family, struct all_addr *addr,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
for (tmp = daemon->if_names; tmp; tmp = tmp->next)
|
for (tmp = daemon->if_names; tmp; tmp = tmp->next)
|
||||||
if (tmp->name && (strcmp(tmp->name, ifr->ifr_name) == 0))
|
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
||||||
ret = tmp->used = 1;
|
ret = tmp->used = 1;
|
||||||
|
|
||||||
for (tmp = daemon->if_addrs; tmp; tmp = tmp->next)
|
for (tmp = daemon->if_addrs; tmp; tmp = tmp->next)
|
||||||
@@ -82,7 +109,7 @@ int iface_check(int family, struct all_addr *addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (tmp = daemon->if_except; tmp; tmp = tmp->next)
|
for (tmp = daemon->if_except; tmp; tmp = tmp->next)
|
||||||
if (tmp->name && (strcmp(tmp->name, ifr->ifr_name) == 0))
|
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -103,16 +130,8 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
if (sockaddr_isequal(&iface->addr, addr))
|
if (sockaddr_isequal(&iface->addr, addr))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
|
||||||
ifr.ifr_ifindex = if_index;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1 ||
|
if ((fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1 ||
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
!indextoname(fd, if_index, ifr.ifr_name) ||
|
||||||
ioctl(fd, SIOCGIFNAME, &ifr) == -1 ||
|
|
||||||
#else
|
|
||||||
!if_indextoname(if_index, ifr.ifr_name) ||
|
|
||||||
#endif
|
|
||||||
ioctl(fd, SIOCGIFFLAGS, &ifr) == -1)
|
ioctl(fd, SIOCGIFFLAGS, &ifr) == -1)
|
||||||
{
|
{
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
@@ -150,7 +169,7 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (addr->sa.sa_family == AF_INET &&
|
if (addr->sa.sa_family == AF_INET &&
|
||||||
!iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, &ifr, NULL))
|
!iface_check(AF_INET, (struct all_addr *)&addr->in.sin_addr, ifr.ifr_name, NULL))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
@@ -159,7 +178,7 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (addr->sa.sa_family == AF_INET6 &&
|
if (addr->sa.sa_family == AF_INET6 &&
|
||||||
!iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, &ifr, NULL))
|
!iface_check(AF_INET6, (struct all_addr *)&addr->in6.sin6_addr, ifr.ifr_name, NULL))
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -217,7 +236,6 @@ static int iface_allowed_v4(struct in_addr local, int if_index,
|
|||||||
return iface_allowed((struct irec **)vparam, if_index, &addr, netmask);
|
return iface_allowed((struct irec **)vparam, if_index, &addr, netmask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int enumerate_interfaces(void)
|
int enumerate_interfaces(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
@@ -529,7 +547,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, sizeof(intname)) == -1)
|
setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, intname, strlen(intname)) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+319
-137
@@ -19,6 +19,10 @@
|
|||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
|
||||||
|
static volatile int mem_recover = 0;
|
||||||
|
static jmp_buf mem_jmp;
|
||||||
|
static void one_file(char *file, int nest, int hard_opt);
|
||||||
|
|
||||||
/* Solaris headers don't have facility names. */
|
/* Solaris headers don't have facility names. */
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
#ifdef HAVE_SOLARIS_NETWORK
|
||||||
static const struct {
|
static const struct {
|
||||||
@@ -34,10 +38,7 @@ static const struct {
|
|||||||
{ "lpr", LOG_LPR },
|
{ "lpr", LOG_LPR },
|
||||||
{ "news", LOG_NEWS },
|
{ "news", LOG_NEWS },
|
||||||
{ "uucp", LOG_UUCP },
|
{ "uucp", LOG_UUCP },
|
||||||
#ifdef LOG_AUDIT
|
|
||||||
/* Not Solaris < 10 */
|
|
||||||
{ "audit", LOG_AUDIT },
|
{ "audit", LOG_AUDIT },
|
||||||
#endif
|
|
||||||
{ "cron", LOG_CRON },
|
{ "cron", LOG_CRON },
|
||||||
{ "local0", LOG_LOCAL0 },
|
{ "local0", LOG_LOCAL0 },
|
||||||
{ "local1", LOG_LOCAL1 },
|
{ "local1", LOG_LOCAL1 },
|
||||||
@@ -98,6 +99,9 @@ struct myoption {
|
|||||||
#define LOPT_MINPORT 288
|
#define LOPT_MINPORT 288
|
||||||
#define LOPT_DHCP_FQDN 289
|
#define LOPT_DHCP_FQDN 289
|
||||||
#define LOPT_CNAME 290
|
#define LOPT_CNAME 290
|
||||||
|
#define LOPT_PXE_PROMT 291
|
||||||
|
#define LOPT_PXE_SERV 292
|
||||||
|
#define LOPT_TEST 293
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
static const struct option opts[] =
|
static const struct option opts[] =
|
||||||
@@ -105,105 +109,106 @@ static const struct option opts[] =
|
|||||||
static const struct myoption opts[] =
|
static const struct myoption opts[] =
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
{"version", 0, 0, 'v'},
|
{ "version", 0, 0, 'v' },
|
||||||
{"no-hosts", 0, 0, 'h'},
|
{ "no-hosts", 0, 0, 'h' },
|
||||||
{"no-poll", 0, 0, 'n'},
|
{ "no-poll", 0, 0, 'n' },
|
||||||
{"help", 0, 0, 'w'},
|
{ "help", 0, 0, 'w' },
|
||||||
{"no-daemon", 0, 0, 'd'},
|
{ "no-daemon", 0, 0, 'd' },
|
||||||
{"log-queries", 0, 0, 'q'},
|
{ "log-queries", 0, 0, 'q' },
|
||||||
{"user", 2, 0, 'u'},
|
{ "user", 2, 0, 'u' },
|
||||||
{"group", 2, 0, 'g'},
|
{ "group", 2, 0, 'g' },
|
||||||
{"resolv-file", 2, 0, 'r'},
|
{ "resolv-file", 2, 0, 'r' },
|
||||||
{"mx-host", 1, 0, 'm'},
|
{ "mx-host", 1, 0, 'm' },
|
||||||
{"mx-target", 1, 0, 't'},
|
{ "mx-target", 1, 0, 't' },
|
||||||
{"cache-size", 2, 0, 'c'},
|
{ "cache-size", 2, 0, 'c' },
|
||||||
{"port", 1, 0, 'p'},
|
{ "port", 1, 0, 'p' },
|
||||||
{"dhcp-leasefile", 2, 0, 'l'},
|
{ "dhcp-leasefile", 2, 0, 'l' },
|
||||||
{"dhcp-lease", 1, 0, 'l' },
|
{ "dhcp-lease", 1, 0, 'l' },
|
||||||
{"dhcp-host", 1, 0, 'G'},
|
{ "dhcp-host", 1, 0, 'G' },
|
||||||
{"dhcp-range", 1, 0, 'F'},
|
{ "dhcp-range", 1, 0, 'F' },
|
||||||
{"dhcp-option", 1, 0, 'O'},
|
{ "dhcp-option", 1, 0, 'O' },
|
||||||
{"dhcp-boot", 1, 0, 'M'},
|
{ "dhcp-boot", 1, 0, 'M' },
|
||||||
{"domain", 1, 0, 's'},
|
{ "domain", 1, 0, 's' },
|
||||||
{"domain-suffix", 1, 0, 's'},
|
{ "domain-suffix", 1, 0, 's' },
|
||||||
{"interface", 1, 0, 'i'},
|
{ "interface", 1, 0, 'i' },
|
||||||
{"listen-address", 1, 0, 'a'},
|
{ "listen-address", 1, 0, 'a' },
|
||||||
{"bogus-priv", 0, 0, 'b'},
|
{ "bogus-priv", 0, 0, 'b' },
|
||||||
{"bogus-nxdomain", 1, 0, 'B'},
|
{ "bogus-nxdomain", 1, 0, 'B' },
|
||||||
{"selfmx", 0, 0, 'e'},
|
{ "selfmx", 0, 0, 'e' },
|
||||||
{"filterwin2k", 0, 0, 'f'},
|
{ "filterwin2k", 0, 0, 'f' },
|
||||||
{"pid-file", 2, 0, 'x'},
|
{ "pid-file", 2, 0, 'x' },
|
||||||
{"strict-order", 0, 0, 'o'},
|
{ "strict-order", 0, 0, 'o' },
|
||||||
{"server", 1, 0, 'S'},
|
{ "server", 1, 0, 'S' },
|
||||||
{"local", 1, 0, LOPT_LOCAL },
|
{ "local", 1, 0, LOPT_LOCAL },
|
||||||
{"address", 1, 0, 'A' },
|
{ "address", 1, 0, 'A' },
|
||||||
{"conf-file", 2, 0, 'C'},
|
{ "conf-file", 2, 0, 'C' },
|
||||||
{"no-resolv", 0, 0, 'R'},
|
{ "no-resolv", 0, 0, 'R' },
|
||||||
{"expand-hosts", 0, 0, 'E'},
|
{ "expand-hosts", 0, 0, 'E' },
|
||||||
{"localmx", 0, 0, 'L'},
|
{ "localmx", 0, 0, 'L' },
|
||||||
{"local-ttl", 1, 0, 'T'},
|
{ "local-ttl", 1, 0, 'T' },
|
||||||
{"no-negcache", 0, 0, 'N'},
|
{ "no-negcache", 0, 0, 'N' },
|
||||||
{"addn-hosts", 1, 0, 'H'},
|
{ "addn-hosts", 1, 0, 'H' },
|
||||||
{"query-port", 1, 0, 'Q'},
|
{ "query-port", 1, 0, 'Q' },
|
||||||
{"except-interface", 1, 0, 'I'},
|
{ "except-interface", 1, 0, 'I' },
|
||||||
{"no-dhcp-interface", 1, 0, '2'},
|
{ "no-dhcp-interface", 1, 0, '2' },
|
||||||
{"domain-needed", 0, 0, 'D'},
|
{ "domain-needed", 0, 0, 'D' },
|
||||||
{"dhcp-lease-max", 1, 0, 'X' },
|
{ "dhcp-lease-max", 1, 0, 'X' },
|
||||||
{"bind-interfaces", 0, 0, 'z'},
|
{ "bind-interfaces", 0, 0, 'z' },
|
||||||
{"read-ethers", 0, 0, 'Z' },
|
{ "read-ethers", 0, 0, 'Z' },
|
||||||
{"alias", 1, 0, 'V' },
|
{ "alias", 1, 0, 'V' },
|
||||||
{"dhcp-vendorclass", 1, 0, 'U'},
|
{ "dhcp-vendorclass", 1, 0, 'U' },
|
||||||
{"dhcp-userclass", 1, 0, 'j'},
|
{ "dhcp-userclass", 1, 0, 'j' },
|
||||||
{"dhcp-ignore", 1, 0, 'J'},
|
{ "dhcp-ignore", 1, 0, 'J' },
|
||||||
{"edns-packet-max", 1, 0, 'P'},
|
{ "edns-packet-max", 1, 0, 'P' },
|
||||||
{"keep-in-foreground", 0, 0, 'k'},
|
{ "keep-in-foreground", 0, 0, 'k' },
|
||||||
{"dhcp-authoritative", 0, 0, 'K'},
|
{ "dhcp-authoritative", 0, 0, 'K' },
|
||||||
{"srv-host", 1, 0, 'W'},
|
{ "srv-host", 1, 0, 'W' },
|
||||||
{"localise-queries", 0, 0, 'y'},
|
{ "localise-queries", 0, 0, 'y' },
|
||||||
{"txt-record", 1, 0, 'Y'},
|
{ "txt-record", 1, 0, 'Y' },
|
||||||
{"enable-dbus", 0, 0, '1'},
|
{ "enable-dbus", 0, 0, '1' },
|
||||||
{"bootp-dynamic", 2, 0, '3'},
|
{ "bootp-dynamic", 2, 0, '3' },
|
||||||
{"dhcp-mac", 1, 0, '4'},
|
{ "dhcp-mac", 1, 0, '4' },
|
||||||
{"no-ping", 0, 0, '5'},
|
{ "no-ping", 0, 0, '5' },
|
||||||
{"dhcp-script", 1, 0, '6'},
|
{ "dhcp-script", 1, 0, '6' },
|
||||||
{"conf-dir", 1, 0, '7'},
|
{ "conf-dir", 1, 0, '7' },
|
||||||
{"log-facility", 1, 0 ,'8'},
|
{ "log-facility", 1, 0 ,'8' },
|
||||||
{"leasefile-ro", 0, 0, '9'},
|
{ "leasefile-ro", 0, 0, '9' },
|
||||||
{"dns-forward-max", 1, 0, '0'},
|
{ "dns-forward-max", 1, 0, '0' },
|
||||||
{"clear-on-reload", 0, 0, LOPT_RELOAD },
|
{ "clear-on-reload", 0, 0, LOPT_RELOAD },
|
||||||
{"dhcp-ignore-names", 2, 0, LOPT_NO_NAMES },
|
{ "dhcp-ignore-names", 2, 0, LOPT_NO_NAMES },
|
||||||
{"enable-tftp", 0, 0, LOPT_TFTP },
|
{ "enable-tftp", 0, 0, LOPT_TFTP },
|
||||||
{"tftp-secure", 0, 0, LOPT_SECURE },
|
{ "tftp-secure", 0, 0, LOPT_SECURE },
|
||||||
{"tftp-unique-root", 0, 0, LOPT_APREF },
|
{ "tftp-unique-root", 0, 0, LOPT_APREF },
|
||||||
{"tftp-root", 1, 0, LOPT_PREFIX },
|
{ "tftp-root", 1, 0, LOPT_PREFIX },
|
||||||
{"tftp-max", 1, 0, LOPT_TFTP_MAX },
|
{ "tftp-max", 1, 0, LOPT_TFTP_MAX },
|
||||||
{"ptr-record", 1, 0, LOPT_PTR },
|
{ "ptr-record", 1, 0, LOPT_PTR },
|
||||||
{"naptr-record", 1, 0, LOPT_NAPTR },
|
{ "naptr-record", 1, 0, LOPT_NAPTR },
|
||||||
#ifdef HAVE_BSD_BRIDGE
|
{ "bridge-interface", 1, 0 , LOPT_BRIDGE },
|
||||||
{"bridge-interface", 1, 0 , LOPT_BRIDGE },
|
{ "dhcp-option-force", 1, 0, LOPT_FORCE },
|
||||||
#endif
|
{ "tftp-no-blocksize", 0, 0, LOPT_NOBLOCK },
|
||||||
{"dhcp-option-force", 1, 0, LOPT_FORCE },
|
{ "log-dhcp", 0, 0, LOPT_LOG_OPTS },
|
||||||
{"tftp-no-blocksize", 0, 0, LOPT_NOBLOCK },
|
{ "log-async", 2, 0, LOPT_MAX_LOGS },
|
||||||
{"log-dhcp", 0, 0, LOPT_LOG_OPTS },
|
{ "dhcp-circuitid", 1, 0, LOPT_CIRCUIT },
|
||||||
{"log-async", 2, 0, LOPT_MAX_LOGS },
|
{ "dhcp-remoteid", 1, 0, LOPT_REMOTE },
|
||||||
{"dhcp-circuitid", 1, 0, LOPT_CIRCUIT },
|
{ "dhcp-subscrid", 1, 0, LOPT_SUBSCR },
|
||||||
{"dhcp-remoteid", 1, 0, LOPT_REMOTE },
|
{ "interface-name", 1, 0, LOPT_INTNAME },
|
||||||
{"dhcp-subscrid", 1, 0, LOPT_SUBSCR },
|
{ "dhcp-hostsfile", 1, 0, LOPT_DHCP_HOST },
|
||||||
{"interface-name", 1, 0, LOPT_INTNAME },
|
{ "dhcp-optsfile", 1, 0, LOPT_DHCP_OPTS },
|
||||||
{"dhcp-hostsfile", 1, 0, LOPT_DHCP_HOST },
|
{ "dhcp-no-override", 0, 0, LOPT_OVERRIDE },
|
||||||
{"dhcp-optsfile", 1, 0, LOPT_DHCP_OPTS },
|
{ "tftp-port-range", 1, 0, LOPT_TFTPPORTS },
|
||||||
{"dhcp-no-override", 0, 0, LOPT_OVERRIDE },
|
{ "stop-dns-rebind", 0, 0, LOPT_REBIND },
|
||||||
{"tftp-port-range", 1, 0, LOPT_TFTPPORTS },
|
{ "all-servers", 0, 0, LOPT_NOLAST },
|
||||||
{"stop-dns-rebind", 0, 0, LOPT_REBIND },
|
{ "dhcp-match", 1, 0, LOPT_MATCH },
|
||||||
{"all-servers", 0, 0, LOPT_NOLAST},
|
{ "dhcp-broadcast", 1, 0, LOPT_BROADCAST },
|
||||||
{"dhcp-match", 1, 0, LOPT_MATCH },
|
{ "neg-ttl", 1, 0, LOPT_NEGTTL },
|
||||||
{"dhcp-broadcast", 1, 0, LOPT_BROADCAST },
|
{ "dhcp-alternate-port", 2, 0, LOPT_ALTPORT },
|
||||||
{"neg-ttl", 1, 0, LOPT_NEGTTL },
|
{ "dhcp-scriptuser", 1, 0, LOPT_SCRIPTUSR },
|
||||||
{"dhcp-alternate-port", 2, 0, LOPT_ALTPORT },
|
{ "min-port", 1, 0, LOPT_MINPORT },
|
||||||
{"dhcp-scriptuser", 1, 0, LOPT_SCRIPTUSR },
|
{ "dhcp-fqdn", 0, 0, LOPT_DHCP_FQDN },
|
||||||
{"min-port", 1, 0, LOPT_MINPORT },
|
{ "cname", 1, 0, LOPT_CNAME },
|
||||||
{"dhcp-fqdn", 0, 0, LOPT_DHCP_FQDN },
|
{ "pxe-prompt", 1, 0, LOPT_PXE_PROMT },
|
||||||
{"cname", 1, 0, LOPT_CNAME },
|
{ "pxe-service", 1, 0, LOPT_PXE_SERV },
|
||||||
|
{ "test", 0, 0, LOPT_TEST },
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -287,9 +292,7 @@ static struct {
|
|||||||
{ '2', ARG_DUP, "interface", gettext_noop("Do not provide DHCP on this interface, only provide DNS."), NULL },
|
{ '2', ARG_DUP, "interface", gettext_noop("Do not provide DHCP on this interface, only provide DNS."), NULL },
|
||||||
{ '3', ARG_DUP, "[=<id>[,<id>]]", gettext_noop("Enable dynamic address allocation for bootp."), NULL },
|
{ '3', ARG_DUP, "[=<id>[,<id>]]", gettext_noop("Enable dynamic address allocation for bootp."), NULL },
|
||||||
{ '4', ARG_DUP, "<id>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL },
|
{ '4', ARG_DUP, "<id>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL },
|
||||||
#ifdef HAVE_BSD_BRIDGE
|
|
||||||
{ LOPT_BRIDGE, ARG_DUP, "iface,alias,..", gettext_noop("Treat DHCP requests on aliases as arriving from interface."), NULL },
|
{ LOPT_BRIDGE, ARG_DUP, "iface,alias,..", gettext_noop("Treat DHCP requests on aliases as arriving from interface."), NULL },
|
||||||
#endif
|
|
||||||
{ '5', OPT_NO_PING, NULL, gettext_noop("Disable ICMP echo address checking in the DHCP server."), NULL },
|
{ '5', OPT_NO_PING, NULL, gettext_noop("Disable ICMP echo address checking in the DHCP server."), NULL },
|
||||||
{ '6', ARG_ONE, "path", gettext_noop("Script to run on DHCP lease creation and destruction."), NULL },
|
{ '6', ARG_ONE, "path", gettext_noop("Script to run on DHCP lease creation and destruction."), NULL },
|
||||||
{ '7', ARG_DUP, "path", gettext_noop("Read configuration from all the files in this directory."), NULL },
|
{ '7', ARG_DUP, "path", gettext_noop("Read configuration from all the files in this directory."), NULL },
|
||||||
@@ -317,13 +320,18 @@ static struct {
|
|||||||
{ LOPT_MINPORT, ARG_ONE, "<port>", gettext_noop("Specify lowest port available for DNS query transmission."), NULL },
|
{ LOPT_MINPORT, ARG_ONE, "<port>", gettext_noop("Specify lowest port available for DNS query transmission."), NULL },
|
||||||
{ LOPT_DHCP_FQDN, OPT_DHCP_FQDN, NULL, gettext_noop("Use only fully qualified domain names for DHCP clients."), NULL },
|
{ LOPT_DHCP_FQDN, OPT_DHCP_FQDN, NULL, gettext_noop("Use only fully qualified domain names for DHCP clients."), NULL },
|
||||||
{ LOPT_CNAME, ARG_DUP, "<alias>,<target>", gettext_noop("Specify alias name for LOCAL DNS name."), NULL },
|
{ LOPT_CNAME, ARG_DUP, "<alias>,<target>", gettext_noop("Specify alias name for LOCAL DNS name."), NULL },
|
||||||
|
{ LOPT_PXE_PROMT, ARG_DUP, "<prompt>,[<timeout>]", gettext_noop("Prompt to send to PXE clients."), NULL },
|
||||||
|
{ LOPT_PXE_SERV, ARG_DUP, "<service>", gettext_noop("Boot service for PXE menu."), NULL },
|
||||||
|
{ LOPT_TEST, 0, NULL, gettext_noop("Check configuration syntax."), NULL },
|
||||||
{ 0, 0, NULL, NULL, NULL }
|
{ 0, 0, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
/* makes options which take a list of addresses */
|
/* makes options which take a list of addresses */
|
||||||
#define OT_ADDR_LIST 255
|
#define OT_ADDR_LIST 0x80
|
||||||
/* DHCP-internal options, for logging. not valid in config file */
|
/* DHCP-internal options, for logging. not valid in config file */
|
||||||
#define OT_INTERNAL 254
|
#define OT_INTERNAL 0x40
|
||||||
|
#define OT_NAME 0x20
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
char *name;
|
char *name;
|
||||||
@@ -335,9 +343,9 @@ static const struct {
|
|||||||
{ "dns-server", 6, OT_ADDR_LIST },
|
{ "dns-server", 6, OT_ADDR_LIST },
|
||||||
{ "log-server", 7, OT_ADDR_LIST },
|
{ "log-server", 7, OT_ADDR_LIST },
|
||||||
{ "lpr-server", 9, OT_ADDR_LIST },
|
{ "lpr-server", 9, OT_ADDR_LIST },
|
||||||
{ "hostname", 12, OT_INTERNAL },
|
{ "hostname", 12, OT_INTERNAL | OT_NAME },
|
||||||
{ "boot-file-size", 13, 2 },
|
{ "boot-file-size", 13, 2 },
|
||||||
{ "domain-name", 15, 0 },
|
{ "domain-name", 15, OT_NAME },
|
||||||
{ "swap-server", 16, OT_ADDR_LIST },
|
{ "swap-server", 16, OT_ADDR_LIST },
|
||||||
{ "root-path", 17, 0 },
|
{ "root-path", 17, 0 },
|
||||||
{ "extension-path", 18, 0 },
|
{ "extension-path", 18, 0 },
|
||||||
@@ -348,7 +356,7 @@ static const struct {
|
|||||||
{ "default-ttl", 23, 1 },
|
{ "default-ttl", 23, 1 },
|
||||||
{ "mtu", 26, 2 },
|
{ "mtu", 26, 2 },
|
||||||
{ "all-subnets-local", 27, 1 },
|
{ "all-subnets-local", 27, 1 },
|
||||||
{ "broadcast", 28, OT_INTERNAL },
|
{ "broadcast", 28, OT_INTERNAL | OT_ADDR_LIST },
|
||||||
{ "router-discovery", 31, 1 },
|
{ "router-discovery", 31, 1 },
|
||||||
{ "router-solicitation", 32, OT_ADDR_LIST },
|
{ "router-solicitation", 32, OT_ADDR_LIST },
|
||||||
{ "static-route", 33, OT_ADDR_LIST },
|
{ "static-route", 33, OT_ADDR_LIST },
|
||||||
@@ -367,11 +375,11 @@ static const struct {
|
|||||||
{ "netbios-scope", 47, 0 },
|
{ "netbios-scope", 47, 0 },
|
||||||
{ "x-windows-fs", 48, OT_ADDR_LIST },
|
{ "x-windows-fs", 48, OT_ADDR_LIST },
|
||||||
{ "x-windows-dm", 49, OT_ADDR_LIST },
|
{ "x-windows-dm", 49, OT_ADDR_LIST },
|
||||||
{ "requested-address", 50, OT_INTERNAL },
|
{ "requested-address", 50, OT_INTERNAL | OT_ADDR_LIST },
|
||||||
{ "lease-time", 51, OT_INTERNAL },
|
{ "lease-time", 51, OT_INTERNAL },
|
||||||
{ "option-overload", 52, OT_INTERNAL },
|
{ "option-overload", 52, OT_INTERNAL },
|
||||||
{ "message-type", 53, OT_INTERNAL, },
|
{ "message-type", 53, OT_INTERNAL, },
|
||||||
{ "server-identifier", 54, OT_INTERNAL },
|
{ "server-identifier", 54, OT_INTERNAL | OT_ADDR_LIST },
|
||||||
{ "parameter-request", 55, OT_INTERNAL },
|
{ "parameter-request", 55, OT_INTERNAL },
|
||||||
{ "message", 56, OT_INTERNAL },
|
{ "message", 56, OT_INTERNAL },
|
||||||
{ "max-message-size", 57, OT_INTERNAL },
|
{ "max-message-size", 57, OT_INTERNAL },
|
||||||
@@ -401,21 +409,25 @@ static const struct {
|
|||||||
{ NULL, 0, 0 }
|
{ NULL, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static volatile int mem_recover = 0;
|
char *option_string(unsigned char opt, int *is_ip, int *is_name)
|
||||||
static jmp_buf mem_jmp;
|
|
||||||
static void one_file(char *file, int nest, int hard_opt);
|
|
||||||
|
|
||||||
char *option_string(unsigned char opt)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; opttab[i].name; i++)
|
for (i = 0; opttab[i].name; i++)
|
||||||
if (opttab[i].val == opt)
|
if (opttab[i].val == opt)
|
||||||
return opttab[i].name;
|
{
|
||||||
|
if (is_ip)
|
||||||
|
*is_ip = !!(opttab[i].size & OT_ADDR_LIST);
|
||||||
|
if (is_name)
|
||||||
|
*is_name = !!(opttab[i].size & OT_NAME);
|
||||||
|
return opttab[i].name;
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* We hide metacharaters in quoted strings by mapping them into the ASCII control
|
/* We hide metacharaters in quoted strings by mapping them into the ASCII control
|
||||||
character space. Note that the \0, \t \b \r \033 and \n characters are carefully placed in the
|
character space. Note that the \0, \t \b \r \033 and \n characters are carefully placed in the
|
||||||
following sequence so that they map to themselves: it is therefore possible to call
|
following sequence so that they map to themselves: it is therefore possible to call
|
||||||
@@ -626,6 +638,7 @@ static void do_usage(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
static void display_opts(void)
|
static void display_opts(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -760,7 +773,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
|
|||||||
|
|
||||||
/* We know that some options take addresses */
|
/* We know that some options take addresses */
|
||||||
|
|
||||||
if (opt_len == OT_ADDR_LIST)
|
if (opt_len & OT_ADDR_LIST)
|
||||||
{
|
{
|
||||||
is_string = is_dec = is_hex = 0;
|
is_string = is_dec = is_hex = 0;
|
||||||
if (!is_addr || dots == 0)
|
if (!is_addr || dots == 0)
|
||||||
@@ -919,7 +932,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new->len > 255)
|
if ((new->len > 255) || (new->len > 253 && (new->flags & (DHOPT_VENDOR | DHOPT_ENCAPSULATE))))
|
||||||
problem = _("dhcp-option too long");
|
problem = _("dhcp-option too long");
|
||||||
|
|
||||||
if (!problem)
|
if (!problem)
|
||||||
@@ -946,6 +959,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
|
|||||||
return problem;
|
return problem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
||||||
{
|
{
|
||||||
@@ -1013,20 +1027,21 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
|
|
||||||
while ((ent = readdir(dir_stream)))
|
while ((ent = readdir(dir_stream)))
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len = strlen(ent->d_name);
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if ((len = strlen(ent->d_name)) == 0)
|
|
||||||
continue;
|
|
||||||
/* ignore emacs backups and dotfiles */
|
/* ignore emacs backups and dotfiles */
|
||||||
if (ent->d_name[len - 1] == '~' ||
|
if (len == 0 ||
|
||||||
|
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;
|
||||||
|
|
||||||
path = opt_malloc(strlen(directory) + len + 2);
|
path = opt_malloc(strlen(directory) + len + 2);
|
||||||
strcpy(path, directory);
|
strcpy(path, directory);
|
||||||
strcat(path, "/");
|
strcat(path, "/");
|
||||||
strcat(path, ent->d_name);
|
strcat(path, ent->d_name);
|
||||||
|
|
||||||
if (stat(path, &buf) == -1)
|
if (stat(path, &buf) == -1)
|
||||||
die(_("cannot access %s: %s"), path, EC_FILE);
|
die(_("cannot access %s: %s"), path, EC_FILE);
|
||||||
/* only reg files allowed. */
|
/* only reg files allowed. */
|
||||||
@@ -1139,25 +1154,28 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
else
|
else
|
||||||
daemon->mxtarget = opt_string_alloc(arg);
|
daemon->mxtarget = opt_string_alloc(arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
case 'l': /* --dhcp-leasefile */
|
case 'l': /* --dhcp-leasefile */
|
||||||
daemon->lease_file = opt_string_alloc(arg);
|
daemon->lease_file = opt_string_alloc(arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '6': /* --dhcp-script */
|
case '6': /* --dhcp-script */
|
||||||
#ifdef NO_FORK
|
# ifdef NO_FORK
|
||||||
problem = _("cannot run scripts under uClinux");
|
problem = _("cannot run scripts under uClinux");
|
||||||
#else
|
# else
|
||||||
daemon->lease_change_command = opt_string_alloc(arg);
|
daemon->lease_change_command = opt_string_alloc(arg);
|
||||||
#endif
|
# endif
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case 'H': /* --addn-hosts */
|
case 'H': /* --addn-hosts */
|
||||||
{
|
{
|
||||||
struct hostsfile *new = opt_malloc(sizeof(struct hostsfile));
|
struct hostsfile *new = opt_malloc(sizeof(struct hostsfile));
|
||||||
static int hosts_index = 1;
|
static int hosts_index = 1;
|
||||||
new->fname = opt_string_alloc(arg);
|
new->fname = opt_string_alloc(arg);
|
||||||
new->index = hosts_index++;
|
new->index = hosts_index++;
|
||||||
|
new->flags = 0;
|
||||||
new->next = daemon->addn_hosts;
|
new->next = daemon->addn_hosts;
|
||||||
daemon->addn_hosts = new;
|
daemon->addn_hosts = new;
|
||||||
break;
|
break;
|
||||||
@@ -1219,9 +1237,11 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
daemon->group_set = 1;
|
daemon->group_set = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
case LOPT_SCRIPTUSR: /* --scriptuser */
|
case LOPT_SCRIPTUSR: /* --scriptuser */
|
||||||
daemon->scriptuser = opt_string_alloc(arg);
|
daemon->scriptuser = opt_string_alloc(arg);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
case 'i': /* --interface */
|
case 'i': /* --interface */
|
||||||
do {
|
do {
|
||||||
@@ -1520,11 +1540,14 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
case 'X': /* --dhcp-lease-max */
|
case 'X': /* --dhcp-lease-max */
|
||||||
if (!atoi_check(arg, &daemon->dhcp_max))
|
if (!atoi_check(arg, &daemon->dhcp_max))
|
||||||
option = '?';
|
option = '?';
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_TFTP
|
||||||
case LOPT_TFTP_MAX: /* --tftp-max */
|
case LOPT_TFTP_MAX: /* --tftp-max */
|
||||||
if (!atoi_check(arg, &daemon->tftp_max))
|
if (!atoi_check(arg, &daemon->tftp_max))
|
||||||
option = '?';
|
option = '?';
|
||||||
@@ -1548,8 +1571,8 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_BSD_BRIDGE
|
|
||||||
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));
|
||||||
@@ -1578,8 +1601,8 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
case 'F': /* --dhcp-range */
|
case 'F': /* --dhcp-range */
|
||||||
{
|
{
|
||||||
int k, leasepos = 2;
|
int k, leasepos = 2;
|
||||||
@@ -1646,6 +1669,11 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
new->end = new->start;
|
new->end = new->start;
|
||||||
new->flags |= CONTEXT_STATIC;
|
new->flags |= CONTEXT_STATIC;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(a[1], "proxy") == 0)
|
||||||
|
{
|
||||||
|
new->end = new->start;
|
||||||
|
new->flags |= CONTEXT_PROXY;
|
||||||
|
}
|
||||||
else if ((new->end.s_addr = inet_addr(a[1])) == (in_addr_t)-1)
|
else if ((new->end.s_addr = inet_addr(a[1])) == (in_addr_t)-1)
|
||||||
option = '?';
|
option = '?';
|
||||||
|
|
||||||
@@ -1916,7 +1944,122 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LOPT_PXE_PROMT: /* --pxe-prompt */
|
||||||
|
{
|
||||||
|
struct dhcp_opt *new = opt_malloc(sizeof(struct dhcp_opt));
|
||||||
|
int timeout;
|
||||||
|
|
||||||
|
new->netid = NULL;
|
||||||
|
new->opt = 10; /* PXE_MENU_PROMPT */
|
||||||
|
|
||||||
|
while (arg && strstr(arg, "net:") == arg)
|
||||||
|
{
|
||||||
|
struct dhcp_netid *nn = opt_malloc(sizeof (struct dhcp_netid));
|
||||||
|
comma = split(arg);
|
||||||
|
nn->next = new->netid;
|
||||||
|
new->netid = nn;
|
||||||
|
nn->net = opt_string_alloc(arg+4);
|
||||||
|
arg = comma;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!arg)
|
||||||
|
option = '?';
|
||||||
|
else
|
||||||
|
{
|
||||||
|
comma = split(arg);
|
||||||
|
unhide_metas(arg);
|
||||||
|
new->len = strlen(arg) + 1;
|
||||||
|
new->val = opt_malloc(new->len);
|
||||||
|
memcpy(new->val + 1, arg, new->len - 1);
|
||||||
|
|
||||||
|
new->u.vendor_class = (unsigned char *)"PXEClient";
|
||||||
|
new->flags = DHOPT_VENDOR;
|
||||||
|
|
||||||
|
if (comma && atoi_check(comma, &timeout))
|
||||||
|
*(new->val) = timeout;
|
||||||
|
else
|
||||||
|
*(new->val) = 255;
|
||||||
|
|
||||||
|
new->next = daemon->dhcp_opts;
|
||||||
|
daemon->dhcp_opts = new;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LOPT_PXE_SERV: /* --pxe-service */
|
||||||
|
{
|
||||||
|
struct pxe_service *new = opt_malloc(sizeof(struct pxe_service));
|
||||||
|
char *CSA[] = { "x86PC", "PC98", "IA64_EFI", "Alpha", "Arc_x86", "Intel_Lean_Client",
|
||||||
|
"IA32_EFI", "BC_EFI", "Xscale_EFI", "x86-64_EFI", NULL };
|
||||||
|
static int boottype = 32768;
|
||||||
|
|
||||||
|
new->netid = NULL;
|
||||||
|
new->server.s_addr = 0;
|
||||||
|
|
||||||
|
while (arg && strstr(arg, "net:") == arg)
|
||||||
|
{
|
||||||
|
struct dhcp_netid *nn = opt_malloc(sizeof (struct dhcp_netid));
|
||||||
|
comma = split(arg);
|
||||||
|
nn->next = new->netid;
|
||||||
|
new->netid = nn;
|
||||||
|
nn->net = opt_string_alloc(arg+4);
|
||||||
|
arg = comma;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg && (comma = split(arg)))
|
||||||
|
{
|
||||||
|
for (i = 0; CSA[i]; i++)
|
||||||
|
if (strcasecmp(CSA[i], arg) == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (CSA[i] || atoi_check(arg, &i))
|
||||||
|
{
|
||||||
|
arg = comma;
|
||||||
|
comma = split(arg);
|
||||||
|
|
||||||
|
new->CSA = i;
|
||||||
|
new->menu = opt_string_alloc(arg);
|
||||||
|
|
||||||
|
if (comma)
|
||||||
|
{
|
||||||
|
arg = comma;
|
||||||
|
comma = split(arg);
|
||||||
|
if (atoi_check(arg, &i))
|
||||||
|
{
|
||||||
|
new->type = i;
|
||||||
|
new->basename = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new->type = boottype++;
|
||||||
|
new->basename = opt_string_alloc(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (comma && (new->server.s_addr = inet_addr(comma)) == (in_addr_t)-1)
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
option = '?';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case '4': /* --dhcp-mac */
|
case '4': /* --dhcp-mac */
|
||||||
{
|
{
|
||||||
if (!(comma = split(arg)))
|
if (!(comma = split(arg)))
|
||||||
@@ -2058,6 +2201,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
new->list = list;
|
new->list = list;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
case 'V': /* --alias */
|
case 'V': /* --alias */
|
||||||
{
|
{
|
||||||
@@ -2311,6 +2455,10 @@ static char *one_opt(int option, char *arg, char *gen_prob, int nest)
|
|||||||
new->weight = weight;
|
new->weight = weight;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
return _("unsupported option (check that dnsmasq was compiled with DHCP/TFTP/DBus support)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (problem)
|
if (problem)
|
||||||
@@ -2328,10 +2476,32 @@ static void one_file(char *file, int nest, int hard_opt)
|
|||||||
int i, option;
|
int i, option;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *p, *arg, *start, *buff = daemon->namebuff;
|
char *p, *arg, *start, *buff = daemon->namebuff;
|
||||||
|
static struct fileread {
|
||||||
|
dev_t dev;
|
||||||
|
ino_t ino;
|
||||||
|
struct fileread *next;
|
||||||
|
} *filesread = NULL;
|
||||||
|
struct stat statbuf;
|
||||||
|
|
||||||
|
/* ignore repeated files. */
|
||||||
|
if (hard_opt == 0 && stat(file, &statbuf) == 0)
|
||||||
|
{
|
||||||
|
struct fileread *r;
|
||||||
|
|
||||||
|
for (r = filesread; r; r = r->next)
|
||||||
|
if (r->dev == statbuf.st_dev && r->ino == statbuf.st_ino)
|
||||||
|
return;
|
||||||
|
|
||||||
|
r = safe_malloc(sizeof(struct fileread));
|
||||||
|
r->next = filesread;
|
||||||
|
filesread = r;
|
||||||
|
r->dev = statbuf.st_dev;
|
||||||
|
r->ino = statbuf.st_ino;
|
||||||
|
}
|
||||||
|
|
||||||
if (nest > 20)
|
if (nest > 20)
|
||||||
die(_("files nested too deep in %s"), file, EC_BADCONF);
|
die(_("files nested too deep in %s"), file, EC_BADCONF);
|
||||||
|
|
||||||
if (!(f = fopen(file, "r")))
|
if (!(f = fopen(file, "r")))
|
||||||
{
|
{
|
||||||
if (errno == ENOENT && nest == 0)
|
if (errno == ENOENT && nest == 0)
|
||||||
@@ -2476,6 +2646,7 @@ static void one_file(char *file, int nest, int hard_opt)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
void reread_dhcp(void)
|
void reread_dhcp(void)
|
||||||
{
|
{
|
||||||
if (daemon->dhcp_hosts_file)
|
if (daemon->dhcp_hosts_file)
|
||||||
@@ -2546,11 +2717,12 @@ void reread_dhcp(void)
|
|||||||
my_syslog(LOG_INFO, _("read %s"), daemon->dhcp_opts_file);
|
my_syslog(LOG_INFO, _("read %s"), daemon->dhcp_opts_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void read_opts(int argc, char **argv, char *compile_opts)
|
void read_opts(int argc, char **argv, char *compile_opts)
|
||||||
{
|
{
|
||||||
char *buff = opt_malloc(MAXDNAME);
|
char *buff = opt_malloc(MAXDNAME);
|
||||||
int option, nest = 0;
|
int option, nest = 0, testmode = 0;
|
||||||
char *errmess, *arg, *conffile = CONFFILE;
|
char *errmess, *arg, *conffile = CONFFILE;
|
||||||
|
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
@@ -2600,12 +2772,16 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
arg = NULL;
|
arg = NULL;
|
||||||
|
|
||||||
/* command-line only stuff */
|
/* command-line only stuff */
|
||||||
if (option == 'w')
|
if (option == LOPT_TEST)
|
||||||
|
testmode = 1;
|
||||||
|
else if (option == 'w')
|
||||||
{
|
{
|
||||||
if (argc == 3 && strcmp(argv[2], "dhcp") == 0)
|
if (argc != 3 || strcmp(argv[2], "dhcp") != 0)
|
||||||
display_opts();
|
|
||||||
else
|
|
||||||
do_usage();
|
do_usage();
|
||||||
|
#ifdef HAVE_DHCP
|
||||||
|
else
|
||||||
|
display_opts();
|
||||||
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (option == 'v')
|
else if (option == 'v')
|
||||||
@@ -2752,4 +2928,10 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
}
|
}
|
||||||
else if (daemon->options & OPT_DHCP_FQDN)
|
else if (daemon->options & OPT_DHCP_FQDN)
|
||||||
die(_("there must be a default domain when --dhcp-fqdn is set"), NULL, EC_BADCONF);
|
die(_("there must be a default domain when --dhcp-fqdn is set"), NULL, EC_BADCONF);
|
||||||
|
|
||||||
|
if (testmode)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "dnsmasq: %s.\n", _("syntax check OK"));
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
-3
@@ -1290,7 +1290,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
log_query(crecp->flags & ~F_FORWARD, cache_get_name(crecp), &addr,
|
log_query(crecp->flags & ~F_FORWARD, cache_get_name(crecp), &addr,
|
||||||
record_source(daemon->addn_hosts, crecp->uid));
|
record_source(crecp->uid));
|
||||||
|
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
crec_ttl(crecp, now), NULL,
|
crec_ttl(crecp, now), NULL,
|
||||||
@@ -1400,7 +1400,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
{
|
{
|
||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
log_query(crecp->flags, name, NULL, record_source(daemon->addn_hosts, crecp->uid));
|
log_query(crecp->flags, name, NULL, record_source(crecp->uid));
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
crec_ttl(crecp, now), &nameoffset,
|
crec_ttl(crecp, now), &nameoffset,
|
||||||
T_CNAME, C_IN, "d", cache_get_name(crecp->addr.cname.cache)))
|
T_CNAME, C_IN, "d", cache_get_name(crecp->addr.cname.cache)))
|
||||||
@@ -1436,7 +1436,7 @@ size_t answer_request(HEADER *header, char *limit, size_t qlen,
|
|||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
log_query(crecp->flags & ~F_REVERSE, name, &crecp->addr.addr,
|
log_query(crecp->flags & ~F_REVERSE, name, &crecp->addr.addr,
|
||||||
record_source(daemon->addn_hosts, crecp->uid));
|
record_source(crecp->uid));
|
||||||
|
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
crec_ttl(crecp, now), NULL, type, C_IN,
|
crec_ttl(crecp, now), NULL, type, C_IN,
|
||||||
|
|||||||
+529
-198
File diff suppressed because it is too large.
Load diff
+23
-27
@@ -45,9 +45,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
char *filename, *mode, *p, *end, *opt;
|
char *filename, *mode, *p, *end, *opt;
|
||||||
struct sockaddr_in addr, peer;
|
struct sockaddr_in addr, peer;
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct cmsghdr *cmptr;
|
|
||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
struct ifreq ifr;
|
|
||||||
int is_err = 1, if_index = 0;
|
int is_err = 1, if_index = 0;
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
struct tftp_transfer *transfer;
|
struct tftp_transfer *transfer;
|
||||||
@@ -62,7 +60,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
char control[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
||||||
#elif defined(HAVE_SOLARIS_NETWORK)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
char control[CMSG_SPACE(sizeof(unsigned int))];
|
char control[CMSG_SPACE(sizeof(unsigned int))];
|
||||||
#else
|
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
||||||
char control[CMSG_SPACE(sizeof(struct sockaddr_dl))];
|
char control[CMSG_SPACE(sizeof(struct sockaddr_dl))];
|
||||||
#endif
|
#endif
|
||||||
} control_u;
|
} control_u;
|
||||||
@@ -88,6 +86,9 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
addr = listen->iface->addr.in;
|
addr = listen->iface->addr.in;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
char name[IF_NAMESIZE];
|
||||||
|
struct cmsghdr *cmptr;
|
||||||
|
|
||||||
addr.sin_addr.s_addr = 0;
|
addr.sin_addr.s_addr = 0;
|
||||||
|
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
@@ -97,36 +98,32 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
addr.sin_addr = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_spec_dst;
|
addr.sin_addr = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_spec_dst;
|
||||||
if_index = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_ifindex;
|
if_index = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_ifindex;
|
||||||
}
|
}
|
||||||
if (!(ifr.ifr_ifindex = if_index) ||
|
|
||||||
ioctl(listen->tftpfd, SIOCGIFNAME, &ifr) == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
||||||
|
addr.sin_addr = *((struct in_addr *)CMSG_DATA(cmptr));
|
||||||
|
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
|
if_index = *((unsigned int *)CMSG_DATA(cmptr));
|
||||||
|
|
||||||
|
|
||||||
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
#elif defined(IP_RECVDSTADDR) && defined(IP_RECVIF)
|
||||||
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 == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVDSTADDR)
|
||||||
addr.sin_addr = *((struct in_addr *)CMSG_DATA(cmptr));
|
addr.sin_addr = *((struct in_addr *)CMSG_DATA(cmptr));
|
||||||
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
else if (cmptr->cmsg_level == IPPROTO_IP && cmptr->cmsg_type == IP_RECVIF)
|
||||||
#ifdef HAVE_SOLARIS_NETWORK
|
if_index = ((struct sockaddr_dl *)CMSG_DATA(cmptr))->sdl_index;
|
||||||
if_index = *((unsigned int *)CMSG_DATA(cmptr));
|
|
||||||
#else
|
|
||||||
if_index = ((struct sockaddr_dl *)CMSG_DATA(cmptr))->sdl_index;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (if_index == 0 || !if_indextoname(if_index, ifr.ifr_name))
|
if (!indextoname(listen->tftpfd, if_index, name) ||
|
||||||
return;
|
addr.sin_addr.s_addr == 0 ||
|
||||||
|
!iface_check(AF_INET, (struct all_addr *)&addr.sin_addr, name, &if_index))
|
||||||
#endif
|
|
||||||
|
|
||||||
if (addr.sin_addr.s_addr == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!iface_check(AF_INET, (struct all_addr *)&addr.sin_addr,
|
|
||||||
&ifr, &if_index))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* allowed interfaces are the same as for DHCP */
|
/* allowed interfaces are the same as for DHCP */
|
||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
if (tmp->name && (strcmp(tmp->name, name) == 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -172,7 +169,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
addr.sin_port = htons(port);
|
addr.sin_port = htons(port);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
my_syslog(LOG_ERR, _("unable to get free port for TFTP"));
|
my_syslog(MS_TFTP | LOG_ERR, _("unable to get free port for TFTP"));
|
||||||
}
|
}
|
||||||
free_transfer(transfer);
|
free_transfer(transfer);
|
||||||
return;
|
return;
|
||||||
@@ -268,7 +265,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
free_transfer(transfer);
|
free_transfer(transfer);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
my_syslog(LOG_INFO, _("TFTP sent %s to %s"), daemon->namebuff, inet_ntoa(peer.sin_addr));
|
my_syslog(MS_TFTP | LOG_INFO, _("TFTP 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;
|
||||||
}
|
}
|
||||||
@@ -402,7 +399,7 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
*(q++) = *r;
|
*(q++) = *r;
|
||||||
*q = 0;
|
*q = 0;
|
||||||
}
|
}
|
||||||
my_syslog(LOG_ERR, _("TFTP error %d %s received from %s"),
|
my_syslog(MS_TFTP | LOG_ERR, _("TFTP 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));
|
||||||
|
|
||||||
@@ -433,7 +430,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(LOG_ERR, _("TFTP failed sending %s to %s"),
|
my_syslog(MS_TFTP | LOG_ERR, _("TFTP 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;
|
||||||
}
|
}
|
||||||
@@ -492,8 +489,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, "TFTP %s", mess->message);
|
||||||
my_syslog(LOG_ERR, "TFTP %s", mess->message);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-7
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* The SURF random number generator was taken from djbdns-1.05, by
|
/* The SURF random number generator was taken from djbdns-1.05, by
|
||||||
Daniel J Berstein, which is public domain. */
|
Daniel J Bernstein, which is public domain. */
|
||||||
|
|
||||||
|
|
||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
@@ -344,14 +344,19 @@ int parse_hex(char *in, unsigned char *out, int maxlen,
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* return 0 for no match, or (no matched octets) + 1 */
|
||||||
int memcmp_masked(unsigned char *a, unsigned char *b, int len, unsigned int mask)
|
int memcmp_masked(unsigned char *a, unsigned char *b, int len, unsigned int mask)
|
||||||
{
|
{
|
||||||
int i;
|
int i, count;
|
||||||
for (i = len - 1; i >= 0; i--, mask = mask >> 1)
|
for (count = 1, i = len - 1; i >= 0; i--, mask = mask >> 1)
|
||||||
if (!(mask & 1) && a[i] != b[i])
|
if (!(mask & 1))
|
||||||
return 0;
|
{
|
||||||
|
if (a[i] == b[i])
|
||||||
return 1;
|
count++;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _note_ may copy buffer */
|
/* _note_ may copy buffer */
|
||||||
|
|||||||
Reference in new issue
Block a user