From nobody Fri Sep 27 22:15:19 2024 X-Original-To: dev-commits-src-all@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 4XFlCC3CZ5z5XKCK; Fri, 27 Sep 2024 22:15:19 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XFlCC27Vbz4kPx; Fri, 27 Sep 2024 22:15:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727475319; 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=lIjx3FQBj3/YLwX7RWO0/3yvljvCZXOyAiFYkqScNxY=; b=ZUnXMdgnDisXDY0ZQQe0+qpEvQd7xtuBMxu9psAGGnKeQ7NPCVTBFKFPeIhIevUfQFmBip H5ao040r6moBiErc0wc0FCrjNV8MjLk2sdvgFAGi6ChTVA2PwHHcUtWDS7lMLhWvz521ra 3xrSqUuFLUj5z0hjcl1Loz0i6eOLm96u3VbmutbeAQKVwPf0KpD0eSQcKbjjTbNNcmem3p nV4vhY0Jx63h/HhjjMWYehS5O556iZx0LRngdjPQGJ6pdvzDVDyocqYvhI4Ys2ZSihM3Wr rTXRG4W3HpmvwmRTDN5hZZO4Q3OnMSKFmyQ95774MWA7o4tHCfq8YpmHxejGNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727475319; 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=lIjx3FQBj3/YLwX7RWO0/3yvljvCZXOyAiFYkqScNxY=; b=ERehpbb0Tpkfneo3XtZk7SlHSn7eaDt2BD/c5dGib96DgFJQGDMVpJjNBB5RHXjH/qqRDJ eOsPAV707+WElQ6creau5kjtfBRbzFKYtfttMLEh5IXsLnrPt0Vhp6A7rwLiTB/JwMPDo/ 48FLSXVKw02F1pGNaRPHNO6EvZLcl0XAnmtJbkjuINnq7e7dgHbIqT5FYKKqkFT94nTa3R dfkwdRrAH5zLSIzVPIMy2UJvw09SBDQkbhbrPrn6A7hdGA0vPwDjsyFm39qN6K08vuD1xS 1rkeQpZ8knSLkp6retzYvaR0wCnFe95UiqUvzP39vdj54JQYxhXYJMoQxS+43Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727475319; a=rsa-sha256; cv=none; b=ZVjzAoNfou+KiFpcUiKwc5VCIYFAKwI9R9sUISuNWhuE5BcwThisNCt8ehR36Yl5sj5tlm Uoh3N2xh4T1sOrGKHyjbOveGbHJSBQSTScYauNVlM2aaC2SYk+wztBOh0LRUuqysiHOiIc jRxRfj1TNZ3702QXg+QvR7da9ICtwqmBeHrZadjLJxpe8Lp1pxEHkxChJVt57MXnvXqoQS ccDwYeUU45XwxJBsiTQI7RQNkEhzU7J2qmuRQifD/WbgKrrpa5Zs0w8zk6jQqCXp7NXf1T 3DbqXMzknJ6vTpe+SIdcAWAtKOi1fsnlj5+xsuHTs+gSV+N/pDzPOYuhIpCpwA== 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 4XFlCC1fGKzyMb; Fri, 27 Sep 2024 22:15:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48RMFJks038842; Fri, 27 Sep 2024 22:15:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48RMFJqY038839; Fri, 27 Sep 2024 22:15:19 GMT (envelope-from git) Date: Fri, 27 Sep 2024 22:15:19 GMT Message-Id: <202409272215.48RMFJqY038839@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: c09ca8f43de1 - stable/14 - mountd: Add check for "=" after exports(5) options List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: c09ca8f43de12fecf701920675b793cbafba58c5 Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=c09ca8f43de12fecf701920675b793cbafba58c5 commit c09ca8f43de12fecf701920675b793cbafba58c5 Author: Rick Macklem AuthorDate: 2024-09-06 23:41:12 +0000 Commit: Rick Macklem CommitDate: 2024-09-27 22:13:49 +0000 mountd: Add check for "=" after exports(5) options Some exports(5) options take a "=arg" component that provides an argument value for the option. Others do not. Without this patch, if "=arg" was provided for an option that did not take an argument value, the "=arg" was simply ignored. This could result in confusion w.r.t. what was being exported, as noted by the Problem Report. This patch adds a check for "=arg" for the options that do not take an argument value and fails the exports line if one is found. PR: 281003 (cherry picked from commit 3df987c99d1194a0e43a84853e934aa0c0ab09db) --- usr.sbin/mountd/mountd.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 6583bfbc0ffb..fa270f3a42d4 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -2827,7 +2827,7 @@ do_opt(char **cpp, char **endcpp, struct exportlist *ep, struct grouplist *grp, { char *cpoptarg, *cpoptend; char *cp, *endcp, *cpopt, savedc, savedc2; - int allflag, usedarg; + int allflag, usedarg, fnd_equal; savedc2 = '\0'; cpopt = *cpp; @@ -2838,14 +2838,18 @@ do_opt(char **cpp, char **endcpp, struct exportlist *ep, struct grouplist *grp, while (cpopt && *cpopt) { allflag = 1; usedarg = -2; + fnd_equal = 0; if ((cpoptend = strchr(cpopt, ','))) { *cpoptend++ = '\0'; - if ((cpoptarg = strchr(cpopt, '='))) + if ((cpoptarg = strchr(cpopt, '='))) { *cpoptarg++ = '\0'; + fnd_equal = 1; + } } else { - if ((cpoptarg = strchr(cpopt, '='))) + if ((cpoptarg = strchr(cpopt, '='))) { *cpoptarg++ = '\0'; - else { + fnd_equal = 1; + } else { *cp = savedc; nextfield(&cp, &endcp); **endcpp = '\0'; @@ -2858,6 +2862,10 @@ do_opt(char **cpp, char **endcpp, struct exportlist *ep, struct grouplist *grp, } } if (!strcmp(cpopt, "ro") || !strcmp(cpopt, "o")) { + if (fnd_equal == 1) { + syslog(LOG_ERR, "= after op: %s", cpopt); + return (1); + } *exflagsp |= MNT_EXRDONLY; } else if (cpoptarg && (!strcmp(cpopt, "maproot") || !(allflag = strcmp(cpopt, "mapall")) || @@ -2896,15 +2904,31 @@ do_opt(char **cpp, char **endcpp, struct exportlist *ep, struct grouplist *grp, usedarg++; opt_flags |= OP_NET; } else if (!strcmp(cpopt, "alldirs")) { + if (fnd_equal == 1) { + syslog(LOG_ERR, "= after op: %s", cpopt); + return (1); + } opt_flags |= OP_ALLDIRS; } else if (!strcmp(cpopt, "public")) { + if (fnd_equal == 1) { + syslog(LOG_ERR, "= after op: %s", cpopt); + return (1); + } *exflagsp |= MNT_EXPUBLIC; } else if (!strcmp(cpopt, "webnfs")) { + if (fnd_equal == 1) { + syslog(LOG_ERR, "= after op: %s", cpopt); + return (1); + } *exflagsp |= (MNT_EXPUBLIC|MNT_EXRDONLY|MNT_EXPORTANON); opt_flags |= OP_MAPALL; } else if (cpoptarg && !strcmp(cpopt, "index")) { ep->ex_indexfile = strdup(cpoptarg); } else if (!strcmp(cpopt, "quiet")) { + if (fnd_equal == 1) { + syslog(LOG_ERR, "= after op: %s", cpopt); + return (1); + } opt_flags |= OP_QUIET; } else if (cpoptarg && !strcmp(cpopt, "sec")) { if (parsesec(cpoptarg, ep)) @@ -2912,10 +2936,22 @@ do_opt(char **cpp, char **endcpp, struct exportlist *ep, struct grouplist *grp, opt_flags |= OP_SEC; usedarg++; } else if (!strcmp(cpopt, "tls")) { + if (fnd_equal == 1) { + syslog(LOG_ERR, "= after op: %s", cpopt); + return (1); + } *exflagsp |= MNT_EXTLS; } else if (!strcmp(cpopt, "tlscert")) { + if (fnd_equal == 1) { + syslog(LOG_ERR, "= after op: %s", cpopt); + return (1); + } *exflagsp |= (MNT_EXTLS | MNT_EXTLSCERT); } else if (!strcmp(cpopt, "tlscertuser")) { + if (fnd_equal == 1) { + syslog(LOG_ERR, "= after op: %s", cpopt); + return (1); + } *exflagsp |= (MNT_EXTLS | MNT_EXTLSCERT | MNT_EXTLSCERTUSER); } else {