blob: 08d3019501dab7e2f3563b7e0549f47b591892bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
|