diff options
author | Jonathan Bauer | 2015-04-07 15:48:18 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-04-07 15:48:18 +0200 |
commit | fa69e01ba28c3c6b3f706b07fbe0647d3f5e509e (patch) | |
tree | 738a8de56129c406434c614d4303632de29b7a6c | |
parent | [pam] fix annoying errors when logging out of ttys (diff) | |
download | tm-scripts-fa69e01ba28c3c6b3f706b07fbe0647d3f5e509e.tar.gz tm-scripts-fa69e01ba28c3c6b3f706b07fbe0647d3f5e509e.tar.xz tm-scripts-fa69e01ba28c3c6b3f706b07fbe0647d3f5e509e.zip |
[pam-common-share] rudimentary nfs-support for common share
when SLX_SHARE_0_PATH is not starting with double backslash, it
is assumed that we have nfs share. Version negiotation is done by the client,
even though we will probably want a finer control for the mount options
-rw-r--r-- | remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share | 87 |
1 files changed, 53 insertions, 34 deletions
diff --git a/remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share b/remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share index a492e248..670943f4 100644 --- a/remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share +++ b/remote/modules/pam-common-share/data/opt/openslx/scripts/pam_script_mount_common_share @@ -54,11 +54,6 @@ mount_share() { # prepare common mount options for either authentication type MOUNT_OPTS="-t cifs -o nounix,uid=${USER_UID},gid=${USER_GID},forceuid,forcegid,nobrl,noacl,$SHARE_PERM" - # flag for failure - SIGNAL=$(mktemp) - rm -f -- "${SIGNAL}" - # output of command - MOUNT_OUTPUT=$(mktemp) # now construct the mount options depending on the type of the share. if [ "${SHARE_AUTH_TYPE}" = "guest" ]; then MOUNT_OPTS="${MOUNT_OPTS},guest,file_mode=0777,dir_mode=0777" @@ -78,44 +73,68 @@ mount_share() { slxlog "pam-share-auth" "Share${SHARE_NUM}: Auth type '${SHARE_AUTH_TYPE}' not supported." return; fi + else + # for now assume NFS-Share, start build options string with default options for all shares + MOUNT_OPTS="-t nfs -o async,nolock" - # we just mount it to the directory with the same name as the - # last directory in the path name of the share - # e.g. //windows.net/lehrpool -> ${COMMON_SHARE_MOUNT_POINT}/lehrpool - local TARGET_DIR="${COMMON_SHARE_MOUNT_POINT}/$(basename ${SHARE_PATH})" - # it exists, so let's create ${COMMON_SHARE_MOUNT_POINT}/lehrpool_${SHARE_NUM} - [ -d "${TARGET_DIR}" ] && TARGET_DIR="${TARGET_DIR}_${SHARE_NUM}" + # TODO: here we will have to evaluate options of NFS-shares - # at this point is TARGET_DIR pointing to the right directory. - mkdir -p "${TARGET_DIR}" || \ - { slxlog "pam-share-mkdirfail" "Share${SHARE_NUM}: Could not create directory '${TARGET_DIR}'. Skipping share."; return; } - # now try to mount it - ( mount ${MOUNT_OPTS} "${SHARE_PATH}" "${TARGET_DIR}" > "${MOUNT_OUTPUT}" 2>&1 || touch "${SIGNAL}" ) & - MOUNT_PID=$! - for COUNTER in 1 1 2 4; do - kill -0 "${MOUNT_PID}" 2>/dev/null || break - sleep "${COUNTER}" - done + # unless specified otherwise, mount the share read-only + [ "x${SHARE_PERM}" != "xrw" ] && SHARE_PERM='ro' + MOUNT_OPTS="${MOUNT_OPTS},${SHARE_PERM}" + fi - # check for failures - if [ -e "${SIGNAL}" ]; then - slxlog "pam-share-mount" "Mount of '${SHARE_PATH}' to '${TARGET_DIR}' failed. (Args: ${MOUNT_OPTS}" "${MOUNT_OUTPUT}" - rm -f -- "${SIGNAL}" - elif kill -9 "${MOUNT_PID}" 2>/dev/null; then - slxlog "pam-share-mount" "Mount of '${SHARE_PATH}' to '${TARGET_DIR}' timed out. (Args: ${MOUNT_OPTS}" "${MOUNT_OUTPUT}" - fi - ( sleep 2; rm -f -- "${MOUNT_OUTPUT}" ) & + ############################################################################ + # + # Following code is independent of the type of share. + # The variable MOUNT_OPTS should have been set correctly + # up to this point. + # + ############################################################################ + + # we just mount it to the directory with the same name as the + # last directory in the path name of the share + # e.g. //windows.net/lehrpool -> ${COMMON_SHARE_MOUNT_POINT}/lehrpool + local TARGET_DIR="${COMMON_SHARE_MOUNT_POINT}/$(basename ${SHARE_PATH})" + # it exists, so let's create ${COMMON_SHARE_MOUNT_POINT}/lehrpool_${SHARE_NUM} + [ -d "${TARGET_DIR}" ] && TARGET_DIR="${TARGET_DIR}_${SHARE_NUM}" + + # at this point is TARGET_DIR pointing to the right directory. + mkdir -p "${TARGET_DIR}" || \ + { slxlog "pam-share-mkdirfail" "Share${SHARE_NUM}: Could not create directory '${TARGET_DIR}'. Skipping share."; return; } + + # flag for failure + SIGNAL=$(mktemp) + rm -f -- "${SIGNAL}" + # output of command + MOUNT_OUTPUT=$(mktemp) + # now try to mount it + ( mount ${MOUNT_OPTS} "${SHARE_PATH}" "${TARGET_DIR}" > "${MOUNT_OUTPUT}" 2>&1 || touch "${SIGNAL}" ) & + MOUNT_PID=$! + for COUNTER in 1 1 2 4; do + kill -0 "${MOUNT_PID}" 2>/dev/null || break + sleep "${COUNTER}" + done - # always unset credentials - unset USER - unset PASSWD + # check for failures + if [ -e "${SIGNAL}" ]; then + slxlog "pam-share-mount" "Mount of '${SHARE_PATH}' to '${TARGET_DIR}' failed. (Args: ${MOUNT_OPTS}" "${MOUNT_OUTPUT}" + rm -f -- "${SIGNAL}" + elif kill -9 "${MOUNT_PID}" 2>/dev/null; then + slxlog "pam-share-mount" "Mount of '${SHARE_PATH}' to '${TARGET_DIR}' timed out. (Args: ${MOUNT_OPTS}" "${MOUNT_OUTPUT}" fi + ( sleep 2; rm -f -- "${MOUNT_OUTPUT}" ) & + + # always unset credentials + unset USER + unset PASSWD } -################################################################### +############################################################################ # -# MAIN SCRIPT +# MAIN LOGIC OVER ALL SHARES # +############################################################################ # at this point we need the slx config to do anything [ -e "/opt/openslx/config" ] || \ { slxlog "pam-share-noconfig" "File '/opt/openslx/config' not found."; return; } |