Return to BSD News archive
Newsgroups: comp.bugs.2bsd Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!nntp.coast.net!chi-news.cic.net!news.wctc.net!news.new-york.net!wlbr!sms From: sms@wlv.iipo.gtegsc.com (Steven M. Schultz) Subject: extra sprintf in quota(1), missing MNT_QUOTAS in mntopts.h (#303) Sender: news@wlbr.iipo.gtegsc.com (System Administrator) Organization: GTE Government Systems, Thousand Oaks CA USA Message-ID: <DMLJH2.MKJ@wlbr.iipo.gtegsc.com> X-Nntp-Posting-Host: wlv.iipo.gtegsc.com Date: Sun, 11 Feb 1996 05:34:14 GMT Lines: 210 Subject: extra sprintf in quota(1), missing MNT_QUOTAS in mntopts.h (#303) Index: mount/mntopts.h,ucb/quota.c 2.11BSD Description: mount(8) complains about illegal option "quotas" if the new style fstab(5) format is used and quotas are enabled. quota(1) always reports "no quota" even if quotas are enabled and a quota has been assigned to a user id. Repeat-By: Have an entry of the form: /dev/ra0f /user ufs rw,quotas 1 4 present in /etc/fstab. Note the error from 'mount'. Have quotas enabled and assigned for a user. Use 'quota' and note that the response is "Disk quotas for ... (none)" Fix: The first problem was caused by paying too much attention to the compatibility mode in the parsing of /etc/fstab. The old "rq" would be correctly handled but the newer "quotas" option was inadvertently omitted. Oops ;-) In the second case too much code was cut and pasted - the 'hasquota' routine generated the correct pathname. The calling routine then prepended the mount point name resulting in the quota file being called something like "/users/users/quotas" which didn't exist, thus no quotas were ever reported. Cut where indicated, saving to a file (/tmp/303) and then: patch -p0 < /tmp/303 cd /usr/src/etc/mount make make install make clean cd /usr/src/ucb make quota install -s -m 4755 quota /usr/ucb/quota ------------------------------cut here------------------------------ *** /usr/src/etc/mount/mntopts.h.old Wed Jan 24 23:32:57 1996 --- /usr/src/etc/mount/mntopts.h Wed Feb 7 22:58:58 1996 *************** *** 30,36 **** * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)mntopts.h 8.3.1 (2.11BSD) 1996/1/16 */ struct mntopt { --- 30,36 ---- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ! * @(#)mntopts.h 8.3.2 (2.11BSD) 1996/2/7 */ struct mntopt { *************** *** 46,51 **** --- 46,52 ---- #define MOPT_NOSUID { "suid", 1, MNT_NOSUID } #define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY } #define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS } + #define MOPT_QUOTAS { "quotas", 0, 0 } /* Control flags. */ #define MOPT_FORCE { "force", 1, MNT_FORCE } *************** *** 56,69 **** #define MOPT_RW { "rw", 1, MNT_RDONLY } #define MOPT_RQ { "rq", 1, MNT_RDONLY } #define MOPT_FSTAB_COMPAT \ MOPT_RO, \ MOPT_RW, \ ! MOPT_RQ /* Standard options which all mounts can understand. */ #define MOPT_STDOPTS \ MOPT_FSTAB_COMPAT, \ MOPT_NODEV, \ MOPT_NOEXEC, \ MOPT_NOSUID, \ --- 57,77 ---- #define MOPT_RW { "rw", 1, MNT_RDONLY } #define MOPT_RQ { "rq", 1, MNT_RDONLY } + /* Ignored options (used for control in fstab) */ + #define MOPT_AUTO { "auto", } + #define MOPT_NOAUTO { "na", } + #define MOPT_FSTAB_COMPAT \ MOPT_RO, \ MOPT_RW, \ ! MOPT_RQ, \ ! MOPT_NOAUTO, \ ! MOPT_AUTO /* Standard options which all mounts can understand. */ #define MOPT_STDOPTS \ MOPT_FSTAB_COMPAT, \ + MOPT_QUOTAS, \ MOPT_NODEV, \ MOPT_NOEXEC, \ MOPT_NOSUID, \ *** /usr/src/ucb/quota.c.old Sun Jan 21 17:40:15 1996 --- /usr/src/ucb/quota.c Wed Feb 7 23:27:08 1996 *************** *** 9,15 **** "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)quota.c 5.4.2 (2.11BSD GTE) 1996/1/21"; #endif /* --- 9,15 ---- "@(#) Copyright (c) 1980 Regents of the University of California.\n\ All rights reserved.\n"; ! static char sccsid[] = "@(#)quota.c 5.4.3 (2.11BSD GTE) 1996/2/7"; #endif /* *************** *** 113,119 **** char *qfpathname; struct dqblk dqblk; int myuid, fd; ! char qfilename[MAXPATHLEN + 1], iwarn[8], dwarn[8]; myuid = getuid(); if (uid != myuid && myuid != 0) { --- 113,119 ---- char *qfpathname; struct dqblk dqblk; int myuid, fd; ! char iwarn[8], dwarn[8]; myuid = getuid(); if (uid != myuid && myuid != 0) { *************** *** 130,136 **** if (stat(fs->fs_spec, &statb) < 0) continue; msgi = msgb = (char *) 0; - (void) sprintf(qfilename, "%s/%s", fs->fs_file, qfpathname); /* * This check for the quota file being in the filesystem to which the quotas * belong is silly but the kernel enforces it. When the kernel is fixed the --- 130,135 ---- *************** *** 137,146 **** * check can be removed. */ fsdev = statb.st_rdev; ! if (stat(qfilename, &statb) < 0 || statb.st_dev != fsdev) continue; if (quota(Q_GETDLIM, uid, fsdev, (caddr_t)&dqblk)) { ! fd = open(qfilename, O_RDONLY); if (fd < 0) continue; (void) lseek(fd, (off_t)(uid * sizeof (dqblk)), L_SET); --- 136,145 ---- * check can be removed. */ fsdev = statb.st_rdev; ! if (stat(qfpathname, &statb) < 0 || statb.st_dev != fsdev) continue; if (quota(Q_GETDLIM, uid, fsdev, (caddr_t)&dqblk)) { ! fd = open(qfpathname, O_RDONLY); if (fd < 0) continue; (void) lseek(fd, (off_t)(uid * sizeof (dqblk)), L_SET); *************** *** 163,169 **** default: /* ERROR */ fprintf(stderr, "quota: read error in "); ! perror(qfilename); (void) close(fd); continue; } --- 162,168 ---- default: /* ERROR */ fprintf(stderr, "quota: read error in "); ! perror(qfpathname); (void) close(fd); continue; } *** /VERSION.old Wed Feb 7 20:16:05 1996 --- /VERSION Wed Feb 7 23:29:24 1996 *************** *** 1,4 **** ! Current Patch Level: 302 2.11 BSD ============ --- 1,4 ---- ! Current Patch Level: 303 2.11 BSD ============