Remove password masking from admin password prompt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 15:27:59 -05:00
parent 66142dcb3c
commit 73802ad96c

View File

@@ -19,7 +19,6 @@ import subprocess
import sys
import termios
import time
import tty
import urllib.error
import urllib.request
from base64 import b64encode
@@ -93,44 +92,16 @@ def draw_box(lines: list, colour: str = C.CYN):
# ── Input helpers ─────────────────────────────────────────────────────────────
def prompt(label: str, default: str = "", password: bool = False) -> str:
def prompt(label: str, default: str = "") -> str:
display = f" {_c(C.CYN, label)}"
if default:
display += f" {_c(C.DIM, f'[{default}]')}"
display += ": "
if password:
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
sys.stdout.write(display)
sys.stdout.flush()
chars = []
while True:
ch = sys.stdin.read(1)
if ch in ("\r", "\n"):
break
elif ch in ("\x7f", "\x08"):
if chars:
chars.pop()
sys.stdout.write("\b \b")
sys.stdout.flush()
elif ch == "\x03":
raise KeyboardInterrupt
else:
chars.append(ch)
sys.stdout.write("*")
sys.stdout.flush()
print()
return "".join(chars)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)
else:
sys.stdout.write(display)
sys.stdout.flush()
val = sys.stdin.readline().strip()
return val if val else default
sys.stdout.write(display)
sys.stdout.flush()
val = sys.stdin.readline().strip()
return val if val else default
def prompt_ip(label: str) -> str:
@@ -155,7 +126,6 @@ def prompt_password() -> str:
while True:
val = prompt(
"Admin password (BMC/chassis serial, e.g. MXE3000043CHA007)",
password=True,
)
if val:
return val