The function translate_opts() in cddl/compat/opensolaris/misc/fsshare.c incorrectly transforms nfs export options. Specifically, it unconditionally separates the input string along hyphens, thereby making it impossible to have a hyphen in a host name (which is allowed, cf. http://tools.ietf.org/html/rfc952 and http://tools.ietf.org/html/rfc1123). I am not sure whether this parsing is needed at all, as the resultant string, which is parsed by mountd(8), in its unaltered form seems to be compatible with the syntax expected by the latter. In fact, one could simply require that the string used for the sharenfs option is mountd(8) compatible and do away with the translate_opts() function entirely. In a related vein, it is absolutely necessary to be able to specify multiple export lines for a single mount point, thereby allowing to assign different permissions to different clients. This has already been proposed a long while ago in http://www.freebsd.org/cgi/query-pr.cgi?pr=147881 but never been implemented. May I use that PR to suggest that this feature be added at the same time as fixing the bug described here. Fix: Correct translate_opts() in cddl/compat/opensolaris/misc/fsshare.c (or get rid of it altogether). As a workaround, I am currently using IP addresses in lieu of the affectd host names. I need to use both IPv4 and IPv6 addresses of the same host, as my network runs both IPv4 and IPv6. How-To-Repeat: Try to execute zfs set sharenfs=test-host <zfs volume> and then do a zfs list -o name,sharenfs <zfs colume>
Responsible Changed From-To: freebsd-bugs->freebsd-fs Over to maintainer(s).
Hi, I just run into this exact bug with: FreeBSD 10.0-RELEASE-p12 FreeBSD 10.0-RELEASE-p12 What is the current status on this, is the "sharenfs" property overall simply not recommended nor used in production? (I also found this bug on the tracker: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=147881) I have read people recommending to just use /etc/exports instead, but most posts a quite old so I'm not sure what's recommended today. Regards, Robert
Created attachment 158168 [details] Patch to support hyphenated host names in sharenfs zfs property. Simple patch that only ignores leading hyphens in options. With this change: '-ro,a-server -alldirs' -> '-ro a-server -alldirs' instead of (current behavior): '-ro,a-server -alldirs' -> '-ro a server -alldirs' Changed by removing '-' from strsep() call, and handling (skipping) hyphen if first character immediately after strsep() call. All test cases listed immediately prior to the code still work; I'm not aware of any supported forms that are broken by this change.
FreeBSD 11.0-STABLE, and still the same. Will the patch by eborisch be included? If I want to include it, do I have to rebuild the whole kernel, or is it enough to rebuild zfs.ko?
Now that this probably starts moving again, may I humbly suggest to use my patch instead for the reasons cited in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=176449#c7 -- Martin
batch change: For bugs that match the following - Status Is In progress AND - Untouched since 2018-01-01. AND - Affects Base System OR Documentation DO: Reset to open status. Note: I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.
I just ran across this problem (not able to set hostnames with hyphen/dash using zfs set sharenfs=...) with a recent FreeBSD 14.1. Is there are chance that this will be fixed?
Created attachment 252620 [details] fix ZFS sharenfs for DNS names with '-' in them Here is the same patch at Martin's, but for current sources. I will try and get it pulled into OpenZFS. (I'm doing this now, but for future reference, anyone can do a OpenZFS pull request. All you need is a github login.)
I have made the pull request for the patch on OpenZFS. I have no idea if/when it will happen.
Just fyi, the patch has now been pulled into OpenZFS. It should end up in FreeBSD's main, etc when the next cycle of downstream pulls occur.
Rick, thank you for your efforts. Good things take time! :-) -- Martin
The patch has now been pulled down into FreeBSD's main. I'll close this patch once it is MFC'd.