Commit b8187c80 authored by Simon Kelley's avatar Simon Kelley

import of dnsmasq-2.24.tar.gz

parent 3d8df260
......@@ -1544,3 +1544,69 @@ version 2.23
Added --bootp-dynamic option and associated
functionality. Thanks to Josef Wolf for the suggestion.
version 2.24
Updated contrib/openvpn/dnsmasq.patch from Joseph Tate.
Tweaked DHCP NAK code, a DHCP NAK is now unicast as a
fallback in cases where a broadcast is futile: namely in
response to a unicast REQUEST from a non-local network
which was not sent via a relay.
Slightly changed the semantics of domain matching in
--server and --address configs. --server=/domain.com/ still
matches domain.com and sub.domain.com but does not
now match newdomain.com The semantics of
--server=/.domain.com/ are unchanged.
Thanks to Chris Blaise for the patch.
Added backwards-compatible internationalisation support.
The existing make targets, (all, dnsmasq, install) work as
before. New ones (all-i18n, and install-i18n) add gettext.
The translations live in po/ There are not too many
strings, so if anybody can provide translations (and for
the manpage....) please send them in.
Tweak behaviour on receipt of REFUSED or SERVFAIL rcodes,
now the query gets retried on all servers before returning
the error to the source of the query. Thanks to Javier
Kohen for the report.
Added Polish translation - thanks to Tomasz Sochanski.
Changed default manpage install location from /usr/man
to /usr/share/man
Added Spanish translation - thanks to Christopher Chatham.
Log a warning when a DHCP packet is truncated due to lack
of space. (Thanks to Michael Welle for the prompt to do
this.)
Added French translation - thanks to Lionel Tricon.
Added Indonesian translation - thanks to Salman AS.
Tweaked the netlink code to cope with interface broadcast
address not set, or set to 0.0.0.0.
Fixed problem assigning fixed addresses to hosts when more
than one dhcp-range is available. Thanks to Sorin Panca
for help chasing this down.
Added more explict error mesages to the hosts file and
ethers file reading code. Markus Kaiserswerth suffered to
make this happen.
Ensure that a hostname supplied by a DHCP client can never
override one configured on the server. Previously, any
host claiming a name would be given it, even if that
over-rode a dhcp-host declaration, leading to potentially
confusing situations.
Added Slackware package-build stuff into contrib/ The i18n
effort broke the current scripts, and working ones were
needed for testing, so they ended up here rather than make
Pat re-invent the wheel.
Added Romanian translation, thanks to Sorin Panca for
that.
PREFIX?=/usr/local
BINDIR = ${PREFIX}/sbin
MANDIR = ${PREFIX}/man
MANDIR = ${PREFIX}/share/man
LOCALEDIR = ${PREFIX}/share/locale
SRC = src
PO = po
MAN = man
CFLAGS?= -O2
all :
$(MAKE) -f ../bld/Makefile -C $(SRC) dnsmasq
$(MAKE) I18N=-DNO_GETTEXT -f ../bld/Makefile -C $(SRC) dnsmasq
clean :
rm -f *~ bld/*~ contrib/*/*~ */*~ $(SRC)/*.o $(SRC)/dnsmasq core build
rm -f *~ $(SRC)/*.mo contrib/*/*~ */*~ $(SRC)/*.pot
rm -f $(SRC)/*.o $(SRC)/dnsmasq core */core
install : all
install : all install-common
install-common :
install -d $(DESTDIR)$(BINDIR) -d $(DESTDIR)$(MANDIR)/man8
install -m 644 dnsmasq.8 $(DESTDIR)$(MANDIR)/man8
install -m 644 $(MAN)/dnsmasq.8 $(DESTDIR)$(MANDIR)/man8
install -m 755 $(SRC)/dnsmasq $(DESTDIR)$(BINDIR)
all-i18n :
$(MAKE) I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' -f ../bld/Makefile -C $(SRC) dnsmasq
cd $(PO); for f in *.po; do \
$(MAKE) -f ../bld/Makefile -C ../$(SRC) $${f/.po/.mo}; \
done
install-i18n : all-i18n install-common
cd $(SRC); ../bld/install-mo $(DESTDIR)$(LOCALEDIR)
cd $(MAN); ../bld/install-man $(DESTDIR)$(MANDIR)
merge :
$(MAKE) I18N=-DLOCALEDIR='\"$(LOCALEDIR)\"' -f ../bld/Makefile -C $(SRC) dnsmasq.pot
cd $(PO); for f in *.po; do \
msgmerge -U $$f ../$(SRC)/dnsmasq.pot; \
done
......@@ -4,14 +4,18 @@
CFLAGS ?= -O2
PKG_CONFIG ?= pkg-config
OBJS = cache.o rfc1035.o util.o option.o forward.o isc.o network.o \
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o
.c.o: dnsmasq.h config.h
$(CC) $(CFLAGS) `../bld/pkg-wrapper $(PKG_CONFIG) --cflags dbus-1` $(RPM_OPT_FLAGS) -Wall -W -c $*.c
.c.o:
$(CC) $(CFLAGS) $(I18N) `../bld/pkg-wrapper $(PKG_CONFIG) --cflags dbus-1` $(RPM_OPT_FLAGS) -Wall -W -c $<
dnsmasq : $(OBJS) dnsmasq.h config.h
dnsmasq : $(OBJS)
$(CC) -o $@ $(OBJS) `../bld/pkg-wrapper $(PKG_CONFIG) --libs dbus-1` $(LIBS)
dnsmasq.pot : $(OBJS:.o=.c) dnsmasq.h config.h
xgettext -d dnsmasq --foreign-user --keyword=_ -o dnsmasq.pot -i $(OBJS:.o=.c)
%.mo : ../po/%.po dnsmasq.pot
msgmerge -o - ../po/$*.po dnsmasq.pot | msgfmt -o $*.mo -
#!/bin/sh
for f in *; do
if [ -d $f ]; then
install -d $1/$f/man8
install -m 644 $f/dnsmasq.8 $1/$f/man8
echo installing $1/$f/man8/dnsmasq.8
fi
done
#!/bin/sh
for f in *.mo; do
install -d $1/${f/.mo/}/LC_MESSAGES
install -m 644 $f $1/${f/.mo/}/LC_MESSAGES/dnsmasq.mo
echo installing $1/${f/.mo/}/LC_MESSAGES/dnsmasq.mo
done
......@@ -18,7 +18,7 @@
+ . /etc/dhclient-enter-hooks
+ cp /etc/resolv.conf /etc/resolv.conf.dnsmasq
+ cp /etc/dhclient-enter-hooks /etc/dhclient-enter-hooks.dnsmasq
+ sed -e 's/resolv\.conf$/resolv.conf.dhclient/' /etc/dhclient-enter-hooks.dnsmasq > /etc/dhclient-enter-hooks
+ sed -e 's/resolv\.conf$/resolv.conf.dnsmasq/' /etc/dhclient-enter-hooks.dnsmasq > /etc/dhclient-enter-hooks
+ sed -e 's/\(nameserver[ tab]\+\)[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$/\1127.0.0.1/' /etc/resolv.conf.dnsmasq > /etc/resolv.conf
+ fi
+}
......
#!/bin/sh
CWD=`pwd`
PKG=/tmp/package-dnsmasq
VERSION=2.24
ARCH=${ARCH:-i486}
BUILD=${BUILD:-1}
if [ "$ARCH" = "i386" ]; then
SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
elif [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
elif [ "$ARCH" = "s390" ]; then
SLKCFLAGS="-O2"
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2"
fi
rm -rf $PKG
mkdir -p $PKG
cd /tmp
rm -rf dnsmasq-$VERSION
tar xzvf $CWD/dnsmasq-$VERSION.tar.gz
cd dnsmasq-$VERSION
zcat $CWD/dnsmasq.leasedir.diff.gz | patch -p1 --verbose --backup --suffix=.orig || exit
chown -R root.root .
make install-i18n PREFIX=/usr DESTDIR=$PKG MANDIR=/usr/man
chmod 755 $PKG/usr/sbin/dnsmasq
chown -R root.bin $PKG/usr/sbin
gzip -9 $PKG/usr/man/man8/dnsmasq.8
for f in $PKG/usr/share/man/*; do
if [ -f $$f/man8/dnsmasq.8 ]; then
gzip -9 $$f/man8/dnsmasq.8 ;
fi
done
gzip -9 $PKG/usr/man/*/man8/dnsmasq.8
mkdir -p $PKG/var/state/dnsmasq
( cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
mkdir $PKG/etc
cat dnsmasq.conf.example > $PKG/etc/dnsmasq.conf.new
mkdir $PKG/etc/rc.d
zcat $CWD/rc.dnsmasq.gz > $PKG/etc/rc.d/rc.dnsmasq.new
mkdir -p $PKG/usr/doc/dnsmasq-$VERSION
cp -a \
CHANGELOG COPYING FAQ UPGRADING_to_2.0 doc.html setup.html \
$PKG/usr/doc/dnsmasq-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
cd $PKG
makepkg -l y -c n ../dnsmasq-$VERSION-$ARCH-$BUILD.tgz
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description. Line
# up the first '|' above the ':' following the base package name, and the '|' on
# the right side marks the last column you can put a character in. You must make
# exactly 11 lines for the formatting to be correct. It's also customary to
# leave one space after the ':'.
|-----handy-ruler------------------------------------------------------|
dnsmasq: dnsmasq (small DNS and DHCP server)
dnsmasq:
dnsmasq: Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP
dnsmasq: server. It is designed to provide DNS (and optionally DHCP) to a
dnsmasq: small network, and can serve the names of local machines which are not
dnsmasq: in the global DNS.
dnsmasq:
dnsmasq: Dnsmasq was written by Simon Kelley.
dnsmasq:
dnsmasq:
dnsmasq:
......@@ -5,7 +5,7 @@
###############################################################################
Name: dnsmasq
Version: 2.23
Version: 2.24
Release: 1
Copyright: GPL
Group: System Environment/Daemons
......@@ -38,7 +38,7 @@ leases and BOOTP for network booting of diskless machines.
%prep
%setup -q
%build
make
make all-i18n PREFIX=/usr
###############################################################################
......@@ -55,9 +55,9 @@ mkdir -p -m 755 $RPM_BUILD_ROOT/etc/rc.d/init.d
mkdir -p -m 755 $RPM_BUILD_ROOT/usr/share/man/man8
cp rpm/dnsmasq.rh $RPM_BUILD_ROOT/etc/rc.d/init.d/dnsmasq
strip src/dnsmasq
make install-i18n DESTDIR=$RPM_BUILD_ROOT PREFIX=/usr
strip $RPM_BUILD_ROOT/usr/sbin/dnsmasq
cp src/dnsmasq $RPM_BUILD_ROOT/usr/sbin
cp dnsmasq.8 $RPM_BUILD_ROOT/usr/share/man/man8
cp dnsmasq.conf.example $RPM_BUILD_ROOT/etc/dnsmasq.conf
###############################################################################
......@@ -127,6 +127,7 @@ fi
%attr(0755,root,root) /etc/rc.d/init.d/dnsmasq
%attr(0664,root,root) /etc/dnsmasq.conf
%attr(0755,root,root) /usr/sbin/dnsmasq
%attr(0644,root,root) /usr/share/man/*/man8/dnsmasq*
%attr(0644,root,root) /usr/share/man/man8/dnsmasq*
%attr(0644,root,root) /usr/share/locale/*/LC_MESSAGES/*
......@@ -5,7 +5,7 @@
###############################################################################
Name: dnsmasq
Version: 2.23
Version: 2.24
Release: 1
Copyright: GPL
Group: Productivity/Networking/DNS/Servers
......@@ -43,7 +43,7 @@ patch -p0 <rpm/%{name}-SuSE.patch
%build
%{?suse_update_config:%{suse_update_config -f}}
make
make all-i18n DESTDIR=$RPM_BUILD_ROOT PREFIX=/usr
###############################################################################
#
......@@ -54,15 +54,11 @@ make
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d
mkdir -p ${RPM_BUILD_ROOT}/usr/sbin
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man8
make install-i18n DESTDIR=$RPM_BUILD_ROOT PREFIX=/usr
install -o root -g root -m 755 rpm/rc.dnsmasq-suse $RPM_BUILD_ROOT/etc/init.d/dnsmasq
install -o root -g root -m 644 dnsmasq.conf.example $RPM_BUILD_ROOT/etc/dnsmasq.conf
strip src/dnsmasq
install -o root -g root -m 755 src/dnsmasq $RPM_BUILD_ROOT/usr/sbin
strip $RPM_BUILD_ROOT/usr/sbin/dnsmasq
ln -sf ../../etc/init.d/dnsmasq $RPM_BUILD_ROOT/usr/sbin/rcdnsmasq
gzip -9 dnsmasq.8
install -o root -g root -m 644 dnsmasq.8.gz $RPM_BUILD_ROOT%{_mandir}/man8
###############################################################################
#
......
......@@ -36,7 +36,7 @@ bogus-priv
#strict-order
# If you don't want dnsmasq to read /etc/resolv.conf or any other
# file, getting its servers for this file instead (see below), then
# file, getting its servers from this file instead (see below), then
# uncomment this
#no-resolv
......@@ -365,8 +365,3 @@ bogus-priv
# Include a another lot of configuration options.
#conf-file=/etc/dnsmasq.more.conf
......@@ -65,7 +65,7 @@ Specify an alternate path for dnsmasq to record its process-id in. Normally /var
.TP
.B \-u, --user=<username>
Specify the userid to which dnsmasq will change after startup. Dnsmasq must normally be started as root, but it will drop root
priviledges after startup by changing id to another user. Normally this user is "nobody" but that
privileges after startup by changing id to another user. Normally this user is "nobody" but that
can be over-ridden with this switch.
.TP
.B \-g, --group=<groupname>
......@@ -155,7 +155,7 @@ dnsmasq which provide DHCP service to run in the same machine.
.TP
.B \-y, --localise-queries
Return answers to DNS queries from /etc/hosts which depend on the interface over which the query was
recieved. If a name in /etc/hosts has more than one address associated with
received. If a name in /etc/hosts has more than one address associated with
it, and at least one of those addresses is on the same subnet as the
interface to which the query was sent, then return only the
address(es) on that subnet. This allows for a server to have multiple
......@@ -179,11 +179,11 @@ Cisco PIX routers call "DNS doctoring".
.B \-B, --bogus-nxdomain=<ipaddr>
Transform replies which contain the IP address given into "No such
domain" replies. This is intended to counteract a devious move made by
Versign in September 2003 when they started returning the address of
Verisign in September 2003 when they started returning the address of
an advertising web page in response to queries for unregistered names,
instead of the correct NXDOMAIN response. This option tells dnsmasq to
fake the correct response when it sees this behaviour. As at Sept 2003
the IP address being returnd by Verisign is 64.94.110.11
the IP address being returned by Verisign is 64.94.110.11
.TP
.B \-f, --filterwin2k
Later versions of windows make periodic DNS requests which don't get sensible answers from
......@@ -208,7 +208,7 @@ line or the dnsmasq configuration file.
.B \-1, --enable-dbus
Allow dnsmasq configuration to be updated via DBus method calls. The
configuration which can be changed is upstream DNS servers (and
corressponding domains) and cache clear. Requires that dnsmasq has
corresponding domains) and cache clear. Requires that dnsmasq has
been built with DBus support.
.TP
.B \-o, --strict-order
......@@ -234,7 +234,7 @@ and they are queried only using the specified server. This is
intended for private nameservers: if you have a nameserver on your
network which deals with names of the form
xxx.internal.thekelleys.org.uk at 192.168.1.1 then giving the flag
.B -S /.internal.thekelleys.org.uk/192.168.1.1
.B -S /internal.thekelleys.org.uk/192.168.1.1
will send all queries for
internal machines to that nameserver, everything else will go to the
servers in /etc/resolv.conf. An empty domain specification,
......@@ -333,13 +333,13 @@ Enable the DHCP server. Addresses will be given out from the range
in
.B dhcp-host
options. If the lease time is given, then leases
will be given for that length of time. The lease time is on 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". This
option may be repeated, with different addresses, to enable DHCP
service to more than one network. For directly connected networks (ie,
networks on which the machine running dnsmasq has an interface) the
netmask is optional. It is, however, required for networks which
recieve 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
one interface when using DHCP, and the name of that interface must be
given using the
......@@ -414,14 +414,14 @@ have exactly the same effect as
options containing the same information.
.TP
.B \-O, --dhcp-option=[<network-id>,[<network-id>,]][vendor:<vendor-class>]<opt>,[<value>[,<value>]]
Specfify different or extra options to DHCP clients. By default,
Specify different or extra options to DHCP clients. By default,
dnsmasq sends some standard options to DHCP clients, the netmask and
broadcast address are set to the same as the host running dnsmasq, and
the DNS server and default route are set to the address of the machine
running dnsmasq. If the domain name option has been set, that is sent.
This option allows these defaults to be overridden,
or other options specified. The <opt> is the number of the option, as
specfied in RFC2132. For example, to set the default route option to
specified in RFC2132. For example, to set the default route option to
192.168.4.4, do
.B --dhcp-option=3,192.168.4.4
and to set the time-server address to 192.168.0.4, do
......@@ -437,7 +437,7 @@ option number is sent, it is quite possible to
persuade dnsmasq to generate illegal DHCP packets with injudicious use
of this flag. When the value is a decimal number, dnsmasq must determine how
large the data item is. It does this by examining the option number and/or the
value, but can be overriden by appending a single letter flag as follows:
value, but can be overridden by appending a single letter flag as follows:
b = one byte, s = two bytes, i = four bytes. This is mainly useful with
encapsulated vendor class options (see below) where dnsmasq cannot
determine data size from the option number. Option data which
......@@ -495,7 +495,7 @@ create thousands of leases and use lots of memory in the dnsmasq
process.
.TP
.B \-K, --dhcp-authoritative
Should be set when dnsmasq is definatively the only DHCP server on a network.
Should be set when dnsmasq is definately the only DHCP server on a network.
It changes the behaviour from strict RFC compliance so that DHCP requests on
unknown leases from unknown hosts are not ignored. This allows new hosts
to get a lease without a tedious timeout under all circumstances.
......@@ -529,20 +529,24 @@ in /etc/resolv.conf (or equivalent).
.B \-E, --expand-hosts
Add the domain to simple names (without a period) in /etc/hosts
in the same way as for DHCP-derived names.
.TP
.B \-C, --conf-file=<file>
Specify a different configuration file. The conf-file option is also allowed in
configuration files, to include multiple configuration files. Only one
level of nesting is allowed.
.SH CONFIG FILE
At startup, dnsmasq reads
.I /etc/dnsmasq.conf,
if it exists. (On
FreeBSD, the file is
.I /usr/local/etc/dnsmasq.conf
) The format of this
) (but see the
.B \-C
option.) The format of this
file consists of one option per line, exactly as the long options detailed
in the OPTIONS section but without the leading "--". Lines starting with # are comments and ignored. For
options which may only be specified once, the configuration file overrides
the command line. Use the --conf-file (or -C) option to specify a different
configuration file. The conf-file option is also allowed in
configuration files, to include multiple configuration files. Only one
level of nesting is allowed. Quoting is allowed in a config file:
the command line. Quoting is allowed in a config file:
between " quotes the special meanings of ,:. and # are removed and the
following escapes are allowed: \\\\ \\" \\t \\a \\b \\r and \\n. The later
corresponding to tab, bell, backspace, return and newline.
......@@ -663,7 +667,8 @@ configurations or in
, and a
.B dhcp-range
configuration option is present to activate the DHCP server
on a particular network. The filename
on a particular network. (Setting --bootp-dynamic removes the need for
static address mappings.) The filename
parameter in a BOOTP request is matched against netids in
.B dhcp-option
configurations, allowing some control over the options returned to
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -562,7 +562,7 @@ static void read_hostsfile(char *filename, int opts, char *buff, char *domain_su
if (!f)
{
syslog(LOG_ERR, "failed to load names from %s: %m", filename);
syslog(LOG_ERR, _("failed to load names from %s: %m"), filename);
return;
}
......@@ -597,7 +597,10 @@ static void read_hostsfile(char *filename, int opts, char *buff, char *domain_su
}
#endif
else
{
syslog(LOG_ERR, _("bad address at %s line %d"), filename, lineno);
continue;
}
while ((token = strtok(NULL, " \t\n\r")) && (*token != '#'))
{
......@@ -622,13 +625,13 @@ static void read_hostsfile(char *filename, int opts, char *buff, char *domain_su
}
}
else
syslog(LOG_ERR, "bad name at %s line %d", filename, lineno);
syslog(LOG_ERR, _("bad name at %s line %d"), filename, lineno);
}
}
fclose(f);
syslog(LOG_INFO, "read %s - %d addresses", filename, count);
syslog(LOG_INFO, _("read %s - %d addresses"), filename, count);
}
void cache_reload(int opts, char *buff, char *domain_suffix, struct hostsfile *addn_hosts)
......@@ -664,7 +667,7 @@ void cache_reload(int opts, char *buff, char *domain_suffix, struct hostsfile *a
if ((opts & OPT_NO_HOSTS) && !addn_hosts)
{
if (cache_size > 0)
syslog(LOG_INFO, "cleared cache");
syslog(LOG_INFO, _("cleared cache"));
return;
}
......@@ -717,8 +720,8 @@ void cache_add_dhcp_entry(struct daemon *daemon, char *host_name,
{
strcpy(daemon->namebuff, inet_ntoa(crec->addr.addr.addr.addr4));
syslog(LOG_WARNING,
"not giving name %s to the DHCP lease of %s because "
"the name exists in %s with address %s",
_("not giving name %s to the DHCP lease of %s because "
"the name exists in %s with address %s"),
host_name, inet_ntoa(*host_address),
record_source(daemon->addn_hosts, crec->uid), daemon->namebuff);
}
......@@ -761,7 +764,7 @@ void cache_add_dhcp_entry(struct daemon *daemon, char *host_name,
void dump_cache(struct daemon *daemon)
{
syslog(LOG_INFO, "cache size %d, %d/%d cache insertions re-used unexpired cache entries.",
syslog(LOG_INFO, _("cache size %d, %d/%d cache insertions re-used unexpired cache entries."),
daemon->cachesize, cache_live_freed, cache_inserted);
if (daemon->options & (OPT_DEBUG | OPT_LOG))
......
......@@ -12,7 +12,7 @@
/* Author's email: simon@thekelleys.org.uk */
#define VERSION "2.23"
#define VERSION "2.24"
#define FTABSIZ 150 /* max number of outstanding requests */
#define MAX_PROCS 20 /* max no children for TCP requests */
......
......@@ -109,7 +109,7 @@ static void dbus_read_servers(struct daemon *daemon, DBusMessage *message)
}
#ifndef HAVE_IPV6
syslog(LOG_WARNING, "attempt to set an IPv6 server address via DBus - no IPv6 support");
syslog(LOG_WARNING, _("attempt to set an IPv6 server address via DBus - no IPv6 support"));
#else
if (i == sizeof(struct in6_addr)-1)
{
......@@ -234,7 +234,7 @@ DBusHandlerResult message_handler (DBusConnection *connection,
}
else if (strcmp(method, "SetServers") == 0)
{
syslog(LOG_INFO, "setting upstream servers from DBus");
syslog(LOG_INFO, _("setting upstream servers from DBus"));
dbus_read_servers(daemon, message);
check_servers(daemon);
}
......@@ -270,7 +270,7 @@ char *dbus_init(struct daemon *daemon)
if (!dbus_connection_register_object_path(connection, DNSMASQ_PATH,
&dnsmasq_vtable, daemon))
return "could not register a DBus message handler";
return _("could not register a DBus message handler");
daemon->dbus = connection;
......
......@@ -22,7 +22,7 @@ void dhcp_init(struct daemon *daemon)
struct dhcp_config *configs, *cp;
if (fd == -1)
die ("cannot create DHCP socket : %s", NULL);
die (_("cannot create DHCP socket : %s"), NULL);
if ((flags = fcntl(fd, F_GETFL, 0)) == -1 ||
fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1 ||
......@@ -32,14 +32,14 @@ void dhcp_init(struct daemon *daemon)
setsockopt(fd, IPPROTO_IP, IP_RECVIF, &oneopt, sizeof(oneopt)) == -1 ||
#endif
setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &oneopt, sizeof(oneopt)) == -1)
die("failed to set options on DHCP socket: %s", NULL);
die(_("failed to set options on DHCP socket: %s"), NULL);
/* When bind-interfaces is set, there might be more than one dnmsasq
instance binding port 67. That's Ok if they serve different networks.
Need to set REUSEADDR to make this posible. */
if ((daemon->options & OPT_NOWILD) &&
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt)) == -1)
die("failed to set SO_REUSEADDR on DHCP socket: %s", NULL);
die(_("failed to set SO_REUSEADDR on DHCP socket: %s"), NULL);
saddr.sin_family = AF_INET;
saddr.sin_port = htons(DHCP_SERVER_PORT);
......@@ -49,7 +49,7 @@ void dhcp_init(struct daemon *daemon)
#endif
if (bind(fd, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in)))
die("failed to bind DHCP server socket: %s", NULL);
die(_("failed to bind DHCP server socket: %s"), NULL);
daemon->dhcpfd = fd;
......@@ -58,7 +58,7 @@ void dhcp_init(struct daemon *daemon)
fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1 ||
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &oneopt, sizeof(oneopt)) == -1 ||
setsockopt(fd, SOL_SOCKET, SO_DONTROUTE, &zeroopt, sizeof(zeroopt)) == -1)
die("cannot create ICMP raw socket: %s.", NULL);
die(_("cannot create ICMP raw socket: %s."), NULL);
daemon->dhcp_icmp_fd = fd;
......@@ -72,7 +72,7 @@ void dhcp_init(struct daemon *daemon)
if ((fd = open(filename, O_RDWR, 0)) != -1)
break;
if (errno != EBUSY)
die("cannot create DHCP BPF socket: %s", NULL);
die(_("cannot create DHCP BPF socket: %s"), NULL);
}
}
#else
......@@ -83,8 +83,8 @@ void dhcp_init(struct daemon *daemon)
rejected as non-sensical by some BSD kernels) */
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETHERTYPE_IP))) == -1 ||
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &oneopt, sizeof(oneopt)) == -1)
die("cannot create DHCP packet socket: %s. "
"Is CONFIG_PACKET enabled in your kernel?", NULL);
die(_("cannot create DHCP packet socket: %s. "
"Is CONFIG_PACKET enabled in your kernel?"), NULL);
#endif
daemon->dhcp_raw_fd = fd;
......@@ -95,7 +95,7 @@ void dhcp_init(struct daemon *daemon)
for (configs = daemon->dhcp_conf; configs; configs = configs->next)
for (cp = configs->next; cp; cp = cp->next)
if ((configs->flags & cp->flags & CONFIG_ADDR) && configs->addr.s_addr == cp->addr.s_addr)
die("duplicate IP address %s in dhcp-config directive.", inet_ntoa(cp->addr));
die(_("duplicate IP address %s in dhcp-config directive."), inet_ntoa(cp->addr));
daemon->dhcp_packet = safe_malloc(sizeof(struct udp_dhcp_packet));
/* These two each hold a DHCP option max size 255
......@@ -116,6 +116,7 @@ void dhcp_packet(struct daemon *daemon, time_t now)
struct iovec iov[2];
struct cmsghdr *cmptr;
int sz, newlen, iface_index = 0;
int unicast_dest = 0;
struct in_addr iface_addr;
#ifdef HAVE_BPF
unsigned char iface_hwaddr[ETHER_ADDR_LEN];
......@@ -151,7 +152,11 @@ void dhcp_packet(struct daemon *daemon, time_t now)
return;
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
if (cmptr->cmsg_level == SOL_IP && cmptr->cmsg_type == IP_PKTINFO)
{
iface_index = ((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_ifindex;
if (((struct in_pktinfo *)CMSG_DATA(cmptr))->ipi_addr.s_addr != INADDR_BROADCAST)
unicast_dest = 1;
}
if (!(ifr.ifr_ifindex = iface_index) ||
ioctl(daemon->dhcpfd, SIOCGIFNAME, &ifr) == -1)
......@@ -233,7 +238,7 @@ void dhcp_packet(struct daemon *daemon, time_t now)
}
lease_prune(NULL, now); /* lose any expired leases */
newlen = dhcp_reply(daemon, context, ifr.ifr_name, sz, now);
newlen = dhcp_reply(daemon, context, ifr.ifr_name, sz, now, unicast_dest);
lease_update_file(0, now);
lease_update_dns(daemon);
......@@ -376,7 +381,7 @@ struct dhcp_context *complete_context(struct daemon *daemon, struct in_addr loca
{
strcpy(daemon->dhcp_buff, inet_ntoa(context->start));
strcpy(daemon->dhcp_buff2, inet_ntoa(context->end));
syslog(LOG_WARNING, "DHCP range %s -- %s is not consistent with netmask %s",
syslog(LOG_WARNING, _("DHCP range %s -- %s is not consistent with netmask %s"),
daemon->dhcp_buff, daemon->dhcp_buff2, inet_ntoa(netmask));
}
context->netmask = netmask;
......@@ -596,10 +601,11 @@ int address_allocate(struct dhcp_context *context, struct daemon *daemon,
static int is_addr_in_context(struct dhcp_context *context, struct dhcp_config *config)
{
if (!context)
if (!context) /* called via find_config() from lease_update_from_configs() */
return 1;
if (!(config->flags & CONFIG_ADDR))
return 1;
for (; context; context = context->current)
if (is_same_net(config->addr, context->start, context->netmask))
return 1;
......@@ -675,18 +681,20 @@ void dhcp_read_ethers(struct daemon *daemon)
struct in_addr addr;
unsigned char hwaddr[ETHER_ADDR_LEN];
struct dhcp_config *config, *configs = daemon->dhcp_conf;
int count = 0;
int count = 0, lineno = 0;
addr.s_addr = 0; /* eliminate warning */
if (!f)
{
syslog(LOG_ERR, "failed to read " ETHERSFILE ":%m");
syslog(LOG_ERR, _("failed to read %s:%m"), ETHERSFILE);
return;
}
while (fgets(buff, MAXDNAME, f))
{
lineno++;
while (strlen(buff) > 0 && isspace(buff[strlen(buff)-1]))
buff[strlen(buff)-1] = 0;
......@@ -696,11 +704,11 @@ void dhcp_read_ethers(struct daemon *daemon)
for (ip = buff; *ip && !isspace(*ip); ip++);
for(; *ip && isspace(*ip); ip++)
*ip = 0;
if (!*ip)
continue;
if (parse_hex(buff, hwaddr, 6, NULL) != 6)
if (!*ip || parse_hex(buff, hwaddr, 6, NULL) != 6)
{
syslog(LOG_ERR, _("bad line at %s line %d"), ETHERSFILE, lineno);
continue;
}
/* check for name or dotted-quad */
for (cp = ip; *cp; cp++)
......@@ -710,7 +718,11 @@ void dhcp_read_ethers(struct daemon *daemon)
if (!*cp)
{
if ((addr.s_addr = inet_addr(ip)) == (in_addr_t)-1)
{
syslog(LOG_ERR, _("bad address at %s line %d"), ETHERSFILE, lineno);
continue;
}
flags = CONFIG_ADDR;
for (config = configs; config; config = config->next)
......@@ -720,7 +732,11 @@ void dhcp_read_ethers(struct daemon *daemon)
else
{
if (!canonicalise(ip))
{
syslog(LOG_ERR, _("bad name at %s line %d"), ETHERSFILE, lineno);
continue;
}
flags = CONFIG_NAME;
for (config = configs; config; config = config->next)
......@@ -768,7 +784,7 @@ void dhcp_read_ethers(struct daemon *daemon)
fclose(f);
syslog(LOG_INFO, "read " ETHERSFILE " - %d addresses", count);
syslog(LOG_INFO, _("read %s - %d addresses"), ETHERSFILE, count);
daemon->dhcp_conf = configs;
}
......@@ -791,7 +807,7 @@ void dhcp_update_configs(struct dhcp_config *configs)
(crec->flags & F_HOSTS))
{
if (config_find_by_address(configs, crec->addr.addr.addr.addr4))
syslog(LOG_WARNING, "duplicate IP address %s (%s) in dhcp-config directive",
syslog(LOG_WARNING, _("duplicate IP address %s (%s) in dhcp-config directive"),
inet_ntoa(crec->addr.addr.addr.addr4), config->hostname);
else
{
......@@ -827,7 +843,7 @@ char *strip_hostname(struct daemon *daemon, char *hostname)
{
if (!daemon->domain_suffix || !hostname_isequal(dot+1, daemon->domain_suffix))
{
syslog(LOG_WARNING, "Ignoring DHCP host name %s because it has an illegal domain part", hostname);
syslog(LOG_WARNING, _("Ignoring DHCP host name %s because it has an illegal domain part"), hostname);
hostname = NULL;
}
else
......
......@@ -33,7 +33,11 @@ static char *compile_opts =
#ifndef HAVE_DBUS
"no-"
#endif
"DBus";
"DBus "
#ifdef NO_GETTEXT
"no-"
#endif
"i18n";
static volatile int sigterm, sighup, sigusr1, sigalarm, num_kids, in_child;
......@@ -51,6 +55,12 @@ int main (int argc, char **argv)
sigset_t sigmask;
struct iname *if_tmp;
#ifndef NO_GETTEXT
setlocale(LC_ALL, "");
bindtextdomain("dnsmasq", LOCALEDIR);
textdomain("dnsmasq");
#endif
sighup = 1; /* init cache the first time through */
sigusr1 = 0; /* but don't dump */
sigterm = 0; /* or die */
......@@ -99,11 +109,11 @@ int main (int argc, char **argv)
}
#ifndef HAVE_ISC_READER
else if (!daemon->dhcp)
die("ISC dhcpd integration not available: set HAVE_ISC_READER in src/config.h", NULL);
die(_("ISC dhcpd integration not available: set HAVE_ISC_READER in src/config.h"), NULL);
#endif
if (!enumerate_interfaces(daemon, &daemon->interfaces, NULL, NULL))
die("failed to find list of interfaces: %s", NULL);
die(_("failed to find list of interfaces: %s"), NULL);
if (!(daemon->options & OPT_NOWILD) &&
!(daemon->listeners = create_wildcard_listeners(daemon->port)))
......@@ -118,13 +128,13 @@ int main (int argc, char **argv)
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
if (if_tmp->name && !if_tmp->used)
die("unknown interface %s", if_tmp->name);
die(_("unknown interface %s"), if_tmp->name);
for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next)
if (!if_tmp->used)
{
prettyprint_addr(&if_tmp->addr, daemon->namebuff);
die("no interface with address %s", daemon->namebuff);
die(_("no interface with address %s"), daemon->namebuff);
}
}
......@@ -133,7 +143,7 @@ int main (int argc, char **argv)
#ifdef HAVE_BROKEN_RTC
if ((daemon->uptime_fd = open(UPTIME, O_RDONLY)) == -1)
die("cannot open " UPTIME ":%s", NULL);
die(_("cannot open %s:%s"), UPTIME);
#endif
now = dnsmasq_time(daemon->uptime_fd);
......@@ -147,7 +157,7 @@ int main (int argc, char **argv)
if (!tmp->isloop)
c++;
if (c != 1)
die("must set exactly one interface on broken systems without IP_RECVIF", NULL);
die(_("must set exactly one interface on broken systems without IP_RECVIF"), NULL);
#endif
dhcp_init(daemon);
lease_init(daemon, now);
......@@ -160,11 +170,11 @@ int main (int argc, char **argv)
daemon->dbus = NULL;
daemon->watches = NULL;
if ((err = dbus_init(daemon)))
die("DBus error: %s", err);
die(_("DBus error: %s"), err);
}
#else
if (daemon->options & OPT_DBUS)
die("DBus not available: set HAVE_DBUS in src/config.h", NULL);
die(_("DBus not available: set HAVE_DBUS in src/config.h"), NULL);
#endif
/* If query_port is set then create a socket now, before dumping root
......@@ -277,29 +287,29 @@ int main (int argc, char **argv)
DNSMASQ_LOG_FAC(daemon->options & OPT_DEBUG));
if (daemon->cachesize != 0)
syslog(LOG_INFO, "started, version %s cachesize %d", VERSION, daemon->cachesize);
syslog(LOG_INFO, _("started, version %s cachesize %d"), VERSION, daemon->cachesize);
else
syslog(LOG_INFO, "started, version %s cache disabled", VERSION);
syslog(LOG_INFO, _("started, version %s cache disabled"), VERSION);
syslog(LOG_INFO, "compile time options: %s", compile_opts);
syslog(LOG_INFO, _("compile time options: %s"), compile_opts);
#ifdef HAVE_DBUS
if (daemon->options & OPT_DBUS)
{
if (daemon->dbus)
syslog(LOG_INFO, "DBus support enabled: connected to system bus");
syslog(LOG_INFO, _("DBus support enabled: connected to system bus"));
else
syslog(LOG_INFO, "DBus support enabled: bus connection pending");
syslog(LOG_INFO, _("DBus support enabled: bus connection pending"));
}
#endif
if (bind_fallback)
syslog(LOG_WARNING, "setting --bind-interfaces option because of OS limitations");
syslog(LOG_WARNING, _("setting --bind-interfaces option because of OS limitations"));
if (!(daemon->options & OPT_NOWILD))
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
if (if_tmp->name && !if_tmp->used)
syslog(LOG_WARNING, "warning: interface %s does not currently exist", if_tmp->name);
syslog(LOG_WARNING, _("warning: interface %s does not currently exist"), if_tmp->name);
if (daemon->dhcp)
{
......@@ -316,8 +326,8 @@ int main (int argc, char **argv)
strcpy(daemon->dhcp_buff, inet_ntoa(dhcp_tmp->start));
syslog(LOG_INFO,
(dhcp_tmp->flags & CONTEXT_STATIC) ?
"DHCP, static leases only on %.0s%s, lease time %s" :
"DHCP, IP range %s -- %s, lease time %s",
_("DHCP, static leases only on %.0s%s, lease time %s") :
_("DHCP, IP range %s -- %s, lease time %s"),
daemon->dhcp_buff, inet_ntoa(dhcp_tmp->end), daemon->dhcp_buff2);
}
......@@ -328,12 +338,12 @@ int main (int argc, char **argv)
if (daemon->min_leasetime < 60)
daemon->min_leasetime = 60;
prettyprint_time(daemon->dhcp_buff2, daemon->min_leasetime);
syslog(LOG_INFO, "DHCP, %s will be written every %s", daemon->lease_file, daemon->dhcp_buff2);
syslog(LOG_INFO, _("DHCP, %s will be written every %s"), daemon->lease_file, daemon->dhcp_buff2);
#endif
}
if (!(daemon->options & OPT_DEBUG) && (getuid() == 0 || geteuid() == 0))
syslog(LOG_WARNING, "running as root");
syslog(LOG_WARNING, _("running as root"));
check_servers(daemon);
......@@ -458,7 +468,7 @@ int main (int argc, char **argv)
if (stat(res->name, &statbuf) == -1)
{
if (!res->logged)
syslog(LOG_WARNING, "failed to access %s: %m", res->name);
syslog(LOG_WARNING, _("failed to access %s: %m"), res->name);
res->logged = 1;
}
else
......@@ -491,9 +501,9 @@ int main (int argc, char **argv)
{
char *err;
if ((err = dbus_init(daemon)))
syslog(LOG_WARNING, "DBus error: %s", err);
syslog(LOG_WARNING, _("DBus error: %s"), err);
if (daemon->dbus)
syslog(LOG_INFO, "connected to system DBus");
syslog(LOG_INFO, _("connected to system DBus"));
}
check_dbus_listeners(daemon, &rset, &wset, &eset);
#endif
......@@ -504,7 +514,7 @@ int main (int argc, char **argv)
dhcp_packet(daemon, now);
}
syslog(LOG_INFO, "exiting on receipt of SIGTERM");
syslog(LOG_INFO, _("exiting on receipt of SIGTERM"));
if (daemon->dhcp)
{
......@@ -551,7 +561,7 @@ void clear_cache_and_reload(struct daemon *daemon, time_t now)
if (daemon->options & OPT_ETHERS)
dhcp_read_ethers(daemon);
dhcp_update_configs(daemon->dhcp_conf);
lease_update_from_configs(daemon->dhcp_conf, daemon->domain_suffix);
lease_update_from_configs(daemon);
lease_update_file(0, now);
lease_update_dns(daemon);
}
......
......@@ -38,6 +38,15 @@
#include "config.h"
#define gettext_noop(S) (S)
#ifdef NO_GETTEXT
# define _(S) (S)
#else
# include <libintl.h>
# include <locale.h>
# define _(S) gettext(S)
#endif
#include <arpa/inet.h>
#include <sys/stat.h>
#include <sys/socket.h>
......@@ -288,6 +297,7 @@ struct dhcp_lease {
int clid_len; /* length of client identifier */
unsigned char *clid; /* clientid */
char *hostname, *fqdn; /* name from client-hostname option or config */
int auth_name; /* hostname came from config, not from client */
time_t expires; /* lease expiry */
unsigned char hwaddr[ETHER_ADDR_LEN];
struct in_addr addr;
......@@ -558,16 +568,17 @@ struct dhcp_lease *lease_allocate(unsigned char *hwaddr, unsigned char *clid,
int clid_len, struct in_addr addr);
int lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
unsigned char *clid, int clid_len);
void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix);
void lease_set_hostname(struct dhcp_lease *lease, char *name,
char *suffix, int auth);
void lease_set_expires(struct dhcp_lease *lease, time_t exp);
struct dhcp_lease *lease_find_by_client(unsigned char *hwaddr,
unsigned char *clid, int clid_len);
struct dhcp_lease *lease_find_by_addr(struct in_addr addr);
void lease_prune(struct dhcp_lease *target, time_t now);
void lease_update_from_configs(struct dhcp_config *dhcp_configs, char *domain);
void lease_update_from_configs(struct daemon *daemon);
/* rfc2131.c */
int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name, unsigned int sz, time_t now);
int dhcp_reply(struct daemon *daemon, struct dhcp_context *context, char *iface_name, unsigned int sz, time_t now, int unicast_dest);
/* dnsmasq.c */
int icmp_ping(struct daemon *daemon, struct in_addr addr);
......
......@@ -90,7 +90,7 @@ static void send_from(int fd, int nowild, char *packet, int len,
#endif
}
else
#ifdef HAVE_IPV
#ifdef HAVE_IPV6
{
struct in6_pktinfo *pkt = (struct in6_pktinfo *)CMSG_DATA(cmptr);
pkt->ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */
......@@ -160,9 +160,11 @@ static unsigned short search_servers(struct daemon *daemon, time_t now, struct a
else if (serv->flags & SERV_HAS_DOMAIN)
{
unsigned int domainlen = strlen(serv->domain);
char *matchstart = qdomain + namelen - domainlen;
if (namelen >= domainlen &&
hostname_isequal(qdomain + namelen - domainlen, serv->domain) &&
domainlen >= matchlen)
hostname_isequal(matchstart, serv->domain) &&
domainlen >= matchlen &&
(namelen == domainlen || *(serv->domain) == '.' || *(matchstart-1) == '.' ))
{
unsigned short sflag = serv->addr.sa.sa_family == AF_INET ? F_IPV4 : F_IPV6;
*type = SERV_HAS_DOMAIN;
......@@ -210,9 +212,8 @@ static unsigned short search_servers(struct daemon *daemon, time_t now, struct a
/* returns new last_server */
static void forward_query(struct daemon *daemon, int udpfd, union mysockaddr *udpaddr,
struct all_addr *dst_addr, unsigned int dst_iface,
HEADER *header, int plen, time_t now)
HEADER *header, int plen, time_t now, struct frec *forward)
{
struct frec *forward;
char *domain = NULL;
int type = 0;
struct all_addr *addrp = NULL;
......@@ -224,7 +225,7 @@ static void forward_query(struct daemon *daemon, int udpfd, union mysockaddr *ud
/* may be no servers available. */
if (!daemon->servers)
forward = NULL;
else if ((forward = lookup_frec_by_sender(ntohs(header->id), udpaddr, crc)))
else if (forward || (forward = lookup_frec_by_sender(ntohs(header->id), udpaddr, crc)))
{
/* retry on existing query, send to all available servers */
domain = forward->sentto->domain;
......@@ -337,8 +338,11 @@ static void forward_query(struct daemon *daemon, int udpfd, union mysockaddr *ud
}
/* could not send on, return empty answer or address if known for whole domain */
if (udpfd != -1)
{
plen = setup_reply(header, (unsigned int)plen, addrp, flags, daemon->local_ttl);
send_from(udpfd, daemon->options & OPT_NOWILD, (char *)header, plen, udpaddr, dst_addr, dst_iface);
}
return;
}
......@@ -371,7 +375,7 @@ static int process_reply(struct daemon *daemon, HEADER *header, time_t now,
server && !(server->flags & SERV_WARNED_RECURSIVE))
{
prettyprint_addr(&server->addr, daemon->namebuff);
syslog(LOG_WARNING, "nameserver %s refused to do a recursive query", daemon->namebuff);
syslog(LOG_WARNING, _("nameserver %s refused to do a recursive query"), daemon->namebuff);
if (!(daemon->options & OPT_LOG))
server->flags |= SERV_WARNED_RECURSIVE;
}
......@@ -445,14 +449,35 @@ void reply_query(struct serverfd *sfd, struct daemon *daemon, time_t now)
{
struct server *server = forward->sentto;
if ((header->rcode == SERVFAIL || header->rcode == REFUSED) && forward->forwardall == 0)
/* for broken servers, attempt to send to another one. */
{
unsigned char *pheader;
unsigned int plen;
int nn;
/* recreate query from reply */
pheader = find_pseudoheader(header, n, &plen, NULL);
header->ancount = htons(0);
header->nscount = htons(0);
header->arcount = htons(0);
if ((nn = resize_packet(header, n, pheader, plen)))
{
forward->forwardall = 1;
header->qr = 0;
header->tc = 0;
forward_query(daemon, -1, NULL, NULL, 0, header, nn, now, forward);
return;
}
}
if ((forward->sentto->flags & SERV_TYPE) == 0)
{
if (header->rcode == SERVFAIL || header->rcode == REFUSED)
server = NULL;
else
{
/* find good server by address if possible, otherwise assume the last one we sent to */
struct server *last_server;
/* find good server by address if possible, otherwise assume the last one we sent to */
for (last_server = daemon->servers; last_server; last_server = last_server->next)
if (!(last_server->flags & (SERV_LITERAL_ADDRESS | SERV_HAS_DOMAIN | SERV_FOR_NODOTS | SERV_NO_ADDR)) &&
sockaddr_isequal(&last_server->addr, &serveraddr))
......@@ -464,6 +489,13 @@ void reply_query(struct serverfd *sfd, struct daemon *daemon, time_t now)
daemon->last_server = server;
}
/* If the answer is an error, keep the forward record in place in case
we get a good reply from another server. Kill it when we've
had replies from all to avoid filling the forwarding table when
everything is broken */
if (forward->forwardall == 0 || --forward->forwardall == 1 ||
(header->rcode != REFUSED && header->rcode != SERVFAIL))
{
if ((n = process_reply(daemon, header, now, forward->crc, server, (unsigned int)n)))
{
header->id = htons(forward->orig_id);
......@@ -471,15 +503,9 @@ void reply_query(struct serverfd *sfd, struct daemon *daemon, time_t now)
send_from(forward->fd, daemon->options & OPT_NOWILD, daemon->packet, n,
&forward->source, &forward->dest, forward->iface);
}
/* If the answer is an error, keep the forward record in place in case
we get a good reply from another server. Kill it when we've
had replies from all to avoid filling the forwarding table when
everything is broken */
if (forward->forwardall == 0 || --forward->forwardall == 1 ||
(header->rcode != REFUSED && header->rcode != SERVFAIL))
forward->new_id = 0; /* cancel */
}
}
}
void receive_query(struct listener *listen, struct daemon *daemon, time_t now)
......@@ -650,7 +676,7 @@ void receive_query(struct listener *listen, struct daemon *daemon, time_t now)
send_from(listen->fd, daemon->options & OPT_NOWILD, (char *)header, m, &source_addr, &dst_addr, if_index);
else
forward_query(daemon, listen->fd, &source_addr, &dst_addr, if_index,
header, n, now);
header, n, now, NULL);
}
static int read_write(int fd, unsigned char *packet, int size, int rw)
......@@ -870,7 +896,7 @@ static struct frec *get_new_frec(time_t now)
if (!warntime || difftime(now, warntime) > LOGRATE)
{
warntime = now;
syslog(LOG_WARNING, "forwarding table overflow: check for server loops.");
syslog(LOG_WARNING, _("forwarding table overflow: check for server loops."));
}
return NULL;
}
......
......@@ -68,7 +68,7 @@ void load_dhcp(struct daemon *daemon, time_t now)
if (stat(daemon->lease_file, &statbuf) == -1)
{
if (!logged_lease)
syslog(LOG_WARNING, "failed to access %s: %m", daemon->lease_file);
syslog(LOG_WARNING, _("failed to access %s: %m"), daemon->lease_file);
logged_lease = 1;
return;
}
......@@ -84,11 +84,11 @@ void load_dhcp(struct daemon *daemon, time_t now)
if (!(fp = fopen (daemon->lease_file, "r")))
{
syslog (LOG_ERR, "failed to load %s: %m", daemon->lease_file);
syslog (LOG_ERR, _("failed to load %s: %m"), daemon->lease_file);
return;
}
syslog (LOG_INFO, "reading %s", daemon->lease_file);
syslog (LOG_INFO, _("reading %s"), daemon->lease_file);
while ((next_token(token, MAXTOK, fp)))
{
......@@ -110,7 +110,7 @@ void load_dhcp(struct daemon *daemon, time_t now)
if (!canonicalise(hostname))
{
*hostname = 0;
syslog(LOG_ERR, "bad name in %s", daemon->lease_file);
syslog(LOG_ERR, _("bad name in %s"), daemon->lease_file);
}
}
else if ((strcmp(token, "ends") == 0) ||
......@@ -172,7 +172,7 @@ void load_dhcp(struct daemon *daemon, time_t now)
if (!daemon->domain_suffix || hostname_isequal(dot+1, daemon->domain_suffix))
{
syslog(LOG_WARNING,
"Ignoring DHCP lease for %s because it has an illegal domain part",
_("Ignoring DHCP lease for %s because it has an illegal domain part"),
hostname);
continue;
}
......
......@@ -36,7 +36,7 @@ void lease_init(struct daemon *daemon, time_t now)
/* NOTE: need a+ mode to create file if it doesn't exist */
if (!(lease_file = fopen(daemon->lease_file, "a+")))
die("cannot open or create leases file: %s", NULL);
die(_("cannot open or create leases file: %s"), NULL);
/* a+ mode lease pointer at end. */
rewind(lease_file);
......@@ -74,12 +74,12 @@ void lease_init(struct daemon *daemon, time_t now)
clid_len = parse_hex(daemon->packet, (unsigned char *)daemon->packet, 255, NULL);
if (!(lease = lease_allocate(hwaddr, (unsigned char *)daemon->packet, clid_len, addr)))
die ("too many stored leases", NULL);
die (_("too many stored leases"), NULL);
lease->expires = expires;
if (strcmp(daemon->dhcp_buff, "*") != 0)
lease_set_hostname(lease, daemon->dhcp_buff, daemon->domain_suffix);
lease_set_hostname(lease, daemon->dhcp_buff, daemon->domain_suffix, 0);
}
dns_dirty = 1;
......@@ -88,17 +88,21 @@ void lease_init(struct daemon *daemon, time_t now)
daemon->lease_fd = fileno(lease_file);
}
void lease_update_from_configs(struct dhcp_config *dhcp_configs, char *domain)
void lease_update_from_configs(struct daemon *daemon)
{
/* changes to the config may change current leases. */
struct dhcp_lease *lease;
struct dhcp_config *config;
char *name;
for (lease = leases; lease; lease = lease->next)
if ((config = find_config(dhcp_configs, NULL, lease->clid, lease->clid_len, lease->hwaddr, NULL)) &&
(config->flags & CONFIG_NAME))
lease_set_hostname(lease, config->hostname, domain);
if ((config = find_config(daemon->dhcp_conf, NULL, lease->clid, lease->clid_len, lease->hwaddr, NULL)) &&
(config->flags & CONFIG_NAME) &&
(!(config->flags & CONFIG_ADDR) || config->addr.s_addr == lease->addr.s_addr))
lease_set_hostname(lease, config->hostname, daemon->domain_suffix, 1);
else if ((name = host_from_dns(daemon, lease->addr)))
lease_set_hostname(lease, name, daemon->domain_suffix, 1); /* updates auth flag only */
}
void lease_update_file(int always, time_t now)
......@@ -304,26 +308,32 @@ int lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
return 1;
}
void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix)
void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix, int auth)
{
struct dhcp_lease *lease_tmp;
char *new_name = NULL, *new_fqdn = NULL;
if (lease->hostname && name && hostname_isequal(lease->hostname, name))
{
lease->auth_name = auth;
return;
}
if (!name && !lease->hostname)
return;
/* If a machine turns up on a new net without dropping the old lease,
or two machines claim the same name, then we end up with two interfaces with
the same name. Check for that here and remove the name from the old lease. */
the same name. Check for that here and remove the name from the old lease.
Don't allow a name from the client to override a name from dnsmasq config. */
if (name)
{
for (lease_tmp = leases; lease_tmp; lease_tmp = lease_tmp->next)
if (lease_tmp->hostname && hostname_isequal(lease_tmp->hostname, name))
{
if (lease_tmp->auth_name && !auth)
return;
new_name = lease_tmp->hostname;
lease_tmp->hostname = NULL;
if (lease_tmp->fqdn)
......@@ -331,6 +341,7 @@ void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix)
new_fqdn = lease_tmp->fqdn;
lease_tmp->fqdn = NULL;
}
break;
}
if (!new_name && (new_name = malloc(strlen(name) + 1)))
......@@ -351,6 +362,7 @@ void lease_set_hostname(struct dhcp_lease *lease, char *name, char *suffix)
lease->hostname = new_name;
lease->fqdn = new_fqdn;
lease->auth_name = auth;
file_dirty = force;
dns_dirty = 1;
......
......@@ -34,7 +34,7 @@ int netlink_init(void)
addr.nl_groups = 0;
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
die("cannot bind netlink socket: %s", NULL);
die(_("cannot bind netlink socket: %s"), NULL);
return sock;
}
......@@ -132,7 +132,7 @@ int netlink_process(struct daemon *daemon, int index, struct in_addr relay,
rta = RTA_NEXT(rta, len1);
}
if (addr.s_addr && broadcast.s_addr)
if (addr.s_addr)
{
ret = complete_context(daemon, addr, ret, netmask, broadcast, relay, primary);
if (addr.s_addr == primary.s_addr)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -146,7 +146,7 @@ void *safe_malloc(size_t size)
void *ret = malloc(size);
if (!ret)
die("could not get memory", NULL);
die(_("could not get memory"), NULL);
return ret;
}
......@@ -169,14 +169,14 @@ void complain(char *message, int lineno, char *file)
{
char buff[256];
sprintf(buff, "%s at line %d of %%s", message, lineno);
sprintf(buff, _("%s at line %d of %%s"), message, lineno);
log_err(buff, file);
}
void die(char *message, char *arg1)
{
log_err(message, arg1);
syslog(LOG_CRIT, "FAILED to start up");
syslog(LOG_CRIT, _("FAILED to start up"));
exit(1);
}
......@@ -302,7 +302,7 @@ int prettyprint_addr(union mysockaddr *addr, char *buf)
void prettyprint_time(char *buf, unsigned int t)
{
if (t == 0xffffffff)
sprintf(buf, "infinite");
sprintf(buf, _("infinite"));
else
{
unsigned int x, p = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment