Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pf.conf.5: additional quoting for ranges in lists #1516

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Defenso-QTH
Copy link
Contributor

When defining network address ranges in macros that will later be used as items in list macro, these ranges must be quoted with additiona simple quotes.

For instance, the following does not work and is rejected as a syntax error:

    usr = "192.168.1.0/24"
    srv = "192.168.2.10 - 192.168.29"
    nat_ranges = "{" $usr $srv "}"

Defining ranges as the following instead will work:

    usr = "'192.168.1.0/24'"
    srv = "'192.168.2.10 - 192.168.29'"

@concussious I took the liberty to already name you as a reviewer based on our recent interaction on Discord, I hope that's fine. Please let me know.

@jlduran
Copy link
Member

jlduran commented Nov 13, 2024

I'm not sure I understand what is the desired result. Is it?:

usr = "192.168.1.0/24"
srv = "192.168.2.10 - 192.168.29"

nat_ranges = "{ $usr, $srv }"

As a side note, for new documentation purposes, we subscribe to the use of RFC 5737 addresses.

@Defenso-QTH
Copy link
Contributor Author

Yes. Except that will give you a syntax error, because, as stated in the previous line of the manpage: Macros are not expanded inside quotes.

Thanks for pointing me to the RFC I will update the PR accordingly.

@jlduran
Copy link
Member

jlduran commented Nov 13, 2024

I think I understand now what you are trying to document:

In order to overcome the limitation that macros don't get expanded inside quotes, when you have, for instance, a macro containing a range, and want it to expand to a list, you must define the macro quoted:

usr = "\"192.168.1.0/24\""
srv = "\"192.168.2.10 - 192.168.29\""

nat_ranges = "{" $usr $srv "}"
nat on $ext_if from $nat_ranges to any -> ($ext_if)

Or as you suggest, using a combination of single and double quotes, in order to avoid escaping the double quotes? ...interesting.

@Defenso-QTH
Copy link
Contributor Author

Yes that's exactly it.

When defining network address ranges in macros that will later be used
as items in list macro, these ranges must be quoted with additiona
simple quotes.

For instance, the following does not work and is rejected as a syntax
error:

    usr = "192.168.1.0/24"
    srv = "192.168.2.10 - 192.168.29"
    nat_ranges = "{" $usr $srv "}"

Defining ranges as the following instead will work:
    usr = "'192.168.1.0/24'"
    srv = "'192.168.2.10 - 192.168.29'"

MFC after: 3 days
Reviewed by: Alexander Ziaee <[email protected]>
@Defenso-QTH Defenso-QTH force-pushed the pf.conf.5-ranges-quoting branch from 5a7b787 to 50c46d9 Compare November 13, 2024 06:42
The current manpage has two PARAMETERS top-level sections, which can be
confusing when searching or browsing documentation quickly.

Since the parameters described in these two sections are actually
applicable within the scope of the sections they follow (ETHERNET
FILTERING and PACKET FILTERING respectively), I propose we move them to
subsections.

I also propose we reword the title of one of those subsections to
facilitate quick searching or browsing.

MFC after: 3 days
Reviewed by: Alexander Ziaee <[email protected]>
@Defenso-QTH Defenso-QTH force-pushed the pf.conf.5-ranges-quoting branch from 1bfd1cf to c814f49 Compare November 13, 2024 07:07
@concussious
Copy link
Contributor

cc @kprovost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants