open-vault/helper/password/password_unix.go
Vishal Nayak 28e3eb9e2c
Errwrap everywhere (#4252)
* package api

* package builtin/credential

* package builtin/logical

* package command

* package helper

* package http and logical

* package physical

* package shamir

* package vault

* package vault

* address feedback

* more fixes
2018-04-05 11:49:21 -04:00

26 lines
426 B
Go

// +build linux darwin freebsd netbsd openbsd
package password
import (
"fmt"
"os"
"golang.org/x/crypto/ssh/terminal"
)
func read(f *os.File) (string, error) {
fd := int(f.Fd())
if !terminal.IsTerminal(fd) {
return "", fmt.Errorf("file descriptor %d is not a terminal", fd)
}
oldState, err := terminal.MakeRaw(fd)
if err != nil {
return "", err
}
defer terminal.Restore(fd, oldState)
return readline(f)
}