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:
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:
$ 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:
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:
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.smartmonto ols.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/smartmonto ols/run. d/), and after verifying that the only thing under /etc/smartmonto ols/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.smartmonto ols.org/ browser/ tags/RELEASE_ 7_1/smartmontoo ls/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 ADDRESS= "root test" SMARTD_ MAILER= /usr/share/ smartmontools/ smartd- runner /usr/share/ smartmontools/ smartd_ warning. sh
$ lxc shell smartmontools-focal
# apt update && apt install -y smartmontools bsd-mailx
# adduser test
# SMARTD_
# 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.