From owner-svn-src-all@freebsd.org Mon Jul 20 22:17:12 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9C3CE9A71B8; Mon, 20 Jul 2015 22:17:12 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 82C5A18B4; Mon, 20 Jul 2015 22:17:12 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6KMHCdO086508; Mon, 20 Jul 2015 22:17:12 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6KMHB5C086506; Mon, 20 Jul 2015 22:17:11 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201507202217.t6KMHB5C086506@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Mon, 20 Jul 2015 22:17:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r285727 - in stable/9: etc usr.bin/quota X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jul 2015 22:17:12 -0000 Author: gjb Date: Mon Jul 20 22:17:11 2015 New Revision: 285727 URL: https://svnweb.freebsd.org/changeset/base/285727 Log: MFC r285253 (hrs): - Add IPv6 support in quota(1). While rpc.rquotad has supported PF_INET6 for a long time, quota(1) utility supported only PF_INET. - Clean up confusing changes in f_mntfromname. - Add an entry for rquotad with rpc/udp6 to inetd.conf. PR: 194084 Sponsored by: The FreeBSD Foundation Modified: stable/9/etc/inetd.conf stable/9/usr.bin/quota/quota.c Directory Properties: stable/9/etc/ (props changed) stable/9/usr.bin/ (props changed) Modified: stable/9/etc/inetd.conf ============================================================================== --- stable/9/etc/inetd.conf Mon Jul 20 22:14:55 2015 (r285726) +++ stable/9/etc/inetd.conf Mon Jul 20 22:17:11 2015 (r285727) @@ -68,6 +68,7 @@ #walld/1 dgram rpc/udp wait root /usr/libexec/rpc.rwalld rpc.rwalld #pcnfsd/1-2 dgram rpc/udp wait root /usr/local/libexec/rpc.pcnfsd rpc.pcnfsd #rquotad/1 dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad +#rquotad/1 dgram rpc/udp6 wait root /usr/libexec/rpc.rquotad rpc.rquotad #sprayd/1 dgram rpc/udp wait root /usr/libexec/rpc.sprayd rpc.sprayd # # example entry for the optional pop3 server Modified: stable/9/usr.bin/quota/quota.c ============================================================================== --- stable/9/usr.bin/quota/quota.c Mon Jul 20 22:14:55 2015 (r285726) +++ stable/9/usr.bin/quota/quota.c Mon Jul 20 22:17:11 2015 (r285727) @@ -571,7 +571,7 @@ getnfsquota(struct statfs *fst, struct q struct getquota_rslt gq_rslt; struct dqblk *dqp = &qup->dqblk; struct timeval tv; - char *cp; + char *cp, host[NI_MAXHOST]; if (fst->f_flags & MNT_LOCAL) return (0); @@ -585,33 +585,29 @@ getnfsquota(struct statfs *fst, struct q /* * must be some form of "hostname:/path" */ - cp = strchr(fst->f_mntfromname, ':'); + cp = fst->f_mntfromname; + do { + cp = strrchr(cp, ':'); + } while (cp != NULL && *(cp + 1) != '/'); if (cp == NULL) { warnx("cannot find hostname for %s", fst->f_mntfromname); return (0); } + memset(host, 0, sizeof(host)); + memcpy(host, fst->f_mntfromname, cp - fst->f_mntfromname); + host[sizeof(host) - 1] = '\0'; - *cp = '\0'; - if (*(cp+1) != '/') { - *cp = ':'; - return (0); - } - /* Avoid attempting the RPC for special amd(8) filesystems. */ if (strncmp(fst->f_mntfromname, "pid", 3) == 0 && - strchr(fst->f_mntfromname, '@') != NULL) { - *cp = ':'; + strchr(fst->f_mntfromname, '@') != NULL) return (0); - } gq_args.gqa_pathp = cp + 1; gq_args.gqa_uid = id; - if (callaurpc(fst->f_mntfromname, RQUOTAPROG, RQUOTAVERS, + if (callaurpc(host, RQUOTAPROG, RQUOTAVERS, RQUOTAPROC_GETQUOTA, (xdrproc_t)xdr_getquota_args, (char *)&gq_args, - (xdrproc_t)xdr_getquota_rslt, (char *)&gq_rslt) != 0) { - *cp = ':'; + (xdrproc_t)xdr_getquota_rslt, (char *)&gq_rslt) != 0) return (0); - } switch (gq_rslt.status) { case Q_NOQUOTA: @@ -644,13 +640,12 @@ getnfsquota(struct statfs *fst, struct q tv.tv_sec + gq_rslt.getquota_rslt_u.gqr_rquota.rq_btimeleft; dqp->dqb_itime = tv.tv_sec + gq_rslt.getquota_rslt_u.gqr_rquota.rq_ftimeleft; - *cp = ':'; return (1); default: warnx("bad rpc result, host: %s", fst->f_mntfromname); break; } - *cp = ':'; + return (0); } @@ -658,26 +653,17 @@ static int 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; - - if ((hp = gethostbyname(host)) == NULL) - return ((int) RPC_UNKNOWNHOST); + + 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); + CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)(void *)&timeout); client->cl_auth = authunix_create_default(); tottimeout.tv_sec = 25;