]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/PTY.pm
pty: fix read_password prototype
[pve-common.git] / src / PVE / PTY.pm
index 1178ea7a2da01eb29e6b2373a50445197cdaa1ec..23d76c0d02f9028d1b394ff32d5e8b6bb4fbf369 100644 (file)
@@ -165,7 +165,7 @@ sub tcsetsize($$$) {
        or die "failed to set window size: $!\n";
 }
 
-sub read_password(;$$) {
+sub read_password($;$$) {
     my ($query, $infd, $outfd) = @_;
 
     my $password = '';
@@ -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