From 7f8c7791ec72d85ec4cbcb1739247d2132789bd7 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Fri, 31 Oct 2014 13:59:09 +0100 Subject: [pam] added support for .d folders containing hook scripts --- remote/modules/pam/data/opt/openslx/scripts/pam_script_auth | 13 +++++++++++++ .../pam/data/opt/openslx/scripts/pam_script_ses_close | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/remote/modules/pam/data/opt/openslx/scripts/pam_script_auth b/remote/modules/pam/data/opt/openslx/scripts/pam_script_auth index e7de3a8c..656d9a01 100755 --- a/remote/modules/pam/data/opt/openslx/scripts/pam_script_auth +++ b/remote/modules/pam/data/opt/openslx/scripts/pam_script_auth @@ -17,6 +17,19 @@ TEMP_HOME_DIR="$USER_HOME" # check if PAM_USER is root and skip if it is the case [ "x${PAM_USER}" == "xroot" ] && exit 0 +# source the stuff in pam_script_auth.d, if it exists +if [ -d "/opt/openslx/scripts/pam_script_auth.d" ]; then + for HOOK in $(ls "/opt/openslx/scripts/pam_script_auth.d"); do + # source it, in case of failure do nothing since these scripts are non-critical + . "/opt/openslx/scripts/pam_script_auth.d/$HOOK" || slxlog "pam-source-hooks" "Could not source '$HOOK'." + done +fi + +############################################################################### +# +# Preparations for volatile /home/ +# +# # check if we already mounted the home directory mount | grep -q " $TEMP_HOME_DIR " && exit 0 diff --git a/remote/modules/pam/data/opt/openslx/scripts/pam_script_ses_close b/remote/modules/pam/data/opt/openslx/scripts/pam_script_ses_close index 0af71c6f..4fc2ce6a 100755 --- a/remote/modules/pam/data/opt/openslx/scripts/pam_script_ses_close +++ b/remote/modules/pam/data/opt/openslx/scripts/pam_script_ses_close @@ -18,6 +18,14 @@ fi # can only work if script is run as root [ "x$(whoami)" = "xroot" ] || exit 0 +# source hooks if there are any +if [ -d "/opt/openslx/scripts/pam_script_ses_close.d" ]; then + for HOOK in $(ls "/opt/openslx/scripts/pam_script_ses_close.d"); do + # failure is non-critical + . "/opt/openslx/scripts/pam_script_ses_close.d/$HOOK" || slxlog "pam-sesclose-hooks" "Could not source '$HOOK'." + done +fi + OPENSESSION=$(loginctl show-user "$PAM_USER" | grep "Sessions=" | cut -c 10-) SESSIONCOUNT=$(echo "$OPENSESSION" | wc -w) # When using su/sudo there is no session created, so count up by one -- cgit v1.2.3-55-g7522