summary refs log tree commit diff
path: root/pkgs/os-specific/linux/mdadm/default.nix
diff options
context:
space:
mode:
authorLéo Gaspard <leo@gaspard.io>2018-03-29 21:23:36 +0200
committerBjørn Forsman <bjorn.forsman@gmail.com>2018-03-30 16:16:31 +0200
commitec9a51d0cc6fab730bfe10d354b47c98ddb37460 (patch)
tree2bb83edb44f714d73239fd86b9023f5c6132e158 /pkgs/os-specific/linux/mdadm/default.nix
parent6547e61577a024faf6f104fd7fc938ecb1343c36 (diff)
downloadnixpkgs-ec9a51d0cc6fab730bfe10d354b47c98ddb37460.tar
nixpkgs-ec9a51d0cc6fab730bfe10d354b47c98ddb37460.tar.gz
nixpkgs-ec9a51d0cc6fab730bfe10d354b47c98ddb37460.tar.bz2
nixpkgs-ec9a51d0cc6fab730bfe10d354b47c98ddb37460.tar.lz
nixpkgs-ec9a51d0cc6fab730bfe10d354b47c98ddb37460.tar.xz
nixpkgs-ec9a51d0cc6fab730bfe10d354b47c98ddb37460.tar.zst
nixpkgs-ec9a51d0cc6fab730bfe10d354b47c98ddb37460.zip
mdadm: allow sending mail when using opensmtpd
OpenSMTPD does not require the setuid bit for its `sendmail`. This works
around it by wrapping the called `sendmail` so that the wrapper falls
back on either the setuid `sendmail` or the non-setuid `sendmail`
depending on what's available.

The solution of relying on `$PATH` to be set is unfortunately
unreliable, as `mdadm --monitor` will likely be executed from a
`systemd` unit, that runs with a clean `$PATH`.
Diffstat (limited to 'pkgs/os-specific/linux/mdadm/default.nix')
-rw-r--r--pkgs/os-specific/linux/mdadm/default.nix17
1 files changed, 14 insertions, 3 deletions
diff --git a/pkgs/os-specific/linux/mdadm/default.nix b/pkgs/os-specific/linux/mdadm/default.nix
index 85a65b8f824..7a59c2ea757 100644
--- a/pkgs/os-specific/linux/mdadm/default.nix
+++ b/pkgs/os-specific/linux/mdadm/default.nix
@@ -1,10 +1,21 @@
-{ stdenv
+{ stdenv, writeScript
 , fetchurl, groff
 , buildPlatform, hostPlatform
 }:
 
 assert stdenv.isLinux;
 
+let
+  sendmail-script = writeScript "sendmail-script" ''
+    #!/bin/sh
+
+    if [ -x /run/wrappers/bin/sendmail ]; then
+      /run/wrappers/bin/sendmail "$@"
+    else
+      /run/current-system/sw/bin/sendmail "$@"
+    fi
+  '';
+in
 stdenv.mkDerivation rec {
   name = "mdadm-4.0";
 
@@ -15,7 +26,7 @@ stdenv.mkDerivation rec {
 
   # This is to avoid self-references, which causes the initrd to explode
   # in size and in turn prevents mdraid systems from booting.
-  allowedReferences = [ stdenv.cc.libc.out ];
+  allowedReferences = [ stdenv.cc.libc.out sendmail-script ];
 
   patches = [ ./no-self-references.patch ];
 
@@ -32,7 +43,7 @@ stdenv.mkDerivation rec {
   preConfigure = ''
     sed -e 's@/lib/udev@''${out}/lib/udev@' \
         -e 's@ -Werror @ @' \
-        -e 's@/usr/sbin/sendmail@/run/wrappers/bin/sendmail@' -i Makefile
+        -e 's@/usr/sbin/sendmail@${sendmail-script}@' -i Makefile
   '';
 
   meta = {