Commit Graph

2139 Commits

Author SHA1 Message Date
Simon Kelley
a61dbc84bf Adjust .gitignore to reflect new Debian packaging. 2024-01-23 23:19:01 +00:00
Gioele Barabucci
3cbd4b0fc0 Use debhelper to simplify tmpfiles installation in debian package. 2024-01-23 23:09:11 +00:00
Simon Kelley
75965b19bd 2023->2024 in debian/copyright 2024-01-23 23:04:29 +00:00
Simon Kelley
830459d3a1 Tie up loose ends in debian/changelog for upload to experimental. 2024-01-23 23:02:49 +00:00
Justin
aa9e9651a1 Man page typo fix. 2024-01-21 22:24:43 +00:00
Simon Kelley
9142942483 Remove Debian patch to bump Lua version. It's upstream now. 2024-01-21 12:51:14 +00:00
Simon Kelley
68fe0d78bb Bump version in Debian changelog to 2.90 2024-01-19 22:35:28 +00:00
Simon Kelley
c9d7b983c4 Bump copright year in debian/copyright and add a copyright holder. 2024-01-19 14:47:03 +00:00
Simon Kelley
7c07dc3526 Bump LUA library to 5.4 2024-01-19 14:34:15 +00:00
Sven Geuer
cd93d15ab1 Largely replace the Debian packaging with a new and much more up-to-date
Debhelper based version.
2024-01-19 14:34:15 +00:00
Simon Kelley
34bbb7a1b8 Fix FTBFS introduced in 2748d4e901 2024-01-19 14:32:02 +00:00
Simon Kelley
b5820d1fd8 Bump copyright to 2024. 2024-01-13 22:20:04 +00:00
Petr Menšík
2748d4e901 Introduce new --local-service=host parameter
Similar to local-service, but more strict. Listen only on localhost
unless other interface is specified. Has no effect when interface is
provided explicitly. I had multiple bugs fillen on Fedora, because I have
changed default configuration to:

interface=lo
bind-interfaces

People just adding configuration parts to /etc/dnsmasq.d or appending to
existing configuration often fail to see some defaults are already there.
Give them auto-ignored configuration as smart default.

Signed-off-by: Petr Menšík <pemensik@redhat.com>

Do not add a new parameter on command line. Instead add just parameter
for behaviour modification of existing local-service option. Now it
accepts two optional values:
- net: exactly the same as before
- host: bind only to lo interface, do not listen on any other addresses
  than loopback.
2024-01-13 22:11:22 +00:00
Simon Kelley
63ba726e1f Fix --synth-domain NXDOMAIN responses.
By design, dnsmasq forwards queries for RR-types it has no data
on, even if it has data for the same domain and other RR-types.

This can lead to an inconsitent view of the DNS when an upstream
server returns NXDOMAIN for an RR-type and domain but the same domain
but a different RR-type gets an answer from dnsmasq. To avoid this,
dnsmasq converts NXDOMAIN answer from upstream to NODATA answers if
it would answer a query for the domain and a different RR-type.

An oversight missed out --synth-domain from the code to do this, so
--synth-domain=thekelleys.org.uk,192.168.0.0/24
would result in the correct answer to an A query for
192-168.0.1.thekelleys.org.uk and an AAAA query for the same domain
would be forwarded upstream and the resulting NXDOMAIN reply
returned.

After the fix, the reply gets converted to NODATA.

Thanks to Matt Wong for spotting the bug.
2023-12-03 17:48:56 +00:00
Simon Kelley
f1beb79429 Fix problem with domains associated with DHCP hosts at startup.
At startup, the leases file is read by lease_init(), and
in lease_init() undecorated hostnames are expanded into
FQDNs by adding the domain associated with the address
of the lease.

lease_init() happens relavtively early in the startup, party because
if it calls  the dhcp-lease helper script, we don't want that to inherit
a load of sensitive file descriptors. This has implications if domains
are defined using the --domain=example.com,eth0 format since it's long
before we call enumerate_interfaces(), so get_domain fails for such domains.

The patch just moves the hostname expansion function to a seperate
subroutine that gets called later, after enumerate_interfaces().
2023-12-03 16:09:08 +00:00
Simon Kelley
cd4db8246e Fix typo in dnsmasq.conf.example
Thanks to Brenton Bostick for the report.
2023-11-30 16:25:21 +00:00
Damian Sawicki
69877f565a Add information on process-forking for TCP connections to metrics.
Add the relevant information to the metrics and to the output of
dump_cache() (which is called when dnsmasq receives SIGUSR1).
Hence, users not collecting metrics will still be able to
troubleshoot with SIGUSR1. In addition to the current usage,
dump_cache() contains the information on the highest usage
since it was last called.
2023-11-30 15:55:51 +00:00
Simon Kelley
744231d995 Tighten up error checking in --bind-dynamic mode.
In bind-dynamic mode, its OK to fail to bind a socket to an address
given by --listen-address if no interface with that address exists
for the time being. Dnsmasq will attempt to create the socket again
when the host's network configuration changes.

The code used to ignore pretty much any error from bind(), which is
incorrect and can lead to confusing behaviour. This change make ONLY
a return of EADDRNOTAVAIL from bind() a non-error: anything else will be
fatal during startup phase, or logged after startup phase.

Thanks to Petr Menšík for the problem report and first-pass patch.
2023-11-27 23:08:31 +00:00
Simon Kelley
65c2d6afd6 Fix standalone SHA256 implementation.
Bug report here:
https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2023q4/017332.html

This error probably has no practical effect since even if the hash
is wrong, it's only compared internally to other hashes computed using
the same code.

Understanding the error:

hash-questions.c:168:21: runtime error: left shift of 128 by 24 places
cannot be represented in type 'int'

requires a certain amount of c-lawyerliness. I think the problem is that

m[i] = data[j] << 24

promotes the unsigned char data array value to int before doing the shift and
then promotes the result to unsigned char to match the type of m[i].
What needs to happen is to cast the unsigned char to unsigned int
BEFORE the shift.

This patch does that with explicit casts.
2023-11-22 22:02:05 +00:00
Simon Kelley
b27b94cfdc Merge branch 'master' of ssh://thekelleys.org.uk/var/local/git/dnsmasq 2023-11-22 15:29:10 +00:00
Simon Kelley
b8b5b734b4 Fix misuse of const pointer in src/nftset.c.
Thanks to  Kevin Darbyshire-Bryant for the initial patch, which was
modified by srk - any remaining bugs are his.
2023-11-22 15:20:53 +00:00
Simon Kelley
568fb02449 Fix use-after-free in cache_remove_uid().
Thanks to Kevin Darbyshire-Bryant for the bug report.
2023-11-13 22:08:08 +00:00
Simon Kelley
77ef9b2603 Fix crash when DNS disabled, introduced in 416390f996 2023-11-10 23:13:46 +00:00
Damian Sawicki
416390f996 Add --max-tcp-connections option to make this dynamically configurable. 2023-11-04 23:33:28 +00:00
Simon Kelley
24804b7431 Fix compile warning introduced by a889c554a7 2023-11-04 16:58:30 +00:00
Dominik Derigs
1fe9d2ba45 Add RESINFO RR-type to the table of RR-type names. 2023-11-04 16:52:09 +00:00
Simon Kelley
3868066085 Fix bad reply to DHCPCONFIRM messages (wrong message type).
Thanks to renmingshuai <renmingshuai@huawei.com> for
spotting the error, and making the initial patch.
2023-10-11 22:33:17 +01:00
Simon Kelley
a889c554a7 Work around possible Linux bug with VRF interfaces and DHCPv6.
The scope_id in the source address of recieved packets gets set
to the index of the VRF interface, not the slave. Fortunately,
the interface index returned by packetinfo is correct so we use
instead.

Thanks to Luci Stanescu <luci@safebits.tech> for characterising this.

Ref: https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2023q4/017276.html
2023-10-11 21:32:55 +01:00
Simon Kelley
ca8d04a8ff Cache zero-TTL DNS replies when stale-caching is enabled. 2023-10-09 21:15:13 +01:00
Simon Kelley
8b606543a3 Fix memory leak in arbitrary-RR caching.
If the cache insertion process fails for any reason, any
blockdata storage allocated needs to be freed.

Thanks to Damian Sawicki for spotting the problem and
supplying patches against earlier releases. This patch by SRK,
and any bugs are his.
2023-10-09 21:00:11 +01:00
renmingshuai
d16b995756 Fix memory leak when using --dhcp-optsfile with DHCPv6 options. 2023-09-30 23:31:08 +01:00
Simon Kelley
768b45a023 Remove two-decade old hack.
answer_request() builds answers in the same packet buffer
as the request.  This means that any EDNS0 header from the
original request is overwritten. If the answer is in cache, that's
fine: dnsmasq adds its own EDNS0 header, but if the cache lookup fails
partially and the request needs to be sent upstream, it's a problem.

This was fixed a long, long time ago by running the cache
lookup twice if the request included an EDNS0 header. The first time,
nothing would be written to the answer packet, nad if the cache
lookup failed, the untouched question packet was still available
to forward upstream. If cache lookup succeeded, the whole thing
was done again, this time writing the data into the reply packet.
In a world where EDNS0 was rare and so was memory, this was a
reasonable solution. Today EDNS0 is ubiquitous so basically
every query is being looked up twice in the cache. There's also
the problem that any code change which makes successive cache lookups
for a query possibly return different answers adds a subtle hidden
bug, because this hack depends on absence of that behaviour.

This commit removes the lookup-twice hack entirely. answer_request()
can now return zero and overwrite the question packet. The code which
was previously added to support stale caching by saving a copy of the
query in the block-storage system is extended to always be active.
This handles the case where answer_request() returns no answer OR
a stale answer and a copy of the original query is needed to forward
upstream.
2023-09-11 22:11:50 +01:00
Simon Kelley
3b5ddf37d9 Fix problem with arbitrary RR caching.
Caching an answer which has more that one RR, with at least
one answer being <=13 bytes and at least one being >13 bytes
can screw up the F_KEYTAG flag bit, resulting in the wrong
type of the address union being used and either a bad value
return or a crash in the block code.

Thanks to Dominik Derigs and the Pi-hole project for finding
and characterising this.
2023-09-02 21:34:54 +01:00
Simon Kelley
9bbf098a97 =/== typo in last commit. 2023-05-26 18:19:15 +01:00
Simon Kelley
6536187b62 Merge branch 'master' of ssh://thekelleys.org.uk/var/local/git/dnsmasq 2023-05-26 18:01:58 +01:00
Simon Kelley
50adf82199 Behave better when attempting to contact unresponsive TCP servers.
By default TCP connect takes minutes to fail when trying to
connect a server which is not responding and for which the
network layer doesn't generate HOSTUNREACH errors.

This is doubled because having failed to connect in FASTOPEN
mode, the code then tries again with a call to connect().

We set TCP_SYNCNT to 2, which make the timeout about 10 seconds.
This in an unportable Linux feature, so it doesn't work on other
platforms.

No longer try connect() if sendmsg in fastopen mode fails with
ETIMEDOUT or EHOSTUNREACH since the story will just be the same.
2023-05-26 17:55:35 +01:00
Simon Kelley
1419de285f Log truncated DNS replies. 2023-05-17 23:19:30 +01:00
Simon Kelley
31c91b40bd Handle SERVFAIL responses to DS queries better.
On 15/5/2023 8.8.8.8 was returning SERVFAIL for a query on ec.europa.eu

ec.europa.eu is not a domain cut, that happens at jrc.ec.europa.eu. which
does return a signed proof of non-existance for a DS record.
Abandoning the search for a DS or proof of non existence at ec.europa.eu
renders everything within that domain BOGUS, since nothing is signed.

This code changes behaviour on a SERVFAIL to continue looking
deeper for a DS or proof of its nonexistence.
2023-05-17 12:20:50 +01:00
Simon Kelley
1d6fe0ea84 Code tidying. 2023-05-01 23:06:29 +01:00
Simon Kelley
d774add784 Fix issue with stale caching.
After replying with stale data, dnsmasq sends the query upstream to
refresh the cache asynchronously and sometimes sends the wrong packet:
packet length can be wrong, and if an EDE marking stale data is added
to the answer that can end up in the query also. This bug only seems
to cause problems when the usptream server is a DOH/DOT proxy. Thanks
to Justin He for the bug report.
2023-05-01 20:42:30 +01:00
Simon Kelley
7500157cff Improve RFC3315 para 15 packet validation.
Thanks to Shashikumar Shashil for spotting the ommision.
2023-04-24 17:43:02 +01:00
Simon Kelley
52e6ad2761 Log failure to determine MAC address in DHCPv6. 2023-04-17 21:25:30 +01:00
Petr Menšík
bcb46809dc Optimization of socket events handling of dbus.
Reduces calls to locate the file descriptor structure. Should lower CPU usage when monitoring
dbus watches.
2023-04-17 21:05:00 +01:00
Petr Menšík
33635d8564 Fix crash in dbus code.
If I configure dnsmasq to use dbus and then restart dbus.service with watchers present,
it crashes dnsmasq. The reason is simple, it uses loop to walk over watchers to call
dbus handling code. But from that code the same list can be modified and watchers removed.
But the list iteration continues anyway.

Restart the loop if list were modified.
2023-04-17 20:55:31 +01:00
Simon Kelley
bd188e306a Fix paren blunder in aaba66efbd
Thanks to Dominik Derigs for spotting this.
2023-04-17 16:23:06 +01:00
Simon Kelley
aaba66efbd Add --no-dhcpv4-interface and --no-dhcpv6-interface options. 2023-04-12 22:55:14 +01:00
Simon Kelley
597378cdf5 Turn "used" member of struct iname into flags in preparation for more. 2023-04-12 16:25:49 +01:00
Simon Kelley
15dcdc824a Missed copyright date. 2023-04-05 17:42:23 +01:00
Simon Kelley
86ee779e22 Make --server=/#/<addr> behave the same as --server=<addr>
For consistency with --address and older dnsmasq releases.
2023-04-05 17:29:04 +01:00
Simon Kelley
df242de5c6 Bump copyrights to 2023. 2023-04-05 12:34:34 +01:00