rstudio/pam_script_auth.sh
3wc b97a7f679f
All checks were successful
continuous-integration/drone/push Build is passing
Stable UIDs for PAM/UNIX users for Keycloak login
Ref https://github.com/WASHNote/washnote-apps/issues/67
2023-02-22 12:18:22 -05:00

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