From 513ce6d619a49ca471ac810beb80012b1d752daa Mon Sep 17 00:00:00 2001 From: smail Date: Sat, 19 Sep 2026 22:23:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E8=BE=93=E5=85=A5=E6=8F=90=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E4=B8=AD=E6=96=87=E5=86=92=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/services/adminreset/password_linux.go | 1 + backend/services/adminreset/password_windows.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/services/adminreset/password_linux.go b/backend/services/adminreset/password_linux.go index fbba0e5..00732de 100644 --- a/backend/services/adminreset/password_linux.go +++ b/backend/services/adminreset/password_linux.go @@ -46,6 +46,7 @@ func ReadVisibleInput(prompt string) (string, error) { } func readSystemdInput(prompt, echo string) (string, error) { + prompt = strings.TrimRight(prompt, ":: ") + ":" // systemd 代理把提示保存在单行配置中,用终端换行控制显示列表,避免配置被拆行。 prompt = strings.ReplaceAll(strings.ReplaceAll(prompt, "\r\n", "\n"), "\n", "\x1bE") command := exec.Command("systemd-ask-password", "--no-tty", "--echo="+echo, prompt) diff --git a/backend/services/adminreset/password_windows.go b/backend/services/adminreset/password_windows.go index d6945cd..b70a700 100644 --- a/backend/services/adminreset/password_windows.go +++ b/backend/services/adminreset/password_windows.go @@ -40,7 +40,7 @@ func readWindowsPassword(prompt string) (string, error) { if !term.IsTerminal(int(os.Stdin.Fd())) { return "", errors.New("受保护的密码输入需要交互式控制台") } - fmt.Fprint(os.Stderr, prompt+": ") + fmt.Fprint(os.Stderr, strings.TrimRight(prompt, ":: ")+": ") valueBytes, err := term.ReadPassword(int(os.Stdin.Fd())) fmt.Fprintln(os.Stderr) if err != nil {