Closed The-M1k3y closed 6 years ago
Hi, sorry for the inconvenience. That indeed looks like the problem. I think we can fix this by putting single quotes around https://github.com/r-raymond/nixos-mailserver/blob/b75575f02e90c208bdd68549e3967ad7fb3bfd1d/mail-server/users.nix#L64. But my bash is weak, so maybe someone else can weigh in. I think you could maybe escape the ${1}
in your script to work around the problem for now (but we should fix this nevertheless).
Thanks for using SNM!
Yes, escaping the ${1}
in the script works. I guess the way to go is to change line 63 in nixos-mailserver/mail-server/users.nix to cat << 'EOF' > "/var/sieve/${name}/default.sieve"
. This way cat should ignore all dollars.
Alternatively you could have a look at lib.pkgs.writeText. It seems to be used by most services in the nix store. But like your bash is weak, my nix is bad. So don't take my word for it.
@The-M1k3y Thanks for the verification.
@eqyiel do you have an opinion on which of the proposed solutions is better? Any reason you did not use a nix function to write the scripts?
@r-raymond I wasn't sure whether the files created by writeText
would be garbage collected if I symlinked them here. If it's the same to you, please consider https://github.com/r-raymond/nixos-mailserver/pull/73
@The-M1k3y I've tried the example mentioned in the PR, but could you please see if it works for you too?
Hi there,
the configuration fails to build when using variables in sieve scripts.
This is the configuration I use:
loginAccounts= { "catcher@example.com" = { hashedPassword = "password"; catchAll = [ "example.com" ]; sieveScript = '' require ["fileinto", "variables", "mailbox"]; if address :matches ["To", "Cc"] ["*.example.com"] { fileinto :create "catcher.''${2}"; } ''; }; };
This leads to the following "activate-virtual-mail-user" script: `... cat << EOF > "/var/sieve/catcher@m1k3y.de.sieve" require ["fileinto", "variables", "mailbox"]; if address :matches ["To", "Cc"] "*.m1k3y.de" { fileinto :create "${1}"; stop; }
EOF`
which ends in an error "activate-virtual-mail-users: line 21: 1: unbound variable"
As far as I can see the problem here is the resulting ${1} in the script, that gets interpreted instead of being printed.