aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-10-29 19:22:33 +0100
committerMattias Andrée <maandree@operamail.com>2014-10-29 19:22:33 +0100
commitbb7c022b456c44df83023c1eb0671d83274ee236 (patch)
tree185fda65a19363f007f24262a34a869fa8dfc7a3 /src
parentmore code reuse (diff)
downloadcerberus-logging-bb7c022b456c44df83023c1eb0671d83274ee236.tar.gz
cerberus-logging-bb7c022b456c44df83023c1eb0671d83274ee236.tar.bz2
cerberus-logging-bb7c022b456c44df83023c1eb0671d83274ee236.tar.xz
add support for ~/.prelogin
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/logging12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/logging b/src/logging
index db14adb..14d2dfc 100755
--- a/src/logging
+++ b/src/logging
@@ -66,6 +66,7 @@ for arg in "$@"; do
username="${arg}"
fi
done
+user="${username}"
# Execute a program only if it exists
try ()
@@ -77,6 +78,17 @@ try ()
# Call logging programs (those that exists) for a successful login action
log-login ()
{
+ # This is useful if you want to print the last logging.
+ # log-login-lastlog updates the entry in lastlog so it is helpful
+ # to be able to print the log entry before the is updated. Its lets
+ # you add a script named .prelogin in your home directory that
+ # contains the following code, to print the last login information:
+ # echo 'Last login:' ; lastlog --user $USER | tail -n 1
+ script="$(getent passwd | grep '^${user}:' | cut -d : -f 6)/.prelogin"
+ if [ -x "${script}" ]; then
+ su -c "${script}" -- "${user}"
+ fi
+
try log-login-utmp "$@"
try log-login-audit "$@"
try log-login-lastlog "$@"