All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <steved@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH] rcpbind.sock removed when daemon is killed
Date: Mon,  9 Nov 2015 10:40:36 -0500	[thread overview]
Message-ID: <1447083636-17178-1-git-send-email-steved@redhat.com> (raw)

rpcbind.sock and rpcbind.lock are created as root
when rpcbind starts. Some distro allow rpcbind
to run as root, others do not.

For distro that change the uid/gid of the running
rpcbind, the uid/gid of those files most also be
changed so they can be removed at termination

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 src/rpcbind.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/rpcbind.c b/src/rpcbind.c
index 045daa1..c6129a9 100644
--- a/src/rpcbind.c
+++ b/src/rpcbind.c
@@ -262,10 +262,18 @@ main(int argc, char *argv[])
 			syslog(LOG_ERR, "cannot get uid of '%s': %m", id);
 			exit(1);
 		}
-                if (setgid(p->pw_gid) == -1) {
-                        syslog(LOG_ERR, "setgid to '%s' (%d) failed: %m", id, p->pw_gid);
-                        exit(1);
-                }
+		if (chown(RPCBINDDLOCK, p->pw_uid, p->pw_gid) < 0){
+			syslog(LOG_WARNING, "chown of '%s' to %d/%d failed: %m", 
+				RPCBINDDLOCK, p->pw_uid, p->pw_gid);
+		}
+		if (chown(_PATH_RPCBINDSOCK, p->pw_uid, p->pw_gid) < 0){
+			syslog(LOG_WARNING, "chown of '%s' to %d/%d failed: %m", 
+				_PATH_RPCBINDSOCK, p->pw_uid, p->pw_gid);
+		}
+		if (setgid(p->pw_gid) == -1) {
+			syslog(LOG_ERR, "setgid to '%s' (%d) failed: %m", id, p->pw_gid);
+			exit(1);
+		}
 		if (setgroups(0, NULL) == -1) {
 			syslog(LOG_ERR, "dropping supplemental groups failed: %m");
 			exit(1);
-- 
2.4.3


                 reply	other threads:[~2015-11-09 15:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly 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=1447083636-17178-1-git-send-email-steved@redhat.com \
    --to=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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.