OpenBSD CVS

CVS log for src/sbin/resolvd/resolvd.c


[BACK] Up to [local] / src / sbin / resolvd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.32 / (download) - annotate - [select for diffs], Fri Dec 9 18:22:35 2022 UTC (17 months, 4 weeks ago) by tb
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, HEAD
Changes since 1.31: +5 -1 lines
Diff to previous 1.31 (colored)

resolvd: fix leaks of line and fp

In case asprintf() fails or the iov overflows, the file and the line read
would be leaked.

also noted by otto
ok deraadt millert

Revision 1.31 / (download) - annotate - [select for diffs], Fri Dec 9 18:11:24 2022 UTC (17 months, 4 weeks ago) by otto
Branch: MAIN
Changes since 1.30: +7 -5 lines
Diff to previous 1.30 (colored)

iovcnt can be zero, writev does not like that and O_CREATE is
not needed, we just renamed sucessfully to that file.
ok deraadt@ florian@

Revision 1.30 / (download) - annotate - [select for diffs], Sun Nov 27 15:19:38 2022 UTC (18 months, 1 week ago) by kn
Branch: MAIN
Changes since 1.29: +6 -3 lines
Diff to previous 1.29 (colored)

Provide more accurate lock error message

When started manuall from single-user mode (/ still read-only), the current
error is misleading:
	# slaacd -dv
	slaacd: already running

The lock was specifically added to prevent multiple instances in the
installer, which discards the error message entirely anyway.

Retain the useful EAGAIN/"already running" message, but otherwise print the
real error reason:
	# slaacd -dv
	slaacd: /dev/slaacd.lock: Read-only file system

Feedback OK deraadt millert

Revision 1.29 / (download) - annotate - [select for diffs], Mon Nov 14 13:57:46 2022 UTC (18 months, 3 weeks ago) by kn
Branch: MAIN
Changes since 1.28: +18 -14 lines
Diff to previous 1.28 (colored)

Preserve original order of nameservers

RFC 2132 "DHCP Options and BOOTP Vendor Extensions"
3.8. Domain Name Server Option says
	Servers SHOULD be listed in order of preference.

tcpdump(8), route(8) monitor and dhcpleasectl(8) -l athn0 show servers from
the DHCP OFFER in their original order, as expected.

resolvd(8) however sorts proposals by priority and IP address before writing
them to resolv.conf(5).

But as the system resolver tries this file's `nameserver' options in the
order appearance, sorting by IP breaks DHCP's intended order and thus may
result in the wrong nameserver being queried.


Sorting by IP is done to later remove duplicates from the file.

Sort by priority alone and ensure uniqueness by iterating over the list of
of proposals and zeroeing duplicates instead to preserve any proposal's
original order.


Spotted on a public wifi OFFERing two local IPs plus 8.8.8.8 in this order
which ended up with 8.8.8.8 being the first entry in my /etc/resolv.conf.

In other words, `route nameserver lo0 2.2.2.2 1.1.1.1 1.1.1.1' now yields
	nameserver 2.2.2.2 # resolvd: lo0
	nameserver 1.1.1.1 # resolvd: lo0
rather than
	nameserver 1.1.1.1 # resolvd: lo0
	nameserver 2.2.2.2 # resolvd: lo0

Feedback OK deraadt

Revision 1.28 / (download) - annotate - [select for diffs], Fri Sep 2 09:39:55 2022 UTC (21 months ago) by florian
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.27: +46 -7 lines
Diff to previous 1.27 (colored)

Write /etc/resolv.conf in a more atomic manner.

There were few reports were /etc/resolv.conf would lose user-managed
lines, possibly caused by a system crash.

While here add a call to fsync(2) which might also help.

input otto
input & OK deraadt, kn

Revision 1.27 / (download) - annotate - [select for diffs], Thu Sep 1 13:24:28 2022 UTC (21 months, 1 week ago) by martijn
Branch: MAIN
Changes since 1.26: +2 -2 lines
Diff to previous 1.26 (colored)

At the moment unveil(2) doesn't check the path for bind(2) or connect(2).
This is about to change and connect(2) will require "w", not "r".

OK deraadt@ florian@ mestre@

Revision 1.26 / (download) - annotate - [select for diffs], Sat May 21 13:54:19 2022 UTC (2 years ago) by deraadt
Branch: MAIN
Changes since 1.25: +10 -4 lines
Diff to previous 1.25 (colored)

Repair a leak of a FILE.  The FILE contains a fd via fdopen(), the
handling of the fd is correct, so this temporary fdopen now must use
a dup() so we can fclose().
ok otto

Revision 1.25 / (download) - annotate - [select for diffs], Tue Nov 16 16:24:22 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.24: +3 -3 lines
Diff to previous 1.24 (colored)

Use size of struct not pointer

Pointed out by florian, thanks.
No change as the sockaddr remains unused by getnameinfo() in this case.

Revision 1.24 / (download) - annotate - [select for diffs], Mon Nov 15 18:25:52 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
Changes since 1.23: +3 -1 lines
Diff to previous 1.23 (colored)

Pass sockaddr length to be on the safe side, still

Revision 1.23 / (download) - annotate - [select for diffs], Mon Nov 15 18:23:45 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
Changes since 1.22: +11 -16 lines
Diff to previous 1.22 (colored)

Revert previous

sockaddr_storage should stay since it is preferred and less error prone.

From deraadt
OK florian

Revision 1.22 / (download) - annotate - [select for diffs], Mon Nov 15 17:33:51 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
Changes since 1.21: +17 -12 lines
Diff to previous 1.21 (colored)

Avoid huge sockaddr_storage

sockaddr_{in,in6} are enough and a simple sockaddr pointer is enough to
abstract them  (sockaddr_storage is what worked for me, there is no other
reason to use it).

While here, be portable and pass a non-zero length to getnameinfo(3);
while OpenBSD's implementation ignores it in the NI_NUMERICHOST case,
at least the old KAME stack didn't.

No functional change.

Prodded by florian
OK florian

Revision 1.21 / (download) - annotate - [select for diffs], Sat Nov 13 17:49:40 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
Changes since 1.20: +33 -45 lines
Diff to previous 1.20 (colored)

Simplify address family handling, ditch inet_ntop(3)

Reduce duplicate code, use getnameinfo(3) for IPv4 as well and use
gai_strerror(3) in case of failure.

This was split out as part of the previous IPv6-LL fix.

Revision 1.20 / (download) - annotate - [select for diffs], Sat Nov 13 17:32:46 2021 UTC (2 years, 6 months ago) by kn
Branch: MAIN
Changes since 1.19: +15 -6 lines
Diff to previous 1.19 (colored)

Install missing scope identifier for IPv6 link-local addresses

RTM_PROPOSAL's list of IP addresses does not contain scope IDs by design.
This is not a problem as the proposal is always bound to an interface,
as long as we use it...

Fill in the scope ID for link-local IPs and replace inet_ntop(3) usage with
getnameinfo(3) in the IPv6 case such that it actually turns up in the string
representation.

Otherwise resolv.conf(5) ends up with "nameserver fe80::1" entries and
libc/asr won't be able to resolve without an interface.

Revision 1.19 / (download) - annotate - [select for diffs], Tue Aug 31 09:56:12 2021 UTC (2 years, 9 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.18: +2 -5 lines
Diff to previous 1.18 (colored)

shorten some code

Revision 1.18 / (download) - annotate - [select for diffs], Mon Aug 30 19:14:30 2021 UTC (2 years, 9 months ago) by kn
Branch: MAIN
Changes since 1.17: +1 -5 lines
Diff to previous 1.17 (colored)

Accept dns proposals for the loopback addresses

Don't reserve^Wignore them for unwind(8);  there are non-unwind use-cases
and so far resolvd(8) always seems to do the right thing when proposing
localhost while unwind is running.

OK benno

Revision 1.17 / (download) - annotate - [select for diffs], Mon Aug 30 11:04:50 2021 UTC (2 years, 9 months ago) by kn
Branch: MAIN
Changes since 1.16: +2 -2 lines
Diff to previous 1.16 (colored)

INADDR_LOOPBACK check needs htonl(3) to work

Revision 1.16 / (download) - annotate - [select for diffs], Wed Jul 21 03:53:50 2021 UTC (2 years, 10 months ago) by kn
Branch: MAIN
Changes since 1.15: +3 -3 lines
Diff to previous 1.15 (colored)

Use exclusive lock under /dev/, silence expected errors in installer

resolvd(8), slaacd(8) and dhcpleased(8) are different from other daemons
in that there must only be a single instance.

resolvd already does this, adjust slaacd and dhcpleased accordingly while
moving the lockfile paths under /dev/ such that they work early on boot and
don't run into races should /var be (un)mounted between daemon starts.

Locking is especially required in the installer where all three daemons are
started every time the "(I)nstall, (U)pgrade, (A)utoinstall or (S)hell? "
prompt is entered, i.e. restarting installation or dropping into a shell
and back into the prompt again would start multiple instances.

To avoid expected lockfile error messages in between installer prompts,
discard standard error when starting the autoconf daemons;  none of them
has other potential failure cases in installer mode before daemon(3)izing.

Input sthen deraadt
OK deraadt

Revision 1.15 / (download) - annotate - [select for diffs], Sun Jul 18 15:18:49 2021 UTC (2 years, 10 months ago) by deraadt
Branch: MAIN
Changes since 1.14: +1 -6 lines
Diff to previous 1.14 (colored)

Remove hackery around /tmp/i/resolv.conf*.  In particular "lookup file bind"
is required because of TLS servername for contacting ftp.openbsd.org, and
there is no point doing that in resolv.conf.tail because it is no longer used.
ok florian kn

Revision 1.14 / (download) - annotate - [select for diffs], Sat Jul 17 03:31:31 2021 UTC (2 years, 10 months ago) by kn
Branch: MAIN
Changes since 1.13: +6 -3 lines
Diff to previous 1.13 (colored)

Ignore unwind socket with kevent(2) under SMALL

All other unwind related bits are under #ifndef SMALL already,
so complete that.

OK florian

Revision 1.13 / (download) - annotate - [select for diffs], Fri Jul 16 15:22:12 2021 UTC (2 years, 10 months ago) by florian
Branch: MAIN
Changes since 1.12: +5 -2 lines
Diff to previous 1.12 (colored)

The installer plays weird tricks with /etc/resolv.conf and symlinks it
from /tmp/i. Work around this in resolvd so that it can correctly
update the file until this is fixed in install.sub.

probably grudgingly OK deraadt

Revision 1.12 / (download) - annotate - [select for diffs], Mon May 10 15:06:34 2021 UTC (3 years ago) by deraadt
Branch: MAIN
Changes since 1.11: +1 -4 lines
Diff to previous 1.11 (colored)

remove serial number (used during development to observe file rewrites)

Revision 1.11 / (download) - annotate - [select for diffs], Fri Mar 19 08:10:57 2021 UTC (3 years, 2 months ago) by kn
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

Fix function name in warning

Revision 1.10 / (download) - annotate - [select for diffs], Wed Mar 3 09:32:11 2021 UTC (3 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.9: +5 -3 lines
Diff to previous 1.9 (colored)

Unveil only /etc/resolv.conf and /etc/resolv.conf.new not /etc/

Unveiling the entire directory stems from earlier development cycles
and is by no means required now, only the two files are created,
read from and written to.

OK deraadt florian semarie

Revision 1.9 / (download) - annotate - [select for diffs], Tue Mar 2 17:11:28 2021 UTC (3 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.8: +3 -3 lines
Diff to previous 1.8 (colored)

satisfy older gcc with poor warning generation

Revision 1.8 / (download) - annotate - [select for diffs], Tue Mar 2 16:39:46 2021 UTC (3 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.7: +2 -1 lines
Diff to previous 1.7 (colored)

requires netinet/in.h

Revision 1.7 / (download) - annotate - [select for diffs], Tue Mar 2 09:18:58 2021 UTC (3 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.6: +1 -0 lines
Diff to previous 1.6 (colored)

Add missing RCS marker

Revision 1.6 / (download) - annotate - [select for diffs], Tue Mar 2 09:17:10 2021 UTC (3 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.5: +5 -2 lines
Diff to previous 1.5 (colored)

Do not unveil unused unwind socket under SMALL

Remove unused STARTUP_WAIT_TIMO (since import),
add missing space to error message.

Revision 1.5 / (download) - annotate - [select for diffs], Sat Feb 27 17:47:43 2021 UTC (3 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.4: +1 -1 lines
Diff to previous 1.4 (colored)

ensure local array is same size as global

Revision 1.4 / (download) - annotate - [select for diffs], Fri Feb 26 18:28:07 2021 UTC (3 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.3: +3 -0 lines
Diff to previous 1.3 (colored)

Ignore SIGHUP

It should always run and there is no reload semantic.

OK deraadt

Revision 1.3 / (download) - annotate - [select for diffs], Thu Feb 25 00:38:59 2021 UTC (3 years, 3 months ago) by kn
Branch: MAIN
Changes since 1.2: +8 -0 lines
Diff to previous 1.2 (colored)

Fix SMALL build

OK deraadt

Revision 1.2 / (download) - annotate - [select for diffs], Wed Feb 24 19:00:08 2021 UTC (3 years, 3 months ago) by deraadt
Branch: MAIN
Changes since 1.1: +270 -392 lines
Diff to previous 1.1 (colored)

fairly significant rewrite, including:
replace poll+kevent with kevent only.
lockfile to block starting of 2nd instance.
remove state file, and recognize '# resolvd: ' lines as state
handle DNS proposal withdraws better
Still a work in progress.
tested and looked at by semarie, benno, florian, dlg

Revision 1.1 / (download) - annotate - [select for diffs], Wed Feb 24 18:10:41 2021 UTC (3 years, 3 months ago) by florian
Branch: MAIN

Import resold(8), a daemon to rewrite resolv.conf.
prodding deraadt

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.