From patchwork Thu Jun 23 01:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 12891623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0699DC433EF for ; Thu, 23 Jun 2022 01:47:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377187AbiFWBrq (ORCPT ); Wed, 22 Jun 2022 21:47:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359719AbiFWBrp (ORCPT ); Wed, 22 Jun 2022 21:47:45 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1F8443ACC for ; Wed, 22 Jun 2022 18:47:44 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 64BD221C66; Thu, 23 Jun 2022 01:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1655948863; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I1DqH5K0Sn0dM/JTC6+NRFvJvl9VHcLAqI0Igel49c4=; b=KToxm9f+9QjR9kcVVnaCTP0yY5wrtTF/ONWFYMT59VVI+Ge+xTYdc8mK57B+Wyn6UdVlMs 6B61kyqUXVBmWFk9MqajwEGJ4FN9dGJYiBjfJ0xUKNwx30D5H3imGOnahuijlKhQRp1oyi ujP8ZBp39Dlus581CD1LCKs1Aiiy6M0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1655948863; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=I1DqH5K0Sn0dM/JTC6+NRFvJvl9VHcLAqI0Igel49c4=; b=1S3NU9/PHMjmR8EwNiPgn6pn9I7Za/774x9kIW1QxdpZX0d3NHijPG2CUF86w2DJWJqHAQ 3lhdJApzChU6sRBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8827013461; Thu, 23 Jun 2022 01:47:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Sg+2ED7Gs2KwWwAAMHmgww (envelope-from ); Thu, 23 Jun 2022 01:47:42 +0000 MIME-Version: 1.0 From: "NeilBrown" To: Steve Dickson Cc: linux-nfs Subject: [PATCH nfs-utils] modprobe: protect against sysctl errors Date: Thu, 23 Jun 2022 11:47:39 +1000 Message-id: <165594885936.4786.14207888490098319610@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If there is an error running sysctl, a modprobe of these modules will fail. We probably don't want that - missing a sysctl is unlikely to be fatal. A real possibility is that /sbin/sysctl might not exist at all, such as in a initramfs. In that case we definitely don't want modprobe to fail. So make the scriptlets safe. Signed-off-by: NeilBrown --- systemd/50-nfs.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/systemd/50-nfs.conf b/systemd/50-nfs.conf index b56b2d765969..19e8ee734c8e 100644 --- a/systemd/50-nfs.conf +++ b/systemd/50-nfs.conf @@ -1,16 +1,16 @@ # Ensure all NFS systctl settings get applied when modules load # sunrpc module supports "sunrpc.*" sysctls -install sunrpc /sbin/modprobe --ignore-install sunrpc $CMDLINE_OPTS && /sbin/sysctl -q --pattern sunrpc --system +install sunrpc /sbin/modprobe --ignore-install sunrpc $CMDLINE_OPTS && { /sbin/sysctl -q --pattern sunrpc --system; exit 0; } # rpcrdma module supports sunrpc.svc_rdma.* -install rpcrdma /sbin/modprobe --ignore-install rpcrdma $CMDLINE_OPTS && /sbin/sysctl -q --pattern sunrpc.svc_rdma --system +install rpcrdma /sbin/modprobe --ignore-install rpcrdma $CMDLINE_OPTS && { /sbin/sysctl -q --pattern sunrpc.svc_rdma --system; exit 0; } # lockd module supports "fs.nfs.nlm*" and "fs.nfs.nsm*" sysctls -install lockd /sbin/modprobe --ignore-install lockd $CMDLINE_OPTS && /sbin/sysctl -q --pattern fs.nfs.n[sl]m --system +install lockd /sbin/modprobe --ignore-install lockd $CMDLINE_OPTS && { /sbin/sysctl -q --pattern fs.nfs.n[sl]m --system; exit 0; } # nfsv4 module supports "fs.nfs.*" sysctls (nfs_callback_tcpport and idmap_cache_timeout) -install nfsv4 /sbin/modprobe --ignore-install nfsv4 $CMDLINE_OPTS && /sbin/sysctl -q --pattern 'fs.nfs.(nfs_callback_tcpport|idmap_cache_timeout)' --system +install nfsv4 /sbin/modprobe --ignore-install nfsv4 $CMDLINE_OPTS && { /sbin/sysctl -q --pattern 'fs.nfs.(nfs_callback_tcpport|idmap_cache_timeout)' --system; exit 0; } # nfs module supports "fs.nfs.*" sysctls -install nfs /sbin/modprobe --ignore-install nfs $CMDLINE_OPTS && /sbin/sysctl -q --pattern fs.nfs --system +install nfs /sbin/modprobe --ignore-install nfs $CMDLINE_OPTS && { /sbin/sysctl -q --pattern fs.nfs --system; exit 0; }