diff options
Diffstat (limited to 'sunrpc')
-rw-r--r-- | sunrpc/auth_des.c | 15 | ||||
-rw-r--r-- | sunrpc/auth_none.c | 2 | ||||
-rw-r--r-- | sunrpc/auth_unix.c | 2 | ||||
-rw-r--r-- | sunrpc/clnt_raw.c | 2 | ||||
-rw-r--r-- | sunrpc/clnt_tcp.c | 2 | ||||
-rw-r--r-- | sunrpc/key_call.c | 79 | ||||
-rw-r--r-- | sunrpc/openchild.c | 17 | ||||
-rw-r--r-- | sunrpc/rpc/auth.h | 16 | ||||
-rw-r--r-- | sunrpc/rpc_cmsg.c | 2 |
9 files changed, 63 insertions, 74 deletions
diff --git a/sunrpc/auth_des.c b/sunrpc/auth_des.c index 4ea6391c6e..9b030567d3 100644 --- a/sunrpc/auth_des.c +++ b/sunrpc/auth_des.c @@ -109,7 +109,7 @@ struct ad_private * Create the client des authentication object */ AUTH * -authdes_create (const char *servername, u_int window, +authdes_create (const char *servername, u_int window, struct sockaddr *syncaddr, des_block * ckey) /* servername - network name of server */ /* window - time to live */ @@ -161,6 +161,7 @@ authdes_pk_create (const char *servername, netobj * pkey, u_int window, */ bcopy (namebuf, ad->ad_fullname, ad->ad_fullnamelen + 1); bcopy (servername, ad->ad_servername, ad->ad_servernamelen + 1); + ad->ad_timediff.tv_sec = ad->ad_timediff.tv_usec = 0; if (syncaddr != NULL) { ad->ad_syncaddr = *syncaddr; @@ -198,11 +199,13 @@ failed: if (auth != NULL) FREE (auth, sizeof (AUTH)); if (ad != NULL) - FREE (ad, sizeof (struct ad_private)); - if (ad->ad_fullname != NULL) - FREE (ad->ad_fullname, ad->ad_fullnamelen + 1); - if (ad->ad_servername != NULL) - FREE (ad->ad_servername, ad->ad_servernamelen + 1); + { + FREE (ad, sizeof (struct ad_private)); + if (ad->ad_fullname != NULL) + FREE (ad->ad_fullname, ad->ad_fullnamelen + 1); + if (ad->ad_servername != NULL) + FREE (ad->ad_servername, ad->ad_servernamelen + 1); + } return (NULL); } diff --git a/sunrpc/auth_none.c b/sunrpc/auth_none.c index a7c1524ef5..0ab306407c 100644 --- a/sunrpc/auth_none.c +++ b/sunrpc/auth_none.c @@ -44,8 +44,6 @@ static char sccsid[] = "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #define MAX_MARSHEL_SIZE 20 -extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); - /* * Authenticator operations routines */ diff --git a/sunrpc/auth_unix.c b/sunrpc/auth_unix.c index 5e5dc995ca..ac9b53a3e3 100644 --- a/sunrpc/auth_unix.c +++ b/sunrpc/auth_unix.c @@ -54,8 +54,6 @@ static char sccsid[] = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #include <rpc/auth.h> #include <rpc/auth_unix.h> -extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); - /* * Unix authenticator operations vector */ diff --git a/sunrpc/clnt_raw.c b/sunrpc/clnt_raw.c index a9ff3ca00a..18ae2414ab 100644 --- a/sunrpc/clnt_raw.c +++ b/sunrpc/clnt_raw.c @@ -46,8 +46,6 @@ static char sccsid[] = "@(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro"; #include <rpc/svc.h> #include <rpc/xdr.h> -extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); - #define MCALL_MSG_SIZE 24 /* diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c index 02c43dd26f..82b34b6259 100644 --- a/sunrpc/clnt_tcp.c +++ b/sunrpc/clnt_tcp.c @@ -58,8 +58,6 @@ static char sccsid[] = "@(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro"; #include <sys/socket.h> #include <rpc/pmap_clnt.h> -extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); - #define MCALL_MSG_SIZE 24 struct ct_data diff --git a/sunrpc/key_call.c b/sunrpc/key_call.c index ba1c2638fb..dff7da6a7a 100644 --- a/sunrpc/key_call.c +++ b/sunrpc/key_call.c @@ -32,11 +32,12 @@ /* * The original source is from the RPCSRC 4.0 package from Sun Microsystems. - * The Interface to keyserver protocoll 2 was added by + * The Interface to keyserver protocoll 2 was added by * Thorsten Kukuk <kukuk@vt.uni-paderborn.de> */ #include <stdio.h> +#include <errno.h> #include <signal.h> #include <unistd.h> #include <string.h> @@ -52,21 +53,21 @@ #define debug(msg) /* turn off debugging */ -extern int _openchild (char *command, FILE ** fto, FILE ** ffrom); +extern int _openchild (char *command, FILE **fto, FILE **ffrom); static int key_call (u_long, xdrproc_t xdr_arg, char *, xdrproc_t xdr_rslt, char *); static struct timeval trytimeout = {KEY_TIMEOUT, 0}; -static struct timeval tottimeout = {KEY_TIMEOUT * KEY_NRETRY, 0}; +static struct timeval tottimeout = {KEY_TIMEOUT *KEY_NRETRY, 0}; int key_setsecret (char *secretkey) { keystatus status; - if (!key_call ((u_long) KEY_SET, (xdrproc_t) xdr_keybuf, secretkey, + if (!key_call ((u_long) KEY_SET, (xdrproc_t) xdr_keybuf, secretkey, (xdrproc_t) xdr_keystatus, (char *) &status)) return -1; if (status != KEY_SUCCESS) @@ -102,14 +103,14 @@ key_secretkey_is_set (void) } int -key_encryptsession (char *remotename, des_block * deskey) +key_encryptsession (char *remotename, des_block *deskey) { cryptkeyarg arg; cryptkeyres res; arg.remotename = remotename; arg.deskey = *deskey; - if (!key_call ((u_long) KEY_ENCRYPT, (xdrproc_t) xdr_cryptkeyarg, + if (!key_call ((u_long) KEY_ENCRYPT, (xdrproc_t) xdr_cryptkeyarg, (char *) &arg, (xdrproc_t) xdr_cryptkeyres, (char *) &res)) return -1; @@ -123,7 +124,7 @@ key_encryptsession (char *remotename, des_block * deskey) } int -key_decryptsession (char *remotename, des_block * deskey) +key_decryptsession (char *remotename, des_block *deskey) { cryptkeyarg arg; cryptkeyres res; @@ -143,8 +144,8 @@ key_decryptsession (char *remotename, des_block * deskey) } int -key_encryptsession_pk (char *remotename, netobj * remotekey, - des_block * deskey) +key_encryptsession_pk (char *remotename, netobj *remotekey, + des_block *deskey) { cryptkeyarg2 arg; cryptkeyres res; @@ -152,7 +153,7 @@ key_encryptsession_pk (char *remotename, netobj * remotekey, arg.remotename = remotename; arg.remotekey = *remotekey; arg.deskey = *deskey; - if (!key_call ((u_long) KEY_ENCRYPT_PK, (xdrproc_t) xdr_cryptkeyarg2, + if (!key_call ((u_long) KEY_ENCRYPT_PK, (xdrproc_t) xdr_cryptkeyarg2, (char *) &arg, (xdrproc_t) xdr_cryptkeyres, (char *) &res)) return -1; @@ -166,8 +167,8 @@ key_encryptsession_pk (char *remotename, netobj * remotekey, } int -key_decryptsession_pk (char *remotename, netobj * remotekey, - des_block * deskey) +key_decryptsession_pk (char *remotename, netobj *remotekey, + des_block *deskey) { cryptkeyarg2 arg; cryptkeyres res; @@ -175,7 +176,7 @@ key_decryptsession_pk (char *remotename, netobj * remotekey, arg.remotename = remotename; arg.remotekey = *remotekey; arg.deskey = *deskey; - if (!key_call ((u_long) KEY_DECRYPT_PK, (xdrproc_t) xdr_cryptkeyarg2, + if (!key_call ((u_long) KEY_DECRYPT_PK, (xdrproc_t) xdr_cryptkeyarg2, (char *) &arg, (xdrproc_t) xdr_cryptkeyres, (char *) &res)) return -1; @@ -189,7 +190,7 @@ key_decryptsession_pk (char *remotename, netobj * remotekey, } int -key_gendes (des_block * key) +key_gendes (des_block *key) { struct sockaddr_in sin; CLIENT *client; @@ -222,7 +223,7 @@ key_setnet (struct key_netstarg *arg) { keystatus status; - if (!key_call ((u_long) KEY_NET_PUT, (xdrproc_t) xdr_key_netstarg, + if (!key_call ((u_long) KEY_NET_PUT, (xdrproc_t) xdr_key_netstarg, (char *) arg,(xdrproc_t) xdr_keystatus, (char *) &status)) return -1; @@ -235,7 +236,7 @@ key_setnet (struct key_netstarg *arg) } int -key_get_conv (char *pkey, des_block * deskey) +key_get_conv (char *pkey, des_block *deskey) { cryptkeyres res; @@ -273,7 +274,7 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg, XDR xdrrslt; FILE *fargs; FILE *frslt; - void (*osigchild) (int); + sigset_t oldmask, mask; union wait status; int pid; int success; @@ -281,9 +282,6 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg, uid_t euid; static char MESSENGER[] = "/usr/etc/keyenvoy"; - success = 1; - osigchild = signal (SIGCHLD, SIG_IGN); - if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL) { cryptkeyres *res; @@ -306,6 +304,11 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg, return 1; } + success = 1; + sigemptyset (&mask); + sigaddset (&mask, SIGCHLD); + sigprocmask (SIG_BLOCK, &mask, &oldmask); + /* * We are going to exec a set-uid program which makes our effective uid * zero, and authenticates us with our real uid. We need to make the @@ -320,6 +323,7 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg, if (pid < 0) { debug ("open_streams"); + sigprocmask(SIG_SETMASK, &oldmask, NULL); return (0); } xdrstdio_create (&xdrargs, fargs, XDR_ENCODE); @@ -337,27 +341,26 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg, debug ("xdr rslt"); success = 0; } + fclose(frslt); -#ifdef NOTDEF - /* - * WARNING! XXX - * The original code appears first. wait4 returns only after the process - * with the requested pid terminates. The effect of using wait() instead - * has not been determined. - */ - fclose (frslt); - if (wait4 (pid, &status, 0, NULL) < 0 || status.w_retcode != 0) + wait_again: + if (wait4(pid, &status, 0, NULL) < 0) { - debug ("wait4"); - success = 0; - } -#endif /* def NOTDEF */ - if (wait (&status) < 0 || status.w_retcode != 0) - { - debug ("wait"); - success = 0; + if (errno == EINTR) + goto wait_again; + debug("wait4"); + if (errno == ECHILD || errno == ESRCH) + perror("wait"); + else + success = 0; } - signal (SIGCHLD, osigchild); + else + if (status.w_retcode) + { + debug("wait4 1"); + success = 0; + } + sigprocmask(SIG_SETMASK, &oldmask, NULL); return (success); } diff --git a/sunrpc/openchild.c b/sunrpc/openchild.c index 2fa26fae45..11e06006b3 100644 --- a/sunrpc/openchild.c +++ b/sunrpc/openchild.c @@ -1,6 +1,3 @@ -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)openchild.c 2.3 88/08/15 4.0 RPCSRC; from 1.7 88/02/08 SMI"; -#endif /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -46,8 +43,6 @@ static char sccsid[] = "@(#)openchild.c 2.3 88/08/15 4.0 RPCSRC; from 1.7 88/02/ #include <rpc/rpc.h> #include <rpc/clnt.h> -static char SHELL[] = "/bin/sh"; - /* * returns pid, or -1 for failure */ @@ -58,13 +53,12 @@ _openchild (char *command, FILE ** fto, FILE ** ffrom) int pid; int pdto[2]; int pdfrom[2]; - char *com; if (pipe (pdto) < 0) goto error1; if (pipe (pdfrom) < 0) goto error2; - switch (pid = vfork ()) + switch (pid = fork ()) { case -1: goto error3; @@ -77,13 +71,12 @@ _openchild (char *command, FILE ** fto, FILE ** ffrom) dup (pdto[0]); close (1); dup (pdfrom[1]); + fflush (stderr); for (i = _rpc_dtablesize () - 1; i >= 3; i--) close (i); - com = malloc (strlen (command) + 6); - if (com == NULL) - _exit (~0); - sprintf (com, "exec %s", command); - execl (SHELL, basename (SHELL), "-c", com, NULL); + fflush (stderr); + execlp (command, command, 0); + perror ("exec"); _exit (~0); default: diff --git a/sunrpc/rpc/auth.h b/sunrpc/rpc/auth.h index 22174193d4..9519ca27f4 100644 --- a/sunrpc/rpc/auth.h +++ b/sunrpc/rpc/auth.h @@ -99,7 +99,7 @@ struct AUTH { struct auth_ops { void (*ah_nextverf) __P ((AUTH *)); int (*ah_marshal) __P ((AUTH *, XDR *)); /* nextverf & serialize */ - int (*ah_validate) __P ((AUTH *, struct opaque_auth *)); + int (*ah_validate) __P ((AUTH *, struct opaque_auth *)); /* validate verifier */ int (*ah_refresh) __P ((AUTH *)); /* refresh credentials */ void (*ah_destroy) __P ((AUTH *)); /* destroy this structure */ @@ -163,7 +163,7 @@ extern AUTH *authunix_create __P ((char *__machname, __uid_t __uid, __gid_t *__aup_gids)); extern AUTH *authunix_create_default __P ((void)); extern AUTH *authnone_create __P ((void)); -extern AUTH *authdes_create __P ((const char *__servername, u_int __window, +extern AUTH *authdes_create __P ((const char *__servername, u_int __window, struct sockaddr *__syncaddr, des_block *__ckey)); @@ -182,7 +182,7 @@ extern AUTH *authdes_create __P ((const char *__servername, u_int __window, extern int getnetname __P ((char *)); extern int host2netname __P ((char *, __const char *, __const char *)); extern int user2netname __P ((char *, __const uid_t, __const char *)); -extern int netname2user __P ((__const char *, uid_t *, gid_t *, int *, +extern int netname2user __P ((__const char *, uid_t *, gid_t *, int *, gid_t *)); extern int netname2host __P ((__const char *, char *, __const int)); @@ -200,11 +200,11 @@ extern int key_setsecret __P ((char *)); extern int key_secretkey_is_set __P ((void)); extern int key_get_conv __P ((char *, des_block *)); -__END_DECLS +/* + * XDR an opaque authentication struct. + */ +extern bool_t xdr_opaque_auth __P ((XDR *, struct opaque_auth *)); -/* This is for compiling the glibc NIS+ code with DES auth. */ -#ifdef _LIBC -#define HAVE_SECURE_RPC 1 -#endif +__END_DECLS #endif /* rpc/auth.h */ diff --git a/sunrpc/rpc_cmsg.c b/sunrpc/rpc_cmsg.c index 5759360b21..4cd2a8f35a 100644 --- a/sunrpc/rpc_cmsg.c +++ b/sunrpc/rpc_cmsg.c @@ -42,8 +42,6 @@ static char sccsid[] = "@(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro"; #include <sys/param.h> #include <rpc/rpc.h> -extern bool_t xdr_opaque_auth (XDR *, struct opaque_auth *); - /* * XDR a call message */ |