Here is a replacement for bug 988384.
This is a better place for it.
========================================================


*** 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,blakeney,reid,delavega,wayne \
        -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.

Compared to others that have been suggested, this patch is superior in
a couple of ways:
*) It accepts an /arbitary/ number of arguments and passes them to the
run-parts script(s) appropriately.
*) It is agnostic as to the number, format, and semantics of the
arguments.

*** 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

/////////// sent Mon 10 May 2021  7:35:45 AM MST
https://bugs.launchpad.net/ubuntu/+source/smartmontools/+bug/1927980

/////////// patch is:
--- smartd-runner#orig  2021-05-06 03:25:01.324133900 -0700
+++ smartd-runner       2021-05-10 07:00:08.342798348 -0700
@@ -3,8 +3,15 @@
 tmp=$(tempfile)
 cat >$tmp
 
-run-parts --report --lsbsysinit --arg=$tmp --arg="$1" \
-    --arg="$2" --arg="$3" -- /etc/smartmontools/run.d
+# Decorate every one of our args with "--arg=".
+# Use an array, since each arg might contain spaces.
+args=("$@")
+cmd=()
+for ((ii=0; ii<${#args[@]}; ii++)); do
+  cmd[$ii]="--arg=${args[$ii]}"
+done
 
-rm -f $tmp
+run-parts --report --lsbsysinit --arg=$tmp \
+         "${cmd[@]}" -- /etc/smartmontools/run.d
 
+rm -f $tmp

Reply via email to