From bf4a04528b971288994d38b5fcd5ff468ea20c88 Mon Sep 17 00:00:00 2001 From: tteckster Date: Tue, 23 Apr 2024 06:55:18 -0400 Subject: [PATCH] Update build.func - Check for spaces and length in passwords - fixes https://github.com/tteck/Proxmox/issues/2843 --- misc/build.func | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/misc/build.func b/misc/build.func index c259eeaa..785fb6a6 100644 --- a/misc/build.func +++ b/misc/build.func @@ -230,17 +230,24 @@ advanced_settings() { fi done - if PW1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then - if [ -z $PW1 ]; then - PW1="Automatic Login" - PW="" + while true; do + if PW1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD(leave blank for automatic login)" 3>&1 1>&2 2>&3); then + if [ -z "$PW1" ]; then + PW1="Automatic Login" + PW="" + elif [[ "$PW1" == *" "* ]]; then + whiptail --msgbox "Password cannot contain spaces. Please try again." 8 58 + elif [ "${#PW1}" -lt 5 ]; then + whiptail --msgbox "Password must be at least 5 characters long. Please try again." 8 58 + else + PW="-password $PW1" + echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" + break + fi else - PW="-password $PW1" + exit-script fi - echo -e "${DGN}Using Root Password: ${BGN}$PW1${CL}" - else - exit-script - fi + done if CT_ID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Container ID" 8 58 $NEXTID --title "CONTAINER ID" 3>&1 1>&2 2>&3); then if [ -z "$CT_ID" ]; then