rstudio/pam_script_auth.sh

19 lines
594 B
Bash
Executable File

#!/bin/bash
if [ -z "$PAM_USER" ]; then
echo "did not receive PAM_USER env var"
exit 1
fi
if ! id "$PAM_USER" &>/dev/null; then
# NOTE(3wc): This generates a stable UID for the user based on the username;
# without it, UID→username mapping changes on every container restart, which
# creates file ownership issues and prevents RStudio from working.
# See https://github.com/WASHNote/washnote-apps/issues/67
uid=$(echo "$PAM_USER" | md5sum | grep -Eo "[[:digit:]]{3}" | head -n1)
uid=$((1000+uid))
adduser --uid="$uid" "$PAM_USER" --disabled-password --quiet --gecos ""
fi
exit 0