Postfixが実行中です。 Maldetレポートを郵送しようとしてエラーが発生した理由はわかりません。
[root@do ~]# maldet --report 170321-0115.21534 [email protected]
Linux Malware Detect v1.6
(C) 2002-2017, R-fx Networks <[email protected]>
(C) 2017, Ryan MacDonald <[email protected]>
This program may be freely redistributed under the terms of the GNU GPL v2
/usr/local/maldetect/internals/functions: line 608: -s: command not found
maldet(18718): {report} report ID 170321-0115.21534 sent to [email protected]
これは608番目の縮小です
if [ -f "$sessdir/session.$rid" ] && [ ! -z "$(echo $2 | grep '\@')" ]; th$
cat $sessdir/session.$rid | $mail -s "$email_subj" "$2"
eout "{report} report ID $rid sent to $2" 1
exit
答え1
$mail変数は、mailコマンドがまだインストールされていないため空です。
実行apt-get install mailx
(debianまたはubuntu)またはyum install -y mailx
(centosまたはredhat)
答え2
一部の設定では、欠落しているコマンドによってmail
次のエラーが発生します。/usr/local/maldetect/internals/functions: line 647: -s: command not found
既にインストールしている場合は、sendmail
次の違いを使用してsendmail
電子メール転送サポートを追加できます。
diff --git a/files/internals/functions b/files/internals/functions
index f3e0a1a..acdb1b9 100644
--- a/files/internals/functions
+++ b/files/internals/functions
@@ -108,6 +108,10 @@ prerun() {
if [ ! -f "$mail" ] || [ -z "$mail" ]; then
email_alert=0
fi
+
+ if [ "$email_alert" == "0" ] && [ -f "$sendmail" ]; then
+ email_alert=1
+ fi
if [ ! -f "$sig_cust_hex_file" ]; then
touch $sig_cust_hex_file
@@ -644,8 +648,19 @@ view_report() {
fi
fi
if [ -f "$sessdir/session.$rid" ] && [ ! -z "$(echo $2 | grep '\@')" ]; then
- cat $sessdir/session.$rid | $mail -s "$email_subj" "$2"
- eout "{report} report ID $rid sent to $2" 1
+ if [ -f "$mail" ]; then
+ cat $sessdir/session.$rid | $mail -s "$email_subj" "$2"
+ elif [ -f "$sendmail" ]; then
+ if ! grep -q "SUBJECT: " "$sessdir/session.$rid"; then
+ echo -e "SUBJECT: $email_subj\n$(cat $sessdir/session.$rid)" > $sessdir/session.$rid
+ fi
+ cat $sessdir/session.$rid | $sendmail -t "$2"
+ else
+ eout "{scan} no \$mail or \$sendmail binaries found, e-mail alerts disabled."
+ exit
+ fi
+
+ eout "{report} report ID $rid sent to $2" 1
exit
fi
if [ "$rid" == "" ] && [ -f "$sessdir/session.last" ]; then
@@ -1073,8 +1088,8 @@ scan() {
eout "{scan.hook} scan of $spath in progress (id: $datestamp.$$)"
fi
cnt=0
- if [ -z "$mail" ]; then
- eout "{scan} no \$mail binary found, e-mail alerts disabled."
+ if [ -z "$mail" ] && [ -z "$sendmail" ]; then
+ eout "{scan} no \$mail or \$sendmail binaries found, e-mail alerts disabled."
fi
if [ -f "$clamscan" ] && [ "$scan_clamscan" == "1" ]; then
if [ -z "$hscan" ]; then
@@ -1309,7 +1324,16 @@ genalert() {
file="$2"
if [ "$email_alert" == "1" ] || [ "$type" == "digest" ] || [ "$type" == "daily" ]; then
if [ "$type" == "file" ] && [ -f "$file" ]; then
- cat $file | $mail -s "$email_subj" $email_addr
+ if [ -f "$mail" ]; then
+ cat $file | $mail -s "$email_subj" $email_addr
+ elif [ -f "$sendmail" ]; then
+ if ! grep -q "SUBJECT: " "$file"; then
+ echo -e "SUBJECT: $email_subj\n$(cat $file)" > $file
+ fi
+ cat $file | $sendmail -t $email_addr
+ else
+ eout "{scan} no \$mail or \$sendmail binaries found, e-mail alerts disabled."
+ fi
if [ ! "$(whoami)" == "root" ] && [ -z "$(echo $2 | grep '\@')" ]; then
if [ -z "$hscan" ]; then
eout "{alert} sent scan report to config default $email_addr" 1
@@ -1353,8 +1377,18 @@ genalert() {
grep -E '^{.*}' $sessdir/session.$scanid > $sessdir/session.hits.$scanid
echo "$scanid" > $sessdir/session.last
email_subj="${email_subj}: monitor summary"
- cat $tmpf | $mail -s "$email_subj" $email_addr
- eout "{alert} sent $type alert to $email_addr"
+ if [ -f "$mail" ]; then
+ cat $tmpf | $mail -s "$email_subj" $email_addr
+ eout "{alert} sent $type alert to $email_addr"
+ elif [ -f "$sendmail" ]; then
+ if ! grep -q "SUBJECT: " "$tmpf"; then
+ echo -e "SUBJECT: $email_subj\n$(cat $tmpf)" > $tmpf
+ fi
+ cat $tmpf | $sendmail -t $email_addr
+ eout "{alert} sent $type alert to $email_addr"
+ else
+ eout "{scan} no \$mail or \$sendmail binaries found, e-mail alerts disabled."
+ fi
rm -f $tmpf $tmpdir/.digest.alert.hits $tmpdir/.digest.clean.hits $tmpdir/.digest.monitor.alert $tmpdir/.digest.susp.hits
fi
else
diff --git a/files/internals/internals.conf b/files/internals/internals.conf
index c998fd3..1291960 100644
--- a/files/internals/internals.conf
+++ b/files/internals/internals.conf
@@ -44,6 +44,7 @@ cpulimit=`which cpulimit 2> /dev/null`
ionice=`which ionice 2> /dev/null`
wc=`which wc 2> /dev/null`
mail=`which mail 2> /dev/null`
+sendmail=`which sendmail 2> /dev/null`
pidof=`which pidof 2> /dev/null`
sed=`which sed 2> /dev/null`
stat=`which stat 2> /dev/null`
--
1.8.3.2
実際のコミットは以下のリンクで確認できます。
上記はLinux Malware Detect v1.6.1に基づいています。