summaryrefslogtreecommitdiffstats
path: root/server/modules/pam-offenburg/opt
diff options
context:
space:
mode:
authorSimon Rettberg2013-12-16 19:25:51 +0100
committerSimon Rettberg2013-12-16 19:25:51 +0100
commit985c761aa4d2cc0e210ac5d3e92ca50c20cbd2de (patch)
tree43b456364abebbab9acf03523241e83e65f7f8fa /server/modules/pam-offenburg/opt
parent[pam-offenburg] Ubuntu needs nox11 for pam-ck-connector (diff)
downloadtm-scripts-985c761aa4d2cc0e210ac5d3e92ca50c20cbd2de.tar.gz
tm-scripts-985c761aa4d2cc0e210ac5d3e92ca50c20cbd2de.tar.xz
tm-scripts-985c761aa4d2cc0e210ac5d3e92ca50c20cbd2de.zip
[pam-offenburg] Adapt to new pam_script_* format
Diffstat (limited to 'server/modules/pam-offenburg/opt')
-rw-r--r--server/modules/pam-offenburg/opt/openslx/scripts/pam_script_mount_persistent55
1 files changed, 55 insertions, 0 deletions
diff --git a/server/modules/pam-offenburg/opt/openslx/scripts/pam_script_mount_persistent b/server/modules/pam-offenburg/opt/openslx/scripts/pam_script_mount_persistent
new file mode 100644
index 00000000..08d30195
--- /dev/null
+++ b/server/modules/pam-offenburg/opt/openslx/scripts/pam_script_mount_persistent
@@ -0,0 +1,55 @@
+###################################################################
+#
+# This script is a part of the pam_script_ses_open script
+# and is not stand-alone!
+#
+# It will try to mount the home directories of students
+# under /home/<user>/PERSISTENT using kerberos.
+#
+
+
+# Only consider users not in local user db
+if ! grep -q "^${PAM_USER}:" /etc/passwd; then
+
+ if [ -z "$PAM_USER" ]; then
+ # Ask for username
+ read -p "Benutzername: " loggedInUser
+ else
+ loggedInUser="$PAM_USER"
+ fi
+
+ if [ -n "$PAM_AUTHTOK" ]; then
+ password="$PAM_AUTHTOK"
+ else
+ # No password from pam stack, ask user (if we're on a console)
+ if [ "x$PAM_TTY" = "xssh" ]; then
+ read -p "Passwort: " password
+ elif [ "x$(echo "$PAM_TTY" | cut -c 1-8)" = "x/dev/tty" ]; then
+ read -p "Passwort: " password
+ fi
+ fi
+
+ if [ -n "$password" ]; then
+ # We know the user's password, so try to mount H-Drive
+ SIGNAL=$(mktemp)
+ ERRLOG=$(mktemp)
+ rm -f -- "${SIGNAL}"
+ ( ncpmount -A "fs1-2-home.rz.hs-offenburg.de" -S "fs1-2-home.rz.hs-offenburg.de" -V "HOME/USERS/$loggedInUser" -U "$loggedInUser.HRZ.FHO" -P "$password" "$PERSISTENT_HOME_DIR" > "$ERRLOG" 2>&1 || touch "$SIGNAL" ) &
+ MOUNT_PID=$!
+ for COUNTER in 1 1 2 3; do
+ kill -0 "$MOUNT_PID" || break
+ sleep "$COUNTER"
+ done
+ if [ -e "${SIGNAL}" ]; then # Signal file was created, so mount failed
+ slxlog "pam-offenburg" "Mount of 'HOME/USERS/$loggedInUser' to '$PERSISTENT_HOME_DIR' failed." "$ERRLOG"
+ elif kill -9 "${MOUNT_PID}" 2>/dev/null; then # ncpmount is still running, consider it failed and kill it
+ slxlog "pam-offenburg" "Mount of 'HOME/USERS/$loggedInUser' to '$PERSISTENT_HOME_DIR' timed out." "$ERRLOG"
+ else # mounting worked
+ chmod 777 "$PERSISTENT_HOME_DIR"
+ PERSISTENT_OK=yes
+ fi
+ rm -f -- "$SIGNAL"
+ rm -f -- "$ERRLOG"
+ fi
+fi
+