summaryrefslogtreecommitdiffstats
path: root/core/modules/pam-slx-plug/data/opt/openslx/pam/common/homedir-passwd
diff options
context:
space:
mode:
authorSimon Rettberg2018-03-08 17:14:42 +0100
committerSimon Rettberg2018-03-08 17:14:42 +0100
commit53f8946416b456476d130334490790c3979d2f82 (patch)
tree6d2483d84477e109de568455ab96aa2cf807b253 /core/modules/pam-slx-plug/data/opt/openslx/pam/common/homedir-passwd
parent[hardware-stats] check if '--no-legend' is needed (diff)
downloadmltk-53f8946416b456476d130334490790c3979d2f82.tar.gz
mltk-53f8946416b456476d130334490790c3979d2f82.tar.xz
mltk-53f8946416b456476d130334490790c3979d2f82.zip
[pam-slx-plug] Starting to separate some of the pam/nsswitch logic out of sssd/pam
Preparation for our own ldap/ad login handling, sssd will only be used for nsswitch related stuff and fallback.
Diffstat (limited to 'core/modules/pam-slx-plug/data/opt/openslx/pam/common/homedir-passwd')
-rw-r--r--core/modules/pam-slx-plug/data/opt/openslx/pam/common/homedir-passwd27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/modules/pam-slx-plug/data/opt/openslx/pam/common/homedir-passwd b/core/modules/pam-slx-plug/data/opt/openslx/pam/common/homedir-passwd
new file mode 100644
index 00000000..20b7991d
--- /dev/null
+++ b/core/modules/pam-slx-plug/data/opt/openslx/pam/common/homedir-passwd
@@ -0,0 +1,27 @@
+#!/bin/ash -- sourced
+
+# Required vars from context:
+# USER_UID
+# USER_GID
+# USER_NAME
+
+# 1) Sanitize the user's home directory, stored and updated in USER_HOME
+
+# 2) Write entry to /etc/passwd if it doesn't exist
+
+# Fixup local home path
+if [ -z "$USER_HOME" ] || [ "${USER_HOME:0:1}" = '\' ] || [ "${USER_HOME:1:1}" = ':' ]; then
+ USER_HOME="/home/_temp-home/$USER_NAME"
+else
+ # Make sure it's absolute, replace spaces, '\' and ':' by '_'
+ USER_HOME=$(echo "$USER_HOME" | sed -r 's,^(/*)(.*)$,/\2,;s/(:|\s|\\)+/_/g')
+fi
+readonly USER_HOME
+
+# Add/replace passwd entry if it doesn't exist yet
+PASSWD="${USER_NAME}:x:${USER_UID}:${USER_GID}:${USER_NAME}:${USER_HOME}:/bin/bash"
+readonly PASSWD
+if ! grep -Fxq -- "${PASSWD}" /etc/passwd; then
+ sed -i "/^${USER_NAME}:/d" /etc/passwd
+ echo "${PASSWD}" >> /etc/passwd
+fi