nfs-utils 2.5.4-31

- nfsdcld: prevent from accessing /var/lib/nfs/nfsdcld in read-only file
  system during boot
  Resolves: RHEL-78177
- Replace the functional gating tests with the ones from RHEL10
  Resolves: RHEL-78110
- Add explicit version requirement for libnfsidmap
  Resolves: RHEL-78107
- Add --disable-sbin-override for when /sbin is a symlink
  Resolves: RHEL-69771
- Move remaining binaries from /sbin to /usr/sbin
  Resolves: RHEL-69771

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
This commit is contained in:
Scott Mayhew 2025-02-06 16:41:00 -05:00
parent bc2d33c530
commit 917ca94bf1
6 changed files with 241 additions and 380 deletions

View File

@ -0,0 +1,89 @@
From 49822c2130a2a6e1d5a9e414f5a0726a461d9b00 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Mon, 25 Oct 2021 12:08:46 -0400
Subject: [nfs-utils PATCH] Add --disable-sbin-override for when /sbin is a
symlink
mount.nfs* umount.nfs* and nfsdcltrack are currently always installed in
/sbin.
Many distros are moving to a "merged /usr" where /sbin and others are
symlinks into /usr/sbin or similar. In these cases it is inelegant to
install in /sbin (i.e. install through a symlink).
So we add "--disable-sbin-override" as a configure option. This causes
the same sbindir to be used for *mount.nfs* and nfsdcltrack as for other
system binaries.
Note that autotools notices if we simply define "sbindir=/sbin"
inside an "if CONFIG_foo" clause, gives a warning, and defeats our
intent.
So instead, we use the @CONFIG_SBIN_OVERRIDE_TRUE@ prefix to find
the new declaration when we don't want it.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Steve Dickson <steved@redhat.com>
---
configure.ac | 6 ++++++
utils/mount/Makefile.am | 8 +++++---
utils/nfsdcltrack/Makefile.am | 9 ++++++---
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index bc2d0f02..93626d62 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,6 +187,12 @@ else
enable_libmount=no
fi
+AC_ARG_ENABLE(sbin-override,
+ [AC_HELP_STRING([--disable-sbin-override],
+ [Don't force nfsdcltrack and mount helpers into /sbin: always honour --sbindir])],
+ enable_sbin_override=$enableval,
+ enable_sbin_override=yes)
+ AM_CONDITIONAL(CONFIG_SBIN_OVERRIDE, [test "$enable_sbin_override" = "yes"])
AC_ARG_ENABLE(junction,
[AC_HELP_STRING([--enable-junction],
[enable support for NFS junctions @<:@default=no@:>@])],
diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am
index ad0be93b..3101f7ab 100644
--- a/utils/mount/Makefile.am
+++ b/utils/mount/Makefile.am
@@ -1,8 +1,10 @@
## Process this file with automake to produce Makefile.in
-# These binaries go in /sbin (not /usr/sbin), and that cannot be
-# overridden at config time.
-sbindir = /sbin
+# These binaries go in /sbin (not /usr/sbin), unless CONFIG_SBIN_OVERRIDE
+# is disabled as may be appropriate when /sbin is a symlink.
+# Note that we don't use "if CONFIG_SBIN_OVERRIDE" as that
+# causes autotools to notice the override and disable it.
+@CONFIG_SBIN_OVERRIDE_TRUE@sbindir = /sbin
man8_MANS = mount.nfs.man umount.nfs.man
man5_MANS = nfs.man
diff --git a/utils/nfsdcltrack/Makefile.am b/utils/nfsdcltrack/Makefile.am
index 2f7fe3de..769e4a45 100644
--- a/utils/nfsdcltrack/Makefile.am
+++ b/utils/nfsdcltrack/Makefile.am
@@ -1,8 +1,11 @@
## Process this file with automake to produce Makefile.in
-# These binaries go in /sbin (not /usr/sbin), and that cannot be
-# overridden at config time. The kernel "knows" the /sbin name.
-sbindir = /sbin
+# These binaries go in /sbin (not /usr/sbin) as the kernel "knows" the
+# /sbin name. If /sbin is a symlink, CONFIG_SBIN_OVERRIDE can be
+# disabled to install in /usr/sbin anyway.
+# Note that we don't use "if CONFIG_SBIN_OVERRIDE" as that
+# causes autotools to notice the override and disable it.
+@CONFIG_SBIN_OVERRIDE_TRUE@sbindir = /sbin
man8_MANS = nfsdcltrack.man
EXTRA_DIST = $(man8_MANS)
--
2.48.1

View File

@ -0,0 +1,39 @@
From 092971c4741814d831e8172eb3332e53aeaef890 Mon Sep 17 00:00:00 2001
From: Seiichi Ikarashi <s.ikarashi@fujitsu.com>
Date: Fri, 18 Oct 2024 08:29:57 -0400
Subject: [nfs-utils PATCH] nfsdcld: prevent from accessing
/var/lib/nfs/nfsdcld in read-only file system during boot
I saw a VMWare guest that hit a rare condition during boot;
nfsdcld started too early to check access on /var/lib/nfs/nfsdcld which were
still in read-only file system as follows:
nfsdcld[...]: Unexpected error when checking access on /var/lib/nfs/nfsdcld: Read-only file system
systemd[1]: nfsdcld.service: Main process exited, code=exited, status=226/NAMESPACE
systemd[1]: nfsdcld.service: Failed with result 'exit-code'.
nfsdcld.service needs to wait the root file system to be remounted at least.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Seiichi Ikarashi <s.ikarashi@fujitsu.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
---
systemd/nfsdcld.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/systemd/nfsdcld.service b/systemd/nfsdcld.service
index 3ced5658..188123df 100644
--- a/systemd/nfsdcld.service
+++ b/systemd/nfsdcld.service
@@ -4,7 +4,7 @@ Documentation=man:nfsdcld(8)
DefaultDependencies=no
Conflicts=umount.target
Requires=rpc_pipefs.target proc-fs-nfsd.mount
-After=rpc_pipefs.target proc-fs-nfsd.mount
+After=rpc_pipefs.target proc-fs-nfsd.mount systemd-remount-fs.service
[Service]
Type=forking
--
2.48.1

View File

@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser
Name: nfs-utils
URL: http://linux-nfs.org/
Version: 2.5.4
Release: 30%{?dist}
Release: 31%{?dist}
Epoch: 1
# group all 32bit related archs
@ -72,6 +72,8 @@ Patch028: nfs-utils-2.5.4-rpcidmapd-nfsopen-failure.patch
Patch029: nfs-utils-2.5.4-mount-writable.patch
Patch030: nfs-utils-2.5.4-mount-v3-retry.patch
Patch031: nfs-utils-2.5.4-conffile-argument.patch
Patch032: nfs-utils-2.5.4-add-disable-sbin-override.patch
Patch033: nfs-utils-2.5.4-fix-nfsdcld-starting-too-early.patch
Patch100: nfs-utils-1.2.1-statdpath-man.patch
Patch101: nfs-utils-1.2.1-exp-subtree-warn-off.patch
@ -113,7 +115,7 @@ Requires(pre): shadow-utils >= 4.0.3-25
Requires(pre): util-linux
Requires(pre): coreutils
Requires(preun): coreutils
Requires: libnfsidmap libevent
Requires: libnfsidmap%{?_isa} = %{epoch}:%{version}-%{release} libevent
Requires: libtirpc >= 0.2.3-1 libblkid libcap libmount
Requires: gssproxy => 0.7.0-3
Requires: rpcbind, sed, gawk, grep
@ -132,6 +134,7 @@ Provides: umount.nfs4 = %{epoch}:%{version}-%{release}
Provides: start-statd = %{epoch}:%{version}-%{release}
Provides: nfsidmap = %{epoch}:%{version}-%{release}
Provides: showmount = %{epoch}:%{version}-%{release}
Requires: libnfsidmap%{?_isa} = %{epoch}:%{version}-%{release}
Requires: rpcbind
%{?systemd_requires}
@ -156,6 +159,7 @@ Provides: mount.nfs4 = %{epoch}:%{version}-%{release}
Provides: umount.nfs = %{epoch}:%{version}-%{release}
Provides: umount.nfs4 = %{epoch}:%{version}-%{release}
Provides: nfsidmap = %{epoch}:%{version}-%{release}
Requires: libnfsidmap%{?_isa} = %{epoch}:%{version}-%{release}
Requires: gssproxy => 0.7.0-3
%description -n nfsv4-client-utils
@ -216,7 +220,8 @@ sh -x autogen.sh
--with-systemd \
--without-tcp-wrappers \
--with-pluginpath=%{_libdir}/libnfsidmap \
--enable-junction
--enable-junction \
--disable-sbin-override
%make_build all
@ -225,7 +230,6 @@ sh -x autogen.sh
rm -rf $RPM_BUILD_ROOT/*
mkdir -p $RPM_BUILD_ROOT/sbin
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
mkdir -p $RPM_BUILD_ROOT%{_libexecdir}/nfs-utils/
mkdir -p $RPM_BUILD_ROOT%{_pkgdir}/system
@ -253,7 +257,6 @@ rm -rf $RPM_BUILD_ROOT%{_libdir}/libnfsidmap/*.{a,la}
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/rpc_pipefs
touch $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/rmtab
mv $RPM_BUILD_ROOT%{_sbindir}/rpc.statd $RPM_BUILD_ROOT/sbin
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/statd/sm
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/statd/sm.bak
@ -377,8 +380,8 @@ fi
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/gssproxy/24-nfs-server.conf
%doc linux-nfs/ChangeLog linux-nfs/KNOWNBUGS linux-nfs/NEW linux-nfs/README
%doc linux-nfs/THANKS linux-nfs/TODO
/sbin/rpc.statd
/sbin/nfsdcltrack
%{_sbindir}/rpc.statd
%{_sbindir}/nfsdcltrack
%{_sbindir}/exportfs
%{_sbindir}/nfsstat
%{_sbindir}/rpcdebug
@ -404,11 +407,11 @@ fi
%{_mandir}/*/*
%{_pkgdir}/*/*
%attr(4755,root,root) /sbin/mount.nfs
%attr(4755,root,root) %{_sbindir}/mount.nfs
/sbin/mount.nfs4
/sbin/umount.nfs
/sbin/umount.nfs4
%{_sbindir}/mount.nfs4
%{_sbindir}/umount.nfs
%{_sbindir}/umount.nfs4
%files -n libnfsidmap
%doc support/nfsidmap/AUTHORS support/nfsidmap/README support/nfsidmap/COPYING
@ -439,11 +442,11 @@ fi
%{_sbindir}/showmount
%{_libexecdir}/nfsrahead
%{_udevrulesdir}/99-nfs.rules
%attr(4755,root,root) /sbin/mount.nfs
/sbin/mount.nfs4
/sbin/rpc.statd
/sbin/umount.nfs
/sbin/umount.nfs4
%attr(4755,root,root) %{_sbindir}/mount.nfs
%{_sbindir}/mount.nfs4
%{_sbindir}/rpc.statd
%{_sbindir}/umount.nfs
%{_sbindir}/umount.nfs4
%{_mandir}/*/nfs.5.gz
%{_mandir}/*/nfs.conf.5.gz
%{_mandir}/*/nfsmount.conf.5.gz
@ -481,10 +484,10 @@ fi
%{_sbindir}/nfsstat
%{_libexecdir}/nfsrahead
%{_udevrulesdir}/99-nfs.rules
%attr(4755,root,root) /sbin/mount.nfs
/sbin/mount.nfs4
/sbin/umount.nfs
/sbin/umount.nfs4
%attr(4755,root,root) %{_sbindir}/mount.nfs
%{_sbindir}/mount.nfs4
%{_sbindir}/umount.nfs
%{_sbindir}/umount.nfs4
%{_mandir}/*/nfs.5.gz
%{_mandir}/*/nfs.conf.5.gz
%{_mandir}/*/nfsmount.conf.5.gz
@ -513,6 +516,13 @@ fi
%{_mandir}/*/nfsiostat.8.gz
%changelog
* Thu Feb 6 2025 Scott Mayhew <smayhew@redhat.com> 2.5.4-31
- nfsdcld: prevent from accessing /var/lib/nfs/nfsdcld in read-only file system during boot (RHEL-78177)
- Replace functional gating tests with the ones from RHEL10 (RHEL-78110)
- Add explicit version requirement for libnfsidmap (RHEL-78107)
- Add --disable-sbin-override for when /sbin is a symlink (RHEL-69771)
- Move remaining binaries from /sbin to /usr/sbin (RHEL-69771)
* Mon Feb 3 2025 Scott Mayhew <smayhew@redhat.com> 2.5.4-30
- fix ownership of /var/lib/nfs/statd/state (RHEL-72823)
- /var/lib/nfs/{etab,rmtab} should not be marked as config files (RHEL-64340)

View File

@ -1,347 +0,0 @@
#!/bin/bash
# set -x # uncomment for debugging
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Description: Test for nfs mount options
# Author: Bill Peck <bpeck@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2006 Red Hat, Inc.
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#[ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh
#. /usr/share/beakerlib/beakerlib.sh || exit 1
#===============================================================================
TESTNAME=${TEST/*\//}
expdir=/exportdir/home
nfsmp=/mnt/$TESTNAME
ORIGINAL_HOSTNAME=$HOSTNAME
rlJournalStart
rlPhaseStartSetup do-$role-Setup-
# Load beakerlib you needed
rlImport kernel/base
envinfo
rlFileBackup /etc/sysconfig/nfs /etc/exports
if echo "$HOSTNAME" | grep -q "localhost"; then
# In case "localhost.localdomain"
hostnamectl set-hostname nfs-mount-options-all.test
HOSTNAME=nfs-mount-options-all.test
fi
run 'rm -rf $expdir $nfsmp && mkdir -p $expdir $nfsmp'
run 'chmod 777 $expdir'
run 'echo "$expdir *(rw,sync,no_root_squash)" >/etc/exports'
run 'service_nfs restart'
rlPhaseEnd
rlPhaseStartTest do-$role-Test-fg_bg_retry_devil
read IP4 _nil <<<$(getDefaultIp)
run 'iptables -F' -
MNT_OPTS="vers=3,soft,fg,retry=1"
log "{Info} Retry 1 minute (60s) NFS mount in *foreground* before giving up."
run 'iptables -A INPUT -s $IP4 -j DROP' -
run 'iptables -L' -
run 'sleep 10'
start_time=$(date +%s)
run "mount ${IP4}:$expdir $nfsmp -o ${MNT_OPTS}" 1-255
retry_time=$((`date +%s` - start_time))
log "{Info} Actually the nfs.mount hang $retry_time seconds."
run 'ps aux | grep -v grep | grep ${MNT_OPTS}' 1
run 'iptables -F' -
run 'ip6tables -F' -
run 'mountpoint $nfsmp && umount $nfsmp' 1
MNT_OPTS="vers=3,soft,bg,retry=1"
log "{Info} Retry 1 minute (60s) NFS mount in *background* before giving up."
run 'iptables -A INPUT -s $IP4 -j DROP' -
run 'iptables -L' -
run 'sleep 10'
# When background exit and fork an childprocess, still, returns 0
run "mount ${IP4}:$expdir $nfsmp -o ${MNT_OPTS}" 0 "should return ok"
if [ $? -eq 0 ]; then
# bg ground, the mount fork an child process
run 'ps aux | grep -v grep | grep ${MNT_OPTS}' 0 "works in bg.. show background process"
[ $? = 0 ] && {
log "{Info} We are sleeping a little longer than 60 seconds (retry=1)."
run "sleep $((retry_time + 10))" 0 "Actually a little more than $retry_time seconds."
# demo mounting process should exit after 60s as retry=1 (minute)
run 'ps aux | grep -v grep | grep ${MNT_OPTS}' 1 "retry=1 for 60s should works file after sleep 70s"
}
fi
run 'iptables -F' -
# should not mount successfully as it expired
run 'mountpoint $nfsmp && umount $nfsmp' 1
rlPhaseEnd
rlPhaseStartTest do-Test-retry-option-should-not-be-ignored
# test retry of the default value (2 minutes) for foreground - NFS(5)
run "service_nfs stop"
run "mount ${HOSTNAME}:$expdir $nfsmp &"
run "sleep 100 ; service_nfs start ; sleep 10"
run "nfsstat -m | grep $nfsmp" 0
[ $? = 0 ] && run "umount $nfsmp"
# test retry of 10 minutes for foreground
MNT_OPTS="retry=10"
log "\n{Info} ${MNT_OPTS}"
run "service_nfs stop"
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS} &"
run "sleep 10 ; service_nfs start ; sleep 10"
run "nfsstat -m | grep $nfsmp" 0
[ $? = 0 ] && run "umount $nfsmp"
# test retry of 100 minutes for background
MNT_OPTS="bg,retry=100"
log "\n{Info} ${MNT_OPTS}"
run "service_nfs stop"
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
run "sleep 10 ; service_nfs start ; sleep 10"
run "nfsstat -m | grep $nfsmp"
[ $? = 0 ] && run "umount $nfsmp"
# test retry of the default value (10000 minutes) for background - NFS(5)
MNT_OPTS="bg"
log "\n{Info} ${MNT_OPTS}"
run "service_nfs stop"
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
run "sleep 10 ; service_nfs start ; sleep 10"
run "nfsstat -m | grep $nfsmp"
[ $? = 0 ] && run "umount $nfsmp"
rlPhaseEnd
rlPhaseStartTest do-$role-Test-resvport_noresvport_test
run 'service_nfs restart'
MNT_OPTS="resvport"
log "{Info} ${MNT_OPTS}"
run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}' 0
run 'mountpoint $nfsmp && umount $nfsmp'
MNT_OPTS="noresvport"
log "{Info} ${MNT_OPTS}"
run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}' 1-255 "should got permission denied"
run 'mountpoint $nfsmp && umount $nfsmp' 1
rlPhaseEnd
rlPhaseStartTest do-$role-Test-cache_nocache_test
MNT_OPTS="noac"
log "\n{Info} ${MNT_OPTS}"
run 'chmod 777 $expdir'
run 'touch $expdir/foo.txt && chmod 777 $expdir/foo.txt'
run 'service_nfs restart'
run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}' 0
[ $? -eq 0 ] && {
ATTR_TMP1=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
chmod 666 $expdir/foo.txt
sleep 1
ATTR_TMP2=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
log "{Info} $ATTR_TMP1 ~ $ATTR_TMP2"
run "[ x"$ATTR_TMP1" != x"$ATTR_TMP2" ]" 0 "with noac, attribution should not cached"
}
run 'mountpoint $nfsmp && umount $nfsmp'
run 'rm -f $expdir/foo.txt'
MNT_OPTS="ac,acregmin=20,acregmax=40,acdirmin=30,acdirmax=60"
log "\n{Info} ${MNT_OPTS}"
run 'touch $expdir/foo.txt && chmod 777 $expdir/foo.txt'
run 'mkdir $expdir/foo.dir && chmod 777 $expdir/foo.dir'
run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}'
[ $? -eq 0 ] && {
ATTR_TMPREG1=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
ATTR_TMPDIR1=$(ls -al $nfsmp | grep foo.dir | awk '{ print $1 }')
chmod 666 $expdir/foo.txt
chmod 555 $expdir/foo.dir
sleep 7
ATTR_TMPREG2=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
sleep 7 #7+7
ATTR_TMPDIR2=$(ls -al $nfsmp | grep foo.dir | awk '{ print $1 }')
sleep 30 #7+7+30
ATTR_TMPREG3=$(ls -al $nfsmp | grep foo.txt | awk '{ print $1 }')
sleep 20 #7+7+30+20
ATTR_TMPDIR3=$(ls -al $nfsmp | grep foo.dir | awk '{ print $1 }')
log "{Info} Regfile Attribution: $ATTR_TMPREG1 ~ $ATTR_TMPREG2 ~ $ATTR_TMPREG3"
run '[ x"$ATTR_TMPREG1" == x"$ATTR_TMPREG2" -a x"$ATTR_TMPREG1" != x"$ATTR_TMPREG3" ]'
log "{Info} Directory Attribution: $ATTR_TMPDIR1 ~ $ATTR_TMPDIR2 ~ $ATTR_TMPDIR3"
run '[ x"$ATTR_TMPDIR1" == x"$ATTR_TMPDIR2" -a x"$ATTR_TMPDIR1" != x"$ATTR_TMPDIR3" ]'
}
run 'mountpoint $nfsmp && umount $nfsmp'
run 'rm -f $expdir/foo.txt'
run 'rm -rf $expdir/foo.dir'
MNT_OPTS="ac,actimeo=20"
log "\n{Info} ${MNT_OPTS}"
run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}'
[ $? -eq 0 ] && {
run 'grep ${TESTNAME} /proc/mounts | grep "acregmin=20" | grep "acregmax=20" | grep "acdirmin=20" | grep "acdirmax=20"'
}
run 'mountpoint $nfsmp && umount $nfsmp'
rlPhaseEnd
rlPhaseStartTest do-$role-Test-sharecache_nosharecache_test
MNT_OPTS="vers=3,nosharecache"
MNT_OPTS="nosharecache,ac,acregmin=30,acregmax=60"
log "\n{Info} ${MNT_OPTS}"
run 'chmod 777 $expdir'
run 'touch $expdir/foo.txt && chmod 777 $expdir/foo.txt'
run 'mkdir -p $nfsmp-{1,2}'
run 'service_nfs restart'
run 'mount ${HOSTNAME}:$expdir $nfsmp-1 -o ${MNT_OPTS} &&
mount ${HOSTNAME}:$expdir $nfsmp-2 -o ${MNT_OPTS}'
[ $? = 0 ] && {
chmod 555 $nfsmp-1/foo.txt
sleep 1
chmod 444 $nfsmp-2/foo.txt
ATTR_TMPREG1=$(ls -al $nfsmp-1 | grep foo.txt | awk '{ print $1 }')
ATTR_TMPREG2=$(ls -al $nfsmp-2 | grep foo.txt | awk '{ print $1 }')
ATTR_TMPREG3=$(ls -al $expdir/ | grep foo.txt | awk '{ print $1 }')
log "{Info} $ATTR_TMPREG1 ~ $ATTR_TMPREG2 ~ $ATTR_TMPREG3"
run '[ x"$ATTR_TMPREG1" == x"$ATTR_TMPREG2" -a x"$ATTR_TMPREG1" == x"$ATTR_TMPREG3" ]'
}
run 'mountpoint $nfsmp-1 && umount $nfsmp-1'
run 'mountpoint $nfsmp-2 && umount $nfsmp-2'
run 'rm -f $expdir/foo.txt'
run 'rm -rf $nfsmp-{1,2}'
rlPhaseEnd
rlPhaseStartTest do-$role-Test-lookupcache_test
MNT_OPTS="ac,acdirmin=30,acdirmax=60,lookupcache=pos"
log "\n{Info} ${MNT_OPTS}"
run 'chmod 777 $expdir'
run 'mkdir -p $expdir/foodir && touch $expdir/foodir/foo-1.txt'
run 'service_nfs restart'
run 'mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}'
[ $? = 0 ] && {
run 'ls -l $nfsmp/foodir/ | grep foo-1.txt'
run 'rm -f $expdir/foodir/foo-1.txt'
run 'sleep 1' -
log "{Info} Checking again..."
run 'ls -l $nfsmp/foodir/ | grep foo-1.txt' 1
run 'umount $nfsmp'
}
run 'rm -fr $expdir'
rlPhaseEnd
rlPhaseStartTest do-$role-Test-rsize-wsize
minSize=1024
minFixSize=4096
#maxSize=1048576
run "cat /proc/fs/nfsd/max_block_size" 0 "The default max block size varies depending on RAM size, with a maximum of 1M."
maxSize=$(cat /proc/fs/nfsd/max_block_size)
run 'mkdir -p $expdir'
run 'echo "$expdir *(rw,sync,no_root_squash)" > /etc/exports'
run 'service_nfs restart'
MNT_OPTS="rsize=1024,wsize=1024"
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
run 'grep $nfsmp /proc/mounts' -
run "cat /proc/mounts | grep -q $MNT_OPTS"
run 'umount $nfsmp'
MNT_OPTS="rsize=8192,wsize=8192"
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
run 'grep $nfsmp /proc/mounts' -
run "cat /proc/mounts | grep -q $MNT_OPTS"
run 'umount $nfsmp'
MNT_OPTS="rsize=1,wsize=255" # less than min_size($minSize)
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
run 'grep $nfsmp /proc/mounts' -
run "cat /proc/mounts | grep -q rsize=$minFixSize,wsize=$minFixSize" 0 "Specified values lower than $minSize are replaced with $minFixSize"
run 'umount $nfsmp'
MNT_OPTS="rsize=1048577,wsize=2048576" # great than max_size($maxSize)
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
run 'grep $nfsmp /proc/mounts' -
run "cat /proc/mounts | grep -q rsize=$maxSize,wsize=$maxSize" 0 "Specified values more than $maxSize are replaced with $maxSize"
run 'umount $nfsmp'
MNT_OPTS="rsize=0,wsize=0"
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}"
run 'grep $nfsmp /proc/mounts' -
run "cat /proc/mounts | grep -q rsize=$maxSize,wsize=$maxSize" 0 "Specified values more than $maxSize are replaced with $maxSize"
run 'umount $nfsmp'
MNT_OPTS="rsize=-1,wsize=-3"
run "mount ${HOSTNAME}:$expdir $nfsmp -o ${MNT_OPTS}" 1-255
rlPhaseEnd
for V in $(ls_nfsvers); do
rlPhaseStartTest do-$role-NFS-mount-options-can-be-lost-when-using-bg-option-vers${V}
run 'service_nfs stop'
run 'mount -v -t nfs -o rw,bg,hard,nointr,tcp,vers=$V,timeo=600,rsize=32768,wsize=32768,actimeo=0,noac localhost:$expdir $nfsmp'
run 'service_nfs start'
run 'while ! grep -q $nfsmp /proc/mounts; do sleep 15; done' -
run 'grep $nfsmp /proc/mounts'
run 'grep $nfsmp /proc/mounts | grep -q "rw,sync"'
if [ "$V" = "2" ]; then
run 'grep $nfsmp /proc/mounts | grep -q "vers=$V,rsize=8192,wsize=8192"'
else
run 'grep $nfsmp /proc/mounts | grep -q "vers=$V,rsize=32768,wsize=32768"'
fi
run 'grep $nfsmp /proc/mounts | grep -q "acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,hard,noac,proto=tcp"'
run 'grep $nfsmp /proc/mounts | grep -q "timeo=600,retrans=2,sec=sys"'
run "umount $nfsmp"
rlPhaseEnd
done
rlPhaseStartTest do-$role-Test-"mount-nfs-needs-descriptive-error-when-nfsvers-specified-incorrectly"
run "log=`mktemp -q`" 0 "Creating temporary log file"
log "{Info} Specify the invalid value."
for vers in {"v3","vers","+","*",""}; do
run "mount -t nfs -o vers=$vers localhost:$expdir $nfsmp 2>$log" 32 \
"should be failed as expected using invalid value"
run "mount -t nfs -o nfsvers=$vers localhost:$expdir $nfsmp 2>>$log" 32 \
"should be failed as expected using invalid value"
run "cat $log" -
run "egrep -q 'Bad nfs mount parameter|parsing error|invalid value' $log"
run ">$log" 0 "clear $log content"
done
log "{Info} Specify the valid number (maybe not supported)."
run "ls_nfsvers" -
for vers in {1,2,3,4,5,23}; do
if ls_nfsvers | grep -q "^$vers"; then
run "mount -t nfs -o vers=$vers localhost:$expdir $nfsmp"
run "umount $nfsmp"
run "mount -t nfs -o nfsvers=$vers localhost:$expdir $nfsmp"
run "umount $nfsmp"
else
run "mount -t nfs -o vers=$vers localhost:$expdir $nfsmp 2>$log" 32 \
"should be failed as expected using unsupported version"
[ $? = 0 ] && run "umount $nfsmp"
run "mount -t nfs -o nfsvers=$vers localhost:$expdir $nfsmp 2>>$log" 32 \
"should be failed as expected using unsupported version"
[ $? = 0 ] && run "umount $nfsmp"
run "cat $log" -
run "egrep -q 'not supported|parsing error|invalid value|call failed' $log"
run ">$log" 0 "clear $log content"
fi
done
run "rm -f $log" 0 "Remove temporary log file"
rlPhaseEnd
rlPhaseStartCleanup do-$role-Cleanup-
run 'mountpoint $nfsmp && umount $nfsmp' 1
hostnamectl set-hostname $ORIGINAL_HOSTNAME
run 'rm -rf $expdir $nfsmp'
rlFileRestore
run 'service_nfs restart'
rlPhaseEnd
rlJournalEnd
#rlJournalPrintText

79
tests/scripts/runtest.sh Normal file
View File

@ -0,0 +1,79 @@
#!/usr/bin/bash
MYHOSTNAME=$(hostnamectl hostname --static)
MYIP=$(ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p')
NFSVERS_LIST="4.2 4.1 4.0 3"
echo "Setup..."
cp /etc/exports /etc/exports.bak
cp /etc/nfs.conf /etc/nfs.conf.bak
mkdir -p /export_test /mnt_test
echo "nfs_test" > /export_test/testfile
systemctl start nfs-server
echo "Check export and mount"
echo "/export_test *(ro,insecure)" > /etc/exports
exportfs -a
showmount -e | grep -q export_test
[ $? -ne 0 ] && echo "Failed to export nfs" && exit 1
for VERS in $NFSVERS_LIST; do
for SERV in $MYHOSTNAME $MYIP; do
mount -t nfs -o vers=$VERS $SERV:/export_test /mnt_test
[ $? -ne 0 ] && echo "Failed to mount" && exit 1
cat /proc/mounts | grep -q mnt_test
[ $? -ne 0 ] && echo "Failed to find" && exit 1
umount /mnt_test
done
done
echo "Check simple IO"
exportfs -i -o rw,secure,no_root_squash *:/export_test
showmount -e | grep -q export_test
[ $? -ne 0 ] && echo "Failed to export nfs" && exit 1
for VERS in $NFSVERS_LIST; do
for SERV in $MYHOSTNAME $MYIP; do
mount -o nfsvers=$VERS $SERV:/export_test /mnt_test
[ $? -ne 0 ] && echo "Failed to mount" && exit 1
cat /proc/mounts | grep -q mnt_test
[ $? -ne 0 ] && echo "Failed to find" && exit 1
cat /mnt_test/testfile | grep -q nfs_test
[ $? -ne 0 ] && echo "Failed to read" && exit 1
date >> /mnt_test/testfile 2>/dev/null
[ $? -ne 0 ] && echo "Failed to write" && exit 1
umount /mnt_test
done
done
echo "Check nfs negotiation"
echo -e "[nfsd]\n vers3=y\n vers4=n" > /etc/nfs.conf
if [ -f /etc/nfsmount.conf.d/10-nfsv4.conf ]; then
mv /etc/nfsmount.conf.d/10-nfsv4.conf /etc/nfsmount.conf.d/10-nfsv4.conf.disabled
fi
systemctl restart nfs-server
showmount -e | grep -q export_test
[ $? -ne 0 ] && echo "Failed to export nfs" && exit 1
for SERV in $MYHOSTNAME $MYIP; do
mount.nfs4 $SERV:/export_test /mnt_test >/dev/null 2>&1
[ $? -eq 0 ] && echo "All v4 disabled but mounted" && exit 1
mount.nfs $SERV:/export_test /mnt_test
[ $? -ne 0 ] && echo "Failed to fallback" && exit 1
cat /proc/mounts | grep -q mnt_test
[ $? -ne 0 ] && echo "Failed to find" && exit 1
umount /mnt_test
done
echo "Success"
echo "Cleanup..."
exportfs -ua
showmount -e | grep -q export_test
[ $? -eq 0 ] && echo "Failed to unexport nfs" && exit 1
systemctl stop nfs-server
cp /etc/nfs.conf.bak /etc/nfs.conf
cp /etc/exports.bak /etc/exports
rm -rf /export_test /mnt_test
if [ -f /etc/nfsmount.conf.d/10-nfsv4.conf.disabled ]; then
mv /etc/nfsmount.conf.d/10-nfsv4.conf.disabled /etc/nfsmount.conf.d/10-nfsv4.conf
fi
exit 0

View File

@ -1,20 +1,11 @@
---
# Tests that run in classic context
- hosts: localhost
roles:
- role: standard-test-beakerlib
use_beakerlib_libraries: yes
- role: standard-test-basic
tags:
- classic
repositories:
- repo: "https://pkgs.devel.redhat.com/git/tests/nfs-utils"
dest: "tests"
tests:
- tests/commands/utils/umount/main.sh
- tests/commands/utils/exportfs/main.sh
- tests/commands/utils/mount/main.sh
- tests/services/systemd/nfs/main.sh
- tests/function/nfs-mount-options-all/main.sh
- simple:
dir: scripts
run: ./runtest.sh
required_packages:
- nfs-utils
- redhat-lsb-core # lsb_release is needed by tests