Browse Source

pam notify

master
Robin Thoni 8 years ago
parent
commit
aa619388d0
3 changed files with 27 additions and 0 deletions
  1. 12
    0
      pam/install
  2. 3
    0
      pam/notify-pam
  3. 12
    0
      pam/notify-pam.sh

+ 12
- 0
pam/install View File

@@ -0,0 +1,12 @@
1
+#! /usr/bin/env bash
2
+
3
+dir="$(dirname $(readlink -f "${0}"))"
4
+
5
+cp "${dir}/notify-pma.sh" /usr/local/bin/notify-pma &&
6
+if [ ! -f /etc/pam.d/notify-pam ]
7
+then
8
+  cp "${dir}/notify-pma" /etc/pam.d/notify-pma &&
9
+  echo "@include notify-pam" >> /etc/pam.d/sudo &&
10
+  echo "@include notify-pam" >> /etc/pam.d/common-session
11
+fi
12
+

+ 3
- 0
pam/notify-pam View File

@@ -0,0 +1,3 @@
1
+#%PAM-1.0
2
+
3
+session    optional     pam_exec.so /usr/local/bin/notify-pam

+ 12
- 0
pam/notify-pam.sh View File

@@ -0,0 +1,12 @@
1
+#! /usr/bin/env sh
2
+
3
+[ "$PAM_TYPE" = "open_session" ] || exit 0
4
+{
5
+  echo "User: $PAM_USER"
6
+  echo "Ruser: $PAM_RUSER"
7
+  echo "Rhost: $PAM_RHOST"
8
+  echo "Service: $PAM_SERVICE"
9
+  echo "TTY: $PAM_TTY"
10
+  echo "Date: `date`"
11
+  echo "Server: `hostname -f`"
12
+} | mail -s "`hostname -s` $PAM_SERVICE login: $PAM_USER" root

Loading…
Cancel
Save