mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-05-13 12:15:03 +00:00
Improve password handling and validation logic (#10925)
This commit is contained in:
committed by
GitHub
parent
e21ab1500b
commit
6e66359d8f
+33
-5
@@ -582,7 +582,22 @@ base_settings() {
|
|||||||
CORE_COUNT="${final_cpu}"
|
CORE_COUNT="${final_cpu}"
|
||||||
RAM_SIZE="${final_ram}"
|
RAM_SIZE="${final_ram}"
|
||||||
VERBOSE=${var_verbose:-"${1:-no}"}
|
VERBOSE=${var_verbose:-"${1:-no}"}
|
||||||
PW=${var_pw:-""}
|
PW=""
|
||||||
|
if [[ -n "${var_pw:-}" ]]; then
|
||||||
|
local _pw_raw="${var_pw}"
|
||||||
|
case "$_pw_raw" in
|
||||||
|
--password\ *) _pw_raw="${_pw_raw#--password }" ;;
|
||||||
|
-password\ *) _pw_raw="${_pw_raw#-password }" ;;
|
||||||
|
esac
|
||||||
|
while [[ "$_pw_raw" == -* ]]; do
|
||||||
|
_pw_raw="${_pw_raw#-}"
|
||||||
|
done
|
||||||
|
if [[ -z "$_pw_raw" ]]; then
|
||||||
|
msg_warn "Password was only dashes after cleanup; leaving empty."
|
||||||
|
else
|
||||||
|
PW="--password $_pw_raw"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Validate and set Container ID
|
# Validate and set Container ID
|
||||||
local requested_id="${var_ctid:-$NEXTID}"
|
local requested_id="${var_ctid:-$NEXTID}"
|
||||||
@@ -1392,17 +1407,30 @@ advanced_settings() {
|
|||||||
((STEP++))
|
((STEP++))
|
||||||
elif [[ "$PW1" == *" "* ]]; then
|
elif [[ "$PW1" == *" "* ]]; then
|
||||||
whiptail --msgbox "Password cannot contain spaces." 8 58
|
whiptail --msgbox "Password cannot contain spaces." 8 58
|
||||||
elif ((${#PW1} < 5)); then
|
|
||||||
whiptail --msgbox "Password must be at least 5 characters." 8 58
|
|
||||||
else
|
else
|
||||||
|
local _pw1_clean="$PW1"
|
||||||
|
while [[ "$_pw1_clean" == -* ]]; do
|
||||||
|
_pw1_clean="${_pw1_clean#-}"
|
||||||
|
done
|
||||||
|
if [[ -z "$_pw1_clean" ]]; then
|
||||||
|
whiptail --msgbox "Password cannot be only '-' characters." 8 58
|
||||||
|
continue
|
||||||
|
elif ((${#_pw1_clean} < 5)); then
|
||||||
|
whiptail --msgbox "Password must be at least 5 characters (after removing leading '-')." 8 70
|
||||||
|
continue
|
||||||
|
fi
|
||||||
# Verify password
|
# Verify password
|
||||||
if PW2=$(whiptail --backtitle "Proxmox VE Helper Scripts [Step $STEP/$MAX_STEP]" \
|
if PW2=$(whiptail --backtitle "Proxmox VE Helper Scripts [Step $STEP/$MAX_STEP]" \
|
||||||
--title "PASSWORD VERIFICATION" \
|
--title "PASSWORD VERIFICATION" \
|
||||||
--ok-button "Confirm" --cancel-button "Back" \
|
--ok-button "Confirm" --cancel-button "Back" \
|
||||||
--passwordbox "\nVerify Root Password" 10 58 \
|
--passwordbox "\nVerify Root Password" 10 58 \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [[ "$PW1" == "$PW2" ]]; then
|
local _pw2_clean="$PW2"
|
||||||
_pw="-password $PW1"
|
while [[ "$_pw2_clean" == -* ]]; do
|
||||||
|
_pw2_clean="${_pw2_clean#-}"
|
||||||
|
done
|
||||||
|
if [[ "$_pw1_clean" == "$_pw2_clean" ]]; then
|
||||||
|
_pw="--password $_pw1_clean"
|
||||||
_pw_display="********"
|
_pw_display="********"
|
||||||
((STEP++))
|
((STEP++))
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user