177 lines
5 KiB
Diff
177 lines
5 KiB
Diff
diff --git a/configure.ac b/configure.ac
|
|
index c0ef896..573e4fd 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -20,6 +20,12 @@ AM_CONDITIONAL(LIBSETDEBUG, test x$lib_setdebug = xyes)
|
|
AC_ARG_ENABLE([warmstarts],
|
|
AS_HELP_STRING([--enable-warmstarts], [Enables Warm Starts @<:@default=no@:>@]))
|
|
AM_CONDITIONAL(WARMSTART, test x$enable_warmstarts = xyes)
|
|
+AS_IF([test x$enable_warmstarts = xyes], [
|
|
+ warmstarts_opt=-w
|
|
+], [
|
|
+ warmstarts_opt=
|
|
+])
|
|
+AC_SUBST([warmstarts_opt], [$warmstarts_opt])
|
|
|
|
AC_ARG_ENABLE([rmtcalls],
|
|
AS_HELP_STRING([--enable-rmtcalls], [Enables Remote Calls @<:@default=no@:>@]))
|
|
@@ -44,6 +50,17 @@ AC_SUBST([nss_modules], [$with_nss_modules])
|
|
|
|
PKG_CHECK_MODULES([TIRPC], [libtirpc])
|
|
|
|
+CPPFLAGS=$TIRPC_CFLAGS
|
|
+AC_MSG_CHECKING([for abstract socket support in libtirpc])
|
|
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
|
|
+#include <rpc/rpc.h>
|
|
+],[
|
|
+char *path = _PATH_RPCBINDSOCK_ABSTRACT;
|
|
+])], [have_abstract=yes], [have_abstract=no])
|
|
+CPPFLAGS=
|
|
+AC_MSG_RESULT([$have_abstract])
|
|
+AM_CONDITIONAL(ABSTRACT, [ test "x$have_abstract" = "xyes" ])
|
|
+
|
|
PKG_PROG_PKG_CONFIG
|
|
AC_ARG_WITH([systemdsystemunitdir],
|
|
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
|
|
@@ -70,4 +87,4 @@ AC_CHECK_HEADERS([nss.h])
|
|
AC_SUBST([_sbindir])
|
|
AC_CONFIG_COMMANDS_PRE([eval eval _sbindir=$sbindir])
|
|
|
|
-AC_OUTPUT([Makefile systemd/rpcbind.service])
|
|
+AC_OUTPUT([Makefile systemd/rpcbind.service systemd/rpcbind.socket])
|
|
diff --git a/src/rpcbind.c b/src/rpcbind.c
|
|
index 25d8a90..ecebe97 100644
|
|
--- a/src/rpcbind.c
|
|
+++ b/src/rpcbind.c
|
|
@@ -552,8 +552,10 @@ init_transport(struct netconfig *nconf)
|
|
syslog(LOG_ERR, "cannot bind %s on %s: %m",
|
|
(hosts[nhostsbak] == NULL) ? "*" :
|
|
hosts[nhostsbak], nconf->nc_netid);
|
|
- if (res != NULL)
|
|
+ if (res != NULL) {
|
|
freeaddrinfo(res);
|
|
+ res = NULL;
|
|
+ }
|
|
continue;
|
|
} else
|
|
checkbind++;
|
|
diff --git a/src/rpcinfo.c b/src/rpcinfo.c
|
|
index 0e14f78..006057a 100644
|
|
--- a/src/rpcinfo.c
|
|
+++ b/src/rpcinfo.c
|
|
@@ -311,29 +311,17 @@ main (int argc, char **argv)
|
|
return (0);
|
|
}
|
|
|
|
+/* Evaluate to actual length of the `sockaddr_un' structure, whether
|
|
+ * abstract or not.
|
|
+ */
|
|
+#include <stddef.h>
|
|
+#define SUN_LEN_A(ptr) (offsetof(struct sockaddr_un, sun_path) \
|
|
+ + 1 + strlen((ptr)->sun_path + 1))
|
|
+
|
|
static CLIENT *
|
|
local_rpcb (rpcprog_t prog, rpcvers_t vers)
|
|
{
|
|
-#if 0
|
|
- void *localhandle;
|
|
- struct netconfig *nconf;
|
|
CLIENT *clnt;
|
|
-
|
|
- localhandle = setnetconfig();
|
|
- while ((nconf = getnetconfig(localhandle)) != NULL) {
|
|
- if (nconf->nc_protofmly != NULL &&
|
|
- strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0)
|
|
- break;
|
|
- }
|
|
- if (nconf == NULL) {
|
|
- warnx("getnetconfig: %s", nc_sperror());
|
|
- return (NULL);
|
|
- }
|
|
-
|
|
- clnt = clnt_tp_create (/* "localhost"*/ NULL, prog, vers, nconf);
|
|
- endnetconfig(localhandle);
|
|
- return clnt;
|
|
-#else
|
|
struct netbuf nbuf;
|
|
struct sockaddr_un sun;
|
|
int sock;
|
|
@@ -344,13 +332,26 @@ local_rpcb (rpcprog_t prog, rpcvers_t vers)
|
|
return NULL;
|
|
|
|
sun.sun_family = AF_LOCAL;
|
|
+
|
|
+#ifdef _PATH_RPCBINDSOCK_ABSTRACT
|
|
+ memcpy(sun.sun_path, _PATH_RPCBINDSOCK_ABSTRACT,
|
|
+ sizeof(_PATH_RPCBINDSOCK_ABSTRACT));
|
|
+ nbuf.len = SUN_LEN_A (&sun);
|
|
+ nbuf.maxlen = sizeof (struct sockaddr_un);
|
|
+ nbuf.buf = &sun;
|
|
+
|
|
+ clnt = clnt_vc_create (sock, &nbuf, prog, vers, 0, 0);
|
|
+ if (clnt)
|
|
+ return clnt;
|
|
+#endif
|
|
+
|
|
strcpy (sun.sun_path, _PATH_RPCBINDSOCK);
|
|
nbuf.len = SUN_LEN (&sun);
|
|
nbuf.maxlen = sizeof (struct sockaddr_un);
|
|
nbuf.buf = &sun;
|
|
|
|
- return clnt_vc_create (sock, &nbuf, prog, vers, 0, 0);
|
|
-#endif
|
|
+ clnt = clnt_vc_create (sock, &nbuf, prog, vers, 0, 0);
|
|
+ return clnt;
|
|
}
|
|
|
|
#ifdef PORTMAP
|
|
diff --git a/systemd/rpcbind.service.in b/systemd/rpcbind.service.in
|
|
index 7b1c74b..c892ca8 100644
|
|
--- a/systemd/rpcbind.service.in
|
|
+++ b/systemd/rpcbind.service.in
|
|
@@ -12,7 +12,7 @@ Wants=rpcbind.target
|
|
[Service]
|
|
Type=notify
|
|
# distro can provide a drop-in adding EnvironmentFile=-/??? if needed.
|
|
-ExecStart=@_sbindir@/rpcbind $RPCBIND_OPTIONS -w -f
|
|
+ExecStart=@_sbindir@/rpcbind $RPCBIND_OPTIONS @warmstarts_opt@ -f
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
diff --git a/systemd/rpcbind.socket b/systemd/rpcbind.socket
|
|
index 3b1a936..685341c 100644
|
|
--- a/systemd/rpcbind.socket
|
|
+++ b/systemd/rpcbind.socket
|
|
@@ -6,6 +6,7 @@ Before=rpcbind.target
|
|
|
|
[Socket]
|
|
ListenStream=/run/rpcbind.sock
|
|
+#ListenStream=@/run/rpcbind.sock
|
|
|
|
# RPC netconfig can't handle ipv6/ipv4 dual sockets
|
|
BindIPv6Only=ipv6-only
|
|
diff --git a/systemd/rpcbind.socket.in b/systemd/rpcbind.socket.in
|
|
new file mode 100644
|
|
index 0000000..5dd09a1
|
|
--- /dev/null
|
|
+++ b/systemd/rpcbind.socket.in
|
|
@@ -0,0 +1,19 @@
|
|
+[Unit]
|
|
+Description=RPCbind Server Activation Socket
|
|
+DefaultDependencies=no
|
|
+Wants=rpcbind.target
|
|
+Before=rpcbind.target
|
|
+
|
|
+[Socket]
|
|
+ListenStream=/run/rpcbind.sock
|
|
+@ABSTRACT_TRUE@ListenStream=@/run/rpcbind.sock
|
|
+
|
|
+# RPC netconfig can't handle ipv6/ipv4 dual sockets
|
|
+BindIPv6Only=ipv6-only
|
|
+ListenStream=0.0.0.0:111
|
|
+ListenDatagram=0.0.0.0:111
|
|
+ListenStream=[::]:111
|
|
+ListenDatagram=[::]:111
|
|
+
|
|
+[Install]
|
|
+WantedBy=sockets.target
|