Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2011 00:34:18 +0200
From:      Adrian Penisoara <ady@freebsd.ady.ro>
To:        freebsd-fs@freebsd.org
Cc:        Pawel Jakub Dawidek <pjd@freebsd.org>
Subject:   Re: ZFS sharenfs mangling NFS options
Message-ID:  <BANLkTinDc3561h4RZ36H6M9C5Z0iawsBAg@mail.gmail.com>
In-Reply-To: <BANLkTimw9kJbgoRTb6_HsxgMKAeii8t8_g@mail.gmail.com>
References:  <BANLkTimw9kJbgoRTb6_HsxgMKAeii8t8_g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Thu, Jun 16, 2011 at 11:47 PM, Adrian Penisoara <ady@freebsd.ady.ro> wrote:
> Hi,
>
>  I was nicely surprised to see that the "sharenfs" option for a ZFS
> dataset does the expected trick and automatically shares on NFS the
> dataset via /etc/zfs/exports. However, I had some not so pleasant
> experiences customizing the NFS sharing parameters -- e.g. when the
> contents of the "sharenfs" property was automatically translated into
> [/etc/zfs/]exports entries:
>   * whatever hostname contains a "-" (dash) it gets malformed by
> being split over the dash character
>   * whatever NFS parameter is prefixed with a "-" (dash) and it's not
> the first in the list it gets transformed into a hostname entry
>
>  After some hunting into the CDDL sources I have been able to
> pinpoint the exact (library) code doing the translation as function
> translate_opts() in src/cddl/compat/opensolaris/misc/fsshare.c :
>
>        while ((o = strsep(&s, "-, ")) != NULL) {
>                if (o[0] == '\0')
>                        continue;
>                for (i = 0; known_opts[i] != NULL; i++) {
>                        len = strlen(known_opts[i]);
>                        if (strncmp(known_opts[i], o, len) == 0 &&
>                            (o[len] == '\0' || o[len] == '=')) {
>                                strlcat(newopts, "-", sizeof(newopts));
>                                break;
>                        }
>                }
>                strlcat(newopts, o, sizeof(newopts));
>                strlcat(newopts, " ", sizeof(newopts));
>        }
>
>  If I'm able to read C correctly, then it looks like the code above
> fails to take into consideration the case of hostnames containing
> dashes and the case of options prefixed with dashes (although it is
> advertised as valid format in the comments).

To be more clear, here is a sample sharenfs property entry:
"-maproot=0 -alldirs clienf-nfs1"
This gets transformed to something like "-maproot=0 alldirs client nfs1" ...

Regards,
Adrian Penisoara <ady (at) freebsd.ady.ro>
EntepriseBSD.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTinDc3561h4RZ36H6M9C5Z0iawsBAg>