Permission denied /.spamassassin/bayes_* R/O

I can’t reproduce it on my system so here the workaround.

Edit /etc/dovecot/sieve/scan_reported_mails and add this code before the last line :

# Workaround to sa-learn changing owner of bayes_toks to root
BAYES_TOKS="${SPAMD_USER_HOMEDIR}/.spamassassin/bayes_toks"
if ! stat -c %U "${BAYES_TOKS}" | grep -q "${SPAMD_USER}"; then
    chown "${SPAMD_USER}":"${SPAMD_USER}" "${BAYES_TOKS}"
fi

So you will have something like:

[...]
rmdir ${SPOOL_LEARN_HAM_DIR} &>/dev/null
if [[ X"$?" != X'0' ]]; then
    output="$(${SA_LEARN} --ham ${SPOOL_LEARN_HAM_DIR})"
    rm -rf ${SPOOL_LEARN_HAM_DIR} &>/dev/null
    ${LOG} '[CLEAN]' ${output}
fi

# Workaround to sa-learn changing owner of bayes_toks to root
BAYES_TOKS="${SPAMD_USER_HOMEDIR}/.spamassassin/bayes_toks"
if ! stat -c %U "${BAYES_TOKS}" | grep -q "${SPAMD_USER}"; then
    chown "${SPAMD_USER}":"${SPAMD_USER}" "${BAYES_TOKS}"
fi

rm -f ${LOCK_FILE} &>/dev/null
3 Likes