Package: dhcpcd
Version: 1:10.1.0-1
Severity: important

Dear Maintainer,

Given the pending removal of the isc `dhclient` I decided to move over
to another method for obtaining DHCP leases.  `dhcpcd`, in the form of
`dhcpcd-base` appears to be the leading contender, so I settled on that.

It works fine, but as it forks and runs in the background (if run either
as the `dhcpcd` daemon as I am doing, or the `dhcpcd-base` non-daemon)
it provides no feedback as to when addresses are obtained and thus
systemd, or anything else, can't easily know when networking is up for
the purposes of NFS mounts.

I *had* been using a static IPv4 setup, utilising a
`/etc/network/interfaces.d/<interface>` file, but had good reason to
change this over to DHCP.  With the static setup systemd's
remote-fs.target took care of the mount without issues.

As supplied use of `dhcpcd` (or -base) makes **no** attempt to ensure
that NFS mounts happen.  There's no feedback into systemd, nor is there
any implementation of a dhcpcd hook file for this purpose.  At least
with dhclient it integrated with ifup and there's
`/etc/network/if-up.d/mountnfs`.  But this is not triggered by `dhcpcd`.

I do note that I *first* tried using `dhcpcd-base`, along with `iface
lan0 inet dhcp`, but this also did not trigger the mountnfs script.

I have implemented a "good enough" `/etc/dhcpcd.exit-hook` script
myself, but it is specific to my system so couldn't be used as-is as a
solution for this.  Obviously such a hook would be better placed as a
Debian addition in `/usr/share/dhcpcd/hooks/`.

Without my exit-hook script my first attempt to login appears to tickle
systemd into mounting my `/home/users/` such that a second login
attempt succeeds.  However this does nothing for *other* NFS mounts.

For what it's worth, here's my script, which does make the assumption
that NFS mounts are made by IP, not hostname:

---------------------------------------------------------------------------
#!/bin/sh
# vim: tabstop=4 shiftwidth=4 expandtab smarttab smartindent wrapmargin=0 
textwidth=0
#
# dhcpcd exit hooks
#
# NB: Not directly, run, but sourced, by /usr/lib/dhcpcd/dhcpcd-run-hooks
#     and that uses /bin/sh, which is usually dash on Debian.

# set -u

log() {
    printf "%s: $@\n" $(date --iso-8601=seconds) >> 
/var/lib/dhcpcd/tmp/etc-exit-hook.log
}
###########################################################################
# Ensure any NFS mounts are attempted *after* addresses and routing
# are in place.
###########################################################################
# First check if mounts are already in place.  *Any* active NFS mount counts
mount | grep -E '^([0-9\.]{7,15}|[:0-9a-f]{2-47}):\/[^ ]+ on \/[^ ]+ type nfs ' 
> /dev/null 2>&1
if [ $? -eq 1 ];
then
# No NFS mounts present
    log "$0: No NFS mounts present"
    # Check this hook run is for expected interface and stage
    # log "$0: interface is: ${interface}"
    if [ "${interface}" = "lan0" ];
    then
        # We don't want to trigger at all stages, only if an address and route
        # has been obtained and added.
        # log "$0: reason is: ${reason}"
        case "${reason}" in
            BOUND|REBIND|REBOOT|BOUND6|REBIND6|REBOOT6|INFORM6)
                log "$0: invoking restart of remote-fs.target"
                systemctl restart remote-fs.target
                ;;
        esac
    fi
# else
#    log "$0: NFS mounts already present"
fi
###########################################################################
---------------------------------------------------------------------------

-- System Information:
Debian Release: 12.7
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 
'stable'), (101, 'unstable'), (99, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.11.5-athan (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages dhcpcd depends on:
ii  dhcpcd-base                1:10.1.0-1~bpo12+1
ii  lsb-base                   11.6
ii  sysvinit-utils [lsb-base]  3.06-4

Versions of packages dhcpcd recommends:
ii  wpasupplicant  2:2.10-12+deb12u2

Versions of packages dhcpcd suggests:
pn  dhcpcd-gtk  <none>

-- no debconf information

Reply via email to