]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(nfs): support rpcbind user named _rpc
authorBenjamin Drung <benjamin.drung@canonical.com>
Mon, 8 Jul 2024 14:29:40 +0000 (16:29 +0200)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Mon, 8 Jul 2024 16:02:08 +0000 (12:02 -0400)
The Debian/Ubuntu package `rpcbind` creates a user named `_rpc`. Support
running `rpcbind` with that user. Add a helper function `get_rpc_user`
that derives the desired user from parsing `/etc/passwd`.

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
modules.d/95nfs/module-setup.sh
modules.d/95nfs/nfs-lib.sh
modules.d/95nfs/nfs-start-rpc.sh
modules.d/95nfs/parse-nfsroot.sh

index abe1ee5946133f28f758c110077d82a195a3915c..5cc4289261cf6d8359e0078b9b390237804db28d 100755 (executable)
@@ -125,7 +125,7 @@ install() {
 
     # Rather than copy the passwd file in, just set a user for rpcbind
     # We'll save the state and restart the daemon from the root anyway
-    grep -E '^nfsnobody:|^rpc:|^rpcuser:' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd"
+    grep -E '^(nfsnobody|_rpc|rpc|rpcuser):' "$dracutsysrootdir"/etc/passwd >> "$initdir/etc/passwd"
     grep -E '^nogroup:|^rpc:|^nobody:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
 
     dracut_need_initqueue
index 7896da9c028b1c71536ba31a46000c886bff610a..52fa97b505f282a8cad1c2f82d8603361117fe5a 100755 (executable)
@@ -155,3 +155,16 @@ mount_nfs() {
     fi
     mount -t "$nfs" -o"$options" "$server:$path" "$mntdir"
 }
+
+get_rpc_user() {
+    while read -r line; do
+        user="${line%%:*}"
+        case $user in
+            _rpc | rpc | rpcuser | nfsnobody)
+                echo "$user"
+                return
+                ;;
+        esac
+    done < /etc/passwd
+    echo "root"
+}
index 52f6a4dedd428dc6d5bd93b70ca77037c4ef8bfa..641a58d23acc13e07c1380162abeccef8265b09c 100755 (executable)
@@ -8,8 +8,9 @@ if load_fstype sunrpc rpc_pipefs; then
     # FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
     command -v portmap > /dev/null && [ -z "$(pidof portmap)" ] && portmap
     if command -v rpcbind > /dev/null && [ -z "$(pidof rpcbind)" ]; then
+        . /lib/nfs-lib.sh
         mkdir -p /run/rpcbind
-        chown rpc:rpc /run/rpcbind
+        chown "$(get_rpc_user):root" /run/rpcbind
         rpcbind
     fi
 
index a07c5f42de98fbae0c4c766b16d7a1e820ecf948..00497c2f51b5b688fa7887e694e20deedbea1861 100755 (executable)
@@ -126,5 +126,5 @@ echo '[ -e $NEWROOT/proc ]' > "$hookdir"/initqueue/finished/nfsroot.sh
 # rpc user needs to be able to write to this directory to save the warmstart
 # file
 mkdir -p /var/lib/rpcbind
-chown rpc:rpc /var/lib/rpcbind
+chown "$(get_rpc_user):root" /var/lib/rpcbind
 chmod 770 /var/lib/rpcbind