Date: Sun, 25 Aug 2002 19:16:26 +0200 (MEST) From: Jean-Luc Richier <Jean-Luc.Richier@imag.fr> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Jean-Luc.Richier@imag.fr Subject: bin/42004: quota and rpc.statd are still IPv4 only, and not INET independant Message-ID: <200208251716.g7PHGQ1W009357@lagavulin.imag.fr>
next in thread | raw e-mail | index | archive | help
>Number: 42004
>Category: bin
>Synopsis: quota and rpc.statd are still IPv4 only, and not INET independant
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Aug 25 10:20:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Jean-Luc Richier
>Release: FreeBSD 5.0-CURRENT i386
>Organization:
LSR-IMAG, Grenoble, France
>Environment:
System: FreeBSD lagavulin.imag.fr 5.0-CURRENT FreeBSD 5.0-CURRENT #1: Thu Aug 22 09:43:42 MEST 2002 richier@lagavulin.imag.fr:/altroot1a/usr/obj/usr/src/sys/GENERIC i386
>Description:
Almost all NFS/kernel code has been ported to TIRPC in July and is
therefore INET4/INET6 indenpendant. There is one command (quota) which
has been forgotten, and a modification done in rpc.statd is not INET*
independant.
>How-To-Repeat:
Code inspection
>Fix:
Applies the following patch - and do not use inet_ntoa/gethostby*
functions, sockaddr_in structures and svc_getcaller call anymore.
--- usr.bin/quota/quota.c.1.18 Fri Aug 9 06:36:48 2002
+++ usr.bin/quota/quota.c Sun Aug 25 17:43:36 2002
@@ -665,26 +665,20 @@
callaurpc(char *host, int prognum, int versnum, int procnum,
xdrproc_t inproc, char *in, xdrproc_t outproc, char *out)
{
- struct sockaddr_in server_addr;
enum clnt_stat clnt_stat;
- struct hostent *hp;
struct timeval timeout, tottimeout;
- CLIENT *client = NULL;
- int sock = RPC_ANYSOCK;
+ CLIENT *client;
- if ((hp = gethostbyname(host)) == NULL)
- return ((int) RPC_UNKNOWNHOST);
+ /* XXX - If clnt_call fails, we should try other addresses and AF_ */
+ client = clnt_create(host, prognum, versnum, "udp");
+ if (client == NULL)
+ return ((int) rpc_createerr.cf_stat);
+
timeout.tv_usec = 0;
timeout.tv_sec = 6;
- bcopy(hp->h_addr, &server_addr.sin_addr,
- MIN(hp->h_length,(int)sizeof(server_addr.sin_addr)));
- server_addr.sin_family = AF_INET;
- server_addr.sin_port = 0;
-
- if ((client = clntudp_create(&server_addr, prognum,
- versnum, timeout, &sock)) == NULL)
- return ((int) rpc_createerr.cf_stat);
+ (void) CLNT_CONTROL(client,
+ CLSET_RETRY_TIMEOUT, (char *)(void *)&timeout);
client->cl_auth = authunix_create_default();
tottimeout.tv_sec = 25;
--- usr.sbin/rpc.statd/procs.c.1.13 Tue Jul 16 00:47:17 2002
+++ usr.sbin/rpc.statd/procs.c Wed Aug 21 17:42:43 2002
@@ -52,6 +52,18 @@
#include "statd.h"
+static const char *
+from_addr(saddr)
+ struct sockaddr *saddr;
+{
+ static char inet_buf[INET6_ADDRSTRLEN];
+
+ if (getnameinfo(saddr, saddr->sa_len, inet_buf, sizeof(inet_buf),
+ NULL, 0, NI_NUMERICHOST) == 0)
+ return inet_buf;
+ return "???";
+}
+
/* sm_check_hostname -------------------------------------------------------- */
/*
* Purpose: Check `mon_name' member of sm_name struct to ensure that the array
@@ -66,13 +78,13 @@
int sm_check_hostname(struct svc_req *req, char *arg)
{
int len, dstlen, ret;
- struct sockaddr_in *claddr;
+ struct sockaddr *claddr;
char *dst;
len = strlen(arg);
dstlen = (4 * len) + 1;
dst = malloc(dstlen);
- claddr = svc_getcaller(req->rq_xprt);
+ claddr = svc_getrpccaller(req->rq_xprt);
ret = 1;
if (claddr == NULL || dst == NULL)
@@ -83,7 +95,7 @@
{
syslog(LOG_ERR,
"sm_stat: client %s hostname %s contained invalid characters.",
- inet_ntoa(claddr->sin_addr),
+ from_addr(claddr),
dst);
ret = 0;
}
@@ -102,7 +114,7 @@
{
static sm_stat_res res;
struct addrinfo *ai;
- struct sockaddr_in *claddr;
+ struct sockaddr *claddr;
static int err;
err = 1;
@@ -120,9 +132,9 @@
}
else
{
- claddr = svc_getcaller(req->rq_xprt);
+ claddr = svc_getrpccaller(req->rq_xprt);
syslog(LOG_ERR, "invalid hostname to sm_stat from %s: %s",
- inet_ntoa(claddr->sin_addr), arg->mon_name);
+ from_addr(claddr), arg->mon_name);
res.res_stat = stat_fail;
}
}
>Release-Note:
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208251716.g7PHGQ1W009357>
