1
0
mirror of https://github.com/bitwarden/server synced 2026-01-06 02:23:51 +00:00

Revert "Use user primary group if not root (#292)"

This reverts commit ec89c36ca0.
This commit is contained in:
Kyle Spearrin
2018-05-29 19:17:48 -04:00
parent ec89c36ca0
commit 0f675d8ccb
11 changed files with 393 additions and 164 deletions

View File

@@ -172,10 +172,7 @@ SA_PASSWORD=SECRET
Helpers.Exec("chmod 600 /bitwarden/env/mssql.override.env");
// Empty uid env file. Only used on Linux hosts.
if(!File.Exists("/bitwarden/env/uid.env"))
{
using(var sw = File.CreateText("/bitwarden/env/uid.env")) { }
}
using(var sw = File.CreateText("/bitwarden/env/uid.env")) { }
}
}
}

View File

@@ -5,27 +5,52 @@
GROUPNAME="bitwarden"
USERNAME="bitwarden"
LUID=${LOCAL_UID:-0}
LGID=${LOCAL_GID:-0}
CURRENTGID=`getent group $GROUPNAME | cut -d: -f3`
LGID=${LOCAL_GID:-999}
# Step down from host root to well-known nobody/nogroup user
NOUSER=`id -u $USERNAME > /dev/null 2>&1; echo $?`
LUID=${LOCAL_UID:-999}
if [ $LUID -eq 0 ]
# Step down from host root
if [ $LGID == 0 ]
then
LUID=65534
fi
if [ $LGID -eq 0 ]
then
LGID=65534
LGID=999
fi
# Create user and group
if [ $LUID == 0 ]
then
LUID=999
fi
groupadd -o -g $LGID $GROUPNAME >/dev/null 2>&1 ||
groupmod -o -g $LGID $GROUPNAME >/dev/null 2>&1
useradd -o -u $LUID -g $GROUPNAME -s /bin/false $USERNAME >/dev/null 2>&1 ||
usermod -o -u $LUID -g $GROUPNAME -s /bin/false $USERNAME >/dev/null 2>&1
mkhomedir_helper $USERNAME
# Create group
if [ $CURRENTGID ]
then
if [ "$CURRENTGID" != "$LGID" ]
then
groupmod -g $LGID $GROUPNAME
fi
else
groupadd -g $LGID $GROUPNAME
fi
# Create user and assign group
if [ $NOUSER == 0 ] && [ `id -u $USERNAME` != $LUID ]
then
usermod -u $LUID $USERNAME
elif [ $NOUSER == 1 ]
then
useradd -r -u $LUID -g $GROUPNAME $USERNAME
fi
# Make home directory for user
if [ ! -d "/home/$USERNAME" ]
then
mkhomedir_helper $USERNAME
fi
# The rest...