diff options
author | Mike Pritchard <mpp@FreeBSD.org> | 1996-03-31 20:57:44 +0000 |
---|---|---|
committer | Mike Pritchard <mpp@FreeBSD.org> | 1996-03-31 20:57:44 +0000 |
commit | d172713dd77fa66824d726720bfc854c399a39aa (patch) | |
tree | 3435590802e88b915f00a4c342636550766b9487 /usr.sbin/edquota/edquota.c | |
parent | 5931895ece70cf13eefaf97de2874078097713b0 (diff) | |
download | src-d172713dd77fa66824d726720bfc854c399a39aa.tar.gz src-d172713dd77fa66824d726720bfc854c399a39aa.zip |
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.
Notes
Notes:
svn path=/head/; revision=14961
Diffstat (limited to 'usr.sbin/edquota/edquota.c')
-rw-r--r-- | usr.sbin/edquota/edquota.c | 23 |
1 files changed, 22 insertions, 1 deletions
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); |