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

nixos/dovecot: add support for sieve extensions, in particular imapsieve and pipe #275031

Merged
merged 2 commits into from Jan 12, 2024

Conversation

2xsaiko
Copy link
Contributor

@2xsaiko 2xsaiko commented Dec 17, 2023

Description of changes

Finally upstreaming some stuff from my config that I've been running for years. This is used on my mail server, where I use it to drive automatic learning for the spam filter. In action here: https://git.dblsaiko.net/systems/tree/configurations/polaris/dovecot.nix?id=8ea672890c78b059e002920628636234c7541c1f#n54

Adds general support for enabling Sieve plugins/extensions, support for the IMAPSieve plugin and support for specifying which binaries are available from the vnd.dovecot.pipe extension (part of the Extprograms plugin). IMAPSieve is used to trigger Sieve scripts on IMAP user actions, like moving mails around. vnd.dovecot.pipe can be used to run external programs from a Sieve script, for example passing the mail to rspamd to register it as spam.

Documentation for the IMAPSieve plugin: https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve/
Documentation for the Extprograms plugin: https://doc.dovecot.org/configuration_manual/sieve/plugins/extprograms/

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

from = mkOption {
default = null;
description = ''
Only execute the administrator Sieve scripts for the mailbox configured with services.dovecot2.imapsieve.mailbox.${name}.name when the message originates from the indicated mailbox.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if you can refer to ${name} here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you build the manual? I wanted to check how it looks in there when I wrote this but couldn't figure out a way to do it :D

What would you write instead?

Copy link
Member

Choose a reason for hiding this comment

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

I'd just do <name> or *, this is the convention I usually see.

@@ -459,4 +622,5 @@ in

};

meta.maintainers = [lib.maintainers.dblsaiko];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
meta.maintainers = [lib.maintainers.dblsaiko];
meta.maintainers = [ lib.maintainers.dblsaiko ];

Copy link
Member

@RaitoBezarius RaitoBezarius left a comment

Choose a reason for hiding this comment

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

LGTM; untested.

@RaitoBezarius RaitoBezarius merged commit 1b2aeec into NixOS:master Jan 12, 2024
19 checks passed
@RaitoBezarius
Copy link
Member

@2xsaiko This broke my production deployment of dovecot2 with the following error:

Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: sievec: Error: stats: open(/run/dovecot2/old-stats-mail) failed: No such file or directory
Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: after: line 1: error: require command: unknown Sieve capability `fileinto'.
Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: after: line 4: error: unknown command 'fileinto' (only reported once at first occurrence).
Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: after: error: validation failed.
Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: sievec: Fatal: failed to compile sieve script '/var/lib/dovecot/sieve/after'

@RaitoBezarius
Copy link
Member

@RaitoBezarius
Copy link
Member

After manual fixups, that is adding:

  services.dovecot2.sieve = {
    plugins = [ "sieve_imapsieve" "sieve_extprograms" ];
    extensions = [ "fileinto" ];
    globalExtensions = [ "+vnd.dovecot.pipe" "+vnd.dovecot.environment" ];
  };

It still complains with:

Jan 14 20:43:39 amadeus dovecot2-pre-start[3701122]: sievec: Error: stats: open(/run/dovecot2/old-stats-mail) failed: No such file or directory
Jan 14 20:43:39 amadeus dovecot2-pre-start[3701174]: sievec: Error: stats: open(/run/dovecot2/old-stats-mail) failed: No such file or directory
Jan 14 20:43:40 amadeus dovecot2-pre-start[3701175]: sievec: Error: stats: open(/run/dovecot2/old-stats-mail) failed: No such file or directory

but is now not broken anymore.

RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
@2xsaiko
Copy link
Contributor Author

2xsaiko commented Jan 14, 2024

Jan 14 20:43:39 amadeus dovecot2-pre-start[3701122]: sievec: Error: stats: open(/run/dovecot2/old-stats-mail) failed: No such file or directory
Jan 14 20:43:39 amadeus dovecot2-pre-start[3701174]: sievec: Error: stats: open(/run/dovecot2/old-stats-mail) failed: No such file or directory
Jan 14 20:43:40 amadeus dovecot2-pre-start[3701175]: sievec: Error: stats: open(/run/dovecot2/old-stats-mail) failed: No such file or directory

Hmm, that most likely comes from line 31 in dovecot-2.3.21/src/lib-old-stats/stats-connection.c which is called from line 394 in dovecot-2.3.21/src/plugins/old-stats/stats-plugin.c. Are you sure that error wasn't there before? This change isn't loading the old-stats plugin and I'm not getting that error either (it's also deprecated). Either way, it shouldn't be fatal from what I can see.

@RaitoBezarius
Copy link
Member

RaitoBezarius commented Jan 14, 2024 via email

idx: el:
singleton "imapsieve_mailbox${toString idx}_name = ${el.name}"
++ optional (el.from != null) "imapsieve_mailbox${toString idx}_from = ${el.from}"
++ optional (el.causes != null) "imapsieve_mailbox${toString idx}_causes = ${el.causes}"
Copy link
Member

Choose a reason for hiding this comment

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

This should have been a list, I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, it should have. My bad!

RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 14, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
@dr460nf1r3
Copy link
Member

@2xsaiko This broke my production deployment of dovecot2 with the following error:

Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: sievec: Error: stats: open(/run/dovecot2/old-stats-mail) failed: No such file or directory
Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: after: line 1: error: require command: unknown Sieve capability `fileinto'.
Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: after: line 4: error: unknown command 'fileinto' (only reported once at first occurrence).
Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: after: error: validation failed.
Jan 14 18:34:30 amadeus dovecot2-pre-start[3655287]: sievec: Fatal: failed to compile sieve script '/var/lib/dovecot/sieve/after'

I can confirm this is an issue. We ran into it after a flake bump yesterday. Can test the PR if desired.

2xsaiko pushed a commit to 2xsaiko/nixpkgs that referenced this pull request Jan 20, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
beardhatcode added a commit to beardhatcode/nixpkgs that referenced this pull request Jan 22, 2024
RaitoBezarius added a commit to RaitoBezarius/nixpkgs that referenced this pull request Jan 23, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RaitoBezarius added a commit that referenced this pull request Jan 25, 2024
…ipts`

#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
2xsaiko pushed a commit to 2xsaiko/nixpkgs that referenced this pull request Jan 29, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
chayleaf pushed a commit to chayleaf/nixpkgs that referenced this pull request Jan 30, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
beardhatcode added a commit to beardhatcode/nixpkgs that referenced this pull request Feb 6, 2024
2xsaiko pushed a commit to 2xsaiko/nixpkgs that referenced this pull request Feb 23, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
beardhatcode added a commit to beardhatcode/nixpkgs that referenced this pull request Mar 1, 2024
2xsaiko pushed a commit to 2xsaiko/nixpkgs that referenced this pull request Mar 12, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
beardhatcode added a commit to beardhatcode/nixpkgs that referenced this pull request Mar 13, 2024
chayleaf pushed a commit to chayleaf/nixpkgs that referenced this pull request Mar 19, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
RyanGibb pushed a commit to RyanGibb/nixos-mailserver that referenced this pull request Mar 21, 2024
Since NixOS/nixpkgs#275031 things have became more structured
when it comes to the sieve plugin.

Relies on NixOS/nixpkgs#281001 for full
features.


Former-commit-id: fe6d325397f35eecb51bc77d04cc1a805c98e249
2xsaiko pushed a commit to 2xsaiko/nixpkgs that referenced this pull request Mar 28, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
2xsaiko pushed a commit to 2xsaiko/nixpkgs that referenced this pull request Apr 24, 2024
…ipts`

NixOS#275031 introduced structured configuration
for the dovecot2 sieve plugin, by doing so, it broke SNM configuration doing Sieve configurations.

This attempts to fix up the public API to make it possible for SNM to pick up the pieces.
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

3 participants