Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 61439 - rkhunter crontab fails w/o mail command
Summary: rkhunter crontab fails w/o mail command
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: solar (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-23 15:03 UTC by Smutt
Modified: 2004-08-24 15:34 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Smutt 2004-08-23 15:03:01 UTC
I use postfix so I don't get a UNIX mail command only postfix version of sendmail.  Because of this the packaged crontab doesn't work.  I rewrote it to check which mail command people have on their box.  Tell me what you think.  It may be overkill.

#!/bin/sh

### Begin Configuration ###

# set this to 'yes' to enable
ENABLE=no

RKHUNTER_EXEC="/usr/bin/rkhunter"
RKHUNTER_OPTS="--checkall --cronjob --skip-keypress"

# set to 'yes' if you wish the output to be mailed to you
SEND_EMAIL=no

# NOTE: the rest of these options are only relevant
# if you set SEND_EMAIL to 'yes'

FQDN=`hostname -f`
EMAIL_RECIPIENT=root@$FQDN
if [ ! `which mail` == "" ]; then
    EMAIL_SUBJECT="${HOSTNAME}: rkhunter output"
    EMAIL_CMD="| mail -s \"${EMAIL_SUBJECT}\" ${EMAIL_RECIPIENT}"
else
    EMAIL_FROM=rkhunter@$FQDN
    EMAIL_CMD="| sendmail -r \"${EMAIL_SENDER}\" ${EMAIL_RECIPIENT}"
if

# set to 1 to recieve only warnings & errors
# set to 2 to recieve ALL rkhunter output
# set to 3 to recieve rkhunter report
EMAIL_VERBOSITY=3

### End Configuration ###

if [ "${ENABLE}" = "yes" ]; then
        CMD="${RKHUNTER_EXEC} ${RKHUNTER_OPTS}"

        if [ "${SEND_EMAIL}" = "yes" ]; then
                if [ "${EMAIL_VERBOSITY}" -eq 1 ]; then
                        CMD="${CMD} --quiet ${EMAIL_CMD}"
                elif [ "${EMAIL_VERBOSITY}" -eq 2 ]; then
                        CMD="${CMD} ${EMAIL_CMD}"
                else # default to report-mode
                        CMD="${CMD} --report-mode ${EMAIL_CMD}"
                fi
        else
                CMD="${CMD} &>/dev/null"
        fi

        eval exec "${CMD}"
fi




Reproducible: Always
Steps to Reproduce:
1.
2.
3.
Comment 1 Smutt 2004-08-23 16:00:43 UTC
My script is really broken.  My bad.  Here's one that works.

#!/bin/sh

### Begin Configuration ###

# set this to 'yes' to enable
ENABLE=yes

RKHUNTER_EXEC="/usr/bin/rkhunter"
RKHUNTER_OPTS="--checkall --cronjob --skip-keypress"

# set to 'yes' if you wish the output to be mailed to you
SEND_EMAIL=yes

# NOTE: the rest of these options are only relevant
# if you set SEND_EMAIL to 'yes'

FQDN=`hostname -f`
EMAIL_RECIPIENT=root@$FQDN
if [ -x /usr/sbin/mail  ]; then
    EMAIL_SUBJECT="${HOSTNAME}: rkhunter output"
    EMAIL_CMD="| mail -s \"${EMAIL_SUBJECT}\" ${EMAIL_RECIPIENT}"
else
    EMAIL_FROM=rkhunter@$FQDN
    EMAIL_CMD="| sendmail -r \"${EMAIL_FROM}\" ${EMAIL_RECIPIENT}"
fi

# set to 1 to recieve only warnings & errors
# set to 2 to recieve ALL rkhunter output
# set to 3 to recieve rkhunter report
EMAIL_VERBOSITY=3

### End Configuration ###

if [ "${ENABLE}" = "yes" ]; then
        CMD="${RKHUNTER_EXEC} ${RKHUNTER_OPTS}"

        if [ "${SEND_EMAIL}" = "yes" ]; then
                if [ "${EMAIL_VERBOSITY}" -eq 1 ]; then
                        CMD="${CMD} --quiet ${EMAIL_CMD}"
                elif [ "${EMAIL_VERBOSITY}" -eq 2 ]; then
                        CMD="${CMD} ${EMAIL_CMD}"
                else # default to report-mode
                        CMD="${CMD} --report-mode ${EMAIL_CMD}"
                fi
        else
                CMD="${CMD} &>/dev/null"
        fi

        eval exec "${CMD}"
fi
Comment 2 Aaron Walker (RETIRED) gentoo-dev 2004-08-24 02:15:04 UTC
Originally, the whole point of adding the EMAIL_CMD variable was so that it was 
configurable by the user; I'm not sure what the difference is between assuming the 
mail command exists and your solution (if mail doesn't exists, assume sendmail 
does). 

IMO, it's fine as is (it's meant to be changed by the user to the best suitable 
option).  Also, the addition of conditional code to the config section makes it 
MUCH less readable by someone that doesn't have any experience reading shell 
scripts.

solar, what is your $0.02?
Comment 3 solar (RETIRED) gentoo-dev 2004-08-24 11:44:27 UTC
My $00.2 is that you Aaron Walker are the maintainer of rkhunter and I'm your cvs proxy. You have been here from the start and I'm going to CC: you on every bug that comes up for rkhunter from here till the end of time or you become a developer and can take the pkg off my hands. 
If you feel this is how it should be or not done fine. 
As you know I was not keen on the crontab stuff in the first place. So shrug..
Comment 4 Smutt 2004-08-24 14:55:31 UTC
After reading your explanation I would have to agree with you.  Leaving it the way it is for the reasons you suggested is probably the simplist thing to do.  It also keeps things like 'if' statements from the config section.

--Smutt
Comment 5 solar (RETIRED) gentoo-dev 2004-08-24 15:34:36 UTC
ok closing as WONTFIX then.