diff --git a/10-nfsv4.conf b/10-nfsv4.conf new file mode 100644 index 0000000000000000000000000000000000000000..03510d9a69383675ce70092ac7c8591c2ea45dd7 --- /dev/null +++ b/10-nfsv4.conf @@ -0,0 +1,9 @@ +[ NFSMount_Global_Options ] +# This statically named section defines global mount +# options that can be applied on all NFS mount. +# +# Setting this option makes it mandatory the server supports the +# given version. The mount will fail if the given version is +# not support by the server. +Nfsvers=4 + diff --git a/24-nfs-server.conf b/24-nfs-server.conf new file mode 100644 index 0000000000000000000000000000000000000000..5011e92fd9ef256d422e181565d491c2d33c0f6d --- /dev/null +++ b/24-nfs-server.conf @@ -0,0 +1,7 @@ +[service/nfs-server] + mechs = krb5 + socket = /run/gssproxy.sock + cred_store = keytab:/etc/krb5.keytab + trusted = yes + kernel_nfsd = yes + euid = 0 diff --git a/id_resolver.conf b/id_resolver.conf new file mode 100644 index 0000000000000000000000000000000000000000..67ccb185fddf6f1ad7c453f645b2414d100e8a67 --- /dev/null +++ b/id_resolver.conf @@ -0,0 +1,9 @@ +# +# nfsidmap(5) - The NFS idmapper upcall program +# Summary: Used by NFSv4 to map user/group ids into +# user/group names and names into in ids +# Options: +# -v Increases the verbosity of the output to syslog +# -t timeout Set the expiration timer, in seconds, on the key +# +create id_resolver * * /usr/sbin/nfsidmap %k %d diff --git a/lockd.conf b/lockd.conf new file mode 100644 index 0000000000000000000000000000000000000000..f672d12a5762f19f5e2e9a9819198edc17e3a7a7 --- /dev/null +++ b/lockd.conf @@ -0,0 +1,23 @@ +# +# Set the NFS lock manager grace period. n is measured in seconds. +#options lockd nlm_grace_period=90 +# +# Set the TCP port that the NFS lock manager should use. +# port must be a valid TCP port value (1-65535). +#options lockd nlm_tcpport +# +# Set the UDP port that the NFS lock manager should use. +# port must be a valid UDP port value (1-65535). +#options lockd nlm_udpport +# +# Set the maximum number of outstanding connections +#options lockd nlm_max_connections=1024 +# +# Set the default time value for the NFS lock manager +# in seconds. Default is 10 secs (min 3 max 20) +#options lockd nlm_timeout=10 +# +# Choose whether to record the caller_name or IP address +# this peer in the local rpc.statd's database. +#options lockd nsm_use_hostnames=0 + diff --git a/nfs-convert.service b/nfs-convert.service new file mode 100644 index 0000000000000000000000000000000000000000..3185ff196d8fe3c4ac84bd11ad16d1a6b3390f22 --- /dev/null +++ b/nfs-convert.service @@ -0,0 +1,22 @@ +[Unit] +Description=Preprocess NFS configuration convertion +DefaultDependencies=no + +Before=nfs-server.service nfs-mountd.service nfs-idmapd.service +Before=nfs-blkmap.service rpc-statd.service rpc-gssd.service +Before=rpc-statd-notify.service + +After=initrd-root-fs.target + +[Service] +Type=oneshot +ExecStart=/usr/libexec/nfs-utils/nfsconvert.sh + +[Install] +RequiredBy=nfs-server.service +RequiredBy=nfs-mountd.service +RequiredBy=nfs-idmapd.service +RequiredBy=nfs-blkmap.service +RequiredBy=rpc-statd.service +RequiredBy=rpc-gssd.service +RequiredBy=rpc-statd-notify.service diff --git a/nfs-utils-2.3.1-systemd-gssproxy-restart.patch b/nfs-utils-2.3.1-systemd-gssproxy-restart.patch new file mode 100644 index 0000000000000000000000000000000000000000..08b8dd15728bcbc2bf38b02ca76ca39625f6d4df --- /dev/null +++ b/nfs-utils-2.3.1-systemd-gssproxy-restart.patch @@ -0,0 +1,11 @@ +diff -up nfs-utils-2.5.2/systemd/nfs-server.service.orig nfs-utils-2.5.2/systemd/nfs-server.service +--- nfs-utils-2.5.2/systemd/nfs-server.service.orig 2020-12-16 12:31:27.677558163 -0500 ++++ nfs-utils-2.5.2/systemd/nfs-server.service 2020-12-16 12:33:56.751806659 -0500 +@@ -23,6 +23,7 @@ Type=oneshot + RemainAfterExit=yes + ExecStartPre=-/usr/sbin/exportfs -r + ExecStart=/usr/sbin/rpc.nfsd ++ExecStart=-/bin/sh -c 'if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi' + ExecStop=/usr/sbin/rpc.nfsd 0 + ExecStopPost=/usr/sbin/exportfs -au + ExecStopPost=/usr/sbin/exportfs -f diff --git a/nfs-utils-2.3.3-nfsconf-usegssproxy.patch b/nfs-utils-2.3.3-nfsconf-usegssproxy.patch new file mode 100644 index 0000000000000000000000000000000000000000..d87ae7d0d7797e647e5ca0a89e8074945c8dbea2 --- /dev/null +++ b/nfs-utils-2.3.3-nfsconf-usegssproxy.patch @@ -0,0 +1,21 @@ +diff -up nfs-utils-2.3.4/nfs.conf.orig nfs-utils-2.3.4/nfs.conf +--- nfs-utils-2.3.4/nfs.conf.orig 2019-05-10 14:49:49.000000000 -0400 ++++ nfs-utils-2.3.4/nfs.conf 2019-05-10 14:58:20.198714920 -0400 +@@ -13,7 +13,7 @@ + # rpc-verbosity=0 + # use-memcache=0 + # use-machine-creds=1 +-# use-gss-proxy=0 ++use-gss-proxy=1 + # avoid-dns=1 + # limit-to-legacy-enctypes=0 + # context-timeout=0 +@@ -77,6 +77,5 @@ + # outgoing-port= + # outgoing-addr= + # lift-grace=y +-# +-[svcgssd] +-# principal= ++ ++#tag1234 - Used for install purposes only diff --git a/nfs-utils-2.4.2-systemd-svcgssd.patch b/nfs-utils-2.4.2-systemd-svcgssd.patch new file mode 100644 index 0000000000000000000000000000000000000000..cdda81705adb52e581123e91b326da28f601ac4f --- /dev/null +++ b/nfs-utils-2.4.2-systemd-svcgssd.patch @@ -0,0 +1,14 @@ +diff -up nfs-utils-2.4.2/systemd/auth-rpcgss-module.service.orig nfs-utils-2.4.2/systemd/auth-rpcgss-module.service +--- nfs-utils-2.4.2/systemd/auth-rpcgss-module.service.orig 2019-11-13 12:09:41.000000000 -0500 ++++ nfs-utils-2.4.2/systemd/auth-rpcgss-module.service 2019-12-18 11:32:04.656735515 -0500 +@@ -7,8 +7,8 @@ + [Unit] + Description=Kernel Module supporting RPCSEC_GSS + DefaultDependencies=no +-Before=gssproxy.service rpc-svcgssd.service rpc-gssd.service +-Wants=gssproxy.service rpc-svcgssd.service rpc-gssd.service ++Before=gssproxy.service rpc-gssd.service ++Wants=gssproxy.service rpc-gssd.service + ConditionPathExists=/etc/krb5.keytab + + [Service] diff --git a/nfs-utils-2.6.1-overflow.patch b/nfs-utils-2.6.1-overflow.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f90bb484d88d56ad342aba4f7c9ba3f797e5ac0 --- /dev/null +++ b/nfs-utils-2.6.1-overflow.patch @@ -0,0 +1,31 @@ +commit 7f8463fe702174bd613df9d308cc899af25ae02e +Author: Steve Dickson +Date: Wed Feb 23 15:19:51 2022 -0500 + + systemd: Fix format-overflow warning + + rpc-pipefs-generator.c:35:23: error: '%s' directive output between 0 and 2147483653 bytes may exceed minimum required size of 4095 [-Werror=format-overflow=] + 35 | sprintf(path, "%s/%s", dirname, pipefs_unit); + | ^ + + Signed-off-by: Steve Dickson + +diff --git a/systemd/rpc-pipefs-generator.c b/systemd/rpc-pipefs-generator.c +index c24db56..7b2bb4f 100644 +--- a/systemd/rpc-pipefs-generator.c ++++ b/systemd/rpc-pipefs-generator.c +@@ -28,11 +28,12 @@ static int generate_mount_unit(const char *pipefs_path, const char *pipefs_unit, + { + char *path; + FILE *f; ++ size_t size = (strlen(dirname) + 1 + strlen(pipefs_unit)); + +- path = malloc(strlen(dirname) + 1 + strlen(pipefs_unit)); ++ path = malloc(size); + if (!path) + return 1; +- sprintf(path, "%s/%s", dirname, pipefs_unit); ++ snprintf(path, size, "%s/%s", dirname, pipefs_unit); + f = fopen(path, "w"); + if (!f) + { diff --git a/nfs-utils-2.6.1.tar.xz b/nfs-utils-2.6.1.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..baafb1d867577fa1c9d7536bec21bb372edd8960 Binary files /dev/null and b/nfs-utils-2.6.1.tar.xz differ diff --git a/nfs-utils.spec b/nfs-utils.spec new file mode 100644 index 0000000000000000000000000000000000000000..6db5f433e3192123000bdfa334c00f6f44d04ae7 --- /dev/null +++ b/nfs-utils.spec @@ -0,0 +1,451 @@ +%define anolis_release 1 +Summary: NFS utilities and supporting clients and daemons for the kernel NFS server +Name: nfs-utils +URL: http://linux-nfs.org/ +Version: 2.6.1 +Release: %{anolis_release}%{?dist} +Epoch: 1 + +Source0: https://www.kernel.org/pub/linux/utils/nfs-utils/%{version}/%{name}-%{version}.tar.xz +Source1: id_resolver.conf +Source2: lockd.conf +Source3: 24-nfs-server.conf +Source4: nfsconvert.py +Source5: nfsconvert.sh +Source6: nfs-convert.service +Source7: 10-nfsv4.conf + +Patch001: nfs-utils-2.6.1-overflow.patch + +Patch101: nfs-utils-2.3.1-systemd-gssproxy-restart.patch +Patch102: nfs-utils-2.3.3-nfsconf-usegssproxy.patch +Patch103: nfs-utils-2.4.2-systemd-svcgssd.patch + +Provides: exportfs = %{epoch}:%{version}-%{release} +Provides: nfsstat = %{epoch}:%{version}-%{release} +Provides: showmount = %{epoch}:%{version}-%{release} +Provides: rpcdebug = %{epoch}:%{version}-%{release} +Provides: rpc.idmapd = %{epoch}:%{version}-%{release} +Provides: rpc.mountd = %{epoch}:%{version}-%{release} +Provides: rpc.nfsd = %{epoch}:%{version}-%{release} +Provides: rpc.statd = %{epoch}:%{version}-%{release} +Provides: rpc.gssd = %{epoch}:%{version}-%{release} +Provides: mount.nfs = %{epoch}:%{version}-%{release} +Provides: mount.nfs4 = %{epoch}:%{version}-%{release} +Provides: umount.nfs = %{epoch}:%{version}-%{release} +Provides: umount.nfs4 = %{epoch}:%{version}-%{release} +Provides: sm-notify = %{epoch}:%{version}-%{release} +Provides: start-statd = %{epoch}:%{version}-%{release} + +License: MIT and GPLv2 and GPLv2+ and BSD +BuildRequires: make +BuildRequires: libevent-devel libcap-devel libuuid-devel +BuildRequires: libtirpc-devel libblkid-devel +BuildRequires: krb5-libs >= 1.4 autoconf >= 2.57 openldap-devel >= 2.2 +BuildRequires: automake, libtool, gcc, device-mapper-devel +BuildRequires: krb5-devel, libmount-devel, libxml2-devel +BuildRequires: sqlite-devel +BuildRequires: python3-devel +BuildRequires: systemd +BuildRequires: rpcgen +Requires(pre): shadow-utils >= 4.0.3-25 +Requires(pre): util-linux +Requires(pre): coreutils +Requires(preun): coreutils +Requires: libnfsidmap libevent +Requires: libtirpc >= 0.2.3-1 libblkid libcap libmount +Requires: gssproxy => 0.7.0-3 +Requires: rpcbind, sed, gawk, grep +Requires: kmod, keyutils, quota +%{?systemd_requires} + +%package -n nfs-utils-coreos +Summary: Minimal NFS utilities for supporting clients +Provides: nfsstat = %{epoch}:%{version}-%{release} +Provides: rpc.statd = %{epoch}:%{version}-%{release} +Provides: rpc.gssd = %{epoch}:%{version}-%{release} +Provides: mount.nfs = %{epoch}:%{version}-%{release} +Provides: mount.nfs4 = %{epoch}:%{version}-%{release} +Provides: umount.nfs = %{epoch}:%{version}-%{release} +Provides: umount.nfs4 = %{epoch}:%{version}-%{release} +Provides: start-statd = %{epoch}:%{version}-%{release} +Provides: nfsidmap = %{epoch}:%{version}-%{release} +Provides: showmount = %{epoch}:%{version}-%{release} +Requires: rpcbind +%{?systemd_requires} + +%description -n nfs-utils-coreos +Minimal NFS utilities for supporting clients + +%package -n nfs-stats-utils +Summary: NFS utilities for supporting clients +Provides: nfsstat = %{epoch}:%{version}-%{release} +Provides: mountstats = %{epoch}:%{version}-%{release} +Provides: nfsiostat = %{epoch}:%{version}-%{release} + +%description -n nfs-stats-utils +Show NFS client Statistics + +%package -n nfsv4-client-utils +Summary: NFSv4 utilities for supporting client +Provides: rpc.gssd = %{epoch}:%{version}-%{release} +Provides: mount.nfs = %{epoch}:%{version}-%{release} +Provides: mount.nfs4 = %{epoch}:%{version}-%{release} +Provides: umount.nfs = %{epoch}:%{version}-%{release} +Provides: umount.nfs4 = %{epoch}:%{version}-%{release} +Provides: nfsidmap = %{epoch}:%{version}-%{release} +Requires: gssproxy => 0.7.0-3 + +%description -n nfsv4-client-utils +The nfsv4-client-utils packages provided NFSv4 client support + +%package -n libnfsidmap +Summary: NFSv4 User and Group ID Mapping Library +Provides: libnfsidmap%{?_isa} = %{epoch}:%{version}-%{release} +License: BSD +BuildRequires: pkgconfig, openldap-devel +BuildRequires: automake, libtool +Requires: openldap + +%description -n libnfsidmap +Library that handles mapping between names and ids for NFSv4. + +%package -n libnfsidmap-devel +Summary: Development files for the libnfsidmap library +Requires: libnfsidmap%{?_isa} = %{epoch}:%{version}-%{release} +Requires: pkgconfig + +%description -n libnfsidmap-devel +This package includes header files and libraries necessary for +developing programs which use the libnfsidmap library. + + +%description +The nfs-utils package provides a daemon for the kernel NFS server and +related tools, which provides a much higher level of performance than the +traditional Linux NFS server used by most users. + +This package also contains the showmount program. Showmount queries the +mount daemon on a remote host for information about the NFS (Network File +System) server on the remote host. For example, showmount can display the +clients which are mounted on that host. + +This package also contains the mount.nfs and umount.nfs program. + +%prep +%autosetup -p1 + +# Remove .orig files +find . -name "*.orig" | xargs rm -f + +# Change shebangs +find -name \*.py -exec sed -r -i '1s|^#!\s*/usr/bin.*python.*|#!%{__python3}|' {} \; + +%build +sh -x autogen.sh +%global _statdpath /var/lib/nfs/statd +%configure \ + CFLAGS="%{build_cflags} -D_FILE_OFFSET_BITS=64" \ + LDFLAGS="%{build_ldflags}" \ + --enable-mountconfig \ + --enable-ipv6 \ + --with-statdpath=%{_statdpath} \ + --enable-libmount-mount \ + --with-systemd \ + --without-tcp-wrappers \ + --with-pluginpath=%{_libdir}/libnfsidmap \ + --enable-junction + +%make_build all + +%install +%global _pkgdir %{_prefix}/lib/systemd + +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 +mkdir -p $RPM_BUILD_ROOT%{_pkgdir}/system-generators +mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man8 +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/request-key.d +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/ +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/gssproxy + +%make_install + +install -s -m 755 tools/rpcdebug/rpcdebug $RPM_BUILD_ROOT%{_sbindir} +install -m 644 utils/mount/nfsmount.conf $RPM_BUILD_ROOT%{_sysconfdir} +install -m 644 nfs.conf $RPM_BUILD_ROOT%{_sysconfdir} +install -m 644 support/nfsidmap/idmapd.conf $RPM_BUILD_ROOT%{_sysconfdir} +install -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/request-key.d + +mkdir -p $RPM_BUILD_ROOT/run/sysconfig +install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/lockd.conf +install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/gssproxy +install -m 755 %{SOURCE4} $RPM_BUILD_ROOT%{_sbindir}/nfsconvert +install -m 755 %{SOURCE5} $RPM_BUILD_ROOT/%{_libexecdir}/nfs-utils/nfsconvert.sh +install -m 644 %{SOURCE6} $RPM_BUILD_ROOT%{_pkgdir}/system + +rm -rf $RPM_BUILD_ROOT%{_libdir}/*.{a,la} +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 +mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/nfs/v4recovery +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/exports.d + +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/nfsmount.conf.d +install -m 644 %{SOURCE7} $RPM_BUILD_ROOT%{_sysconfdir}/nfsmount.conf.d + + +%pre +# move files so the running service will have this applied as well +for x in gssd idmapd ; do + if [ -f /var/lock/subsys/rpc.$x ]; then + mv /var/lock/subsys/rpc.$x /var/lock/subsys/rpc$x + fi +done + +%global rpcuser_uid 29 +# Create rpcuser gid as long as it does not already exist +cat /etc/group | cut -d':' -f 1 | grep --quiet rpcuser 2>/dev/null +if [ "$?" -eq 1 ]; then + /usr/sbin/groupadd -g %{rpcuser_uid} rpcuser >/dev/null 2>&1 || : +fi + +# Create rpcuser uid as long as it does not already exist. +cat /etc/passwd | cut -d':' -f 1 | grep --quiet rpcuser 2>/dev/null +if [ "$?" -eq 1 ]; then + /usr/sbin/useradd -l -c "RPC Service User" -r -g %{rpcuser_uid} \ + -s /sbin/nologin -u %{rpcuser_uid} -d /var/lib/nfs rpcuser >/dev/null 2>&1 || : +else + /usr/sbin/usermod -u %{rpcuser_uid} -g %{rpcuser_uid} rpcuser >/dev/null 2>&1 || : +fi + +# Using the 16-bit value of -2 for the nfsnobody uid and gid +%global nfsnobody_uid 65534 + +# Nowadays 'nobody/65534' user/group are included in setup rpm. But on +# systems installed previously, nobody/99 might be present, with user +# 65534 missing. Let's create nfsnobody/65534 in that case. + +# Create nfsnobody gid as long as it does not already exist +cat /etc/group | cut -d':' -f 3 | grep --quiet %{nfsnobody_uid} 2>/dev/null +if [ "$?" -eq 1 ]; then + /usr/sbin/groupadd -g %{nfsnobody_uid} nfsnobody >/dev/null 2>&1 || : +fi + +# Create nfsnobody uid as long as it does not already exist. +cat /etc/passwd | cut -d':' -f 3 | grep --quiet %{nfsnobody_uid} 2>/dev/null +if [ $? -eq 1 ]; then + /usr/sbin/useradd -l -c "Anonymous NFS User" -r -g %{nfsnobody_uid} \ + -s /sbin/nologin -u %{nfsnobody_uid} -d /var/lib/nfs nfsnobody >/dev/null 2>&1 || : +fi + +%post +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl enable nfs-client.target >/dev/null 2>&1 || : + /bin/systemctl start nfs-client.target >/dev/null 2>&1 || : +fi + +# Enable nfs-convert so if an old configuration +# exists a conversion will occur +/bin/systemctl enable nfs-convert >/dev/null 2>&1 || : + +%systemd_post nfs-server + +%post -n nfsv4-client-utils +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl enable nfs-client.target >/dev/null 2>&1 || : + /bin/systemctl start nfs-client.target >/dev/null 2>&1 || : +fi + +%preun +if [ $1 -eq 0 ]; then + %systemd_preun nfs-client.target + %systemd_preun nfs-server.service + + rm -rf /var/lib/nfs/statd + rm -rf /var/lib/nfs/v4recovery +fi + +%preun -n nfsv4-client-utils +if [ $1 -eq 0 ]; then + %systemd_preun nfs-client.target + + rm -rf /etc/nfsmount.conf.d + rm -rf /var/lib/nfs/v4recovery +fi + +%postun +%systemd_postun_with_restart nfs-client.target +%systemd_postun_with_restart nfs-server + +%postun -n nfsv4-client-utils +%systemd_postun_with_restart nfs-client.target + +/bin/systemctl --system daemon-reload >/dev/null 2>&1 || : + +%triggerin -- nfs-utils > 1:2.1.1-3 +/bin/systemctl try-restart gssproxy || : + +%files +%config(noreplace) /etc/nfsmount.conf +%dir %{_sysconfdir}/exports.d +%dir %{_sharedstatedir}/nfs/v4recovery +%dir %attr(555, root, root) %{_sharedstatedir}/nfs/rpc_pipefs +%dir %{_sharedstatedir}/nfs +%dir %{_libexecdir}/nfs-utils +%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd +%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd/sm +%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd/sm.bak +%ghost %attr(644,rpcuser,rpcuser) %{_statdpath}/state +%config(noreplace) %{_sharedstatedir}/nfs/etab +%config(noreplace) %{_sharedstatedir}/nfs/rmtab +%config(noreplace) %{_sysconfdir}/request-key.d/id_resolver.conf +%config(noreplace) %{_sysconfdir}/modprobe.d/lockd.conf +%config(noreplace) %{_sysconfdir}/nfs.conf +%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}/exportfs +%{_sbindir}/nfsstat +%{_sbindir}/rpcdebug +%{_sbindir}/rpc.mountd +%{_sbindir}/rpc.nfsd +%{_sbindir}/showmount +%{_sbindir}/rpc.idmapd +%{_sbindir}/rpc.gssd +%{_sbindir}/sm-notify +%{_sbindir}/start-statd +%{_sbindir}/mountstats +%{_sbindir}/nfsiostat +%{_sbindir}/nfsidmap +%{_sbindir}/blkmapd +%{_sbindir}/nfsconf +%{_sbindir}/nfsref +%{_sbindir}/nfsconvert +%{_sbindir}/nfsdcld +%{_sbindir}/nfsdclddb +%{_sbindir}/nfsdclnts +%{_mandir}/*/* +%{_pkgdir}/*/* + +%attr(4755,root,root) /sbin/mount.nfs +%attr(755,root,root) %{_libexecdir}/nfs-utils/nfsconvert.sh + +/sbin/mount.nfs4 +/sbin/umount.nfs +/sbin/umount.nfs4 + +%files -n libnfsidmap +%doc support/nfsidmap/AUTHORS support/nfsidmap/README support/nfsidmap/COPYING +%config(noreplace) %{_sysconfdir}/idmapd.conf +%{_libdir}/libnfsidmap.so.* +%{_libdir}/libnfsidmap/*.so +%{_mandir}/man3/nfs4_uid_to_name.* + +%files -n libnfsidmap-devel +%{_libdir}/pkgconfig/libnfsidmap.pc +%{_includedir}/nfsidmap.h +%{_includedir}/nfsidmap_plugin.h +%{_libdir}/libnfsidmap.so + +%files -n nfs-utils-coreos +%dir %attr(555, root, root) %{_sharedstatedir}/nfs/rpc_pipefs +%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd +%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd/sm +%dir %attr(700,rpcuser,rpcuser) %{_sharedstatedir}/nfs/statd/sm.bak +%ghost %attr(644,rpcuser,rpcuser) %{_statdpath}/state +%config(noreplace) %{_sysconfdir}/nfsmount.conf +%config(noreplace) %{_sysconfdir}/nfs.conf +%config(noreplace) %{_sysconfdir}/request-key.d/id_resolver.conf +%{_sbindir}/nfsidmap +%{_sbindir}/nfsstat +%{_sbindir}/rpc.gssd +%{_sbindir}/start-statd +%{_sbindir}/showmount +%attr(4755,root,root) /sbin/mount.nfs +/sbin/mount.nfs4 +/sbin/rpc.statd +/sbin/umount.nfs +/sbin/umount.nfs4 +%{_mandir}/*/nfs.5.gz +%{_mandir}/*/nfs.conf.5.gz +%{_mandir}/*/nfsmount.conf.5.gz +%{_mandir}/*/nfs.systemd.7.gz +%{_mandir}/*/gssd.8.gz +%{_mandir}/*/mount.nfs.8.gz +%{_mandir}/*/nfsconf.8.gz +%{_mandir}/*/nfsidmap.8.gz +%{_mandir}/*/nfsstat.8.gz +%{_mandir}/*/rpc.gssd.8.gz +%{_mandir}/*/rpc.statd.8.gz +%{_mandir}/*/showmount.8.gz +%{_mandir}/*/statd.8.gz +%{_mandir}/*/umount.nfs.8.gz +%{_pkgdir}/*/rpc-pipefs-generator +%{_pkgdir}/*/auth-rpcgss-module.service +%{_pkgdir}/*/nfs-client.target +%{_pkgdir}/*/rpc-gssd.service +%{_pkgdir}/*/rpc-statd.service +%{_pkgdir}/*/rpc_pipefs.target +%{_pkgdir}/*/var-lib-nfs-rpc_pipefs.mount + +%files -n nfsv4-client-utils +%config(noreplace) /etc/nfsmount.conf +%dir %{_sharedstatedir}/nfs/v4recovery +%dir %attr(555, root, root) %{_sharedstatedir}/nfs/rpc_pipefs +%dir %{_libexecdir}/nfs-utils +%config(noreplace) %{_sysconfdir}/request-key.d/id_resolver.conf +%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/gssproxy/24-nfs-server.conf +%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/nfsmount.conf.d/10-nfsv4.conf +%{_sbindir}/rpc.gssd +%{_sbindir}/nfsidmap +%{_sbindir}/nfsconvert +%{_sbindir}/nfsstat +%attr(755,root,root) %{_libexecdir}/nfs-utils/nfsconvert.sh +%attr(4755,root,root) /sbin/mount.nfs +/sbin/mount.nfs4 +/sbin/umount.nfs +/sbin/umount.nfs4 +%{_mandir}/*/nfs.5.gz +%{_mandir}/*/nfs.conf.5.gz +%{_mandir}/*/nfsmount.conf.5.gz +%{_mandir}/*/gssd.8.gz +%{_mandir}/*/mount.nfs.8.gz +%{_mandir}/*/nfsconf.8.gz +%{_mandir}/*/nfsidmap.8.gz +%{_mandir}/*/rpc.gssd.8.gz +%{_mandir}/*/mount.nfs.8.gz +%{_mandir}/*/umount.nfs.8.gz +%{_mandir}/*/nfsidmap.8.gz +%{_mandir}/*/nfsstat.8.gz +%{_pkgdir}/*/rpc-pipefs-generator +%{_pkgdir}/*/auth-rpcgss-module.service +%{_pkgdir}/*/nfs-client.target +%{_pkgdir}/*/nfs-convert.service +%{_pkgdir}/*/rpc-gssd.service +%{_pkgdir}/*/rpc_pipefs.target +%{_pkgdir}/*/var-lib-nfs-rpc_pipefs.mount + +%files -n nfs-stats-utils +%{_sbindir}/mountstats +%{_sbindir}/nfsiostat +%{_mandir}/*/mountstats.8.gz +%{_mandir}/*/nfsiostat.8.gz + +%changelog +* Wed Mar 09 2022 Chunmei Xu 2.6.1-1 +- init from usptream 2.6.1 diff --git a/nfsconvert.py b/nfsconvert.py new file mode 100644 index 0000000000000000000000000000000000000000..dd240ee0fd72a3ed285e8587e23492d3010f4ebc --- /dev/null +++ b/nfsconvert.py @@ -0,0 +1,310 @@ +#!/usr/bin/env python3 +""" +Read in the deprecated /etc/sysconfig/nfs file and +set the corresponding values in nfs.conf +""" + +from __future__ import print_function +import os +import sys +import getopt +import subprocess +import configparser + +CONF_NFS = '/etc/nfs.conf' +CONF_IDMAP = '/etc/idmapd.conf' +SYSCONF_NFS = '/etc/sysconfig/nfs' +SYSCONF_BACKUP = ".rpmsave" +CONF_TOOL = '/usr/sbin/nfsconf' + +# options for nfsd found in RPCNFSDARGS +OPTS_NFSD = 'dH:p:rR:N:V:stTuUG:L:' +LONG_NFSD = ['debug', 'host=', 'port=', 'rdma=', 'nfs-version=', 'no-nfs-version=', + 'tcp', 'no-tcp', 'udp', 'no-udp', 'grace-time=', 'lease-time='] +CONV_NFSD = {'-d': (CONF_NFS, 'nfsd', 'debug', 'all'), + '-H': (CONF_NFS, 'nfsd', 'host', ','), + '-p': (CONF_NFS, 'nfsd', 'port', '$1'), + '-r': (CONF_NFS, 'nfsd', 'rdma', 'nfsrdma'), + '-R': (CONF_NFS, 'nfsd', 'rdma', '$1'), + '-N': (CONF_NFS, 'nfsd', 'vers$1', 'n'), + '-V': (CONF_NFS, 'nfsd', 'vers$1', 'y'), + '-t': (CONF_NFS, 'nfsd', 'tcp', '1'), + '-T': (CONF_NFS, 'nfsd', 'tcp', '0'), + '-u': (CONF_NFS, 'nfsd', 'udp', '1'), + '-U': (CONF_NFS, 'nfsd', 'udp', '0'), + '-G': (CONF_NFS, 'nfsd', 'grace-time', '$1'), + '-L': (CONF_NFS, 'nfsd', 'lease-time', '$1'), + '$1': (CONF_NFS, 'nfsd', 'threads', '$1'), + '--debug': (CONF_NFS, 'nfsd', 'debug', 'all'), + '--host': (CONF_NFS, 'nfsd', 'host', ','), + '--port': (CONF_NFS, 'nfsd', 'port', '$1'), + '--rdma': (CONF_NFS, 'nfsd', 'rdma', '$1'), + '--no-nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'n'), + '--nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'y'), + '--tcp': (CONF_NFS, 'nfsd', 'tcp', '1'), + '--no-tcp': (CONF_NFS, 'nfsd', 'tcp', '0'), + '--udp': (CONF_NFS, 'nfsd', 'udp', '1'), + '--no-udp': (CONF_NFS, 'nfsd', 'udp', '0'), + '--grace-time': (CONF_NFS, 'nfsd', 'grace-time', '$1'), + '--lease-time': (CONF_NFS, 'nfsd', 'lease-time', '$1'), + } + +# options for mountd found in RPCMOUNTDOPTS +OPTS_MOUNTD = 'go:d:H:p:N:nrs:t:V:' +LONG_MOUNTD = ['descriptors=', 'debug=', 'nfs-version=', 'no-nfs-version=', + 'port=', 'no-tcp', 'ha-callout=', 'state-directory-path=', + 'num-threads=', 'reverse-lookup', 'manage-gids', 'no-udp'] + +CONV_MOUNTD = {'-g': (CONF_NFS, 'mountd', 'manage-gids', '1'), + '-o': (CONF_NFS, 'mountd', 'descriptors', '$1'), + '-d': (CONF_NFS, 'mountd', 'debug', '$1'), + '-H': (CONF_NFS, 'mountd', 'ha-callout', '$1'), + '-p': (CONF_NFS, 'mountd', 'port', '$1'), + '-N': (CONF_NFS, 'nfsd', 'vers$1', 'n'), + '-V': (CONF_NFS, 'nfsd', 'vers$1', 'y'), + '-n': (CONF_NFS, 'nfsd', 'tcp', '0'), + '-s': (CONF_NFS, 'mountd', 'stat-directory-path', '$1'), + '-t': (CONF_NFS, 'mountd', 'threads', '$1'), + '-r': (CONF_NFS, 'mountd', 'reverse-lookup', '1'), + '-u': (CONF_NFS, 'nfsd', 'udp', '0'), + '--manage-gids': (CONF_NFS, 'mountd', 'manage-gids', '1'), + '--descriptors': (CONF_NFS, 'mountd', 'descriptors', '$1'), + '--debug': (CONF_NFS, 'mountd', 'debug', '$1'), + '--ha-callout': (CONF_NFS, 'mountd', 'ha-callout', '$1'), + '--port': (CONF_NFS, 'mountd', 'port', '$1'), + '--nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'y'), + '--no-nfs-version': (CONF_NFS, 'nfsd', 'vers$1', 'n'), + '--no-tcp': (CONF_NFS, 'nfsd', 'tcp', '0'), + '--state-directory-path': (CONF_NFS, 'mountd', 'state-directory-path', '$1'), + '--num-threads': (CONF_NFS, 'mountd', 'threads', '$1'), + '--reverse-lookup': (CONF_NFS, 'mountd', 'reverse-lookup', '1'), + '--no-udp': (CONF_NFS, 'nfsd', 'udp', '0'), + } + +# options for statd found in STATDARG +OPTS_STATD = 'o:p:T:U:n:P:H:' +LONG_STATD = ['outgoing-port=', 'port=', 'name=', 'state-directory-path=', + 'ha-callout=', 'nlm-port=', 'nlm-udp-port='] +CONV_STATD = {'-o': (CONF_NFS, 'statd', 'outgoing-port', '$1'), + '-p': (CONF_NFS, 'statd', 'port', '$1'), + '-T': (CONF_NFS, 'lockd', 'port', '$1'), + '-U': (CONF_NFS, 'lockd', 'udp-port', '$1'), + '-n': (CONF_NFS, 'statd', 'name', '$1'), + '-P': (CONF_NFS, 'statd', 'state-directory-path', '$1'), + '-H': (CONF_NFS, 'statd', 'ha-callout', '$1'), + '--outgoing-port': (CONF_NFS, 'statd', 'outgoing-port', '$1'), + '--port': (CONF_NFS, 'statd', 'port', '$1'), + '--name': (CONF_NFS, 'statd', 'name', '$1'), + '--state-directory-path': (CONF_NFS, 'statd', 'state-directory-path', '$1'), + '--ha-callout': (CONF_NFS, 'statd', 'ha-callout', '$1'), + '--nlm-port': (CONF_NFS, 'lockd', 'port', '$1'), + '--nlm-udp-port': (CONF_NFS, 'lockd', 'udp-port', '$1'), + } + +# options for sm-notify found in SMNOTIFYARGS +OPTS_SMNOTIFY = 'dm:np:v:P:' +CONV_SMNOTIFY = {'-d': (CONF_NFS, 'sm-notify', 'debug', 'all'), + '-m': (CONF_NFS, 'sm-notify', 'retry-time', '$1'), + '-n': (CONF_NFS, 'sm-notify', 'update-state', '1'), + '-p': (CONF_NFS, 'sm-notify', 'outgoing-port', '$1'), + '-v': (CONF_NFS, 'sm-notify', 'outgoing-addr', '$1'), + '-P': (CONF_NFS, 'statd', 'state-directory-path', '$1'), + } + +# options for idmapd found in RPCIDMAPDARGS +OPTS_IDMAPD = 'vp:CS' +CONV_IDMAPD = {'-v': (CONF_IDMAP, 'general', 'verbosity', '+'), + '-p': (CONF_NFS, 'general', 'pipefs-directory', '$1'), + '-C': (CONF_IDMAP, 'general', 'client-only', '1'), + '-S': (CONF_IDMAP, 'general', 'server-only', '1'), + } + +# options for gssd found in RPCGSSDARGS +OPTS_GSSD = 'Mnvrp:k:d:t:T:R:lD' +CONV_GSSD = {'-M': (CONF_NFS, 'gssd', 'use-memcache', '1'), + '-n': (CONF_NFS, 'gssd', 'root_uses_machine_creds', '0'), + '-v': (CONF_NFS, 'gssd', 'verbosity', '+'), + '-r': (CONF_NFS, 'gssd', 'rpc-verbosity', '+'), + '-p': (CONF_NFS, 'general', 'pipefs-directory', '$1'), + '-k': (CONF_NFS, 'gssd', 'keytab-file', '$1'), + '-d': (CONF_NFS, 'gssd', 'cred-cache-directory', '$1'), + '-t': (CONF_NFS, 'gssd', 'context-timeout', '$1'), + '-T': (CONF_NFS, 'gssd', 'rpc-timeout', '$1'), + '-R': (CONF_NFS, 'gssd', 'preferred-realm', '$1'), + '-l': (CONF_NFS, 'gssd', 'limit-to-legacy-enctypes', '0'), + '-D': (CONF_NFS, 'gssd', 'avoid-dns', '0'), + } + +# options for blkmapd found in BLKMAPDARGS +OPTS_BLKMAPD = '' +CONV_BLKMAPD = {} + +# meta list of all the getopt lists +GETOPT_MAPS = [('RPCNFSDARGS', OPTS_NFSD, LONG_NFSD, CONV_NFSD), + ('RPCMOUNTDOPTS', OPTS_MOUNTD, LONG_MOUNTD, CONV_MOUNTD), + ('STATDARG', OPTS_STATD, LONG_STATD, CONV_STATD), + ('STATDARGS', OPTS_STATD, LONG_STATD, CONV_STATD), + ('SMNOTIFYARGS', OPTS_SMNOTIFY, [], CONV_SMNOTIFY), + ('RPCIDMAPDARGS', OPTS_IDMAPD, [], CONV_IDMAPD), + ('RPCGSSDARGS', OPTS_GSSD, [], CONV_GSSD), + ('BLKMAPDARGS', OPTS_BLKMAPD, [], CONV_BLKMAPD), + ] + +# map for all of the single option values +VALUE_MAPS = {'LOCKD_TCPPORT': (CONF_NFS, 'lockd', 'port', '$1'), + 'LOCKD_UDPPORT': (CONF_NFS, 'lockd', 'udp-port', '$1'), + 'RPCNFSDCOUNT': (CONF_NFS, 'nfsd', 'threads', '$1'), + 'NFSD_V4_GRACE': (CONF_NFS, 'nfsd', 'grace-time', '$1'), + 'NFSD_V4_LEASE': (CONF_NFS, 'nfsd', 'lease-time', '$1'), + 'MOUNTD_PORT': (CONF_NFS, 'mountd', 'port', '$1'), + 'STATD_PORT': (CONF_NFS, 'statd', 'port', '$1'), + 'STATD_OUTGOING_PORT': (CONF_NFS, 'statd', 'outgoing-port', '$1'), + 'STATD_HA_CALLOUT': (CONF_NFS, 'statd', 'ha-callout', '$1'), + 'GSS_USE_PROXY': (CONF_NFS, 'gssd', 'use-gss-proxy', '$1') + } + +def eprint(*args, **kwargs): + """ Print error to stderr """ + print(*args, file=sys.stderr, **kwargs) + +def makesub(param, value): + """ Variable substitution """ + return param.replace('$1', value) + +def set_value(value, entry): + """ Set a configuration value by running nfsconf tool""" + cfile, section, tag, param = entry + + tag = makesub(tag, value) + param = makesub(param, value) + if param == '+': + param = value + if param == ',': + param = value + args = [CONF_TOOL, "--file", cfile, "--set", section, tag, param] + + try: + subprocess.check_output(args, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + print("Error running nfs-conf tool:\n %s" % (e.output.decode())) + print("Args: %s\n" % args) + raise Exception + +def convert_getopt(optname, options, optstring, longopts, conversions): + """ Parse option string into seperate config items + + Take a getopt string and a table of conversions + parse it all and spit out the converted config + + Keyword arguments: + options -- the argv string to convert + optstring -- getopt format option list + conversions -- table of translations + """ + optcount = 0 + try: + args = options.strip('\"').split() + optlist, optargs = getopt.gnu_getopt(args, optstring, longopts=longopts) + except getopt.GetoptError as err: + eprint(err) + raise Exception + + setlist = {} + for (k, v) in optlist: + if k in conversions: + # it's already been set once + param = conversions[k][3] + tag = k + makesub(conversions[k][2], v) + if tag in setlist: + value = setlist[tag][0] + # is it a cummulative entry + if param == '+': + value = str(int(value) + 1) + if param == ',': + value += "," + v + else: + if param == '+': + value = "1" + elif param == ',': + value = v + else: + value = v + setlist[tag] = (value, conversions[k]) + else: + if v: + eprint("Ignoring unrecognised option %s=%s in %s" % (k, v, optname)) + else: + eprint("Ignoring unrecognised option %s in %s" % (k, optname)) + + + for v, c in setlist.values(): + try: + set_value(v, c) + optcount += 1 + except Exception: + raise + + i = 1 + for o in optargs: + opname = '$' + str(i) + if opname in conversions: + try: + set_value(o, conversions[opname]) + optcount += 1 + except Exception: + raise + else: + eprint("Unrecognised trailing arguments") + raise Exception + i += 1 + + return optcount + +def map_values(): + """ Main function """ + mapcount = 0 + + # Lets load the old config + with open(SYSCONF_NFS) as cfile: + file_content = '[sysconf]\n' + cfile.read() + sysconfig = configparser.RawConfigParser() + sysconfig.read_string(file_content) + + # Map all the getopt option lists + for (name, opts, lopts, conv) in GETOPT_MAPS: + if name in sysconfig['sysconf']: + try: + mapcount += convert_getopt(name, sysconfig['sysconf'][name], opts, + lopts, conv) + except Exception: + eprint("Error whilst converting %s to nfsconf options." % (name)) + raise + + # Map the single value options + for name, opts in VALUE_MAPS.items(): + if name in sysconfig['sysconf']: + try: + value = sysconfig['sysconf'][name] + set_value(value.strip('\"'), opts) + mapcount += 1 + except Exception: + raise + + # All went well, move aside the old file + # but dont bother if there were no changes and + # an old config file already exists + backupfile = SYSCONF_NFS + SYSCONF_BACKUP + if mapcount > 0 or not os.path.exists(backupfile): + try: + os.replace(SYSCONF_NFS, backupfile) + except OSError as err: + eprint("Error moving old config %s: %s" % (SYSCONF_NFS, err)) + raise + +# Main routine +try: + map_values() +except Exception as e: + eprint(e) + eprint("Conversion failed. Please correct the error and try again.") + exit(1) diff --git a/nfsconvert.sh b/nfsconvert.sh new file mode 100644 index 0000000000000000000000000000000000000000..ce285622365c45a68b20863267b31136515b5dd2 --- /dev/null +++ b/nfsconvert.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# +# Convert /etc/sysconfig/nfs values in /etc/nfs.conf valuse +# + +# +# No file no conversion +# +if [ ! -f /etc/sysconfig/nfs ]; then + exit 0 +fi + +# +# See if the conversion happen already +# +grep "nfs.conf" /etc/sysconfig/nfs > /dev/null +if [ $? -eq 0 ]; then + exit 0 +fi + +if [ -f /etc/nfs.conf.rpmnew ]; then + # See if it is the we want to use + grep tag1234 /etc/nfs.conf.rpmnew > /dev/null + if [ $? -eq 0 ]; then + cp /etc/nfs.conf /etc/nfs.conf.rpmsave + cat /etc/nfs.conf.rpmnew | sed '/tag123/d' > /etc/nfs.conf + rm /etc/nfs.conf.rpmnew + fi +else + cp /etc/nfs.conf /etc/nfs.conf.rpmsave +fi + +# +# Do the conversion +# +/usr/sbin/nfsconvert +