aboutsummaryrefslogtreecommitdiff
path: root/sshtool
diff options
context:
space:
mode:
authorArmaël Guéneau <armael.gueneau@ens-lyon.org>2024-04-27 11:56:53 +0200
committerArmaël Guéneau <armael.gueneau@ens-lyon.org>2024-04-27 11:56:53 +0200
commit14c6dae001fe533e4e999a74ced5a5ad26ac526d (patch)
treea35155686a9775cb7975934384fe5b5271593dd9 /sshtool
parent6307f7e62f85552cabb22ae69e14a797a974ee92 (diff)
downloadnixcfg-14c6dae001fe533e4e999a74ced5a5ad26ac526d.tar.gz
nixcfg-14c6dae001fe533e4e999a74ced5a5ad26ac526d.zip
sshtool: handle sudo passwords that contain quotes or backslashes
Diffstat (limited to 'sshtool')
-rwxr-xr-xsshtool6
1 files changed, 3 insertions, 3 deletions
diff --git a/sshtool b/sshtool
index 6841bd6..474cb6d 100755
--- a/sshtool
+++ b/sshtool
@@ -26,7 +26,7 @@ else
fi
if [ -z "$ROOT_PASS" ]; then
- read -s -p "Enter remote sudo password: " ROOT_PASS
+ read -r -s -p "Enter remote sudo password: " ROOT_PASS
echo
fi
@@ -37,11 +37,11 @@ function header {
cat <<EOF
cat > /tmp/deploytool_askpass_$RANDNAME <<EOG
#!/usr/bin/env sh
-echo "\\\$DEPLOYTOOL_ROOT_PASSWORD"
+echo "\\\$DEPLOYTOOL_ROOT_PASSWORD" | base64 -d
EOG
chmod +x /tmp/deploytool_askpass_$RANDNAME
export SUDO_ASKPASS=/tmp/deploytool_askpass_$RANDNAME
-export DEPLOYTOOL_ROOT_PASSWORD="$ROOT_PASS"
+export DEPLOYTOOL_ROOT_PASSWORD=$(echo $ROOT_PASS | base64)
sudo -A sh - <<'EOEVERYTHING'
set -e
EOF