################################################################### # # 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//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