File 0386-kernel-Fix-io-get_password.patch of Package erlang
From 5da1a5575f7b1b3e3153319508d08a9198696f08 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 28 Feb 2024 10:35:26 +0100
Subject: [PATCH] kernel: Fix io:get_password
---
lib/kernel/src/group.erl | 24 ++++++++++++++-------
lib/kernel/test/interactive_shell_SUITE.erl | 16 ++++++++++++++
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/lib/kernel/src/group.erl b/lib/kernel/src/group.erl
index b552347c22..b5241a92b0 100644
--- a/lib/kernel/src/group.erl
+++ b/lib/kernel/src/group.erl
@@ -443,13 +443,21 @@ getopts(Drv,Buf) ->
%% {error,What,NewSaveBuffer}
get_password_chars(Drv,Shell,Buf) ->
- case get_password_line(Buf, Drv, Shell) of
- {done, Line, Buf1} ->
- {ok, Line, Buf1};
- interrupted ->
- {error, {error, interrupted}, []};
- terminated ->
- {exit, terminated}
+ case get(echo) of
+ true ->
+ case get_password_line(Buf, Drv, Shell) of
+ {done, Line, Buf1} ->
+ {ok, Line, Buf1};
+ interrupted ->
+ {error, {error, interrupted}, []};
+ terminated ->
+ {exit, terminated}
+ end;
+ false ->
+ %% Echo needs to be set to true, otherwise the
+ %% password will be printed to the shell and we
+ %% do not want that.
+ {error, {error, enotsup}, []}
end.
get_chars_n(Prompt, M, F, Xa, Drv, Shell, Buf, Encoding) ->
--
2.35.3