summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2007-08-23 19:58:14 +0000
committerjkar8572 <jkar8572>2007-08-23 19:58:14 +0000
commitb5f4715038ac5236a31e396208d33a5e600f9f4c (patch)
tree45bd7fca50d54646a91a3762c5f27a40c05d5d24
parent690f9c08922da8d625732259c5db5f67a17ed4e0 (diff)
Added options to enable pathname mangling for NFSv4 (Jan Kara)
-rw-r--r--edquota.c18
-rw-r--r--quota.c24
-rw-r--r--quotaio.c2
-rw-r--r--quotaio.h2
-rw-r--r--quotasys.h1
-rw-r--r--rquota_client.c8
-rw-r--r--rquota_server.c11
-rw-r--r--rquota_svc.c39
-rw-r--r--rquotad.818
-rw-r--r--setquota.c20
10 files changed, 103 insertions, 40 deletions
diff --git a/edquota.c b/edquota.c
index 125ebe7..cebdb62 100644
--- a/edquota.c
+++ b/edquota.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: edquota.c,v 1.20 2006/10/30 15:26:20 jkar8572 Exp $"
+#ident "$Id: edquota.c,v 1.21 2007/08/23 19:58:14 jkar8572 Exp $"
/*
* Disk quota editor.
@@ -64,6 +64,7 @@
#define FL_EDIT_TIMES 2
#define FL_REMOTE 4
#define FL_NUMNAMES 8
+#define FL_MIXED_PATHS 16
char *progname;
@@ -75,7 +76,7 @@ char *dirname;
void usage(void)
{
#if defined(RPC_SETQUOTA)
- char *rpcflag = "[-r] ";
+ char *rpcflag = "[-rm] ";
#else
char *rpcflag = "";
#endif
@@ -87,7 +88,8 @@ void usage(void)
-u, --user edit user data\n\
-g, --group edit group data\n"), stderr);
#if defined(RPC_SETQUOTA)
- fputs(_("-r, --remote edit remote quota (via RPC)\n"), stderr);
+ fputs(_("-r, --remote edit remote quota (via RPC)\n\
+-m, --mixed-pathnames trim leading slashes from NFSv4 mountpoints\n"), stderr);
#endif
fputs(_("-F, --format=formatname edit quotas of a specific format\n\
-p, --prototype=name copy data from a prototype user/group\n\
@@ -115,6 +117,7 @@ int parse_options(int argc, char **argv)
{ "filesystem", 1, NULL, 'f' },
#if defined(RPC_SETQUOTA)
{ "remote", 0, NULL, 'r' },
+ { "mixed-pathnames", 0, NULL, 'm' },
#endif
{ "always-resolve", 0, NULL, 256 },
{ "edit-period", 0, NULL, 't' },
@@ -127,7 +130,7 @@ int parse_options(int argc, char **argv)
quotatype = USRQUOTA;
#if defined(RPC_SETQUOTA)
- while ((ret = getopt_long(argc, argv, "ugrntTVp:F:f:", long_opts, NULL)) != -1) {
+ while ((ret = getopt_long(argc, argv, "ugrmntTVp:F:f:", long_opts, NULL)) != -1) {
#else
while ((ret = getopt_long(argc, argv, "ugtTVp:F:f:", long_opts, NULL)) != -1) {
#endif
@@ -143,6 +146,9 @@ int parse_options(int argc, char **argv)
case 'r':
flags |= FL_REMOTE;
break;
+ case 'm':
+ flags |= FL_MIXED_PATHS;
+ break;
#endif
case 'u':
quotatype = USRQUOTA;
@@ -233,7 +239,9 @@ int main(int argc, char **argv)
argv += ret;
init_kernel_interface();
- handles = create_handle_list(dirname ? 1 : 0, dirname ? &dirname : NULL, quotatype, fmt, 0, (flags & FL_REMOTE) ? 0 : MS_LOCALONLY);
+ handles = create_handle_list(dirname ? 1 : 0, dirname ? &dirname : NULL, quotatype, fmt,
+ (flags & FL_MIXED_PATHS) ? IOI_NFS_MIXED_PATHS : 0,
+ (flags & FL_REMOTE) ? 0 : MS_LOCALONLY);
if (!handles[0]) {
dispose_handle_list(handles);
fputs(_("No filesystems with quota detected.\n"), stderr);
diff --git a/quota.c b/quota.c
index 1dc397a..f48c194 100644
--- a/quota.c
+++ b/quota.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quota.c,v 1.24 2007/06/20 16:22:23 jkar8572 Exp $"
+#ident "$Id: quota.c,v 1.25 2007/08/23 19:58:14 jkar8572 Exp $"
/*
* Disk quota reporting program.
@@ -74,6 +74,7 @@
#define FL_NUMNAMES 1024
#define FL_NFSALL 2048
#define FL_RAWGRACE 4096
+#define FL_MIXED_PATHS 8192
int flags, fmt = -1;
char *progname;
@@ -81,10 +82,10 @@ char *progname;
void usage(void)
{
errstr( "%s%s%s%s%s",
- _("Usage: quota [-guqvsw] [-l | [-Q | -A]] [-i] [-F quotaformat]\n"),
- _("\tquota [-qvsw] [-l | [-Q | -A]] [-i] [-F quotaformat] -u username ...\n"),
- _("\tquota [-qvsw] [-l | [-Q | -A]] [-i] [-F quotaformat] -g groupname ...\n"),
- _("\tquota [-qvswugQ] [-F quotaformat] -f filesystem ...\n"),
+ _("Usage: quota [-guqvswim] [-l | [-Q | -A]] [-F quotaformat]\n"),
+ _("\tquota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -u username ...\n"),
+ _("\tquota [-qvswim] [-l | [-Q | -A]] [-F quotaformat] -g groupname ...\n"),
+ _("\tquota [-qvswugQm] [-F quotaformat] -f filesystem ...\n"),
_("\n\
-u, --user display quota for user\n\
-g, --group display quota for group\n\
@@ -102,6 +103,7 @@ void usage(void)
-F, --format=formatname display quota of a specific format\n\
-f, --filesystem-list display quota information only for given filesystems\n\
-A, --nfs-all display quota for all NFS mountpoints\n\
+-m, --mixed-pathnames trim leading slashes from NFSv4 mountpoints\n\
-h, --help display this help message and exit\n\
-V, --version display version information and exit\n\n"));
fprintf(stderr, _("Bugs to: %s\n"), MY_EMAIL);
@@ -131,7 +133,11 @@ int showquotas(int type, qid_t id, int mntcnt, char **mnt)
time(&now);
id2name(id, type, name);
- handles = create_handle_list(mntcnt, mnt, type, fmt, IOI_READONLY, ((flags & FL_NOAUTOFS) ? MS_NO_AUTOFS : 0) | ((flags & FL_LOCALONLY) ? MS_LOCALONLY : 0) | ((flags & FL_NFSALL) ? MS_NFS_ALL : 0));
+ handles = create_handle_list(mntcnt, mnt, type, fmt,
+ IOI_READONLY | ((flags & FL_MIXED_PATHS) ? IOI_NFS_MIXED_PATHS : 0),
+ ((flags & FL_NOAUTOFS) ? MS_NO_AUTOFS : 0)
+ | ((flags & FL_LOCALONLY) ? MS_LOCALONLY : 0)
+ | ((flags & FL_NFSALL) ? MS_NFS_ALL : 0));
qlist = getprivs(id, handles, !!(flags & FL_QUIETREFUSE));
over = 0;
for (q = qlist; q; q = q->dq_next) {
@@ -257,13 +263,14 @@ int main(int argc, char **argv)
{ "no-wrap", 0, NULL, 'w' },
{ "filesystem-list", 0, NULL, 'f' },
{ "all-nfs", 0, NULL, 'A' },
+ { "mixed-pathnames", 0, NULL, 'm' },
{ NULL, 0, NULL, 0 }
};
gettexton();
progname = basename(argv[0]);
- while ((ret = getopt_long(argc, argv, "guqvsVliQF:wfAp", long_opts, NULL)) != -1) {
+ while ((ret = getopt_long(argc, argv, "guqvsVliQF:wfApm", long_opts, NULL)) != -1) {
switch (ret) {
case 'g':
flags |= FL_GROUP;
@@ -308,6 +315,9 @@ int main(int argc, char **argv)
case 'A':
flags |= FL_NFSALL;
break;
+ case 'm':
+ flags |= FL_MIXED_PATHS;
+ break;
case 'V':
version();
exit(0);
diff --git a/quotaio.c b/quotaio.c
index 65c108c..5be8a25 100644
--- a/quotaio.c
+++ b/quotaio.c
@@ -51,6 +51,8 @@ struct quota_handle *init_io(struct mntent *mnt, int type, int fmt, int flags)
h->qh_io_flags = 0;
if (flags & IOI_READONLY)
h->qh_io_flags |= IOFL_RO;
+ if (flags & IOI_NFS_MIXED_PATHS)
+ h->qh_io_flags |= IOFL_NFS_MIXED_PATHS;
h->qh_type = type;
sstrncpy(h->qh_quotadev, mnt_fsname, sizeof(h->qh_quotadev));
free((char *)mnt_fsname);
diff --git a/quotaio.h b/quotaio.h
index 0ab9c24..c3f633d 100644
--- a/quotaio.h
+++ b/quotaio.h
@@ -66,6 +66,8 @@
#define IOFL_QUOTAON 0x01 /* Is quota enabled in kernel? */
#define IOFL_INFODIRTY 0x02 /* Did info change? */
#define IOFL_RO 0x04 /* Just RO access? */
+#define IOFL_NFS_MIXED_PATHS 0x08 /* Should we trim leading slashes
+ from NFSv4 mountpoints? */
struct quotafile_ops;
diff --git a/quotasys.h b/quotasys.h
index 642eed3..54bcb8d 100644
--- a/quotasys.h
+++ b/quotasys.h
@@ -21,6 +21,7 @@
/* Flags for IO initialization */
#define IOI_READONLY 0x1 /* Only readonly access */
#define IOI_OPENFILE 0x2 /* Open file even if kernel has quotas turned on */
+#define IOI_NFS_MIXED_PATHS 0x4 /* Trim leading / from NFSv4 mountpoints */
#define KERN_KNOWN_QUOTA_VERSION (6*10000 + 5*100 + 1)
diff --git a/rquota_client.c b/rquota_client.c
index f6926f2..883df40 100644
--- a/rquota_client.c
+++ b/rquota_client.c
@@ -9,7 +9,7 @@
*
* This part does the rpc-communication with the rquotad.
*
- * Version: $Id: rquota_client.c,v 1.10 2007/08/23 18:55:28 jkar8572 Exp $
+ * Version: $Id: rquota_client.c,v 1.11 2007/08/23 19:58:14 jkar8572 Exp $
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
@@ -157,7 +157,8 @@ int rpc_rquota_get(struct dquot *dquot)
*pathname++ = '\0';
/* For NFSv4, we send the filesystem path without initial /. Server prepends proper
* NFS pseudoroot automatically and uses this for detection of NFSv4 mounts. */
- if (!strcmp(dquot->dq_h->qh_fstype, MNTTYPE_NFS4)) {
+ if ((dquot->dq_h->qh_io_flags & IOFL_NFS_MIXED_PATHS) &&
+ !strcmp(dquot->dq_h->qh_fstype, MNTTYPE_NFS4)) {
while (*pathname == '/')
pathname++;
}
@@ -273,7 +274,8 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
*pathname++ = '\0';
/* For NFSv4, we send the filesystem path without initial /. Server prepends proper
* NFS pseudoroot automatically and uses this for detection of NFSv4 mounts. */
- if (!strcmp(dquot->dq_h->qh_fstype, MNTTYPE_NFS4)) {
+ if ((dquot->dq_h->qh_io_flags & IOFL_NFS_MIXED_PATHS) &&
+ !strcmp(dquot->dq_h->qh_fstype, MNTTYPE_NFS4)) {
while (*pathname == '/')
pathname++;
}
diff --git a/rquota_server.c b/rquota_server.c
index e734ef5..8494336 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.17 2007/08/23 18:55:28 jkar8572 Exp $
+ * Version: $Id: rquota_server.c,v 1.18 2007/08/23 19:58:14 jkar8572 Exp $
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
@@ -49,6 +49,7 @@
/* Options from rquota_svc.c */
#define FL_AUTOFS 4
+#define FL_MIXED_PATHS 8
extern int flags;
extern char nfs_pseudoroot[PATH_MAX];
@@ -142,7 +143,7 @@ setquota_rslt *setquotainfo(int lflags, caddr_t * argp, struct svc_req *rqstp)
qcmd = arguments.ext_args->sqa_qcmd;
type = arguments.ext_args->sqa_type;
- if (arguments.ext_args->sqa_pathp[0] != '/')
+ if (!(flags & FL_MIXED_PATHS) || arguments.ext_args->sqa_pathp[0] != '/')
sstrncpy(pathname, nfs_pseudoroot, PATH_MAX);
sstrncat(pathname, arguments.ext_args->sqa_pathp, PATH_MAX);
servnet2utildqblk(&dqblk, &arguments.ext_args->sqa_dqblk);
@@ -158,7 +159,7 @@ setquota_rslt *setquotainfo(int lflags, caddr_t * argp, struct svc_req *rqstp)
qcmd = arguments.args->sqa_qcmd;
type = USRQUOTA;
- if (arguments.args->sqa_pathp[0] != '/')
+ if (!(flags & FL_MIXED_PATHS) || arguments.args->sqa_pathp[0] != '/')
sstrncpy(pathname, nfs_pseudoroot, PATH_MAX);
sstrncat(pathname, arguments.args->sqa_pathp, PATH_MAX);
servnet2utildqblk(&dqblk, &arguments.args->sqa_dqblk);
@@ -227,7 +228,7 @@ getquota_rslt *getquotainfo(int lflags, caddr_t * argp, struct svc_req * rqstp)
arguments.ext_args = (ext_getquota_args *) argp;
id = arguments.ext_args->gqa_id;
type = arguments.ext_args->gqa_type;
- if (arguments.ext_args->gqa_pathp[0] != '/')
+ if (!(flags & FL_MIXED_PATHS) || arguments.ext_args->gqa_pathp[0] != '/')
sstrncpy(pathname, nfs_pseudoroot, PATH_MAX);
sstrncat(pathname, arguments.ext_args->gqa_pathp, PATH_MAX);
@@ -246,7 +247,7 @@ getquota_rslt *getquotainfo(int lflags, caddr_t * argp, struct svc_req * rqstp)
arguments.args = (getquota_args *) argp;
id = arguments.args->gqa_uid;
type = USRQUOTA;
- if (arguments.ext_args->gqa_pathp[0] != '/')
+ if (!(flags & FL_MIXED_PATHS) || arguments.ext_args->gqa_pathp[0] != '/')
sstrncpy(pathname, nfs_pseudoroot, PATH_MAX);
sstrncat(pathname, arguments.args->gqa_pathp, PATH_MAX);
diff --git a/rquota_svc.c b/rquota_svc.c
index 5872464..1d0b326 100644
--- a/rquota_svc.c
+++ b/rquota_svc.c
@@ -12,7 +12,7 @@
* changes for new utilities by Jan Kara <jack@suse.cz>
* patches by Jani Jaakkola <jjaakkol@cs.helsinki.fi>
*
- * Version: $Id: rquota_svc.c,v 1.18 2007/08/22 13:03:24 jkar8572 Exp $
+ * Version: $Id: rquota_svc.c,v 1.19 2007/08/23 19:58:14 jkar8572 Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -62,6 +62,7 @@ struct authunix_parms *unix_cred;
#define FL_SETQUOTA 1 /* Enable setquota rpc */
#define FL_NODAEMON 2 /* Disable daemon() call */
#define FL_AUTOFS 4 /* Don't ignore autofs mountpoints */
+#define FL_MIXED_PATHS 8 /* Prepend NFS pseudoroot only to relative paths */
int flags; /* Options specified on command line */
static int port; /* Port to use (0 for default one) */
@@ -79,6 +80,7 @@ static struct option options[]= {
{ "autofs", 0, NULL, 'I'},
{ "port", 1, NULL, 'p' },
{ "xtab", 1, NULL, 'x' },
+ { "mixed-pathnames", 0, NULL, 'm'},
{ NULL, 0, NULL , 0 }
};
@@ -86,23 +88,27 @@ static void show_help(void)
{
#ifdef RPC_SETQUOTA
errstr(_("Usage: %s [options]\nOptions are:\n\
- -h --help shows this text\n\
- -V --version shows version information\n\
- -F --foreground starts the quota service in foreground\n\
- -I --autofs do not ignore mountpoints mounted by automounter\n\
- -p --port <port> listen on given port\n\
- -s --no-setquota disables remote calls to setquota (default)\n\
- -S --setquota enables remote calls to setquota\n\
- -x --xtab <path> set an alternative file with NFSD export table\n"), progname);
+ -h --help shows this text\n\
+ -V --version shows version information\n\
+ -F --foreground starts the quota service in foreground\n\
+ -I --autofs do not ignore mountpoints mounted by automounter\n\
+ -p --port <port> listen on given port\n\
+ -s --no-setquota disables remote calls to setquota (default)\n\
+ -S --setquota enables remote calls to setquota\n\
+ -x --xtab <path> set an alternative file with NFSD export table\n\
+ -m --mixed-pathnames prepend by NFS pseudoroot only pathnames without\n\
+ leading slash\n"), progname);
#else
errstr(_("Usage: %s [options]\nOptions are:\n\
- -h --help shows this text\n\
- -V --version shows version information\n\
- -F --foreground starts the quota service in foreground\n\
- -I --autofs do not ignore mountpoints mounted by automounter\n\
- -p --port <port> listen on given port\n\
- -x --xtab <path> set an alternative file with NFSD export table\n"), progname);
+ -h --help shows this text\n\
+ -V --version shows version information\n\
+ -F --foreground starts the quota service in foreground\n\
+ -I --autofs do not ignore mountpoints mounted by automounter\n\
+ -p --port <port> listen on given port\n\
+ -x --xtab <path> set an alternative file with NFSD export table\n\
+ -m --mixed-pathnames prepend by NFS pseudoroot only pathnames without\n\
+ leading slash\n"), progname);
#endif
}
@@ -156,6 +162,9 @@ static void parse_options(int argc, char **argv)
}
sstrncpy(xtab_path, optarg, PATH_MAX);
break;
+ case 'm':
+ flags |= FL_MIXED_PATHS;
+ break;
default:
errstr(_("Unknown option '%c'.\n"), opt);
show_help();
diff --git a/rquotad.8 b/rquotad.8
index 65b756a..787ccf6 100644
--- a/rquotad.8
+++ b/rquotad.8
@@ -68,6 +68,24 @@ Do not ignore autofs mountpoints.
.B \-p \f2port\f3, \-\-port \f2port\f1
Listen on alternate port
.IR port.
+.TP
+.B \-x \f2path\f3, \-\-xtab \f2path\f1
+Set an alternative file with NFSD export table. This file is used to
+determine pseudoroot of NFSv4 exports. The pseudoroot is then prepended
+to a path received in each quota RPC request. This may cause some
+troubles in environments with both NFSv3 and NFSv4 clients. In such cases
+consider
+.I mixed-pathnames
+option.
+.TP
+.B \-m, \-\-mixed-pathnames
+Prepend pseudoroot of NFSv4 exports only to pathnames which do not begin
+with a slash. This option is useful in environments with both NFSv3 and
+NFSv4 clients together with the same option of tools such as
+.BR quota (1).
+If you pass an option
+.I mixed-pathnames
+to these tools, they trim leading slashes from NFSv4 mounts in RPC requests.
.SH FILES
.PD 0
diff --git a/setquota.c b/setquota.c
index 7aad2e1..fce066a 100644
--- a/setquota.c
+++ b/setquota.c
@@ -30,6 +30,7 @@
#define FL_INDIVIDUAL_GRACE 64
#define FL_BATCH 128
#define FL_NUMNAMES 256
+#define FL_MIXED_PATHS 512
int flags, fmt = -1;
char **mnt;
@@ -42,7 +43,7 @@ struct util_dqblk toset;
static void usage(void)
{
#if defined(RPC_SETQUOTA)
- char *ropt = "[-r] ";
+ char *ropt = "[-rm] ";
#else
char *ropt = "";
#endif
@@ -62,7 +63,8 @@ static void usage(void)
-p, --prototype=protoname copy limits from user/group\n\
-b, --batch read limits from standard input\n"), ropt);
#if defined(RPC_SETQUOTA)
- fputs(_("-r, --remote set remote quota (via RPC)\n"), stderr);
+ fputs(_("-r, --remote set remote quota (via RPC)\n\
+-m, --mixed-pathnames trim leading slashes from NFSv4 mountpoints\n"), stderr);
#endif
fputs(_("-t, --edit-period edit grace period\n\
-T, --edit-times edit grace times for user/group\n\
@@ -102,7 +104,7 @@ static void parse_options(int argcnt, char **argstr)
char *protoname = NULL;
#ifdef RPC_SETQUOTA
- char *opts = "gp:urVF:taTb";
+ char *opts = "gp:urmVF:taTb";
#else
char *opts = "gp:uVF:taTb";
#endif
@@ -112,6 +114,7 @@ static void parse_options(int argcnt, char **argstr)
{ "prototype", 1, NULL, 'p' },
#ifdef RPC_SETQUOTA
{ "remote", 0, NULL, 'r' },
+ { "mixed-pathnames", 0, NULL, 'm' },
#endif
{ "all", 0, NULL, 'a' },
{ "always-resolve", 0, NULL, 256},
@@ -142,6 +145,9 @@ static void parse_options(int argcnt, char **argstr)
case 'r':
flags |= FL_RPC;
break;
+ case 'm':
+ flags |= FL_MIXED_PATHS;
+ break;
case 'a':
flags |= FL_ALL;
break;
@@ -375,9 +381,13 @@ int main(int argc, char **argv)
init_kernel_interface();
if (flags & FL_ALL)
- handles = create_handle_list(0, NULL, flag2type(flags), fmt, 0, (flags & FL_RPC) ? 0 : MS_LOCALONLY);
+ handles = create_handle_list(0, NULL, flag2type(flags), fmt,
+ (flags & FL_MIXED_PATHS) ? IOI_NFS_MIXED_PATHS : 0,
+ (flags & FL_RPC) ? 0 : MS_LOCALONLY);
else
- handles = create_handle_list(mntcnt, mnt, flag2type(flags), fmt, 0, (flags & FL_RPC) ? 0 : MS_LOCALONLY);
+ handles = create_handle_list(mntcnt, mnt, flag2type(flags), fmt,
+ (flags & FL_MIXED_PATHS) ? IOI_NFS_MIXED_PATHS : 0,
+ (flags & FL_RPC) ? 0 : MS_LOCALONLY);
if (flags & FL_GRACE)
ret = setgraces(handles);