Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mdadm: allow sending mail when using opensmtpd #38067

Closed
wants to merge 1 commit into from

Conversation

Ekleog
Copy link
Member

@Ekleog Ekleog commented Mar 29, 2018

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.

I don't know whether that's something that happens often, but maybe it'd make sense to generate a linkfarm to both current-system/sw/bin and wrappers/bin, for when an absolute path is requested?

Tested on 18.03.

@Ekleog
Copy link
Member Author

Ekleog commented Mar 29, 2018

@GrahamcOfBorg build mdadm

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: mdadm

Partial log (click to expand)

shrinking RPATHs of ELF executables and libraries in /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0
shrinking /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/sbin/mdadm
shrinking /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/sbin/mdmon
gzipping man pages under /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/share/man/
strip is /nix/store/fzcs0fn6bb04m82frhlb78nc03ny3w55-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/lib  /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/sbin
patching script interpreter paths in /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0
checking for references to /build in /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0...
moving /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/sbin/* to /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/bin
/nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: mdadm

Partial log (click to expand)

shrinking RPATHs of ELF executables and libraries in /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0
shrinking /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0/sbin/mdmon
shrinking /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0/sbin/mdadm
gzipping man pages under /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0/share/man/
strip is /nix/store/3zq400fri5dv7d30lpxlqm2v9y1iis6j-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0/lib  /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0/sbin
patching script interpreter paths in /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0
checking for references to /build in /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0...
moving /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0/sbin/* to /nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0/bin
/nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: mdadm

Partial log (click to expand)

shrinking RPATHs of ELF executables and libraries in /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0
shrinking /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/sbin/mdadm
shrinking /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/sbin/mdmon
gzipping man pages under /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/share/man/
strip is /nix/store/fzcs0fn6bb04m82frhlb78nc03ny3w55-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/lib  /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/sbin
patching script interpreter paths in /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0
checking for references to /build in /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0...
moving /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/sbin/* to /nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0/bin
/nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: mdadm

Partial log (click to expand)

/nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0

@bjornfor
Copy link
Contributor

If no absolulte path is needed, simple $PATH lookup could suffice, with priority ordering by directory position in the $PATH list. Does mdadm need absolute path?

Please add full explanation in the commit message, not just the PR message. The PR message starts out with the contents of the commit message, so the text only needs to be written once (not even copy-pasted).

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`.
@Ekleog
Copy link
Member Author

Ekleog commented Mar 29, 2018

Just added information to the commit message. Also copying it here as it'll be easier to access:

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`.

So I thought it'd be better to just follow what the previous mdadm did, and depend on the current environment.

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: mdadm

Partial log (click to expand)

/nix/store/xzymic7fcjdcxw88v10j4amnyz09bl79-mdadm-4.0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: mdadm

Partial log (click to expand)

/nix/store/3g02fy269y31jkn3yr5r1v91k9ffia3m-mdadm-4.0

@bjornfor
Copy link
Contributor

Both approaches have their benefits.

I personally prefer to not leak NixOS specific paths into nixpkgs (the packages). Sometimes it doesn't really matter, other times it makes packages break on non-NixOS. By the way, here you can see the $PATH approach implemented in the kbfs NixOS module. Does mdadm work with sendmail PATH lookup and something like path = [ "/run/wrappers" "/run/current-system/sw/bin" ]; in the systemd service definition?

@Ekleog
Copy link
Member Author

Ekleog commented Mar 30, 2018

I can confirm it does work with PATH, actually that's the way I initially chose to develop. The issue I came upon with that is that there are likely people with services such as:

systemd.services.mdadm-monitor = {
  description = "Monitor RAID disks";
  wantedBy = [ "multi-user.target" ];
  script = "${pkgs.mdadm}/bin/mdadm --scan --monitor -m root";
};

And such a script would be silently broken by such an update: it would no longer send any email were one of the disks to fail. This sounds like an easy way to have someone hate nixpkgs, unfortunately.

And I don't really know of any way to handle the switch cleanly. Using lib.warn to warn on all installs of mdadm until 18.09 seems… a bit overkill. And I'd rather not just break everything silently until then.

Do you have any idea how to handle this better?

@bjornfor
Copy link
Contributor

Good point. (I have a hand-written service like that myself.) The problem is that we don't have a NixOS module for mdadm, #31840. Let's merge.

@bjornfor
Copy link
Contributor

Applied to master (ec9a51d).

@bjornfor bjornfor closed this Mar 30, 2018
@Ekleog
Copy link
Member Author

Ekleog commented Mar 30, 2018

Thanks!

@Ekleog Ekleog deleted the sendmail-from-path branch March 30, 2018 16:21
@Ekleog Ekleog mentioned this pull request Oct 29, 2018
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants