mmv

mailserver bootstrap script
git clone git://git.yotsev.xyz/mmv.git
Log | Files | Refs | README | LICENSE

commit 91dc06bbfceb7b6c740f38634336dc7548afc015
parent a11743cf36609b1ae4531b159bf7c888940164b0
Author: Petar Yotsev <petar@yotsev.xyz>
Date:   Wed, 16 Mar 2022 00:50:59 +0000

Fix password prompt
It is impossible to use a variable containing all special symbols in
shell without some interpretation. Because of this, the madduser and
mpasswd commands would produce wrong password hashes when supplying the
password. This commit exports the whole process to OpenBSD's encrypt
utility.

Diffstat:
Mfiles/madduser | 17++++++++---------
Mfiles/mpasswd | 13++++++-------
2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/files/madduser b/files/madduser @@ -26,14 +26,13 @@ if [ -n "$(grep "^$user@$domain" /etc/mail/virtuals 2> /dev/null)" ]; then return 1 fi -echo -n "Password: " -stty -echo -read password -stty echo -echo - -record="$(smtpctl encrypt "$password")" -record="$user@$domain:$record:vmail:2000:2000:/var/vmail/$domain/$user::userdb_mail=maildir:/var/vmail/$domain/$user" -echo "$record" >> /etc/mail/credentials +echo "Please enter a password." +password="$(encrypt -p)" + +record="$user@$domain:$password:vmail:2000:2000:/var/vmail/$domain/$user::userdb_mail=maildir:/var/vmail/$domain/$user" +echo "$record" >> /etc/mail/credentials echo "$user@$domain: vmail" >> /etc/mail/virtuals + +rcctl restart smtpd +rcctl restart dovecot diff --git a/files/mpasswd b/files/mpasswd @@ -26,14 +26,13 @@ if [ -z "$(grep "^$user@$domain" /etc/mail/virtuals 2> /dev/null)" ]; then return 1 fi -echo -n "Password: " -stty -echo -read password -stty echo -echo +echo "Please enter a password." +password=$(encrypt -p) -record="$(smtpctl encrypt "$password")" -record="$user@$domain:$record:vmail:2000:2000:/var/vmail/$domain/$user::userdb_mail=maildir:/var/vmail/$domain/$user" +record="$user@$domain:$password:vmail:2000:2000:/var/vmail/$domain/$user::userdb_mail=maildir:/var/vmail/$domain/$user" sed "s#^$user@$domain.*#$record#g" /etc/mail/credentials > temp-cred-file mv temp-cred-file /etc/mail/credentials + +rcctl restart smtpd +rcctl restart dovecot