Last modified: 2001-10-06 02:00 Changed files: usr.bin/chpass/pw_yp.c usr.bin/passwd/yp_passwd.c lib/libc/rpc/crypt_client.c usr.bin/rpcinfo/rpcinfo.c Commment: The clnt_create(KEYSERVSOCK, CRYPT_PROG, CRYPT_VERS, "unix") hacks were removed and replaced them with clnt_tp_create, now the af_local support is fixed. I also removed the hack how rpcinfo contacted rpcbind, now we can relay on clnt_tp_create create the client-handle for us. Only rpcbind itself needs a hardcoded socket-path. Index: lib/libc/rpc/crypt_client.c =================================================================== RCS file: /usr/home/ncvs/src/lib/libc/rpc/crypt_client.c,v retrieving revision 1.5 diff -u -r1.5 crypt_client.c --- lib/libc/rpc/crypt_client.c 19 Mar 2001 12:49:50 -0000 1.5 +++ lib/libc/rpc/crypt_client.c 5 Oct 2001 23:47:51 -0000 @@ -42,10 +42,6 @@ static const char rcsid[] = "$FreeBSD: src/lib/libc/rpc/crypt_client.c,v 1.5 2001/03/19 12:49:50 alfred Exp $"; #endif -#ifndef KEYSERVSOCK -#define KEYSERVSOCK "/var/run/keyservsock" -#endif - int _des_crypt_call(buf, len, dparms) char *buf; @@ -55,12 +51,27 @@ CLIENT *clnt; desresp *result_1; desargs des_crypt_1_arg; - int stat; + struct netconfig *nconf; + void *localhandle; + int stat; - clnt = clnt_create(KEYSERVSOCK, CRYPT_PROG, CRYPT_VERS, "unix"); + nconf = NULL; + localhandle = setnetconfig(); + while ((nconf = getnetconfig(localhandle)) != NULL) { + if (nconf->nc_protofmly != NULL && + strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) + break; + } + if (nconf == NULL) { + warnx("getnetconfig: %s", nc_sperror()); + return(DESERR_HWERROR); + } + clnt = clnt_tp_create(NULL, CRYPT_PROG, CRYPT_VERS, nconf); if (clnt == (CLIENT *) NULL) { + endnetconfig(localhandle); return(DESERR_HWERROR); } + endnetconfig(localhandle); des_crypt_1_arg.desbuf.desbuf_len = len; des_crypt_1_arg.desbuf.desbuf_val = buf; Index: usr.bin/chpass/pw_yp.c =================================================================== RCS file: /usr/home/ncvs/src/usr.bin/chpass/pw_yp.c,v retrieving revision 1.16 diff -u -r1.16 pw_yp.c --- usr.bin/chpass/pw_yp.c 20 Oct 1999 15:20:00 -0000 1.16 +++ usr.bin/chpass/pw_yp.c 5 Oct 2001 23:47:51 -0000 @@ -354,7 +354,6 @@ char *mastername; int rval, localport; struct stat st; - char *sockname = YP_SOCKNAME; /* * Sometimes we are called just to probe for rpc.yppasswdd and @@ -407,7 +406,7 @@ /* See if _we_ are the master server. */ if (!force_old && !getuid() && (localport = getrpcport("localhost", YPPASSWDPROG, YPPASSWDPROC_UPDATE, IPPROTO_UDP)) != 0) { - if (localport == rval && stat(sockname, &st) != -1) { + if (localport == rval) { suser_override = 1; mastername = "localhost"; } @@ -433,12 +432,14 @@ { struct yppasswd yppasswd; struct master_yppasswd master_yppasswd; + struct netconfig *nconf; + void *localhandle; CLIENT *clnt; char *master, *password; int *status = NULL; struct rpc_err err; - char *sockname = YP_SOCKNAME; + nconf = NULL; _use_yp = 1; /* Get NIS master server name */ @@ -490,13 +491,26 @@ if (suser_override) { /* Talk to server via AF_UNIX socket. */ - clnt = clnt_create(sockname, MASTER_YPPASSWDPROG, - MASTER_YPPASSWDVERS, "unix"); + localhandle = setnetconfig(); + while ((nconf = getnetconfig(localhandle)) != NULL) { + if (nconf->nc_protofmly != NULL && + strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) + break; + } + if (nconf == NULL) { + warnx("getnetconfig: %s", nc_sperror()); + pw_error(tempname, 0, 1); + } + + clnt = clnt_tp_create(NULL, MASTER_YPPASSWDPROG, + MASTER_YPPASSWDVERS, nconf); if (clnt == NULL) { warnx("failed to contact rpc.yppasswdd: %s", clnt_spcreateerror(master)); + endnetconfig(localhandle); pw_error(tempname, 0, 1); } + endnetconfig(localhandle); } else { /* Create a handle to yppasswdd. */ Index: usr.bin/passwd/yp_passwd.c =================================================================== RCS file: /usr/home/ncvs/src/usr.bin/passwd/yp_passwd.c,v retrieving revision 1.15 diff -u -r1.15 yp_passwd.c --- usr.bin/passwd/yp_passwd.c 28 Sep 1997 08:51:02 -0000 1.15 +++ usr.bin/passwd/yp_passwd.c 5 Oct 2001 23:47:51 -0000 @@ -55,14 +55,16 @@ { struct yppasswd yppasswd; struct master_yppasswd master_yppasswd; + struct netconfig *nconf; + void *localhandle; struct passwd *pw; CLIENT *clnt; struct rpc_err err; char *master; int *status = NULL; uid_t uid; - char *sockname = YP_SOCKNAME; + nconf = NULL; _use_yp = 1; uid = getuid(); @@ -144,12 +146,24 @@ } if (suser_override) { - if ((clnt = clnt_create(sockname, MASTER_YPPASSWDPROG, - MASTER_YPPASSWDVERS, "unix")) == NULL) { + localhandle = setnetconfig(); + while ((nconf = getnetconfig(localhandle)) != NULL) { + if (nconf->nc_protofmly != NULL && + strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) + break; + } + if (nconf == NULL) { + warnx("getnetconfig: %s", nc_sperror()); + return(1); + } + if ((clnt = clnt_tp_create(NULL, MASTER_YPPASSWDPROG, + MASTER_YPPASSWDVERS, nconf)) == NULL) { warnx("failed to contact rpc.yppasswdd on host %s: %s", master, clnt_spcreateerror("")); + endnetconfig(localhandle); return(1); } + endnetconfig(localhandle); } else { if ((clnt = clnt_create(master, YPPASSWDPROG, YPPASSWDVERS, "udp")) == NULL) { Index: usr.bin/rpcinfo/rpcinfo.c =================================================================== RCS file: /usr/home/ncvs/src/usr.bin/rpcinfo/rpcinfo.c,v retrieving revision 1.11 diff -u -r1.11 rpcinfo.c --- usr.bin/rpcinfo/rpcinfo.c 19 Mar 2001 12:50:04 -0000 1.11 +++ usr.bin/rpcinfo/rpcinfo.c 5 Oct 2001 23:47:51 -0000 @@ -321,22 +321,24 @@ static CLIENT * local_rpcb(u_long prog, u_long vers) { - struct netbuf nbuf; - struct sockaddr_un sun; - int sock; + void *localhandle; + struct netconfig *nconf; + CLIENT *clnt; - memset(&sun, 0, sizeof sun); - sock = socket(AF_LOCAL, SOCK_STREAM, 0); - if (sock < 0) - return NULL; + localhandle = setnetconfig(); + while ((nconf = getnetconfig(localhandle)) != NULL) { + if (nconf->nc_protofmly != NULL && + strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0) + break; + } + if (nconf == NULL) { + warnx("getnetconfig: %s", nc_sperror()); + return (NULL); + } - sun.sun_family = AF_LOCAL; - strcpy(sun.sun_path, _PATH_RPCBINDSOCK); - nbuf.len = sun.sun_len = SUN_LEN(&sun); - nbuf.maxlen = sizeof (struct sockaddr_un); - nbuf.buf = &sun; - - return clnt_vc_create(sock, &nbuf, prog, vers, 0, 0); + clnt = clnt_tp_create(NULL, prog, vers, nconf); + endnetconfig(localhandle); + return clnt; } #ifdef PORTMAP