From 01e008a9577155f6b0875b207e42f1c2bbd087f4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 18 Jan 2018 13:46:35 +0100 Subject: Fix UID/USER ambiguity in several places --- core/modules/pam/data/opt/openslx/scripts/pam_script_auth | 7 ++++++- .../modules/pam/data/opt/openslx/scripts/pam_script_ses_close | 11 +++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'core/modules/pam') diff --git a/core/modules/pam/data/opt/openslx/scripts/pam_script_auth b/core/modules/pam/data/opt/openslx/scripts/pam_script_auth index e977185e..f7e12acf 100755 --- a/core/modules/pam/data/opt/openslx/scripts/pam_script_auth +++ b/core/modules/pam/data/opt/openslx/scripts/pam_script_auth @@ -6,7 +6,12 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/o # check if the script runs as root [ "x$(whoami)" != "xroot" ] && exit 0 -PASSWD=$(getent passwd "$PAM_USER") +USER_UID=$(id -u "$PAM_USER") +if [ -n "$USER_UID" ]; then + PASSWD=$(getent passwd "$USER_UID") +else + PASSWD=$(getent passwd "$PAM_USER") +fi USER_NAME=$(echo "$PASSWD" | awk -F ':' '{print $1}') USER_UID=$(echo "$PASSWD" | awk -F ':' '{print $3}') USER_GID=$(echo "$PASSWD" | awk -F ':' '{print $4}') diff --git a/core/modules/pam/data/opt/openslx/scripts/pam_script_ses_close b/core/modules/pam/data/opt/openslx/scripts/pam_script_ses_close index e4a7c1b4..0c0b804f 100755 --- a/core/modules/pam/data/opt/openslx/scripts/pam_script_ses_close +++ b/core/modules/pam/data/opt/openslx/scripts/pam_script_ses_close @@ -29,6 +29,9 @@ fi # do not kill all root processes :) [ "x${PAM_USER}" = "xroot" ] && exit 0 +USERID=$(id -u "$PAM_USER") +[ -z "$USERID" ] && USERID="$PAM_USER" + # Async block: Check if user has no session open anymore, if not # kill any remaining processes belonging to the user and unmount # everything at $USERHOME and below. @@ -41,17 +44,17 @@ fi if [ "$SESSIONCOUNT" = "0" ]; then # last session, close all ghost user processes - pkill -u "${PAM_USER}" + pkill -u "${USERID}" # check if user's processes are still running for TIMEOUT in 1 1 2 FAIL; do - if ! ps -o pid,s -u "$PAM_USER" -U "$PAM_USER" | grep -q -v -E "PID|Z"; then + if ! ps -o pid,s -u "$USERID" -U "$USERID" | grep -q -v -E "PID|Z"; then # nothing running anymore break fi if [ "$TIMEOUT" = "FAIL" ]; then # still something running, send SIGKILL - pkill -9 -u "${PAM_USER}" + pkill -9 -u "${USERID}" else # give some time sleep "${TIMEOUT}" @@ -65,7 +68,7 @@ fi if [ "$SESSIONCOUNT" = "0" ]; then # unmount the home directory structure - USER_HOME=$(getent passwd "$PAM_USER" | awk -F ':' '{print $6}') + USER_HOME=$(getent passwd "$USERID" | awk -F ':' '{print $6}') if [ -n "$USER_HOME" ]; then for TIMEOUT in 0 0 2 2 FAIL; do OK=yes -- cgit v1.2.3-55-g7522