static char sccsid
[] = "@(#)keyenvoy.c 2.2 88/08/10 4.0 RPCSRC";
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
* unrestricted use provided that this legend is included on all tape
* media and as a part of the software program in whole or part. Users
* may copy or modify Sun RPC without charge, but are not authorized
* to license or distribute it to anyone else except as part of a product or
* program developed by the user.
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
* Sun RPC is provided with no support and without any obligation on the
* part of Sun Microsystems, Inc. to assist in its use, correction,
* modification or enhancement.
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
* or profits or other special, indirect and consequential damages, even if
* Sun has been advised of the possibility of such damages.
* Mountain View, California 94043
* Copyright (C) 1986, Sun Microsystems, Inc.
#include <rpc/key_prot.h>
* Talk to the keyserver on a privileged port on the part of a calling program.
* Protocol is for caller to send through stdin the procedure number
* to call followed by the argument data. We call the keyserver, and
* send the results back to the caller through stdout.
* Non-zero exit status means something went wrong.
#define TOTAL_TIMEOUT 30 /* total timeout talking to keyserver */
#define TOTAL_TRIES 10 /* Number of tries */
* Opaque data that we send and receive
"This program cannot be used interactively.\n");
open("/dev/console", O_WRONLY
, 0);
xdrstdio_create(&xdrs_args
, stdin
, XDR_DECODE
);
xdrstdio_create(&xdrs_rslt
, stdout
, XDR_ENCODE
);
if ( ! xdr_u_long(&xdrs_args
, &proc
)) {
if (! xdr_opaqn(&xdrs_args
, &args
)) {
debug("recving args failed");
if (! callkeyserver(proc
, xdr_opaqn
, &args
, xdr_opaqn
, &rslt
)) {
debug("rpc_call failed");
if (! xdr_opaqn(&xdrs_rslt
, &rslt
)) {
debug("sending args failed");
callkeyserver(proc
, xdr_args
, args
, xdr_rslt
, rslt
)
struct sockaddr_in remote
;
* set up the remote address
remote
.sin_addr
.s_addr
= htonl(INADDR_LOOPBACK
);
remote
.sin_family
= AF_INET
;
wait
.tv_sec
= TOTAL_TIMEOUT
/TOTAL_TRIES
; wait
.tv_usec
= 0;
client
= clntudp_create(&remote
, KEY_PROG
, KEY_VERS
, wait
, &sd
);
* Check that server is bound to a reserved port, so
* that noone can masquerade as the keyserver.
if (ntohs(remote
.sin_port
) >= IPPORT_RESERVED
) {
* All we care about really is sending the real uid
client
->cl_auth
= authunix_create("", getuid(), 0, 0, NULL
);
if (client
->cl_auth
== NULL
) {
wait
.tv_sec
= TOTAL_TIMEOUT
; wait
.tv_usec
= 0;
stat
= clnt_call(client
, proc
, xdr_args
, args
, xdr_rslt
, rslt
, wait
);
if (stat
!= RPC_SUCCESS
) {
debug("clnt_call failed");
return (stat
== RPC_SUCCESS
);
* Don't know the length on decode, so just keep receiving until failure.
for (i
= 0; i
< MAXOPAQUE
&& xdr_int(xdrs
, &objp
->data
[i
]); i
++) {
for (i
= 0; i
< objp
->len
; i
++) {
if (! xdr_int(xdrs
, &objp
->data
[i
])) {
fprintf(stderr
, "%s\n", msg
);