Opened 4 years ago

Closed 4 years ago

#1454 closed defect (fixed)

Mail is only sent one recipient from the -m list, not counting plugins (smartd), the last one.

Reported by: lockywolf Owned by: Christian Franke
Priority: major Milestone: Release 7.3
Component: smartd Version: 7.2
Keywords: smartd.conf Cc:

Description

I have the following problem:

My smartd.conf is the following:

DEVICESCAN -d removable -n standby,15 -I 194 -I 9 -R 194 -R 180 -R 232 -R 5 -R 197 \

-a -o on -S on -s (S/../.././02|L/../../6/03) \
-m root@localhost,lockywolf@localhost,@lwf_first-try.bash -M daily -M test

lwf_first-try is a simple script that just prints the execution date into a file.

In this case, when smartd is restarted:
/usr/sbin/smartd -p /run/smartd.pid --attributelog=/var/log/smartd/ --savestates=/var/log/smartd/ &

The plugin runs, and lockywolf received the message, but not root.
I tried playing with the -m list, for example, by swapping lockywolf and root, and by adding more lockywolf@localhost and root@localhost entries, and it seems that only the last address is getting the message.

The mail command is mailx from s-nail.
lockywolf@delllaptop:~$ readlink /usr/bin/mail
mailx

Change History (6)

comment:1 by lockywolf, 4 years ago

I just tried it with mailutils instead of s-nail, and it seems to behave identically.

comment:2 by Christian Franke, 4 years ago

Keywords: smartd.conf added; mail mailx s-nail notification removed
Owner: set to Christian Franke
Status: newaccepted

Thanks for reporting this longstanding bug introduced 8+ years ago in r3712.

PS: Please do not set the Milestone in future submissions.

comment:3 by Christian Franke, 4 years ago

Possible workaround:

Add this script as e.g. mail.sh to smartd_warning.d:

#!/bin/sh
exec mail -s "$SMARTD_SUBJECT" root@localhost lockywolf@localhost <<EOF
$SMARTD_FULLMESSAGE
EOF

Then change -m in smartd.conf to: -m @mail.sh,@lwf_first-try.bash.

Could be tested without running smartd by:

SMARTD_ADDRESS='@mail.sh @lwf_first-try.bash' /script/path/smartd_warning.sh

Add --dryrun to print commands only.

See -w command line option in smartd -h output or smartd man page for the configured script path.

comment:4 by Christian Franke, 4 years ago

Possible local fix:

  • smartd_warning.sh

    old new  
    168168          fi
    169169          ;;
    170170        *)
    171           SMARTD_ADDRESS="${SMARTD_ADDRESS:+ }$ad"
     171          SMARTD_ADDRESS="${SMARTD_ADDRESS}${SMARTD_ADDRESS:+ }$ad"
    172172          ;;
    173173      esac
    174174    done

comment:5 by lockywolf, 4 years ago

The "Possible local fix" seems to work, thank you.

comment:6 by Christian Franke, 4 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.