From nobody Wed Jul 2 08:27:16 2025 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 4bXCgS705wz604Vl; Wed, 02 Jul 2025 08:27:16 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bXCgS3KKQz3ZFP; Wed, 02 Jul 2025 08:27:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751444836; 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=QaNk0dbU4N1uFcqJlHnZ3o6J3PezR41v6oCQcGfioU0=; b=kHqU5MeY80AZhn26Jpr/dOC7ge0u74YfqwuRUemnW8Go88UpaBp42DD3AfKv6ziSEGVQa5 D6RoP8eQ46zoIOk8hECwd9rJ7NonqR5EldRIwd/boM3kBQM/DelJ5m3xaJbLORUCtJtprB u9SeQooBaImuinMMad+Yo6SlWVjFTP8veydGJw5oZuw6l4qWJWGhW0zReYVL00iO0woKQ8 s+5xj2Dz0gK9cA9v5WxaEOePkbdObSxpTD8PA/Q11UgMYam5/7eWwtm0YkBsKEOSHMbBWt dP4N78C2Ga9ByfVazHgWbRyy/jHUo5G2h6nf3Roudp8/xJ4vujoGzHZepytDYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751444836; 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=QaNk0dbU4N1uFcqJlHnZ3o6J3PezR41v6oCQcGfioU0=; b=TpzYxEFw/eUaWn7LgOdpEVNoy+21x7tZ3PrBKvNm4KIQUOlOs77Fxqlbjb2Mp21Q/z0Asm B1+Qg0vLxmBhoenwdtZcORH6HfqJxwsW+IymkS/SnTo7fogV/qLXZ+zWITJsS4amxlCIdl etYgNFjosC4mdjnyrd89xpwtETzICogqXq9fMwf8gFDQy8pR6M1mD3dDBE15ZWcekPrDZh K8AddVV9hBDQRerHtfmJ3kP84JNsK8GlkjBK+FpZQRX8T9EudY7ddQI55GY1aEciXR7E0y wLlaGGvuYEZ+7RCumTAkCM8womxxeRNfinQZjD9c3yApAobc0VkCSnqBEb8i2w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751444836; a=rsa-sha256; cv=none; b=g9HMkVBbpG919SPxRBy1IKlGLxQP6Jlg+ZYjG+nsUvWA/oLqAHNXUOmVyCYUY0MqkBv9cC cUP2+8an4EJfv7AmO2MwN8JgwhxzNJBZWogCXExWZOyXoJ91toqfmotdWbiQsk/mtg7WHd ZftOVkM9Llrv/CMR3rEEAsnP9yoqhCkDXd142wdvOvdVgG577KLevpXAzbYp8qwtDq32iC eV2SgiAK3AyjJnHu5XARKJ9083ElGKQVGIn0ecS/Bzroe5jiDwCNrSvpsmrdfPUpExJLoT 1jNT/B0kmfTeDaAfUzCJybfGBEj6lI2Xk7hUntYZRuKjHnsGPIUttfG9DKBRzw== 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 4bXCgS2PPTz1BPB; Wed, 02 Jul 2025 08:27:16 +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 5628RG49025655; Wed, 2 Jul 2025 08:27:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5628RGUi025652; Wed, 2 Jul 2025 08:27:16 GMT (envelope-from git) Date: Wed, 2 Jul 2025 08:27:16 GMT Message-Id: <202507020827.5628RGUi025652@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: 725e65580a0e - main - pfctl: Error out early on bad anchor usage 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: 725e65580a0ec14992f41c93dba78c181de179d3 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=725e65580a0ec14992f41c93dba78c181de179d3 commit 725e65580a0ec14992f41c93dba78c181de179d3 Author: Kristof Provost AuthorDate: 2025-06-27 14:21:09 +0000 Commit: Kristof Provost CommitDate: 2025-07-02 07:40:53 +0000 pfctl: Error out early on bad anchor usage `pfctl -a foo' would do nothing with the non-existent anchor and exit 0. This implements behaviour as documented in pfctl(8): -a anchor Apply flags -f, -F, and -s only to the rules in the specified anchor. While here, hoist a duplicate "_" check by using the more mnemonic `mode'. OK henning sashan Obtained from: OpenBSD, kn , 574cdb686a Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 926c18ee5dbc..79076fc69776 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -3198,6 +3198,15 @@ main(int argc, char *argv[]) if (anchoropt != NULL) { int len = strlen(anchoropt); + if (mode == O_RDONLY && showopt == NULL) { + warnx("anchors apply to -f, -F and -s only"); + usage(); + } + if (mode == O_RDWR && + (anchoropt[0] == '_' || strstr(anchoropt, "/_") != NULL)) + errx(1, "anchor names beginning with '_' cannot " + "be modified from the command line"); + if (len >= 1 && anchoropt[len - 1] == '*') { if (len >= 2 && anchoropt[len - 2] == '/') anchoropt[len - 2] = '\0'; @@ -3329,10 +3338,6 @@ main(int argc, char *argv[]) } if (clearopt != NULL) { - if (anchorname[0] == '_' || strstr(anchorname, "/_") != NULL) - errx(1, "anchor names beginning with '_' cannot " - "be modified from the command line"); - switch (*clearopt) { case 'e': pfctl_flush_eth_rules(dev, opts, anchorname); @@ -3423,9 +3428,6 @@ main(int argc, char *argv[]) error = 1; if (rulesopt != NULL) { - if (anchorname[0] == '_' || strstr(anchorname, "/_") != NULL) - errx(1, "anchor names beginning with '_' cannot " - "be modified from the command line"); if (pfctl_rules(dev, rulesopt, opts, optimize, anchorname, NULL)) error = 1;