From nobody Fri Dec 22 20:44:57 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SxfS92Zvnz54Sc2; Fri, 22 Dec 2023 20:44:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SxfS92496z4Pxw; Fri, 22 Dec 2023 20:44:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703277897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pHba0lHy1AVrpW6Oe4c6nAIvvL1OzOoONubu8ZOG57w=; b=Of+vXXq0RyfplObhMPdwermufpSSam85UT7fa40ZMqhzOSlnpV+ZbB1RZ61CQiL8io3zXV Y/9C/ajCrtuwMRK/b+AvinKD6Q0dJ5nN2NZ7rcxgGvBOFH2m+gXABbETH5XDbOvuYGDbNF Y1GLrysHBE+8+1WVYT4QxVx5fSh2F1Er1pQxhbQoNtg2scjvMqRxk7j59chrOKLE/e3zy3 s9PWIJYNxIYQY8wULpPK6qGlDQ5eASMx4vw7tcZCcpjY2qhEmX2Sp/XAcqsU4+fNdfXYg2 qOTmhkpuJ3SGOJJXk4gU/OyefYmmF1pz+ZYfLLENRithyM3M6BbtAewNeeovjQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703277897; a=rsa-sha256; cv=none; b=KWfOEdrb7/p9iLam5bPczNYnPL8Ehjc37CpVJTihateWuEPY4dHd+W70sNC0gYC9gdpLoM KyGLH0QMW2zQQdTOz/MwC2jhlSwf5ybkuEegDCGFw5IamzPGsmbIvpS2nWsytuIBwy4UkP 9KVvH0ODp8rhZpH5I0FE2eobTHs6kODp9sM2yhEXYAHzAGe99AC0pyxcb6jkUr8HhzpsuJ eIK+AYoB1alq2d84IDYiZgPPJ7X6lIofbq1cmSH1cp5+d0f1iwYKCJrwNweSCcJA7pHAby 708mH9bCF+v6/f1UvlrdfS0NaRJF9pxZYYossgohSeQBeC8QwBQnZ+YWWxUg2g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703277897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pHba0lHy1AVrpW6Oe4c6nAIvvL1OzOoONubu8ZOG57w=; b=HYV71wpm1hll4K+kcZhz3/FcjbL1dy2GxGucvDU1wCB262SvKSQ1zakjvEmozL5Te7zLRH LJw1VRkLkixe7s3DvY5eGZ3wNTpVXCr+AqZzNB89mx07M9ymqMBuP1d16ZjIpMlg2SjFE5 DtdyeYZufWPczdMoCcDE29+Nz4B8xjas4ksR++EkiFQPXAiXJNJiEwTjZLpJgh/f6o2I2c G344MEgaiKp1+sjBaI4uExLWj4sXRmcrWQG0KIoLGyYCvKJuLKvHC0DMI8ROn4TtWvJNwj 6Cbz4lCmASHivNZ2PNFsL5BsgYK6SpGrGfHEgBrhYNkypgDA3PvlaBFwDJZ7/w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SxfS9174FzXKp; Fri, 22 Dec 2023 20:44:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BMKivJv098207; Fri, 22 Dec 2023 20:44:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BMKiviA098204; Fri, 22 Dec 2023 20:44:57 GMT (envelope-from git) Date: Fri, 22 Dec 2023 20:44:57 GMT Message-Id: <202312222044.3BMKiviA098204@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: e615bcd32171 - stable/14 - mountd: Add support for spaces in exported directories List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: e615bcd32171378fc4204fea2ea2cf97ec238213 Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=e615bcd32171378fc4204fea2ea2cf97ec238213 commit e615bcd32171378fc4204fea2ea2cf97ec238213 Author: Dan Mcgregor AuthorDate: 2023-11-04 22:07:56 +0000 Commit: Rick Macklem CommitDate: 2023-12-22 20:42:15 +0000 mountd: Add support for spaces in exported directories The previous code would correctly parse strings including quotation marks (") or backslash (/), but the tests when creating the export includes them in the final string. This prevents exporting paths with embedded spaces, for example "/exports/with space". Trying results in log lines resembling: mountd[1337]: bad exports list line '/exports/with\ space': /exports/with\ space: lstat() failed: No such file or directory. Turns out that when creating its exports list, zfs escapes strings in a format compatible with vis(3). Since I expect that zfs sharenfs is the dominating use case for generating an exports list, use strunvis(3) to parse the export path. The result is lines like the following allowing spaces: /exports/with\040space -network 192.168.0 -mask 255.255.255.0 A man page update will be done as a separate commit. (cherry picked from commit 7c5146da128688ba2bb6bdad5e98716087a47281) --- usr.sbin/mountd/mountd.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 6602dbc09aa0..33c19a81a0cf 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -83,6 +83,7 @@ static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95"; #include #include #include +#include #include "pathnames.h" #include "mntopts.h" @@ -1561,10 +1562,13 @@ get_exportlist_one(int passno) char *err_msg = NULL; int len, has_host, got_nondir, dirplen, netgrp; uint64_t exflags; + char unvis_dir[PATH_MAX + 1]; + int unvis_len; v4root_phase = 0; anon.cr_groups = NULL; dirhead = (struct dirlist *)NULL; + unvis_dir[0] = '\0'; while (get_line()) { if (debug) warnx("got line %s", line); @@ -1631,17 +1635,25 @@ get_exportlist_one(int passno) } else if (*cp == '/') { savedc = *endcp; *endcp = '\0'; + unvis_len = strnunvis(unvis_dir, sizeof(unvis_dir), + cp); + if (unvis_len <= 0) { + getexp_err(ep, tgrp, "Cannot strunvis " + "decode dir"); + goto nextline; + } if (v4root_phase > 1) { if (dirp != NULL) { getexp_err(ep, tgrp, "Multiple V4 dirs"); goto nextline; } } - if (check_dirpath(cp, &err_msg) && - check_statfs(cp, &fsb, &err_msg)) { + if (check_dirpath(unvis_dir, &err_msg) && + check_statfs(unvis_dir, &fsb, &err_msg)) { if ((fsb.f_flags & MNT_AUTOMOUNTED) != 0) syslog(LOG_ERR, "Warning: exporting of " - "automounted fs %s not supported", cp); + "automounted fs %s not supported", + unvis_dir); if (got_nondir) { getexp_err(ep, tgrp, "dirs must be first"); goto nextline; @@ -1652,16 +1664,17 @@ get_exportlist_one(int passno) goto nextline; } if (strlen(v4root_dirpath) == 0) { - strlcpy(v4root_dirpath, cp, + strlcpy(v4root_dirpath, unvis_dir, sizeof (v4root_dirpath)); - } else if (strcmp(v4root_dirpath, cp) + } else if (strcmp(v4root_dirpath, unvis_dir) != 0) { syslog(LOG_ERR, - "different V4 dirpath %s", cp); + "different V4 dirpath %s", + unvis_dir); getexp_err(ep, tgrp, NULL); goto nextline; } - dirp = cp; + dirp = unvis_dir; v4root_phase = 2; got_nondir = 1; ep = get_exp(); @@ -1699,8 +1712,9 @@ get_exportlist_one(int passno) /* * Add dirpath to export mount point. */ - dirp = add_expdir(&dirhead, cp, len); - dirplen = len; + dirp = add_expdir(&dirhead, unvis_dir, + unvis_len); + dirplen = unvis_len; } } else { if (err_msg != NULL) {