aboutsummaryrefslogtreecommitdiff
path: root/sunrpc
diff options
context:
space:
mode:
Diffstat (limited to 'sunrpc')
-rw-r--r--sunrpc/Makefile4
-rw-r--r--sunrpc/clnt_unix.c5
-rw-r--r--sunrpc/key_call.c87
-rw-r--r--sunrpc/svc_unix.c5
4 files changed, 96 insertions, 5 deletions
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index 2dac993..c96fe4f 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -109,6 +109,10 @@ CFLAGS-xnfs_prot.c = -Wno-unused
CFLAGS-xrquota.c = -Wno-unused
CFLAGS-xkey_prot.c = -Wno-unused
+ifeq (yes,$(have_doors))
+CPPFLAGS-key_call.c += -DHAVE_DOORS=1
+endif
+
include ../Rules
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) \
diff --git a/sunrpc/clnt_unix.c b/sunrpc/clnt_unix.c
index 64b9ca9..ad12d5f 100644
--- a/sunrpc/clnt_unix.c
+++ b/sunrpc/clnt_unix.c
@@ -458,7 +458,10 @@ __msgread (int sock, void *buf, size_t cnt)
msg.msg_controllen = sizeof(struct cmessage);
msg.msg_flags = 0;
- setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on));
+#ifdef SO_PASSCRED
+ if (setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on)))
+ return -1;
+#endif
return recvmsg (sock, &msg, 0);
}
diff --git a/sunrpc/key_call.c b/sunrpc/key_call.c
index 0219eaf..0aa49cc 100644
--- a/sunrpc/key_call.c
+++ b/sunrpc/key_call.c
@@ -32,8 +32,8 @@
/*
* The original source is from the RPCSRC 4.0 package from Sun Microsystems.
- * The Interface to keyserver protocoll 2 was added by
- * Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
+ * The Interface to keyserver protocoll 2, RPC over AF_UNIX und Linux/doors
+ * was added by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
*/
#include <stdio.h>
@@ -50,6 +50,10 @@
#include <rpc/key_prot.h>
#include <bits/libc-lock.h>
+#ifdef HAVE_DOORS
+# include "door/door.h"
+#endif
+
#define KEY_TIMEOUT 5 /* per-try timeout in seconds */
#define KEY_NRETRY 12 /* number of retries */
@@ -479,13 +483,82 @@ key_call_socket (u_long proc, xdrproc_t xdr_arg, char *arg,
return result;
}
-/* returns 0 on failure, 1 on success */
+#ifdef HAVE_DOORS
+/* returns 0 on failure, 1 on success */
+static int
+internal_function
+key_call_door (u_long proc, xdrproc_t xdr_arg, char *arg,
+ xdrproc_t xdr_rslt, char *rslt)
+{
+ XDR xdrs;
+ int fd;
+ door_arg_t args;
+ char *data_ptr;
+ u_long data_len = 0;
+ char res[255];
+
+ if ((fd = open("/var/run/keyservdoor", O_RDONLY)) < 0)
+ return 0;
+ res[0] = 0;
+
+ data_len = xdr_sizeof (xdr_arg, arg);
+ data_ptr = calloc (1, data_len + 2 * sizeof (u_long));
+ if (data_ptr == NULL)
+ return 0;
+
+ xdrmem_create (&xdrs, &data_ptr[2 * sizeof (u_long)], data_len, XDR_ENCODE);
+ if (!xdr_arg (&xdrs, arg))
+ {
+ xdr_destroy (&xdrs);
+ free (data_ptr);
+ return 0;
+ }
+ xdr_destroy (&xdrs);
+
+ memcpy (data_ptr, &proc, sizeof (u_long));
+ memcpy (&data_ptr[sizeof (proc)], &data_len, sizeof (u_long));
+
+ args.data_ptr = data_ptr;
+ args.data_size = data_len + 2 * sizeof (u_long);
+ args.desc_ptr = NULL;
+ args.desc_num = 0;
+ args.rbuf = res;
+ args.rsize = sizeof (res);
+
+ if (__door_call (fd, &args) < 0)
+ return 0;
+
+ free (data_ptr);
+ close (fd);
+
+ memcpy (&data_len, args.data_ptr, sizeof (u_long));
+ if (data_len != 0)
+ return 0;
+
+ memcpy (&data_len, &args.data_ptr[sizeof (u_long)], sizeof (u_long));
+ xdrmem_create (&xdrs, &args.data_ptr[2 * sizeof (u_long)],
+ data_len, XDR_DECODE);
+ if (!xdr_rslt (&xdrs, rslt))
+ {
+ xdr_destroy (&xdrs);
+ return 0;
+ }
+ xdr_destroy (&xdrs);
+
+ return 1;
+}
+#endif
+
+/* returns 0 on failure, 1 on success */
static int
internal_function
key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
xdrproc_t xdr_rslt, char *rslt)
{
static int use_keyenvoy = 0;
+#ifdef HAVE_DOORS
+ static int use_doors = 1;
+#endif
if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL)
{
@@ -509,6 +582,14 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
return 1;
}
+#ifdef HAVE_DOORS
+ if (use_doors)
+ {
+ if (key_call_door (proc, xdr_arg, arg, xdr_rslt, rslt))
+ return 1;
+ use_doors = 0;
+ }
+#endif
if (!use_keyenvoy)
{
if (key_call_socket (proc, xdr_arg, arg, xdr_rslt, rslt))
diff --git a/sunrpc/svc_unix.c b/sunrpc/svc_unix.c
index a8ed534..c42d30e 100644
--- a/sunrpc/svc_unix.c
+++ b/sunrpc/svc_unix.c
@@ -307,7 +307,10 @@ __msgread (int sock, void *buf, size_t cnt)
msg.msg_controllen = sizeof (struct cmessage);
msg.msg_flags = 0;
- setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on));
+#ifdef SO_PASSCRED
+ if (setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on)))
+ return -1;
+#endif
return recvmsg (sock, &msg, 0);
}