Bug#1086710: reportbug: if-up.d/mountnfs is always a NO-OP and should be fixed or removed
Athanasius
Athanasius at miggy.org
Mon Nov 4 14:20:27 GMT 2024
Package: initscripts
Version: 3.06-4
Severity: normal
I recently had reason to change from defining my IPv4 address
statically to utilising DHCP (and DHCPv6) instead. Due to the pending
removal of dhclient I went with dhcpcd for this. Unfortunately, whether
using dhcpcd-base only (so no daemon, and relying on interfaces(5)
invocation) or the dhcpcd daemon my NFS mounts were not activated.
1. It turns out that the SysV script /etc/init.d/mountfs.sh is masked with
respect to systemd. This is due to the creation of symbolic link to
/dev/null as part of `/var/lib/dpkg/info/initscripts.postinst`. This
was a Stretch > Buster change.
2. With the systemd pseudo-service for the init script being masked there
is a check in `/lib/lsb/init-functions.d/40-systemd` that exits the
script if a state of 'masked' is found. This is invoked as part of the
line `. /lib/lsb/init-functions` in `/etc/network/if-up.d/mountnfs`.
3. If you `systemctl unmask mountnfs.service` then instead the check at
the start of `/etc/network/if-up.d/mountnfs` causes it to bail out:
if [ -d /run/systemd/system ]; then
systemctl list-jobs | grep -q network.target && exit 0
fi
Ergo, there is no way that this if-up.d script, in its current form,
can ever actually do anything useful when systemd is in use, which it
always is on modern Debian systems.
Note that when interfaces(5) and dhcpcd is used in this fashion the
systemd `network-online.target` seems to not be invoked after networking
is set up by dhcpcd. As such NFS mounts are never attempted. Logging
in to a user relying on such *does* then cause relevant mount(s) to be
performed, but that does nothing for any not related to their $HOME.
Specifically in my case `/home/users` gets mounted, but another mount
does not.
It feels like this if-up.d/mountnfs script should be updated to invoke
something like `systemctl start remote-fs.service` in the systemd case.
Otherwise it should simply be removed as any other package that thinks
it can be relied upon is mistaken.
For the curious, a workaround for using dhcpcd is to write an
/etc/dhcpcd.exit-hook script that performs necessary actions.
-- 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.6-athan (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=C, LC_CTYPE=C.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 initscripts depends on:
ii sysv-rc 3.06-4
ii sysvinit-utils 3.06-4
Versions of packages initscripts recommends:
ii e2fsprogs 1.47.0-2
ii psmisc 23.6-1
initscripts suggests no packages.
-- Configuration Files:
/etc/network/if-up.d/mountnfs changed:
if [ -d /run/systemd/system ]; then
systemctl list-jobs | grep -q network.target && exit 0
fi
PATH=/sbin:/bin
. /lib/init/vars.sh
. /lib/lsb/init-functions
. /lib/init/mount-functions.sh
set_env() {
# Read through fstab line by line. If it is NFS, set the flag
# for mounting NFS file systems. If any NFS partition is found
# and it not mounted with the nolock option, we start the
# portmapper.
#
# If any sec={krb5,krb5i,krb5p} option is given, or any of the
# file systems are nfs4, we'll need to start rpc.gssd and/or
# rpc.idmapd too; we'll leave that to nfs-common.
start_nfs=no
NETFS=""
NETDEV=""
for file in $(fstab_files); do
if [ -f "$file" ]; then
while read DEV MTPT FSTYPE OPTS REST; do
case "$DEV" in
""|\#*)
continue
;;
esac
case "$OPTS" in
noauto|*,noauto|noauto,*|*,noauto,*)
continue
;;
_netdev|*,_netdev|_netdev,*|*,_netdev,*)
NETDEV=yes
;;
esac
case "$FSTYPE" in
nfs)
# NFS filesystems normally
# require statd and
# portmap. However, if nolock
# is set, portmap and statd
# are not required for this
# file system.
case "$OPTS" in
nolock|*,nolock|nolock,*|*,nolock,*)
# no action
;;
*)
start_nfs=yes
;;
esac
# However, Kerberos requires
# gssd, so start nfs-common
# anyway.
case "$OPTS" in
sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
start_nfs=yes
;;
esac
;;
nfs4)
# NFSv4 requires idmapd, so
# start nfs-common no matter
# what the options are.
start_nfs=yes
;;
smbfs|cifs|coda|ncp|ncpfs|ceph)
;;
*)
FSTYPE=
;;
esac
if [ "$FSTYPE" ]; then
case "$NETFS" in
$FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
;;
*)
NETFS="$NETFS${NETFS:+,}$FSTYPE"
;;
esac
fi
done < "$file"
fi
done
}
do_start() {
#
# Initialize nfs-common (which starts rpc.statd, rpc.gssd
# and/or rpc.idmapd, and loads the right kernel modules if
# applicable) if we use Kerberos and/or NFSv4 mounts.
#
if [ "$start_nfs" = yes ] && [ -x /etc/init.d/nfs-common ]
then
[ -x /etc/init.d/portmap ] && /etc/init.d/portmap start
[ -x /etc/init.d/rpcbind ] && /etc/init.d/rpcbind start
/etc/init.d/nfs-common start
fi
pre_mountall
if [ "$NETFS" ]
then
mount -a -t$NETFS
fi
if [ "$NETDEV" ]; then
mount -a -O _netdev
fi
post_mountall
}
exit_unless_last_interface() {
ifaces="$(ifquery --list)"
for i in $ifaces ; do
if [ "$i" = "lo" ]; then
continue
fi
if ! ifquery --state $i >/dev/null ; then
msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
log_warning_msg "$msg"
exit 0
fi
done
}
set_env
if [ "$start_nfs" = "no" ] && [ ! "$NETFS" ] && [ ! "$NETDEV" ]; then
exit 0
fi
if [ no != "$ASYNCMOUNTNFS" ]; then
# Not for loopback!
[ "$IFACE" != "lo" ] || exit 0
[ "$ADDRFAM" = "inet" ] || [ "$ADDRFAM" = "inet6" ] || exit 0
# Lock around this otherwise insanity may occur
mkdir /var/run/network 2>/dev/null || true
# Wait until all auto interfaces are up before attempting to mount
# network file systems.
exit_unless_last_interface
if mkdir /var/run/network/mountnfs 2>/dev/null ; then
:
else
msg="if-up.d/mountnfs[$IFACE]: lock /var/run/network/mountnfs exist, not mounting"
log_failure_msg "$msg"
# Log if /usr/ is mounted
[ -x /usr/bin/logger ] && /usr/bin/logger -t "if-up.d/mountnfs[$IFACE]" "$msg"
exit 0
fi
on_exit() {
# Clean up lock when script exits, even if it is interrupted
rmdir /var/run/network/mountnfs 2>/dev/null || exit 0
}
trap on_exit EXIT # Enable emergency handler
do_start
elif [ yes = "$FROMINITD" ] ; then
do_start
fi
-- no debconf information
--
- Athanasius (he/him) = Athanasius(at)miggy.org / https://miggy.org/
GPG/PGP Key: https://miggy.org/gpg-key
"And it's me who is my enemy. Me who beats me up.
Me who makes the monsters. Me who strips my confidence." Paula Cole - ME
More information about the Debian-init-diversity
mailing list