Commit Graph

1894 Commits

Author SHA1 Message Date
Simon Kelley
b5dafc0b7e Extend packet dump system to RA. 2022-01-29 22:52:21 +00:00
Simon Kelley
fc664d114d Extend packet-dump system to DHCP and TFTP. 2022-01-29 15:55:04 +00:00
Simon Kelley
c6d4c33d61 Bump copyright to 2022. 2022-01-24 15:19:00 +00:00
Simon Kelley
4e2a4b8788 Fix crash in PXE code with bad config. 2022-01-18 00:55:13 +00:00
Simon Kelley
2362784bc0 Debian bug management. 2022-01-18 00:32:15 +00:00
Simon Kelley
b2cec1b881 Debian: fold in 2.86-1.1 changelog and close bug introducded by same. 2022-01-18 00:02:32 +00:00
Simon Kelley
a946857133 Remove temporary debugging message and close related Debian bug. 2022-01-17 23:54:58 +00:00
Simon Kelley
10cd342f5c Document change of behaviour of --address in 2.86 onwards. 2022-01-17 16:01:02 +00:00
Simon Kelley
27ce754b3d Tidy previous commit and add manpage entries for new options. 2022-01-15 17:57:57 +00:00
Dominik Derigs
3ab0ad8748 Strip EDNS(0) Client Subnet / MAC information if --strip-subnet or --strip-mac is set. If both the add and strip options are set, incoming EDNS0 options are replaced. This ensures we do not unintentionally forward client information somewhere upstream when ECS is used in lower DNS layers in our local network.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-01-15 15:36:28 +00:00
Dominik Derigs
4308236262 Minimum safe size is recommended to be 1232. See https://dnsflagday.net/2020/
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-01-13 00:31:54 +00:00
Simon Kelley
ebd8350300 Fix DNSSEC failure to validate unsigned NoDATA replies.
A reply with an empty answer section would not always be checked
for either suitable NSEC records or proof of non-existence of
the relevant DS record.
2022-01-13 00:12:07 +00:00
Simon Kelley
8285d335f4 Fix error introduced in 11c52d032b 2022-01-12 23:05:25 +00:00
Simon Kelley
9db275ebea Small fix to ff43d35aee 2022-01-12 23:00:16 +00:00
Petr Menšík
1f8f78a49b Add root group writeable flag to log file
Some systems strips even root process capability of writing to different
users file. That include systemd under Fedora. When
log-facility=/var/log/dnsmasq.log is used, log file with mode 0640
is created. But restart then fails, because such log file can be used
only when created new. Existing file cannot be opened by root when
starting, causing fatal error. Avoid that by adding root group writeable flag.

Ensure group is always root when granting write access. If it is
anything else, administrator has to configure correct rights.
2022-01-11 23:43:09 +00:00
Simon Kelley
c2f129ba3d Fix FTBFS when HAVE_DNSSEC not defined. 2022-01-11 22:48:14 +00:00
Simon Kelley
07c47416a9 Log source of ignored query when local-service is used.
Thanks to Dominik Derigs for the initial patch.
2022-01-11 22:36:01 +00:00
Dominik Derigs
8f2a62b386 Extend cache dump: "!" as type for non-terminals, new flag "C" for config-provided and log source when applicable.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-01-11 22:17:14 +00:00
Dominik Derigs
a6c0edd4f4 Fix header of cache dump. The width of the host and address fields are 30 and 40 characters, respectively.
Signed-off-by: DL6ER <dl6er@dl6er.de>
2022-01-11 22:16:48 +00:00
Simon Kelley
ff43d35aee Log port numbers in server addresses when non-standard ports in use. 2022-01-11 22:09:09 +00:00
Simon Kelley
70fca205be Overhaul code which sends DNSSEC queries.
There are two functional changes in this commit.

1) When searching for an in-flight DNSSEC query to use
   (rather than starting a new one), compare the already
   sent query (stored in the frec "stash" field, rather than
   using the hash of the query. This is probably faster (no hash
   calculation) and eliminates having to worry about the
   consequences of a hash collision.

2) Check for dependency loops in DNSSEC validation,
   say validating A requires DS B and validating DS B
   requires DNSKEY C and validating DNSKEY C requires DS B.
   This should never happen in correctly signed records, but it's
   likely the case that sufficiently broken ones can cause
   our validation code requests to exhibit cycles.
   The result is that the ->blocking_query list
   can form a cycle, and under certain circumstances that can lock us in
   an infinite loop.
   Instead we transform the situation into an ABANDONED state.
2022-01-11 00:29:36 +00:00
Simon Kelley
1033130b6c Handle malformed query packets sensibly.
Previously, hash_questions() would return a random hash
if the packet was malformed, and probably the hash of a previous
query. Now handle this as an error.
2022-01-09 23:21:55 +00:00
Andreas Metzler
8cfcd9ff63 Clarify man page for --filterwin2k 2022-01-06 23:12:53 +00:00
Daniel Collins
80a6c16dcc Implements a SetLocaliseQueriesOption D-Bus method.
For setting the state of the -y/--localise-queries option.
2022-01-06 00:23:53 +00:00
Simon Kelley
553c4c99cc Fix massive confusion on server reload.
The 2.86 upstream server rewrite severely broke re-reading
of server configuration. It would get everyting right the first
time, but on re-reading /etc/resolv.conf or --servers-file
or setting things with DBUS, the results were just wrong.

This should put things right again.
2022-01-03 23:32:30 +00:00
Simon Kelley
4165c1331b Fix fail to build when NO_SCRIPT set. 2022-01-03 23:31:15 +00:00
Fabrice Fontaine
b2690415bf src/option.c: fix build with gcc 4.8
Thanks for applying and fixing my patch. Here is another one on src/pattern.c

Best Regards,

Fabrice

Le dim. 2 janv. 2022 à 00:36, Simon Kelley <simon@thekelleys.org.uk> a écrit :
>
>
>
> Thanks,
>
>
> patch applied. Followed by a small fix, and then a larger fix when I was
> forced to look at the code in question ;)
>
>
>
> Cheers,
>
> Simon.
>
> On 31/12/2021 16:29, Fabrice Fontaine wrote:
> > Fix the following build failure with gcc 4.8 raised since version 2.86:
> >
> > option.c: In function 'one_opt':
> > option.c:2445:11: error: 'for' loop initial declarations are only allowed in C99 mode
> >            for (char *p = arg; *p; p++) {
> >            ^
> > option.c:2445:11: note: use option -std=c99 or -std=gnu99 to compile your code
> > option.c:2453:11: error: 'for' loop initial declarations are only allowed in C99 mode
> >            for (u8 i = 0; i < sizeof(daemon->umbrella_device); i++, arg+=2) {
> >            ^
> >
> > Fixes:
> >  - http://autobuild.buildroot.org/results/39b34a4e69fc10f4bd9d4ddb0ed8c0aae5741c84
> >
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> > ---
> >  src/option.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/option.c b/src/option.c
> > index ff54def..c57f6d8 100644
> > --- a/src/option.c
> > +++ b/src/option.c
> > @@ -2525,7 +2525,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
> >            arg += 9;
> >            if (strlen(arg) != 16)
> >                ret_err(gen_err);
> > -          for (char *p = arg; *p; p++) {
> > +          char *p;
> > +          for (*p = arg; *p; p++) {
> >              if (!isxdigit((int)*p))
> >                ret_err(gen_err);
> >            }
> > @@ -2533,7 +2534,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
> >
> >            u8 *u = daemon->umbrella_device;
> >            char word[3];
> > -          for (u8 i = 0; i < sizeof(daemon->umbrella_device); i++, arg+=2) {
> > +          u8 i;
> > +          for (i = 0; i < sizeof(daemon->umbrella_device); i++, arg+=2) {
> >              memcpy(word, &(arg[0]), 2);
> >              *u++ = strtoul(word, NULL, 16);
> >            }
> >
>

From 0c89dd2fa0fe50b00bca638dbbacfbd361526e0a Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Sun, 2 Jan 2022 21:57:52 +0100
Subject: [PATCH] src/pattern.c: fix build with gcc 4.8

Fix the following build failure:

pattern.c: In function 'is_valid_dns_name':
pattern.c:134:3: error: 'for' loop initial declarations are only allowed in C99 mode
   for (const char *c = value;; c++)
   ^
pattern.c:134:3: note: use option -std=c99 or -std=gnu99 to compile your code
pattern.c: In function 'is_valid_dns_name_pattern':
pattern.c:249:3: error: 'for' loop initial declarations are only allowed in C99 mode
   for (const char *c = value;; c++)
   ^

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-01-03 15:13:53 +00:00
Simon Kelley
011f8cf1d0 Tidy code for --umbrella option. 2022-01-01 23:33:39 +00:00
Simon Kelley
2748fb81e2 Fix 46312909d9 typo. 2022-01-01 23:03:26 +00:00
Fabrice Fontaine
46312909d9 src/option.c: fix build with gcc 4.8
Fix the following build failure with gcc 4.8 raised since version 2.86:

option.c: In function 'one_opt':
option.c:2445:11: error: 'for' loop initial declarations are only allowed in C99 mode
           for (char *p = arg; *p; p++) {
           ^
option.c:2445:11: note: use option -std=c99 or -std=gnu99 to compile your code
option.c:2453:11: error: 'for' loop initial declarations are only allowed in C99 mode
           for (u8 i = 0; i < sizeof(daemon->umbrella_device); i++, arg+=2) {
           ^

Fixes:
 - http://autobuild.buildroot.org/results/39b34a4e69fc10f4bd9d4ddb0ed8c0aae5741c84

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-01-01 23:00:25 +00:00
Simon Kelley
41adecad14 Include client address if TFTP file-not-found errors. 2022-01-01 22:15:16 +00:00
Simon Kelley
ea5d8c56a0 Finesse parsing of --dhcp-remoteid and --dhcp-subscrid.
To be treated as hex, the pattern must consist of only hex digits AND
contain at least one ':'. Thanks to Bengt-Erik Sandstrom who tripped
over a pattern consisting of a decimal number which was interpreted
surprisingly.
2021-12-30 23:22:43 +00:00
Simon Kelley
d242cbffa4 Add snooping of DHCPv6 prefix delegation to the DHCP-relay function. 2021-12-30 21:20:37 +00:00
Simon Kelley
1c8855ed10 Fix wrong client address for dhcp-script when DHCPv4 relay in use. 2021-12-26 16:35:54 +00:00
Simon Kelley
ea33a01303 Fix rare "Internal error in cache" messages.
Fix error created in 1ce1c6beae

Many thanks to Hartmut Birr for finding the bug and bisecting to
the guilty commit.

The breaking commit creates cache entries which have F_NXDOMAIN
set but none of F_IPV4, F_IPV6 or F_SRV. If cache_scan_free() is called
to delete such an entry it will fail to do so.

If the cache has no free slots and the least-recently-used slot is such
an entry, then a new insertion will attempt to make space by calling
cache_scan_free(), which will fail when it should be impossible and
trigger the internal error.
2021-12-24 18:58:35 +00:00
Simon Kelley
18b1d1424e Generalise --dhcp-relay.
Sending via broadcast/multicast is now supported for both
IPv4 and IPv6 and the configuration syntax made
easier (but backwards compatible).
2021-12-20 16:40:41 +00:00
Simon Kelley
1176cd58c9 Fix regression in --rebind-domain-ok in 2.86
The 2.86 domain-match rewrite changed matching from
whole-labels to substring matching, so example.com
would match example.com and www.example.com, as before,
but also goodexample.com, which is a regression. This
restores the original behaviour.

Also restore the behaviour of --rebind-domain-ok=//
to match domains with onlt a single label and no dots.

Thanks to Sung Pae for reporting these bugs and supplying
an initial patch.
2021-12-08 23:51:38 +00:00
guns
44a4643b62 Correctly return a heap-allocated empty string instead of NULL
Commit 32e15c3f45 added the following
change:

  --- a/src/option.c
  +++ b/src/option.c
  @@ -654,7 +654,7 @@ static char *canonicalise_opt(char *s)
       return 0;

     if (strlen(s) == 0)
  -    return "";
  +    return opt_string_alloc("");

     unhide_metas(s);
     if (!(ret = canonicalise(s, &nomem)) && nomem)

Unfortunately, opt_string_alloc(const char *cp) returns NULL when
strlen(cp) == 0, which in turn causes --rebind-domain-ok='' to crash
with SIGSEGV.
2021-12-04 12:03:31 +00:00
Simon Kelley
ed96efd865 Fix confusion with log-IDs and DNS retries.
The IDs logged when --log-queries=extra is in effect
can be wrong in three cases.

1) When query is retried in response to a a SERVFAIL or REFUSED
answer from upstream. In this case the ID of an unrelated query will
appear in the answer log lines.

2) When the same query arrives from two clients. The query is
sent upstream once, as designed, and the result returned to both clients,
as designed, but the reply to the first client gets the log-ID of the
second query in error.

3) When a query arrives, is sent upstream, and the reply comes back,
but the transaction is blocked awaiting a DNSSEC query needed to validate
the reply. If the client retries the query in this state, the blocking
DNSSEC query will be resent, as designed, but that send will be logged with
the ID of the original, currently blocked, query.

Thanks to  Dominik Derigs for his analysis of this problem.
2021-12-01 16:40:26 +00:00
Simon Kelley
e3093b532c Fix problems with upper-case in domain-match.
The domain-match rewrite didn't take into account
that domain names are case-insensitive, so things like

--address=/Example.com/.....

didn't work correctly.
2021-11-28 18:39:42 +00:00
Simon Kelley
9560658c5b Fix crash in PXE/netboot when DNS server disabled. 2021-10-19 15:33:41 +01:00
Simon Kelley
37a70d39e0 Add --filter and --filter-AAAA options. 2021-10-07 23:12:59 +01:00
Dominik Derigs
72fac0810c dnsmasq.h has to be included first as it sources config.h
Signed-off-by: DL6ER <dl6er@dl6er.de>
2021-10-07 09:28:34 +01:00
Simon Kelley
c166c07a93 Support IDN in --auth-zone. 2021-10-06 23:48:06 +01:00
Petr Menšík
39a625ff72 Disable transitional IDN rules, accept only sane names
Transitional encoding accepts every emoticon you can think about.
Because setlocale were not enabled before, IDN 2003 input was not
accepted by dnsmasq. It makes no sense therefore to maintain backward
compatibility. Accept only proper encoded unicode names and reject
random unicode characters.

Signed-off-by: Petr Menšík <pemensik@redhat.com>
2021-10-06 23:33:13 +01:00
Petr Menšík
ad32ca18a7 Enable locale support for IDN at startup
--address=/münchen.de/ is not accepted unless LOCALEDIR is defined on
build. It is not by default. If LIBIDN1 or 2 is defined, call setlocale
to initialize locale required to translate domains to ascii form.

Signed-off-by: Petr Menšík <pemensik@redhat.com>
2021-10-06 23:23:51 +01:00
Simon Kelley
efea282396 Fix logic in add_update_server() to make optimisation actually optimise. 2021-10-06 23:01:14 +01:00
Simon Kelley
33d6a01cd3 Use host byte-order variable for answer counting. 2021-10-06 22:54:35 +01:00
Simon Kelley
d290630d31 Fix crash after re-reading an empty resolv.conf file.
If dnsmasq re-reads a resolv file, and it's empty, it will
retry after a delay. In the meantime, the old servers from the
resolv file have been deleted, but the servers_array doesn't
get updated, leading to dangling pointers and crashes.

Thanks to Brad Jorsch for finding and analysing this bug.

This problem was introduced in 2.86.
2021-10-06 22:31:06 +01:00
Simon Kelley
d2ad5dc073 Fix truncation logic in make_local_answer()
add_resource_record() returns 1 if the record was added.
Only increment anscount of so.

Thanks to Petr Menšík for spotting the problem.
2021-10-05 23:38:20 +01:00