There are some cases where rpcbind is not started by systemd.

Therefore, add macro WITHOUT_SYSTEMD to relieve dependence on
systemd.

Signed-off-by: Qing Wang <wangqing151@huawei.com>
(cherry picked from commit 18d75374a483a197e846016e3a278584df39b7b2)
This commit is contained in:
Xin Shi 2023-03-21 15:09:00 +08:00 committed by openeuler-sync-bot
parent 221f9e846c
commit 574cefcacb
2 changed files with 19 additions and 6 deletions

View File

@ -1,33 +1,40 @@
diff -up rpcbind-0.2.4/src/rpcbind.c.orig rpcbind-0.2.4/src/rpcbind.c --- rpcbind-1.2.6/src/rpcbind.c 2023-03-27 15:17:28.116410124 +0800
--- rpcbind-0.2.4/src/rpcbind.c.orig 2017-03-21 10:12:35.005190509 -0400 +++ rpcbind-1.2.6-dev/src/rpcbind.c 2023-03-27 15:37:14.215749666 +0800
+++ rpcbind-0.2.4/src/rpcbind.c 2017-03-21 10:36:45.510507649 -0400 @@ -143,6 +143,10 @@ static void rbllist_add(rpcprog_t, rpcve
@@ -144,6 +144,8 @@ static void rbllist_add(rpcprog_t, rpcve
static void terminate(int); static void terminate(int);
static void parseargs(int, char *[]); static void parseargs(int, char *[]);
+#ifndef WITHOUT_SYSTEMD
+char *systemdtmp = "/usr/bin/systemd-tmpfiles --create rpcbind.conf"; +char *systemdtmp = "/usr/bin/systemd-tmpfiles --create rpcbind.conf";
+#endif
+ +
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@@ -151,13 +153,21 @@ main(int argc, char *argv[]) @@ -150,13 +154,27 @@ main(int argc, char *argv[])
void *nc_handle; /* Net config handle */ void *nc_handle; /* Net config handle */
struct rlimit rl; struct rlimit rl;
int maxrec = RPC_MAXDATASIZE; int maxrec = RPC_MAXDATASIZE;
+#ifndef WITHOUT_SYSTEMD
+ int once = 1; + int once = 1;
+#endif
parseargs(argc, argv); parseargs(argc, argv);
+#ifndef WITHOUT_SYSTEMD
+tryagain: +tryagain:
+#endif
/* Check that another rpcbind isn't already running. */ /* Check that another rpcbind isn't already running. */
if ((rpcbindlockfd = (open(RPCBINDDLOCK, if ((rpcbindlockfd = (open(RPCBINDDLOCK,
- O_RDONLY|O_CREAT, 0444))) == -1) - O_RDONLY|O_CREAT, 0444))) == -1)
+ O_RDONLY|O_CREAT, 0444))) == -1) { + O_RDONLY|O_CREAT, 0444))) == -1) {
+#ifndef WITHOUT_SYSTEMD
+ if (once) { + if (once) {
+ once = system(systemdtmp); /* set once to avoid a warning */ + once = system(systemdtmp); /* set once to avoid a warning */
+ once = 0; + once = 0;
+ goto tryagain; + goto tryagain;
+ } + }
+#endif
err(1, "%s", RPCBINDDLOCK); err(1, "%s", RPCBINDDLOCK);
+ } + }

View File

@ -3,7 +3,7 @@
Name: rpcbind Name: rpcbind
Version: 1.2.6 Version: 1.2.6
Release: 4 Release: 5
Summary: Universal addresses to RPC program number mapper Summary: Universal addresses to RPC program number mapper
License: BSD License: BSD
@ -118,6 +118,12 @@ fi
%{_mandir}/man8/*.8.gz %{_mandir}/man8/*.8.gz
%changelog %changelog
* Mon Mar 27 2023 wangqing <wangqing151@huawei.com> - 1.2.6-5
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:add macro WITHOUT_SYSTEMD to relieve dependence on systemd
* Wed Mar 30 2022 kircher <majun65@huawei.com> - 1.2.6-4 * Wed Mar 30 2022 kircher <majun65@huawei.com> - 1.2.6-4
- Type:bugfix - Type:bugfix
- Id:NA - Id:NA