r-raymond / nixos-mailserver

A complete and Simple Nixos Mailserver
GNU General Public License v3.0
181 stars 27 forks source link

Unable to activate a Sieve script via ManageSieve #53

Closed erosennin closed 6 years ago

erosennin commented 6 years ago

Hi, I'm migrating my mail server from Debian to nixos-mailserver and it mostly works great! Thanks for the project. :)

The only problem I've faced so far is broken activation of Sieve scripts. I was successfully able to upload a Sieve script with KMail, but trying to activate the scripts results in this error:

managesieve(user@example.com): Error: sieve: file script: Failed to activate Sieve script: symlink(/var/sieve/user@example.com.sieve/default.sieve, /var/empty/.dovecot.sieve) failed: Operation not permitted

I'm using nixos-mailserver-2.0.4 on NixOS 17.09.

Thanks!

r-raymond commented 6 years ago

Hi, thanks for using SNM! I'm hoping @eqyiel has some more insights, since I'm not using custom sieve scripts myself.

The idea is however, that you specify the sieve scripts in your configuration file (see https://github.com/r-raymond/nixos-mailserver/blob/cd9e790f21d26aa6a6588715d18a66a18899b7f6/default.nix#L81) instead of uploading it after deploying the server (the idea being: no state).

Is that something that breaks your workflow?

erosennin commented 6 years ago

Managing Sieve scripts as part of the configuration is great for a personal mail server, but does not really scale to multi-user servers. On a typical mail server, most users do not have root access to the system, but may still want to use custom Sieve scripts.

How about using sieve_default and sieve_default_name options for the script from the configufation file? This way, the script from the configuration will be used by default and the user will be able to override it via ManageSieve, if necessary.

https://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration#Visible_Default_Script

r-raymond commented 6 years ago

That sounds like a good plan. We need to make sure it behaves well with our default script defined via dovecot2.sieveScript and the current custom script implementation. Maybe we can add an option whether to allow users to override sieve scripts?

Do you want to make a PR for this? I could do it too, but I'm a little busy right now and certainly no expert on sieve scripts.

eqyiel commented 6 years ago

@erosennin it would probably be sufficient to just add here: https://github.com/r-raymond/nixos-mailserver/blob/cd9e790f21d26aa6a6588715d18a66a18899b7f6/mail-server/dovecot.nix#L111-L113

plugin {
   sieve = file:~/sieve
   sieve_default = file:/var/sieve/%u.sieve
}

I'd be happy to give it a go if this works for you 👍

eqyiel commented 6 years ago

Don't forget to open port 4190 too, maybe we should make a configuration option for this?

erosennin commented 6 years ago

Thanks, I'll try to make a pull request.