diff --git a/0012-Move-default-state-dir-to-a-subdirectory-of-var-run.patch b/0012-Move-default-state-dir-to-a-subdirectory-of-var-run.patch new file mode 100644 index 0000000..818f058 --- /dev/null +++ b/0012-Move-default-state-dir-to-a-subdirectory-of-var-run.patch @@ -0,0 +1,146 @@ +From 2e78e6fb51292fea798355e5cb749dbc1de26ca6 Mon Sep 17 00:00:00 2001 +From: NeilBrown +Date: Wed, 16 Nov 2016 10:53:07 -0500 +Subject: [PATCH 1/1] Move default state-dir to a subdirectory of /var/run + +rpcbind can save state in a file to allow restart without forgetting +about running services. + +The default location is currently "/tmp" which is +not ideal for system files. It is particularly unpleasant +to put simple files there rather than creating a directory +to contain them. + +On a modern Linux system it is preferable to use /run, and there it is +even more consistent with practice to use a subdirectory. + +This directory needs to be create one each boot, and while there are +tools (e.g. systemd-tmpfiles) which can do that it is cleaner to keep +rpcbind self-contained and have it create the directory. + +So change the default location to /var/run/rpcbind, and create that +directory. If a different user-id is used, we need to create +and chown the directory before dropping privileges. We do this +with care so avoid chowning the wrong thing by mistake. + +Signed-off-by: NeilBrown +Signed-off-by: Steve Dickson +--- + configure.ac | 4 ++-- + src/rpcbind.c | 5 +++++ + src/rpcbind.h | 1 + + src/warmstart.c | 37 +++++++++++++++++++++++++++++++++---- + 4 files changed, 41 insertions(+), 6 deletions(-) + +diff --git a/configure.ac b/configure.ac +index f84921e..acc6914 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=/var/run/rpcbind@:>@]) ++ ,, [with_statedir=/var/run/rpcbind]) + AC_SUBST([statedir], [$with_statedir]) + + AC_ARG_WITH([rpcuser], +diff --git a/src/rpcbind.c b/src/rpcbind.c +index 87ccdc2..8db8dfc 100644 +--- a/src/rpcbind.c ++++ b/src/rpcbind.c +@@ -263,6 +263,11 @@ main(int argc, char *argv[]) + syslog(LOG_ERR, "cannot get uid of '%s': %m", id); + exit(1); + } ++#ifdef WARMSTART ++ if (warmstart) { ++ mkdir_warmstart(p->pw_uid); ++ } ++#endif + if (setgid(p->pw_gid) == -1) { + syslog(LOG_ERR, "setgid to '%s' (%d) failed: %m", id, p->pw_gid); + exit(1); +diff --git a/src/rpcbind.h b/src/rpcbind.h +index 74f9591..5b1a9bb 100644 +--- a/src/rpcbind.h ++++ b/src/rpcbind.h +@@ -129,6 +129,7 @@ int is_localroot(struct netbuf *); + extern void pmap_service(struct svc_req *, SVCXPRT *); + #endif + ++void mkdir_warmstart(int uid); + void write_warmstart(void); + void read_warmstart(void); + +diff --git a/src/warmstart.c b/src/warmstart.c +index 122a058..aafcb61 100644 +--- a/src/warmstart.c ++++ b/src/warmstart.c +@@ -45,19 +45,23 @@ + #include + #include + #include ++#include + + #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 + #define PMAPFILE RPCBIND_STATEDIR "/portmap.xdr" + #endif + ++#ifndef O_DIRECTORY ++#define O_DIRECTORY 0 ++#endif ++#ifndef O_NOFOLLOW ++#define O_NOFOLLOW 0 ++#endif ++ + static bool_t write_struct __P((char *, xdrproc_t, void *)); + static bool_t read_struct __P((char *, xdrproc_t, void *)); + +@@ -139,8 +143,33 @@ error: + } + + void ++mkdir_warmstart(int uid) ++{ ++ /* Already exists? */ ++ if (access(RPCBIND_STATEDIR, X_OK) == 0) ++ return; ++ ++ if (mkdir(RPCBIND_STATEDIR, 0770) == 0) { ++ int fd = open(RPCBIND_STATEDIR, O_RDONLY | O_DIRECTORY | O_NOFOLLOW); ++ if (fd >= 0) { ++ if (fchown(fd, uid, -1) < 0) { ++ syslog(LOG_ERR, ++ "mkdir_warmstart: open failed '%s', errno %d (%s)", ++ RPCBIND_STATEDIR, errno, strerror(errno)); ++ } ++ close(fd); ++ } else ++ syslog(LOG_ERR, "mkdir_warmstart: open failed '%s', errno %d (%s)", ++ RPCBIND_STATEDIR, errno, strerror(errno)); ++ } else ++ syslog(LOG_ERR, "mkdir_warmstart: mkdir failed '%s', errno %d (%s)", ++ RPCBIND_STATEDIR, errno, strerror(errno)); ++} ++ ++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); +-- +1.8.5.6 + diff --git a/rpcbind.changes b/rpcbind.changes index 4938a8d..af40808 100644 --- a/rpcbind.changes +++ b/rpcbind.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Nov 22 08:27:10 CET 2016 - kukuk@suse.de + +- Add 0012-Move-default-state-dir-to-a-subdirectory-of-var-run.patch + from upstream, replacing systemd tmpfile solution. + ------------------------------------------------------------------- Sat Nov 12 21:19:10 CET 2016 - kukuk@suse.de diff --git a/rpcbind.conf b/rpcbind.conf deleted file mode 100644 index 6a11118..0000000 --- a/rpcbind.conf +++ /dev/null @@ -1 +0,0 @@ -d /run/rpcbind 0755 rpc root diff --git a/rpcbind.spec b/rpcbind.spec index cb8ecd7..7aa3f20 100644 --- a/rpcbind.spec +++ b/rpcbind.spec @@ -27,7 +27,6 @@ Source: %{name}-%{version}.tar.bz2 Source2: sysconfig.rpcbind Source3: rpcbind.xml Source4: pmap_set.c -Source5: rpcbind.conf BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: libtirpc-devel >= 1.0.1 BuildRequires: libtool @@ -47,6 +46,7 @@ Patch8: 0008-First-part-of-init_transport-refactoring.patch Patch9: 0009-init_transport-move-the-registration-code-into-a-sep.patch Patch10: 0010-Fix-the-behavior-when-specifying-the-h-option.patch Patch11: 0011-Clean-up-the-way-we-handle-the-h-option-in-init_tran.patch +Patch12: 0012-Move-default-state-dir-to-a-subdirectory-of-var-run.patch Patch14: 0014-When-using-systemd-redirect-syslog-calls-to-the-syst.patch Patch30: 0030-systemd-fix-rmtcall.patch Patch31: 0031-rpcbind-manpage.patch @@ -74,6 +74,7 @@ cp %{SOURCE4} . #%patch9 -p1 #%patch10 -p1 #%patch11 -p1 +%patch12 -p1 #%patch14 -p1 #%patch30 -p1 %patch31 -p1 @@ -101,8 +102,6 @@ mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates install -m 644 %{SOURCE2} $RPM_BUILD_ROOT/var/adm/fillup-templates/ mkdir -p $RPM_BUILD_ROOT%_datadir/omc/svcinfo.d install -m 644 %{SOURCE3} $RPM_BUILD_ROOT%_datadir/omc/svcinfo.d/ -mkdir -p $RPM_BUILD_ROOT/usr/lib/tmpfiles.d -install -m 644 %{SOURCE5} $RPM_BUILD_ROOT/usr/lib/tmpfiles.d/ # install -m 755 pmap_set $RPM_BUILD_ROOT/sbin/pmap_set2 # create symlink for rcrpcbind @@ -124,7 +123,6 @@ exit 0 %post %{fillup_only -n rpcbind} -/usr/bin/systemd-tmpfiles --create rpcbind.conf ||: %service_add_post %{name}.service %{name}.socket %postun @@ -139,7 +137,6 @@ exit 0 %{_sbindir}/rcrpcbind %{_mandir}/*/* /var/adm/fillup-templates/sysconfig.rpcbind -/usr/lib/tmpfiles.d/rpcbind.conf %{_datadir}/omc/svcinfo.d/rpcbind.xml %{_unitdir}/%{name}.service %{_unitdir}/%{name}.socket