change password encryption from doveadm to openssl, avoids potential permissions issues with doveadm

This commit is contained in:
Matthew Saunders Brown 2022-09-12 16:27:21 -07:00
parent b9628f921a
commit f1f2fd9e9a
4 changed files with 4 additions and 5 deletions

View File

@ -51,7 +51,8 @@ rowcount=`mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -s -r -N -e "S
if [ "$rowcount" -eq '0' ] ; then
# mbox does not exist, build SQL
# first encrypt password
passwd=`doveadm -o stats_writer_socket_path= pw -s sha512-crypt -p "$password"`
passwd=`/usr/bin/openssl passwd -6 "$password"`
passwd="{SHA512-CRYPT}$passwd"
dbcmd="mysql --defaults-extra-file=$MYSQL_CONNECTION_INFO_FILE -e 'INSERT INTO vm_mboxes SET domain_id=\"$domain_id\", mbox=\"$mbox\", passwd=\"$passwd\""
if [[ -n $status ]] ; then
dbcmd="$dbcmd, status=\"$status\""

View File

@ -71,7 +71,8 @@ fi
# check for password update
if [ ! -z "$password" ]; then
passwd=`doveadm -o stats_writer_socket_path= pw -s sha512-crypt -p "$password"`
passwd=`/usr/bin/openssl passwd -6 "$password"`
passwd="{SHA512-CRYPT}$passwd"
if [ ! -z "$dbset" ]; then
dbset="$dbset,"
fi

View File

@ -131,7 +131,6 @@ cp -a etc/dovecot/* /etc/dovecot/
chgrp dovecot /etc/dovecot/dovecot-sql.conf.ext
chmod 640 /etc/dovecot/dovecot-sql.conf.ext
sed -i "s|password=password|password=$VMAILPASS|g" /etc/dovecot/dovecot-sql.conf.ext
chown -R vmail /etc/dovecot/conf.d/
if ! [ -d "/usr/local/libexec" ]; then
mkdir /usr/local/libexec
fi

View File

@ -58,8 +58,6 @@ for etc_config in "${etc_configs_array[@]}"; do
echo
fi
done
# make sure /etc/dovecot/conf.d/ is readable by vmail (needed for encrypting passwords with 'doveadm pw')
chown -R vmail /etc/dovecot/conf.d/
# update libexec script
if ! diff -q libexec/vmail-quota-warning.sh /usr/local/libexec/vmail-quota-warning.sh ; then