Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
From: NeilBrown <neilb@suse.de>
To: Steve Dickson <SteveD@RedHat.com>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 3/3] statd: take user-id from /var/lib/nfs/sm
Date: Mon, 23 Sep 2019 14:26:58 +1000
Message-ID: <156921281809.27519.10997149063922425666.stgit@noble.brown> (raw)
In-Reply-To: <156921267783.27519.2402857390317412450.stgit@noble.brown>

Having /var/lib/nfs writeable by statd is not ideal
as there are files in there that statd doesn't need
to access.
After dropping privs, statd and sm-notify only need to
access files in the directories sm and sm.bak.
So take the uid for these deamons from 'sm'.

Signed-off-by: NeilBrown <neilb@suse.de>
---
 support/nsm/file.c        |   16 +++++-----------
 utils/statd/sm-notify.man |   10 +++++++++-
 utils/statd/statd.man     |   10 +++++++++-
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/support/nsm/file.c b/support/nsm/file.c
index 0b66f123165e..f5b448015751 100644
--- a/support/nsm/file.c
+++ b/support/nsm/file.c
@@ -388,23 +388,17 @@ nsm_drop_privileges(const int pidfd)
 
 	(void)umask(S_IRWXO);
 
-	/*
-	 * XXX: If we can't stat dirname, or if dirname is owned by
-	 *      root, we should use "statduser" instead, which is set up
-	 *      by configure.ac.  Nothing in nfs-utils seems to use
-	 *      "statduser," though.
-	 */
-	if (lstat(nsm_base_dirname, &st) == -1) {
-		xlog(L_ERROR, "Failed to stat %s: %m", nsm_base_dirname);
-		return false;
-	}
-
 	if (chdir(nsm_base_dirname) == -1) {
 		xlog(L_ERROR, "Failed to change working directory to %s: %m",
 				nsm_base_dirname);
 		return false;
 	}
 
+	if (lstat(NSM_MONITOR_DIR, &st) == -1) {
+		xlog(L_ERROR, "Failed to stat %s/%s: %m", nsm_base_dirname, NSM_MONITOR_DIR);
+		return false;
+	}
+
 	if (!prune_bounding_set())
 		return false;
 
diff --git a/utils/statd/sm-notify.man b/utils/statd/sm-notify.man
index cfe1e4b1dac8..addf5d3c028e 100644
--- a/utils/statd/sm-notify.man
+++ b/utils/statd/sm-notify.man
@@ -190,7 +190,15 @@ by default.
 After starting,
 .B sm-notify
 attempts to set its effective UID and GID to the owner
-and group of this directory.
+and group of the subdirectory
+.B sm
+of this directory.  After changing the effective ids,
+.B sm-notify
+only needs to access files in
+.B sm
+and
+.B sm.bak
+within the state-directory-path.
 .TP
 .BI -v " ipaddr " | " hostname
 Specifies the network address from which to send reboot notifications,
diff --git a/utils/statd/statd.man b/utils/statd/statd.man
index 71d58461b5ea..6222701e38a8 100644
--- a/utils/statd/statd.man
+++ b/utils/statd/statd.man
@@ -259,7 +259,15 @@ by default.
 After starting,
 .B rpc.statd
 attempts to set its effective UID and GID to the owner
-and group of this directory.
+and group of the subdirectory
+.B sm
+of this directory.  After changing the effective ids,
+.B rpc.statd
+only needs to access files in
+.B sm
+and
+.B sm.bak
+within the state-directory-path.
 .TP
 .BR -v ", " -V ", " --version
 Causes



  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-23  4:26 [PATCH 0/3] some nfs-utils patches NeilBrown
2019-09-23  4:26 ` NeilBrown [this message]
2019-09-23  4:26 ` [PATCH 2/3] conffile: allow optional include files NeilBrown
2019-09-23  4:26 ` [PATCH 1/3] mountd: Initialize logging early NeilBrown
2019-10-14 18:16 ` [PATCH 0/3] some nfs-utils patches Steve Dickson
2019-10-14 22:36   ` NeilBrown

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=156921281809.27519.10997149063922425666.stgit@noble.brown \
    --to=neilb@suse.de \
    --cc=SteveD@RedHat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git