From patchwork Fri Nov 11 03:36:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9422411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0967B60484 for ; Fri, 11 Nov 2016 03:36:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4CB1298C9 for ; Fri, 11 Nov 2016 03:36:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D87B8298CB; Fri, 11 Nov 2016 03:36:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CAB0298C9 for ; Fri, 11 Nov 2016 03:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965813AbcKKDgK (ORCPT ); Thu, 10 Nov 2016 22:36:10 -0500 Received: from mx2.suse.de ([195.135.220.15]:37427 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965233AbcKKDgJ (ORCPT ); Thu, 10 Nov 2016 22:36:09 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DC29CABC7; Fri, 11 Nov 2016 03:36:07 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Fri, 11 Nov 2016 14:36:00 +1100 Cc: libtirpc-devel@lists.sourceforge.net, Linux NFS Mailing List Subject: [PATCH rpcbind] Move default state-dir to /run/rpcbind User-Agent: Notmuch/0.22.1 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-suse-linux-gnu) Message-ID: <877f8almcf.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rpcbind can save state in a file to allow restart without forgetting about running services. The default location is currently "/tmp" which is an over-used directory that isn't really suitable for system files. The modern preferences would be a subdirectory of "/run", which can be selected with a ./configure option. That subdirectory would still need to be created by something. It is trivial for rpcbind to create the directory itself, and harmless to try if it already exists, so: - add a "mkdir" when saving state data - change the default to /run/rpcbind (currently used by Debian) - remove the default settign in the code, just use the one in configure.ac Signed-off-by: NeilBrown --- configure.ac | 4 ++-- src/warmstart.c | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index f84921eb27fb..fe7d0b068439 100644 --- a/configure.ac +++ b/configure.ac @@ -22,8 +22,8 @@ AC_ARG_ENABLE([warmstarts], AM_CONDITIONAL(WARMSTART, test x$enable_warmstarts = xyes) AC_ARG_WITH([statedir], - AS_HELP_STRING([--with-statedir=ARG], [use ARG as state dir @<:@default=/tmp@:>@]) - ,, [with_statedir=/tmp]) + AS_HELP_STRING([--with-statedir=ARG], [use ARG as state dir @<:@default=/run/rpcbind@:>@]) + ,, [with_statedir=/run/rpcbind]) AC_SUBST([statedir], [$with_statedir]) AC_ARG_WITH([rpcuser], diff --git a/src/warmstart.c b/src/warmstart.c index 122a058b7954..3896027e62ba 100644 --- a/src/warmstart.c +++ b/src/warmstart.c @@ -48,10 +48,6 @@ #include "rpcbind.h" -#ifndef RPCBIND_STATEDIR -#define RPCBIND_STATEDIR "/tmp" -#endif - /* These files keep the pmap_list and rpcb_list in XDR format */ #define RPCBFILE RPCBIND_STATEDIR "/rpcbind.xdr" #ifdef PORTMAP @@ -141,6 +137,7 @@ error: void write_warmstart() { + (void) mkdir(RPCBIND_STATEDIR, 0770); (void) write_struct(RPCBFILE, (xdrproc_t)xdr_rpcblist_ptr, &list_rbl); #ifdef PORTMAP (void) write_struct(PMAPFILE, (xdrproc_t)xdr_pmaplist_ptr, &list_pml);