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>
# 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
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"
+}
# 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
# 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