Skip to content

Commit

Permalink
fix: Fail if RMT_PASSWORD is not set but used
Browse files Browse the repository at this point in the history
  • Loading branch information
dominik003 committed Sep 20, 2023
1 parent 16bf16c commit 12bf0bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion readonly/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

set -exuo pipefail

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

# Prepare Workspace
Expand Down
4 changes: 3 additions & 1 deletion remote/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ set -exuo pipefail

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

0 comments on commit 12bf0bf

Please sign in to comment.