summaryrefslogtreecommitdiffstats
path: root/usr.sbin/edquota
diff options
context:
space:
mode:
authormpp <mpp@FreeBSD.org>1996-03-31 20:57:44 +0000
committermpp <mpp@FreeBSD.org>1996-03-31 20:57:44 +0000
commitf37e8c4ec5816d38e20cd2769b8bded707af4f3c (patch)
tree3435590802e88b915f00a4c342636550766b9487 /usr.sbin/edquota
parented7401f29fe6df1b1c8eaaa35a97df758dc1175a (diff)
downloadFreeBSD-src-f37e8c4ec5816d38e20cd2769b8bded707af4f3c.zip
FreeBSD-src-f37e8c4ec5816d38e20cd2769b8bded707af4f3c.tar.gz
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.
Diffstat (limited to 'usr.sbin/edquota')
-rw-r--r--usr.sbin/edquota/edquota.88
-rw-r--r--usr.sbin/edquota/edquota.c23
2 files changed, 30 insertions, 1 deletions
diff --git a/usr.sbin/edquota/edquota.8 b/usr.sbin/edquota/edquota.8
index f5bf705..eb875e1 100644
--- a/usr.sbin/edquota/edquota.8
+++ b/usr.sbin/edquota/edquota.8
@@ -104,6 +104,14 @@ will duplicate the quotas of the prototypical user
specified for each user specified.
This is the normal mechanism used to
initialize quotas for groups of users.
+If the user given to assign quotas to is a numerical uid
+range (e.g. 1000-2000), then
+.I edquota
+will duplicate the quotas of the prototypical user
+for each uid in the range specified. This allows
+for easy setup of default quotas for a group of users.
+The uids in question do not have to be currently assigned in
+.IR /etc/passwd.
.PP
If the \fI-g\fP flag is specified,
.I edquota
diff --git a/usr.sbin/edquota/edquota.c b/usr.sbin/edquota/edquota.c
index 441df05..31fee41 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);
OpenPOWER on IntegriCloud