From d172713dd77fa66824d726720bfc854c399a39aa Mon Sep 17 00:00:00 2001 From: Mike Pritchard Date: Sun, 31 Mar 1996 20:57:44 +0000 Subject: Allow the use of uid ranges when using the "-p" option to allow easy setup of default quotas for a range of uids. Usage: edquota -p protouser startuid-enduid E.g. edquota -p mpp 10000-19999 Will duplicate the quota limints for user mpp for uids 10000 - 19999. The uids in question do not have to currently exist in /etc/passwd. --- usr.sbin/edquota/edquota.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'usr.sbin/edquota/edquota.c') diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c index 441df05f7bdf..31fee417f295 100644 --- a/usr.sbin/edquota/edquota.c +++ b/usr.sbin/edquota/edquota.c @@ -85,8 +85,10 @@ main(argc, argv) extern int optind; register long id, protoid; register int quotatype, tmpfd; - char *protoname, ch; + register uid_t startuid, enduid; + char *protoname, *cp, ch; int tflag = 0, pflag = 0; + char buf[30]; if (argc < 2) usage(); @@ -125,6 +127,25 @@ main(argc, argv) qup->dqblk.dqb_itime = 0; } while (argc-- > 0) { + if (isdigit(*argv[0]) && + (cp = strchr(*argv, '-')) != NULL) { + *cp++ = '\0'; + startuid = atoi(*argv); + enduid = atoi(cp); + if (enduid < startuid) { + fprintf(stderr, "edquota: ending uid (%d) must be >= starting uid (%d) when using uid ranges\n", + enduid, startuid); + exit(1); + } + for ( ; startuid <= enduid; startuid++) { + snprintf(buf, sizeof(buf), "%d", + startuid); + if ((id = getentry(buf, quotatype)) < 0) + continue; + putprivs(id, quotatype, protoprivs); + } + continue; + } if ((id = getentry(*argv++, quotatype)) < 0) continue; putprivs(id, quotatype, protoprivs); -- cgit v1.2.3