From 45d187c2203f8cbd4134968d3b5e00952c65ec72 Mon Sep 17 00:00:00 2001 From: Kjeld Flarup Date: Fri, 8 Apr 2022 10:52:06 +0200 Subject: [PATCH 1/3] Change adduser to useradd as adduser does not accept UID larger than 256000 Signed-off-by: Kjeld Flarup --- Dockerfile | 1 + scripts/create-hash.sh | 4 ++-- scripts/entrypoint.sh | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b186e5c..d3519c5 100755 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ ENV PATH="/container/scripts:${PATH}" RUN apk add --no-cache runit \ avahi \ samba \ + shadow \ \ && sed -i 's/#enable-dbus=.*/enable-dbus=no/g' /etc/avahi/avahi-daemon.conf \ && rm -vf /etc/avahi/services/* \ diff --git a/scripts/create-hash.sh b/scripts/create-hash.sh index c232e94..3a571ff 100755 --- a/scripts/create-hash.sh +++ b/scripts/create-hash.sh @@ -14,7 +14,7 @@ echo if [ "$PASSWORD_1" == "$PASSWORD_2" ] && [ "$PASSWORD_1" != "" ] && [ "$USERNAME" != "" ] then - adduser -D -H -s /bin/false "$USERNAME" 2> /dev/null >/dev/null + useradd -u "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" 2> /dev/null >/dev/null smbpasswd -a -n "$USERNAME" 2> /dev/null >/dev/null echo -e "$PASSWORD_1\n$PASSWORD_1" | passwd "$USERNAME" 2> /dev/null >/dev/null echo -e "$PASSWORD_1\n$PASSWORD_1" | smbpasswd "$USERNAME" 2> /dev/null >/dev/null @@ -22,4 +22,4 @@ then exit 0 fi -exit 1 \ No newline at end of file +exit 1 diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 71ee12d..9510a78 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -87,10 +87,10 @@ if [ ! -f "$INITALIZED" ]; then if [ "$ACCOUNT_UID" -gt 0 ] 2>/dev/null then echo ">> ACCOUNT: adding account: $ACCOUNT_NAME with UID: $ACCOUNT_UID" - adduser -D -H -u "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" + useradd -u "$ACCOUNT_UID" -s /bin/false "$ACCOUNT_NAME" else echo ">> ACCOUNT: adding account: $ACCOUNT_NAME" - adduser -D -H -s /bin/false "$ACCOUNT_NAME" + useradd -s /bin/false "$ACCOUNT_NAME" fi smbpasswd -a -n "$ACCOUNT_NAME" From b1c26675fc170de30e2a55369657ed6f042374a8 Mon Sep 17 00:00:00 2001 From: Kjeld Flarup Date: Fri, 8 Apr 2022 11:12:03 +0200 Subject: [PATCH 2/3] Change addgroup to groupadd when creating groups to allow large GID Signed-off-by: Kjeld Flarup --- scripts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 9510a78..b0f2032 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -71,7 +71,7 @@ if [ ! -f "$INITALIZED" ]; then GROUP_NAME=$(echo "$I_CONF" | sed 's/^GROUP_//g' | sed 's/=.*//g') GROUP_ID=$(echo "$I_CONF" | sed 's/^[^=]*=//g') echo ">> GROUP: adding group $GROUP_NAME with GID: $GROUP_ID" - addgroup -g "$GROUP_ID" "$GROUP_NAME" + groupadd -g "$GROUP_ID" "$GROUP_NAME" done ## From 2672f9c1d43a525fcccdadd3a1f4ce938a656b24 Mon Sep 17 00:00:00 2001 From: Kjeld Flarup Date: Sun, 27 Oct 2024 02:53:49 +0200 Subject: [PATCH 3/3] Also change to usermod when assigning user to group Signed-off-by: Kjeld Flarup --- scripts/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index b0f2032..1f389e7 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -110,7 +110,7 @@ if [ ! -f "$INITALIZED" ]; then ACCOUNT_GROUPS=$(env | grep '^GROUPS_'"$ACCOUNT_NAME" | sed 's/^[^=]*=//g') for GRP in $(echo "$ACCOUNT_GROUPS" | tr ',' '\n' | grep .); do echo ">> ACCOUNT: adding account: $ACCOUNT_NAME to group: $GRP" - addgroup "$ACCOUNT_NAME" "$GRP" + usermod -aG "$GRP" "$ACCOUNT_NAME" done unset $(echo "$I_ACCOUNT" | cut -d'=' -f1)