From nobody Thu Aug 08 15:41:05 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 4WfrqQ0H4wz5T5MM; Thu, 08 Aug 2024 15:41:06 +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 4WfrqP6xjjz4HK5; Thu, 8 Aug 2024 15:41:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723131666; 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=2L2oBDyql3r5YRmVagE3uGbaFKAsTsNzNo4+tkyaB8U=; b=jlyZCuSG6aLIGTRG2YcJkcAkc/VMKYiVXTfluJy0n1L63WoyvS3Oi2LXR+fPmf+a0707T/ R3mY3Fp89tZ6k9LJEhFn8ti4mFG3JCGp1WEwiH6zuwS88vDpYiuN8QnPC0ZGtB5aYmb8yF g0fcoT9aZtCu2LqAokoCfAYtkiwEIiZvhaWDNIpTA/EcBQo8doi8L+H4ctineakWVtHKmh UFn+jMkoUK6GXBaCucK1CVJo8HeFBBHpsvvhEdJKwOH22K27nnQNk7Mm1mMaQ/QgMF/L2h MBkMmChl2g2MSo5HnzsU+2ZT/8516FzHu7GsVY+Jw56GEW272gHzr1YA+EyCIQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723131666; a=rsa-sha256; cv=none; b=RCaXT/hnoRAN4iFNCOGUUNDB8vwQX/c+EcBEAsoz+QGVHUG8hq6trxbRwp6QjclWlgLykB jAadh/6zlBTopVTBTrRbFUY4fFHMbMfONxE+M5PgtdNuxxWXZ60QjbaarrsAUsmYTiWuJD 3qdPnAOcj/6NrF6JZIfTS2799S/ZZ4O0GFWTEFXYPSFkGneDxAbs6Aj3YlfKyW2QxmpIzu 4Li1zhGnAS3h2ZD/Gm0wycwYq5and2NaYm9wnKzKA4kfyCBUsjxqpY14R1D5j8+lBd+RF4 1DyI7IoiyoyGAIdlTUChm2khQ21jGChecxjWuK8XEM1vBCs4WxqVIsC01zIZ5g== 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=1723131666; 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=2L2oBDyql3r5YRmVagE3uGbaFKAsTsNzNo4+tkyaB8U=; b=HqwMuYylZaLtsv/VVBI2Fgjbf19pa3TaI1iQ7HjR9EflJwoSftRPNHwO0RD1HqvxNlkVaK oCu0BOPO87sZEyPI4lbkqCRsFl7CjKYlvEz+om4Db2hHtRVh7GkajbeWmBXwiVu3Yza2vx kb2BUGavD8eNygN3XibEOnzTgJWh+Xh/luaIh4ytvE9ofFZ4LaVhrkRRBH8k2KGbHH9PGs lBVv3cd3fCqfjO6iW83Rqwu9rJ5BF8QxTPXcHoGQ6fG6i/jkqRGm7ggM8iIJDTv0V7iAqg VjIkeLJs4ibRftvGo4kZInOJ54Mv6SpICZPvU8JSGMLg4FxAd+E8d8oSMubWCg== 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 4WfrqP6YYRzfRG; Thu, 8 Aug 2024 15:41:05 +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 478Ff5hB070812; Thu, 8 Aug 2024 15:41:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 478Ff5lI070810; Thu, 8 Aug 2024 15:41:05 GMT (envelope-from git) Date: Thu, 8 Aug 2024 15:41:05 GMT Message-Id: <202408081541.478Ff5lI070810@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 053500aa9301 - stable/13 - pfctl: Allow a semicolon (;) as a comment 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 053500aa93017f8d8096a9625491ae1e335a356e Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=053500aa93017f8d8096a9625491ae1e335a356e commit 053500aa93017f8d8096a9625491ae1e335a356e Author: Juraj Lutter AuthorDate: 2024-07-25 08:07:50 +0000 Commit: Kristof Provost CommitDate: 2024-08-08 05:42:58 +0000 pfctl: Allow a semicolon (;) as a comment To make parsing of, for example, Spamhaus' drop.txt and similar files that contains semicolons as comments, allow them also in file-based tables. Reviewed by: kp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D46088 (cherry picked from commit a8a95277363be2c92b3c06bd9cd1a32d1c6c6ecd) --- sbin/pfctl/pfctl.8 | 4 +++- sbin/pfctl/pfctl_radix.c | 4 ++-- sbin/pfctl/tests/files/pf1020.in | 3 +++ sbin/pfctl/tests/files/pf1020.include | 4 ++++ sbin/pfctl/tests/files/pf1020.ok | 2 ++ sbin/pfctl/tests/pfctl_test_list.inc | 1 + 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sbin/pfctl/pfctl.8 b/sbin/pfctl/pfctl.8 index 41a8ec8b4340..196ce0f1766f 100644 --- a/sbin/pfctl/pfctl.8 +++ b/sbin/pfctl/pfctl.8 @@ -24,7 +24,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd October 3, 2016 +.Dd July 23, 2024 .Dt PFCTL 8 .Os .Sh NAME @@ -518,6 +518,8 @@ line and/or in an unformatted text file, using the flag. Comments starting with a .Sq # +or +.Sq \; are allowed in the text file. With these commands, the .Fl v diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c index d33f091d8b69..1e93a8972d9e 100644 --- a/sbin/pfctl/pfctl_radix.c +++ b/sbin/pfctl/pfctl_radix.c @@ -535,8 +535,8 @@ pfr_next_token(char buf[BUF_SIZE], FILE *fp) /* skip spaces */ while (isspace(next_ch) && !feof(fp)) next_ch = fgetc(fp); - /* remove from '#' until end of line */ - if (next_ch == '#') + /* remove from '#' or ';' until end of line */ + if (next_ch == '#' || next_ch == ';') while (!feof(fp)) { next_ch = fgetc(fp); if (next_ch == '\n') diff --git a/sbin/pfctl/tests/files/pf1020.in b/sbin/pfctl/tests/files/pf1020.in new file mode 100644 index 000000000000..7f98df69bd04 --- /dev/null +++ b/sbin/pfctl/tests/files/pf1020.in @@ -0,0 +1,3 @@ +table file "./pf1020.include" + +block from diff --git a/sbin/pfctl/tests/files/pf1020.include b/sbin/pfctl/tests/files/pf1020.include new file mode 100644 index 000000000000..3fca07f64bfa --- /dev/null +++ b/sbin/pfctl/tests/files/pf1020.include @@ -0,0 +1,4 @@ +; comment1 +# comment2 +1.0.0.1/32 ; comment1 +2.0.0.2/32 # comment2 diff --git a/sbin/pfctl/tests/files/pf1020.ok b/sbin/pfctl/tests/files/pf1020.ok new file mode 100644 index 000000000000..16073b3d6987 --- /dev/null +++ b/sbin/pfctl/tests/files/pf1020.ok @@ -0,0 +1,2 @@ +table file "./pf1020.include" +block drop from to any diff --git a/sbin/pfctl/tests/pfctl_test_list.inc b/sbin/pfctl/tests/pfctl_test_list.inc index b73bcf2522b7..2565a119cc6a 100644 --- a/sbin/pfctl/tests/pfctl_test_list.inc +++ b/sbin/pfctl/tests/pfctl_test_list.inc @@ -117,3 +117,4 @@ PFCTL_TEST(1005, "PR 231323") PFCTL_TEST(1006, "pfctl crashes with certain fairq configurations") PFCTL_TEST(1010, "POM_STICKYADDRESS test") PFCTL_TEST(1018, "Test dynamic address mask") +PFCTL_TEST(1020, "Test hashmark and semicolon comment")