Try creating statdir once when opening lock file fails (bz 1401561)

Signed-off-by: Steve Dickson <steved@redhat.com>
This commit is contained in:
Steve Dickson 2017-03-21 10:55:19 -04:00
parent 07bfa98316
commit 283abcbc02
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,35 @@
diff -up rpcbind-0.2.4/src/rpcbind.c.orig rpcbind-0.2.4/src/rpcbind.c
--- rpcbind-0.2.4/src/rpcbind.c.orig 2017-03-21 10:12:35.005190509 -0400
+++ rpcbind-0.2.4/src/rpcbind.c 2017-03-21 10:36:45.510507649 -0400
@@ -144,6 +144,8 @@ static void rbllist_add(rpcprog_t, rpcve
static void terminate(int);
static void parseargs(int, char *[]);
+char *systemdtmp = "/usr/bin/systemd-tmpfiles --create rpcbind.conf";
+
int
main(int argc, char *argv[])
{
@@ -151,13 +153,21 @@ main(int argc, char *argv[])
void *nc_handle; /* Net config handle */
struct rlimit rl;
int maxrec = RPC_MAXDATASIZE;
+ int once = 1;
parseargs(argc, argv);
+tryagain:
/* Check that another rpcbind isn't already running. */
if ((rpcbindlockfd = (open(RPCBINDDLOCK,
- O_RDONLY|O_CREAT, 0444))) == -1)
+ O_RDONLY|O_CREAT, 0444))) == -1) {
+ if (once) {
+ once = system(systemdtmp); /* set once to avoid a warning */
+ once = 0;
+ goto tryagain;
+ }
err(1, "%s", RPCBINDDLOCK);
+ }
if(flock(rpcbindlockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK)
errx(1, "another rpcbind is already running. Aborting");

View File

@ -1,6 +1,6 @@
Name: rpcbind
Version: 0.2.4
Release: 5%{?dist}
Release: 6%{?dist}
Summary: Universal Addresses to RPC Program Number Mapper
Group: System Environment/Daemons
License: BSD
@ -25,6 +25,7 @@ Patch100: rpcbind-0.2.3-systemd-envfile.patch
Patch101: rpcbind-0.2.3-systemd-tmpfiles.patch
Patch102: rpcbind-0.2.4-runstatdir.patch
Patch103: rpcbind-0.2.4-systemd-service.patch
Patch104: rpcbind-0.2.4-systemd-rundir.patch
Provides: portmap = %{version}-%{release}
Obsoletes: portmap <= 4.0-65.3
@ -44,6 +45,7 @@ RPC calls on a server on that machine.
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%build
%ifarch s390 s390x
PIE="-fPIE"
@ -137,6 +139,9 @@ fi
%{_tmpfilesdir}/%{name}.conf
%changelog
* Tue Mar 21 2017 Steve Dickson <steved@redhat.com> - 0.2.4-6
- Try creating statdir once when opening lock file fails (bz 1401561)
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild