roehling / postsrsd

Postfix Sender Rewriting Scheme daemon
325 stars 39 forks source link

SRS_EXCLUDE_DOMAINS seems to not be working on test server #64

Closed tedeasydns closed 5 years ago

tedeasydns commented 7 years ago

I'm doing some testing on a virtualised network of vagrant boxes using postsrsd to implement srs, and I have it working and able to send emails with re-written return paths to external mailservers. The box doing the forwarding is installed and configured by the same automation as our production forwarders. When I un-comment the SRS_EXCLUDE_DOMAINS list in /etc/default/postsrsd and enter domains I'm testing through there, restarting both postsrsd and postfix, just to be sure, I still see the the domain on the exclude list being re-written. I'm wondering if the fact it's a virtual network is causing a problem, but I don't see why that should interfere in this, the server behaves normally in every other way. Is there some step in using that list that I am missing or unaware of, or what should I check into to find the problem? I've not been successful finding anything helpful in logs, if someone could point me in the right direction to look I'd appreciate it.

otetard commented 7 years ago

After an upgrade from 1.2 to 1.4 (using Debian backport packages), I encountered the same issue.

roehling commented 7 years ago

Hm, I'll need to do some more digging. The executable itself handles everything fine on my end. Maybe it's a problem with the startup scripts not passing the -X option properly?

raimue commented 7 years ago

It is probably the problem with quoting in the systemd unit that I described in this comment on an older issue: https://github.com/roehling/postsrsd/issues/44#issuecomment-278507826

Check the parameters with ps aux |grep postsrsd. You will probably see postsrsd ... -X"exclude1 exclude2 exclude3" with literal quotes being passed to postsrsd. Which means this is actually taken as "exclude1 and exclude3", while exclude2 would be fine.

Adding some dummy at the front and back avoids the problem, but it would be even better to fix the systemd unit file.

tedeasydns commented 7 years ago

Thanks for the replies, and sorry it took me a while to get back to this. It turns out the problem I was having seems to have been an understanding on what basis the exemption is being made. The exemptions seem to work for the domain sending the email, where as I was thinking to exempt domains using the mailserver for forwarding or backup mail spool. Is that correct? That when you put example.com in the exemptions, that refers to not rewriting email which is sent from example.com, not exempting email sent to example.com from SRS rewrite? Some of our clients using various forms of forwarding to mail systems they control are interested in having email to their domains not subjected to the SRS rewrite. Can you point me in the right direction to be able to exempt domains we are handling mail for from the SRS system?

roehling commented 7 years ago

@raimue The systemd unit file proves to be a source of unending pain joy...

@tedeasydns PostSRSd sees nothing but the sender's email address (via the canonical lookup mechanism), so all rewrite decision have to be based on the sender's email address only, plus some system-wide configuration items (e.g. the domain name to which addresses are rewritten). For a more complex setup, PostSRSd would have to run as milter. I've been thinking about implementing a milter mode, but my time is rather limited and I haven't gotten around to do it yet...

zhavranek commented 7 years ago

See https://github.com/roehling/postsrsd/issues/74, you must write postsrsd ... -X"exclude1 exclude2 exclude3 " (ending space added). I think it's a bug in the postsrsd.

roehling commented 5 years ago

See #74