Postfix - Header checks not working?

Started by uproden, October 10, 2021, 08:05:23 PM

Previous topic - Next topic
I am trying to troubleshoot through some issues with header checks, I've read all I can about how to format the regex properly and I think I've got that right, so for example:

/^From:.*twitter.*/ REJECT rejected

But I still get mail from twitter.com. I've tried many many variations of the regex and nothing seems to work. In digging in further it seems like the postfix mail.cf in /usr/local/etc/postfix is pointing to:

header_checks = regexp:/usr/local/etc/postfix/header_checks_receiving
smtp_header_checks = regexp:/usr/local/etc/postfix/header_checks_delivering

No matter what I do in the GUI (enable, disable rules, use the example regex, etc...) Those two files are completely empty

This makes it impossible to "test" the header checks using postmap which is supposed to be something like:

postmap -q "<put test header here>" regexp:/usr/local/etc/postfix/header_checks_receiving

Obviously this doesn't work. So I'm kind of stuck, I'm not sure how to test my rules and I don't know why those files are blank. Any assistance would be very much appreciated.




any errors in System: Log Files: Backend when applying potsfix settings?

I do not see any postfix related errors in the backend system logs, all postfix changes seem to apply correctly.

Not using postfix on opnsense myself, but generally speaking...

You could try to find alternate config files (as su):

find / -name "main.cf"
find / -name "header_checks"
find / -name "header_checks*"


...and you could perhaps just use:

/^From:.*twitter/ REJECT Twitter sux, leave me alone

Also, from the plugin info, you get:

Quote1.16

* Add support for header_checks (contributed by Starkstromkonsument)

...which you may want to hunt down on here or on Github.

HTH,
Ben

@uproden
sorry, can't reproduce this behaviour. works stable on test vm.
(the only way i can stop the template application is to disable header check rule or postfix itself)
any errors on healt audit  (System: Firmware->run an audit->health)?

No iussue come up in the health check. I have an update though, after messing around with just about everything and several reboots, now all of a sudden the header_checks_receiving file is now populated with the rules... however... When I add new rules via the GUI they are NOT added to the file. Any idea what process / script is responsible for taking the entries from the UI and generating the headers file? Also this seems to be very similar to an issue I am having with aliases where sometimes they do not seem to update until I reboot.

What version and commit are you running (on System: Firmware page)?

Have you re-installed the plugin?

Have you had any unexpected shutdowns?

Quote from: uproden on October 26, 2021, 03:28:56 PM
No iussue come up in the health check. I have an update though, after messing around with just about everything and several reboots, now all of a sudden the header_checks_receiving file is now populated with the rules... however... When I add new rules via the GUI they are NOT added to the file. Any idea what process / script is responsible for taking the entries from the UI and generating the headers file? Also this seems to be very similar to an issue I am having with aliases where sometimes they do not seem to update until I reboot.


System : Log Files : Backend (after adding a header check)

@uproden
as @mimugmail said and i asked at https://forum.opnsense.org/index.php?topic=25102.msg120946#msg120946
what is in backend log when applying potsfix settings?
is there "Postfix generated //usr/local/etc/postfix/header_checks_receiving" string?
QuoteAny idea what process / script is responsible for taking the entries from the UI and generating the headers file?
when you hit Apply gui sends the api request to reconfigure service. at some step configd daemon reloads services templates.
QuoteAlso this seems to be very similar to an issue I am having with aliases
hm. Is there a configmodelfield.data file in the /tmp dir? what is the last modified date of this file?