From nobody Thu Jul 25 13:10:35 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 4WVB8D0Tbtz5S2JH; Thu, 25 Jul 2024 13:10:36 +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 4WVB8D00rYz4P9S; Thu, 25 Jul 2024 13:10:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721913036; 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=LLv8Gk/EMBowb32GpyWTlbcBY9cWSehqJiXB2qsn1DM=; b=NE1taiVEU7Siap969STxNGR0YDAk67zOOkNVjxortN8MMJHkH6pSPd1WzkaOJRtv0IoLE/ wMp3+fcEWhyoaZtgl4MGiNhDeK4Z24efF502qcQnfLtiUjGipzuA4XEkIxL8LqV6hmeoV6 nUmM+FnE/1Kqm5Tn6bshoOosXoIavuF9a8ALZtNEF2G1U9nYINwmzjHM2jR7/alFfw3ytb aNnCHD2Y6ANCa+nFGhd95WXrKZ8ggMmZuGsM5utzxs6GB1U9DTdTjSAMch/V84dIRPdbAS peVFdNj2gljqtJk8J+ZTneHAS9Mxrmn8vqy7pjYqhHKT80ct9yK/+d4NAzSXQg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721913036; a=rsa-sha256; cv=none; b=mvWzoPpJxXxnvCRczZnYeNfdAtMdTmZiRfhkkNUe0QNCLBpaROaAWuyQ+FBzgal/1hj5Pl C4nNJH6RFM0fAC/hiqWBh+Y56wLPEmourRo6lNlB+pvdHhR6eeB6Zk/AUtADf1gkrsQezh Hs4KBPdkv6YBbs/3XRFBdjsln8uRLwioqH0w2Zh+rAS/WrwCdJXXBon4R244bnFB+WzG/M qiSJZRD31PS+1/LIw41+oqKsdNsf6k4OUivnHq+anpSGncHeNd3YuSvpq21wS09gNUwbQb OfLKEaT1Bv+I0XeSeY9rdLUAg/+2H6HmIXxfyYeATlXhhHZmoa3QA81JOn9qKA== 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=1721913036; 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=LLv8Gk/EMBowb32GpyWTlbcBY9cWSehqJiXB2qsn1DM=; b=XhH9MpZ9iB5dIu294Cgyi5w6C6RuVMtwp2/Db+8dY02/01wzugAwC7xNWaq9BgZwHBulaf 72Awu6AN73xRxSFdaUrkxyN1QTvB8LcWQ3DWecBn8Xjzj+M2E1NujOB5zyflsXxFEgMGEV C4wLyV92GW3+DpzYb7142Mmvii9aPtu9f7K9Jv1888oHTrziibR/Aj+yCWWHDtsxobGxZu IMmqqxqLLcMBbH14dPPVAq9F1RyW/tt4BBG9kOkQuNpVTaXFytnVfoU0T81sSBnFBJZ8jf OqzZFRF+mcCXsQBHsW6zhHNmt8Qw5cZX0T0jMcs6wG8GLMa1jK38xvCQIdZAiw== 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 4WVB8C6fNxzwYh; Thu, 25 Jul 2024 13:10:35 +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 46PDAZYo089036; Thu, 25 Jul 2024 13:10:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46PDAZCW089031; Thu, 25 Jul 2024 13:10:35 GMT (envelope-from git) Date: Thu, 25 Jul 2024 13:10:35 GMT Message-Id: <202407251310.46PDAZCW089031@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: a8a95277363b - main - 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/main X-Git-Reftype: branch X-Git-Commit: a8a95277363be2c92b3c06bd9cd1a32d1c6c6ecd Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a8a95277363be2c92b3c06bd9cd1a32d1c6c6ecd commit a8a95277363be2c92b3c06bd9cd1a32d1c6c6ecd Author: Juraj Lutter AuthorDate: 2024-07-25 08:07:50 +0000 Commit: Kristof Provost CommitDate: 2024-07-25 13:06:24 +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 --- 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 6c9a9f3b2ca4..80fdc394a568 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 20, 2023 +.Dd July 23, 2024 .Dt PFCTL 8 .Os .Sh NAME @@ -531,6 +531,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 b1180b40dfee..cfe982a84e95 100644 --- a/sbin/pfctl/pfctl_radix.c +++ b/sbin/pfctl/pfctl_radix.c @@ -534,8 +534,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 2dcee80b6e93..5d1717200759 100644 --- a/sbin/pfctl/tests/pfctl_test_list.inc +++ b/sbin/pfctl/tests/pfctl_test_list.inc @@ -128,3 +128,4 @@ PFCTL_TEST(1016, "Ethernet rule with ridentifier and one label") PFCTL_TEST(1017, "Ethernet rule with ridentifier and several labels") PFCTL_TEST(1018, "Test dynamic address mask") PFCTL_TEST(1019, "Test pflow option") +PFCTL_TEST(1020, "Test hashmark and semicolon comment")