]> git.ipfire.org Git - thirdparty/systemd.git/commit
resolved: add hook api
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Oct 2025 09:04:58 +0000 (11:04 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 15 Nov 2025 06:44:24 +0000 (07:44 +0100)
commit8209f4adcde08d225f56269e608ccd5f6704cd70
tree2d2116edbc4e10ad093a3187b802dd3dc1b98c5c
parentfe9bccb2b7ac357d0d486e3adcefc151aff5e5aa
resolved: add hook api

This introduces /run/systemd/resolve.hook/ as a new directory that local
(privileged) programs can bind a Varlink socket into. If they do they'll
get a method call for each attempted resolved lookup, which they can
then either process themselves (and generate new records for, or return
errors to block stuff) or let pass so that the regular resolution is
done.

Usecase for this is primarily two things:

1. in machined we can add local resolution of machine names to their IP
   addresses, similar in fashion to nss-mymachines, but working also if
   the non-NSS interfaces to name resolution are used, i.e. the local
   DNS responder. In fact, I think we should eventually remove
   nss-mymachines from our tree, as soon as this code in resolved is
   setlled.

2. in networkd we can add local resolution of names specified in DHCP
   leases we hand out.

But beyond that there should be many other uses, for example people
could write "dns firewalls" with this if they like where they
dynamically block certain names from resolution.

Fixes: #8518
18 files changed:
man/org.freedesktop.resolve1.xml
src/resolve/meson.build
src/resolve/resolvectl.c
src/resolve/resolved-bus.c
src/resolve/resolved-dns-query.c
src/resolve/resolved-dns-query.h
src/resolve/resolved-forward.h
src/resolve/resolved-hook.c [new file with mode: 0644]
src/resolve/resolved-hook.h [new file with mode: 0644]
src/resolve/resolved-manager.c
src/resolve/resolved-manager.h
src/resolve/resolved-varlink.c
src/resolve/test-dns-query.c
src/shared/meson.build
src/shared/resolved-def.h
src/shared/varlink-io.systemd.Resolve.Hook.c [new file with mode: 0644]
src/shared/varlink-io.systemd.Resolve.Hook.h [new file with mode: 0644]
src/test/test-varlink-idl.c