diff options
author | alfred <alfred@FreeBSD.org> | 2002-02-05 19:26:04 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-02-05 19:26:04 +0000 |
commit | 4b6dfb0371e69053a084f9be4527d00c21ff21b2 (patch) | |
tree | d0bfae22d41f9e22feb21e5677a4049209d6314a /usr.bin | |
parent | 903f014bc1c0d907f00f5ee5cd8d683b823d9081 (diff) | |
download | FreeBSD-src-4b6dfb0371e69053a084f9be4527d00c21ff21b2.zip FreeBSD-src-4b6dfb0371e69053a084f9be4527d00c21ff21b2.tar.gz |
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.
Submitted by: mbr
Also add $FreeBSD
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/chpass/pw_yp.c | 24 | ||||
-rw-r--r-- | usr.bin/passwd/yp_passwd.c | 22 | ||||
-rw-r--r-- | usr.bin/rpcinfo/rpcinfo.c | 34 |
3 files changed, 56 insertions, 24 deletions
diff --git a/usr.bin/chpass/pw_yp.c b/usr.bin/chpass/pw_yp.c index d6cfaeb..1c523ae 100644 --- a/usr.bin/chpass/pw_yp.c +++ b/usr.bin/chpass/pw_yp.c @@ -354,7 +354,6 @@ char *get_yp_master(getserver) 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 @@ char *get_yp_master(getserver) /* 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 @@ void yp_submit(pw) { 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 @@ void yp_submit(pw) 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. */ diff --git a/usr.bin/passwd/yp_passwd.c b/usr.bin/passwd/yp_passwd.c index 92688ed..fb39c76 100644 --- a/usr.bin/passwd/yp_passwd.c +++ b/usr.bin/passwd/yp_passwd.c @@ -27,6 +27,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ #ifdef YP @@ -55,14 +57,16 @@ yp_passwd(char *user) { 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 +148,24 @@ for other users"); } 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) { diff --git a/usr.bin/rpcinfo/rpcinfo.c b/usr.bin/rpcinfo/rpcinfo.c index 38abe2f..6ae9d4f 100644 --- a/usr.bin/rpcinfo/rpcinfo.c +++ b/usr.bin/rpcinfo/rpcinfo.c @@ -321,22 +321,24 @@ main(int argc, char **argv) static CLIENT * local_rpcb(u_long prog, u_long vers) { - struct netbuf nbuf; - struct sockaddr_un sun; - int sock; - - memset(&sun, 0, sizeof sun); - sock = socket(AF_LOCAL, SOCK_STREAM, 0); - if (sock < 0) - 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); + void *localhandle; + struct netconfig *nconf; + CLIENT *clnt; + + 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); + } + + clnt = clnt_tp_create(NULL, prog, vers, nconf); + endnetconfig(localhandle); + return clnt; } #ifdef PORTMAP |