Merge pull request #60373 from sttts/sttts-1.10-cfssl

Automatic merge from submit-queue (batch tested with PRs 60373, 61098, 61352, 61359, 61362). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Bump cfssl to be compatible with Go 1.10

Kubernetes-commit: ef3539e69e4c897f48ecd6b2dd73417ce0416b08
This commit is contained in:
Kubernetes Publisher 2018-03-21 22:39:09 -07:00
commit 30089d3674
4 changed files with 73 additions and 77 deletions

60
Godeps/Godeps.json generated
View File

@ -164,7 +164,7 @@
},
{
"ImportPath": "golang.org/x/crypto/ssh/terminal",
"Rev": "81e90905daefcd6fd217b62423c0908922eadb30"
"Rev": "49796115aa4b964c318aad4f3084fdb41e9aa067"
},
{
"ImportPath": "golang.org/x/net/context",
@ -248,119 +248,119 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "2448346d4164b057ffdbe114c1a85e5c6742a1f0"
"Rev": "7e796de92438aede7cb5d6bcf6c10f4fa65db560"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",

View File

@ -617,7 +617,7 @@ func writeWithCRLF(w io.Writer, buf []byte) (n int, err error) {
if _, err = w.Write(crlf); err != nil {
return n, err
}
n += 1
n++
buf = buf[1:]
}
}

View File

@ -17,44 +17,41 @@
package terminal
import (
"syscall"
"unsafe"
"golang.org/x/sys/unix"
)
// State contains the state of a terminal.
type State struct {
termios syscall.Termios
termios unix.Termios
}
// IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal(fd int) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
_, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
return err == nil
}
// MakeRaw put the terminal connected to the given file descriptor into raw
// mode and returns the previous state of the terminal so that it can be
// restored.
func MakeRaw(fd int) (*State, error) {
var oldState State
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 {
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
if err != nil {
return nil, err
}
newState := oldState.termios
oldState := State{termios: *termios}
// This attempts to replicate the behaviour documented for cfmakeraw in
// the termios(3) manpage.
newState.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON
newState.Oflag &^= syscall.OPOST
newState.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN
newState.Cflag &^= syscall.CSIZE | syscall.PARENB
newState.Cflag |= syscall.CS8
newState.Cc[unix.VMIN] = 1
newState.Cc[unix.VTIME] = 0
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 {
termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
termios.Oflag &^= unix.OPOST
termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
termios.Cflag &^= unix.CSIZE | unix.PARENB
termios.Cflag |= unix.CS8
termios.Cc[unix.VMIN] = 1
termios.Cc[unix.VTIME] = 0
if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, termios); err != nil {
return nil, err
}
@ -64,59 +61,55 @@ func MakeRaw(fd int) (*State, error) {
// GetState returns the current state of a terminal which may be useful to
// restore the terminal after a signal.
func GetState(fd int) (*State, error) {
var oldState State
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 {
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
if err != nil {
return nil, err
}
return &oldState, nil
return &State{termios: *termios}, nil
}
// Restore restores the terminal connected to the given file descriptor to a
// previous state.
func Restore(fd int, state *State) error {
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&state.termios)), 0, 0, 0); err != 0 {
return err
}
return nil
return unix.IoctlSetTermios(fd, ioctlWriteTermios, &state.termios)
}
// GetSize returns the dimensions of the given terminal.
func GetSize(fd int) (width, height int, err error) {
var dimensions [4]uint16
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0); err != 0 {
ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ)
if err != nil {
return -1, -1, err
}
return int(dimensions[1]), int(dimensions[0]), nil
return int(ws.Col), int(ws.Row), nil
}
// passwordReader is an io.Reader that reads from a specific file descriptor.
type passwordReader int
func (r passwordReader) Read(buf []byte) (int, error) {
return syscall.Read(int(r), buf)
return unix.Read(int(r), buf)
}
// ReadPassword reads a line of input from a terminal without local echo. This
// is commonly used for inputting passwords and other sensitive data. The slice
// returned does not include the \n.
func ReadPassword(fd int) ([]byte, error) {
var oldState syscall.Termios
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0); err != 0 {
termios, err := unix.IoctlGetTermios(fd, ioctlReadTermios)
if err != nil {
return nil, err
}
newState := oldState
newState.Lflag &^= syscall.ECHO
newState.Lflag |= syscall.ICANON | syscall.ISIG
newState.Iflag |= syscall.ICRNL
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 {
newState := *termios
newState.Lflag &^= unix.ECHO
newState.Lflag |= unix.ICANON | unix.ISIG
newState.Iflag |= unix.ICRNL
if err := unix.IoctlSetTermios(fd, ioctlWriteTermios, &newState); err != nil {
return nil, err
}
defer func() {
syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(&oldState)), 0, 0, 0)
unix.IoctlSetTermios(fd, ioctlWriteTermios, termios)
}()
return readPasswordLine(passwordReader(fd))

View File

@ -17,6 +17,8 @@
package terminal
import (
"os"
"golang.org/x/sys/windows"
)
@ -71,13 +73,6 @@ func GetSize(fd int) (width, height int, err error) {
return int(info.Size.X), int(info.Size.Y), nil
}
// passwordReader is an io.Reader that reads from a specific Windows HANDLE.
type passwordReader int
func (r passwordReader) Read(buf []byte) (int, error) {
return windows.Read(windows.Handle(r), buf)
}
// ReadPassword reads a line of input from a terminal without local echo. This
// is commonly used for inputting passwords and other sensitive data. The slice
// returned does not include the \n.
@ -98,5 +93,13 @@ func ReadPassword(fd int) ([]byte, error) {
windows.SetConsoleMode(windows.Handle(fd), old)
}()
return readPasswordLine(passwordReader(fd))
var h windows.Handle
p, _ := windows.GetCurrentProcess()
if err := windows.DuplicateHandle(p, windows.Handle(fd), p, &h, 0, false, windows.DUPLICATE_SAME_ACCESS); err != nil {
return nil, err
}
f := os.NewFile(uintptr(h), "stdin")
defer f.Close()
return readPasswordLine(f)
}