summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2002-05-03 07:05:46 +0000
committerjkar8572 <jkar8572>2002-05-03 07:05:46 +0000
commit1883e1ee6514b304d0bb6fa5705644230b145a4b (patch)
treeff59246795e0be3744869e440c613160d269b526
parent04bc20aa76dc9743a3d81ad48427860e0f3f3b2f (diff)
downloadlinuxquota-1883e1ee6514b304d0bb6fa5705644230b145a4b.tar.gz
Fixed bug with rpc.rquotad bad path processing.
-rw-r--r--convertquota.c4
-rw-r--r--quot.c4
-rw-r--r--quotacheck.c6
-rw-r--r--quotaio.c3
-rw-r--r--quotaon.c6
-rw-r--r--quotasys.c45
-rw-r--r--quotasys.h8
-rw-r--r--rquota_server.c10
8 files changed, 53 insertions, 33 deletions
diff --git a/convertquota.c b/convertquota.c
index f690889..06c235b 100644
--- a/convertquota.c
+++ b/convertquota.c
@@ -345,9 +345,9 @@ int main(int argc, char **argv)
parse_options(argc, argv);
init_kernel_interface();
- if (init_mounts_scan(1, &mntpoint) < 0)
+ if (init_mounts_scan(1, &mntpoint, 0) < 0)
return 1;
- if (!(mnt = get_next_mount(0))) {
+ if (!(mnt = get_next_mount())) {
end_mounts_scan();
return 1;
}
diff --git a/quot.c b/quot.c
index 4f855f5..0ee1c8d 100644
--- a/quot.c
+++ b/quot.c
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
usage();
if (!uflag && !gflag)
uflag++;
- if (init_mounts_scan(aflag ? 0 : argc - optind, argv + optind) < 0)
+ if (init_mounts_scan(aflag ? 0 : argc - optind, argv + optind, 0) < 0)
return 1;
mounttable();
end_mounts_scan();
@@ -131,7 +131,7 @@ static void mounttable(void)
int doit = 0;
struct mntent *mntp;
- while ((mntp = get_next_mount(0))) {
+ while ((mntp = get_next_mount())) {
/* Currently, only XFS is implemented... */
if (strcmp(mntp->mnt_type, MNTTYPE_XFS) == 0) {
checkXFS(mntp->mnt_fsname, mntp->mnt_dir);
diff --git a/quotacheck.c b/quotacheck.c
index e4586ed..b318f34 100644
--- a/quotacheck.c
+++ b/quotacheck.c
@@ -8,7 +8,7 @@
* New quota format implementation - Jan Kara <jack@suse.cz> - Sponsored by SuSE CR
*/
-#ident "$Id: quotacheck.c,v 1.28 2002/04/26 11:59:19 jkar8572 Exp $"
+#ident "$Id: quotacheck.c,v 1.29 2002/05/03 07:05:46 jkar8572 Exp $"
#include <dirent.h>
#include <stdio.h>
@@ -853,9 +853,9 @@ static void check_all(void)
struct mntent *mnt;
int checked = 0;
- if (init_mounts_scan((flags & FL_ALL) ? 0 : 1, &mntpoint) < 0)
+ if (init_mounts_scan((flags & FL_ALL) ? 0 : 1, &mntpoint, 0) < 0)
die(2, _("Can't initialize mountpoint scan.\n"));
- while ((mnt = get_next_mount(0))) {
+ while ((mnt = get_next_mount())) {
if (flags & FL_ALL && flags & FL_NOROOT && !strcmp(mnt->mnt_dir, "/"))
continue;
if (!strcmp(mnt->mnt_type, MNTTYPE_XFS) || !strcmp(mnt->mnt_type, MNTTYPE_NFS)) {
diff --git a/quotaio.c b/quotaio.c
index 93f7c60..c08406f 100644
--- a/quotaio.c
+++ b/quotaio.c
@@ -94,7 +94,8 @@ struct quota_handle *init_io(struct mntent *mnt, int type, int fmt, int flags)
fmt = kernfmt; /* Default is kernel used format */
}
}
- if ((fmt = get_qf_name(mnt, type, (fmt == -1) ? ((1 << QF_VFSOLD) | (1 << QF_VFSV0)) : (1 << fmt), NF_FORMAT, &qfname)) < 0) {
+ if ((fmt = get_qf_name(mnt, type, (fmt == -1) ? ((1 << QF_VFSOLD) | (1 << QF_VFSV0)) : (1 << fmt),
+ (!QIO_ENABLED(h) || flags & IOI_OPENFILE) ? NF_FORMAT : 0, &qfname)) < 0) {
errstr(_("Quota file not found or has wrong format.\n"));
goto out_handle;
}
diff --git a/quotaon.c b/quotaon.c
index 6aa9899..0012431 100644
--- a/quotaon.c
+++ b/quotaon.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quotaon.c,v 1.14 2002/03/27 16:21:26 jkar8572 Exp $"
+#ident "$Id: quotaon.c,v 1.15 2002/05/03 07:05:46 jkar8572 Exp $"
/*
* Turn quota on/off for a filesystem.
@@ -314,9 +314,9 @@ int main(int argc, char **argv)
if (fmt != -1 && !(kernel_formats & (1 << fmt)))
die(1, _("Required format %s not supported by kernel.\n"), fmt2name(fmt));
- if (init_mounts_scan(mntcnt, mntpoints) < 0)
+ if (init_mounts_scan(mntcnt, mntpoints, 0) < 0)
return 1;
- while ((mnt = get_next_mount(0))) {
+ while ((mnt = get_next_mount())) {
if (!strcmp(mnt->mnt_type, MNTTYPE_NFS)) {
if (!(flags & FL_ALL))
fprintf(stderr, "%s: Quota can't be turned on on NFS filesystem\n", mnt->mnt_fsname);
diff --git a/quotasys.c b/quotasys.c
index 8cf62f6..4123542 100644
--- a/quotasys.c
+++ b/quotasys.c
@@ -371,7 +371,7 @@ static int check_fmtfile_ok(char *name, int type, int fmt, int flags)
ret = quotafile_ops_1.check_file(fd, type);
close(fd);
}
- else if (errno != ENOENT)
+ else if (errno != ENOENT && errno != EPERM)
errstr(_("Can't open quotafile %s: %s\n"), name, strerror(errno));
return ret;
}
@@ -437,9 +437,9 @@ struct quota_handle **create_handle_list(int count, char **mntpoints, int type,
int gotmnt = 0;
static struct quota_handle *hlist[MAXMNTPOINTS];
- if (init_mounts_scan(count, mntpoints) < 0)
+ if (init_mounts_scan(count, mntpoints, 0) < 0)
die(2, _("Can't initialize mountpoint scan.\n"));
- while ((mnt = get_next_mount(0))) {
+ while ((mnt = get_next_mount())) {
if (strcmp(mnt->mnt_type, MNTTYPE_NFS)) { /* No NFS? */
if (gotmnt+1 == MAXMNTPOINTS)
die(2, _("Too many mountpoints with quota. Contact %s\n"), MY_EMAIL);
@@ -820,8 +820,21 @@ static int cache_mnt_table(void)
return 0;
}
+/* Find mountpoint of filesystem hosting dir in 'st'; Store it in 'st' */
+static char *find_dir_mntpoint(struct stat *st)
+{
+ int i;
+
+ for (i = 0; i < mnt_entries_cnt; i++)
+ if (mnt_entries[i].me_dev == st->st_dev) {
+ st->st_ino = mnt_entries[i].me_ino;
+ return mnt_entries[i].me_dir;
+ }
+ return NULL;
+}
+
/* Process and store given paths */
-static int process_dirs(int dcnt, char **dirs)
+static int process_dirs(int dcnt, char **dirs, int flags)
{
struct stat st;
int i;
@@ -838,10 +851,17 @@ static int process_dirs(int dcnt, char **dirs)
}
check_dirs[check_dirs_cnt].sd_dir = S_ISDIR(st.st_mode);
if (S_ISDIR(st.st_mode)) {
+ char *realmnt = dirs[i];
+
+ /* Return st of mountpoint of dir in st.. */
+ if (flags & MS_NO_MNTPOINT && !(realmnt = find_dir_mntpoint(&st))) {
+ errstr(_("Can't find filesystem mountpoint for directory %s\n"), dirs[i]);
+ continue;
+ }
check_dirs[check_dirs_cnt].sd_dev = st.st_dev;
check_dirs[check_dirs_cnt].sd_ino = st.st_ino;
- if (!realpath(dirs[i], mntpointbuf)) {
- errstr(_("Can't resolve path %s: %s\n"), dirs[i], strerror(errno));
+ if (!realpath(realmnt, mntpointbuf)) {
+ errstr(_("Can't resolve path %s: %s\n"), realmnt, strerror(errno));
continue;
}
}
@@ -875,11 +895,11 @@ static int process_dirs(int dcnt, char **dirs)
/*
* Initialize mountpoint scan
*/
-int init_mounts_scan(int dcnt, char **dirs)
+int init_mounts_scan(int dcnt, char **dirs, int flags)
{
if (cache_mnt_table() < 0)
return -1;
- if (process_dirs(dcnt, dirs) < 0) {
+ if (process_dirs(dcnt, dirs, flags) < 0) {
end_mounts_scan();
return -1;
}
@@ -906,7 +926,7 @@ static int find_next_entry_all(int *pos)
}
/* Find next usable mountpoint when scanning selected mountpoints */
-static int find_next_entry_sel(int *pos, int flags)
+static int find_next_entry_sel(int *pos)
{
int i;
struct searched_dir *sd;
@@ -917,8 +937,7 @@ restart:
sd = check_dirs + act_checked;
for (i = 0; i < mnt_entries_cnt; i++) {
if (sd->sd_dir) {
- if (sd->sd_dev == mnt_entries[i].me_dev &&
- (flags & MS_NO_MNTPOINT || sd->sd_ino == mnt_entries[i].me_ino))
+ if (sd->sd_dev == mnt_entries[i].me_dev && sd->sd_ino == mnt_entries[i].me_ino)
break;
}
else
@@ -936,7 +955,7 @@ restart:
/*
* Return next directory from the list
*/
-struct mntent *get_next_mount(int flags)
+struct mntent *get_next_mount(void)
{
static struct mntent mnt;
int mntpos;
@@ -947,7 +966,7 @@ struct mntent *get_next_mount(int flags)
mnt.mnt_dir = (char *)mnt_entries[mntpos].me_dir;
}
else {
- if (!find_next_entry_sel(&mntpos, flags))
+ if (!find_next_entry_sel(&mntpos))
return NULL;
mnt.mnt_dir = (char *)check_dirs[act_checked].sd_name;
}
diff --git a/quotasys.h b/quotasys.h
index db85490..8e95c13 100644
--- a/quotasys.h
+++ b/quotasys.h
@@ -113,13 +113,13 @@ void init_kernel_interface(void);
/* Check whether is quota turned on on given device for given type */
int kern_quota_on(const char *dev, int type, int fmt);
+/* Flags for init_mounts_scan() */
+#define MS_NO_MNTPOINT 0x01 /* Specified directory needn't be mountpoint */
/* Initialize mountpoints scan */
-int init_mounts_scan(int dcnt, char **dirs);
+int init_mounts_scan(int dcnt, char **dirs, int flags);
-/* Flags for get_next_mount() */
-#define MS_NO_MNTPOINT 0x01 /* Specified directory needn't be mountpoint */
/* Return next mountpoint for scan */
-struct mntent *get_next_mount(int flags);
+struct mntent *get_next_mount(void);
/* Free all structures associated with mountpoints scan */
void end_mounts_scan(void);
diff --git a/rquota_server.c b/rquota_server.c
index 59c54f9..c8430a1 100644
--- a/rquota_server.c
+++ b/rquota_server.c
@@ -9,7 +9,7 @@
*
* This part does the lookup of the info.
*
- * Version: $Id: rquota_server.c,v 1.10 2001/11/26 18:18:25 jkar8572 Exp $
+ * Version: $Id: rquota_server.c,v 1.11 2002/05/03 07:05:46 jkar8572 Exp $
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
@@ -158,9 +158,9 @@ setquota_rslt *setquotainfo(int flags, caddr_t * argp, struct svc_req *rqstp)
result.status = Q_NOQUOTA;
result.setquota_rslt_u.sqr_rquota.rq_bsize = RPC_DQBLK_SIZE;
- if (init_mounts_scan(1, &pathname) < 0)
+ if (init_mounts_scan(1, &pathname, MS_NO_MNTPOINT) < 0)
goto out;
- if (!(mnt = get_next_mount(MS_NO_MNTPOINT))) {
+ if (!(mnt = get_next_mount())) {
end_mounts_scan();
goto out;
}
@@ -242,9 +242,9 @@ getquota_rslt *getquotainfo(int flags, caddr_t * argp, struct svc_req * rqstp)
result.status = Q_NOQUOTA;
result.getquota_rslt_u.gqr_rquota.rq_bsize = RPC_DQBLK_SIZE;
- if (init_mounts_scan(1, &pathname) < 0)
+ if (init_mounts_scan(1, &pathname, MS_NO_MNTPOINT) < 0)
goto out;
- if (!(mnt = get_next_mount(MS_NO_MNTPOINT))) {
+ if (!(mnt = get_next_mount())) {
end_mounts_scan();
goto out;
}