diff options
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | quota.1 | 8 | ||||
-rw-r--r-- | quota.c | 18 | ||||
-rw-r--r-- | quotaops.c | 29 |
4 files changed, 39 insertions, 17 deletions
@@ -1,4 +1,5 @@ Changes in quota-tools from 3.11 to 3.12 +* maximal number of groups is now got via sysconf (Nathan Scott) * added batch mode to the setquota(8) (Jan Kara) * added reference to setquota(8) to manpages of other tools (Jan Kara) * fixed bug in --port option of rquotad (Max Kalika) @@ -19,7 +19,7 @@ quota \- display disk usage and limits .BR -uvsil \ | .B q ] -.I user +.IR user ... .br .B quota [ @@ -29,7 +29,7 @@ quota \- display disk usage and limits .BR -gvsil \ | .B q ] -.I group +.IR group ... .SH DESCRIPTION .B quota displays users' disk usage and limits. @@ -57,7 +57,9 @@ Possible format names are: .B \-g Print group quotas for the group of which the user is a member. -The optional +The optional +.B group +argument(s) restricts the display to the specified group(s). .TP .B \-u flag is equivalent to the default. @@ -34,7 +34,7 @@ #ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $" #ident "$Copyright: All rights reserved. $" -#ident "$Id: quota.c,v 1.14 2004/04/14 16:03:14 jkar8572 Exp $" +#ident "$Id: quota.c,v 1.15 2004/04/20 19:33:05 jkar8572 Exp $" /* * Disk quota reporting program. @@ -79,7 +79,7 @@ void heading(int type, qid_t id, char *name, char *tag); int main(int argc, char **argv) { int ngroups; - gid_t gidset[NGROUPS]; + gid_t gidset[NGROUPS], *gidsetp; int i, ret; gettexton(); @@ -134,11 +134,19 @@ int main(int argc, char **argv) if (flags & FL_USER) ret |= showquotas(USRQUOTA, getuid()); if (flags & FL_GROUP) { - ngroups = getgroups(NGROUPS, gidset); + ngroups = sysconf(_SC_NGROUPS_MAX); + if (ngroups > NGROUPS) { + gidsetp = malloc(ngroups * sizeof(gid_t)); + if (!gidsetp) + die(1, _("quota: gid set allocation (%d): %s\n"), ngroups, strerror(errno)); + } else { + gidsetp = &gidset[0]; + } + ngroups = getgroups(ngroups, gidsetp); if (ngroups < 0) die(1, _("quota: getgroups(): %s\n"), strerror(errno)); for (i = 0; i < ngroups; i++) - ret |= showquotas(GRPQUOTA, gidset[i]); + ret |= showquotas(GRPQUOTA, gidsetp[i]); } exit(ret); } @@ -253,7 +261,7 @@ int showquotas(int type, qid_t id) continue; } } - if (!(flags & FL_QUIET) && !lines) + if (!(flags & FL_QUIET) && !lines && qlist) heading(type, id, name, _("none")); freeprivs(qlist); dispose_handle_list(handles); @@ -34,7 +34,7 @@ #ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $" #ident "$Copyright: All rights reserved. $" -#ident "$Id: quotaops.c,v 1.12 2004/04/14 16:03:14 jkar8572 Exp $" +#ident "$Id: quotaops.c,v 1.13 2004/04/20 19:33:05 jkar8572 Exp $" #include <rpc/rpc.h> #include <sys/types.h> @@ -96,7 +96,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet) #if defined(BSD_BEHAVIOUR) int j, ngroups; uid_t euid; - gid_t gidset[NGROUPS]; + gid_t gidset[NGROUPS], *gidsetp; char name[MAXNAMELEN]; #endif @@ -107,18 +107,29 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet) euid = geteuid(); if (euid != id && euid != 0) { uid2user(id, name); - die(1, _("%s (uid %d): Permission denied\n"), name, id); + errstr(_("%s (uid %d): Permission denied\n"), name, id); + return (struct dquot *)NULL; } break; case GRPQUOTA: - ngroups = getgroups(NGROUPS, gidset); + ngroups = sysconf(_SC_NGROUPS_MAX); + if (ngroups > NGROUPS) { + gidsetp = malloc(ngroups * sizeof(gid_t)); + if (!gidsetp) { + errstr(_("%s: gid set allocation (%d): %s\n"), name, ngroups, strerror(errno)); + return (struct dquot *)NULL; + } + } else { + gidsetp = &gidset[0]; + } + ngroups = getgroups(ngroups, gidsetp); if (ngroups < 0) { - die(1, _("Error while trying getgroups(): %s\n"), strerror(errno)); - continue; + errstr(_("%s: error while trying getgroups(): %s\n"), name, strerror(errno)); + return (struct dquot *)NULL; } for (j = 0; j < ngroups; j++) - if (id == gidset[j]) + if (id == gidsetp[j]) break; if (j >= ngroups && geteuid() != 0) { @@ -136,8 +147,8 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet) if (!(q = handles[i]->qh_ops->read_dquot(handles[i], id))) { /* If rpc.rquotad is not running filesystem might be just without quotas... */ if (errno != ENOENT && (errno != ECONNREFUSED || !quiet)) - errstr(_("Error while getting quota from %s for %u: %s\n"), - handles[i]->qh_quotadev, id, strerror(errno)); + errstr(_("%s: error while getting quota from %s for %u: %s\n"), + name, handles[i]->qh_quotadev, id, strerror(errno)); continue; } if (qhead == NULL) |