mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-21 18:50:50 +01:00
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
This commit is contained in:
parent
4d8c65b466
commit
a8a9527736
@ -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
|
||||
|
@ -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')
|
||||
|
3
sbin/pfctl/tests/files/pf1020.in
Normal file
3
sbin/pfctl/tests/files/pf1020.in
Normal file
@ -0,0 +1,3 @@
|
||||
table <tabl1> file "./pf1020.include"
|
||||
|
||||
block from <tabl1>
|
4
sbin/pfctl/tests/files/pf1020.include
Normal file
4
sbin/pfctl/tests/files/pf1020.include
Normal file
@ -0,0 +1,4 @@
|
||||
; comment1
|
||||
# comment2
|
||||
1.0.0.1/32 ; comment1
|
||||
2.0.0.2/32 # comment2
|
2
sbin/pfctl/tests/files/pf1020.ok
Normal file
2
sbin/pfctl/tests/files/pf1020.ok
Normal file
@ -0,0 +1,2 @@
|
||||
table <tabl1> file "./pf1020.include"
|
||||
block drop from <tabl1> to any
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user