2007-09-22 10:12:01

by Steinar H. Gunderson

[permalink] [raw]
Subject: Multiple ranges in squash_uids

Hi,

A user recently complained that you cannot use options like
"squash_uids=1000-1005,2000-3000", even though the manual page says it's
supported. The issue is that the option tokenizer thinks "2000-3000" is a
separate option, so although the uid range parser does handle multiple ranges
correctly, it doesn't work right.

The user also supplied a patch (see
http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=nfs-utils_parse_squashids_fix.diff;att=1;bug=442370),
but I'm not sure if it's the best way to do it. Any suggestions?

/* Steinar */
--
Homepage: http://www.sesse.net/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2007-09-24 07:21:49

by NeilBrown

[permalink] [raw]
Subject: Re: Multiple ranges in squash_uids

On Saturday September 22, [email protected] wrote:
> Hi,
>
> A user recently complained that you cannot use options like
> "squash_uids=1000-1005,2000-3000", even though the manual page says it's
> supported. The issue is that the option tokenizer thinks "2000-3000" is a
> separate option, so although the uid range parser does handle multiple ranges
> correctly, it doesn't work right.
>
> The user also supplied a patch (see
> http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=nfs-utils_parse_squashids_fix.diff;att=1;bug=442370),
> but I'm not sure if it's the best way to do it. Any suggestions?

Yes.... the suggested patch treats a comma followed by a digit
differently from a comma followed by a non-digit. I agree that is
ugly, though the code in parsesquash does exactly the same thing.

I would rather change the separator character to e.g. ':', like:

diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index c82bb0e..029a4d4 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -678,9 +678,6 @@ parsesquash(char *list, int **idp, int *lenp, char **ep)
int len = *lenp;
int *id = *idp;

- if (**ep)
- *--(*ep) = ',';
-
do {
id0 = parsenum(&cp);
if (*cp == '-') {
@@ -697,17 +694,15 @@ parsesquash(char *list, int **idp, int *lenp, char **ep)
id = (int *) xrealloc(id, (len + 8) * sizeof(*id));
id[len++] = id0;
id[len++] = id1;
- if (!*cp || *cp == ')' || (*cp == ',' && !isdigit(cp[1])))
+ if (cp >= *ep)
break;
- if (*cp != ',') {
+ if (*cp != ':') {
syntaxerr("bad uid/gid list");
return -1;
}
cp++;
} while(1);

- if (**ep == ',') (*ep)++;
-
*lenp = len;
*idp = id;
return 1;


(plus a patch to fix the manpage)..

except that this is all completely irrelevant to nfs-utils as we don't
support squash_uids or squash_gids, and never have done.
I wonder what manpage the customer was reading when they saw that:

The manpage shows "squash_uids=0-15,20,25-50" as a valid entry for the
/etc/exports file.

It appears in exports.man, but is commented out.

NeilBrownm

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs