Home | History | Annotate | Line # | Download | only in quota
quota.c revision 1.12
      1 /*	$NetBSD: quota.c,v 1.12 1997/01/09 20:20:53 tls Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1980, 1990, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * Robert Elz at The University of Melbourne.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  */
     38 
     39 #ifndef lint
     40 static char copyright[] =
     41 "@(#) Copyright (c) 1980, 1990, 1993\n\
     42 	The Regents of the University of California.  All rights reserved.\n";
     43 #endif /* not lint */
     44 
     45 #ifndef lint
     46 /*static char sccsid[] = "from: @(#)quota.c	8.1 (Berkeley) 6/6/93";*/
     47 static char rcsid[] = "$NetBSD: quota.c,v 1.12 1997/01/09 20:20:53 tls Exp $";
     48 #endif /* not lint */
     49 
     50 /*
     51  * Disk quota reporting program.
     52  */
     53 #include <sys/param.h>
     54 #include <sys/types.h>
     55 #include <sys/file.h>
     56 #include <sys/stat.h>
     57 #include <sys/mount.h>
     58 #include <sys/socket.h>
     59 #include <ufs/ufs/quota.h>
     60 #include <stdio.h>
     61 #include <stdlib.h>
     62 #include <fstab.h>
     63 #include <ctype.h>
     64 #include <string.h>
     65 #include <pwd.h>
     66 #include <grp.h>
     67 #include <errno.h>
     68 
     69 #include <netdb.h>
     70 #include <rpc/rpc.h>
     71 #include <rpc/pmap_prot.h>
     72 #include <rpcsvc/rquota.h>
     73 
     74 char *qfname = QUOTAFILENAME;
     75 char *qfextension[] = INITQFNAMES;
     76 
     77 struct quotause {
     78 	struct	quotause *next;
     79 	long	flags;
     80 	struct	dqblk dqblk;
     81 	char	fsname[MAXPATHLEN + 1];
     82 };
     83 #define	FOUND	0x01
     84 
     85 char *timeprt	__P((time_t seconds));
     86 struct quotause *getprivs __P((long id, int quotatype));
     87 
     88 int	qflag;
     89 int	vflag;
     90 
     91 main(argc, argv)
     92 	char *argv[];
     93 {
     94 	int ngroups;
     95 	gid_t mygid, gidset[NGROUPS];
     96 	int i, gflag = 0, uflag = 0;
     97 	int ch;
     98 	extern char *optarg;
     99 	extern int optind, errno;
    100 
    101 	while ((ch = getopt(argc, argv, "ugvq")) != -1) {
    102 		switch(ch) {
    103 		case 'g':
    104 			gflag++;
    105 			break;
    106 		case 'u':
    107 			uflag++;
    108 			break;
    109 		case 'v':
    110 			vflag++;
    111 			break;
    112 		case 'q':
    113 			qflag++;
    114 			break;
    115 		default:
    116 			usage();
    117 		}
    118 	}
    119 	argc -= optind;
    120 	argv += optind;
    121 	if (!uflag && !gflag)
    122 		uflag++;
    123 	if (argc == 0) {
    124 		if (uflag)
    125 			showuid(getuid());
    126 		if (gflag) {
    127 			mygid = getgid();
    128 			ngroups = getgroups(NGROUPS, gidset);
    129 			if (ngroups < 0) {
    130 				perror("quota: getgroups");
    131 				exit(1);
    132 			}
    133 			showgid(mygid);
    134 			for (i = 0; i < ngroups; i++)
    135 				if (gidset[i] != mygid)
    136 					showgid(gidset[i]);
    137 		}
    138 		exit(0);
    139 	}
    140 	if (uflag && gflag)
    141 		usage();
    142 	if (uflag) {
    143 		for (; argc > 0; argc--, argv++) {
    144 			if (alldigits(*argv))
    145 				showuid(atoi(*argv));
    146 			else
    147 				showusrname(*argv);
    148 		}
    149 		exit(0);
    150 	}
    151 	if (gflag) {
    152 		for (; argc > 0; argc--, argv++) {
    153 			if (alldigits(*argv))
    154 				showgid(atoi(*argv));
    155 			else
    156 				showgrpname(*argv);
    157 		}
    158 		exit(0);
    159 	}
    160 }
    161 
    162 usage()
    163 {
    164 
    165 	fprintf(stderr, "%s\n%s\n%s\n",
    166 		"Usage: quota [-guqv]",
    167 		"\tquota [-qv] -u username ...",
    168 		"\tquota [-qv] -g groupname ...");
    169 	exit(1);
    170 }
    171 
    172 /*
    173  * Print out quotas for a specified user identifier.
    174  */
    175 showuid(uid)
    176 	u_long uid;
    177 {
    178 	struct passwd *pwd = getpwuid(uid);
    179 	u_long myuid;
    180 	char *name;
    181 
    182 	if (pwd == NULL)
    183 		name = "(no account)";
    184 	else
    185 		name = pwd->pw_name;
    186 	myuid = getuid();
    187 	if (uid != myuid && myuid != 0) {
    188 		printf("quota: %s (uid %d): permission denied\n", name, uid);
    189 		return;
    190 	}
    191 	showquotas(USRQUOTA, uid, name);
    192 }
    193 
    194 /*
    195  * Print out quotas for a specifed user name.
    196  */
    197 showusrname(name)
    198 	char *name;
    199 {
    200 	struct passwd *pwd = getpwnam(name);
    201 	u_long myuid;
    202 
    203 	if (pwd == NULL) {
    204 		fprintf(stderr, "quota: %s: unknown user\n", name);
    205 		return;
    206 	}
    207 	myuid = getuid();
    208 	if (pwd->pw_uid != myuid && myuid != 0) {
    209 		fprintf(stderr, "quota: %s (uid %d): permission denied\n",
    210 		    name, pwd->pw_uid);
    211 		return;
    212 	}
    213 	showquotas(USRQUOTA, pwd->pw_uid, name);
    214 }
    215 
    216 /*
    217  * Print out quotas for a specified group identifier.
    218  */
    219 showgid(gid)
    220 	u_long gid;
    221 {
    222 	struct group *grp = getgrgid(gid);
    223 	int ngroups;
    224 	gid_t mygid, gidset[NGROUPS];
    225 	register int i;
    226 	char *name;
    227 
    228 	if (grp == NULL)
    229 		name = "(no entry)";
    230 	else
    231 		name = grp->gr_name;
    232 	mygid = getgid();
    233 	ngroups = getgroups(NGROUPS, gidset);
    234 	if (ngroups < 0) {
    235 		perror("quota: getgroups");
    236 		return;
    237 	}
    238 	if (gid != mygid) {
    239 		for (i = 0; i < ngroups; i++)
    240 			if (gid == gidset[i])
    241 				break;
    242 		if (i >= ngroups && getuid() != 0) {
    243 			fprintf(stderr,
    244 			    "quota: %s (gid %d): permission denied\n",
    245 			    name, gid);
    246 			return;
    247 		}
    248 	}
    249 	showquotas(GRPQUOTA, gid, name);
    250 }
    251 
    252 /*
    253  * Print out quotas for a specifed group name.
    254  */
    255 showgrpname(name)
    256 	char *name;
    257 {
    258 	struct group *grp = getgrnam(name);
    259 	int ngroups;
    260 	gid_t mygid, gidset[NGROUPS];
    261 	register int i;
    262 
    263 	if (grp == NULL) {
    264 		fprintf(stderr, "quota: %s: unknown group\n", name);
    265 		return;
    266 	}
    267 	mygid = getgid();
    268 	ngroups = getgroups(NGROUPS, gidset);
    269 	if (ngroups < 0) {
    270 		perror("quota: getgroups");
    271 		return;
    272 	}
    273 	if (grp->gr_gid != mygid) {
    274 		for (i = 0; i < ngroups; i++)
    275 			if (grp->gr_gid == gidset[i])
    276 				break;
    277 		if (i >= ngroups && getuid() != 0) {
    278 			fprintf(stderr,
    279 			    "quota: %s (gid %d): permission denied\n",
    280 			    name, grp->gr_gid);
    281 			return;
    282 		}
    283 	}
    284 	showquotas(GRPQUOTA, grp->gr_gid, name);
    285 }
    286 
    287 showquotas(type, id, name)
    288 	int type;
    289 	u_long id;
    290 	char *name;
    291 {
    292 	register struct quotause *qup;
    293 	struct quotause *quplist;
    294 	char *msgi, *msgb, *nam;
    295 	int myuid, fd, lines = 0;
    296 	static int first;
    297 	static time_t now;
    298 
    299 	if (now == 0)
    300 		time(&now);
    301 	quplist = getprivs(id, type);
    302 	for (qup = quplist; qup; qup = qup->next) {
    303 		if (!vflag &&
    304 		    qup->dqblk.dqb_isoftlimit == 0 &&
    305 		    qup->dqblk.dqb_ihardlimit == 0 &&
    306 		    qup->dqblk.dqb_bsoftlimit == 0 &&
    307 		    qup->dqblk.dqb_bhardlimit == 0)
    308 			continue;
    309 		msgi = (char *)0;
    310 		if (qup->dqblk.dqb_ihardlimit &&
    311 		    qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_ihardlimit)
    312 			msgi = "File limit reached on";
    313 		else if (qup->dqblk.dqb_isoftlimit &&
    314 		    qup->dqblk.dqb_curinodes >= qup->dqblk.dqb_isoftlimit)
    315 			if (qup->dqblk.dqb_itime > now)
    316 				msgi = "In file grace period on";
    317 			else
    318 				msgi = "Over file quota on";
    319 		msgb = (char *)0;
    320 		if (qup->dqblk.dqb_bhardlimit &&
    321 		    qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bhardlimit)
    322 			msgb = "Block limit reached on";
    323 		else if (qup->dqblk.dqb_bsoftlimit &&
    324 		    qup->dqblk.dqb_curblocks >= qup->dqblk.dqb_bsoftlimit)
    325 			if (qup->dqblk.dqb_btime > now)
    326 				msgb = "In block grace period on";
    327 			else
    328 				msgb = "Over block quota on";
    329 		if (qflag) {
    330 			if ((msgi != (char *)0 || msgb != (char *)0) &&
    331 			    lines++ == 0)
    332 				heading(type, id, name, "");
    333 			if (msgi != (char *)0)
    334 				printf("\t%s %s\n", msgi, qup->fsname);
    335 			if (msgb != (char *)0)
    336 				printf("\t%s %s\n", msgb, qup->fsname);
    337 			continue;
    338 		}
    339 		if (vflag ||
    340 		    qup->dqblk.dqb_curblocks ||
    341 		    qup->dqblk.dqb_curinodes) {
    342 			if (lines++ == 0)
    343 				heading(type, id, name, "");
    344 			nam = qup->fsname;
    345 			if (strlen(qup->fsname) > 15) {
    346 				printf("%s\n", qup->fsname);
    347 				nam = "";
    348 			}
    349 			printf("%15s%8d%c%7d%8d%8s"
    350 				, nam
    351 				, dbtob(qup->dqblk.dqb_curblocks) / 1024
    352 				, (msgb == (char *)0) ? ' ' : '*'
    353 				, dbtob(qup->dqblk.dqb_bsoftlimit) / 1024
    354 				, dbtob(qup->dqblk.dqb_bhardlimit) / 1024
    355 				, (msgb == (char *)0) ? ""
    356 				    : timeprt(qup->dqblk.dqb_btime));
    357 			printf("%8d%c%7d%8d%8s\n"
    358 				, qup->dqblk.dqb_curinodes
    359 				, (msgi == (char *)0) ? ' ' : '*'
    360 				, qup->dqblk.dqb_isoftlimit
    361 				, qup->dqblk.dqb_ihardlimit
    362 				, (msgi == (char *)0) ? ""
    363 				    : timeprt(qup->dqblk.dqb_itime)
    364 			);
    365 			continue;
    366 		}
    367 	}
    368 	if (!qflag && lines == 0)
    369 		heading(type, id, name, "none");
    370 }
    371 
    372 heading(type, id, name, tag)
    373 	int type;
    374 	u_long id;
    375 	char *name, *tag;
    376 {
    377 
    378 	printf("Disk quotas for %s %s (%cid %d): %s\n", qfextension[type],
    379 	    name, *qfextension[type], id, tag);
    380 	if (!qflag && tag[0] == '\0') {
    381 		printf("%15s%8s %7s%8s%8s%8s %7s%8s%8s\n"
    382 			, "Filesystem"
    383 			, "blocks"
    384 			, "quota"
    385 			, "limit"
    386 			, "grace"
    387 			, "files"
    388 			, "quota"
    389 			, "limit"
    390 			, "grace"
    391 		);
    392 	}
    393 }
    394 
    395 /*
    396  * Calculate the grace period and return a printable string for it.
    397  */
    398 char *
    399 timeprt(seconds)
    400 	time_t seconds;
    401 {
    402 	time_t hours, minutes;
    403 	static char buf[20];
    404 	static time_t now;
    405 
    406 	if (now == 0)
    407 		time(&now);
    408 	if (now > seconds)
    409 		return ("none");
    410 	seconds -= now;
    411 	minutes = (seconds + 30) / 60;
    412 	hours = (minutes + 30) / 60;
    413 	if (hours >= 36) {
    414 		sprintf(buf, "%ddays", (hours + 12) / 24);
    415 		return (buf);
    416 	}
    417 	if (minutes >= 60) {
    418 		sprintf(buf, "%2d:%d", minutes / 60, minutes % 60);
    419 		return (buf);
    420 	}
    421 	sprintf(buf, "%2d", minutes);
    422 	return (buf);
    423 }
    424 
    425 /*
    426  * Collect the requested quota information.
    427  */
    428 struct quotause *
    429 getprivs(id, quotatype)
    430 	register long id;
    431 	int quotatype;
    432 {
    433 	register struct quotause *qup, *quptail;
    434 	register struct fstab *fs;
    435 	struct quotause *quphead;
    436 	struct statfs *fst;
    437 	int nfst, i;
    438 
    439 	qup = quphead = (struct quotause *)0;
    440 
    441 	nfst = getmntinfo(&fst, MNT_WAIT);
    442 	if (nfst == 0) {
    443 		fprintf(stderr, "quota: no filesystems mounted!\n");
    444 		exit(2);
    445 	}
    446 	setfsent();
    447 	for (i=0; i<nfst; i++) {
    448 		if (qup == NULL) {
    449 			if ((qup = (struct quotause *)malloc(sizeof *qup)) == NULL) {
    450 				fprintf(stderr, "quota: out of memory\n");
    451 				exit(2);
    452 			}
    453 		}
    454 		if (strncmp(fst[i].f_fstypename, "nfs", MFSNAMELEN) == 0) {
    455 			if (getnfsquota(&fst[i], NULL, qup, id, quotatype) == 0)
    456 				continue;
    457 		} else if (strncmp(fst[i].f_fstypename, "ffs",
    458 		    MFSNAMELEN) == 0) {
    459 			/*
    460 			 * XXX
    461 			 * UFS filesystems must be in /etc/fstab, and must
    462 			 * indicate that they have quotas on (?!) This is quite
    463 			 * unlike SunOS where quotas can be enabled/disabled
    464 			 * on a filesystem independent of /etc/fstab, and it
    465 			 * will still print quotas for them.
    466 			 */
    467 			if ((fs = getfsspec(fst[i].f_mntfromname)) == NULL)
    468 				continue;
    469 			if (getufsquota(&fst[i], fs, qup, id, quotatype) == 0)
    470 				continue;
    471 		} else
    472 			continue;
    473 		strcpy(qup->fsname, fst[i].f_mntonname);
    474 		if (quphead == NULL)
    475 			quphead = qup;
    476 		else
    477 			quptail->next = qup;
    478 		quptail = qup;
    479 		quptail->next = 0;
    480 		qup = NULL;
    481 	}
    482 	if (qup)
    483 		free(qup);
    484 	endfsent();
    485 	return (quphead);
    486 }
    487 
    488 /*
    489  * Check to see if a particular quota is to be enabled.
    490  */
    491 ufshasquota(fs, type, qfnamep)
    492 	register struct fstab *fs;
    493 	int type;
    494 	char **qfnamep;
    495 {
    496 	static char initname, usrname[100], grpname[100];
    497 	static char buf[BUFSIZ];
    498 	char *opt, *cp;
    499 
    500 	if (!initname) {
    501 		sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname);
    502 		sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname);
    503 		initname = 1;
    504 	}
    505 	strcpy(buf, fs->fs_mntops);
    506 	for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
    507 		if (cp = index(opt, '='))
    508 			*cp++ = '\0';
    509 		if (type == USRQUOTA && strcmp(opt, usrname) == 0)
    510 			break;
    511 		if (type == GRPQUOTA && strcmp(opt, grpname) == 0)
    512 			break;
    513 	}
    514 	if (!opt)
    515 		return (0);
    516 	if (cp) {
    517 		*qfnamep = cp;
    518 		return (1);
    519 	}
    520 	(void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]);
    521 	*qfnamep = buf;
    522 	return (1);
    523 }
    524 
    525 int
    526 getufsquota(fst, fs, qup, id, quotatype)
    527 	struct statfs *fst;
    528 	struct fstab *fs;
    529 	struct quotause *qup;
    530 	long id;
    531 	int quotatype;
    532 {
    533 	char *qfpathname;
    534 	int fd, qcmd;
    535 
    536 	qcmd = QCMD(Q_GETQUOTA, quotatype);
    537 	if (!ufshasquota(fs, quotatype, &qfpathname))
    538 		return (0);
    539 
    540 	if (quotactl(fs->fs_file, qcmd, id, &qup->dqblk) != 0) {
    541 		if ((fd = open(qfpathname, O_RDONLY)) < 0) {
    542 			perror(qfpathname);
    543 			return (0);
    544 		}
    545 		(void) lseek(fd, (off_t)(id * sizeof(struct dqblk)), L_SET);
    546 		switch (read(fd, &qup->dqblk, sizeof(struct dqblk))) {
    547 		case 0:				/* EOF */
    548 			/*
    549 			 * Convert implicit 0 quota (EOF)
    550 			 * into an explicit one (zero'ed dqblk)
    551 			 */
    552 			bzero((caddr_t)&qup->dqblk, sizeof(struct dqblk));
    553 			break;
    554 		case sizeof(struct dqblk):	/* OK */
    555 			break;
    556 		default:		/* ERROR */
    557 			fprintf(stderr, "quota: read error");
    558 			perror(qfpathname);
    559 			close(fd);
    560 			return (0);
    561 		}
    562 		close(fd);
    563 	}
    564 	return (1);
    565 }
    566 
    567 int
    568 getnfsquota(fst, fs, qup, id, quotatype)
    569 	struct statfs *fst;
    570 	struct fstab *fs;
    571 	struct quotause *qup;
    572 	long id;
    573 	int quotatype;
    574 {
    575 	struct getquota_args gq_args;
    576 	struct getquota_rslt gq_rslt;
    577 	struct dqblk *dqp = &qup->dqblk;
    578 	struct timeval tv;
    579 	char *cp;
    580 
    581 	if (fst->f_flags & MNT_LOCAL)
    582 		return (0);
    583 
    584 	/*
    585 	 * rpc.rquotad does not support group quotas
    586 	 */
    587 	if (quotatype != USRQUOTA)
    588 		return (0);
    589 
    590 	/*
    591 	 * must be some form of "hostname:/path"
    592 	 */
    593 	cp = strchr(fst->f_mntfromname, ':');
    594 	if (cp == NULL) {
    595 		fprintf(stderr, "cannot find hostname for %s\n",
    596 		    fst->f_mntfromname);
    597 		return (0);
    598 	}
    599 
    600 	*cp = '\0';
    601 	if (*(cp+1) != '/') {
    602 		*cp = ':';
    603 		return (0);
    604 	}
    605 
    606 	gq_args.gqa_pathp = cp + 1;
    607 	gq_args.gqa_uid = id;
    608 	if (callaurpc(fst->f_mntfromname, RQUOTAPROG, RQUOTAVERS,
    609 	    RQUOTAPROC_GETQUOTA, xdr_getquota_args, &gq_args,
    610 	    xdr_getquota_rslt, &gq_rslt) != 0) {
    611 		*cp = ':';
    612 		return (0);
    613 	}
    614 
    615 	switch (gq_rslt.status) {
    616 	case Q_NOQUOTA:
    617 		break;
    618 	case Q_EPERM:
    619 		fprintf(stderr, "quota permission error, host: %s\n",
    620 			fst->f_mntfromname);
    621 		break;
    622 	case Q_OK:
    623 		gettimeofday(&tv, NULL);
    624 			/* blocks*/
    625 		dqp->dqb_bhardlimit =
    626 		    gq_rslt.getquota_rslt_u.gqr_rquota.rq_bhardlimit *
    627 		    gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE;
    628 		dqp->dqb_bsoftlimit =
    629 		    gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsoftlimit *
    630 		    gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE;
    631 		dqp->dqb_curblocks =
    632 		    gq_rslt.getquota_rslt_u.gqr_rquota.rq_curblocks *
    633 		    gq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize / DEV_BSIZE;
    634 			/* inodes */
    635 		dqp->dqb_ihardlimit =
    636 			gq_rslt.getquota_rslt_u.gqr_rquota.rq_fhardlimit;
    637 		dqp->dqb_isoftlimit =
    638 			gq_rslt.getquota_rslt_u.gqr_rquota.rq_fsoftlimit;
    639 		dqp->dqb_curinodes =
    640 			gq_rslt.getquota_rslt_u.gqr_rquota.rq_curfiles;
    641 			/* grace times */
    642 		dqp->dqb_btime =
    643 		    tv.tv_sec + gq_rslt.getquota_rslt_u.gqr_rquota.rq_btimeleft;
    644 		dqp->dqb_itime =
    645 		    tv.tv_sec + gq_rslt.getquota_rslt_u.gqr_rquota.rq_ftimeleft;
    646 		*cp = ':';
    647 		return (1);
    648 	default:
    649 		fprintf(stderr, "bad rpc result, host: %s\n",
    650 		    fst->f_mntfromname);
    651 		break;
    652 	}
    653 	*cp = ':';
    654 	return (0);
    655 }
    656 
    657 int
    658 callaurpc(host, prognum, versnum, procnum, inproc, in, outproc, out)
    659 	char *host;
    660 	xdrproc_t inproc, outproc;
    661 	char *in, *out;
    662 {
    663 	struct sockaddr_in server_addr;
    664 	enum clnt_stat clnt_stat;
    665 	struct hostent *hp;
    666 	struct timeval timeout, tottimeout;
    667 
    668 	CLIENT *client = NULL;
    669 	int socket = RPC_ANYSOCK;
    670 
    671 	if ((hp = gethostbyname(host)) == NULL)
    672 		return ((int) RPC_UNKNOWNHOST);
    673 	timeout.tv_usec = 0;
    674 	timeout.tv_sec = 6;
    675 	bcopy(hp->h_addr, &server_addr.sin_addr, hp->h_length);
    676 	server_addr.sin_family = AF_INET;
    677 	server_addr.sin_port =  0;
    678 
    679 	if ((client = clntudp_create(&server_addr, prognum,
    680 	    versnum, timeout, &socket)) == NULL)
    681 		return ((int) rpc_createerr.cf_stat);
    682 
    683 	client->cl_auth = authunix_create_default();
    684 	tottimeout.tv_sec = 25;
    685 	tottimeout.tv_usec = 0;
    686 	clnt_stat = clnt_call(client, procnum, inproc, in,
    687 	    outproc, out, tottimeout);
    688 
    689 	return ((int) clnt_stat);
    690 }
    691 
    692 alldigits(s)
    693 	register char *s;
    694 {
    695 	register c;
    696 
    697 	c = *s++;
    698 	do {
    699 		if (!isdigit(c))
    700 			return (0);
    701 	} while (c = *s++);
    702 	return (1);
    703 }
    704