Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 120365 - DSPAM 3.6.3 does not honor MySQL 4.1 setup
Summary: DSPAM 3.6.3 does not honor MySQL 4.1 setup
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Lim Swee Tat (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-25 19:36 UTC by steveb
Modified: 2006-02-13 07:39 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
mail-filter/dspam/files/dspam.cron (dspam.cron,4.26 KB, text/plain)
2006-01-25 20:17 UTC, steveb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description steveb 2006-01-25 19:36:27 UTC
The cron job for optimizing/purging DSPAM data in MySQL does not honor the new mysql_purge-4.1.sql script. I know that this is my error, since I wrote the original dspam.cron script. Anyway... the script needs changes and should probably look like this:

#!/bin/bash
# Remove old signatures and unimportant tokens from the DSPAM database

for foo in awk head tail
do
        DSPAM_Check_App="$(${foo} --version 2>&1)"
        if [[ "${DSPAM_Check_App/ *}" == "bash:" ]]
        then
                echo "Command ${foo} not found."
                exit 1
        fi
done

DSPAM_HOMEDIR="$(grep ^dspam /etc/passwd|awk -F : '{print $6}')"
[[ ! -d "${DSPAM_HOMEDIR}" ]] && exit 2

if [[ -f "${DSPAM_HOMEDIR}/mysql.data" ]]
then
        DSPAM_MySQL_PURGE_SQL=""
        DSPAM_MySQL_VER="$(mysql_config --version)"
        case "${DSPAM_MySQL_VER:0:3}" in
                "4.0")
                        [[ -f "${DSPAM_HOMEDIR}/config/mysql_purge.sql" ]] && DSPAM_MySQL_PURGE_SQL="${DSPAM_HOMEDIR}/config/mysql_purge.sql"
                        [[ -f "${DSPAM_HOMEDIR}/mysql_purge.sql" ]] && DSPAM_MySQL_PURGE_SQL="${DSPAM_HOMEDIR}/mysql_purge.sql"
                        ;;
                "4.1" | "5.0" )
                        [[ -f "${DSPAM_HOMEDIR}/config/mysql_purge-4.1.sql" ]] && DSPAM_MySQL_PURGE_SQL="${DSPAM_HOMEDIR}/config/mysql_purge-4.1.sql"
                        [[ -f "${DSPAM_HOMEDIR}/mysql_purge-4.1.sql" ]] && DSPAM_MySQL_PURGE_SQL="${DSPAM_HOMEDIR}/mysql_purge-4.1.sql"
                        ;;
                *)
                        echo "Unknown/unsupported MySQL Version ${DSPAM_MySQL_VER}"
                        ;;
        esac
        [[ "${DSPAM_MySQL_PURGE_SQL}" == "" ]] && exit 3
        [[ ! -f "/usr/bin/mysql" ]] && exit 4
        DSPAM_MySQL_HOST="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 1|tail -n 1)"
        DSPAM_MySQL_PORT="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 2|tail -n 1)"
        DSPAM_MySQL_USER="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 3|tail -n 1)"
        DSPAM_MySQL_PWD="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 4|tail -n 1)"
        DSPAM_MySQL_DB="$(cat ${DSPAM_HOMEDIR}/mysql.data|head -n 5|tail -n 1)"
        (/usr/bin/mysql -u ${DSPAM_MySQL_USER} -p"${DSPAM_MySQL_PWD}" ${DSPAM_MySQL_DB} < ${DSPAM_MySQL_PURGE_SQL}) 1>/dev/null 2>&1
        MYRC="$?"
        for foo in $(/usr/bin/mysql -u ${DSPAM_MySQL_USER} -p"${DSPAM_MySQL_PWD}" ${DSPAM_MySQL_DB} -e 'SHOW TABLES;' 2>&1 | grep -v "^+\|^Tables_in_${DSPAM_MySQL_DB}")
        do
                (/usr/bin/mysql -u ${DSPAM_MySQL_USER} -p"${DSPAM_MySQL_PWD}" ${DSPAM_MySQL_DB} -e "OPTIMIZE TABLE ${foo};") 1>/dev/null 2>&1
        done
        exit ${MYRC}
elif [[ -f "${DSPAM_HOMEDIR}/pgsql.data" ]]
then
        DSPAM_PgSQL_PURGE_SQL=""
        [[ -f "${DSPAM_HOMEDIR}/config/pgsql_purge.sql" ]] && DSPAM_PgSQL_PURGE_SQL="${DSPAM_HOMEDIR}/config/pgsql_purge.sql"
        [[ -f "${DSPAM_HOMEDIR}/pgsql_purge.sql" ]] && DSPAM_PgSQL_PURGE_SQL="${DSPAM_HOMEDIR}/pgsql_purge.sql"
        [[ "${DSPAM_PgSQL_PURGE_SQL}" == "" ]] && exit 3
        [[ ! -f "/usr/bin/psql" ]] && exit 4
        DSPAM_PgSQL_HOST="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 1|tail -n 1)"
        DSPAM_PgSQL_PORT="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 2|tail -n 1)"
        DSPAM_PgSQL_USER="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 3|tail -n 1)"
        DSPAM_PgSQL_PWD="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 4|tail -n 1)"
        DSPAM_PgSQL_DB="$(cat ${DSPAM_HOMEDIR}/pgsql.data|head -n 5|tail -n 1)"
        (PGUSER=${DSPAM_PgSQL_USER} PGPASSWORD=${DSPAM_PgSQL_PWD} /usr/bin/psql -U ${DSPAM_PgSQL_USER} -d ${DSPAM_PgSQL_DB} -p ${DSPAM_PgSQL_PORT} -h ${DSPAM_PgSQL_HOST} -f ${DSPAM_PgSQL_PURGE_SQL}) 1>/dev/null 2>&1
        exit $?
elif [[ -f "${DSPAM_HOMEDIR}/oracle.data" ]]
then
        DSPAM_Oracle_PURGE_SQL=""
        [[ -f "${DSPAM_HOMEDIR}/config/ora_purge.sql" ]] && DSPAM_Oracle_PURGE_SQL="${DSPAM_HOMEDIR}/config/ora_purge.sql"
        [[ -f "${DSPAM_HOMEDIR}/ora_purge.sql" ]] && DSPAM_Oracle_PURGE_SQL="${DSPAM_HOMEDIR}/ora_purge.sql"
        [[ "${DSPAM_Oracle_PURGE_SQL}" == "" ]] && exit 3
        [[ ! -f "/usr/bin/sqlplus" ]] && exit 4
        DSPAM_Oracle_DBLINK="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 1|tail -n 1)"
        DSPAM_Oracle_USER="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 2|tail -n 1)"
        DSPAM_Oracle_PWD="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 3|tail -n 1)"
        DSPAM_Oracle_SCHEMA="$(cat ${DSPAM_HOMEDIR}/oracle.data|head -n 4|tail -n 1)"
        (/usr/bin/sqlplus -s ${DSPAM_Oracle_USER}/${DSPAM_Oracle_PWD} @${DSPAM_Oracle_PURGE_SQL}) 1>/dev/null 2>&1
        exit $?
else
        [[ ! -f "/usr/bin/dspam_clean" ]] && exit 4
        /usr/bin/dspam_clean -s -p -u 1>/dev/null 2>&1
        exit $?
fi
Comment 1 steveb 2006-01-25 20:17:12 UTC
Created attachment 78131 [details]
mail-filter/dspam/files/dspam.cron

Ouch! When I created the dspam.cron file, then the home directory in passwd for dspam was /etc/mail/dspam. Now the new home is /var/spool/dspam. The dspam.cron file as it is today would never ever execute the MySQL / PostgreSQL / Oracle purge SQL scripts, since it would not find the *.data files in /var/spool/dspam. I changed this now in the attached dspam.cron file. Sorry for the error.

cheers

SteveB
Comment 2 Lim Swee Tat (RETIRED) gentoo-dev 2006-02-13 07:39:15 UTC
Included in the latest dspam-3.6.4