mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Bump Microsoft/go-winio to v0.4.11
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
c15a478047
commit
a906968a3f
4 changed files with 167 additions and 169 deletions
|
@ -1,6 +1,6 @@
|
||||||
github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109
|
github.com/Azure/go-ansiterm d6e3b3328b783f23731bc4d058875b0371ff8109
|
||||||
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895
|
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895
|
||||||
github.com/Microsoft/go-winio v0.4.7
|
github.com/Microsoft/go-winio v0.4.11
|
||||||
github.com/Microsoft/hcsshim v0.7.3
|
github.com/Microsoft/hcsshim v0.7.3
|
||||||
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
|
||||||
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
|
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
|
||||||
|
|
274
libnetwork/vendor/github.com/Microsoft/go-winio/ea.go
generated
vendored
274
libnetwork/vendor/github.com/Microsoft/go-winio/ea.go
generated
vendored
|
@ -1,137 +1,137 @@
|
||||||
package winio
|
package winio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type fileFullEaInformation struct {
|
type fileFullEaInformation struct {
|
||||||
NextEntryOffset uint32
|
NextEntryOffset uint32
|
||||||
Flags uint8
|
Flags uint8
|
||||||
NameLength uint8
|
NameLength uint8
|
||||||
ValueLength uint16
|
ValueLength uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fileFullEaInformationSize = binary.Size(&fileFullEaInformation{})
|
fileFullEaInformationSize = binary.Size(&fileFullEaInformation{})
|
||||||
|
|
||||||
errInvalidEaBuffer = errors.New("invalid extended attribute buffer")
|
errInvalidEaBuffer = errors.New("invalid extended attribute buffer")
|
||||||
errEaNameTooLarge = errors.New("extended attribute name too large")
|
errEaNameTooLarge = errors.New("extended attribute name too large")
|
||||||
errEaValueTooLarge = errors.New("extended attribute value too large")
|
errEaValueTooLarge = errors.New("extended attribute value too large")
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExtendedAttribute represents a single Windows EA.
|
// ExtendedAttribute represents a single Windows EA.
|
||||||
type ExtendedAttribute struct {
|
type ExtendedAttribute struct {
|
||||||
Name string
|
Name string
|
||||||
Value []byte
|
Value []byte
|
||||||
Flags uint8
|
Flags uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseEa(b []byte) (ea ExtendedAttribute, nb []byte, err error) {
|
func parseEa(b []byte) (ea ExtendedAttribute, nb []byte, err error) {
|
||||||
var info fileFullEaInformation
|
var info fileFullEaInformation
|
||||||
err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &info)
|
err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errInvalidEaBuffer
|
err = errInvalidEaBuffer
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nameOffset := fileFullEaInformationSize
|
nameOffset := fileFullEaInformationSize
|
||||||
nameLen := int(info.NameLength)
|
nameLen := int(info.NameLength)
|
||||||
valueOffset := nameOffset + int(info.NameLength) + 1
|
valueOffset := nameOffset + int(info.NameLength) + 1
|
||||||
valueLen := int(info.ValueLength)
|
valueLen := int(info.ValueLength)
|
||||||
nextOffset := int(info.NextEntryOffset)
|
nextOffset := int(info.NextEntryOffset)
|
||||||
if valueLen+valueOffset > len(b) || nextOffset < 0 || nextOffset > len(b) {
|
if valueLen+valueOffset > len(b) || nextOffset < 0 || nextOffset > len(b) {
|
||||||
err = errInvalidEaBuffer
|
err = errInvalidEaBuffer
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ea.Name = string(b[nameOffset : nameOffset+nameLen])
|
ea.Name = string(b[nameOffset : nameOffset+nameLen])
|
||||||
ea.Value = b[valueOffset : valueOffset+valueLen]
|
ea.Value = b[valueOffset : valueOffset+valueLen]
|
||||||
ea.Flags = info.Flags
|
ea.Flags = info.Flags
|
||||||
if info.NextEntryOffset != 0 {
|
if info.NextEntryOffset != 0 {
|
||||||
nb = b[info.NextEntryOffset:]
|
nb = b[info.NextEntryOffset:]
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeExtendedAttributes decodes a list of EAs from a FILE_FULL_EA_INFORMATION
|
// DecodeExtendedAttributes decodes a list of EAs from a FILE_FULL_EA_INFORMATION
|
||||||
// buffer retrieved from BackupRead, ZwQueryEaFile, etc.
|
// buffer retrieved from BackupRead, ZwQueryEaFile, etc.
|
||||||
func DecodeExtendedAttributes(b []byte) (eas []ExtendedAttribute, err error) {
|
func DecodeExtendedAttributes(b []byte) (eas []ExtendedAttribute, err error) {
|
||||||
for len(b) != 0 {
|
for len(b) != 0 {
|
||||||
ea, nb, err := parseEa(b)
|
ea, nb, err := parseEa(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
eas = append(eas, ea)
|
eas = append(eas, ea)
|
||||||
b = nb
|
b = nb
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeEa(buf *bytes.Buffer, ea *ExtendedAttribute, last bool) error {
|
func writeEa(buf *bytes.Buffer, ea *ExtendedAttribute, last bool) error {
|
||||||
if int(uint8(len(ea.Name))) != len(ea.Name) {
|
if int(uint8(len(ea.Name))) != len(ea.Name) {
|
||||||
return errEaNameTooLarge
|
return errEaNameTooLarge
|
||||||
}
|
}
|
||||||
if int(uint16(len(ea.Value))) != len(ea.Value) {
|
if int(uint16(len(ea.Value))) != len(ea.Value) {
|
||||||
return errEaValueTooLarge
|
return errEaValueTooLarge
|
||||||
}
|
}
|
||||||
entrySize := uint32(fileFullEaInformationSize + len(ea.Name) + 1 + len(ea.Value))
|
entrySize := uint32(fileFullEaInformationSize + len(ea.Name) + 1 + len(ea.Value))
|
||||||
withPadding := (entrySize + 3) &^ 3
|
withPadding := (entrySize + 3) &^ 3
|
||||||
nextOffset := uint32(0)
|
nextOffset := uint32(0)
|
||||||
if !last {
|
if !last {
|
||||||
nextOffset = withPadding
|
nextOffset = withPadding
|
||||||
}
|
}
|
||||||
info := fileFullEaInformation{
|
info := fileFullEaInformation{
|
||||||
NextEntryOffset: nextOffset,
|
NextEntryOffset: nextOffset,
|
||||||
Flags: ea.Flags,
|
Flags: ea.Flags,
|
||||||
NameLength: uint8(len(ea.Name)),
|
NameLength: uint8(len(ea.Name)),
|
||||||
ValueLength: uint16(len(ea.Value)),
|
ValueLength: uint16(len(ea.Value)),
|
||||||
}
|
}
|
||||||
|
|
||||||
err := binary.Write(buf, binary.LittleEndian, &info)
|
err := binary.Write(buf, binary.LittleEndian, &info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = buf.Write([]byte(ea.Name))
|
_, err = buf.Write([]byte(ea.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = buf.WriteByte(0)
|
err = buf.WriteByte(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = buf.Write(ea.Value)
|
_, err = buf.Write(ea.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = buf.Write([]byte{0, 0, 0}[0 : withPadding-entrySize])
|
_, err = buf.Write([]byte{0, 0, 0}[0 : withPadding-entrySize])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncodeExtendedAttributes encodes a list of EAs into a FILE_FULL_EA_INFORMATION
|
// EncodeExtendedAttributes encodes a list of EAs into a FILE_FULL_EA_INFORMATION
|
||||||
// buffer for use with BackupWrite, ZwSetEaFile, etc.
|
// buffer for use with BackupWrite, ZwSetEaFile, etc.
|
||||||
func EncodeExtendedAttributes(eas []ExtendedAttribute) ([]byte, error) {
|
func EncodeExtendedAttributes(eas []ExtendedAttribute) ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
for i := range eas {
|
for i := range eas {
|
||||||
last := false
|
last := false
|
||||||
if i == len(eas)-1 {
|
if i == len(eas)-1 {
|
||||||
last = true
|
last = true
|
||||||
}
|
}
|
||||||
|
|
||||||
err := writeEa(&buf, &eas[i], last)
|
err := writeEa(&buf, &eas[i], last)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
3
libnetwork/vendor/github.com/Microsoft/go-winio/fileinfo.go
generated
vendored
3
libnetwork/vendor/github.com/Microsoft/go-winio/fileinfo.go
generated
vendored
|
@ -20,7 +20,8 @@ const (
|
||||||
// FileBasicInfo contains file access time and file attributes information.
|
// FileBasicInfo contains file access time and file attributes information.
|
||||||
type FileBasicInfo struct {
|
type FileBasicInfo struct {
|
||||||
CreationTime, LastAccessTime, LastWriteTime, ChangeTime syscall.Filetime
|
CreationTime, LastAccessTime, LastWriteTime, ChangeTime syscall.Filetime
|
||||||
FileAttributes uintptr // includes padding
|
FileAttributes uint32
|
||||||
|
pad uint32 // padding
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFileBasicInfo retrieves times and attributes for a file.
|
// GetFileBasicInfo retrieves times and attributes for a file.
|
||||||
|
|
57
libnetwork/vendor/github.com/Microsoft/go-winio/pipe.go
generated
vendored
57
libnetwork/vendor/github.com/Microsoft/go-winio/pipe.go
generated
vendored
|
@ -15,7 +15,6 @@ import (
|
||||||
//sys connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) = ConnectNamedPipe
|
//sys connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) = ConnectNamedPipe
|
||||||
//sys createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateNamedPipeW
|
//sys createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateNamedPipeW
|
||||||
//sys createFile(name string, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateFileW
|
//sys createFile(name string, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateFileW
|
||||||
//sys waitNamedPipe(name string, timeout uint32) (err error) = WaitNamedPipeW
|
|
||||||
//sys getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) = GetNamedPipeInfo
|
//sys getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) = GetNamedPipeInfo
|
||||||
//sys getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
|
//sys getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
|
||||||
//sys localAlloc(uFlags uint32, length uint32) (ptr uintptr) = LocalAlloc
|
//sys localAlloc(uFlags uint32, length uint32) (ptr uintptr) = LocalAlloc
|
||||||
|
@ -121,6 +120,11 @@ func (f *win32MessageBytePipe) Read(b []byte) (int, error) {
|
||||||
// zero-byte message, ensure that all future Read() calls
|
// zero-byte message, ensure that all future Read() calls
|
||||||
// also return EOF.
|
// also return EOF.
|
||||||
f.readEOF = true
|
f.readEOF = true
|
||||||
|
} else if err == syscall.ERROR_MORE_DATA {
|
||||||
|
// ERROR_MORE_DATA indicates that the pipe's read mode is message mode
|
||||||
|
// and the message still has more bytes. Treat this as a success, since
|
||||||
|
// this package presents all named pipes as byte streams.
|
||||||
|
err = nil
|
||||||
}
|
}
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
@ -134,12 +138,14 @@ func (s pipeAddress) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialPipe connects to a named pipe by path, timing out if the connection
|
// DialPipe connects to a named pipe by path, timing out if the connection
|
||||||
// takes longer than the specified duration. If timeout is nil, then the timeout
|
// takes longer than the specified duration. If timeout is nil, then we use
|
||||||
// is the default timeout established by the pipe server.
|
// a default timeout of 5 seconds. (We do not use WaitNamedPipe.)
|
||||||
func DialPipe(path string, timeout *time.Duration) (net.Conn, error) {
|
func DialPipe(path string, timeout *time.Duration) (net.Conn, error) {
|
||||||
var absTimeout time.Time
|
var absTimeout time.Time
|
||||||
if timeout != nil {
|
if timeout != nil {
|
||||||
absTimeout = time.Now().Add(*timeout)
|
absTimeout = time.Now().Add(*timeout)
|
||||||
|
} else {
|
||||||
|
absTimeout = time.Now().Add(time.Second * 2)
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
var h syscall.Handle
|
var h syscall.Handle
|
||||||
|
@ -148,22 +154,13 @@ func DialPipe(path string, timeout *time.Duration) (net.Conn, error) {
|
||||||
if err != cERROR_PIPE_BUSY {
|
if err != cERROR_PIPE_BUSY {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
now := time.Now()
|
if time.Now().After(absTimeout) {
|
||||||
var ms uint32
|
return nil, ErrTimeout
|
||||||
if absTimeout.IsZero() {
|
|
||||||
ms = cNMPWAIT_USE_DEFAULT_WAIT
|
|
||||||
} else if now.After(absTimeout) {
|
|
||||||
ms = cNMPWAIT_NOWAIT
|
|
||||||
} else {
|
|
||||||
ms = uint32(absTimeout.Sub(now).Nanoseconds() / 1000 / 1000)
|
|
||||||
}
|
|
||||||
err = waitNamedPipe(path, ms)
|
|
||||||
if err != nil {
|
|
||||||
if err == cERROR_SEM_TIMEOUT {
|
|
||||||
return nil, ErrTimeout
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait 10 msec and try again. This is a rather simplistic
|
||||||
|
// view, as we always try each 10 milliseconds.
|
||||||
|
time.Sleep(time.Millisecond * 10)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &os.PathError{Op: "open", Path: path, Err: err}
|
return nil, &os.PathError{Op: "open", Path: path, Err: err}
|
||||||
|
@ -175,16 +172,6 @@ func DialPipe(path string, timeout *time.Duration) (net.Conn, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var state uint32
|
|
||||||
err = getNamedPipeHandleState(h, &state, nil, nil, nil, nil, 0)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if state&cPIPE_READMODE_MESSAGE != 0 {
|
|
||||||
return nil, &os.PathError{Op: "open", Path: path, Err: errors.New("message readmode pipes not supported")}
|
|
||||||
}
|
|
||||||
|
|
||||||
f, err := makeWin32File(h)
|
f, err := makeWin32File(h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
syscall.Close(h)
|
syscall.Close(h)
|
||||||
|
@ -354,13 +341,23 @@ func ListenPipe(path string, c *PipeConfig) (net.Listener, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// Immediately open and then close a client handle so that the named pipe is
|
// Create a client handle and connect it. This results in the pipe
|
||||||
// created but not currently accepting connections.
|
// instance always existing, so that clients see ERROR_PIPE_BUSY
|
||||||
|
// rather than ERROR_FILE_NOT_FOUND. This ties the first instance
|
||||||
|
// up so that no other instances can be used. This would have been
|
||||||
|
// cleaner if the Win32 API matched CreateFile with ConnectNamedPipe
|
||||||
|
// instead of CreateNamedPipe. (Apparently created named pipes are
|
||||||
|
// considered to be in listening state regardless of whether any
|
||||||
|
// active calls to ConnectNamedPipe are outstanding.)
|
||||||
h2, err := createFile(path, 0, 0, nil, syscall.OPEN_EXISTING, cSECURITY_SQOS_PRESENT|cSECURITY_ANONYMOUS, 0)
|
h2, err := createFile(path, 0, 0, nil, syscall.OPEN_EXISTING, cSECURITY_SQOS_PRESENT|cSECURITY_ANONYMOUS, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
syscall.Close(h)
|
syscall.Close(h)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// Close the client handle. The server side of the instance will
|
||||||
|
// still be busy, leading to ERROR_PIPE_BUSY instead of
|
||||||
|
// ERROR_NOT_FOUND, as long as we don't close the server handle,
|
||||||
|
// or disconnect the client with DisconnectNamedPipe.
|
||||||
syscall.Close(h2)
|
syscall.Close(h2)
|
||||||
l := &win32PipeListener{
|
l := &win32PipeListener{
|
||||||
firstHandle: h,
|
firstHandle: h,
|
||||||
|
|
Loading…
Reference in a new issue