diff options
33 files changed, 425 insertions, 84 deletions
diff --git a/lib/libc/rpc/Makefile.inc b/lib/libc/rpc/Makefile.inc index 9f83aca..5c96968 100644 --- a/lib/libc/rpc/Makefile.inc +++ b/lib/libc/rpc/Makefile.inc @@ -1,5 +1,4 @@ -# from @(#)Makefile 5.11 (Berkeley) 9/6/90 -# $Id$ +# @(#)Makefile 5.11 (Berkeley) 9/6/90 .PATH: ${.CURDIR}/../libc/rpc ${.CURDIR}/. SRCS+= auth_none.c auth_unix.c authunix_prot.c bindresvport.c \ @@ -10,6 +9,28 @@ SRCS+= auth_none.c auth_unix.c authunix_prot.c bindresvport.c \ svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c svc_simple.c \ svc_tcp.c svc_udp.c +SRCS+= clnt_unix.c svc_unix.c + +SRCS+= auth_des.c authdes_prot.c auth_time.c des_soft.c des_crypt.c \ + key_call.c key_prot_xdr.c netname.c netnamer.c rpcdname.c rtime.c \ + svc_auth_des.c crypt_clnt.c crypt_xdr.c crypt_client.c + +CFLAGS+= -DBROKEN_DES + +CLEANFILES= crypt_clnt.c crypt_xdr.c crypt.h + +RPCDIR= ${DESTDIR}/usr/include/rpcsvc +RPCGEN= rpcgen -C + +crypt_clnt.c: ${RPCDIR}/crypt.x crypt.h + ${RPCGEN} -l -o ${.TARGET} ${RPCDIR}/crypt.x + +crypt_xdr.c: ${RPCDIR}/crypt.x crypt.h + ${RPCGEN} -c -o ${.TARGET} ${RPCDIR}/crypt.x + +crypt.h: ${RPCDIR}/crypt.x + ${RPCGEN} -h -o ${.TARGET} ${RPCDIR}/crypt.x + # Only build man pages with libc. .if ${LIB} == "c" # @@ -24,6 +45,9 @@ MAN3+= rpc/bindresvport.3 rpc/getrpcent.3 rpc/getrpcport.3 rpc/rpc.3 MAN5+= rpc/rpc.5 MAN8+= rpc/rstat_svc.8 +MAN3+= rpc/rpc_secure.3 rpc/publickey.3 rpc/rtime.3 rpc/des_crypt.3 +MAN5+= rpc/publickey.5 + MLINKS+= getrpcent.3 getrpcbyname.3 \ getrpcent.3 getrpcbynumber.3 \ getrpcent.3 endrpcent.3 \ diff --git a/lib/libc/rpc/auth_none.c b/lib/libc/rpc/auth_none.c index dc71ce2..b2e2995 100644 --- a/lib/libc/rpc/auth_none.c +++ b/lib/libc/rpc/auth_none.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: auth_none.c,v 1.5 1996/12/30 14:13:30 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index 19c7818..32200c2 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: auth_unix.c,v 1.7 1996/12/30 14:14:39 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/authunix_prot.c b/lib/libc/rpc/authunix_prot.c index d1d6ad0..c818ba0 100644 --- a/lib/libc/rpc/authunix_prot.c +++ b/lib/libc/rpc/authunix_prot.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)authunix_prot.c 1.15 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)authunix_prot.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: authunix_prot.c,v 1.2 1995/05/30 05:41:12 rgrimes Exp $"; #endif /* diff --git a/lib/libc/rpc/bindresvport.c b/lib/libc/rpc/bindresvport.c index 5d97adc..dea8705 100644 --- a/lib/libc/rpc/bindresvport.c +++ b/lib/libc/rpc/bindresvport.c @@ -31,7 +31,7 @@ /*static char *sccsid = "from: @(#)bindresvport.c 1.8 88/02/08 SMI";*/ /*static char *sccsid = "from: @(#)bindresvport.c 2.2 88/07/29 4.0 RPCSRC";*/ /*from: OpenBSD: bindresvport.c,v 1.7 1996/07/30 16:25:47 downsj Exp */ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: bindresvport.c,v 1.6 1996/12/30 14:12:36 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/clnt_generic.c b/lib/libc/rpc/clnt_generic.c index fd0133f..ed754ea 100644 --- a/lib/libc/rpc/clnt_generic.c +++ b/lib/libc/rpc/clnt_generic.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)clnt_generic.c 1.4 87/08/11 (C) 1987 SMI";*/ /*static char *sccsid = "from: @(#)clnt_generic.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: clnt_generic.c,v 1.5 1996/12/30 14:17:20 peter Exp $"; #endif /* @@ -57,10 +57,27 @@ clnt_create(hostname, prog, vers, proto) struct hostent *h; struct protoent *p; struct sockaddr_in sin; + struct sockaddr_un sun; int sock; - struct timeval tv; + static struct timeval tv; CLIENT *client; + if (!strcmp(proto, "unix")) { + bzero((char *)&sun, sizeof(sun)); + sun.sun_family = AF_UNIX; + strcpy(sun.sun_path, hostname); + sun.sun_len = sizeof(sun.sun_len) + sizeof(sun.sun_family) + + strlen(sun.sun_path) + 1; + sock = RPC_ANYSOCK; + client = clntunix_create(&sun, prog, vers, &sock, 0, 0); + if (client == NULL) + return(NULL); + tv.tv_sec = 25; + tv.tv_usec = 0; + clnt_control(client, CLSET_TIMEOUT, &tv); + return(client); + } + h = gethostbyname(hostname); if (h == NULL) { rpc_createerr.cf_stat = RPC_UNKNOWNHOST; diff --git a/lib/libc/rpc/clnt_perror.c b/lib/libc/rpc/clnt_perror.c index 6db23ae..79baac2 100644 --- a/lib/libc/rpc/clnt_perror.c +++ b/lib/libc/rpc/clnt_perror.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: clnt_perror.c,v 1.6 1996/12/30 14:19:34 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/clnt_raw.c b/lib/libc/rpc/clnt_raw.c index cec7357..c715ef69 100644 --- a/lib/libc/rpc/clnt_raw.c +++ b/lib/libc/rpc/clnt_raw.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)clnt_raw.c 1.22 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)clnt_raw.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: clnt_raw.c,v 1.6 1996/12/30 14:21:36 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/clnt_simple.c b/lib/libc/rpc/clnt_simple.c index f49e5a7..5bcfd47 100644 --- a/lib/libc/rpc/clnt_simple.c +++ b/lib/libc/rpc/clnt_simple.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)clnt_simple.c 1.35 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)clnt_simple.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: clnt_simple.c,v 1.6 1996/12/30 14:23:50 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/clnt_tcp.c b/lib/libc/rpc/clnt_tcp.c index 0f457b3..cfb3746 100644 --- a/lib/libc/rpc/clnt_tcp.c +++ b/lib/libc/rpc/clnt_tcp.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)clnt_tcp.c 1.37 87/10/05 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)clnt_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: clnt_tcp.c,v 1.7 1996/12/30 14:36:17 peter Exp $"; #endif /* @@ -355,6 +355,7 @@ clnttcp_abort() { } + static bool_t clnttcp_control(cl, request, info) CLIENT *cl; @@ -362,18 +363,102 @@ clnttcp_control(cl, request, info) char *info; { register struct ct_data *ct = (struct ct_data *)cl->cl_private; + register struct timeval *tv; + int len; switch (request) { + case CLSET_FD_CLOSE: + ct->ct_closeit = TRUE; + break; + case CLSET_FD_NCLOSE: + ct->ct_closeit = FALSE; + break; case CLSET_TIMEOUT: - ct->ct_wait = *(struct timeval *)info; + if (info == NULL) + return(FALSE); + tv = (struct timeval *)info; + ct->ct_wait.tv_sec = tv->tv_sec; + ct->ct_wait.tv_usec = tv->tv_usec; ct->ct_waitset = TRUE; break; case CLGET_TIMEOUT: + if (info == NULL) + return(FALSE); *(struct timeval *)info = ct->ct_wait; break; case CLGET_SERVER_ADDR: + if (info == NULL) + return(FALSE); *(struct sockaddr_in *)info = ct->ct_addr; break; + case CLGET_FD: + if (info == NULL) + return(FALSE); + *(int *)info = ct->ct_sock; + break; + case CLGET_XID: + /* + * use the knowledge that xid is the + * first element in the call structure *. + * This will get the xid of the PREVIOUS call + */ + if (info == NULL) + return(FALSE); + *(u_long *)info = ntohl(*(u_long *)ct->ct_mcall); + break; + case CLSET_XID: + /* This will set the xid of the NEXT call */ + if (info == NULL) + return(FALSE); + *(u_long *)ct->ct_mcall = htonl(*(u_long *)info - 1); + /* decrement by 1 as clnttcp_call() increments once */ + case CLGET_VERS: + /* + * This RELIES on the information that, in the call body, + * the version number field is the fifth field from the + * begining of the RPC header. MUST be changed if the + * call_struct is changed + */ + if (info == NULL) + return(FALSE); + *(u_long *)info = ntohl(*(u_long *)(ct->ct_mcall + + 4 * BYTES_PER_XDR_UNIT)); + break; + case CLSET_VERS: + if (info == NULL) + return(FALSE); + *(u_long *)(ct->ct_mcall + 4 * BYTES_PER_XDR_UNIT) + = htonl(*(u_long *)info); + break; + case CLGET_PROG: + /* + * This RELIES on the information that, in the call body, + * the program number field is the field from the + * begining of the RPC header. MUST be changed if the + * call_struct is changed + */ + if (info == NULL) + return(FALSE); + *(u_long *)info = ntohl(*(u_long *)(ct->ct_mcall + + 3 * BYTES_PER_XDR_UNIT)); + break; + case CLSET_PROG: + if (info == NULL) + return(FALSE); + *(u_long *)(ct->ct_mcall + 3 * BYTES_PER_XDR_UNIT) + = htonl(*(u_long *)info); + break; + case CLGET_LOCAL_ADDR: + len = sizeof(struct sockaddr); + if (getsockname(ct->ct_sock, (struct sockaddr *)info, &len) <0) + return(FALSE); + break; + case CLGET_RETRY_TIMEOUT: + case CLSET_RETRY_TIMEOUT: + case CLGET_SVC_ADDR: + case CLSET_SVC_ADDR: + case CLSET_PUSH_TIMOD: + case CLSET_POP_TIMOD: default: return (FALSE); } diff --git a/lib/libc/rpc/clnt_udp.c b/lib/libc/rpc/clnt_udp.c index 1549bec..035ce96 100644 --- a/lib/libc/rpc/clnt_udp.c +++ b/lib/libc/rpc/clnt_udp.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: clnt_udp.c,v 1.8 1996/12/30 14:40:34 peter Exp $"; #endif /* @@ -419,6 +419,7 @@ clntudp_abort(/*h*/) { } + static bool_t clntudp_control(cl, request, info) CLIENT *cl; @@ -426,23 +427,111 @@ clntudp_control(cl, request, info) char *info; { register struct cu_data *cu = (struct cu_data *)cl->cl_private; + register struct timeval *tv; + int len; switch (request) { + case CLSET_FD_CLOSE: + cu->cu_closeit = TRUE; + break; + case CLSET_FD_NCLOSE: + cu->cu_closeit = FALSE; + break; case CLSET_TIMEOUT: - cu->cu_total = *(struct timeval *)info; + if (info == NULL) + return(FALSE); + tv = (struct timeval *)info; + cu->cu_total.tv_sec = tv->tv_sec; + cu->cu_total.tv_usec = tv->tv_usec; break; case CLGET_TIMEOUT: + if (info == NULL) + return(FALSE); *(struct timeval *)info = cu->cu_total; break; case CLSET_RETRY_TIMEOUT: - cu->cu_wait = *(struct timeval *)info; + if (info == NULL) + return(FALSE); + tv = (struct timeval *)info; + cu->cu_wait.tv_sec = tv->tv_sec; + cu->cu_wait.tv_usec = tv->tv_usec; break; case CLGET_RETRY_TIMEOUT: + if (info == NULL) + return(FALSE); *(struct timeval *)info = cu->cu_wait; break; case CLGET_SERVER_ADDR: + if (info == NULL) + return(FALSE); *(struct sockaddr_in *)info = cu->cu_raddr; break; + case CLGET_FD: + if (info == NULL) + return(FALSE); + *(int *)info = cu->cu_sock; + break; + case CLGET_XID: + /* + * use the knowledge that xid is the + * first element in the call structure *. + * This will get the xid of the PREVIOUS call + */ + if (info == NULL) + return(FALSE); + *(u_long *)info = ntohl(*(u_long *)cu->cu_outbuf); + break; + case CLSET_XID: + /* This will set the xid of the NEXT call */ + if (info == NULL) + return(FALSE); + *(u_long *)cu->cu_outbuf = htonl(*(u_long *)info - 1); + /* decrement by 1 as clntudp_call() increments once */ + case CLGET_VERS: + /* + * This RELIES on the information that, in the call body, + * the version number field is the fifth field from the + * begining of the RPC header. MUST be changed if the + * call_struct is changed + */ + if (info == NULL) + return(FALSE); + *(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf + + 4 * BYTES_PER_XDR_UNIT)); + break; + case CLSET_VERS: + if (info == NULL) + return(FALSE); + *(u_long *)(cu->cu_outbuf + 4 * BYTES_PER_XDR_UNIT) + = htonl(*(u_long *)info); + break; + case CLGET_PROG: + /* + * This RELIES on the information that, in the call body, + * the program number field is the field from the + * begining of the RPC header. MUST be changed if the + * call_struct is changed + */ + if (info == NULL) + return(FALSE); + *(u_long *)info = ntohl(*(u_long *)(cu->cu_outbuf + + 3 * BYTES_PER_XDR_UNIT)); + break; + case CLSET_PROG: + if (info == NULL) + return(FALSE); + *(u_long *)(cu->cu_outbuf + 3 * BYTES_PER_XDR_UNIT) + = htonl(*(u_long *)info); + break; + case CLGET_LOCAL_ADDR: + len = sizeof(struct sockaddr); + if (getsockname(cu->cu_sock, (struct sockaddr *)info, &len) <0) + return(FALSE); + break; + case CLGET_SVC_ADDR: + case CLSET_SVC_ADDR: + case CLSET_PUSH_TIMOD: + case CLSET_POP_TIMOD: default: return (FALSE); } diff --git a/lib/libc/rpc/get_myaddress.c b/lib/libc/rpc/get_myaddress.c index cb7ac9e..f8bfa7c 100644 --- a/lib/libc/rpc/get_myaddress.c +++ b/lib/libc/rpc/get_myaddress.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)get_myaddress.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)get_myaddress.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: get_myaddress.c,v 1.6 1996/12/30 14:26:28 peter Exp $"; #endif /* @@ -62,7 +62,7 @@ get_myaddress(addr) struct sockaddr_in *addr; { int s; - char buf[1024 * 8]; + char buf[BUFSIZ]; struct ifconf ifc; struct ifreq ifreq, *ifr, *end; int loopback = 0, gotit = 0; @@ -88,7 +88,7 @@ again: } if ((ifreq.ifr_flags & IFF_UP) && ifr->ifr_addr.sa_family == AF_INET && - (loopback == 1 || !(ifreq.ifr_flags & IFF_LOOPBACK))) { + (loopback == 1 && (ifreq.ifr_flags & IFF_LOOPBACK))) { *addr = *((struct sockaddr_in *)&ifr->ifr_addr); addr->sin_port = htons(PMAPPORT); gotit = 1; @@ -105,7 +105,5 @@ again: goto again; } (void) close(s); - if (gotit == 0) /* still found nothing?? */ - return (-1); return (0); } diff --git a/lib/libc/rpc/getrpcent.3 b/lib/libc/rpc/getrpcent.3 index 20e0256..5d70079 100644 --- a/lib/libc/rpc/getrpcent.3 +++ b/lib/libc/rpc/getrpcent.3 @@ -10,7 +10,7 @@ .Nm setrpcent .Nd get RPC entry .Sh SYNOPSIS -.Fd #include <rpc/rpc.h> +.Fd #include <netdb.h> .Ft struct rpcent * .Fn getrpcent void .Ft struct rpcent * diff --git a/lib/libc/rpc/getrpcent.c b/lib/libc/rpc/getrpcent.c index df079f1..8266285 100644 --- a/lib/libc/rpc/getrpcent.c +++ b/lib/libc/rpc/getrpcent.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)getrpcent.c 1.14 91/03/11 Copyr 1984 Sun Micro";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: getrpcent.c,v 1.6 1996/12/30 14:42:31 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/getrpcport.c b/lib/libc/rpc/getrpcport.c index 5260438..04a8de2 100644 --- a/lib/libc/rpc/getrpcport.c +++ b/lib/libc/rpc/getrpcport.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)getrpcport.c 1.3 87/08/11 SMI";*/ /*static char *sccsid = "from: @(#)getrpcport.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: getrpcport.c,v 1.6 1996/12/30 14:43:42 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/pmap_clnt.c b/lib/libc/rpc/pmap_clnt.c index 6a1f567..9901d81 100644 --- a/lib/libc/rpc/pmap_clnt.c +++ b/lib/libc/rpc/pmap_clnt.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_clnt.c 1.37 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_clnt.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: pmap_clnt.c,v 1.5 1996/12/30 14:46:33 peter Exp $"; #endif /* @@ -40,6 +40,8 @@ static char *rcsid = "$Id$"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include <rpc/rpc.h> #include <rpc/pmap_prot.h> @@ -51,6 +53,9 @@ static struct timeval tottimeout = { 60, 0 }; void clnt_perror(); +#ifndef PORTMAPSOCK +#define PORTMAPSOCK "/var/run/portmapsock" +#endif /* * Set a mapping between program,version and port. @@ -68,12 +73,22 @@ pmap_set(program, version, protocol, port) register CLIENT *client; struct pmap parms; bool_t rslt; + struct stat st; + + /* + * Temporary hack for backwards compatibility. Eventually + * this test will go away and we'll use only the "unix" transport. + */ + if (stat(PORTMAPSOCK, &st) == 0 && st.st_mode & S_IFSOCK) + client = clnt_create(PORTMAPSOCK, PMAPPROG, PMAPVERS, "unix"); + else { + if (get_myaddress(&myaddress) != 0) + return (FALSE); + myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, + timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); + } - if (get_myaddress(&myaddress) != 0) - return (FALSE); - myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, - timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); if (client == (CLIENT *)NULL) return (FALSE); parms.pm_prog = program; @@ -105,12 +120,21 @@ pmap_unset(program, version) register CLIENT *client; struct pmap parms; bool_t rslt; + struct stat st; - if (get_myaddress(&myaddress) != 0) - return (FALSE); - myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, - timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); + /* + * Temporary hack for backwards compatibility. Eventually + * this test will go away and we'll use only the "unix" transport. + */ + if (stat(PORTMAPSOCK, &st) == 0 && st.st_mode & S_IFSOCK) + client = clnt_create(PORTMAPSOCK, PMAPPROG, PMAPVERS, "unix"); + else { + if (get_myaddress(&myaddress) != 0) + return (FALSE); + myaddress.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS, + timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE); + } if (client == (CLIENT *)NULL) return (FALSE); parms.pm_prog = program; diff --git a/lib/libc/rpc/pmap_getmaps.c b/lib/libc/rpc/pmap_getmaps.c index add48fa..d4f2774 100644 --- a/lib/libc/rpc/pmap_getmaps.c +++ b/lib/libc/rpc/pmap_getmaps.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_getmaps.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_getmaps.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: pmap_getmaps.c,v 1.5 1996/12/30 14:48:28 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/pmap_getport.c b/lib/libc/rpc/pmap_getport.c index e968607..3d4c48a 100644 --- a/lib/libc/rpc/pmap_getport.c +++ b/lib/libc/rpc/pmap_getport.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_getport.c 1.9 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_getport.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: pmap_getport.c,v 1.4 1996/12/30 14:49:24 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/pmap_prot.c b/lib/libc/rpc/pmap_prot.c index 7bb61c1..fcb9c99 100644 --- a/lib/libc/rpc/pmap_prot.c +++ b/lib/libc/rpc/pmap_prot.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_prot.c 1.17 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_prot.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: pmap_prot.c,v 1.2 1995/05/30 05:41:25 rgrimes Exp $"; #endif /* diff --git a/lib/libc/rpc/pmap_prot2.c b/lib/libc/rpc/pmap_prot2.c index bd0263c..d81f612 100644 --- a/lib/libc/rpc/pmap_prot2.c +++ b/lib/libc/rpc/pmap_prot2.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_prot2.c 1.3 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_prot2.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: pmap_prot2.c,v 1.3 1996/06/10 20:13:05 jraynard Exp $"; #endif /* diff --git a/lib/libc/rpc/pmap_rmt.c b/lib/libc/rpc/pmap_rmt.c index b4b50ed..07a81e2 100644 --- a/lib/libc/rpc/pmap_rmt.c +++ b/lib/libc/rpc/pmap_rmt.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: pmap_rmt.c,v 1.9 1996/12/30 14:53:20 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/rpc_callmsg.c b/lib/libc/rpc/rpc_callmsg.c index 9ed7664..af8e573 100644 --- a/lib/libc/rpc/rpc_callmsg.c +++ b/lib/libc/rpc/rpc_callmsg.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: rpc_callmsg.c,v 1.5 1996/12/30 14:55:38 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/rpc_commondata.c b/lib/libc/rpc/rpc_commondata.c index 6c440d1..9640782 100644 --- a/lib/libc/rpc/rpc_commondata.c +++ b/lib/libc/rpc/rpc_commondata.c @@ -29,7 +29,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)rpc_commondata.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: rpc_commondata.c,v 1.3 1996/12/30 14:57:33 peter Exp $"; #endif #include <rpc/rpc.h> diff --git a/lib/libc/rpc/rpc_dtablesize.c b/lib/libc/rpc/rpc_dtablesize.c index 77697fe..c2703fa 100644 --- a/lib/libc/rpc/rpc_dtablesize.c +++ b/lib/libc/rpc/rpc_dtablesize.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)rpc_dtablesize.c 1.2 87/08/11 Copyr 1987 Sun Micro";*/ /*static char *sccsid = "from: @(#)rpc_dtablesize.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: rpc_dtablesize.c,v 1.6 1996/12/30 18:41:20 peter Exp $"; #endif #include <sys/types.h> diff --git a/lib/libc/rpc/rpc_prot.c b/lib/libc/rpc/rpc_prot.c index 6f121fa..8debaf1 100644 --- a/lib/libc/rpc/rpc_prot.c +++ b/lib/libc/rpc/rpc_prot.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: rpc_prot.c,v 1.4 1996/12/30 15:00:53 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/svc.c b/lib/libc/rpc/svc.c index e7718c3..ab0e8c1 100644 --- a/lib/libc/rpc/svc.c +++ b/lib/libc/rpc/svc.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc.c 1.44 88/02/08 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc.c 2.4 88/08/11 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: svc.c,v 1.7 1996/12/30 15:07:33 peter Exp $"; #endif /* @@ -401,8 +401,6 @@ svc_getreq(rdfds) svc_getreqset(&readfds); } -extern void svc_getreqset2(fd_set *, int); - void svc_getreqset(readfds) fd_set *readfds; diff --git a/lib/libc/rpc/svc_auth.c b/lib/libc/rpc/svc_auth.c index f69ebf5..0063e75 100644 --- a/lib/libc/rpc/svc_auth.c +++ b/lib/libc/rpc/svc_auth.c @@ -5,42 +5,56 @@ * 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 * OR ANY PART THEREOF. - * + * * 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. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ +/* + * Copyright (c) 1986-1991 by Sun Microsystems Inc. + */ + +#ident "@(#)svc_auth.c 1.16 94/04/24 SMI" -#if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)svc_auth.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)svc_auth.c 2.1 88/08/07 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +#if !defined(lint) && defined(SCCSIDS) +static char sccsid[] = "@(#)svc_auth.c 1.26 89/02/07 Copyr 1984 Sun Micro"; #endif /* - * svc_auth_nodes.c, Server-side rpc authenticator interface, - * *WITHOUT* DES authentication. + * svc_auth.c, Server-side rpc authenticator interface. * - * Copyright (C) 1984, Sun Microsystems, Inc. */ +#ifdef KERNEL +#include <sys/param.h> +#include <rpc/types.h> +#include <rpc/xdr.h> +#include <rpc/auth.h> +#include <rpc/clnt.h> +#include <rpc/rpc_msg.h> +#include <rpc/svc.h> +#include <rpc/svc_auth.h> +#else +#include <stdlib.h> #include <rpc/rpc.h> +#endif +#include <sys/types.h> /* * svcauthsw is the bdevsw of server side authentication. @@ -57,19 +71,18 @@ static char *rcsid = "$Id$"; * */ -enum auth_stat _svcauth_null(); /* no authentication */ -enum auth_stat _svcauth_unix(); /* unix style (uid, gids) */ +enum auth_stat _svcauth_null(); /* no authentication */ +enum auth_stat _svcauth_unix(); /* (system) unix style (uid, gids) */ enum auth_stat _svcauth_short(); /* short hand unix style */ +enum auth_stat _svcauth_des(); /* des style */ -static struct { - enum auth_stat (*authenticator)(); -} svcauthsw[] = { - {_svcauth_null}, /* AUTH_NULL */ - {_svcauth_unix}, /* AUTH_UNIX */ - {_svcauth_short}, /* AUTH_SHORT */ +/* declarations to allow servers to specify new authentication flavors */ +struct authsvc { + int flavor; + enum auth_stat (*handler)(); + struct authsvc *next; }; -#define AUTH_MAX 2 /* HIGHEST AUTH NUMBER */ - +static struct authsvc *Auths = NULL; /* * The call rpc message, msg has been obtained from the wire. The msg contains @@ -95,23 +108,104 @@ _authenticate(rqst, msg) struct rpc_msg *msg; { register int cred_flavor; + register struct authsvc *asp; rqst->rq_cred = msg->rm_call.cb_cred; rqst->rq_xprt->xp_verf.oa_flavor = _null_auth.oa_flavor; rqst->rq_xprt->xp_verf.oa_length = 0; cred_flavor = rqst->rq_cred.oa_flavor; - if ((cred_flavor <= AUTH_MAX) && (cred_flavor >= AUTH_NULL)) { - return ((*(svcauthsw[cred_flavor].authenticator))(rqst, msg)); + switch (cred_flavor) { + case AUTH_NULL: + return(_svcauth_null(rqst, msg)); + case AUTH_UNIX: + return(_svcauth_unix(rqst, msg)); + case AUTH_SHORT: + return(_svcauth_short(rqst, msg)); + /* + * We leave AUTH_DES turned off by default because svcauth_des() + * needs getpublickey(), which is in librpcsvc, not libc. If we + * included AUTH_DES as a built-in flavor, programs that don't + * have -lrpcsvc in their Makefiles wouldn't link correctly, even + * though they don't use AUTH_DES. And I'm too lazy to go through + * the tree looking for all of them. + */ +#ifdef DES_BUILTIN + case AUTH_DES: + return(_svcauth_des(rqst, msg)); +#endif + } + + /* flavor doesn't match any of the builtin types, so try new ones */ + for (asp = Auths; asp; asp = asp->next) { + if (asp->flavor == cred_flavor) { + enum auth_stat as; + + as = (*asp->handler)(rqst, msg); + return (as); + } } return (AUTH_REJECTEDCRED); } +/*ARGSUSED*/ enum auth_stat -_svcauth_null(/*rqst, msg*/) - /*struct svc_req *rqst; - struct rpc_msg *msg;*/ +_svcauth_null(rqst, msg) + struct svc_req *rqst; + struct rpc_msg *msg; { - return (AUTH_OK); } + +/* + * Allow the rpc service to register new authentication types that it is + * prepared to handle. When an authentication flavor is registered, + * the flavor is checked against already registered values. If not + * registered, then a new Auths entry is added on the list. + * + * There is no provision to delete a registration once registered. + * + * This routine returns: + * 0 if registration successful + * 1 if flavor already registered + * -1 if can't register (errno set) + */ + +int +svc_auth_reg(cred_flavor, handler) + register int cred_flavor; + enum auth_stat (*handler)(); +{ + register struct authsvc *asp; + + switch (cred_flavor) { + case AUTH_NULL: + case AUTH_UNIX: + case AUTH_SHORT: +#ifdef DES_BUILTIN + case AUTH_DES: +#endif + /* already registered */ + return (1); + + default: + for (asp = Auths; asp; asp = asp->next) { + if (asp->flavor == cred_flavor) { + /* already registered */ + return (1); + } + } + + /* this is a new one, so go ahead and register it */ + asp = (struct authsvc *)mem_alloc(sizeof (*asp)); + if (asp == NULL) { + return (-1); + } + asp->flavor = cred_flavor; + asp->handler = handler; + asp->next = Auths; + Auths = asp; + break; + } + return (0); +} diff --git a/lib/libc/rpc/svc_auth_unix.c b/lib/libc/rpc/svc_auth_unix.c index 96f7d15..959cb73 100644 --- a/lib/libc/rpc/svc_auth_unix.c +++ b/lib/libc/rpc/svc_auth_unix.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: svc_auth_unix.c,v 1.4 1996/12/30 15:10:14 peter Exp $"; #endif /* @@ -114,8 +114,19 @@ _svcauth_unix(rqst, msg) stat = AUTH_BADCRED; goto done; } - rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; - rqst->rq_xprt->xp_verf.oa_length = 0; + + /* get the verifier */ + if ((u_int)msg->rm_call.cb_verf.oa_length) { + rqst->rq_xprt->xp_verf.oa_flavor = + msg->rm_call.cb_verf.oa_flavor; + rqst->rq_xprt->xp_verf.oa_base = + msg->rm_call.cb_verf.oa_base; + rqst->rq_xprt->xp_verf.oa_length = + msg->rm_call.cb_verf.oa_length; + } else { + rqst->rq_xprt->xp_verf.oa_flavor = AUTH_NULL; + rqst->rq_xprt->xp_verf.oa_length = 0; + } stat = AUTH_OK; done: XDR_DESTROY(&xdrs); diff --git a/lib/libc/rpc/svc_raw.c b/lib/libc/rpc/svc_raw.c index 771340c..3a5bcb3 100644 --- a/lib/libc/rpc/svc_raw.c +++ b/lib/libc/rpc/svc_raw.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_raw.c 1.15 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_raw.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: svc_raw.c,v 1.3 1995/10/22 14:51:36 phk Exp $"; #endif /* diff --git a/lib/libc/rpc/svc_run.c b/lib/libc/rpc/svc_run.c index ad8c365..896aa12 100644 --- a/lib/libc/rpc/svc_run.c +++ b/lib/libc/rpc/svc_run.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_run.c 1.1 87/10/13 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_run.c 2.1 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: svc_run.c,v 1.4 1996/12/30 15:14:29 peter Exp $"; #endif /* @@ -79,7 +79,7 @@ svc_run() free(fds); continue; default: - /* if fds == NULL, select() can't return a result */ + /* XXX What the hell?? what if fds == NULL?? */ svc_getreqset2(fds, svc_maxfd + 1); free(fds); } diff --git a/lib/libc/rpc/svc_simple.c b/lib/libc/rpc/svc_simple.c index bfbdba3..0324675 100644 --- a/lib/libc/rpc/svc_simple.c +++ b/lib/libc/rpc/svc_simple.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_simple.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: svc_simple.c,v 1.5 1996/12/30 15:16:22 peter Exp $"; #endif /* @@ -44,6 +44,7 @@ static char *rcsid = "$Id$"; #include <stdlib.h> #include <string.h> #include <rpc/rpc.h> +#include <rpc/pmap_clnt.h> #include <sys/socket.h> #include <netdb.h> diff --git a/lib/libc/rpc/svc_tcp.c b/lib/libc/rpc/svc_tcp.c index b794751..1387ee1 100644 --- a/lib/libc/rpc/svc_tcp.c +++ b/lib/libc/rpc/svc_tcp.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: svc_tcp.c,v 1.8 1996/12/30 15:19:08 peter Exp $"; #endif /* diff --git a/lib/libc/rpc/svc_udp.c b/lib/libc/rpc/svc_udp.c index 660063d..6622de2 100644 --- a/lib/libc/rpc/svc_udp.c +++ b/lib/libc/rpc/svc_udp.c @@ -30,7 +30,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)svc_udp.c 2.2 88/07/29 4.0 RPCSRC";*/ -static char *rcsid = "$Id$"; +static char *rcsid = "$Id: svc_udp.c,v 1.7 1996/12/30 15:21:19 peter Exp $"; #endif /* |