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

rmilter: Fix a couple of bugs #21866

Merged
merged 3 commits into from Mar 20, 2017
Merged

rmilter: Fix a couple of bugs #21866

merged 3 commits into from Mar 20, 2017

Conversation

pjones
Copy link
Contributor

@pjones pjones commented Jan 13, 2017

Motivation for this change
  • The module uses stringSplit but it should be splitString

  • rmilter doesn't actually support binding to multiple sockets.
    Therefore, bind to the last one specified if socketActivation is
    false.

I also believe there is a bug in this module related to systemd
ListenStream. If socketActivation is true, Postfix gets
connection timeouts trying to connect to one of the ListenStream
inet addresses. I don't know enough about ListenStream passing
connections on to fd:3 to understand what's going on.

These changes are in production (with socketActivation = false) via NixOps.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@pjones, thanks for your PR! By analyzing the history of the files in this pull request, we identified @avnik, @fpletz and @joachifm to be potential reviewers.

@avnik
Copy link
Contributor

avnik commented Jan 13, 2017

LGTM!
I will address question about socked activation to upstream author.

@Mic92
Copy link
Member

Mic92 commented Jan 13, 2017

When multiple sockets are specified systemd socket activation will pass them as file descriptors from fd:3 upwards (fd:3, fd:4, ..., fd:n)

@pjones
Copy link
Contributor Author

pjones commented Jan 13, 2017

When multiple sockets are specified systemd socket activation will pass them as file descriptors from fd:3 upwards (fd:3, fd:4, ..., fd:n)

Then that also causes a problem since rmilter can only bind/listen to one address.

@Mic92
Copy link
Member

Mic92 commented Jan 14, 2017

If it only support one socket address at the time, the options should not allow to specify multiple. Picking the last socket does not make sense to me.

@avnik
Copy link
Contributor

avnik commented Jan 14, 2017

actually socket activation needs only because libmilter can't setup proper permissions on unix socket, but systemd can.

@avnik
Copy link
Contributor

avnik commented Jan 14, 2017

rmilter unable to listen more than one socket/port, due libmilter desing flaw

@Mic92
Copy link
Member

Mic92 commented Jan 14, 2017

socket activation is also useful to prevent race conditions between connecting smtp daemons and rmilter on startup, because systemd create listening sockets before any service is started.

Copy link
Member

@fpletz fpletz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 on the changes, but this will break current setups using unix sockets and socketActivation disabled. The sockets will have 777 permissions.

Could you please add one or two sentences to the release notes for 17.03? Thanks!

@avnik
Copy link
Contributor

avnik commented Jan 20, 2017

@fpletz It why I implement socket activation in module (and also why upstream author add it), libmilter unable to set proper permissions on socket (as well, as listen to more than one socket)

@pjones
Copy link
Contributor Author

pjones commented Jan 21, 2017

@avnik If rmilter can't listen on more than one socket the Nix module shouldn't allow someone to configure more than one socket.

@avnik
Copy link
Contributor

avnik commented Jan 23, 2017 via email

@pjones
Copy link
Contributor Author

pjones commented Jan 24, 2017

@avnik If you have time please go ahead and work on it. I've got a lot on my plate right now so this is going to have to sit on the back burner for now.

@pjones
Copy link
Contributor Author

pjones commented Jan 24, 2017

@fpletz Maybe we should hold off on this PR until @avnik can change the interface for configuring the listening socket. Changing the interface is going to be better than what I'm doing here.

Also, @avnik, if you come up with something let me know and I can test it.

@fpletz
Copy link
Member

fpletz commented Jan 28, 2017

I've implemented support for only one socket and deprecated the two old options. Also rebased to current master.

@avnik @pjones What do you think?

@avnik
Copy link
Contributor

avnik commented Jan 28, 2017

@fpletz thank you. Your changes looks good.


rmilterConf = ''
pidfile = /run/rmilter/rmilter.pid;
bind_socket = ${if cfg.socketActivation then "fd:3" else last inetSockets};
bind_socket = ${if cfg.socketActivation then "fd:3" else rspamdSocket};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't rspamdSocket be rmilterSocket instead?

Copy link
Member

@fpletz fpletz Jan 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right! I've actually never tested this with a rspamd postfix but will before merging of course. Thanks for reading my changes carefully! 👍

@pjones
Copy link
Contributor Author

pjones commented Jan 28, 2017

I added one comment, and I also think the description for the socketActivation option needs to be updated since it doesn't actually force rmilter to use an inet socket now.

pjones and others added 3 commits March 17, 2017 20:15
  * The module uses `stringSplit` but it should be `splitString`

  * `rmilter` doesn't actually support binding to multiple sockets.
    Therefore, bind to the last one specified if `socketActivation` is
    `false`.

I also believe there is a bug in this module related to systemd
`ListenStream`.  If `socketActivation` is true, Postfix gets
connection timeouts trying to connect to one of the `ListenStream`
inet addresses.  I don't know enough about `ListenStream` passing
connections on to `fd:3` to understand what's going on.

These changes are in production (with `socketActivation = false`) via NixOps.
@fpletz
Copy link
Member

fpletz commented Mar 17, 2017

Rebased, fixed the issues @pjones mentioned and also tightened the permissions so only users in the rmilter or rspamd groups can access the unix sockets.

milter_protocol = 6
milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen}
# skip mail without checks if milter will die
milter_default_action = accept
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing: I removed milter_default_action here because it would get appended last in my main.cf so I couldn't overwrite it anymore. This should be set in services.postfix.extraConfig manually if required IMHO. The postfix default is tempfail which should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, I don't use this feature of the package. I add the milter stuff to postfix by hand because my needs are a bit different.

@fpletz fpletz merged commit 295a824 into NixOS:master Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants