Fixed Postfix permission issue

This commit is contained in:
Brian Zalewski 2023-11-05 05:06:54 +00:00
parent 8e08b982e5
commit 842e927ccc

View file

@ -101,8 +101,24 @@ if command -v postfix > /dev/null; then
logg info 'Forward user e-mail to root@localhost' logg info 'Forward user e-mail to root@localhost'
echo '{{ .user.username }}: root' | sudo tee -a /etc/aliases > /dev/null echo '{{ .user.username }}: root' | sudo tee -a /etc/aliases > /dev/null
fi fi
logg info 'Running newaliases to regenerate the alias database'
sudo newaliases ### Ensure old /etc/aliases.db is removed
if [ -f /etc/aliases.db ]; then
logg info 'Ensuring /etc/aliases.db is removed' && sudo rm -f /etc/aliases.db
else
logg info '/etc/aliases.db was not found'
fi
### Re-generate the /etc/aliases.db file
if [ -f /etc/aliases ]; then
logg info 'Ensuring proper permissions on the /etc/aliases file' && chown $(stat -c "%U:%G" /etc/sudoers) /etc/aliases
logg info 'Generating Postfix aliases' && sudo postalias /etc/aliases
else
logg warn '/etc/aliases is missing which is required for Postfix'
fi
# The `sudo newaliases` mode is probably used to regenerate the /etc/aliases.db
# but since we are removing it to ensure proper permissions, this method is commented out.
# logg info 'Running newaliases to regenerate the alias database' && sudo newaliases
else else
logg warn '/etc/aliases does not appear to exist' logg warn '/etc/aliases does not appear to exist'
fi fi