chore(encryption): support for passworded user email storage encryption keys#2080
chore(encryption): support for passworded user email storage encryption keys#2080NorseGaud wants to merge 9 commits intodocker-mailserver:masterfrom NorseGaud:issues/2058
Conversation
wernerfred
left a comment
There was a problem hiding this comment.
Overall: nice addition!
Please see the comments in the review below.
Also please make sure to mirror the changes you introduced to setup.sh to the corresponding docs site that it reflects the current state.
Waiting for reply and further reviews 👀
will do! |
|
Current state: I want to avoid writing tests for now until the overall changes I made are reviewed by a few people. That way I'm minimizing time spent on rewrites. |
|
Accidentally rebased again. I hope this is fine this time, otherwise excuse me again and force-push over it 🙈 |
|
Bad habits never die 😅 |
|
I don't mind reviewing, but will be busy until early next week. Unfortunately no time until then due to a deadline. |
|
There is no rush for this |
DavyLandman
left a comment
There was a problem hiding this comment.
I just read a few pieces, really nice that you are integrating it into the existing scripts!
|
An opportunity for a PR if someone has time: check-for-changes.sh doesn't start on the very first start of the container and if no email is created. Where there is needed improvement is for the setup-stack.sh to loop at |
|
Yes, that sounds good!
…On Tue, Jul 13, 2021, 15:15 Nathan Pierce ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In docs/content/config/security/mail_crypt.md
<#2080 (comment)>
:
> +
+1. Create `10-custom.conf` and populate it with the following:
+
+ ```
+ mail_attribute_dict = file:%h/Maildir/dovecot-attributes
+ mail_plugins = $mail_plugins mail_crypt
+ mail_debug= yes
+
+ plugin {
+ mail_crypt_curve = secp521r1
+ mail_crypt_save_version = 2
+ mail_crypt_require_encrypted_user_key = yes
+ }
+ ```
+
+2. Create `auth-passwdfile.inc` and populate it with the following:
Thanks for clarifying. Give me a few days to consider how to do this and
get back. I think the issue with that is now the user encryption
keys/password stuff becomes an official feature -- which I'm totally fine
with but maybe the maintainers don't agree! This would make sense since I
added features in setup.sh for it, so it's already sort of a built-in
feature in many ways. We can easily allow users to set an ENV to enable it
and then even change the setup.sh to check for that ENV and automatically
run the doveadm commands instead of requiring users to set -g or -c.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2080 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABL3E24CA4UNJBP3CTMPSDTXQ37NANCNFSM5ACZ33OA>
.
|
|
Documentation preview for this PR is ready! 🎉 Built with commit: fc6a4b2 |
|
Is there a workaround that might be fine for now? (One that avoids destroying containers Everytime you add a new user?) |
I would appreciate if someone else could pick this up and contact dovecot. I've recently become too overwhelmed with travel, work, and another side project to continue with this. |
|
I'll take it over, but it is low priority for me, I should be able to work on it by december hopefully 👍 Once the hostname and related changes I've been sorting out are all merged, a v10.3 release can be done and this PR should be able go from there for v11 release. |
|
I'd close this as is, but I feel like at least two persons will reach out and tell me this will be worked on. Hence, I will just move it to v13.0.0, because it is unlikely going into v12.0.0. |
|
I don't know if it helps, but I've been using a setup like this. Using only The encrypted mails are working quite nicely. Except I didn't do (yet) @polarathene idea of using But at some point I hope to switch the custom user-patches out, but I fully understand this will take effort to develop. And open source motivation comes from your own case, not from others. So here is hoping I'll find some time to properly take a swing at this, but I don't expect to find that time anywhere soon. FYI: This is my setup. I WOULD NOT ADVICE ANYONE DOING THIS! You have to review changes to the patched files for every release: 10-crypt.conf: user-patches.sh: #!/bin/bash
TARGET='/etc/dovecot/conf.d/auth-passwdfile.inc'
ADDEDLINE='override_fields = userdb_mail_crypt_private_password=%{sha256:password} userdb_mail_crypt_save_version=2'
if ! grep -Fq "$ADDEDLINE" $TARGET; then
sedfile -i 's|^\( args = scheme.*userdb\)|\1\n'"$ADDEDLINE"'|' $TARGET
fi
TARGET='/usr/local/bin/addmailuser'
if ! grep -Fq "mail_crypt_private_password" $TARGET; then
cat << 'EOF' >> "$TARGET"
while [[ $(stat -c '%U' "/var/mail/${DOMAIN}/${USER}") != docker ]] # handle slow ownership setting problem
do
echo "Waiting for proper owner to be set on /var/mail/${DOMAIN}/${USER}..."
sleep 1
done
doveadm -o plugin/mail_crypt_private_password="$(echo -n "${PASSWD}" | sha256sum | awk '{print $1}')" mailbox cryptokey generate -u "${FULL_EMAIL}" -U
EOF
fi
TARGET='/usr/local/bin/updatemailuser'
if ! grep -Fq "mail_crypt_private_password" $TARGET; then
cat << 'EOF' >> "$TARGET"
FULL_EMAIL="${USER}@${DOMAIN}"
USER="${FULL_EMAIL%@*}"
DOMAIN="${FULL_EMAIL#*@}"
if [[ ! -f "/var/mail/${DOMAIN}/${USER}/.attributes" ]] # create key if it doesn't exist already
then
doveadm -o plugin/mail_crypt_private_password="$(echo -n "${PASSWD}" | sha256sum | awk '{print $1}')" mailbox cryptokey generate -u "${FULL_EMAIL}" -U
else
if [[ -z "${CRYPTOKEY_UPDATE_PASSWORD}" ]]
then
read -r -s -p "Enter Old Password (to update encryption key): " CRYPTOKEY_UPDATE_PASSWORD
echo
[[ -z ${CRYPTOKEY_UPDATE_PASSWORD} ]] && _exit_with_error "old encryption password must not be empty"
fi
doveadm mailbox cryptokey password -u "${FULL_EMAIL}" -n "$(echo -n "${PASSWD}" | sha256sum | awk '{print $1}')" -o "$(echo -n "${CRYPTOKEY_UPDATE_PASSWORD}" | sha256sum | awk '{print $1}')"
fi
EOF
ficustom mounts: volumes:
- ./config/dms:/tmp/docker-mailserver # get user patches
- ./config/dms/10-crypt.conf:/etc/dovecot/conf.d/10-crypt.conf:ro # add config |
I've had something 90% complete since August 2022, but:
I actually was looking into revisiting it roughly a week ago to adapt to all the v12 changes, but received more issues and reviews to go over (which I'm slow at), among other commitments outside of DMS also reaching out for their own time-sensitive needs. I'm exhausted.
I was wanting to tackle this in Jan, but needed to prioritize other activity within the project that came up. With v12 release, hopefully that settles down so I can allocate time to getting this wrapped up (the tests definitely aren't going to rebase anymore). I can't make any promises if I have to shift priorities elsewhere, I have a backlog building up outside of DMS and really should be focusing on job search 😅 I'll do my best to at least get the work adjusted and pushed up as a draft PR in the event I am unable to finish it. |
Damn, sorry about that. I did not mean to pile on. I think this project is doing great, and looking at it's history, it's kinda impressive you all manage to keep it running like this, even with multiple people coming and leaving. So yeah, focus on that job search, and this issue will get back later, once you have the space. |
|
Closing this for now. Reason: This PR has become stale. If you want to pick up these changes, please do so :) We encourage everyone to further work on this, and apply these changes and updates to the most recent version of Related: #3289 (comment) |

Description
ENABLE_PER_USER_STORAGE_ENCRYPTIONin their docker-compose to enable the featurePER_USER_STORAGE_ENCRYPTION_CURVEand default tosecp521r1PER_USER_STORAGE_ENCRYPTION_SCHEMEand default toCRYPTRelated issue: #2058
Related: #2134
Type of change
Checklist:
docs/)