Skip to content

Commit 68de006

Browse files
committed
Enhance user creation process in serversideup-create-unprivileged-user script by setting accounts to expired for Alpine and using a locked password for Debian, ensuring accounts remain unlocked while preventing unauthorized access.
1 parent ecefe7e commit 68de006

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/rootfs/usr/local/bin/serversideup-create-unprivileged-user

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ PGID="$3"
2525
if [ -f /etc/alpine-release ]; then
2626
# Alpine
2727
addgroup -g "${PGID}" "${username}" && \
28-
adduser -u "${PUID}" -G "${username}" -h "/home/${username}" -s /bin/sh -D "${username}"
28+
adduser -u "${PUID}" -G "${username}" -h "/home/${username}" -s /bin/sh -D "${username}" && \
29+
# Set account to expired but not locked
30+
chage -E 0 "${username}"
2931
else
3032
# Debian
3133
addgroup --gid "${PGID}" "${username}" && \
3234
adduser --uid "${PUID}" \
3335
--gid "${PGID}" \
3436
--home "/home/${username}" \
3537
--shell /bin/bash \
38+
--disabled-password \
3639
--gecos '' \
37-
"${username}"
40+
"${username}" && \
41+
# Set a locked password that can't be used but keeps the account unlocked
42+
usermod -p '!' "${username}"
3843
fi

0 commit comments

Comments
 (0)