I created this NixOS module which implements a simple sendmail
implementation to send all emails to my Maildir: erosanix/sendtome.nix at 8b0029d62af923693f2a0557ecd5aa88fc49fb79 · emmanuelrosa/erosanix · GitHub
My intention is to use this to get notifications from journalwatch and smartd.
It’s configured as follows:
services.sendtome.setSendmail = true;
services.sendtome.user = "emmanuel";
When I run the program as another user, it fails:
echo "A message from foobar" | sendmail
mkdir: cannot create directory ‘/home/emmanuel’: Permission denied
mkdir: cannot create directory ‘/home/emmanuel’: Permission denied
mkdir: cannot create directory ‘/home/emmanuel’: Permission denied
/nix/store/rgny8ldjmn0pndkbk8a0cncwk4x8g6fl-sendmail: line 12: /home/emmanuel/Maildir/tmp/1669904538.P3615R89.xyz: Permission denied
mv: cannot stat '/home/emmanuel/Maildir/tmp/1669904538.P3615R89.xyz': Permission denied
The setuid/setgid flags are set, and it’s a binary which then calls my script, so I don’t know what the problem is:
stat `which sendmail`
File: /run/wrappers/bin/sendmail
Size: 17064 Blocks: 40 IO Block: 4096 regular file
Device: 0,24 Inode: 29 Links: 1
Access: (6511/-r-s--s--x) Uid: ( 1000/emmanuel) Gid: ( 100/ users)
Access: 2022-12-01 09:21:52.780047127 -0500
Modify: 2022-12-01 09:19:49.175551661 -0500
Change: 2022-12-01 09:19:49.177551635 -0500
Birth: 2022-12-01 09:19:49.175551661 -0500