[Midnightbsd-cvs] src [11260] trunk/usr.bin/quota/quota.c: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jul 3 19:50:31 EDT 2018


Revision: 11260
          http://svnweb.midnightbsd.org/src/?rev=11260
Author:   laffer1
Date:     2018-07-03 19:50:30 -0400 (Tue, 03 Jul 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/usr.bin/quota/Makefile
    trunk/usr.bin/quota/quota.1
    trunk/usr.bin/quota/quota.c

Property Changed:
----------------
    trunk/usr.bin/quota/quota.1

Modified: trunk/usr.bin/quota/Makefile
===================================================================
--- trunk/usr.bin/quota/Makefile	2018-07-03 23:47:48 UTC (rev 11259)
+++ trunk/usr.bin/quota/Makefile	2018-07-03 23:50:30 UTC (rev 11260)
@@ -1,5 +1,6 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
-# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/quota/Makefile 207736 2010-05-07 00:41:12Z mckusick $
 
 PROG=	quota
 BINOWN=	root

Modified: trunk/usr.bin/quota/quota.1
===================================================================
--- trunk/usr.bin/quota/quota.1	2018-07-03 23:47:48 UTC (rev 11259)
+++ trunk/usr.bin/quota/quota.1	2018-07-03 23:50:30 UTC (rev 11260)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1983, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -29,7 +30,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"	from: @(#)quota.1	8.1 (Berkeley) 6/6/93
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/quota/quota.1 216370 2010-12-11 08:32:16Z joel $
 .\"
 .Dd February 3, 2007
 .Dt QUOTA 1


Property changes on: trunk/usr.bin/quota/quota.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/quota/quota.c
===================================================================
--- trunk/usr.bin/quota/quota.c	2018-07-03 23:47:48 UTC (rev 11259)
+++ trunk/usr.bin/quota/quota.c	2018-07-03 23:50:30 UTC (rev 11260)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1980, 1990, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -44,7 +45,7 @@
  * Disk quota reporting program.
  */
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/quota/quota.c 285725 2015-07-20 21:52:05Z gjb $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -73,8 +74,7 @@
 #include <time.h>
 #include <unistd.h>
 
-const char *qfname = QUOTAFILENAME;
-const char *qfextension[] = INITQFNAMES;
+static const char *qfextension[] = INITQFNAMES;
 
 struct quotause {
 	struct	quotause *next;
@@ -101,12 +101,12 @@
 	xdrproc_t inproc, char *in, xdrproc_t outproc, char *out);
 static int alldigits(char *s);
 
-int	hflag;
-int	lflag;
-int	rflag;
-int	qflag;
-int	vflag;
-char	*filename = NULL;
+static int	hflag;
+static int	lflag;
+static int	rflag;
+static int	qflag;
+static int	vflag;
+static char	*filename = NULL;
 
 int
 main(int argc, char *argv[])
@@ -571,7 +571,7 @@
 	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 @@
 	/*
 	 * 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 @@
 		    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,27 +653,18 @@
 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;
+	CLNT_CONTROL(client, CLSET_RETRY_TIMEOUT, (char *)(void *)&timeout);
 
-	if ((client = clntudp_create(&server_addr, prognum,
-	    versnum, timeout, &sock)) == NULL)
-		return ((int) rpc_createerr.cf_stat);
-
 	client->cl_auth = authunix_create_default();
 	tottimeout.tv_sec = 25;
 	tottimeout.tv_usec = 0;



More information about the Midnightbsd-cvs mailing list