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.
This commit is contained in:
parent
5931895ece
commit
d172713dd7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=14961
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user