#1101003 dhcpcd-base: dhcpcd-run-hooks .d dir support would be useful

Package:
dhcpcd-base
Source:
dhcpcd-base
Description:
DHCPv4 and DHCPv6 dual-stack client (binaries and exit hooks)
Submitter:
Daniel Gröber
Date:
2025-04-19 09:21:01 UTC
Severity:
normal
Tags:
#1101003#5
Date:
2025-03-21 16:01:55 UTC
From:
To:
Hi Martin,

Currently dhcpcd is missing a place in /etc where users can conveniently
install hook scripts. It already has /usr/share/dhcpcd/hooks, but on the
user-configurable side only /etc/dhcpcd.enter-hook and
/etc/dhcpcd.exit-hook exist. However those are singular scripts that can be
hard to manage.

We should add support for /etc/dhcpcd.{enter,exit}-hook.d.

#1101003#10
Date:
2025-03-21 19:57:01 UTC
From:
To:
pe 21.3.2025 klo 18.03 Daniel Gröber (dxld@darkboxed.org) kirjoitti:

This is yet another upstream issue. Debian is the wrong place to report this.

Martin-Éric

#1101003#15
Date:
2025-03-21 20:30:50 UTC
From:
To:
Hi Martin,

Since we've switched to dhcpcd by default this very much is a Debian
issue. dhclient had this feature, people will be expecting it in it's
replacement.

Just because this is a patch we should also clear with upstream before
applying I don't see why we shouldn't have a tracking issue for it in
Debian. Very much the opposite tracking issues are highly useful.

If you don't want to work on it that's fine. dhcpcd is collab maintained
last I checked being in the debian/ namespace on salsa. Right? I'm planning
to work on a number of these issues to get it into shape for trixie and BTS
is my TODO list here.

#1101003#20
Date:
2025-03-26 10:04:22 UTC
From:
To:
On Fri, 21 Mar 2025 21:30:50 +0100 Daniel =?utf-8?Q?Gr=C3=B6ber?= <dxld@darkboxed.org> wrote:

In Bookworm:
$ apt-file search dhclient-exit-hooks.d
avahi-autoipd: /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd
chrony: /etc/dhcp/dhclient-exit-hooks.d/chrony
cloud-init: /etc/dhcp/dhclient-exit-hooks.d/hook-dhclient
ddclient: /etc/dhcp/dhclient-exit-hooks.d/ddclient
debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/autofs-reload
debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/fetch-rootca-cert
debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/hostname
debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/wpad-proxy-update
isc-dhcp-client: /etc/dhcp/dhclient-exit-hooks.d/debug
isc-dhcp-client: /etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
ntpsec: /etc/dhcp/dhclient-exit-hooks.d/ntpsec
ntpsec-ntpdate: /etc/dhcp/dhclient-exit-hooks.d/ntpsec-ntpdate
sendmail-base: /etc/dhcp/dhclient-exit-hooks.d/sendmail
sendmail-base: /usr/share/sendmail/examples/dhcp/dhclient-exit-hooks.d/sendmail
sendmail-base: /usr/share/sendmail/examples/dhcp/dhclient-exit-hooks.d/sendmail.md5sum
systemd-timesyncd: /etc/dhcp/dhclient-exit-hooks.d/timesyncd
whereami: /etc/dhcp/dhclient-exit-hooks.d/whereami
whereami: /etc/dhcp3/dhclient-exit-hooks.d/whereami
$ apt-file search dhclient-enter-hooks.d
avahi-autoipd: /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd
isc-dhcp-client: /etc/dhcp/dhclient-enter-hooks.d/debug
openresolv: /etc/dhcp/dhclient-enter-hooks.d/resolvconf
resolvconf: /etc/dhcp/dhclient-enter-hooks.d/resolvconf
samba-common: /etc/dhcp/dhclient-enter-hooks.d/samba

In Trixie:
$ apt-file search dhclient-exit-hooks.d
avahi-autoipd: /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd
chrony: /etc/dhcp/dhclient-exit-hooks.d/chrony
ddclient: /etc/dhcp/dhclient-exit-hooks.d/ddclient
debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/autofs-reload
debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/fetch-rootca-cert
debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/hostname
debian-edu-config: /etc/dhcp/dhclient-exit-hooks.d/wpad-proxy-update
isc-dhcp-client: /etc/dhcp/dhclient-exit-hooks.d/debug
isc-dhcp-client: /etc/dhcp/dhclient-exit-hooks.d/resolved
isc-dhcp-client: /etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes
ntpsec: /etc/dhcp/dhclient-exit-hooks.d/ntpsec
ntpsec-ntpdate: /etc/dhcp/dhclient-exit-hooks.d/ntpsec-ntpdate
sendmail-base: /etc/dhcp/dhclient-exit-hooks.d/sendmail
sendmail-base: /usr/share/sendmail/examples/dhcp/dhclient-exit-hooks.d/sendmail
sendmail-base: /usr/share/sendmail/examples/dhcp/dhclient-exit-hooks.d/sendmail.md5sum
systemd-timesyncd: /etc/dhcp/dhclient-exit-hooks.d/timesyncd
whereami: /etc/dhcp/dhclient-exit-hooks.d/whereami
$ apt-file search dhclient-enter-hooks.d
avahi-autoipd: /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd
isc-dhcp-client: /etc/dhcp/dhclient-enter-hooks.d/debug
isc-dhcp-client: /etc/dhcp/dhclient-enter-hooks.d/resolved-enter
openresolv: /etc/dhcp/dhclient-enter-hooks.d/resolvconf
resolvconf: /etc/dhcp/dhclient-enter-hooks.d/resolvconf

Basically, while the idea of offering a directory for administrator
scripts is a noble one, the need is very small. Let's call it a
wishlist item.

Martin-Éric

#1101003#27
Date:
2025-03-26 11:40:45 UTC
From:
To:
* Martin-Éric Racine <martin-eric.racine@iki.fi> [250326 11:09]:
[..]
[..]

If anyone in the future considers implementing this, please also
consider:

1) packaged software can decide to listen on netlink events instead

2) packaged software probably wants to avoid dropping new scripts as
   conffiles into /etc; so it would make sense to provide an
   extension point in /usr that the admin can override in /etc

3) for local administrators dropping something in /etc might still
   make sense


Personally I have no opinion if this feature should ever be done.

Chris

#1101003#34
Date:
2025-04-19 09:17:46 UTC
From:
To:
Looking into the source code for dhcpcd-run-hooks:

for hook in \
    @SYSCONFDIR@/dhcpcd.enter-hook \
    @HOOKDIR@/* \
    @SYSCONFDIR@/dhcpcd.exit-hook
do

Which using our current configure options translates to:

for hook in \
    /etc/dhcpcd.enter-hook \
    /usr/lib/dhcpcd/dhcpcd-hooks/* \
    /etc/dhcpcd.exit-hook
do

Basically, we already support user scripts. However, the above
fragment suggests that these are currently admin-configured flat
files, rather than directories whose content is sourced. If
directories would be preferable, this should be discussed upstream at
https://github.com/NetworkConfiguration/dhcpcd/issues/494 instead of
here.

Martin-Éric