Skip to content

Commit

Permalink
fix: Fail if RMT_PASSWORD is unset
Browse files Browse the repository at this point in the history
When RMT_PASSWORD wasn't set, openssl was waiting for the argument,
This could cause the Docker container to hang up.
  • Loading branch information
MoritzWeber0 committed Sep 19, 2023
1 parent 9290e7d commit 17321d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions readonly/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
# SPDX-License-Identifier: Apache-2.0

set -ex
set -exuo pipefail

line=$(grep techuser /etc/shadow);
echo ${line%%:*}:$(openssl passwd -6 -salt $(openssl rand -base64 16) $RMT_PASSWORD):${line#*:*:} > /etc/shadow;
echo ${line%%:*}:$(openssl passwd -6 -salt $(openssl rand -base64 16) "${RMT_PASSWORD:?}"):${line#*:*:} > /etc/shadow;
unset RMT_PASSWORD

# Prepare Workspace
Expand Down
5 changes: 3 additions & 2 deletions remote/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors
# SPDX-License-Identifier: Apache-2.0

set -e
set -exuo pipefail

if [ "$(whoami)" == "root" ] || [ "$(whoami)" == "techuser" ];
then
line=$(grep techuser /etc/shadow);
echo ${line%%:*}:$(openssl passwd -6 -salt $(openssl rand -base64 16) $RMT_PASSWORD):${line#*:*:} > /etc/shadow;
echo ${line%%:*}:$(openssl passwd -6 -salt $(openssl rand -base64 16) "${RMT_PASSWORD:?}"):${line#*:*:} > /etc/shadow;
else
echo "Only techuser and root are supported as users.";
exit 1;
Expand Down

0 comments on commit 17321d4

Please sign in to comment.