Setting up Rkhunter with MIAB

Hi,

I decided to check my VPS for viruses, etc. as my domain got recently blacklisted by Barracuda and decided to install rkhunter. However, there is one thing bugging me in its configuration - rkhunter uses mailutils to send out mail after it finds something. Before messing about with mailutils, I thought I’d ask if there’s anything already installed on Mailinabox that I can utilize to let rkhunter automatically be able to send out warnings about viruses.

In rkhunter’s config file, it uses this command to send out mail -
MAIL_CMD=mail -s "[rkhunter] Warnings found for ${HOST_NAME}"

Is there anything similar on Mailinabox, so I can substitute the mail command with something else?

Thanks a lot!

Mailinabox uses a python library for mail sending. You can see an example in: ~/mailinabox/management/email_administrator.py where it calls

smtpclient.sendmail()

so I just substitute mail with sendmail? Will it work?

No, that’s a different package. The file I referenced would show you an example of how to use the python library.

I’ve been using rkhunter for quite awhile with success. Rather than installing mail-utils, I just created a script that I placed in /usr/bin/mail (where rkhunter was expecting it). All the script does is translate rkhunter emails into a call to sendmail. It is below

#!/bin/bash
# Save the command-line information passed to the function
# so that I can translate info to call sendmail
if read -t 0; then
  message=`cat`
fi
script="$0"

for arg in "$@"; do
  if [ "$lastarg" == "-s" ]; then
    subject="$arg"
  fi
  if [[ $arg =~ [[:space:]] ]]; then
    arg=\"$arg\"
  fi
  lastarg="$arg"
done

# send message using sendmail
echo "Subject: $subject

$message" | sendmail -F "`hostname -f`" "$lastarg"

This topic was automatically closed after 61 days. New replies are no longer allowed.