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