From: Steve Langasek <steve.langasek@canonical.com>
Date: Wed, 3 Jun 2026 11:23:10 +0800
Subject: Fix to look directly in /run instead of via the /var/run symlink

Because /var may be a separate partition, and could even be mounted via NFS,
and in wheezy and later /var/run is a symlink to /run, look up our files in
/run directly.  This ensures rpcbind can be started early in boot without
any races.
---
 src/rpcbind.c | 9 ++++++++-
 src/rpcinfo.c | 7 +++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/rpcbind.c b/src/rpcbind.c
index 8562064..9895255 100644
--- a/src/rpcbind.c
+++ b/src/rpcbind.c
@@ -106,7 +106,14 @@ char *nss_modules = "files";
 /* who to suid to if -s is given */
 #define RUN_AS  "daemon"
 
-#define RPCBINDDLOCK "/var/run/rpcbind.lock"
+#define RPCBINDDLOCK "/run/rpcbind.lock"
+
+/* Bypass the libtirpc definition, because we know that /var/run is a compat
+ * symlink to /run. */
+#ifdef _PATH_RPCBINDSOCK
+#undef _PATH_RPCBINDSOCK
+#endif
+#define _PATH_RPCBINDSOCK "/run/rpcbind.sock"
 
 int runasdaemon = 0;
 int insecure = 0;
diff --git a/src/rpcinfo.c b/src/rpcinfo.c
index 006057a..b7d1a11 100644
--- a/src/rpcinfo.c
+++ b/src/rpcinfo.c
@@ -75,6 +75,13 @@
 #define	MAX_VERS	((u_long)4294967295UL)
 #define	UNKNOWN		"unknown"
 
+/* Bypass the libtirpc definition, because we know that /var/run is a compat
+ * symlink to /run. */
+#ifdef _PATH_RPCBINDSOCK
+#undef _PATH_RPCBINDSOCK
+#endif
+#define _PATH_RPCBINDSOCK "/run/rpcbind.sock"
+
 /*
  * Functions to be performed.
  */
