summaryrefslogtreecommitdiffstats
path: root/modules.d/95nfs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xmodules.d/95nfs/module-setup.sh2
-rwxr-xr-xmodules.d/95nfs/nfs-lib.sh13
-rwxr-xr-xmodules.d/95nfs/nfs-start-rpc.sh3
-rwxr-xr-xmodules.d/95nfs/nfsroot-cleanup.sh8
-rwxr-xr-xmodules.d/95nfs/parse-nfsroot.sh2
5 files changed, 21 insertions, 7 deletions
diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh
index abe1ee5..5cc4289 100755
--- a/modules.d/95nfs/module-setup.sh
+++ b/modules.d/95nfs/module-setup.sh
@@ -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
diff --git a/modules.d/95nfs/nfs-lib.sh b/modules.d/95nfs/nfs-lib.sh
index 7896da9..52fa97b 100755
--- a/modules.d/95nfs/nfs-lib.sh
+++ b/modules.d/95nfs/nfs-lib.sh
@@ -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"
+}
diff --git a/modules.d/95nfs/nfs-start-rpc.sh b/modules.d/95nfs/nfs-start-rpc.sh
index 52f6a4d..641a58d 100755
--- a/modules.d/95nfs/nfs-start-rpc.sh
+++ b/modules.d/95nfs/nfs-start-rpc.sh
@@ -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
diff --git a/modules.d/95nfs/nfsroot-cleanup.sh b/modules.d/95nfs/nfsroot-cleanup.sh
index d99519b..3b164de 100755
--- a/modules.d/95nfs/nfsroot-cleanup.sh
+++ b/modules.d/95nfs/nfsroot-cleanup.sh
@@ -16,12 +16,12 @@ pid=$(pidof rpcbind)
if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then
# try to create the destination directory
- [ -d "$NEWROOT"/$rpcpipefspath ] \
- || mkdir -m 0755 -p "$NEWROOT"/$rpcpipefspath 2> /dev/null
+ [ -d "$NEWROOT/$rpcpipefspath" ] \
+ || mkdir -m 0755 -p "$NEWROOT/$rpcpipefspath" 2> /dev/null
- if [ -d "$NEWROOT"/$rpcpipefspath ]; then
+ if [ -d "$NEWROOT/$rpcpipefspath" ]; then
# mount --move does not seem to work???
- mount --bind /var/lib/nfs/rpc_pipefs "$NEWROOT"/$rpcpipefspath
+ mount --bind /var/lib/nfs/rpc_pipefs "$NEWROOT/$rpcpipefspath"
umount /var/lib/nfs/rpc_pipefs 2> /dev/null
else
umount /var/lib/nfs/rpc_pipefs 2> /dev/null
diff --git a/modules.d/95nfs/parse-nfsroot.sh b/modules.d/95nfs/parse-nfsroot.sh
index a07c5f4..00497c2 100755
--- a/modules.d/95nfs/parse-nfsroot.sh
+++ b/modules.d/95nfs/parse-nfsroot.sh
@@ -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