envoi mail après login

This commit is contained in:
nyanloutre 2019-06-07 11:57:12 +02:00
parent 651a0d3c64
commit a93d836d36
1 changed files with 16 additions and 3 deletions

View File

@ -11,6 +11,16 @@ let
musique_port = 52349; musique_port = 52349;
factorio_port = 52351; factorio_port = 52351;
airsonic_port = 4040; airsonic_port = 4040;
login_mail_alert = pkgs.writeShellScriptBin "mail_alert.sh" ''
if [ "$PAM_TYPE" != "close_session" ]; then
${pkgs.system-sendmail}/bin/sendmail paul@nyanlout.re <<EOF
From: root@nyanlout.re
Subject: SSH Login: $PAM_USER from $PAM_RHOST
`env`
EOF
fi
'';
in in
{ {
@ -415,9 +425,12 @@ in
users.groups.acme.members = [ "matrix-synapse" ]; users.groups.acme.members = [ "matrix-synapse" ];
security.sudo.extraRules = [ security = {
{ commands = [ { command = "${pkgs.smartmontools}/bin/smartctl"; options = [ "NOPASSWD" ]; } ]; users = [ "telegraf" ]; } sudo.extraRules = [
]; { commands = [ { command = "${pkgs.smartmontools}/bin/smartctl"; options = [ "NOPASSWD" ]; } ]; users = [ "telegraf" ]; }
];
pam.services.sshd.text = pkgs.lib.mkDefault( pkgs.lib.mkAfter "session optional ${pkgs.pam}/lib/security/pam_exec.so seteuid ${login_mail_alert}/bin/mail_alert.sh" );
};
networking = { networking = {
wireguard.interfaces = { wireguard.interfaces = {