open-vault/helper/password/password_unix.go
Steve Wills 7244094509 allow building on FreeBSD
Allow this file to build on FreeBSD
2015-06-19 16:59:24 -04:00

26 lines
411 B
Go

// +build linux darwin freebsd
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)
}