Therefore, add macro WITHOUT_SYSTEMD to relieve dependence on systemd. Signed-off-by: Qing Wang <wangqing151@huawei.com> (cherry picked from commit 18d75374a483a197e846016e3a278584df39b7b2)
43 lines
1.2 KiB
Diff
43 lines
1.2 KiB
Diff
--- rpcbind-1.2.6/src/rpcbind.c 2023-03-27 15:17:28.116410124 +0800
|
|
+++ rpcbind-1.2.6-dev/src/rpcbind.c 2023-03-27 15:37:14.215749666 +0800
|
|
@@ -143,6 +143,10 @@ static void rbllist_add(rpcprog_t, rpcve
|
|
static void terminate(int);
|
|
static void parseargs(int, char *[]);
|
|
|
|
+#ifndef WITHOUT_SYSTEMD
|
|
+char *systemdtmp = "/usr/bin/systemd-tmpfiles --create rpcbind.conf";
|
|
+#endif
|
|
+
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
@@ -150,13 +154,27 @@ main(int argc, char *argv[])
|
|
void *nc_handle; /* Net config handle */
|
|
struct rlimit rl;
|
|
int maxrec = RPC_MAXDATASIZE;
|
|
+#ifndef WITHOUT_SYSTEMD
|
|
+ int once = 1;
|
|
+#endif
|
|
|
|
parseargs(argc, argv);
|
|
|
|
+#ifndef WITHOUT_SYSTEMD
|
|
+tryagain:
|
|
+#endif
|
|
/* Check that another rpcbind isn't already running. */
|
|
if ((rpcbindlockfd = (open(RPCBINDDLOCK,
|
|
- O_RDONLY|O_CREAT, 0444))) == -1)
|
|
+ O_RDONLY|O_CREAT, 0444))) == -1) {
|
|
+#ifndef WITHOUT_SYSTEMD
|
|
+ if (once) {
|
|
+ once = system(systemdtmp); /* set once to avoid a warning */
|
|
+ once = 0;
|
|
+ goto tryagain;
|
|
+ }
|
|
+#endif
|
|
err(1, "%s", RPCBINDDLOCK);
|
|
+ }
|
|
|
|
if(flock(rpcbindlockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK)
|
|
errx(1, "another rpcbind is already running. Aborting");
|