mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-27 11:44:45 +00:00
read_password improvements
* Cancel on Ctrl+C (die()) * Finish on Ctrl+D (eof/eot) without appending a newline * Also finish on \n to be sure. Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com> Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Tested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
590b924e19
commit
ee29490fe0
@ -194,10 +194,13 @@ sub read_password(;$$) {
|
||||
syswrite($outfd, $query, length($query));
|
||||
while (($got = sysread($infd, $ch, 1))) {
|
||||
my ($ord) = unpack('C', $ch);
|
||||
if ($ord == 0xD) {
|
||||
last if $ord == 4; # ^D / EOF
|
||||
if ($ord == 0xA || $ord == 0xD) {
|
||||
# newline, we're done
|
||||
syswrite($outfd, "\r\n", 2);
|
||||
last;
|
||||
} elsif ($ord == 3) { # ^C
|
||||
die "password input aborted\n";
|
||||
} elsif ($ord == 0x7f) {
|
||||
# backspace - if it's the first key disable
|
||||
# asterisks
|
||||
|
Loading…
Reference in New Issue
Block a user