smartd-runner bug causes loss of email recipients

Bug #1927980 reported by John Denker
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
smartmontools (Debian)
New
Unknown
smartmontools (Ubuntu)
Medium
Unassigned

Bug Description

*** Expected, documented, and desired behavior:

In /etc/smartd.conf it is permitted to specify multiple email recipients.
Here is the relevant snippet:

#######################
DEFAULT -d removable -n standby \
        -a -M test \
        -s S/../.././01 \
        -m root,jsd \
        -M exec /usr/share/smartmontools/smartd-runner
#######################

The last line is relevant, and the next-to-last line is super-relevant, insofar as it contains a comma-separated list of recipients.

The code in smartd itself handles this just fine, and always has.

*** Observed bad behavior:

I observe that the smartd-runner script throws away all recipients after the first.

*** Remark:

The root problem is that smartd-runner assumes it will be called with exactly three arguments.
It can be expected that this will cause multiple bugs, not just the one reported here.

*** Patch to fix the problem

A patch file is attached.

*** Platform details

ProblemType: Bug
ApportVersion: 2.20.11-0ubuntu27.17
Architecture: amd64
CasperMD5CheckResult: skip
CurrentDesktop: MATE
Date: Mon May 10 07:13:51 2021
Dependencies:
 debianutils 4.9.1
 gcc-10-base 10.2.0-5ubuntu1~20.04
 libc6 2.31-0ubuntu9.2
 libcap-ng0 0.7.9-2.1build1
 libcrypt1 1:4.4.10-10ubuntu4
 libgcc-s1 10.2.0-5ubuntu1~20.04
 libgcrypt20 1.8.5-5ubuntu1
 libgpg-error-l10n 1.37-1
 libgpg-error0 1.37-1
 libidn2-0 2.2.0-2
 liblz4-1 1.9.2-2
 liblzma5 5.2.4-1ubuntu1
 libpcre2-8-0 10.34-7
 libselinux1 3.0-1build2
 libstdc++6 10.2.0-5ubuntu1~20.04
 libsystemd0 245.4-4ubuntu3.6
 libunistring2 0.9.10-2
 lsb-base 11.1.0ubuntu2
DistroRelease: Ubuntu 20.04
InstallationDate: Installed on 2010-07-10 (3957 days ago)
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100429)
Package: smartmontools 7.1-1build1 [modified: usr/share/smartmontools/smartd-runner]
PackageArchitecture: amd64
ProcCpuinfoMinimal:
 processor : 1
 vendor_id : GenuineIntel
 cpu family : 6
 model : 23
 model name : Intel(R) Core(TM)2 Duo CPU T9600 @ 2.80GHz
 stepping : 10
 microcode : 0xa07
 cpu MHz : 800.000
 cache size : 6144 KB
 physical id : 0
 siblings : 2
 core id : 1
 cpu cores : 2
 apicid : 1
 initial apicid : 1
 fpu : yes
 fpu_exception : yes
 cpuid level : 13
 wp : yes
 flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts nopl cpuid aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm pti tpr_shadow vnmi flexpriority vpid dtherm ida
 vmx flags : vnmi flexpriority tsc_offset vtpr vapic
 bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs itlb_multihit
 bogomips : 5585.85
 clflush size : 64
 cache_alignment : 64
 address sizes : 36 bits physical, 48 bits virtual
 power management:
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: smartmontools
Tags: focal
Uname: Linux 5.11.0+ x86_64
UpgradeStatus: Upgraded to focal on 2020-08-09 (273 days ago)
_MarkForUpload: True
modified.conffile..etc.default.apport: [modified]
modified.conffile..etc.default.smartmontools: [modified]
modified.conffile..etc.smartd.conf: [modified]
mtime.conffile..etc.default.apport: 2020-08-09T18:38:49.803212
mtime.conffile..etc.default.smartmontools: 2010-11-12T20:22:37
mtime.conffile..etc.smartd.conf: 2016-05-14T13:58:08.981915

Revision history for this message
John Denker (lp-8) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "smartd-runner.diff" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Lucas Kanashiro (lucaskanashiro) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu
better.

This bug is present in Debian as well and Ubuntu currently does not make any
changes to the Debian package. Therefore, this bug would be best fixed
directly in Debian, and then Ubuntu will pick up the fix automatically. Once
it is fixed in the development release we can consider a SRU:

https://wiki.ubuntu.com/StableReleaseUpdates

Would you mind filing a bug with Debian please?

Revision history for this message
John Denker (lp-8) wrote :

Pushed upstream, as requested, just now.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

I tried investigating this bug a bit more with Athos' help.

First, I cannot easily reproduce it because smartd doesn't even start when running on virtualized environments, and I don't feel like using my own host machine to test the problem.

Then, I noticed that there is a bug filed upstream which looked very similar to this one:

https://www.smartmontools.org/ticket/1454

It *may* be related, but it doesn't seem to directly impact this one (keep reading).

After looking at the flow of execution, it was clear that:

- smartd will call /usr/share/smartmontools/smartd_warning.sh after having set a bunch of environment variables that affect the execution of the script. For our purposes, the only variables we will need to manually set are SMARTD_ADDRESS and SMARTD_MAILER.

- Because SMARTD_MAILER will be set to /usr/share/smartmontools/smartd-runner, this is the script that will be executed afterwards. After looking at what "smartd-runner" does (it invokes every executable under /etc/smartmontools/run.d/), and after verifying that the only thing under /etc/smartmontools/run.d/ is a very simple script called "10mail" (which just invokes the "mail" command with some arguments), it's clear that we can try to reproduce this bug by hand.

By the way, here is the smartd function that is responsible for putting the arguments together and actually invoking the smartd_warning.sh script:

https://www.smartmontools.org/browser/tags/RELEASE_7_1/smartmontools/smartd.cpp#L1084

In a nutshell, what the function seems to do is:

To reproduce the bug, we can:

$ lxc launch images:ubuntu/focal smartmontools-focal
$ lxc shell smartmontools-focal
# apt update && apt install -y smartmontools bsd-mailx
# adduser test
# SMARTD_ADDRESS="root test" SMARTD_MAILER=/usr/share/smartmontools/smartd-runner /usr/share/smartmontools/smartd_warning.sh
# mail root
... verify that there's an email from smartd_warning ...
# su - test
$ mail
No mail for test

I verified that the reporter's patch seems to fix the problem.

@John, I noticed that you opened a bug against Debian, which is good. However, there is already a bug opened about this problem:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661485

Could you please close your bug and comment on that other bug to let them know that you're also affected? Also, if you have the time, it would be good if you could also open a Merge Request against the Debian smartmontools project on salsa:

https://salsa.debian.org/debian/smartmontools

Thanks a lot.

Changed in smartmontools (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
John Denker (lp-8) wrote :

> Also, if you have the time, it would be good if you could also open a Merge Request against the Debian smartmontools project on salsa:
>
> https://salsa.debian.org/debian/smartmontools

I'd love to, but how? What do you suggest?
-- salsa won't let me create a merge request, presumably because I am not logged in.
-- salsa won't let me log in using my longstanding oft-used github credentials.
-- it also won't let me log in with username (JohnDenker) and password; it says:

  Your account is pending approval from your GitLab administrator and hence blocked. Please contact your GitLab administrator if you think this is an error.

Changed in smartmontools (Debian):
status: Unknown → New
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Thank you for your reply.

Unfortunately I cannot help you with salsa; I don't manage the system. I know you can ask for help on the #salsa channel (OFTC IRC network); maybe someone there will be able to help you with the user creation.

Once you are able to login you should also be able to create the Merge Request.

Thanks.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.