*** amd/host_ops.c.dist Thu Sep 30 10:49:31 1993 --- amd/host_ops.c Sun Jun 19 23:24:49 1994 *************** *** 320,379 **** * SVR4 VERSION: * Create an rpc client attached to the mount daemon. */ ! static CLIENT *get_mount_client P((char *host, struct sockaddr_in *sin, struct timeval *tv, int *sock)); ! static CLIENT *get_mount_client(host, sin, tv, sock) char *host; - struct sockaddr_in *sin; struct timeval *tv; int *sock; { CLIENT *client; - int fd = 0; struct netbuf nb; /* * First try a TCP handler */ ! if ((client = clnt_create(host, MOUNTPROG, MOUNTVERS, "tcp")) == (CLIENT *) NULL) { ! plog(XLOG_ERROR, "clnt_create for tcp failed"); goto tryudp; } ! if (clnt_control(client, CLGET_FD, (char *)&fd) == FALSE) { ! plog(XLOG_ERROR, "clnt_control CLGET_FD for tcp failed"); ! clnt_destroy(client); goto tryudp; } ! if (clnt_control(client, CLGET_SVC_ADDR, (char *)&nb) == FALSE) { ! plog(XLOG_ERROR, "clnt_control CLGET_SVC_ADDR for tcp failed"); ! clnt_destroy(client); goto tryudp; ! } else { ! /* tcp succeeded */ ! *sock = fd; ! sin = (struct sockaddr_in *) nb.buf; #ifdef DEBUG ! dlog("get_mount_client: using tcp, port %d", sin->sin_port); #endif /* DEBUG */ ! return client; ! } tryudp: - /* * TCP failed so try UDP */ ! if ((client = clnt_create(host, MOUNTPROG, MOUNTVERS, "udp")) == (CLIENT *) NULL) { ! plog(XLOG_ERROR, "clnt_create for udp failed"); ! return NULL; /* neither tcp not udp succeeded */ } ! if (clnt_control(client, CLGET_FD, (char *)&fd) == FALSE) { ! plog(XLOG_ERROR, "clnt_control CLGET_FD for udp failed"); ! clnt_destroy(client); return NULL; /* neither tcp not udp succeeded */ } ! if (clnt_control(client, CLGET_SVC_ADDR, (char *)&nb) == FALSE) { ! plog(XLOG_ERROR, "clnt_control CLGET_SVC_ADDR for udp failed"); ! clnt_destroy(client); return NULL; /* neither tcp not udp succeeded */ } if (clnt_control(client, CLSET_RETRY_TIMEOUT, (char *) tv) == FALSE) { --- 320,421 ---- * SVR4 VERSION: * Create an rpc client attached to the mount daemon. */ ! static CLIENT *get_mount_client P((char *host, struct timeval *tv, int *sock)); ! static CLIENT *get_mount_client(host, tv, sock) char *host; struct timeval *tv; int *sock; { CLIENT *client; struct netbuf nb; + struct netconfig *nc; + struct sockaddr_in sin; + nb.maxlen = sizeof(sin); + nb.buf = (char *)&sin; + /* * First try a TCP handler */ ! ! /* ! * Find mountd address on TCP ! */ ! if ((nc = getnetconfigent("tcp")) == NULL) { ! plog(XLOG_ERROR, "getnetconfig for tcp failed: %s", nc_sperror()); goto tryudp; } ! ! if (!rpcb_getaddr(MOUNTPROG, MOUNTVERS, nc, &nb, host)) { ! /* ! * don't pring error messages here, since mountd might legitimately ! * serve udp only ! */ goto tryudp; } ! ! /* ! * Create priviledged TCP socket ! */ ! *sock = t_open(nc->nc_device, O_RDWR, 0); ! ! if (*sock < 0) { ! plog(XLOG_ERROR, "t_open %s: %m", nc->nc_device); goto tryudp; ! } ! if (bind_resv_port(*sock, (unsigned short *) 0) < 0) ! plog(XLOG_ERROR, "couldn't bind mountd socket to privileged port"); ! ! if ((client = clnt_vc_create(*sock, &nb, MOUNTPROG, MOUNTVERS, 0, 0)) ! == (CLIENT *) NULL) ! { ! plog(XLOG_ERROR, "clnt_vc_create failed"); ! t_close(*sock); ! goto tryudp; ! } ! ! /* tcp succeeded */ #ifdef DEBUG ! dlog("get_mount_client: using tcp, port %d", sin.sin_port); #endif /* DEBUG */ ! return client; tryudp: /* * TCP failed so try UDP */ ! ! /* ! * Find mountd address on UDP ! */ ! if ((nc = getnetconfigent("udp")) == NULL) { ! plog(XLOG_ERROR, "getnetconfig for udp failed: %s", nc_sperror()); ! return NULL; } ! ! if (!rpcb_getaddr(MOUNTPROG, MOUNTVERS, nc, &nb, host)) { ! plog(XLOG_ERROR, "%s", ! clnt_spcreateerror("couldn't get mountd address on udp")); ! return NULL; ! } ! ! /* ! * Create priviledged UDP socket ! */ ! *sock = t_open(nc->nc_device, O_RDWR, 0); ! ! if (*sock < 0) { ! plog(XLOG_ERROR, "t_open %s: %m", nc->nc_device); return NULL; /* neither tcp not udp succeeded */ } ! if (bind_resv_port(*sock, (unsigned short *) 0) < 0) ! plog(XLOG_ERROR, "couldn't bind mountd socket to privileged port"); ! ! if ((client = clnt_dg_create(*sock, &nb, MOUNTPROG, MOUNTVERS, 0, 0)) ! == (CLIENT *) NULL) ! { ! plog(XLOG_ERROR, "clnt_dg_create failed"); ! t_close(*sock); return NULL; /* neither tcp not udp succeeded */ } if (clnt_control(client, CLSET_RETRY_TIMEOUT, (char *) tv) == FALSE) { *************** *** 381,391 **** clnt_destroy(client); return NULL; /* neither tcp not udp succeeded */ } ! /* udp succeeded */ ! *sock = fd; ! sin = (struct sockaddr_in *) nb.buf; #ifdef DEBUG ! dlog("get_mount_client: using udp, port %d", sin->sin_port); #endif /* DEBUG */ return client; } --- 423,432 ---- clnt_destroy(client); return NULL; /* neither tcp not udp succeeded */ } ! ! /* udp succeeded */ #ifdef DEBUG ! dlog("get_mount_client: using udp, port %d", sin.sin_port); #endif /* DEBUG */ return client; } *************** *** 523,532 **** * Create a client attached to mountd */ #ifdef __svr4__ ! if ((client = get_mount_client(host, &sin, &tv, &sock)) == NULL) { #else if ((client = get_mount_client(&sin, &tv, &sock)) == NULL) { ! #endif /* __svr4__ */ plog(XLOG_ERROR, "Failed to make rpc connection to mountd on %s", host); error = EIO; goto out; --- 564,573 ---- * Create a client attached to mountd */ #ifdef __svr4__ ! if ((client = get_mount_client(host, &tv, &sock)) == NULL) { #else if ((client = get_mount_client(&sin, &tv, &sock)) == NULL) { ! #endif plog(XLOG_ERROR, "Failed to make rpc connection to mountd on %s", host); error = EIO; goto out; *************** *** 796,805 **** * Create a client attached to mountd */ #ifdef __svr4__ ! if ((client = get_mount_client(host, &sin, &tv, &sock)) == NULL) { #else if ((client = get_mount_client(&sin, &tv, &sock)) == NULL) { ! #endif /* __svr4__ */ plog(XLOG_ERROR, "Failed to make rpc connection to mountd on %s", host); goto out; } --- 837,846 ---- * Create a client attached to mountd */ #ifdef __svr4__ ! if ((client = get_mount_client(host, &tv, &sock)) == NULL) { #else if ((client = get_mount_client(&sin, &tv, &sock)) == NULL) { ! #endif plog(XLOG_ERROR, "Failed to make rpc connection to mountd on %s", host); goto out; }