From 2dc8529d9a6b390c4da7a2d6386b74f2f351fb2b Mon Sep 17 00:00:00 2001 From: rmacklem <64620010+rmacklem@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:56:26 -0700 Subject: [PATCH] Fix handling of DNS names with '-' in them for sharenfs An old FreeBSD bugzilla report PR#168158 notes that DNS names with '-'s in them cannot be used for the sharenfs property. This patch fixes the parsing of these DNS names. The only negative affect this patch might have is that, if a user has incorrectly separated options with a '-' the sharenfs setting will no longer work once this patch is applied. Reviewed by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Rick Macklem Closes #16529 --- lib/libshare/os/freebsd/nfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libshare/os/freebsd/nfs.c b/lib/libshare/os/freebsd/nfs.c index d9fc66106..dbfc86f2a 100644 --- a/lib/libshare/os/freebsd/nfs.c +++ b/lib/libshare/os/freebsd/nfs.c @@ -85,7 +85,9 @@ translate_opts(const char *shareopts, FILE *out) strlcpy(oldopts, shareopts, sizeof (oldopts)); newopts[0] = '\0'; s = oldopts; - while ((o = strsep(&s, "-, ")) != NULL) { + while ((o = strsep(&s, ", ")) != NULL) { + if (o[0] == '-') + o++; if (o[0] == '\0') continue; for (i = 0; i < ARRAY_SIZE(known_opts); ++i) {