How to "source" a .conf file

Questions and answers about how to do stuff
Post Reply
max_of_tl
Posts: 15
Joined: 07 Jan 2021 18:47

How to "source" a .conf file

Post by max_of_tl »

Hi,

Does anyone know if there is an easy way to "source" a mailscanner .conf file from another? Like for example, if I wanted to include some special rules for a certain group of e-mails/domains - I could just import the changes to the main ruleset.

Currently I have 2 rulesets for filename.rules.conf - they're almost identical except a couple lines. I'd rather not have to explain via comments that these 2 files need to be modified in tandem, except those 2 rules that are different.

Also, offhand - does anyone know if the first rule you hit is what counts - or is it the last. Or is it the first deny you hit that denies you but you have to pass all the rest? I've been using it a few years and still not sure how it works exactly.

Thanks
User avatar
pdwalker
Posts: 1553
Joined: 18 Mar 2015 09:16

Re: How to "source" a .conf file

Post by pdwalker »

max_of_tl wrote: 25 Jul 2022 17:58Does anyone know if there is an easy way to "source" a mailscanner .conf file from another? Like for example, if I wanted to include some special rules for a certain group of e-mails/domains - I could just import the changes to the main ruleset.
That's called "include" and I don't believe it is supported.
max_of_tl wrote: 25 Jul 2022 17:58Also, offhand - does anyone know if the first rule you hit is what counts - or is it the last. Or is it the first deny you hit that denies you but you have to pass all the rest? I've been using it a few years and still not sure how it works exactly.
Good question! I've wondered this myself. It's easy enough to test. Let's see:

Test 1: adding this to /etc/MailScanner/filename.rules.conf

Code: Select all

allow   \.testing$   testing extension allowed               test extension to deliver
deny    \.test.*$    testing extension denied                test extension to not deliver
send two emails, one with an attachment called "mailscanner.testing" and "mailscanner.test"

results:
allowed: mailscanner.testing
denied: mailscanner.test

Test 2: change the order of the instructions

Code: Select all

deny    \.test.*$    testing extension denied                test extension to not deliver
allow   \.testing$   testing extension allowed               test extension to deliver
and then resend the messages.

results:
allowed: mailscanner.testing
denied: mailscanner.test


Conclusion:

The order doesn't seem to matter. What seems to matter is how close the match is to what you are testing. Since .testing$ is a more exact match than \.test*$, that rule took priority over the wildcard rule.

Also, I tested with "mailscanner.testin" and it was denied, just as I expected it would be.
max_of_tl
Posts: 15
Joined: 07 Jan 2021 18:47

Re: How to "source" a .conf file

Post by max_of_tl »

pdwalker, Thank you for the excellent answer and going thru testing this.
User avatar
pdwalker
Posts: 1553
Joined: 18 Mar 2015 09:16

Re: How to "source" a .conf file

Post by pdwalker »

You're welcome. It's actually a question I had for myself, but I was previously too lazy to get off my ass and work it out.
Post Reply