smartd fails to send an email

  • Open
  • quality assurance status badge
Details
3 participants
  • 45mg
  • Hilton Chain
  • Tomas Volf
Owner
unassigned
Submitted by
Tomas Volf
Severity
normal
T
T
Tomas Volf wrote 4 days ago
(address . bug-guix@gnu.org)
87r056rxbe.fsf@wolfsden.cz
Hi,

I have tried to write a service type for smartd from smartmontools,
however the bundled script fails.

When the test (-m root -M test) is executed, some programs seem to be
missing in the $PATH:

Toggle snippet (6 lines)
Jan 14 01:34:19 localhost smartd[3138]: Executing test of <mail> to root ...
Jan 14 01:34:19 localhost smartd[3138]: Test of <mail> to root produced unexpected output (118 bytes) to STDOUT/STDERR:
Jan 14 01:34:19 localhost smartd[3138]: /gnu/store/ks6lnp8hssm9zkka47ysa4qp9xd9f8bv-smartmontools-7.4/etc/smartd_warning.sh: line 132: sed: command not found
Jan 14 01:34:19 localhost smartd[3138]: Test of <mail> to root: failed (32-bit/8-bit exit status: 32512/127)

At the start of the script I see:

Toggle snippet (3 lines)
export PATH="/usr/local/bin:/usr/bin:/bin"

That does not look correct. I am not sure if any wrapping is necessary.

Have a nice day,
Tomas

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
4
4
45mg wrote 4 days ago
87wmeyc67s.fsf@gmail.com
Hi Tomas,

Tomas Volf <~@wolfsden.cz> writes:

Toggle quote (15 lines)
> Hi,
>
> I have tried to write a service type for smartd from smartmontools,
> however the bundled script fails.
>
> When the test (-m root -M test) is executed, some programs seem to be
> missing in the $PATH:
>
> --8<---------------cut here---------------start------------->8---
> Jan 14 01:34:19 localhost smartd[3138]: Executing test of <mail> to root ...
> Jan 14 01:34:19 localhost smartd[3138]: Test of <mail> to root produced unexpected output (118 bytes) to STDOUT/STDERR:
> Jan 14 01:34:19 localhost smartd[3138]: /gnu/store/ks6lnp8hssm9zkka47ysa4qp9xd9f8bv-smartmontools-7.4/etc/smartd_warning.sh: line 132: sed: command not found
> Jan 14 01:34:19 localhost smartd[3138]: Test of <mail> to root: failed (32-bit/8-bit exit status: 32512/127)
> --8<---------------cut here---------------end--------------->8---

I've seen other package definitions deal with this problem by using
`substitute*` to replace executables specified in scripts, etc. (like
sed here) with the corresponding store paths. See 'light' in (gnu
packages linux) for an example.
T
T
Tomas Volf wrote 3 days ago
[PATCH] gnu: smartmontools: Fix PATH in smartd_warning.sh.
(name . Tomas Volf)(address . ~@wolfsden.cz)
d7320ddeb1939ce0eeeea10f7267883692c269e7.1736898019.git.~@wolfsden.cz
The script started with reset of the $PATH to a value not suitable to Guix.
In addition, the script requires coreutils and sed, so add those into the
$PATH.

* gnu/packages/admin.scm (smartmontools)[arguments]<#:phases>: Add 'fix-path.

Change-Id: Ide97f572e6f369fe24337f945474dc7a65584eda
---
gnu/packages/admin.scm | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

Toggle diff (28 lines)
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 7f50d5f4e9..098e21ff8a 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -2921,8 +2921,19 @@ (define-public smartmontools
"0gcrzcb4g7f994n6nws26g6x15yjija1gyzd359sjv7r3xj1z9p9"))))
(build-system gnu-build-system)
(arguments
- (list #:make-flags
- #~(list "BUILD_INFO=\"(Guix)\"")))
+ (list
+ #:make-flags
+ #~(list "BUILD_INFO=\"(Guix)\"")
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'install 'fix-path
+ (lambda _
+ (substitute* (string-append #$output "/etc/smartd_warning.sh")
+ (("export PATH=.*$" all)
+ (string-append "PATH="
+ #$(file-append sed "/bin") ":"
+ #$(file-append coreutils "/bin") ":"
+ "$PATH\n"))))))))
(inputs (list libcap-ng))
(home-page "https://www.smartmontools.org/")
(synopsis "S.M.A.R.T. harddisk control and monitoring tools")
--
2.47.1
T
T
Tomas Volf wrote 3 days ago
control message for bug #75550
(address . control@debbugs.gnu.org)
338703f3736c814d1d204e9b74acbdc9@wolfsden.cz
reassign 75550 guix-patches
quit
H
H
Hilton Chain wrote 3 days ago
Re: bug#75550: [PATCH] gnu: smartmontools: Fix PATH in smartd_warning.sh.
(name . Tomas Volf)(address . ~@wolfsden.cz)
87ed14ssck.wl-hako@ultrarare.space
Hi Tomas,

On Wed, 15 Jan 2025 07:40:19 +0800,
Tomas Volf wrote:
Toggle quote (36 lines)
>
> The script started with reset of the $PATH to a value not suitable to Guix.
> In addition, the script requires coreutils and sed, so add those into the
> $PATH.
>
> * gnu/packages/admin.scm (smartmontools)[arguments]<#:phases>: Add 'fix-path.
>
> Change-Id: Ide97f572e6f369fe24337f945474dc7a65584eda
> ---
> gnu/packages/admin.scm | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
> index 7f50d5f4e9..098e21ff8a 100644
> --- a/gnu/packages/admin.scm
> +++ b/gnu/packages/admin.scm
> @@ -2921,8 +2921,19 @@ (define-public smartmontools
> "0gcrzcb4g7f994n6nws26g6x15yjija1gyzd359sjv7r3xj1z9p9"))))
> (build-system gnu-build-system)
> (arguments
> - (list #:make-flags
> - #~(list "BUILD_INFO=\"(Guix)\"")))
> + (list
> + #:make-flags
> + #~(list "BUILD_INFO=\"(Guix)\"")
> + #:phases
> + #~(modify-phases %standard-phases
> + (add-after 'install 'fix-path
> + (lambda _
> + (substitute* (string-append #$output "/etc/smartd_warning.sh")
> + (("export PATH=.*$" all)
> + (string-append "PATH="
> + #$(file-append sed "/bin") ":"
> + #$(file-append coreutils "/bin") ":"
> + "$PATH\n"))))))))

Please add sed and coreutils-minimal to inputs and use search-input-file or
this-package-input instead.

For smartmontools the proper way is to set --with-scriptpath='...' configure
flag, which is documented in its INSTALL file. (It can be disabled with a 'no'
value as well.)

Toggle quote (6 lines)
> (inputs (list libcap-ng))
> (home-page "https://www.smartmontools.org/")
> (synopsis "S.M.A.R.T. harddisk control and monitoring tools")
> --
> 2.47.1

Thanks
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 75550@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 75550
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch