From 8c0627a6fc13848e7d76f641f6e8c295219e7e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Peters?= Date: Sun, 22 Dec 2019 16:52:45 +0100 Subject: [PATCH] Update u_e-dovecot-mail-crypt.md --- docs/u_e-dovecot-mail-crypt.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/u_e-dovecot-mail-crypt.md b/docs/u_e-dovecot-mail-crypt.md index 6850ed7d7..d211df44b 100644 --- a/docs/u_e-dovecot-mail-crypt.md +++ b/docs/u_e-dovecot-mail-crypt.md @@ -10,9 +10,13 @@ find /var/vmail/ -type f -regextype egrep -regex '.*S=.*W=.*' | while read -r fi if [[ $(head -c7 "$file") == "CRYPTED" ]]; then doveadm fs get crypt private_key_path=/mail_crypt/ecprivkey.pem:public_key_path=/mail_crypt/ecpubkey.pem:posix:prefix=/ \ "$file" > "/tmp/$(basename "$file")" - chmod 600 "/tmp/$(basename "$file")" - chown 5000:5000 "/tmp/$(basename "$file")" - mv "/tmp/$(basename "$file")" "$file" + if [[ -s "/tmp/$(basename "$file")" ]]; then + chmod 600 "/tmp/$(basename "$file")" + chown 5000:5000 "/tmp/$(basename "$file")" + mv "/tmp/$(basename "$file")" "$file" + else + rm "/tmp/$(basename "$file")" + fi fi done