[PATCH] add -n to repquota

Brooks Davis brooks at one-eyed-alien.net
Tue Jul 1 17:14:31 PDT 2003


Does anyone object to this patch adding a -n option to repquota?  A
student admin on a RedHat system I help administer was running into
problems with their repquota truncating usernames[1] and I realized that
repquota really ought to have a -n option since that would be handy
for some scripts and would optionally eliminate the dependency of the
password database.

-- Brooks

[1] Fixed in 4.4BSD, maybe earlier

Index: repquota.8
===================================================================
RCS file: /usr/cvs/src/usr.sbin/repquota/repquota.8,v
retrieving revision 1.9
diff -u -p -r1.9 repquota.8
--- repquota.8	12 Dec 2002 17:26:03 -0000	1.9
+++ repquota.8	1 Jul 2003 23:56:37 -0000
@@ -44,11 +44,13 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl g
+.Op Fl n
 .Op Fl u
 .Op Fl v
 .Ar filesystem Ar ...
 .Nm
 .Op Fl g
+.Op Fl n
 .Op Fl u
 .Op Fl v
 .Fl a
@@ -66,6 +68,9 @@ Print the quotas of all the file systems
 .It Fl g
 Print only group quotas (the default is to print both
 group and user quotas if they exist).
+.It Fl n
+Display user and group IDs numerically rather than converting to
+a user or group name.
 .It Fl u
 Print only user quotas (the default is to print both
 group and user quotas if they exist).
Index: repquota.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/repquota/repquota.c,v
retrieving revision 1.15
diff -u -p -r1.15 repquota.c
--- repquota.c	3 May 2003 21:06:39 -0000	1.15
+++ repquota.c	1 Jul 2003 23:51:16 -0000
@@ -96,6 +96,7 @@ u_long highid[MAXQUOTAS];	/* highest add
 
 int	vflag;			/* verbose */
 int	aflag;			/* all filesystems */
+int	nflag;			/* display user/group by id */
 
 int hasquota(struct fstab *, int, char **);
 int oneof(char *, char *[], int);
@@ -113,7 +114,7 @@ main(int argc, char **argv)
 	long i, argnum, done = 0;
 	char ch, *qfnp;
 
-	while ((ch = getopt(argc, argv, "aguv")) != -1) {
+	while ((ch = getopt(argc, argv, "agnuv")) != -1) {
 		switch(ch) {
 		case 'a':
 			aflag++;
@@ -121,6 +122,9 @@ main(int argc, char **argv)
 		case 'g':
 			gflag++;
 			break;
+		case 'n':
+			nflag++;
+			break;
 		case 'u':
 			uflag++;
 			break;
@@ -140,13 +144,13 @@ main(int argc, char **argv)
 			gflag++;
 		uflag++;
 	}
-	if (gflag) {
+	if (gflag && !nflag) {
 		setgrent();
 		while ((gr = getgrent()) != 0)
 			(void) addid((u_long)gr->gr_gid, GRPQUOTA, gr->gr_name);
 		endgrent();
 	}
-	if (uflag) {
+	if (uflag && !nflag) {
 		setpwent();
 		while ((pw = getpwent()) != 0)
 			(void) addid((u_long)pw->pw_uid, USRQUOTA, pw->pw_name);
@@ -183,8 +187,8 @@ static void
 usage()
 {
 	fprintf(stderr, "%s\n%s\n",
-		"usage: repquota [-v] [-g] [-u] -a",
-		"       repquota [-v] [-g] [-u] filesystem ...");
+		"usage: repquota [-v] [-g] [-n] [-u] -a",
+		"       repquota [-v] [-g] [-n] [-u] filesystem ...");
 	exit(1);
 }
 

-- 
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20030701/a271db49/attachment.bin


More information about the freebsd-hackers mailing list