summaryrefslogtreecommitdiffstats
path: root/core/modules/pam
diff options
context:
space:
mode:
authorSimon Rettberg2018-01-18 13:46:35 +0100
committerSimon Rettberg2018-01-18 13:46:35 +0100
commit01e008a9577155f6b0875b207e42f1c2bbd087f4 (patch)
treed505e3236867c6953e25b4ebd5a4f1b606c217a1 /core/modules/pam
parent[run-virt] add --sync to slxlog calls (diff)
downloadmltk-01e008a9577155f6b0875b207e42f1c2bbd087f4.tar.gz
mltk-01e008a9577155f6b0875b207e42f1c2bbd087f4.tar.xz
mltk-01e008a9577155f6b0875b207e42f1c2bbd087f4.zip
Fix UID/USER ambiguity in several places
Diffstat (limited to 'core/modules/pam')
-rwxr-xr-xcore/modules/pam/data/opt/openslx/scripts/pam_script_auth7
-rwxr-xr-xcore/modules/pam/data/opt/openslx/scripts/pam_script_ses_close11
2 files changed, 13 insertions, 5 deletions
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