Bug in /etc/quotacheck

Gunnar Lindberg lindberg at chalmers.UUCP
Wed Nov 5 02:39:19 AEST 1986


/etc/quotacheck does not correct quota file entries for users that
no longer owns any files in the file system.

System:
    UNIX BSD 4.2++ (TURBO), VAX 11/780.
    Mainly used for education so we quite frequently create and
    remove users (which may be part of the problem).

Observation:
    /etc/repquota starts reporting numerous "#1234..." entries. Using
    "find -user 1234", however, does not give anything. In fact, the
    quota file is in error since the user's entry should have been
    cleared out but hasn't.

Repeat by:
    God knows! I have no idea on how to reproduce the situation.
    There could be bugs in the way the kernel manipulates the quota
    files when root removes files (is this likely?). At times we remove
    quite large amounts of users (200-300) using shell scripts, possibly
    this could lead to "quota overrun"...

Fix:
    What /etc/quotacheck mainly does, is going through the file system
    (inode tables) collecting file sizes etc. for each user. These
    values are the compared to the content of the quota file for the
    users that were found during the search. However, no check is made
    that the users *not* found in the search has zero entries in the
    quota file! Diff's, see below.

	    Gunnar Lindberg (lindberg at chalmers.{UUCP,CSNET})
	    Department of Computer Science
	    Chalmers University of Technology
	    S-412 96 Gothenburg, SWEDEN



RCS file: quotacheck.c,v
retrieving revision 1.1
diff  -r1.1 quotacheck.c
56a57
> struct fileusage	zerofupbuf;	/* Empty entry	*/
163,166c164
< 	for (uid = 0; uid <= highuid; uid++) {
< 		fup = lookup(uid);
< 		if (fup == 0)
< 			continue;
---
> 	for (uid = 0, i = 1; ; uid++) {
170,175c168,190
< 			dqbuf = zerodqbuf;
< 		if (dqbuf.dqb_curinodes == fup->fu_usage.du_curinodes &&
< 		    dqbuf.dqb_curblocks == fup->fu_usage.du_curblocks) {
< 			fup->fu_usage.du_curinodes = 0;
< 			fup->fu_usage.du_curblocks = 0;
< 			continue;
---
> 			dqbuf = zerodqbuf;	/* Unknown...		*/
> 		if (i == 0 && uid > highuid)	/* EOF && End of users	*/
> 		    break;
> 		fup = lookup(uid);
> 		if (fup ==  (struct fileusage *)0)
> 		{
> 		    /*
> 		     * If we didn't find him in our inode-search he (hopefully)
> 		     * doesn't own any files here. If quota file says different
> 		     * we'd better fix it!
> 		     */
> 		    if (dqbuf.dqb_curinodes == 0 && dqbuf.dqb_curblocks == 0)
> 			continue;			/* Empty, OK	*/
> 		    fup = &zerofupbuf;			/* clear it out	*/
> 		}
> 		else
> 		{
> 		    if (dqbuf.dqb_curinodes == fup->fu_usage.du_curinodes &&
> 			dqbuf.dqb_curblocks == fup->fu_usage.du_curblocks) {
> 			    fup->fu_usage.du_curinodes = 0;
> 			    fup->fu_usage.du_curblocks = 0;
> 			    continue;
> 		}



More information about the Comp.bugs.4bsd.ucb-fixes mailing list