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
dovecot: Fix sieve scripts #21864
dovecot: Fix sieve scripts #21864
Conversation
Make sure that the output of the sieve compiler produces files that have a newer time stamp than the source sieve script. Otherwise you get errors in the logs about Dovecot not being able to compile do to a permission issue.
preStart = '' | ||
rm -rf ${stateDir}/sieve | ||
'' + optionalString (cfg.sieveScripts != {}) '' | ||
mkdir -p ${stateDir}/sieve | ||
${concatStringsSep "\n" (mapAttrsToList (to: from: '' | ||
if [ -d '${from}' ]; then | ||
mkdir '${stateDir}/sieve/${to}' | ||
cp "${from}/"*.sieve '${stateDir}/sieve/${to}' | ||
cp -p "${from}/"*.sieve '${stateDir}/sieve/${to}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By newer you mean the same timestamp as their source files?
Does Dovecot recompile the sieve scripts based on their mtime or their content? With this change, all sieve files would have the same mtime. |
Could manual compilation be an option? http://wiki2.dovecot.org/Pigeonhole/Sieve/Usage#scriptcompile |
Dovecot compares the time stamps of the sieve source files and compiled scripts. If the source file is newer than the compiled file Dovecot will attempt to recompile. But, when it does, it's already running as another user and doesn't have permission to write to the sieve directory. This change ensures that the source files will always have a time stamp that is older than the compiled version so Dovecot won't try to recompile on the fly. (Which isn't needed since they are compiled by the pre-start script.) |
Just to be clear, the Another solution might be to just compile the sieve scripts from the Nix store and store the compiled output in the state directory. I haven't tested this so I don't know if Dovecot supports a directory with compiled sieve scripts where the source files are missing. |
Thanks. Now it make sense to me. |
Motivation for this change
Make sure that the output of the sieve compiler produces files that
have a newer time stamp than the source sieve script. Otherwise you
get errors in the logs about Dovecot not being able to compile do to a
permission issue.
This change is running in production via NixOps.
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)