From patchwork Mon Nov 9 15:40:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 7584601 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 94A5FC05C6 for ; Mon, 9 Nov 2015 15:40:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD84F2053B for ; Mon, 9 Nov 2015 15:40:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C08872047C for ; Mon, 9 Nov 2015 15:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504AbbKIPkk (ORCPT ); Mon, 9 Nov 2015 10:40:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35967 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbbKIPkj (ORCPT ); Mon, 9 Nov 2015 10:40:39 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 16E248FAA5 for ; Mon, 9 Nov 2015 15:40:39 +0000 (UTC) Received: from smallhat.boston.devel.redhat.com (vpn-54-90.rdu2.redhat.com [10.10.54.90]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA9FecFW013823 for ; Mon, 9 Nov 2015 10:40:38 -0500 From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH] rcpbind.sock removed when daemon is killed Date: Mon, 9 Nov 2015 10:40:36 -0500 Message-Id: <1447083636-17178-1-git-send-email-steved@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);