From nobody Fri Sep 06 23:42:27 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 4X0t7R64fqz5WFlT; Fri, 06 Sep 2024 23:42:27 +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 4X0t7R3sJJz4X4S; Fri, 6 Sep 2024 23:42:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725666147; 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=+W1sd+I0yn8+4KMARD5e1WUk5tS3lJao6YLTdQ8RDks=; b=HJlMbJv/ljXg1Brh3hVMbARv5vbpH4aU2mBXOLRm/NVVR6rcdHL/QMxquaUjySDXF9QE3C HOscxlbusF/zqKCIttZvAgAeX/9j2LYIrVu/rjToAwISvlJamwRs9kvphUnb9kS+VoX5A5 1FVdn5/RG24IAQOvVT4H+sAP4jOyEAqOhGsj0j3yR2ZePQRdggyA1ICm3waGKSm7VhpNdu ZVDeQS0jUJ0IaGx/31eNcOQ8m1VwDPtXrlxNZz1T8434NimkmCKD3/15CTARmZZd/L4AhL TnG7IIQUV+54RqEDdsjgAM/SzXJXpbyGXAT3vWBmC5X2nz69jhGCbeMrXIg6bg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725666147; a=rsa-sha256; cv=none; b=Ol5BHV1SquhT2xloWK1zGK9F4U2prkjCSxWIOqmblX/q18guQ+0e2Bzmzv3SpMkoyL8Mxp C4jcm9mrs2Cc0qklnRpZq1TGH1tEjF2kGHHNJqj2JnKaau1MGjxbc7xRFdk9P7WRuI+8lb jBc52k8q4/4h9OScZWvAGXGePLd7FDFsw9Azvlik7sZe3wD9QuMk29SL61APjUfE8s3V40 JtrwIk+VeJHd0tn9Vz/a7UU2Ag1aZGMxZq0q9gOOslOgRBymQ+9gF9nunuNOxvWbXLC5UQ U3nh8VMnfyQSSEQFzKzP9rygYtzAT8zVfh2MydpOg/QtoyeEnqyX8fMQJ8g1Bg== 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=1725666147; 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=+W1sd+I0yn8+4KMARD5e1WUk5tS3lJao6YLTdQ8RDks=; b=kMHIYPYYbghsbae9ruotJYaoabPsevdht7dxnPQ30TXGkuDxGmq92qhg4bK7Paz1HiB4Vk woozmcKwtfF+uJ8mECKf6hlyKvog14fKW68EAzJd4VB0xkrXEp3Z9OU8E3DuKdCxN4575f FtkjIkMZMyQSLACFU0xnVrqhGxhvKnmO+M9GIu/XfMqvLYRZJX16JEVMOrfnylzy0UxuAd JopliyGGTXXYR0+Ll4yMicqOYP1H7AQcgb+L8+JsaRe927xkoc7jk9bFqnhljUqRkfBLCg oj9gHGUkqhvkJXvjbbupnlh2njBTxgplcb0L8U+9DGaHqP46kYyVrtNDng9VfQ== 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 4X0t7R3TJZz1BWm; Fri, 6 Sep 2024 23:42:27 +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 486NgR3F038266; Fri, 6 Sep 2024 23:42:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 486NgR7O038243; Fri, 6 Sep 2024 23:42:27 GMT (envelope-from git) Date: Fri, 6 Sep 2024 23:42:27 GMT Message-Id: <202409062342.486NgR7O038243@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: 3df987c99d11 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 3df987c99d1194a0e43a84853e934aa0c0ab09db Auto-Submitted: auto-generated The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=3df987c99d1194a0e43a84853e934aa0c0ab09db commit 3df987c99d1194a0e43a84853e934aa0c0ab09db Author: Rick Macklem AuthorDate: 2024-09-06 23:41:12 +0000 Commit: Rick Macklem CommitDate: 2024-09-06 23:41:12 +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 MFC after: 2 weeks --- 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 00293909614e..00309ed58136 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -2825,7 +2825,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; @@ -2836,14 +2836,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'; @@ -2856,6 +2860,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")) || @@ -2894,15 +2902,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)) @@ -2910,10 +2934,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 {