diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/quota/quota.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/usr.bin/quota/quota.c b/usr.bin/quota/quota.c index c97fec5..6ddd7aa 100644 --- a/usr.bin/quota/quota.c +++ b/usr.bin/quota/quota.c @@ -483,13 +483,17 @@ getprivs(long id, int quotatype) static int ufshasquota(struct fstab *fs, int type, char **qfnamep) { + char *opt; + char *cp; + struct statfs sfb; static char initname, usrname[100], grpname[100]; static char buf[BUFSIZ]; - char *opt, *cp; if (!initname) { - sprintf(usrname, "%s%s", qfextension[USRQUOTA], qfname); - sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname); + (void)snprintf(usrname, sizeof(usrname), "%s%s", + qfextension[USRQUOTA], qfname); + (void)snprintf(grpname, sizeof(grpname), "%s%s", + qfextension[GRPQUOTA], qfname); initname = 1; } strcpy(buf, fs->fs_mntops); @@ -503,12 +507,22 @@ ufshasquota(struct fstab *fs, int type, char **qfnamep) } if (!opt) return (0); - if (cp) { + if (cp) *qfnamep = cp; - return (1); + else { + (void)snprintf(buf, sizeof(buf), "%s/%s.%s", fs->fs_file, + qfname, qfextension[type]); + *qfnamep = buf; + } + if (statfs(fs->fs_file, &sfb) != 0) { + warn("cannot statfs mount point %s", fs->fs_file); + return (0); + } + if (strcmp(fs->fs_file, sfb.f_mntonname)) { + warnx("%s not mounted for %s quotas", fs->fs_file, + type == USRQUOTA ? "user" : "group"); + return (0); } - (void) sprintf(buf, "%s/%s.%s", fs->fs_file, qfname, qfextension[type]); - *qfnamep = buf; return (1); } |