summaryrefslogtreecommitdiff
path: root/sunrpc/key_call.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
committerUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
commita334319f6530564d22e775935d9c91663623a1b4 (patch)
treeb5877475619e4c938e98757d518bb1e9cbead751 /sunrpc/key_call.c
parent0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff)
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'sunrpc/key_call.c')
-rw-r--r--sunrpc/key_call.c91
1 files changed, 85 insertions, 6 deletions
diff --git a/sunrpc/key_call.c b/sunrpc/key_call.c
index 611c37256c..211f61db70 100644
--- a/sunrpc/key_call.c
+++ b/sunrpc/key_call.c
@@ -51,6 +51,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 */
@@ -382,7 +386,7 @@ getkeyserv_handle (int vers)
struct timeval wait_time;
int fd;
struct sockaddr_un name;
- socklen_t namelen = sizeof(struct sockaddr_un);
+ int namelen = sizeof(struct sockaddr_un);
#define TOTAL_TIMEOUT 30 /* total timeout talking to keyserver */
#define TOTAL_TRIES 5 /* Number of tries */
@@ -400,7 +404,6 @@ getkeyserv_handle (int vers)
/* if pid has changed, destroy client and rebuild */
if (kcp->client != NULL && kcp->pid != __getpid ())
{
- auth_destroy (kcp->client->cl_auth);
clnt_destroy (kcp->client);
kcp->client = NULL;
}
@@ -500,6 +503,73 @@ key_call_socket (u_long proc, xdrproc_t xdr_arg, char *arg,
return result;
}
+#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, ret;
+ 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;
+
+ INTUSE(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);
+
+ ret = __door_call (fd, &args);
+ free (data_ptr);
+ close (fd);
+
+ if (ret < 0)
+ return 0;
+
+ 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));
+ INTUSE(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
@@ -510,6 +580,9 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
#ifndef SO_PASSCRED
static int use_keyenvoy;
#endif
+#ifdef HAVE_DOORS
+ static int not_use_doors;
+#endif
if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL)
{
@@ -533,6 +606,15 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
return 1;
}
+#ifdef HAVE_DOORS
+ if (!not_use_doors)
+ {
+ if (key_call_door (proc, xdr_arg, arg, xdr_rslt, rslt))
+ return 1;
+ not_use_doors = 1;
+ }
+#endif
+
#ifdef SO_PASSCRED
return key_call_socket (proc, xdr_arg, arg, xdr_rslt, rslt);
#else
@@ -553,11 +635,8 @@ __rpc_thread_key_cleanup (void)
struct key_call_private *kcp = RPC_THREAD_VARIABLE(key_call_private_s);
if (kcp) {
- if (kcp->client) {
- if (kcp->client->cl_auth)
- auth_destroy (kcp->client->cl_auth);
+ if (kcp->client)
clnt_destroy(kcp->client);
- }
free (kcp);
}
}