Skip to contentSkip to conversation

nfs-utils: clean up startup

PATCH In review Dan McGregor 2 participants 5 messages Feb 12, 2025 – Feb 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 nfs-utils: clean up startup

From: Daniel McGregor <[email protected]>

Change the sysvinit script to start at the S runlevel, this matches Debian, and prevents systemd from generating a unit file for it. Also have the nfsd systemd service request the nfsd kernel filesystem mountpoint. This avoids startup failures in unpriviled containers or other setups that don't support the filesystem.

---
 meta/recipes-connectivity/nfs-utils/nfs-utils/nfscommon | 8 ++++----
 meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb  | 9 ++++-----
 2 files changed, 8 insertions(+), 9 deletions(-)
meta/recipes-connectivity/nfs-utils/nfs-utils/nfscommon +4 -4
index 992267d5a16..4f07324a21f 100644
@@ -1,9 +1,9 @@
 #!/bin/sh
 ### BEGIN INIT INFO
 # Provides:          nfs-common
-# Required-Start:    $portmap hwclock
-# Required-Stop:     $portmap hwclock
-# Default-Start:     2 3 4 5
+# Required-Start:    $portmap $time
+# Required-Stop:     $portmap $time
+# Default-Start:     S
 # Default-Stop:      0 1 6
 # Short-Description: NFS support for both client and server
 # Description:       NFS is a popular protocol for file sharing across
@@ -20,7 +20,7 @@
 . /etc/init.d/functions
 
 test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd
-test -z "$STATD_PID" && STATD_PID=/var/run/rpc.statd.pid
+test -z "$STATD_PID" && STATD_PID=/run/rpc.statd.pid
 #
 # The default state directory is /var/lib/nfs
 test -n "$NFS_STATEDIR" || NFS_STATEDIR=/var/lib/nfs
meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb +4 -5
index ff02a3aea01..df9c95a71ff 100644
@@ -133,15 +133,14 @@ do_install:append () {
 	install -m 0644 ${UNPACKDIR}/nfs-server.service ${D}${systemd_system_unitdir}/
 	install -m 0644 ${UNPACKDIR}/nfs-mountd.service ${D}${systemd_system_unitdir}/
 	install -m 0644 ${UNPACKDIR}/nfs-statd.service ${D}${systemd_system_unitdir}/
+	install -m 0644 ${UNPACKDIR}/proc-fs-nfsd.mount ${D}${systemd_system_unitdir}/
 	sed -i -e 's,@SBINDIR@,${sbindir},g' \
 		-e 's,@SYSCONFDIR@,${sysconfdir},g' \
 		-e 's,@HIGH_RLIMIT_NOFILE@,${HIGH_RLIMIT_NOFILE},g' \
 		${D}${systemd_system_unitdir}/*.service
-	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
-		install -m 0644 ${UNPACKDIR}/proc-fs-nfsd.mount ${D}${systemd_system_unitdir}/
-		install -d ${D}${systemd_system_unitdir}/sysinit.target.wants/
-		ln -sf ../proc-fs-nfsd.mount ${D}${systemd_system_unitdir}/sysinit.target.wants/proc-fs-nfsd.mount
-	fi
+	# Add compatibility symlinks for the sysvinit scripts
+	ln -s nfs-server.service ${D}${systemd_system_unitdir}/nfsserver.service
+	ln -s /dev/null ${D}${systemd_system_unitdir}/nfscommon.service
 
 	# kernel code as of 3.8 hard-codes this path as a default
 	install -d ${D}/var/lib/nfs/v4recovery
Signature · 1 line
2.47.0
#1 lore raw

PATCH 2/4 nfs-utils: Use upstream systemd service files

From: Daniel McGregor <[email protected]>

Reduce diffs against upstream by using the service files provided by them. This reduces our dependence on patches that simply change the names of a service.
This also changes the way some nfs options get set for systemd, it introduces the nfs.conf file for configuration, which all daemons already support.

---
 .../bugfix-adjust-statd-service-name.patch    | 39 -----------------
 .../nfs-utils/nfs-utils/nfs-mountd.service    | 18 --------
 .../nfs-utils/nfs-utils/nfs-server.service    | 24 -----------
 .../nfs-utils/nfs-utils/nfs-statd.service     | 16 -------
 .../nfs-utils-debianize-start-statd.patch     | 42 -------------------
 .../nfs-utils/nfs-utils/nfs-utils.conf        | 35 ----------------
 .../nfs-utils/nfs-utils/proc-fs-nfsd.mount    |  8 ----
 .../nfs-utils/nfs-utils_2.8.2.bb              | 33 +++++----------
 8 files changed, 11 insertions(+), 204 deletions(-)
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/bugfix-adjust-statd-service-name.patch
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-mountd.service
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-server.service
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-statd.service
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-utils-debianize-start-statd.patch
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-utils.conf
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/proc-fs-nfsd.mount
meta/recipes-connectivity/nfs-utils/nfs-utils/bugfix-adjust-statd-service-name.patch deleted +0 -39
deleted file mode 100644
index f13d7b380ca..00000000000
@@ -1,39 +0,0 @@
-From 398fed3bb0350cb1229e54e7020ae0e044c206d1 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Ulrich=20=C3=96lmann?= <[email protected]>
-Date: Wed, 17 Feb 2016 08:33:45 +0100
-Subject: bugfix: adjust statd service name
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Upstream uses 'rpc-statd.service' and Yocto introduced 'nfs-statd.service'
-instead but forgot to update the mount.nfs helper 'start-statd' accordingly.
-
-Upstream-Status: Inappropriate [other]
-
-Signed-off-by: Ulrich Ölmann <[email protected]>
-
-Rebase it.
-
-Signed-off-by: Robert Yang <[email protected]>
----
- utils/statd/start-statd | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/utils/statd/start-statd b/utils/statd/start-statd
-index af5c950..df9b9be 100755
---- a/utils/statd/start-statd
-+++ b/utils/statd/start-statd
-@@ -28,10 +28,10 @@ fi
- # First try systemd if it's installed.
- if [ -d /run/systemd/system ]; then
-     # Quit only if the call worked.
--    if systemctl start rpc-statd.service; then
-+    if systemctl start nfs-statd.service; then
-         # Ensure systemd knows not to stop rpc.statd or its dependencies
-         # on 'systemctl isolate ..'
--        systemctl add-wants --runtime remote-fs.target rpc-statd.service
-+        systemctl add-wants --runtime remote-fs.target nfs-statd.service
-         exit 0
-     fi
- fi
meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-mountd.service deleted +0 -18
deleted file mode 100644
index ebfe64b9ced..00000000000
@@ -1,18 +0,0 @@
-[Unit]
-Description=NFS Mount Daemon
-DefaultDependencies=no
-After=rpcbind.socket
-Requires=proc-fs-nfsd.mount
-After=proc-fs-nfsd.mount
-After=network.target local-fs.target
-BindsTo=nfs-server.service
-ConditionPathExists=@SYSCONFDIR@/exports
-
-[Service]
-EnvironmentFile=-@SYSCONFDIR@/nfs-utils.conf
-ExecStart=@SBINDIR@/rpc.mountd -F $MOUNTD_OPTS
-LimitNOFILE=@HIGH_RLIMIT_NOFILE@
-StateDirectory=nfs
-
-[Install]
-WantedBy=multi-user.target
meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-server.service deleted +0 -24
deleted file mode 100644
index 15ceee04d0d..00000000000
@@ -1,24 +0,0 @@
-[Unit]
-Description=NFS server and services
-DefaultDependencies=no
-Requires=network.target proc-fs-nfsd.mount
-Requires=nfs-mountd.service
-Wants=rpcbind.service
-After=local-fs.target
-After=network.target proc-fs-nfsd.mount rpcbind.service nfs-mountd.service
-ConditionPathExists=@SYSCONFDIR@/exports
-
-[Service]
-Type=oneshot
-EnvironmentFile=-@SYSCONFDIR@/nfs-utils.conf
-ExecStartPre=@SBINDIR@/exportfs -r
-ExecStart=@SBINDIR@/rpc.nfsd $NFSD_OPTS $NFSD_COUNT
-ExecStop=@SBINDIR@/rpc.nfsd 0
-ExecStopPost=@SBINDIR@/exportfs -au
-ExecStopPost=@SBINDIR@/exportfs -f
-ExecReload=@SBINDIR@/exportfs -r
-RemainAfterExit=yes
-StateDirectory=nfs
-
-[Install]
-WantedBy=multi-user.target
meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-statd.service deleted +0 -16
deleted file mode 100644
index b519194121c..00000000000
@@ -1,16 +0,0 @@
-[Unit]
-Description=NFS status monitor for NFSv2/3 locking.
-DefaultDependencies=no
-Conflicts=umount.target
-Requires=nss-lookup.target rpcbind.service
-After=network.target nss-lookup.target rpcbind.service
-ConditionPathExists=@SYSCONFDIR@/exports
-
-[Service]
-EnvironmentFile=-@SYSCONFDIR@/nfs-utils.conf
-ExecStart=@SBINDIR@/rpc.statd -F $STATD_OPTS
-LimitNOFILE=@HIGH_RLIMIT_NOFILE@
-StateDirectory=nfs
-
-[Install]
-WantedBy=multi-user.target
meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-utils-debianize-start-statd.patch deleted +0 -42

42 lines not on this page · raw message

meta/recipes-connectivity/nfs-utils/nfs-utils/nfs-utils.conf deleted +0 -35
deleted file mode 100644
index a1007a7fbf4..00000000000
@@ -1,35 +0,0 @@
-# Parameters to be passed to nfs-utils (clients & server) service files.
-#
-
-# Options to pass to rpc.nfsd.
-NFSD_OPTS=""
-
-# Number of servers to start up; the default is 8 servers.
-NFSD_COUNT=""
-
-# Where to mount nfsd filesystem; the default is "/proc/fs/nfsd".
-PROCNFSD_MOUNTPOINT=""
-
-# Options used to mount nfsd filesystem; the default is "rw,nodev,noexec,nosuid".
-PROCNFSD_MOUNTOPTS=""
-
-# Options for rpc.mountd.
-# If you have a port-based firewall, you might want to set up
-# a fixed port here using the --port option.
-MOUNTD_OPTS=""
-
-# Parameters to be passed to nfs-common (nfs clients & server) init script.
-#
-
-# If you do not set values for the NEED_ options, they will be attempted
-# autodetected; this should be sufficient for most people. Valid alternatives
-# for the NEED_ options are "yes" and "no".
-
-# Do you want to start the statd daemon? It is not needed for NFSv4.
-NEED_STATD=""
-
-# Options to pass to rpc.statd.
-# N.B. statd normally runs on both client and server, and run-time
-# options should be specified accordingly.
-# STATD_OPTS="-p 32765 -o 32766"
-STATD_OPTS=""
meta/recipes-connectivity/nfs-utils/nfs-utils/proc-fs-nfsd.mount deleted +0 -8
deleted file mode 100644
index 630801b3751..00000000000
@@ -1,8 +0,0 @@
-[Unit]
-Description=NFSD configuration filesystem
-After=systemd-modules-load.service
-
-[Mount]
-What=nfsd
-Where=/proc/fs/nfsd
-Type=nfsd
meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb +11 -22
index df9c95a71ff..f07ed2040ad 100644
@@ -21,13 +21,6 @@ USERADD_PARAM:${PN}-client = "--system  --home-dir /var/lib/nfs \
 SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.xz \
            file://nfsserver \
            file://nfscommon \
-           file://nfs-utils.conf \
-           file://nfs-server.service \
-           file://nfs-mountd.service \
-           file://nfs-statd.service \
-           file://proc-fs-nfsd.mount \
-           file://nfs-utils-debianize-start-statd.patch \
-           file://bugfix-adjust-statd-service-name.patch \
            file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
            file://clang-warnings.patch \
            file://0001-locktest-Makefile.am-Do-not-use-build-flags.patch \
@@ -48,8 +41,8 @@ INITSCRIPT_PARAMS:${PN}-client = "defaults 19 21"
 inherit autotools-brokensep update-rc.d systemd pkgconfig
 
 SYSTEMD_PACKAGES = "${PN} ${PN}-client"
-SYSTEMD_SERVICE:${PN} = "nfs-server.service nfs-mountd.service"
-SYSTEMD_SERVICE:${PN}-client = "nfs-statd.service"
+SYSTEMD_SERVICE:${PN} = "nfs-server.service"
+SYSTEMD_SERVICE:${PN}-client = "nfs-client.target"
 
 # --enable-uuid is need for cross-compiling
 EXTRA_OECONF = "--with-statduser=rpcuser \
@@ -65,7 +58,7 @@ EXTRA_OECONF = "--with-statduser=rpcuser \
 LDFLAGS += "-lsqlite3 -levent"
 
 PACKAGECONFIG ??= "tcp-wrappers \
-    ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)} \
+    ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6 systemd', d)} \
 "
 PACKAGECONFIG:remove:libc-musl = "tcp-wrappers"
 PACKAGECONFIG[tcp-wrappers] = "--with-tcp-wrappers,--without-tcp-wrappers,tcp-wrappers"
@@ -75,6 +68,7 @@ PACKAGECONFIG[nfsv41] = "--enable-nfsv41,--disable-nfsv41,libdevmapper,libdevmap
 # keyutils is available in meta-oe
 PACKAGECONFIG[nfsv4] = "--enable-nfsv4,--disable-nfsv4,keyutils,python3-core"
 PACKAGECONFIG[nfsdctl] = "--enable-nfsdctl,--disable-nfsdctl,libnl readline,"
+PACKAGECONFIG[systemd] = "--with-systemd=${systemd_unitdir}/system,--without-systemd"
 
 PACKAGES =+ "${PN}-client ${PN}-mount ${PN}-stats ${PN}-rpcctl"
 
@@ -82,14 +76,16 @@ CONFFILES:${PN}-client += "${localstatedir}/lib/nfs/etab \
 			   ${localstatedir}/lib/nfs/rmtab \
 			   ${localstatedir}/lib/nfs/xtab \
 			   ${localstatedir}/lib/nfs/statd/state \
+			   ${sysconfdir}/nfs.conf \
 			   ${sysconfdir}/nfsmount.conf"
 
 FILES:${PN}-client = "${sbindir}/*statd \
 		      ${libdir}/libnfsidmap.so.* \
 		      ${sbindir}/rpc.idmapd ${sbindir}/sm-notify \
 		      ${sbindir}/showmount ${sbindir}/nfsstat \
+		      ${sbindir}/nfsconf \
 		      ${localstatedir}/lib/nfs \
-		      ${sysconfdir}/nfs-utils.conf \
+		      ${sysconfdir}/nfs.conf \
 		      ${sysconfdir}/nfsmount.conf \
 		      ${sysconfdir}/init.d/nfscommon \
 		      ${systemd_system_unitdir}/nfs-statd.service"
@@ -109,7 +105,7 @@ FILES:${PN} += "${systemd_unitdir} ${libdir}/libnfsidmap/ ${nonarch_libdir}/modp
 
 do_configure:prepend() {
 	sed -i -e 's,sbindir = /sbin,sbindir = ${base_sbindir},g' \
-		${S}/utils/mount/Makefile.am
+		${S}/utils/mount/Makefile.am ${S}/utils/nfsdcltrack/Makefile.am
 }
 
 # Make clean needed because the package comes with
@@ -126,18 +122,11 @@ do_install:append () {
 	install -m 0755 ${UNPACKDIR}/nfsserver ${D}${sysconfdir}/init.d/nfsserver
 	install -m 0755 ${UNPACKDIR}/nfscommon ${D}${sysconfdir}/init.d/nfscommon
 
-	install -m 0755 ${UNPACKDIR}/nfs-utils.conf ${D}${sysconfdir}
-	install -m 0755 ${S}/utils/mount/nfsmount.conf ${D}${sysconfdir}
+	install -m 0644 ${S}/nfs.conf ${D}${sysconfdir}
 
 	install -d ${D}${systemd_system_unitdir}
-	install -m 0644 ${UNPACKDIR}/nfs-server.service ${D}${systemd_system_unitdir}/
-	install -m 0644 ${UNPACKDIR}/nfs-mountd.service ${D}${systemd_system_unitdir}/
-	install -m 0644 ${UNPACKDIR}/nfs-statd.service ${D}${systemd_system_unitdir}/
-	install -m 0644 ${UNPACKDIR}/proc-fs-nfsd.mount ${D}${systemd_system_unitdir}/
-	sed -i -e 's,@SBINDIR@,${sbindir},g' \
-		-e 's,@SYSCONFDIR@,${sysconfdir},g' \
-		-e 's,@HIGH_RLIMIT_NOFILE@,${HIGH_RLIMIT_NOFILE},g' \
-		${D}${systemd_system_unitdir}/*.service
+	# Retain historical service name so old scripts keep working
+	ln -s rpc-statd.service ${D}${systemd_system_unitdir}/nfs-statd.service
 	# Add compatibility symlinks for the sysvinit scripts
 	ln -s nfs-server.service ${D}${systemd_system_unitdir}/nfsserver.service
 	ln -s /dev/null ${D}${systemd_system_unitdir}/nfscommon.service
Signature · 1 line
2.47.0
#2 lore raw

PATCH 3/4 nfs-utils: Configure nfsv4 ID mapping & Kerberos

In reply to Dan McGregor

From: Daniel McGregor <[email protected]>

Add support for the nfsv4 user ID mapping daemon, configured with a sensible default, and add a packageconfig for Kerberos support.

This is reasonably tested in production in our environment, but only systemd support. There'll be some more work to do to get GSSAPI and NFS idmapd support integreated into that.

---
 ...ect-warning-options-during-configure.patch | 109 +++++++
 ...-fix-undefined-function-for-libnsm.a.patch | 299 ------------------
 .../0004-Use-nogroup-for-nobody-group.patch   |  38 +++
 .../0005-find-OE-provided-Kerberos.patch      |  42 +++
 .../nfs-utils/nfs-utils/clang-warnings.patch  |  36 ---
 .../nfs-utils/nfs-utils_2.8.2.bb              |  39 ++-
 6 files changed, 219 insertions(+), 344 deletions(-)
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Detect-warning-options-during-configure.patch
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0004-Use-nogroup-for-nobody-group.patch
 create mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/0005-find-OE-provided-Kerberos.patch
 delete mode 100644 meta/recipes-connectivity/nfs-utils/nfs-utils/clang-warnings.patch
meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Detect-warning-options-during-configure.patch new file +109 -0
new file mode 100644
index 00000000000..69236e8278c
@@ -0,0 +1,109 @@
+From 1ab0c326405c6daa06f1a7eb4b0b60bf4e0584c2 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Tue, 31 Dec 2019 08:15:34 -0800
+Subject: [PATCH] Detect warning options during configure
+
+Certain options maybe compiler specific therefore its better
+to detect them before use.
+
+nfs_error copies the format string and appends newline to it
+but compiler can forget that it was format string since its not
+same fmt string that was passed. Ignore the warning
+
+Wdiscarded-qualifiers is gcc specific and this is no longer needed
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+
+---
+ support/nfs/xcommon.c          | 6 ++++++
+ support/nfs/xlog.c             | 6 ++++++
+ support/nfsidmap/libnfsidmap.c | 3 +++
+ utils/exportfs/exportfs.c      | 3 +++
+ 4 files changed, 18 insertions(+)
+
+diff --git a/support/nfs/xcommon.c b/support/nfs/xcommon.c
+index 3989f0bc..ff438c18 100644
+--- a/support/nfs/xcommon.c
++++ b/support/nfs/xcommon.c
+@@ -98,7 +98,10 @@ nfs_error (const char *fmt, ...) {
+ 
+      fmt2 = xstrconcat2 (fmt, "\n");
+      va_start (args, fmt);
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+      vfprintf (stderr, fmt2, args);
++#pragma GCC diagnostic pop
+      va_end (args);
+      free (fmt2);
+ }
+@@ -132,7 +135,10 @@ die(int err, const char *fmt, ...) {
+ 	va_list args;
+ 
+ 	va_start(args, fmt);
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ 	vfprintf(stderr, fmt, args);
++#pragma GCC diagnostic pop
+ 	fprintf(stderr, "\n");
+ 	va_end(args);
+ 
+diff --git a/support/nfs/xlog.c b/support/nfs/xlog.c
+index fa125cef..dc4c9ea1 100644
+--- a/support/nfs/xlog.c
++++ b/support/nfs/xlog.c
+@@ -178,11 +178,16 @@ xlog_backend(int kind, const char *fmt, va_list args)
+ 		fprintf(stderr, "%s: ", log_name);
+ #endif
+ 		va_copy(args2, args);
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ 		vfprintf(stderr, fmt, args2);
++#pragma GCC diagnostic pop
+ 		fprintf(stderr, "\n");
+ 		va_end(args2);
+ 	}
+ 
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ 	if (log_syslog) {
+ 		switch (kind) {
+ 		case L_FATAL:
+@@ -203,6 +208,7 @@ xlog_backend(int kind, const char *fmt, va_list args)
+ 			break;
+ 		}
+ 	}
++#pragma GCC diagnostic pop
+ 
+ 	if (kind == L_FATAL)
+ 		exit(1);
+diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
+index f8c36480..1a28be0a 100644
+--- a/support/nfsidmap/libnfsidmap.c
++++ b/support/nfsidmap/libnfsidmap.c
+@@ -99,7 +99,10 @@ static void default_logger(const char *fmt, ...)
+ 	va_list vp;
+ 
+ 	va_start(vp, fmt);
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ 	vsyslog(LOG_WARNING, fmt, vp);
++#pragma GCC diagnostic pop
+ 	va_end(vp);
+ }
+ 
+diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
+index b03a047b..eac1ff2a 100644
+--- a/utils/exportfs/exportfs.c
++++ b/utils/exportfs/exportfs.c
+@@ -646,7 +646,10 @@ dumpopt(char c, char *fmt, ...)
+ 
+ 	va_start(ap, fmt);
+ 	printf("%c", c);
++#pragma GCC diagnostic push
++#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+ 	vprintf(fmt, ap);
++#pragma GCC diagnostic pop
+ 	va_end(ap);
+ 	return ',';
+ }
meta/recipes-connectivity/nfs-utils/nfs-utils/0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch deleted +0 -299

299 lines not on this page · raw message

meta/recipes-connectivity/nfs-utils/nfs-utils/0004-Use-nogroup-for-nobody-group.patch new file +38 -0
new file mode 100644
index 00000000000..bbf44d59771
@@ -0,0 +1,38 @@
+From 001913c5eb0aad933a93ee966252905cd46d776b Mon Sep 17 00:00:00 2001
+From: Daniel McGregor <[email protected]>
+Date: Tue, 6 Jun 2023 16:07:53 -0600
+Subject: [PATCH] Use "nogroup" for nobody group
+
+Upstream-Status: Inappropriate [oe-core specific, configuration]
+Signed-off-by: Daniel McGregor <[email protected]>
+---
+ support/nfsidmap/idmapd.conf | 2 +-
+ utils/idmapd/idmapd.c        | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/support/nfsidmap/idmapd.conf b/support/nfsidmap/idmapd.conf
+index 2a2f79a1..e6f3724f 100644
+--- a/support/nfsidmap/idmapd.conf
++++ b/support/nfsidmap/idmapd.conf
+@@ -41,7 +41,7 @@
+ [Mapping]
+ 
+ #Nobody-User = nobody
+-#Nobody-Group = nobody
++#Nobody-Group = nogroup
+ 
+ [Translation]
+ 
+diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
+index cd9a965f..3be805e9 100644
+--- a/utils/idmapd/idmapd.c
++++ b/utils/idmapd/idmapd.c
+@@ -89,7 +89,7 @@
+ #endif
+ 
+ #ifndef NFS4NOBODY_GROUP
+-#define NFS4NOBODY_GROUP "nobody"
++#define NFS4NOBODY_GROUP "nogroup"
+ #endif
+ 
+ /* From Niels */
meta/recipes-connectivity/nfs-utils/nfs-utils/0005-find-OE-provided-Kerberos.patch new file +42 -0

42 lines not on this page · raw message

meta/recipes-connectivity/nfs-utils/nfs-utils/clang-warnings.patch deleted +0 -36
deleted file mode 100644
index fde99b599eb..00000000000
@@ -1,36 +0,0 @@
-From 1ab0c326405c6daa06f1a7eb4b0b60bf4e0584c2 Mon Sep 17 00:00:00 2001
-From: Khem Raj <[email protected]>
-Date: Tue, 31 Dec 2019 08:15:34 -0800
-Subject: [PATCH] Detect warning options during configure
-
-Certain options maybe compiler specific therefore its better
-to detect them before use.
-
-nfs_error copies the format string and appends newline to it
-but compiler can forget that it was format string since its not
-same fmt string that was passed. Ignore the warning
-
-Wdiscarded-qualifiers is gcc specific and this is no longer needed
-
-Upstream-Status: Pending
-Signed-off-by: Khem Raj <[email protected]>
-
----
- support/nfs/xcommon.c | 3 +++
- 1 file changed, 3 insertions(+)
-
-diff --git a/support/nfs/xcommon.c b/support/nfs/xcommon.c
-index 3989f0b..e080423 100644
---- a/support/nfs/xcommon.c
-+++ b/support/nfs/xcommon.c
-@@ -98,7 +98,10 @@ nfs_error (const char *fmt, ...) {
- 
-      fmt2 = xstrconcat2 (fmt, "\n");
-      va_start (args, fmt);
-+#pragma GCC diagnostic push
-+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
-      vfprintf (stderr, fmt2, args);
-+#pragma GCC diagnostic pop
-      va_end (args);
-      free (fmt2);
- }
meta/recipes-connectivity/nfs-utils/nfs-utils_2.8.2.bb +30 -9
index f07ed2040ad..abbdec7808d 100644
@@ -21,10 +21,11 @@ USERADD_PARAM:${PN}-client = "--system  --home-dir /var/lib/nfs \
 SRC_URI = "${KERNELORG_MIRROR}/linux/utils/nfs-utils/${PV}/nfs-utils-${PV}.tar.xz \
            file://nfsserver \
            file://nfscommon \
-           file://0001-Makefile.am-fix-undefined-function-for-libnsm.a.patch \
-           file://clang-warnings.patch \
            file://0001-locktest-Makefile.am-Do-not-use-build-flags.patch \
            file://0001-Fix-typecast-warning-with-clang.patch \
+           file://0001-Detect-warning-options-during-configure.patch \
+           file://0004-Use-nogroup-for-nobody-group.patch \
+           file://0005-find-OE-provided-Kerberos.patch \
            "
 
 SRC_URI[sha256sum] = "a39bbea76ac0ab9e6e8699caf3c308b6b310c20d458e8fa8606196d358e7fb15"
@@ -49,9 +50,8 @@ EXTRA_OECONF = "--with-statduser=rpcuser \
                 --enable-mountconfig \
                 --enable-libmount-mount \
                 --enable-uuid \
-                --disable-gss \
-                --disable-nfsdcltrack \
                 --with-statdpath=/var/lib/nfs/statd \
+                --with-pluginpath=${libdir}/libnfsidmap \
                 --with-rpcgen=${HOSTTOOLS_DIR}/rpcgen \
                "
 
@@ -60,13 +60,16 @@ LDFLAGS += "-lsqlite3 -levent"
 PACKAGECONFIG ??= "tcp-wrappers \
     ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6 systemd', d)} \
 "
+
 PACKAGECONFIG:remove:libc-musl = "tcp-wrappers"
+#krb5 is available in meta-oe
+PACKAGECONFIG[gssapi] = "--with-krb5=${STAGING_EXECPREFIXDIR} --enable-gss --enable-svcgss,--disable-gss --disable-svcgss,krb5"
 PACKAGECONFIG[tcp-wrappers] = "--with-tcp-wrappers,--without-tcp-wrappers,tcp-wrappers"
 PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
 # libdevmapper is available in meta-oe
 PACKAGECONFIG[nfsv41] = "--enable-nfsv41,--disable-nfsv41,libdevmapper,libdevmapper"
 # keyutils is available in meta-oe
-PACKAGECONFIG[nfsv4] = "--enable-nfsv4,--disable-nfsv4,keyutils,python3-core"
+PACKAGECONFIG[nfsv4] = "--enable-nfsv4 --enable-nfsdcltrack,--disable-nfsv4 --disable-nfsdcltrack,keyutils,python3-core"
 PACKAGECONFIG[nfsdctl] = "--enable-nfsdctl,--disable-nfsdctl,libnl readline,"
 PACKAGECONFIG[systemd] = "--with-systemd=${systemd_unitdir}/system,--without-systemd"
 
@@ -76,19 +79,34 @@ CONFFILES:${PN}-client += "${localstatedir}/lib/nfs/etab \
 			   ${localstatedir}/lib/nfs/rmtab \
 			   ${localstatedir}/lib/nfs/xtab \
 			   ${localstatedir}/lib/nfs/statd/state \
+			   ${sysconfdir}/idmapd.conf \
 			   ${sysconfdir}/nfs.conf \
 			   ${sysconfdir}/nfsmount.conf"
 
 FILES:${PN}-client = "${sbindir}/*statd \
-		      ${libdir}/libnfsidmap.so.* \
 		      ${sbindir}/rpc.idmapd ${sbindir}/sm-notify \
 		      ${sbindir}/showmount ${sbindir}/nfsstat \
+		      ${sbindir}/rpc.gssd \
 		      ${sbindir}/nfsconf \
+		      ${libdir}/libnfsidmap.so.* \
+		      ${libdir}/libnfsidmap/*.so \
+		      ${libexecdir}/nfsrahead \
 		      ${localstatedir}/lib/nfs \
+		      ${sysconfdir}/idmapd.conf \
+		      ${sysconfdir}/init.d/nfscommon \
 		      ${sysconfdir}/nfs.conf \
 		      ${sysconfdir}/nfsmount.conf \
-		      ${sysconfdir}/init.d/nfscommon \
-		      ${systemd_system_unitdir}/nfs-statd.service"
+		      ${systemd_system_unitdir}/auth-rpcgss-module.service \
+		      ${systemd_system_unitdir}/nfs-client.target \
+		      ${systemd_system_unitdir}/nfs-idmapd.service \
+		      ${systemd_system_unitdir}/nfs-statd.service \
+		      ${systemd_system_unitdir}/nfscommon.service \
+		      ${systemd_system_unitdir}/rpc-gssd.service \
+		      ${systemd_system_unitdir}/rpc-statd-notify.service \
+		      ${systemd_system_unitdir}/rpc-statd.service \
+		      ${systemd_system_unitdir}/rpc_pipefs.target \
+		      ${systemd_system_unitdir}/var-lib-nfs-rpc_pipefs.mount \
+		      ${nonarch_libdir}/udev/rules.d/*"
 RDEPENDS:${PN}-client = "${PN}-mount rpcbind"
 
 FILES:${PN}-mount = "${base_sbindir}/*mount.nfs*"
@@ -105,7 +123,9 @@ FILES:${PN} += "${systemd_unitdir} ${libdir}/libnfsidmap/ ${nonarch_libdir}/modp
 
 do_configure:prepend() {
 	sed -i -e 's,sbindir = /sbin,sbindir = ${base_sbindir},g' \
-		${S}/utils/mount/Makefile.am ${S}/utils/nfsdcltrack/Makefile.am
+		-e 's,udev_rulesdir = /usr/lib/udev/rules.d/,udev_rulesdir = ${nonarch_base_libdir}/udev/rules.d/,g' \
+		${S}/utils/mount/Makefile.am ${S}/utils/nfsdcltrack/Makefile.am \
+		${S}/systemd/Makefile.am ${S}/tools/nfsrahead/Makefile.am
 }
 
 # Make clean needed because the package comes with
@@ -122,6 +142,7 @@ do_install:append () {
 	install -m 0755 ${UNPACKDIR}/nfsserver ${D}${sysconfdir}/init.d/nfsserver
 	install -m 0755 ${UNPACKDIR}/nfscommon ${D}${sysconfdir}/init.d/nfscommon
 
+	install -m 0644 ${S}/support/nfsidmap/idmapd.conf ${D}${sysconfdir}
 	install -m 0644 ${S}/nfs.conf ${D}${sysconfdir}
 
 	install -d ${D}${systemd_system_unitdir}
Signature · 1 line
2.47.0
#3 lore raw

PATCH 4/4 nfs-utils: Start nfsv4 utilities with sysvinit

In reply to Dan McGregor

From: Daniel McGregor <[email protected]>

Rewrite the nfs sysvinit scripts to start the services required by nfsv4: gssd, idmapd, and statd.

---
 .../nfs-utils/nfs-utils/nfscommon             | 294 +++++++++++++++---
 .../nfs-utils/nfs-utils/nfsserver             |  43 ++-
 2 files changed, 289 insertions(+), 48 deletions(-)
meta/recipes-connectivity/nfs-utils/nfs-utils/nfscommon +255 -39
index 4f07324a21f..6c7b92bdb1b 100644
@@ -1,63 +1,279 @@
 #!/bin/sh
+
 ### BEGIN INIT INFO
 # Provides:          nfs-common
 # Required-Start:    $portmap $time
 # Required-Stop:     $portmap $time
 # Default-Start:     S
 # Default-Stop:      0 1 6
-# Short-Description: NFS support for both client and server
+# Short-Description: NFS support files common to client and server
 # Description:       NFS is a popular protocol for file sharing across
-#                    TCP/IP networks. This service provides various
+#		     TCP/IP networks. This service provides various
 #                    support functions for NFS mounts.
 ### END INIT INFO
-#
-# Startup script for nfs-utils
-#
-#
-# Location of executables:
 
-# Source function library.
+# What is this?
+DESC="NFS common utilities"
+
+# Read config
+DEFAULTFILE=/etc/default/nfs-utils
+NEED_STATD=
+NEED_GSSD=
+if nfsconf --isset general pipefs-directory; then
+    PIPEFS_MOUNTPOINT=$(nfsconf --get general pipefs-directory)
+else
+    PIPEFS_MOUNTPOINT=/var/lib/nfs/rpc_pipefs
+fi
+if [ -f $DEFAULTFILE ]; then
+    . $DEFAULTFILE
+fi
+
 . /etc/init.d/functions
 
-test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd
-test -z "$STATD_PID" && STATD_PID=/run/rpc.statd.pid
+# Exit if required binaries are missing.
+[ -x /usr/sbin/rpc.statd ] || exit 0
+
 #
-# The default state directory is /var/lib/nfs
-test -n "$NFS_STATEDIR" || NFS_STATEDIR=/var/lib/nfs
+# Parse the fstab file, and determine whether we need gssd. (The
+# /etc/defaults settings, if any, will override our autodetection.) This code
+# is partially adapted from the mountnfs.sh script in the sysvinit package.
 #
-#----------------------------------------------------------------------
-# Startup and shutdown functions.
-#  Actual startup/shutdown is at the end of this file.
-
-start_statd(){
-	echo -n "starting statd: "
-	start-stop-daemon --start --exec "$NFS_STATD" --pidfile "$STATD_PID"
-	echo done
+AUTO_NEED_GSSD=no
+
+if [ -f /etc/fstab ]; then
+    exec 9<&0 </etc/fstab
+
+    while read -r DEV _ _ OPTS _
+    do
+	case $DEV in
+	    ''|\#*)
+		continue
+		;;
+	esac
+	OLDIFS="$IFS"
+	IFS=","
+	for OPT in $OPTS; do
+	    case "$OPT" in
+		sec=krb5|sec=krb5i|sec=krb5p)
+		    AUTO_NEED_GSSD=yes
+		;;
+	    esac
+	done
+	IFS="$OLDIFS"
+    done
+
+    exec 0<&9 9<&-
+fi
+
+case "$NEED_STATD" in
+    yes|no)
+        ;;
+    *)
+        NEED_STATD=yes
+        ;;
+esac
+
+case "$NEED_IDMAPD" in
+    yes|no)
+        ;;
+    *)
+        NEED_IDMAPD=yes
+	;;
+esac
+
+case "$NEED_GSSD" in
+    yes|no)
+        ;;
+    *)
+        NEED_GSSD=$AUTO_NEED_GSSD
+	;;
+esac
+
+do_modprobe() {
+    if [ -x /sbin/modprobe ] && [ -f /proc/modules ]
+    then
+        modprobe -q "$1" || true
+    fi
+}
+
+do_mount() {
+    if ! grep -E -qs "$1\$" /proc/filesystems
+    then
+	return 1
+    fi
+    if ! mountpoint -q "$2"
+    then
+	mount -t "$1" "$1" "$2"
+	return
+    fi
+    return 0
 }
-stop_statd(){
-	echo -n 'stopping statd: '
-	start-stop-daemon --stop --quiet --signal 1 --pidfile "$STATD_PID"
-	echo done
+
+do_umount() {
+    if mountpoint -q "$1"
+    then
+	umount "$1"
+    fi
+    return 0
 }
-#----------------------------------------------------------------------
-#
-# supported options:
-#  start
-#  stop
-#  restart: stops and starts mountd
-#FIXME: need to create the /var/lib/nfs/... directories
+
+# See how we were called.
 case "$1" in
   start)
-	start_statd;;
+	echo -n "Starting $DESC ..."
+
+	if [ "$NEED_STATD" = yes ]; then
+	    echo -n " statd"
+
+	    # See if rpcbind is running
+	    if [ -x /usr/sbin/rpcinfo ]; then
+		/usr/sbin/rpcinfo -p >/dev/null 2>&1
+		RET=$?
+		if [ $RET != 0 ]; then
+		   echo
+		   echo "Not starting: portmapper is not running"
+		   exit 0
+		fi
+	    fi
+	    start-stop-daemon --start --oknodo --quiet \
+		--pidfile /run/rpc.statd.pid \
+	        --exec /sbin/rpc.statd
+	    RET=$?
+	    if [ $RET != 0 ]; then
+	        echo " failed" $RET
+	        exit $RET
+	    else
+		if [ -d /run/sendsigs.omit.d ]; then
+		    rm -f /run/sendsigs.omit.d/statd
+		    ln -s /run/rpc.statd.pid /run/sendsigs.omit.d/statd
+		fi
+	    fi
+	fi
+
+	# Don't start idmapd and gssd if we don't have them (say, if /usr is not
+	# up yet).
+	[ -x /usr/sbin/rpc.idmapd ] || NEED_IDMAPD=no
+	[ -x /usr/sbin/rpc.gssd   ] || NEED_GSSD=no
+
+	if [ "$NEED_IDMAPD" = yes ] || [ "$NEED_GSSD" = yes ]
+	then
+	    do_modprobe sunrpc
+	    do_modprobe nfs
+	    do_modprobe nfsd
+	    mkdir -p "$PIPEFS_MOUNTPOINT"
+	    if do_mount rpc_pipefs $PIPEFS_MOUNTPOINT
+	    then
+	    	if [ "$NEED_IDMAPD" = yes ]
+		then
+	            ecno -n " idmapd"
+		    start-stop-daemon --start --oknodo --quiet \
+			    --exec /usr/sbin/rpc.idmapd
+		    RET=$?
+	            if [ $RET != 0 ]; then
+        	        echo " failed" $RET
+        	        exit $RET
+                    fi
+		fi
+		if [ "$NEED_GSSD" = yes ]
+		then
+		    do_modprobe rpcsec_gss_krb5
+	            echo -n " gssd"
+
+		    start-stop-daemon --start --oknodo --quiet \
+			    --exec /usr/sbin/rpc.gssd
+		    RET=$?
+	            if [ $RET != 0 ]; then
+        	        echo " failed" $RET
+        	        exit $RET
+                    fi
+		fi
+	    fi
+	fi
+	echo " done"
+	;;
+
   stop)
-	stop_statd;;
+	echo -n "Stopping $DESC ..."
+
+	if [ "$NEED_GSSD" = yes ]
+	then
+	    echo -n " gssd"
+	    start-stop-daemon --stop --oknodo --quiet \
+		    --name rpc.gssd
+	    RET=$?
+	    if [ $RET != 0 ]; then
+                echo " failed" $RET
+                exit $RET
+            fi
+	fi
+	if [ "$NEED_IDMAPD" = yes ]
+	then
+	    echo -n " idmapd"
+	    start-stop-daemon --stop --oknodo --quiet \
+		--name rpc.idmapd
+            RET=$?
+	    if [ $RET != 0 ]; then
+                echo " failed" $RET
+                exit $RET
+            fi
+	fi
+	if [ "$NEED_STATD" = yes ]
+	then
+	    echo -n " statd"
+	    start-stop-daemon --stop --oknodo --quiet \
+	        --name rpc.statd
+	    RET=$?
+	    if [ $RET != 0 ]; then
+                echo " failed" $RET
+                exit $RET
+            fi
+	fi
+	do_umount $PIPEFS_MOUNTPOINT 2>/dev/null || true
+	echo " done"
+	;;
+
   status)
-	status $NFS_STATD
-	exit $?;;
-  restart)
+	if [ "$NEED_STATD" = yes ]
+	then
+	    if ! pidof rpc.statd >/dev/null
+	    then
+	        echo "rpc.statd not running"
+	        exit 3
+	    fi
+	fi
+
+	if [ "$NEED_GSSD" = yes ]
+	then
+            if ! pidof rpc.gssd >/dev/null
+	    then
+		echo "rpc.gssd not running"
+		exit 3
+	    fi
+	fi
+
+	if [ "$NEED_IDMAPD" = yes ]
+	then
+            if ! pidof rpc.idmapd >/dev/null
+	    then
+		echo "rpc.idmapd not running"
+		exit 3
+	    fi
+	fi
+
+	echo "all daemons running"
+	exit 0
+	;;
+
+  restart | force-reload)
 	$0 stop
-	$0 start;;
+	sleep 1
+	$0 start
+	;;
+
   *)
-	echo "Usage: $0 {start|stop|status|restart}"
-	exit 1;;
+	echo "Usage: nfscommon {start|stop|status|restart}"
+	exit 1
+	;;
 esac
+
+exit 0
meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver +34 -9

86 lines not on this page · raw message

Signature · 1 line
2.47.0
#4 lore raw
In reply to Dan McGregor
Quoted 6 lines · Dan McGregor via lists.openembedded.org

Change the sysvinit script to start at the S runlevel, this matches Debian, and prevents systemd from generating a unit file for it. Also have the nfsd systemd service request the nfsd kernel filesystem mountpoint. This avoids startup failures in unpriviled containers or other setups that don't support the filesystem.

These just merged, but I found some issues:

On boot with sysv:

Starting NFS common utilities … statd start-stop-daemon: can't execute '/sbin/rpc.statd': No such file or directory

It’s not wrong: the path is /usr/sbin/rpc.statd for me.

Probably a related issue, but at rootfs time:

- nothing provides nfs-utils-mount needed by nfs-utils-client-2.8.2-r0.core2-64

Indeed nfs-utils-mount is empty, because it has FILES using base_sbindir but the binaries are in sbindir.

I’m wondering if there’s a latent usrmerge issue here.

Ross