sojuctl: don't use log.Fatalf in readPassword
This commit is contained in:
parent
0d6d297027
commit
c994ce7092
@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -125,12 +126,13 @@ func readPassword() ([]byte, error) {
|
|||||||
fmt.Printf("\n")
|
fmt.Printf("\n")
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(os.Stderr, "Warning: Reading password from stdin.\n")
|
fmt.Fprintf(os.Stderr, "Warning: Reading password from stdin.\n")
|
||||||
|
// TODO: the buffering messes up repeated calls to readPassword
|
||||||
scanner := bufio.NewScanner(os.Stdin)
|
scanner := bufio.NewScanner(os.Stdin)
|
||||||
if !scanner.Scan() {
|
if !scanner.Scan() {
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
log.Fatalf("failed to read password from stdin: %v", err)
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Fatalf("failed to read password from stdin: stdin is empty")
|
return nil, io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
password = scanner.Bytes()
|
password = scanner.Bytes()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user