chore(deps): update module github.com/pkg/sftp to v1.13.10 #10
177 changed files with 29998 additions and 1119 deletions
10
go.mod
10
go.mod
|
|
@ -1,14 +1,14 @@
|
||||||
module idun
|
module idun
|
||||||
|
|
||||||
go 1.21
|
go 1.23.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/aws/aws-sdk-go v1.55.5
|
github.com/aws/aws-sdk-go v1.55.5
|
||||||
github.com/pkg/sftp v1.13.6
|
github.com/pkg/sftp v1.13.10
|
||||||
github.com/rs/zerolog v1.33.0
|
github.com/rs/zerolog v1.33.0
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.10.0
|
||||||
github.com/urfave/cli/v2 v2.27.4
|
github.com/urfave/cli/v2 v2.27.4
|
||||||
golang.org/x/crypto v0.27.0
|
golang.org/x/crypto v0.41.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -22,5 +22,5 @@ require (
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||||
golang.org/x/sys v0.25.0 // indirect
|
golang.org/x/sys v0.35.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
|
||||||
8
go.sum
8
go.sum
|
|
@ -25,6 +25,8 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/sftp v1.13.6 h1:JFZT4XbOU7l77xGSpOdW+pwIMqP044IyjXX6FGyEKFo=
|
github.com/pkg/sftp v1.13.6 h1:JFZT4XbOU7l77xGSpOdW+pwIMqP044IyjXX6FGyEKFo=
|
||||||
github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk=
|
github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk=
|
||||||
|
github.com/pkg/sftp v1.13.10 h1:+5FbKNTe5Z9aspU88DPIKJ9z2KZoaGCu6Sr6kKR/5mU=
|
||||||
|
github.com/pkg/sftp v1.13.10/go.mod h1:bJ1a7uDhrX/4OII+agvy28lzRvQrmIQuaHrcI1HbeGA=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
|
|
@ -42,6 +44,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
|
||||||
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
|
||||||
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
|
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
|
||||||
|
|
@ -58,6 +62,8 @@ golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||||
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
||||||
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||||
|
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
|
||||||
|
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
|
@ -80,6 +86,8 @@ golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||||
|
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
|
|
||||||
13
vendor/github.com/pkg/sftp/SECURITY.md
generated
vendored
Normal file
13
vendor/github.com/pkg/sftp/SECURITY.md
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
Security updates are provided for the latest released version of this package.
|
||||||
|
We also welcome vulnerability reports for the development version to help us ensure it is secure before the next release.
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
If you believe you’ve found a security vulnerability in this project, we strongly encourage you to report it privately using GitHub’s [security advisory system](https://github.com/pkg/sftp/security/advisories/new).
|
||||||
|
This will allow us to review and address the issue before public disclosure.
|
||||||
|
|
||||||
|
Thank you for helping us keep the project secure.
|
||||||
19
vendor/github.com/pkg/sftp/attrs.go
generated
vendored
19
vendor/github.com/pkg/sftp/attrs.go
generated
vendored
|
|
@ -32,10 +32,10 @@ func (fi *fileInfo) Name() string { return fi.name }
|
||||||
func (fi *fileInfo) Size() int64 { return int64(fi.stat.Size) }
|
func (fi *fileInfo) Size() int64 { return int64(fi.stat.Size) }
|
||||||
|
|
||||||
// Mode returns file mode bits.
|
// Mode returns file mode bits.
|
||||||
func (fi *fileInfo) Mode() os.FileMode { return toFileMode(fi.stat.Mode) }
|
func (fi *fileInfo) Mode() os.FileMode { return fi.stat.FileMode() }
|
||||||
|
|
||||||
// ModTime returns the last modification time of the file.
|
// ModTime returns the last modification time of the file.
|
||||||
func (fi *fileInfo) ModTime() time.Time { return time.Unix(int64(fi.stat.Mtime), 0) }
|
func (fi *fileInfo) ModTime() time.Time { return fi.stat.ModTime() }
|
||||||
|
|
||||||
// IsDir returns true if the file is a directory.
|
// IsDir returns true if the file is a directory.
|
||||||
func (fi *fileInfo) IsDir() bool { return fi.Mode().IsDir() }
|
func (fi *fileInfo) IsDir() bool { return fi.Mode().IsDir() }
|
||||||
|
|
@ -56,6 +56,21 @@ type FileStat struct {
|
||||||
Extended []StatExtended
|
Extended []StatExtended
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ModTime returns the Mtime SFTP file attribute converted to a time.Time
|
||||||
|
func (fs *FileStat) ModTime() time.Time {
|
||||||
|
return time.Unix(int64(fs.Mtime), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessTime returns the Atime SFTP file attribute converted to a time.Time
|
||||||
|
func (fs *FileStat) AccessTime() time.Time {
|
||||||
|
return time.Unix(int64(fs.Atime), 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FileMode returns the Mode SFTP file attribute converted to an os.FileMode
|
||||||
|
func (fs *FileStat) FileMode() os.FileMode {
|
||||||
|
return toFileMode(fs.Mode)
|
||||||
|
}
|
||||||
|
|
||||||
// StatExtended contains additional, extended information for a FileStat.
|
// StatExtended contains additional, extended information for a FileStat.
|
||||||
type StatExtended struct {
|
type StatExtended struct {
|
||||||
ExtType string
|
ExtType string
|
||||||
|
|
|
||||||
4
vendor/github.com/pkg/sftp/attrs_unix.go
generated
vendored
4
vendor/github.com/pkg/sftp/attrs_unix.go
generated
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
//go:build darwin || dragonfly || freebsd || (!android && linux) || netbsd || openbsd || solaris || aix || js
|
//go:build darwin || dragonfly || freebsd || (!android && linux) || netbsd || openbsd || solaris || aix || js || zos
|
||||||
// +build darwin dragonfly freebsd !android,linux netbsd openbsd solaris aix js
|
// +build darwin dragonfly freebsd !android,linux netbsd openbsd solaris aix js zos
|
||||||
|
|
||||||
package sftp
|
package sftp
|
||||||
|
|
||||||
|
|
|
||||||
476
vendor/github.com/pkg/sftp/client.go
generated
vendored
476
vendor/github.com/pkg/sftp/client.go
generated
vendored
|
|
@ -2,6 +2,7 @@ package sftp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -16,6 +17,8 @@ import (
|
||||||
|
|
||||||
"github.com/kr/fs"
|
"github.com/kr/fs"
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
|
|
||||||
|
"github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -155,6 +158,17 @@ func UseFstat(value bool) ClientOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CopyStderrTo specifies a writer to which the standard error of the remote sftp-server command should be written.
|
||||||
|
//
|
||||||
|
// The writer passed in will not be automatically closed.
|
||||||
|
// It is the responsibility of the caller to coordinate closure of any writers.
|
||||||
|
func CopyStderrTo(wr io.Writer) ClientOption {
|
||||||
|
return func(c *Client) error {
|
||||||
|
c.stderrTo = wr
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Client represents an SFTP session on a *ssh.ClientConn SSH connection.
|
// Client represents an SFTP session on a *ssh.ClientConn SSH connection.
|
||||||
// Multiple Clients can be active on a single SSH connection, and a Client
|
// Multiple Clients can be active on a single SSH connection, and a Client
|
||||||
// may be called concurrently from multiple Goroutines.
|
// may be called concurrently from multiple Goroutines.
|
||||||
|
|
@ -163,6 +177,8 @@ func UseFstat(value bool) ClientOption {
|
||||||
type Client struct {
|
type Client struct {
|
||||||
clientConn
|
clientConn
|
||||||
|
|
||||||
|
stderrTo io.Writer
|
||||||
|
|
||||||
ext map[string]string // Extensions (name -> data).
|
ext map[string]string // Extensions (name -> data).
|
||||||
|
|
||||||
maxPacket int // max packet size read or written.
|
maxPacket int // max packet size read or written.
|
||||||
|
|
@ -183,9 +199,7 @@ func NewClient(conn *ssh.Client, opts ...ClientOption) (*Client, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := s.RequestSubsystem("sftp"); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
pw, err := s.StdinPipe()
|
pw, err := s.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -194,15 +208,27 @@ func NewClient(conn *ssh.Client, opts ...ClientOption) (*Client, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
perr, err := s.StderrPipe()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return NewClientPipe(pr, pw, opts...)
|
if err := s.RequestSubsystem("sftp"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return newClientPipe(pr, perr, pw, s.Wait, opts...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClientPipe creates a new SFTP client given a Reader and a WriteCloser.
|
// NewClientPipe creates a new SFTP client given a Reader and a WriteCloser.
|
||||||
// This can be used for connecting to an SFTP server over TCP/TLS or by using
|
// This can be used for connecting to an SFTP server over TCP/TLS or by using
|
||||||
// the system's ssh client program (e.g. via exec.Command).
|
// the system's ssh client program (e.g. via exec.Command).
|
||||||
func NewClientPipe(rd io.Reader, wr io.WriteCloser, opts ...ClientOption) (*Client, error) {
|
func NewClientPipe(rd io.Reader, wr io.WriteCloser, opts ...ClientOption) (*Client, error) {
|
||||||
sftp := &Client{
|
return newClientPipe(rd, nil, wr, nil, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newClientPipe(rd, stderr io.Reader, wr io.WriteCloser, wait func() error, opts ...ClientOption) (*Client, error) {
|
||||||
|
c := &Client{
|
||||||
clientConn: clientConn{
|
clientConn: clientConn{
|
||||||
conn: conn{
|
conn: conn{
|
||||||
Reader: rd,
|
Reader: rd,
|
||||||
|
|
@ -210,6 +236,7 @@ func NewClientPipe(rd io.Reader, wr io.WriteCloser, opts ...ClientOption) (*Clie
|
||||||
},
|
},
|
||||||
inflight: make(map[uint32]chan<- result),
|
inflight: make(map[uint32]chan<- result),
|
||||||
closed: make(chan struct{}),
|
closed: make(chan struct{}),
|
||||||
|
wait: wait,
|
||||||
},
|
},
|
||||||
|
|
||||||
ext: make(map[string]string),
|
ext: make(map[string]string),
|
||||||
|
|
@ -219,32 +246,50 @@ func NewClientPipe(rd io.Reader, wr io.WriteCloser, opts ...ClientOption) (*Clie
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
if err := opt(sftp); err != nil {
|
if err := opt(c); err != nil {
|
||||||
wr.Close()
|
wr.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := sftp.sendInit(); err != nil {
|
if stderr != nil {
|
||||||
|
wr := io.Discard
|
||||||
|
if c.stderrTo != nil {
|
||||||
|
wr = c.stderrTo
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
// DO NOT close the writer!
|
||||||
|
// Programs may pass in `os.Stderr` to write the remote stderr to,
|
||||||
|
// and the program may continue after disconnect by reconnecting.
|
||||||
|
// But if we've closed their stderr, then we just messed everything up.
|
||||||
|
|
||||||
|
if _, err := io.Copy(wr, stderr); err != nil {
|
||||||
|
debug("error copying stderr: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.sendInit(); err != nil {
|
||||||
wr.Close()
|
wr.Close()
|
||||||
return nil, fmt.Errorf("error sending init packet to server: %w", err)
|
return nil, fmt.Errorf("error sending init packet to server: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := sftp.recvVersion(); err != nil {
|
if err := c.recvVersion(); err != nil {
|
||||||
wr.Close()
|
wr.Close()
|
||||||
return nil, fmt.Errorf("error receiving version packet from server: %w", err)
|
return nil, fmt.Errorf("error receiving version packet from server: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sftp.clientConn.wg.Add(1)
|
c.clientConn.wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer sftp.clientConn.wg.Done()
|
defer c.clientConn.wg.Done()
|
||||||
|
|
||||||
if err := sftp.clientConn.recv(); err != nil {
|
if err := c.clientConn.recv(); err != nil {
|
||||||
sftp.clientConn.broadcastErr(err)
|
c.clientConn.broadcastErr(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return sftp, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create creates the named file mode 0666 (before umask), truncating it if it
|
// Create creates the named file mode 0666 (before umask), truncating it if it
|
||||||
|
|
@ -256,7 +301,7 @@ func NewClientPipe(rd io.Reader, wr io.WriteCloser, opts ...ClientOption) (*Clie
|
||||||
// read/write at the same time. For those services you will need to use
|
// read/write at the same time. For those services you will need to use
|
||||||
// `client.OpenFile(os.O_WRONLY|os.O_CREATE|os.O_TRUNC)`.
|
// `client.OpenFile(os.O_WRONLY|os.O_CREATE|os.O_TRUNC)`.
|
||||||
func (c *Client) Create(path string) (*File, error) {
|
func (c *Client) Create(path string) (*File, error) {
|
||||||
return c.open(path, flags(os.O_RDWR|os.O_CREATE|os.O_TRUNC))
|
return c.open(path, toPflags(os.O_RDWR|os.O_CREATE|os.O_TRUNC))
|
||||||
}
|
}
|
||||||
|
|
||||||
const sftpProtocolVersion = 3 // https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt
|
const sftpProtocolVersion = 3 // https://filezilla-project.org/specs/draft-ietf-secsh-filexfer-02.txt
|
||||||
|
|
@ -321,19 +366,27 @@ func (c *Client) Walk(root string) *fs.Walker {
|
||||||
return fs.WalkFS(root, c)
|
return fs.WalkFS(root, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadDir reads the directory named by dirname and returns a list of
|
// ReadDir reads the directory named by p
|
||||||
// directory entries.
|
// and returns a list of directory entries.
|
||||||
func (c *Client) ReadDir(p string) ([]os.FileInfo, error) {
|
func (c *Client) ReadDir(p string) ([]os.FileInfo, error) {
|
||||||
handle, err := c.opendir(p)
|
return c.ReadDirContext(context.Background(), p)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadDirContext reads the directory named by p
|
||||||
|
// and returns a list of directory entries.
|
||||||
|
// The passed context can be used to cancel the operation
|
||||||
|
// returning all entries listed up to the cancellation.
|
||||||
|
func (c *Client) ReadDirContext(ctx context.Context, p string) ([]os.FileInfo, error) {
|
||||||
|
handle, err := c.opendir(ctx, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer c.close(handle) // this has to defer earlier than the lock below
|
defer c.close(handle) // this has to defer earlier than the lock below
|
||||||
var attrs []os.FileInfo
|
var entries []os.FileInfo
|
||||||
var done = false
|
var done = false
|
||||||
for !done {
|
for !done {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err1 := c.sendPacket(nil, &sshFxpReaddirPacket{
|
typ, data, err1 := c.sendPacket(ctx, nil, &sshFxpReaddirPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Handle: handle,
|
Handle: handle,
|
||||||
})
|
})
|
||||||
|
|
@ -354,11 +407,14 @@ func (c *Client) ReadDir(p string) ([]os.FileInfo, error) {
|
||||||
filename, data = unmarshalString(data)
|
filename, data = unmarshalString(data)
|
||||||
_, data = unmarshalString(data) // discard longname
|
_, data = unmarshalString(data) // discard longname
|
||||||
var attr *FileStat
|
var attr *FileStat
|
||||||
attr, data = unmarshalAttrs(data)
|
attr, data, err = unmarshalAttrs(data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if filename == "." || filename == ".." {
|
if filename == "." || filename == ".." {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
attrs = append(attrs, fileInfoFromStat(attr, path.Base(filename)))
|
entries = append(entries, fileInfoFromStat(attr, path.Base(filename)))
|
||||||
}
|
}
|
||||||
case sshFxpStatus:
|
case sshFxpStatus:
|
||||||
// TODO(dfc) scope warning!
|
// TODO(dfc) scope warning!
|
||||||
|
|
@ -371,12 +427,12 @@ func (c *Client) ReadDir(p string) ([]os.FileInfo, error) {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
return attrs, err
|
return entries, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) opendir(path string) (string, error) {
|
func (c *Client) opendir(ctx context.Context, path string) (string, error) {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpOpendirPacket{
|
typ, data, err := c.sendPacket(ctx, nil, &sshFxpOpendirPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: path,
|
Path: path,
|
||||||
})
|
})
|
||||||
|
|
@ -412,7 +468,7 @@ func (c *Client) Stat(p string) (os.FileInfo, error) {
|
||||||
// If 'p' is a symbolic link, the returned FileInfo structure describes the symbolic link.
|
// If 'p' is a symbolic link, the returned FileInfo structure describes the symbolic link.
|
||||||
func (c *Client) Lstat(p string) (os.FileInfo, error) {
|
func (c *Client) Lstat(p string) (os.FileInfo, error) {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpLstatPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpLstatPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: p,
|
Path: p,
|
||||||
})
|
})
|
||||||
|
|
@ -425,7 +481,11 @@ func (c *Client) Lstat(p string) (os.FileInfo, error) {
|
||||||
if sid != id {
|
if sid != id {
|
||||||
return nil, &unexpectedIDErr{id, sid}
|
return nil, &unexpectedIDErr{id, sid}
|
||||||
}
|
}
|
||||||
attr, _ := unmarshalAttrs(data)
|
attr, _, err := unmarshalAttrs(data)
|
||||||
|
if err != nil {
|
||||||
|
// avoid returning a valid value from fileInfoFromStats if err != nil.
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return fileInfoFromStat(attr, path.Base(p)), nil
|
return fileInfoFromStat(attr, path.Base(p)), nil
|
||||||
case sshFxpStatus:
|
case sshFxpStatus:
|
||||||
return nil, normaliseError(unmarshalStatus(id, data))
|
return nil, normaliseError(unmarshalStatus(id, data))
|
||||||
|
|
@ -437,7 +497,7 @@ func (c *Client) Lstat(p string) (os.FileInfo, error) {
|
||||||
// ReadLink reads the target of a symbolic link.
|
// ReadLink reads the target of a symbolic link.
|
||||||
func (c *Client) ReadLink(p string) (string, error) {
|
func (c *Client) ReadLink(p string) (string, error) {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpReadlinkPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpReadlinkPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: p,
|
Path: p,
|
||||||
})
|
})
|
||||||
|
|
@ -466,7 +526,7 @@ func (c *Client) ReadLink(p string) (string, error) {
|
||||||
// Link creates a hard link at 'newname', pointing at the same inode as 'oldname'
|
// Link creates a hard link at 'newname', pointing at the same inode as 'oldname'
|
||||||
func (c *Client) Link(oldname, newname string) error {
|
func (c *Client) Link(oldname, newname string) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpHardlinkPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpHardlinkPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Oldpath: oldname,
|
Oldpath: oldname,
|
||||||
Newpath: newname,
|
Newpath: newname,
|
||||||
|
|
@ -485,7 +545,7 @@ func (c *Client) Link(oldname, newname string) error {
|
||||||
// Symlink creates a symbolic link at 'newname', pointing at target 'oldname'
|
// Symlink creates a symbolic link at 'newname', pointing at target 'oldname'
|
||||||
func (c *Client) Symlink(oldname, newname string) error {
|
func (c *Client) Symlink(oldname, newname string) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpSymlinkPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpSymlinkPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Linkpath: newname,
|
Linkpath: newname,
|
||||||
Targetpath: oldname,
|
Targetpath: oldname,
|
||||||
|
|
@ -501,9 +561,9 @@ func (c *Client) Symlink(oldname, newname string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) setfstat(handle string, flags uint32, attrs interface{}) error {
|
func (c *Client) fsetstat(handle string, flags uint32, attrs interface{}) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpFsetstatPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpFsetstatPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Handle: handle,
|
Handle: handle,
|
||||||
Flags: flags,
|
Flags: flags,
|
||||||
|
|
@ -523,7 +583,7 @@ func (c *Client) setfstat(handle string, flags uint32, attrs interface{}) error
|
||||||
// setstat is a convience wrapper to allow for changing of various parts of the file descriptor.
|
// setstat is a convience wrapper to allow for changing of various parts of the file descriptor.
|
||||||
func (c *Client) setstat(path string, flags uint32, attrs interface{}) error {
|
func (c *Client) setstat(path string, flags uint32, attrs interface{}) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpSetstatPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpSetstatPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: path,
|
Path: path,
|
||||||
Flags: flags,
|
Flags: flags,
|
||||||
|
|
@ -577,23 +637,37 @@ func (c *Client) Truncate(path string, size int64) error {
|
||||||
return c.setstat(path, sshFileXferAttrSize, uint64(size))
|
return c.setstat(path, sshFileXferAttrSize, uint64(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetExtendedData sets extended attributes of the named file. It uses the
|
||||||
|
// SSH_FILEXFER_ATTR_EXTENDED flag in the setstat request.
|
||||||
|
//
|
||||||
|
// This flag provides a general extension mechanism for vendor-specific extensions.
|
||||||
|
// Names of the attributes should be a string of the format "name@domain", where "domain"
|
||||||
|
// is a valid, registered domain name and "name" identifies the method. Server
|
||||||
|
// implementations SHOULD ignore extended data fields that they do not understand.
|
||||||
|
func (c *Client) SetExtendedData(path string, extended []StatExtended) error {
|
||||||
|
attrs := &FileStat{
|
||||||
|
Extended: extended,
|
||||||
|
}
|
||||||
|
return c.setstat(path, sshFileXferAttrExtended, attrs)
|
||||||
|
}
|
||||||
|
|
||||||
// Open opens the named file for reading. If successful, methods on the
|
// Open opens the named file for reading. If successful, methods on the
|
||||||
// returned file can be used for reading; the associated file descriptor
|
// returned file can be used for reading; the associated file descriptor
|
||||||
// has mode O_RDONLY.
|
// has mode O_RDONLY.
|
||||||
func (c *Client) Open(path string) (*File, error) {
|
func (c *Client) Open(path string) (*File, error) {
|
||||||
return c.open(path, flags(os.O_RDONLY))
|
return c.open(path, toPflags(os.O_RDONLY))
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenFile is the generalized open call; most users will use Open or
|
// OpenFile is the generalized open call; most users will use Open or
|
||||||
// Create instead. It opens the named file with specified flag (O_RDONLY
|
// Create instead. It opens the named file with specified flag (O_RDONLY
|
||||||
// etc.). If successful, methods on the returned File can be used for I/O.
|
// etc.). If successful, methods on the returned File can be used for I/O.
|
||||||
func (c *Client) OpenFile(path string, f int) (*File, error) {
|
func (c *Client) OpenFile(path string, f int) (*File, error) {
|
||||||
return c.open(path, flags(f))
|
return c.open(path, toPflags(f))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) open(path string, pflags uint32) (*File, error) {
|
func (c *Client) open(path string, pflags uint32) (*File, error) {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpOpenPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpOpenPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: path,
|
Path: path,
|
||||||
Pflags: pflags,
|
Pflags: pflags,
|
||||||
|
|
@ -621,7 +695,7 @@ func (c *Client) open(path string, pflags uint32) (*File, error) {
|
||||||
// immediately after this request has been sent.
|
// immediately after this request has been sent.
|
||||||
func (c *Client) close(handle string) error {
|
func (c *Client) close(handle string) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpClosePacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpClosePacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Handle: handle,
|
Handle: handle,
|
||||||
})
|
})
|
||||||
|
|
@ -638,7 +712,7 @@ func (c *Client) close(handle string) error {
|
||||||
|
|
||||||
func (c *Client) stat(path string) (*FileStat, error) {
|
func (c *Client) stat(path string) (*FileStat, error) {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpStatPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpStatPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: path,
|
Path: path,
|
||||||
})
|
})
|
||||||
|
|
@ -651,8 +725,8 @@ func (c *Client) stat(path string) (*FileStat, error) {
|
||||||
if sid != id {
|
if sid != id {
|
||||||
return nil, &unexpectedIDErr{id, sid}
|
return nil, &unexpectedIDErr{id, sid}
|
||||||
}
|
}
|
||||||
attr, _ := unmarshalAttrs(data)
|
attr, _, err := unmarshalAttrs(data)
|
||||||
return attr, nil
|
return attr, err
|
||||||
case sshFxpStatus:
|
case sshFxpStatus:
|
||||||
return nil, normaliseError(unmarshalStatus(id, data))
|
return nil, normaliseError(unmarshalStatus(id, data))
|
||||||
default:
|
default:
|
||||||
|
|
@ -662,7 +736,7 @@ func (c *Client) stat(path string) (*FileStat, error) {
|
||||||
|
|
||||||
func (c *Client) fstat(handle string) (*FileStat, error) {
|
func (c *Client) fstat(handle string) (*FileStat, error) {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpFstatPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpFstatPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Handle: handle,
|
Handle: handle,
|
||||||
})
|
})
|
||||||
|
|
@ -675,8 +749,8 @@ func (c *Client) fstat(handle string) (*FileStat, error) {
|
||||||
if sid != id {
|
if sid != id {
|
||||||
return nil, &unexpectedIDErr{id, sid}
|
return nil, &unexpectedIDErr{id, sid}
|
||||||
}
|
}
|
||||||
attr, _ := unmarshalAttrs(data)
|
attr, _, err := unmarshalAttrs(data)
|
||||||
return attr, nil
|
return attr, err
|
||||||
case sshFxpStatus:
|
case sshFxpStatus:
|
||||||
return nil, normaliseError(unmarshalStatus(id, data))
|
return nil, normaliseError(unmarshalStatus(id, data))
|
||||||
default:
|
default:
|
||||||
|
|
@ -691,7 +765,7 @@ func (c *Client) fstat(handle string) (*FileStat, error) {
|
||||||
func (c *Client) StatVFS(path string) (*StatVFS, error) {
|
func (c *Client) StatVFS(path string) (*StatVFS, error) {
|
||||||
// send the StatVFS packet to the server
|
// send the StatVFS packet to the server
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpStatvfsPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpStatvfsPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: path,
|
Path: path,
|
||||||
})
|
})
|
||||||
|
|
@ -728,25 +802,44 @@ func (c *Client) Join(elem ...string) string { return path.Join(elem...) }
|
||||||
// file or directory with the specified path exists, or if the specified directory
|
// file or directory with the specified path exists, or if the specified directory
|
||||||
// is not empty.
|
// is not empty.
|
||||||
func (c *Client) Remove(path string) error {
|
func (c *Client) Remove(path string) error {
|
||||||
err := c.removeFile(path)
|
errF := c.removeFile(path)
|
||||||
// some servers, *cough* osx *cough*, return EPERM, not ENODIR.
|
if errF == nil {
|
||||||
// serv-u returns ssh_FX_FILE_IS_A_DIRECTORY
|
return nil
|
||||||
// EPERM is converted to os.ErrPermission so it is not a StatusError
|
}
|
||||||
if err, ok := err.(*StatusError); ok {
|
|
||||||
switch err.Code {
|
errD := c.RemoveDirectory(path)
|
||||||
case sshFxFailure, sshFxFileIsADirectory:
|
if errD == nil {
|
||||||
return c.RemoveDirectory(path)
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Both failed: figure out which error to return.
|
||||||
|
|
||||||
|
if errF, ok := errF.(*os.PathError); ok {
|
||||||
|
// The only time it makes sense to compare errors, is when both are `*os.PathError`.
|
||||||
|
// We cannot test these directly with errF == errD, as that would be a pointer comparison.
|
||||||
|
|
||||||
|
if errD, ok := errD.(*os.PathError); ok && errors.Is(errF.Err, errD.Err) {
|
||||||
|
// If they are both pointers to PathError,
|
||||||
|
// and the same underlying error, then return that.
|
||||||
|
return errF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if os.IsPermission(err) {
|
|
||||||
return c.RemoveDirectory(path)
|
fi, err := c.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
return err
|
|
||||||
|
if fi.IsDir() {
|
||||||
|
return errD
|
||||||
|
}
|
||||||
|
|
||||||
|
return errF
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) removeFile(path string) error {
|
func (c *Client) removeFile(path string) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpRemovePacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpRemovePacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Filename: path,
|
Filename: path,
|
||||||
})
|
})
|
||||||
|
|
@ -755,7 +848,15 @@ func (c *Client) removeFile(path string) error {
|
||||||
}
|
}
|
||||||
switch typ {
|
switch typ {
|
||||||
case sshFxpStatus:
|
case sshFxpStatus:
|
||||||
return normaliseError(unmarshalStatus(id, data))
|
err = normaliseError(unmarshalStatus(id, data))
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &os.PathError{
|
||||||
|
Op: "remove",
|
||||||
|
Path: path,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return unimplementedPacketErr(typ)
|
return unimplementedPacketErr(typ)
|
||||||
}
|
}
|
||||||
|
|
@ -764,7 +865,7 @@ func (c *Client) removeFile(path string) error {
|
||||||
// RemoveDirectory removes a directory path.
|
// RemoveDirectory removes a directory path.
|
||||||
func (c *Client) RemoveDirectory(path string) error {
|
func (c *Client) RemoveDirectory(path string) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpRmdirPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpRmdirPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: path,
|
Path: path,
|
||||||
})
|
})
|
||||||
|
|
@ -773,7 +874,15 @@ func (c *Client) RemoveDirectory(path string) error {
|
||||||
}
|
}
|
||||||
switch typ {
|
switch typ {
|
||||||
case sshFxpStatus:
|
case sshFxpStatus:
|
||||||
return normaliseError(unmarshalStatus(id, data))
|
err = normaliseError(unmarshalStatus(id, data))
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &os.PathError{
|
||||||
|
Op: "remove",
|
||||||
|
Path: path,
|
||||||
|
Err: err,
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return unimplementedPacketErr(typ)
|
return unimplementedPacketErr(typ)
|
||||||
}
|
}
|
||||||
|
|
@ -782,7 +891,7 @@ func (c *Client) RemoveDirectory(path string) error {
|
||||||
// Rename renames a file.
|
// Rename renames a file.
|
||||||
func (c *Client) Rename(oldname, newname string) error {
|
func (c *Client) Rename(oldname, newname string) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpRenamePacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpRenamePacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Oldpath: oldname,
|
Oldpath: oldname,
|
||||||
Newpath: newname,
|
Newpath: newname,
|
||||||
|
|
@ -802,7 +911,7 @@ func (c *Client) Rename(oldname, newname string) error {
|
||||||
// which will replace newname if it already exists.
|
// which will replace newname if it already exists.
|
||||||
func (c *Client) PosixRename(oldname, newname string) error {
|
func (c *Client) PosixRename(oldname, newname string) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpPosixRenamePacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpPosixRenamePacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Oldpath: oldname,
|
Oldpath: oldname,
|
||||||
Newpath: newname,
|
Newpath: newname,
|
||||||
|
|
@ -824,7 +933,7 @@ func (c *Client) PosixRename(oldname, newname string) error {
|
||||||
// or relative pathnames without a leading slash into absolute paths.
|
// or relative pathnames without a leading slash into absolute paths.
|
||||||
func (c *Client) RealPath(path string) (string, error) {
|
func (c *Client) RealPath(path string) (string, error) {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpRealpathPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpRealpathPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: path,
|
Path: path,
|
||||||
})
|
})
|
||||||
|
|
@ -861,7 +970,7 @@ func (c *Client) Getwd() (string, error) {
|
||||||
// parent folder does not exist (the method cannot create complete paths).
|
// parent folder does not exist (the method cannot create complete paths).
|
||||||
func (c *Client) Mkdir(path string) error {
|
func (c *Client) Mkdir(path string) error {
|
||||||
id := c.nextID()
|
id := c.nextID()
|
||||||
typ, data, err := c.sendPacket(nil, &sshFxpMkdirPacket{
|
typ, data, err := c.sendPacket(context.Background(), nil, &sshFxpMkdirPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Path: path,
|
Path: path,
|
||||||
})
|
})
|
||||||
|
|
@ -879,7 +988,7 @@ func (c *Client) Mkdir(path string) error {
|
||||||
// MkdirAll creates a directory named path, along with any necessary parents,
|
// MkdirAll creates a directory named path, along with any necessary parents,
|
||||||
// and returns nil, or else returns an error.
|
// and returns nil, or else returns an error.
|
||||||
// If path is already a directory, MkdirAll does nothing and returns nil.
|
// If path is already a directory, MkdirAll does nothing and returns nil.
|
||||||
// If path contains a regular file, an error is returned
|
// If, while making any directory, that path is found to already be a regular file, an error is returned.
|
||||||
func (c *Client) MkdirAll(path string) error {
|
func (c *Client) MkdirAll(path string) error {
|
||||||
// Most of this code mimics https://golang.org/src/os/path.go?s=514:561#L13
|
// Most of this code mimics https://golang.org/src/os/path.go?s=514:561#L13
|
||||||
// Fast path: if we can tell whether path is a directory or file, stop with success or error.
|
// Fast path: if we can tell whether path is a directory or file, stop with success or error.
|
||||||
|
|
@ -965,18 +1074,34 @@ func (c *Client) RemoveAll(path string) error {
|
||||||
|
|
||||||
// File represents a remote file.
|
// File represents a remote file.
|
||||||
type File struct {
|
type File struct {
|
||||||
c *Client
|
c *Client
|
||||||
path string
|
path string
|
||||||
handle string
|
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.RWMutex
|
||||||
|
handle string
|
||||||
offset int64 // current offset within remote file
|
offset int64 // current offset within remote file
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the File, rendering it unusable for I/O. It returns an
|
// Close closes the File, rendering it unusable for I/O. It returns an
|
||||||
// error, if any.
|
// error, if any.
|
||||||
func (f *File) Close() error {
|
func (f *File) Close() error {
|
||||||
return f.c.close(f.handle)
|
f.mu.Lock()
|
||||||
|
defer f.mu.Unlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
// The design principle here is that when `openssh-portable/sftp-server.c` is doing `handle_close`,
|
||||||
|
// it will unconditionally mark the handle as unused,
|
||||||
|
// so we need to also unconditionally mark this handle as invalid.
|
||||||
|
// By invalidating our local copy of the handle,
|
||||||
|
// we ensure that there cannot be any erroneous use-after-close requests sent after Close.
|
||||||
|
|
||||||
|
handle := f.handle
|
||||||
|
f.handle = ""
|
||||||
|
|
||||||
|
return f.c.close(handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name returns the name of the file as presented to Open or Create.
|
// Name returns the name of the file as presented to Open or Create.
|
||||||
|
|
@ -997,7 +1122,7 @@ func (f *File) Read(b []byte) (int, error) {
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
defer f.mu.Unlock()
|
defer f.mu.Unlock()
|
||||||
|
|
||||||
n, err := f.ReadAt(b, f.offset)
|
n, err := f.readAt(b, f.offset)
|
||||||
f.offset += int64(n)
|
f.offset += int64(n)
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
@ -1007,7 +1132,7 @@ func (f *File) Read(b []byte) (int, error) {
|
||||||
func (f *File) readChunkAt(ch chan result, b []byte, off int64) (n int, err error) {
|
func (f *File) readChunkAt(ch chan result, b []byte, off int64) (n int, err error) {
|
||||||
for err == nil && n < len(b) {
|
for err == nil && n < len(b) {
|
||||||
id := f.c.nextID()
|
id := f.c.nextID()
|
||||||
typ, data, err := f.c.sendPacket(ch, &sshFxpReadPacket{
|
typ, data, err := f.c.sendPacket(context.Background(), ch, &sshFxpReadPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Handle: f.handle,
|
Handle: f.handle,
|
||||||
Offset: uint64(off) + uint64(n),
|
Offset: uint64(off) + uint64(n),
|
||||||
|
|
@ -1062,6 +1187,19 @@ func (f *File) readAtSequential(b []byte, off int64) (read int, err error) {
|
||||||
// the number of bytes read and an error, if any. ReadAt follows io.ReaderAt semantics,
|
// the number of bytes read and an error, if any. ReadAt follows io.ReaderAt semantics,
|
||||||
// so the file offset is not altered during the read.
|
// so the file offset is not altered during the read.
|
||||||
func (f *File) ReadAt(b []byte, off int64) (int, error) {
|
func (f *File) ReadAt(b []byte, off int64) (int, error) {
|
||||||
|
f.mu.RLock()
|
||||||
|
defer f.mu.RUnlock()
|
||||||
|
|
||||||
|
return f.readAt(b, off)
|
||||||
|
}
|
||||||
|
|
||||||
|
// readAt must be called while holding either the Read or Write mutex in File.
|
||||||
|
// This code is concurrent safe with itself, but not with Close.
|
||||||
|
func (f *File) readAt(b []byte, off int64) (int, error) {
|
||||||
|
if f.handle == "" {
|
||||||
|
return 0, os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
if len(b) <= f.c.maxPacket {
|
if len(b) <= f.c.maxPacket {
|
||||||
// This should be able to be serviced with 1/2 requests.
|
// This should be able to be serviced with 1/2 requests.
|
||||||
// So, just do it directly.
|
// So, just do it directly.
|
||||||
|
|
@ -1115,7 +1253,7 @@ func (f *File) ReadAt(b []byte, off int64) (int, error) {
|
||||||
ID: id,
|
ID: id,
|
||||||
Handle: f.handle,
|
Handle: f.handle,
|
||||||
Offset: uint64(offset),
|
Offset: uint64(offset),
|
||||||
Len: uint32(chunkSize),
|
Len: uint32(len(rb)),
|
||||||
})
|
})
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
|
@ -1179,7 +1317,9 @@ func (f *File) ReadAt(b []byte, off int64) (int, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// return the offset as the start + how much we read before the error.
|
// return the offset as the start + how much we read before the error.
|
||||||
errCh <- rErr{packet.off + int64(n), err}
|
errCh <- rErr{packet.off + int64(n), err}
|
||||||
return
|
|
||||||
|
// DO NOT return.
|
||||||
|
// We want to ensure that workCh is drained before wg.Wait returns.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
@ -1258,6 +1398,10 @@ func (f *File) WriteTo(w io.Writer) (written int64, err error) {
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
defer f.mu.Unlock()
|
defer f.mu.Unlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return 0, os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
if f.c.disableConcurrentReads {
|
if f.c.disableConcurrentReads {
|
||||||
return f.writeToSequential(w)
|
return f.writeToSequential(w)
|
||||||
}
|
}
|
||||||
|
|
@ -1405,12 +1549,10 @@ func (f *File) WriteTo(w io.Writer) (written int64, err error) {
|
||||||
select {
|
select {
|
||||||
case readWork.cur <- writeWork:
|
case readWork.cur <- writeWork:
|
||||||
case <-cancel:
|
case <-cancel:
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
// DO NOT return.
|
||||||
return
|
// We want to ensure that readCh is drained before wg.Wait returns.
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
@ -1450,6 +1592,17 @@ func (f *File) WriteTo(w io.Writer) (written int64, err error) {
|
||||||
// Stat returns the FileInfo structure describing file. If there is an
|
// Stat returns the FileInfo structure describing file. If there is an
|
||||||
// error.
|
// error.
|
||||||
func (f *File) Stat() (os.FileInfo, error) {
|
func (f *File) Stat() (os.FileInfo, error) {
|
||||||
|
f.mu.RLock()
|
||||||
|
defer f.mu.RUnlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return nil, os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.stat()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *File) stat() (os.FileInfo, error) {
|
||||||
fs, err := f.c.fstat(f.handle)
|
fs, err := f.c.fstat(f.handle)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1469,13 +1622,17 @@ func (f *File) Write(b []byte) (int, error) {
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
defer f.mu.Unlock()
|
defer f.mu.Unlock()
|
||||||
|
|
||||||
n, err := f.WriteAt(b, f.offset)
|
if f.handle == "" {
|
||||||
|
return 0, os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
n, err := f.writeAt(b, f.offset)
|
||||||
f.offset += int64(n)
|
f.offset += int64(n)
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) writeChunkAt(ch chan result, b []byte, off int64) (int, error) {
|
func (f *File) writeChunkAt(ch chan result, b []byte, off int64) (int, error) {
|
||||||
typ, data, err := f.c.sendPacket(ch, &sshFxpWritePacket{
|
typ, data, err := f.c.sendPacket(context.Background(), ch, &sshFxpWritePacket{
|
||||||
ID: f.c.nextID(),
|
ID: f.c.nextID(),
|
||||||
Handle: f.handle,
|
Handle: f.handle,
|
||||||
Offset: uint64(off),
|
Offset: uint64(off),
|
||||||
|
|
@ -1627,6 +1784,19 @@ func (f *File) writeAtConcurrent(b []byte, off int64) (int, error) {
|
||||||
// the number of bytes written and an error, if any. WriteAt follows io.WriterAt semantics,
|
// the number of bytes written and an error, if any. WriteAt follows io.WriterAt semantics,
|
||||||
// so the file offset is not altered during the write.
|
// so the file offset is not altered during the write.
|
||||||
func (f *File) WriteAt(b []byte, off int64) (written int, err error) {
|
func (f *File) WriteAt(b []byte, off int64) (written int, err error) {
|
||||||
|
f.mu.RLock()
|
||||||
|
defer f.mu.RUnlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return 0, os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.writeAt(b, off)
|
||||||
|
}
|
||||||
|
|
||||||
|
// writeAt must be called while holding either the Read or Write mutex in File.
|
||||||
|
// This code is concurrent safe with itself, but not with Close.
|
||||||
|
func (f *File) writeAt(b []byte, off int64) (written int, err error) {
|
||||||
if len(b) <= f.c.maxPacket {
|
if len(b) <= f.c.maxPacket {
|
||||||
// We can do this in one write.
|
// We can do this in one write.
|
||||||
return f.writeChunkAt(nil, b, off)
|
return f.writeChunkAt(nil, b, off)
|
||||||
|
|
@ -1665,7 +1835,21 @@ func (f *File) WriteAt(b []byte, off int64) (written int, err error) {
|
||||||
// Giving a concurrency of less than one will default to the Client’s max concurrency.
|
// Giving a concurrency of less than one will default to the Client’s max concurrency.
|
||||||
//
|
//
|
||||||
// Otherwise, the given concurrency will be capped by the Client's max concurrency.
|
// Otherwise, the given concurrency will be capped by the Client's max concurrency.
|
||||||
|
//
|
||||||
|
// When one needs to guarantee concurrent reads/writes, this method is preferred
|
||||||
|
// over ReadFrom.
|
||||||
func (f *File) ReadFromWithConcurrency(r io.Reader, concurrency int) (read int64, err error) {
|
func (f *File) ReadFromWithConcurrency(r io.Reader, concurrency int) (read int64, err error) {
|
||||||
|
f.mu.Lock()
|
||||||
|
defer f.mu.Unlock()
|
||||||
|
|
||||||
|
return f.readFromWithConcurrency(r, concurrency)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *File) readFromWithConcurrency(r io.Reader, concurrency int) (read int64, err error) {
|
||||||
|
if f.handle == "" {
|
||||||
|
return 0, os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
// Split the write into multiple maxPacket sized concurrent writes.
|
// Split the write into multiple maxPacket sized concurrent writes.
|
||||||
// This allows writes with a suitably large reader
|
// This allows writes with a suitably large reader
|
||||||
// to transfer data at a much faster rate due to overlapping round trip times.
|
// to transfer data at a much faster rate due to overlapping round trip times.
|
||||||
|
|
@ -1700,7 +1884,8 @@ func (f *File) ReadFromWithConcurrency(r io.Reader, concurrency int) (read int64
|
||||||
off := f.offset
|
off := f.offset
|
||||||
|
|
||||||
for {
|
for {
|
||||||
n, err := r.Read(b)
|
// Fill the entire buffer.
|
||||||
|
n, err := io.ReadFull(r, b)
|
||||||
|
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
read += int64(n)
|
read += int64(n)
|
||||||
|
|
@ -1726,7 +1911,7 @@ func (f *File) ReadFromWithConcurrency(r io.Reader, concurrency int) (read int64
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != io.EOF {
|
if !errors.Is(err, io.EOF) && !errors.Is(err, io.ErrUnexpectedEOF) {
|
||||||
errCh <- rwErr{off, err}
|
errCh <- rwErr{off, err}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
@ -1757,6 +1942,9 @@ func (f *File) ReadFromWithConcurrency(r io.Reader, concurrency int) (read int64
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errCh <- rwErr{work.off, err}
|
errCh <- rwErr{work.off, err}
|
||||||
|
|
||||||
|
// DO NOT return.
|
||||||
|
// We want to ensure that workCh is drained before wg.Wait returns.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
@ -1811,10 +1999,26 @@ func (f *File) ReadFromWithConcurrency(r io.Reader, concurrency int) (read int64
|
||||||
// This method is preferred over calling Write multiple times
|
// This method is preferred over calling Write multiple times
|
||||||
// to maximise throughput for transferring the entire file,
|
// to maximise throughput for transferring the entire file,
|
||||||
// especially over high-latency links.
|
// especially over high-latency links.
|
||||||
|
//
|
||||||
|
// To ensure concurrent writes, the given r needs to implement one of
|
||||||
|
// the following receiver methods:
|
||||||
|
//
|
||||||
|
// Len() int
|
||||||
|
// Size() int64
|
||||||
|
// Stat() (os.FileInfo, error)
|
||||||
|
//
|
||||||
|
// or be an instance of [io.LimitedReader] to determine the number of possible
|
||||||
|
// concurrent requests. Otherwise, reads/writes are performed sequentially.
|
||||||
|
// ReadFromWithConcurrency can be used explicitly to guarantee concurrent
|
||||||
|
// processing of the reader.
|
||||||
func (f *File) ReadFrom(r io.Reader) (int64, error) {
|
func (f *File) ReadFrom(r io.Reader) (int64, error) {
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
defer f.mu.Unlock()
|
defer f.mu.Unlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return 0, os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
if f.c.useConcurrentWrites {
|
if f.c.useConcurrentWrites {
|
||||||
var remain int64
|
var remain int64
|
||||||
switch r := r.(type) {
|
switch r := r.(type) {
|
||||||
|
|
@ -1836,7 +2040,7 @@ func (f *File) ReadFrom(r io.Reader) (int64, error) {
|
||||||
|
|
||||||
if remain < 0 {
|
if remain < 0 {
|
||||||
// We can strongly assert that we want default max concurrency here.
|
// We can strongly assert that we want default max concurrency here.
|
||||||
return f.ReadFromWithConcurrency(r, f.c.maxConcurrentRequests)
|
return f.readFromWithConcurrency(r, f.c.maxConcurrentRequests)
|
||||||
}
|
}
|
||||||
|
|
||||||
if remain > int64(f.c.maxPacket) {
|
if remain > int64(f.c.maxPacket) {
|
||||||
|
|
@ -1851,7 +2055,7 @@ func (f *File) ReadFrom(r io.Reader) (int64, error) {
|
||||||
concurrency64 = int64(f.c.maxConcurrentRequests)
|
concurrency64 = int64(f.c.maxConcurrentRequests)
|
||||||
}
|
}
|
||||||
|
|
||||||
return f.ReadFromWithConcurrency(r, int(concurrency64))
|
return f.readFromWithConcurrency(r, int(concurrency64))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1861,7 +2065,8 @@ func (f *File) ReadFrom(r io.Reader) (int64, error) {
|
||||||
|
|
||||||
var read int64
|
var read int64
|
||||||
for {
|
for {
|
||||||
n, err := r.Read(b)
|
// Fill the entire buffer.
|
||||||
|
n, err := io.ReadFull(r, b)
|
||||||
if n < 0 {
|
if n < 0 {
|
||||||
panic("sftp.File: reader returned negative count from Read")
|
panic("sftp.File: reader returned negative count from Read")
|
||||||
}
|
}
|
||||||
|
|
@ -1878,7 +2083,7 @@ func (f *File) ReadFrom(r io.Reader) (int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == io.EOF {
|
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
|
||||||
return read, nil // return nil explicitly.
|
return read, nil // return nil explicitly.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1894,12 +2099,16 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
|
||||||
f.mu.Lock()
|
f.mu.Lock()
|
||||||
defer f.mu.Unlock()
|
defer f.mu.Unlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return 0, os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
switch whence {
|
switch whence {
|
||||||
case io.SeekStart:
|
case io.SeekStart:
|
||||||
case io.SeekCurrent:
|
case io.SeekCurrent:
|
||||||
offset += f.offset
|
offset += f.offset
|
||||||
case io.SeekEnd:
|
case io.SeekEnd:
|
||||||
fi, err := f.Stat()
|
fi, err := f.stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return f.offset, err
|
return f.offset, err
|
||||||
}
|
}
|
||||||
|
|
@ -1918,22 +2127,91 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
|
||||||
|
|
||||||
// Chown changes the uid/gid of the current file.
|
// Chown changes the uid/gid of the current file.
|
||||||
func (f *File) Chown(uid, gid int) error {
|
func (f *File) Chown(uid, gid int) error {
|
||||||
return f.c.Chown(f.path, uid, gid)
|
f.mu.RLock()
|
||||||
|
defer f.mu.RUnlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.c.fsetstat(f.handle, sshFileXferAttrUIDGID, &FileStat{
|
||||||
|
UID: uint32(uid),
|
||||||
|
GID: uint32(gid),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chmod changes the permissions of the current file.
|
// Chmod changes the permissions of the current file.
|
||||||
//
|
//
|
||||||
// See Client.Chmod for details.
|
// See Client.Chmod for details.
|
||||||
func (f *File) Chmod(mode os.FileMode) error {
|
func (f *File) Chmod(mode os.FileMode) error {
|
||||||
return f.c.setfstat(f.handle, sshFileXferAttrPermissions, toChmodPerm(mode))
|
f.mu.RLock()
|
||||||
|
defer f.mu.RUnlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.c.fsetstat(f.handle, sshFileXferAttrPermissions, toChmodPerm(mode))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExtendedData sets extended attributes of the current file. It uses the
|
||||||
|
// SSH_FILEXFER_ATTR_EXTENDED flag in the setstat request.
|
||||||
|
//
|
||||||
|
// This flag provides a general extension mechanism for vendor-specific extensions.
|
||||||
|
// Names of the attributes should be a string of the format "name@domain", where "domain"
|
||||||
|
// is a valid, registered domain name and "name" identifies the method. Server
|
||||||
|
// implementations SHOULD ignore extended data fields that they do not understand.
|
||||||
|
func (f *File) SetExtendedData(path string, extended []StatExtended) error {
|
||||||
|
f.mu.RLock()
|
||||||
|
defer f.mu.RUnlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
attrs := &FileStat{
|
||||||
|
Extended: extended,
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.c.fsetstat(f.handle, sshFileXferAttrExtended, attrs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncate sets the size of the current file. Although it may be safely assumed
|
||||||
|
// that if the size is less than its current size it will be truncated to fit,
|
||||||
|
// the SFTP protocol does not specify what behavior the server should do when setting
|
||||||
|
// size greater than the current size.
|
||||||
|
// We send a SSH_FXP_FSETSTAT here since we have a file handle
|
||||||
|
func (f *File) Truncate(size int64) error {
|
||||||
|
f.mu.RLock()
|
||||||
|
defer f.mu.RUnlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
return f.c.fsetstat(f.handle, sshFileXferAttrSize, uint64(size))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync requests a flush of the contents of a File to stable storage.
|
// Sync requests a flush of the contents of a File to stable storage.
|
||||||
//
|
//
|
||||||
// Sync requires the server to support the fsync@openssh.com extension.
|
// Sync requires the server to support the fsync@openssh.com extension.
|
||||||
func (f *File) Sync() error {
|
func (f *File) Sync() error {
|
||||||
|
f.mu.Lock()
|
||||||
|
defer f.mu.Unlock()
|
||||||
|
|
||||||
|
if f.handle == "" {
|
||||||
|
return os.ErrClosed
|
||||||
|
}
|
||||||
|
|
||||||
|
if data, ok := f.c.HasExtension(openssh.ExtensionFSync().Name); !ok || data != "1" {
|
||||||
|
return &StatusError{
|
||||||
|
Code: sshFxOPUnsupported,
|
||||||
|
msg: "fsync not supported",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
id := f.c.nextID()
|
id := f.c.nextID()
|
||||||
typ, data, err := f.c.sendPacket(nil, &sshFxpFsyncPacket{
|
typ, data, err := f.c.sendPacket(context.Background(), nil, &sshFxpFsyncPacket{
|
||||||
ID: id,
|
ID: id,
|
||||||
Handle: f.handle,
|
Handle: f.handle,
|
||||||
})
|
})
|
||||||
|
|
@ -1948,15 +2226,6 @@ func (f *File) Sync() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate sets the size of the current file. Although it may be safely assumed
|
|
||||||
// that if the size is less than its current size it will be truncated to fit,
|
|
||||||
// the SFTP protocol does not specify what behavior the server should do when setting
|
|
||||||
// size greater than the current size.
|
|
||||||
// We send a SSH_FXP_FSETSTAT here since we have a file handle
|
|
||||||
func (f *File) Truncate(size int64) error {
|
|
||||||
return f.c.setfstat(f.handle, sshFileXferAttrSize, uint64(size))
|
|
||||||
}
|
|
||||||
|
|
||||||
// normaliseError normalises an error into a more standard form that can be
|
// normaliseError normalises an error into a more standard form that can be
|
||||||
// checked against stdlib errors like io.EOF or os.ErrNotExist.
|
// checked against stdlib errors like io.EOF or os.ErrNotExist.
|
||||||
func normaliseError(err error) error {
|
func normaliseError(err error) error {
|
||||||
|
|
@ -1981,15 +2250,14 @@ func normaliseError(err error) error {
|
||||||
|
|
||||||
// flags converts the flags passed to OpenFile into ssh flags.
|
// flags converts the flags passed to OpenFile into ssh flags.
|
||||||
// Unsupported flags are ignored.
|
// Unsupported flags are ignored.
|
||||||
func flags(f int) uint32 {
|
func toPflags(f int) uint32 {
|
||||||
var out uint32
|
var out uint32
|
||||||
switch f & os.O_WRONLY {
|
switch f & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR) {
|
||||||
case os.O_WRONLY:
|
|
||||||
out |= sshFxfWrite
|
|
||||||
case os.O_RDONLY:
|
case os.O_RDONLY:
|
||||||
out |= sshFxfRead
|
out |= sshFxfRead
|
||||||
}
|
case os.O_WRONLY:
|
||||||
if f&os.O_RDWR == os.O_RDWR {
|
out |= sshFxfWrite
|
||||||
|
case os.O_RDWR:
|
||||||
out |= sshFxfRead | sshFxfWrite
|
out |= sshFxfRead | sshFxfWrite
|
||||||
}
|
}
|
||||||
if f&os.O_APPEND == os.O_APPEND {
|
if f&os.O_APPEND == os.O_APPEND {
|
||||||
|
|
@ -2013,7 +2281,7 @@ func flags(f int) uint32 {
|
||||||
// setuid, setgid and sticky in m, because we've historically supported those
|
// setuid, setgid and sticky in m, because we've historically supported those
|
||||||
// bits, and we mask off any non-permission bits.
|
// bits, and we mask off any non-permission bits.
|
||||||
func toChmodPerm(m os.FileMode) (perm uint32) {
|
func toChmodPerm(m os.FileMode) (perm uint32) {
|
||||||
const mask = os.ModePerm | s_ISUID | s_ISGID | s_ISVTX
|
const mask = os.ModePerm | os.FileMode(s_ISUID|s_ISGID|s_ISVTX)
|
||||||
perm = uint32(m & mask)
|
perm = uint32(m & mask)
|
||||||
|
|
||||||
if m&os.ModeSetuid != 0 {
|
if m&os.ModeSetuid != 0 {
|
||||||
|
|
|
||||||
39
vendor/github.com/pkg/sftp/conn.go
generated
vendored
39
vendor/github.com/pkg/sftp/conn.go
generated
vendored
|
|
@ -1,6 +1,7 @@
|
||||||
package sftp
|
package sftp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding"
|
"encoding"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -21,7 +22,7 @@ type conn struct {
|
||||||
// For the client mode just pass 0.
|
// For the client mode just pass 0.
|
||||||
// It returns io.EOF if the connection is closed and
|
// It returns io.EOF if the connection is closed and
|
||||||
// there are no more packets to read.
|
// there are no more packets to read.
|
||||||
func (c *conn) recvPacket(orderID uint32) (uint8, []byte, error) {
|
func (c *conn) recvPacket(orderID uint32) (fxp, []byte, error) {
|
||||||
return recvPacket(c, c.alloc, orderID)
|
return recvPacket(c, c.alloc, orderID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,6 +43,8 @@ type clientConn struct {
|
||||||
conn
|
conn
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
|
wait func() error // if non-nil, call this during Wait() to get a possible remote status error.
|
||||||
|
|
||||||
sync.Mutex // protects inflight
|
sync.Mutex // protects inflight
|
||||||
inflight map[uint32]chan<- result // outstanding requests
|
inflight map[uint32]chan<- result // outstanding requests
|
||||||
|
|
||||||
|
|
@ -54,6 +57,27 @@ type clientConn struct {
|
||||||
// goroutines.
|
// goroutines.
|
||||||
func (c *clientConn) Wait() error {
|
func (c *clientConn) Wait() error {
|
||||||
<-c.closed
|
<-c.closed
|
||||||
|
|
||||||
|
if c.wait == nil {
|
||||||
|
// Only return this error if c.wait won't return something more useful.
|
||||||
|
return c.err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := c.wait(); err != nil {
|
||||||
|
|
||||||
|
// TODO: when https://github.com/golang/go/issues/35025 is fixed,
|
||||||
|
// we can remove this if block entirely.
|
||||||
|
// Right now, it’s always going to return this, so it is not useful.
|
||||||
|
// But we have this code here so that as soon as the ssh library is updated,
|
||||||
|
// we can return a possibly more useful error.
|
||||||
|
if err.Error() == "ssh: session not started" {
|
||||||
|
return c.err
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// c.wait returned no error; so, let's return something maybe more useful.
|
||||||
return c.err
|
return c.err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +142,7 @@ func (c *clientConn) getChannel(sid uint32) (chan<- result, bool) {
|
||||||
|
|
||||||
// result captures the result of receiving the a packet from the server
|
// result captures the result of receiving the a packet from the server
|
||||||
type result struct {
|
type result struct {
|
||||||
typ byte
|
typ fxp
|
||||||
data []byte
|
data []byte
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
@ -128,14 +152,19 @@ type idmarshaler interface {
|
||||||
encoding.BinaryMarshaler
|
encoding.BinaryMarshaler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *clientConn) sendPacket(ch chan result, p idmarshaler) (byte, []byte, error) {
|
func (c *clientConn) sendPacket(ctx context.Context, ch chan result, p idmarshaler) (fxp, []byte, error) {
|
||||||
if cap(ch) < 1 {
|
if cap(ch) < 1 {
|
||||||
ch = make(chan result, 1)
|
ch = make(chan result, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.dispatchRequest(ch, p)
|
c.dispatchRequest(ch, p)
|
||||||
s := <-ch
|
|
||||||
return s.typ, s.data, s.err
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return 0, nil, ctx.Err()
|
||||||
|
case s := <-ch:
|
||||||
|
return s.typ, s.data, s.err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// dispatchRequest should ideally only be called by race-detection tests outside of this file,
|
// dispatchRequest should ideally only be called by race-detection tests outside of this file,
|
||||||
|
|
|
||||||
42
vendor/github.com/pkg/sftp/errno_plan9.go
generated
vendored
Normal file
42
vendor/github.com/pkg/sftp/errno_plan9.go
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
package sftp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
var EBADF = syscall.NewError("fd out of range or not open")
|
||||||
|
|
||||||
|
func wrapPathError(filepath string, err error) error {
|
||||||
|
if errno, ok := err.(syscall.ErrorString); ok {
|
||||||
|
return &os.PathError{Path: filepath, Err: errno}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// translateErrno translates a syscall error number to a SFTP error code.
|
||||||
|
func translateErrno(errno syscall.ErrorString) uint32 {
|
||||||
|
switch errno {
|
||||||
|
case "":
|
||||||
|
return sshFxOk
|
||||||
|
case syscall.ENOENT:
|
||||||
|
return sshFxNoSuchFile
|
||||||
|
case syscall.EPERM:
|
||||||
|
return sshFxPermissionDenied
|
||||||
|
}
|
||||||
|
|
||||||
|
return sshFxFailure
|
||||||
|
}
|
||||||
|
|
||||||
|
func translateSyscallError(err error) (uint32, bool) {
|
||||||
|
switch e := err.(type) {
|
||||||
|
case syscall.ErrorString:
|
||||||
|
return translateErrno(e), true
|
||||||
|
case *os.PathError:
|
||||||
|
debug("statusFromError,pathError: error is %T %#v", e.Err, e.Err)
|
||||||
|
if errno, ok := e.Err.(syscall.ErrorString); ok {
|
||||||
|
return translateErrno(errno), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
45
vendor/github.com/pkg/sftp/errno_posix.go
generated
vendored
Normal file
45
vendor/github.com/pkg/sftp/errno_posix.go
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
//go:build !plan9
|
||||||
|
// +build !plan9
|
||||||
|
|
||||||
|
package sftp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
const EBADF = syscall.EBADF
|
||||||
|
|
||||||
|
func wrapPathError(filepath string, err error) error {
|
||||||
|
if errno, ok := err.(syscall.Errno); ok {
|
||||||
|
return &os.PathError{Path: filepath, Err: errno}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// translateErrno translates a syscall error number to a SFTP error code.
|
||||||
|
func translateErrno(errno syscall.Errno) uint32 {
|
||||||
|
switch errno {
|
||||||
|
case 0:
|
||||||
|
return sshFxOk
|
||||||
|
case syscall.ENOENT:
|
||||||
|
return sshFxNoSuchFile
|
||||||
|
case syscall.EACCES, syscall.EPERM:
|
||||||
|
return sshFxPermissionDenied
|
||||||
|
}
|
||||||
|
|
||||||
|
return sshFxFailure
|
||||||
|
}
|
||||||
|
|
||||||
|
func translateSyscallError(err error) (uint32, bool) {
|
||||||
|
switch e := err.(type) {
|
||||||
|
case syscall.Errno:
|
||||||
|
return translateErrno(e), true
|
||||||
|
case *os.PathError:
|
||||||
|
debug("statusFromError,pathError: error is %T %#v", e.Err, e.Err)
|
||||||
|
if errno, ok := e.Err.(syscall.Errno); ok {
|
||||||
|
return translateErrno(errno), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
73
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/fsync.go
generated
vendored
Normal file
73
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/fsync.go
generated
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
package openssh
|
||||||
|
|
||||||
|
import (
|
||||||
|
sshfx "github.com/pkg/sftp/internal/encoding/ssh/filexfer"
|
||||||
|
)
|
||||||
|
|
||||||
|
const extensionFSync = "fsync@openssh.com"
|
||||||
|
|
||||||
|
// RegisterExtensionFSync registers the "fsync@openssh.com" extended packet with the encoding/ssh/filexfer package.
|
||||||
|
func RegisterExtensionFSync() {
|
||||||
|
sshfx.RegisterExtendedPacketType(extensionFSync, func() sshfx.ExtendedData {
|
||||||
|
return new(FSyncExtendedPacket)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtensionFSync returns an ExtensionPair suitable to append into an sshfx.InitPacket or sshfx.VersionPacket.
|
||||||
|
func ExtensionFSync() *sshfx.ExtensionPair {
|
||||||
|
return &sshfx.ExtensionPair{
|
||||||
|
Name: extensionFSync,
|
||||||
|
Data: "1",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FSyncExtendedPacket defines the fsync@openssh.com extend packet.
|
||||||
|
type FSyncExtendedPacket struct {
|
||||||
|
Handle string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type returns the SSH_FXP_EXTENDED packet type.
|
||||||
|
func (ep *FSyncExtendedPacket) Type() sshfx.PacketType {
|
||||||
|
return sshfx.PacketTypeExtended
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalPacket returns ep as a two-part binary encoding of the full extended packet.
|
||||||
|
func (ep *FSyncExtendedPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error) {
|
||||||
|
p := &sshfx.ExtendedPacket{
|
||||||
|
ExtendedRequest: extensionFSync,
|
||||||
|
|
||||||
|
Data: ep,
|
||||||
|
}
|
||||||
|
return p.MarshalPacket(reqid, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalInto encodes ep into the binary encoding of the fsync@openssh.com extended packet-specific data.
|
||||||
|
func (ep *FSyncExtendedPacket) MarshalInto(buf *sshfx.Buffer) {
|
||||||
|
buf.AppendString(ep.Handle)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary encodes ep into the binary encoding of the fsync@openssh.com extended packet-specific data.
|
||||||
|
//
|
||||||
|
// NOTE: This _only_ encodes the packet-specific data, it does not encode the full extended packet.
|
||||||
|
func (ep *FSyncExtendedPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
// string(handle)
|
||||||
|
size := 4 + len(ep.Handle)
|
||||||
|
|
||||||
|
buf := sshfx.NewBuffer(make([]byte, 0, size))
|
||||||
|
ep.MarshalInto(buf)
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalFrom decodes the fsync@openssh.com extended packet-specific data from buf.
|
||||||
|
func (ep *FSyncExtendedPacket) UnmarshalFrom(buf *sshfx.Buffer) (err error) {
|
||||||
|
*ep = FSyncExtendedPacket{
|
||||||
|
Handle: buf.ConsumeString(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary decodes the fsync@openssh.com extended packet-specific data into ep.
|
||||||
|
func (ep *FSyncExtendedPacket) UnmarshalBinary(data []byte) (err error) {
|
||||||
|
return ep.UnmarshalFrom(sshfx.NewBuffer(data))
|
||||||
|
}
|
||||||
76
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/hardlink.go
generated
vendored
Normal file
76
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/hardlink.go
generated
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
package openssh
|
||||||
|
|
||||||
|
import (
|
||||||
|
sshfx "github.com/pkg/sftp/internal/encoding/ssh/filexfer"
|
||||||
|
)
|
||||||
|
|
||||||
|
const extensionHardlink = "hardlink@openssh.com"
|
||||||
|
|
||||||
|
// RegisterExtensionHardlink registers the "hardlink@openssh.com" extended packet with the encoding/ssh/filexfer package.
|
||||||
|
func RegisterExtensionHardlink() {
|
||||||
|
sshfx.RegisterExtendedPacketType(extensionHardlink, func() sshfx.ExtendedData {
|
||||||
|
return new(HardlinkExtendedPacket)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtensionHardlink returns an ExtensionPair suitable to append into an sshfx.InitPacket or sshfx.VersionPacket.
|
||||||
|
func ExtensionHardlink() *sshfx.ExtensionPair {
|
||||||
|
return &sshfx.ExtensionPair{
|
||||||
|
Name: extensionHardlink,
|
||||||
|
Data: "1",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HardlinkExtendedPacket defines the hardlink@openssh.com extend packet.
|
||||||
|
type HardlinkExtendedPacket struct {
|
||||||
|
OldPath string
|
||||||
|
NewPath string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type returns the SSH_FXP_EXTENDED packet type.
|
||||||
|
func (ep *HardlinkExtendedPacket) Type() sshfx.PacketType {
|
||||||
|
return sshfx.PacketTypeExtended
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalPacket returns ep as a two-part binary encoding of the full extended packet.
|
||||||
|
func (ep *HardlinkExtendedPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error) {
|
||||||
|
p := &sshfx.ExtendedPacket{
|
||||||
|
ExtendedRequest: extensionHardlink,
|
||||||
|
|
||||||
|
Data: ep,
|
||||||
|
}
|
||||||
|
return p.MarshalPacket(reqid, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalInto encodes ep into the binary encoding of the hardlink@openssh.com extended packet-specific data.
|
||||||
|
func (ep *HardlinkExtendedPacket) MarshalInto(buf *sshfx.Buffer) {
|
||||||
|
buf.AppendString(ep.OldPath)
|
||||||
|
buf.AppendString(ep.NewPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary encodes ep into the binary encoding of the hardlink@openssh.com extended packet-specific data.
|
||||||
|
//
|
||||||
|
// NOTE: This _only_ encodes the packet-specific data, it does not encode the full extended packet.
|
||||||
|
func (ep *HardlinkExtendedPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
// string(oldpath) + string(newpath)
|
||||||
|
size := 4 + len(ep.OldPath) + 4 + len(ep.NewPath)
|
||||||
|
|
||||||
|
buf := sshfx.NewBuffer(make([]byte, 0, size))
|
||||||
|
ep.MarshalInto(buf)
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalFrom decodes the hardlink@openssh.com extended packet-specific data from buf.
|
||||||
|
func (ep *HardlinkExtendedPacket) UnmarshalFrom(buf *sshfx.Buffer) (err error) {
|
||||||
|
*ep = HardlinkExtendedPacket{
|
||||||
|
OldPath: buf.ConsumeString(),
|
||||||
|
NewPath: buf.ConsumeString(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary decodes the hardlink@openssh.com extended packet-specific data into ep.
|
||||||
|
func (ep *HardlinkExtendedPacket) UnmarshalBinary(data []byte) (err error) {
|
||||||
|
return ep.UnmarshalFrom(sshfx.NewBuffer(data))
|
||||||
|
}
|
||||||
2
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/openssh.go
generated
vendored
Normal file
2
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/openssh.go
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
// Package openssh implements the openssh secsh-filexfer extensions as described in https://github.com/openssh/openssh-portable/blob/master/PROTOCOL
|
||||||
|
package openssh
|
||||||
76
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/posix-rename.go
generated
vendored
Normal file
76
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/posix-rename.go
generated
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
package openssh
|
||||||
|
|
||||||
|
import (
|
||||||
|
sshfx "github.com/pkg/sftp/internal/encoding/ssh/filexfer"
|
||||||
|
)
|
||||||
|
|
||||||
|
const extensionPOSIXRename = "posix-rename@openssh.com"
|
||||||
|
|
||||||
|
// RegisterExtensionPOSIXRename registers the "posix-rename@openssh.com" extended packet with the encoding/ssh/filexfer package.
|
||||||
|
func RegisterExtensionPOSIXRename() {
|
||||||
|
sshfx.RegisterExtendedPacketType(extensionPOSIXRename, func() sshfx.ExtendedData {
|
||||||
|
return new(POSIXRenameExtendedPacket)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtensionPOSIXRename returns an ExtensionPair suitable to append into an sshfx.InitPacket or sshfx.VersionPacket.
|
||||||
|
func ExtensionPOSIXRename() *sshfx.ExtensionPair {
|
||||||
|
return &sshfx.ExtensionPair{
|
||||||
|
Name: extensionPOSIXRename,
|
||||||
|
Data: "1",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// POSIXRenameExtendedPacket defines the posix-rename@openssh.com extend packet.
|
||||||
|
type POSIXRenameExtendedPacket struct {
|
||||||
|
OldPath string
|
||||||
|
NewPath string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type returns the SSH_FXP_EXTENDED packet type.
|
||||||
|
func (ep *POSIXRenameExtendedPacket) Type() sshfx.PacketType {
|
||||||
|
return sshfx.PacketTypeExtended
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalPacket returns ep as a two-part binary encoding of the full extended packet.
|
||||||
|
func (ep *POSIXRenameExtendedPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error) {
|
||||||
|
p := &sshfx.ExtendedPacket{
|
||||||
|
ExtendedRequest: extensionPOSIXRename,
|
||||||
|
|
||||||
|
Data: ep,
|
||||||
|
}
|
||||||
|
return p.MarshalPacket(reqid, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalInto encodes ep into the binary encoding of the hardlink@openssh.com extended packet-specific data.
|
||||||
|
func (ep *POSIXRenameExtendedPacket) MarshalInto(buf *sshfx.Buffer) {
|
||||||
|
buf.AppendString(ep.OldPath)
|
||||||
|
buf.AppendString(ep.NewPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary encodes ep into the binary encoding of the hardlink@openssh.com extended packet-specific data.
|
||||||
|
//
|
||||||
|
// NOTE: This _only_ encodes the packet-specific data, it does not encode the full extended packet.
|
||||||
|
func (ep *POSIXRenameExtendedPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
// string(oldpath) + string(newpath)
|
||||||
|
size := 4 + len(ep.OldPath) + 4 + len(ep.NewPath)
|
||||||
|
|
||||||
|
buf := sshfx.NewBuffer(make([]byte, 0, size))
|
||||||
|
ep.MarshalInto(buf)
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalFrom decodes the hardlink@openssh.com extended packet-specific data from buf.
|
||||||
|
func (ep *POSIXRenameExtendedPacket) UnmarshalFrom(buf *sshfx.Buffer) (err error) {
|
||||||
|
*ep = POSIXRenameExtendedPacket{
|
||||||
|
OldPath: buf.ConsumeString(),
|
||||||
|
NewPath: buf.ConsumeString(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary decodes the hardlink@openssh.com extended packet-specific data into ep.
|
||||||
|
func (ep *POSIXRenameExtendedPacket) UnmarshalBinary(data []byte) (err error) {
|
||||||
|
return ep.UnmarshalFrom(sshfx.NewBuffer(data))
|
||||||
|
}
|
||||||
236
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/statvfs.go
generated
vendored
Normal file
236
vendor/github.com/pkg/sftp/internal/encoding/ssh/filexfer/openssh/statvfs.go
generated
vendored
Normal file
|
|
@ -0,0 +1,236 @@
|
||||||
|
package openssh
|
||||||
|
|
||||||
|
import (
|
||||||
|
sshfx "github.com/pkg/sftp/internal/encoding/ssh/filexfer"
|
||||||
|
)
|
||||||
|
|
||||||
|
const extensionStatVFS = "statvfs@openssh.com"
|
||||||
|
|
||||||
|
// RegisterExtensionStatVFS registers the "statvfs@openssh.com" extended packet with the encoding/ssh/filexfer package.
|
||||||
|
func RegisterExtensionStatVFS() {
|
||||||
|
sshfx.RegisterExtendedPacketType(extensionStatVFS, func() sshfx.ExtendedData {
|
||||||
|
return new(StatVFSExtendedPacket)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtensionStatVFS returns an ExtensionPair suitable to append into an sshfx.InitPacket or sshfx.VersionPacket.
|
||||||
|
func ExtensionStatVFS() *sshfx.ExtensionPair {
|
||||||
|
return &sshfx.ExtensionPair{
|
||||||
|
Name: extensionStatVFS,
|
||||||
|
Data: "2",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatVFSExtendedPacket defines the statvfs@openssh.com extend packet.
|
||||||
|
type StatVFSExtendedPacket struct {
|
||||||
|
Path string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type returns the SSH_FXP_EXTENDED packet type.
|
||||||
|
func (ep *StatVFSExtendedPacket) Type() sshfx.PacketType {
|
||||||
|
return sshfx.PacketTypeExtended
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalPacket returns ep as a two-part binary encoding of the full extended packet.
|
||||||
|
func (ep *StatVFSExtendedPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error) {
|
||||||
|
p := &sshfx.ExtendedPacket{
|
||||||
|
ExtendedRequest: extensionStatVFS,
|
||||||
|
|
||||||
|
Data: ep,
|
||||||
|
}
|
||||||
|
return p.MarshalPacket(reqid, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalInto encodes ep into the binary encoding of the statvfs@openssh.com extended packet-specific data.
|
||||||
|
func (ep *StatVFSExtendedPacket) MarshalInto(buf *sshfx.Buffer) {
|
||||||
|
buf.AppendString(ep.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary encodes ep into the binary encoding of the statvfs@openssh.com extended packet-specific data.
|
||||||
|
//
|
||||||
|
// NOTE: This _only_ encodes the packet-specific data, it does not encode the full extended packet.
|
||||||
|
func (ep *StatVFSExtendedPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
size := 4 + len(ep.Path) // string(path)
|
||||||
|
|
||||||
|
buf := sshfx.NewBuffer(make([]byte, 0, size))
|
||||||
|
|
||||||
|
ep.MarshalInto(buf)
|
||||||
|
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalFrom decodes the statvfs@openssh.com extended packet-specific data into ep.
|
||||||
|
func (ep *StatVFSExtendedPacket) UnmarshalFrom(buf *sshfx.Buffer) (err error) {
|
||||||
|
*ep = StatVFSExtendedPacket{
|
||||||
|
Path: buf.ConsumeString(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary decodes the statvfs@openssh.com extended packet-specific data into ep.
|
||||||
|
func (ep *StatVFSExtendedPacket) UnmarshalBinary(data []byte) (err error) {
|
||||||
|
return ep.UnmarshalFrom(sshfx.NewBuffer(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
const extensionFStatVFS = "fstatvfs@openssh.com"
|
||||||
|
|
||||||
|
// RegisterExtensionFStatVFS registers the "fstatvfs@openssh.com" extended packet with the encoding/ssh/filexfer package.
|
||||||
|
func RegisterExtensionFStatVFS() {
|
||||||
|
sshfx.RegisterExtendedPacketType(extensionFStatVFS, func() sshfx.ExtendedData {
|
||||||
|
return new(FStatVFSExtendedPacket)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtensionFStatVFS returns an ExtensionPair suitable to append into an sshfx.InitPacket or sshfx.VersionPacket.
|
||||||
|
func ExtensionFStatVFS() *sshfx.ExtensionPair {
|
||||||
|
return &sshfx.ExtensionPair{
|
||||||
|
Name: extensionFStatVFS,
|
||||||
|
Data: "2",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FStatVFSExtendedPacket defines the fstatvfs@openssh.com extend packet.
|
||||||
|
type FStatVFSExtendedPacket struct {
|
||||||
|
Path string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type returns the SSH_FXP_EXTENDED packet type.
|
||||||
|
func (ep *FStatVFSExtendedPacket) Type() sshfx.PacketType {
|
||||||
|
return sshfx.PacketTypeExtended
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalPacket returns ep as a two-part binary encoding of the full extended packet.
|
||||||
|
func (ep *FStatVFSExtendedPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error) {
|
||||||
|
p := &sshfx.ExtendedPacket{
|
||||||
|
ExtendedRequest: extensionFStatVFS,
|
||||||
|
|
||||||
|
Data: ep,
|
||||||
|
}
|
||||||
|
return p.MarshalPacket(reqid, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalInto encodes ep into the binary encoding of the statvfs@openssh.com extended packet-specific data.
|
||||||
|
func (ep *FStatVFSExtendedPacket) MarshalInto(buf *sshfx.Buffer) {
|
||||||
|
buf.AppendString(ep.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary encodes ep into the binary encoding of the statvfs@openssh.com extended packet-specific data.
|
||||||
|
//
|
||||||
|
// NOTE: This _only_ encodes the packet-specific data, it does not encode the full extended packet.
|
||||||
|
func (ep *FStatVFSExtendedPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
size := 4 + len(ep.Path) // string(path)
|
||||||
|
|
||||||
|
buf := sshfx.NewBuffer(make([]byte, 0, size))
|
||||||
|
|
||||||
|
ep.MarshalInto(buf)
|
||||||
|
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalFrom decodes the statvfs@openssh.com extended packet-specific data into ep.
|
||||||
|
func (ep *FStatVFSExtendedPacket) UnmarshalFrom(buf *sshfx.Buffer) (err error) {
|
||||||
|
*ep = FStatVFSExtendedPacket{
|
||||||
|
Path: buf.ConsumeString(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary decodes the statvfs@openssh.com extended packet-specific data into ep.
|
||||||
|
func (ep *FStatVFSExtendedPacket) UnmarshalBinary(data []byte) (err error) {
|
||||||
|
return ep.UnmarshalFrom(sshfx.NewBuffer(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
// The values for the MountFlags field.
|
||||||
|
// https://github.com/openssh/openssh-portable/blob/master/PROTOCOL
|
||||||
|
const (
|
||||||
|
MountFlagsReadOnly = 0x1 // SSH_FXE_STATVFS_ST_RDONLY
|
||||||
|
MountFlagsNoSUID = 0x2 // SSH_FXE_STATVFS_ST_NOSUID
|
||||||
|
)
|
||||||
|
|
||||||
|
// StatVFSExtendedReplyPacket defines the extended reply packet for statvfs@openssh.com and fstatvfs@openssh.com requests.
|
||||||
|
type StatVFSExtendedReplyPacket struct {
|
||||||
|
BlockSize uint64 /* f_bsize: file system block size */
|
||||||
|
FragmentSize uint64 /* f_frsize: fundamental fs block size / fagment size */
|
||||||
|
Blocks uint64 /* f_blocks: number of blocks (unit f_frsize) */
|
||||||
|
BlocksFree uint64 /* f_bfree: free blocks in filesystem */
|
||||||
|
BlocksAvail uint64 /* f_bavail: free blocks for non-root */
|
||||||
|
Files uint64 /* f_files: total file inodes */
|
||||||
|
FilesFree uint64 /* f_ffree: free file inodes */
|
||||||
|
FilesAvail uint64 /* f_favail: free file inodes for to non-root */
|
||||||
|
FilesystemID uint64 /* f_fsid: file system id */
|
||||||
|
MountFlags uint64 /* f_flag: bit mask of mount flag values */
|
||||||
|
MaxNameLength uint64 /* f_namemax: maximum filename length */
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type returns the SSH_FXP_EXTENDED_REPLY packet type.
|
||||||
|
func (ep *StatVFSExtendedReplyPacket) Type() sshfx.PacketType {
|
||||||
|
return sshfx.PacketTypeExtendedReply
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalPacket returns ep as a two-part binary encoding of the full extended reply packet.
|
||||||
|
func (ep *StatVFSExtendedReplyPacket) MarshalPacket(reqid uint32, b []byte) (header, payload []byte, err error) {
|
||||||
|
p := &sshfx.ExtendedReplyPacket{
|
||||||
|
Data: ep,
|
||||||
|
}
|
||||||
|
return p.MarshalPacket(reqid, b)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalPacketBody returns ep as a two-part binary encoding of the full extended reply packet.
|
||||||
|
func (ep *StatVFSExtendedReplyPacket) UnmarshalPacketBody(buf *sshfx.Buffer) (err error) {
|
||||||
|
p := &sshfx.ExtendedReplyPacket{
|
||||||
|
Data: ep,
|
||||||
|
}
|
||||||
|
return p.UnmarshalPacketBody(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalInto encodes ep into the binary encoding of the (f)statvfs@openssh.com extended reply packet-specific data.
|
||||||
|
func (ep *StatVFSExtendedReplyPacket) MarshalInto(buf *sshfx.Buffer) {
|
||||||
|
buf.AppendUint64(ep.BlockSize)
|
||||||
|
buf.AppendUint64(ep.FragmentSize)
|
||||||
|
buf.AppendUint64(ep.Blocks)
|
||||||
|
buf.AppendUint64(ep.BlocksFree)
|
||||||
|
buf.AppendUint64(ep.BlocksAvail)
|
||||||
|
buf.AppendUint64(ep.Files)
|
||||||
|
buf.AppendUint64(ep.FilesFree)
|
||||||
|
buf.AppendUint64(ep.FilesAvail)
|
||||||
|
buf.AppendUint64(ep.FilesystemID)
|
||||||
|
buf.AppendUint64(ep.MountFlags)
|
||||||
|
buf.AppendUint64(ep.MaxNameLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary encodes ep into the binary encoding of the (f)statvfs@openssh.com extended reply packet-specific data.
|
||||||
|
//
|
||||||
|
// NOTE: This _only_ encodes the packet-specific data, it does not encode the full extended reply packet.
|
||||||
|
func (ep *StatVFSExtendedReplyPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
size := 11 * 8 // 11 × uint64(various)
|
||||||
|
|
||||||
|
b := sshfx.NewBuffer(make([]byte, 0, size))
|
||||||
|
ep.MarshalInto(b)
|
||||||
|
return b.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalFrom decodes the fstatvfs@openssh.com extended reply packet-specific data into ep.
|
||||||
|
func (ep *StatVFSExtendedReplyPacket) UnmarshalFrom(buf *sshfx.Buffer) (err error) {
|
||||||
|
*ep = StatVFSExtendedReplyPacket{
|
||||||
|
BlockSize: buf.ConsumeUint64(),
|
||||||
|
FragmentSize: buf.ConsumeUint64(),
|
||||||
|
Blocks: buf.ConsumeUint64(),
|
||||||
|
BlocksFree: buf.ConsumeUint64(),
|
||||||
|
BlocksAvail: buf.ConsumeUint64(),
|
||||||
|
Files: buf.ConsumeUint64(),
|
||||||
|
FilesFree: buf.ConsumeUint64(),
|
||||||
|
FilesAvail: buf.ConsumeUint64(),
|
||||||
|
FilesystemID: buf.ConsumeUint64(),
|
||||||
|
MountFlags: buf.ConsumeUint64(),
|
||||||
|
MaxNameLength: buf.ConsumeUint64(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary decodes the fstatvfs@openssh.com extended reply packet-specific data into ep.
|
||||||
|
func (ep *StatVFSExtendedReplyPacket) UnmarshalBinary(data []byte) (err error) {
|
||||||
|
return ep.UnmarshalFrom(sshfx.NewBuffer(data))
|
||||||
|
}
|
||||||
4
vendor/github.com/pkg/sftp/ls_unix.go
generated
vendored
4
vendor/github.com/pkg/sftp/ls_unix.go
generated
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
//go:build aix || darwin || dragonfly || freebsd || (!android && linux) || netbsd || openbsd || solaris || js
|
//go:build aix || darwin || dragonfly || freebsd || (!android && linux) || netbsd || openbsd || solaris || js || zos
|
||||||
// +build aix darwin dragonfly freebsd !android,linux netbsd openbsd solaris js
|
// +build aix darwin dragonfly freebsd !android,linux netbsd openbsd solaris js zos
|
||||||
|
|
||||||
package sftp
|
package sftp
|
||||||
|
|
||||||
|
|
|
||||||
199
vendor/github.com/pkg/sftp/packet.go
generated
vendored
199
vendor/github.com/pkg/sftp/packet.go
generated
vendored
|
|
@ -56,6 +56,11 @@ func marshalFileInfo(b []byte, fi os.FileInfo) []byte {
|
||||||
flags, fileStat := fileStatFromInfo(fi)
|
flags, fileStat := fileStatFromInfo(fi)
|
||||||
|
|
||||||
b = marshalUint32(b, flags)
|
b = marshalUint32(b, flags)
|
||||||
|
|
||||||
|
return marshalFileStat(b, flags, fileStat)
|
||||||
|
}
|
||||||
|
|
||||||
|
func marshalFileStat(b []byte, flags uint32, fileStat *FileStat) []byte {
|
||||||
if flags&sshFileXferAttrSize != 0 {
|
if flags&sshFileXferAttrSize != 0 {
|
||||||
b = marshalUint64(b, fileStat.Size)
|
b = marshalUint64(b, fileStat.Size)
|
||||||
}
|
}
|
||||||
|
|
@ -91,10 +96,9 @@ func marshalStatus(b []byte, err StatusError) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshal(b []byte, v interface{}) []byte {
|
func marshal(b []byte, v interface{}) []byte {
|
||||||
if v == nil {
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
switch v := v.(type) {
|
switch v := v.(type) {
|
||||||
|
case nil:
|
||||||
|
return b
|
||||||
case uint8:
|
case uint8:
|
||||||
return append(b, v)
|
return append(b, v)
|
||||||
case uint32:
|
case uint32:
|
||||||
|
|
@ -103,6 +107,8 @@ func marshal(b []byte, v interface{}) []byte {
|
||||||
return marshalUint64(b, v)
|
return marshalUint64(b, v)
|
||||||
case string:
|
case string:
|
||||||
return marshalString(b, v)
|
return marshalString(b, v)
|
||||||
|
case []byte:
|
||||||
|
return append(b, v...)
|
||||||
case os.FileInfo:
|
case os.FileInfo:
|
||||||
return marshalFileInfo(b, v)
|
return marshalFileInfo(b, v)
|
||||||
default:
|
default:
|
||||||
|
|
@ -168,38 +174,69 @@ func unmarshalStringSafe(b []byte) (string, []byte, error) {
|
||||||
return string(b[:n]), b[n:], nil
|
return string(b[:n]), b[n:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func unmarshalAttrs(b []byte) (*FileStat, []byte) {
|
func unmarshalAttrs(b []byte) (*FileStat, []byte, error) {
|
||||||
flags, b := unmarshalUint32(b)
|
flags, b, err := unmarshalUint32Safe(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
return unmarshalFileStat(flags, b)
|
return unmarshalFileStat(flags, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func unmarshalFileStat(flags uint32, b []byte) (*FileStat, []byte) {
|
func unmarshalFileStat(flags uint32, b []byte) (*FileStat, []byte, error) {
|
||||||
var fs FileStat
|
var fs FileStat
|
||||||
|
var err error
|
||||||
|
|
||||||
if flags&sshFileXferAttrSize == sshFileXferAttrSize {
|
if flags&sshFileXferAttrSize == sshFileXferAttrSize {
|
||||||
fs.Size, b, _ = unmarshalUint64Safe(b)
|
fs.Size, b, err = unmarshalUint64Safe(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if flags&sshFileXferAttrUIDGID == sshFileXferAttrUIDGID {
|
if flags&sshFileXferAttrUIDGID == sshFileXferAttrUIDGID {
|
||||||
fs.UID, b, _ = unmarshalUint32Safe(b)
|
fs.UID, b, err = unmarshalUint32Safe(b)
|
||||||
}
|
if err != nil {
|
||||||
if flags&sshFileXferAttrUIDGID == sshFileXferAttrUIDGID {
|
return nil, b, err
|
||||||
fs.GID, b, _ = unmarshalUint32Safe(b)
|
}
|
||||||
|
fs.GID, b, err = unmarshalUint32Safe(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if flags&sshFileXferAttrPermissions == sshFileXferAttrPermissions {
|
if flags&sshFileXferAttrPermissions == sshFileXferAttrPermissions {
|
||||||
fs.Mode, b, _ = unmarshalUint32Safe(b)
|
fs.Mode, b, err = unmarshalUint32Safe(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if flags&sshFileXferAttrACmodTime == sshFileXferAttrACmodTime {
|
if flags&sshFileXferAttrACmodTime == sshFileXferAttrACmodTime {
|
||||||
fs.Atime, b, _ = unmarshalUint32Safe(b)
|
fs.Atime, b, err = unmarshalUint32Safe(b)
|
||||||
fs.Mtime, b, _ = unmarshalUint32Safe(b)
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
|
fs.Mtime, b, err = unmarshalUint32Safe(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if flags&sshFileXferAttrExtended == sshFileXferAttrExtended {
|
if flags&sshFileXferAttrExtended == sshFileXferAttrExtended {
|
||||||
var count uint32
|
var count uint32
|
||||||
count, b, _ = unmarshalUint32Safe(b)
|
count, b, err = unmarshalUint32Safe(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
|
|
||||||
ext := make([]StatExtended, count)
|
ext := make([]StatExtended, count)
|
||||||
for i := uint32(0); i < count; i++ {
|
for i := uint32(0); i < count; i++ {
|
||||||
var typ string
|
var typ string
|
||||||
var data string
|
var data string
|
||||||
typ, b, _ = unmarshalStringSafe(b)
|
typ, b, err = unmarshalStringSafe(b)
|
||||||
data, b, _ = unmarshalStringSafe(b)
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
|
data, b, err = unmarshalStringSafe(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, b, err
|
||||||
|
}
|
||||||
ext[i] = StatExtended{
|
ext[i] = StatExtended{
|
||||||
ExtType: typ,
|
ExtType: typ,
|
||||||
ExtData: data,
|
ExtData: data,
|
||||||
|
|
@ -207,7 +244,7 @@ func unmarshalFileStat(flags uint32, b []byte) (*FileStat, []byte) {
|
||||||
}
|
}
|
||||||
fs.Extended = ext
|
fs.Extended = ext
|
||||||
}
|
}
|
||||||
return &fs, b
|
return &fs, b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func unmarshalStatus(id uint32, data []byte) error {
|
func unmarshalStatus(id uint32, data []byte) error {
|
||||||
|
|
@ -267,16 +304,22 @@ func sendPacket(w io.Writer, m encoding.BinaryMarshaler) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func recvPacket(r io.Reader, alloc *allocator, orderID uint32) (uint8, []byte, error) {
|
func recvPacket(r io.Reader, alloc *allocator, orderID uint32) (fxp, []byte, error) {
|
||||||
var b []byte
|
var b []byte
|
||||||
if alloc != nil {
|
if alloc != nil {
|
||||||
b = alloc.GetPage(orderID)
|
b = alloc.GetPage(orderID)
|
||||||
} else {
|
} else {
|
||||||
b = make([]byte, 4)
|
b = make([]byte, 4)
|
||||||
}
|
}
|
||||||
if _, err := io.ReadFull(r, b[:4]); err != nil {
|
|
||||||
return 0, nil, err
|
if n, err := io.ReadFull(r, b[:4]); err != nil {
|
||||||
|
if err == io.EOF {
|
||||||
|
return 0, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0, nil, fmt.Errorf("error reading packet length: %d of 4: %w", n, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
length, _ := unmarshalUint32(b)
|
length, _ := unmarshalUint32(b)
|
||||||
if length > maxMsgLength {
|
if length > maxMsgLength {
|
||||||
debug("recv packet %d bytes too long", length)
|
debug("recv packet %d bytes too long", length)
|
||||||
|
|
@ -286,24 +329,39 @@ func recvPacket(r io.Reader, alloc *allocator, orderID uint32) (uint8, []byte, e
|
||||||
debug("recv packet of 0 bytes too short")
|
debug("recv packet of 0 bytes too short")
|
||||||
return 0, nil, errShortPacket
|
return 0, nil, errShortPacket
|
||||||
}
|
}
|
||||||
|
|
||||||
if alloc == nil {
|
if alloc == nil {
|
||||||
b = make([]byte, length)
|
b = make([]byte, length)
|
||||||
}
|
}
|
||||||
if _, err := io.ReadFull(r, b[:length]); err != nil {
|
|
||||||
|
n, err := io.ReadFull(r, b[:length])
|
||||||
|
b = b[:n]
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
debug("recv packet error: %d of %d bytes: %x", n, length, b)
|
||||||
|
|
||||||
// ReadFull only returns EOF if it has read no bytes.
|
// ReadFull only returns EOF if it has read no bytes.
|
||||||
// In this case, that means a partial packet, and thus unexpected.
|
// In this case, that means a partial packet, and thus unexpected.
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
err = io.ErrUnexpectedEOF
|
err = io.ErrUnexpectedEOF
|
||||||
}
|
}
|
||||||
debug("recv packet %d bytes: err %v", length, err)
|
|
||||||
return 0, nil, err
|
if n == 0 {
|
||||||
|
return 0, nil, fmt.Errorf("error reading packet body: %d of %d: %w", n, length, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0, nil, fmt.Errorf("error reading packet body: %d of %d: (%s) %w", n, length, fxp(b[0]), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typ, payload := fxp(b[0]), b[1:n]
|
||||||
|
|
||||||
if debugDumpRxPacketBytes {
|
if debugDumpRxPacketBytes {
|
||||||
debug("recv packet: %s %d bytes %x", fxp(b[0]), length, b[1:length])
|
debug("recv packet: %s %d bytes %x", typ, length, payload)
|
||||||
} else if debugDumpRxPacket {
|
} else if debugDumpRxPacket {
|
||||||
debug("recv packet: %s %d bytes", fxp(b[0]), length)
|
debug("recv packet: %s %d bytes", typ, length)
|
||||||
}
|
}
|
||||||
return b[0], b[1:length], nil
|
|
||||||
|
return typ, payload, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type extensionPair struct {
|
type extensionPair struct {
|
||||||
|
|
@ -681,12 +739,13 @@ type sshFxpOpenPacket struct {
|
||||||
ID uint32
|
ID uint32
|
||||||
Path string
|
Path string
|
||||||
Pflags uint32
|
Pflags uint32
|
||||||
Flags uint32 // ignored
|
Flags uint32
|
||||||
|
Attrs interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *sshFxpOpenPacket) id() uint32 { return p.ID }
|
func (p *sshFxpOpenPacket) id() uint32 { return p.ID }
|
||||||
|
|
||||||
func (p *sshFxpOpenPacket) MarshalBinary() ([]byte, error) {
|
func (p *sshFxpOpenPacket) marshalPacket() ([]byte, []byte, error) {
|
||||||
l := 4 + 1 + 4 + // uint32(length) + byte(type) + uint32(id)
|
l := 4 + 1 + 4 + // uint32(length) + byte(type) + uint32(id)
|
||||||
4 + len(p.Path) +
|
4 + len(p.Path) +
|
||||||
4 + 4
|
4 + 4
|
||||||
|
|
@ -698,7 +757,22 @@ func (p *sshFxpOpenPacket) MarshalBinary() ([]byte, error) {
|
||||||
b = marshalUint32(b, p.Pflags)
|
b = marshalUint32(b, p.Pflags)
|
||||||
b = marshalUint32(b, p.Flags)
|
b = marshalUint32(b, p.Flags)
|
||||||
|
|
||||||
return b, nil
|
switch attrs := p.Attrs.(type) {
|
||||||
|
case []byte:
|
||||||
|
return b, attrs, nil // may as well short-ciruit this case.
|
||||||
|
case os.FileInfo:
|
||||||
|
_, fs := fileStatFromInfo(attrs) // we throw away the flags, and override with those in packet.
|
||||||
|
return b, marshalFileStat(nil, p.Flags, fs), nil
|
||||||
|
case *FileStat:
|
||||||
|
return b, marshalFileStat(nil, p.Flags, attrs), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return b, marshal(nil, p.Attrs), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *sshFxpOpenPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
header, payload, err := p.marshalPacket()
|
||||||
|
return append(header, payload...), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *sshFxpOpenPacket) UnmarshalBinary(b []byte) error {
|
func (p *sshFxpOpenPacket) UnmarshalBinary(b []byte) error {
|
||||||
|
|
@ -709,12 +783,25 @@ func (p *sshFxpOpenPacket) UnmarshalBinary(b []byte) error {
|
||||||
return err
|
return err
|
||||||
} else if p.Pflags, b, err = unmarshalUint32Safe(b); err != nil {
|
} else if p.Pflags, b, err = unmarshalUint32Safe(b); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if p.Flags, _, err = unmarshalUint32Safe(b); err != nil {
|
} else if p.Flags, b, err = unmarshalUint32Safe(b); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
p.Attrs = b
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *sshFxpOpenPacket) unmarshalFileStat(flags uint32) (*FileStat, error) {
|
||||||
|
switch attrs := p.Attrs.(type) {
|
||||||
|
case *FileStat:
|
||||||
|
return attrs, nil
|
||||||
|
case []byte:
|
||||||
|
fs, _, err := unmarshalFileStat(flags, attrs)
|
||||||
|
return fs, err
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("invalid type in unmarshalFileStat: %T", attrs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type sshFxpReadPacket struct {
|
type sshFxpReadPacket struct {
|
||||||
ID uint32
|
ID uint32
|
||||||
Len uint32
|
Len uint32
|
||||||
|
|
@ -757,7 +844,7 @@ func (p *sshFxpReadPacket) UnmarshalBinary(b []byte) error {
|
||||||
// So, we need: uint32(length) + byte(type) + uint32(id) + uint32(data_length)
|
// So, we need: uint32(length) + byte(type) + uint32(id) + uint32(data_length)
|
||||||
const dataHeaderLen = 4 + 1 + 4 + 4
|
const dataHeaderLen = 4 + 1 + 4 + 4
|
||||||
|
|
||||||
func (p *sshFxpReadPacket) getDataSlice(alloc *allocator, orderID uint32) []byte {
|
func (p *sshFxpReadPacket) getDataSlice(alloc *allocator, orderID uint32, maxTxPacket uint32) []byte {
|
||||||
dataLen := p.Len
|
dataLen := p.Len
|
||||||
if dataLen > maxTxPacket {
|
if dataLen > maxTxPacket {
|
||||||
dataLen = maxTxPacket
|
dataLen = maxTxPacket
|
||||||
|
|
@ -943,9 +1030,17 @@ func (p *sshFxpSetstatPacket) marshalPacket() ([]byte, []byte, error) {
|
||||||
b = marshalString(b, p.Path)
|
b = marshalString(b, p.Path)
|
||||||
b = marshalUint32(b, p.Flags)
|
b = marshalUint32(b, p.Flags)
|
||||||
|
|
||||||
payload := marshal(nil, p.Attrs)
|
switch attrs := p.Attrs.(type) {
|
||||||
|
case []byte:
|
||||||
|
return b, attrs, nil // may as well short-ciruit this case.
|
||||||
|
case os.FileInfo:
|
||||||
|
_, fs := fileStatFromInfo(attrs) // we throw away the flags, and override with those in packet.
|
||||||
|
return b, marshalFileStat(nil, p.Flags, fs), nil
|
||||||
|
case *FileStat:
|
||||||
|
return b, marshalFileStat(nil, p.Flags, attrs), nil
|
||||||
|
}
|
||||||
|
|
||||||
return b, payload, nil
|
return b, marshal(nil, p.Attrs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *sshFxpSetstatPacket) MarshalBinary() ([]byte, error) {
|
func (p *sshFxpSetstatPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
|
@ -964,9 +1059,17 @@ func (p *sshFxpFsetstatPacket) marshalPacket() ([]byte, []byte, error) {
|
||||||
b = marshalString(b, p.Handle)
|
b = marshalString(b, p.Handle)
|
||||||
b = marshalUint32(b, p.Flags)
|
b = marshalUint32(b, p.Flags)
|
||||||
|
|
||||||
payload := marshal(nil, p.Attrs)
|
switch attrs := p.Attrs.(type) {
|
||||||
|
case []byte:
|
||||||
|
return b, attrs, nil // may as well short-ciruit this case.
|
||||||
|
case os.FileInfo:
|
||||||
|
_, fs := fileStatFromInfo(attrs) // we throw away the flags, and override with those in packet.
|
||||||
|
return b, marshalFileStat(nil, p.Flags, fs), nil
|
||||||
|
case *FileStat:
|
||||||
|
return b, marshalFileStat(nil, p.Flags, attrs), nil
|
||||||
|
}
|
||||||
|
|
||||||
return b, payload, nil
|
return b, marshal(nil, p.Attrs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *sshFxpFsetstatPacket) MarshalBinary() ([]byte, error) {
|
func (p *sshFxpFsetstatPacket) MarshalBinary() ([]byte, error) {
|
||||||
|
|
@ -987,6 +1090,18 @@ func (p *sshFxpSetstatPacket) UnmarshalBinary(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *sshFxpSetstatPacket) unmarshalFileStat(flags uint32) (*FileStat, error) {
|
||||||
|
switch attrs := p.Attrs.(type) {
|
||||||
|
case *FileStat:
|
||||||
|
return attrs, nil
|
||||||
|
case []byte:
|
||||||
|
fs, _, err := unmarshalFileStat(flags, attrs)
|
||||||
|
return fs, err
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("invalid type in unmarshalFileStat: %T", attrs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *sshFxpFsetstatPacket) UnmarshalBinary(b []byte) error {
|
func (p *sshFxpFsetstatPacket) UnmarshalBinary(b []byte) error {
|
||||||
var err error
|
var err error
|
||||||
if p.ID, b, err = unmarshalUint32Safe(b); err != nil {
|
if p.ID, b, err = unmarshalUint32Safe(b); err != nil {
|
||||||
|
|
@ -1000,6 +1115,18 @@ func (p *sshFxpFsetstatPacket) UnmarshalBinary(b []byte) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *sshFxpFsetstatPacket) unmarshalFileStat(flags uint32) (*FileStat, error) {
|
||||||
|
switch attrs := p.Attrs.(type) {
|
||||||
|
case *FileStat:
|
||||||
|
return attrs, nil
|
||||||
|
case []byte:
|
||||||
|
fs, _, err := unmarshalFileStat(flags, attrs)
|
||||||
|
return fs, err
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("invalid type in unmarshalFileStat: %T", attrs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type sshFxpHandlePacket struct {
|
type sshFxpHandlePacket struct {
|
||||||
ID uint32
|
ID uint32
|
||||||
Handle string
|
Handle string
|
||||||
|
|
|
||||||
8
vendor/github.com/pkg/sftp/request-attrs.go
generated
vendored
8
vendor/github.com/pkg/sftp/request-attrs.go
generated
vendored
|
|
@ -3,7 +3,6 @@ package sftp
|
||||||
// Methods on the Request object to make working with the Flags bitmasks and
|
// Methods on the Request object to make working with the Flags bitmasks and
|
||||||
// Attr(ibutes) byte blob easier. Use Pflags() when working with an Open/Write
|
// Attr(ibutes) byte blob easier. Use Pflags() when working with an Open/Write
|
||||||
// request and AttrFlags() and Attributes() when working with SetStat requests.
|
// request and AttrFlags() and Attributes() when working with SetStat requests.
|
||||||
import "os"
|
|
||||||
|
|
||||||
// FileOpenFlags defines Open and Write Flags. Correlate directly with with os.OpenFile flags
|
// FileOpenFlags defines Open and Write Flags. Correlate directly with with os.OpenFile flags
|
||||||
// (https://golang.org/pkg/os/#pkg-constants).
|
// (https://golang.org/pkg/os/#pkg-constants).
|
||||||
|
|
@ -50,14 +49,9 @@ func (r *Request) AttrFlags() FileAttrFlags {
|
||||||
return newFileAttrFlags(r.Flags)
|
return newFileAttrFlags(r.Flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FileMode returns the Mode SFTP file attributes wrapped as os.FileMode
|
|
||||||
func (a FileStat) FileMode() os.FileMode {
|
|
||||||
return os.FileMode(a.Mode)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attributes parses file attributes byte blob and return them in a
|
// Attributes parses file attributes byte blob and return them in a
|
||||||
// FileStat object.
|
// FileStat object.
|
||||||
func (r *Request) Attributes() *FileStat {
|
func (r *Request) Attributes() *FileStat {
|
||||||
fs, _ := unmarshalFileStat(r.Flags, r.Attrs)
|
fs, _, _ := unmarshalFileStat(r.Flags, r.Attrs)
|
||||||
return fs
|
return fs
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
vendor/github.com/pkg/sftp/request-example.go
generated
vendored
4
vendor/github.com/pkg/sftp/request-example.go
generated
vendored
|
|
@ -20,7 +20,7 @@ const maxSymlinkFollows = 5
|
||||||
|
|
||||||
var errTooManySymlinks = errors.New("too many symbolic links")
|
var errTooManySymlinks = errors.New("too many symbolic links")
|
||||||
|
|
||||||
// InMemHandler returns a Hanlders object with the test handlers.
|
// InMemHandler returns a Handlers object with the test handlers.
|
||||||
func InMemHandler() Handlers {
|
func InMemHandler() Handlers {
|
||||||
root := &root{
|
root := &root{
|
||||||
rootFile: &memFile{name: "/", modtime: time.Now(), isdir: true},
|
rootFile: &memFile{name: "/", modtime: time.Now(), isdir: true},
|
||||||
|
|
@ -449,7 +449,7 @@ func (fs *root) Lstat(r *Request) (ListerAt, error) {
|
||||||
return listerat{file}, nil
|
return listerat{file}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// In memory file-system-y thing that the Hanlders live on
|
// In memory file-system-y thing that the Handlers live on
|
||||||
type root struct {
|
type root struct {
|
||||||
rootFile *memFile
|
rootFile *memFile
|
||||||
mockErr error
|
mockErr error
|
||||||
|
|
|
||||||
4
vendor/github.com/pkg/sftp/request-interfaces.go
generated
vendored
4
vendor/github.com/pkg/sftp/request-interfaces.go
generated
vendored
|
|
@ -30,7 +30,7 @@ type FileReader interface {
|
||||||
// FileWriter should return an io.WriterAt for the filepath.
|
// FileWriter should return an io.WriterAt for the filepath.
|
||||||
//
|
//
|
||||||
// The request server code will call Close() on the returned io.WriterAt
|
// The request server code will call Close() on the returned io.WriterAt
|
||||||
// ojbect if an io.Closer type assertion succeeds.
|
// object if an io.Closer type assertion succeeds.
|
||||||
// Note in cases of an error, the error text will be sent to the client.
|
// Note in cases of an error, the error text will be sent to the client.
|
||||||
// Note when receiving an Append flag it is important to not open files using
|
// Note when receiving an Append flag it is important to not open files using
|
||||||
// O_APPEND if you plan to use WriteAt, as they conflict.
|
// O_APPEND if you plan to use WriteAt, as they conflict.
|
||||||
|
|
@ -144,6 +144,8 @@ type NameLookupFileLister interface {
|
||||||
//
|
//
|
||||||
// If a populated entry implements [FileInfoExtendedData], extended attributes will also be returned to the client.
|
// If a populated entry implements [FileInfoExtendedData], extended attributes will also be returned to the client.
|
||||||
//
|
//
|
||||||
|
// The request server code will call Close() on ListerAt if an io.Closer type assertion succeeds.
|
||||||
|
//
|
||||||
// Note in cases of an error, the error text will be sent to the client.
|
// Note in cases of an error, the error text will be sent to the client.
|
||||||
type ListerAt interface {
|
type ListerAt interface {
|
||||||
ListAt([]os.FileInfo, int64) (int, error)
|
ListAt([]os.FileInfo, int64) (int, error)
|
||||||
|
|
|
||||||
36
vendor/github.com/pkg/sftp/request-server.go
generated
vendored
36
vendor/github.com/pkg/sftp/request-server.go
generated
vendored
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
var maxTxPacket uint32 = 1 << 15
|
const defaultMaxTxPacket uint32 = 1 << 15
|
||||||
|
|
||||||
// Handlers contains the 4 SFTP server request handlers.
|
// Handlers contains the 4 SFTP server request handlers.
|
||||||
type Handlers struct {
|
type Handlers struct {
|
||||||
|
|
@ -28,6 +28,7 @@ type RequestServer struct {
|
||||||
pktMgr *packetManager
|
pktMgr *packetManager
|
||||||
|
|
||||||
startDirectory string
|
startDirectory string
|
||||||
|
maxTxPacket uint32
|
||||||
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
handleCount int
|
handleCount int
|
||||||
|
|
@ -57,6 +58,22 @@ func WithStartDirectory(startDirectory string) RequestServerOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithRSMaxTxPacket sets the maximum size of the payload returned to the client,
|
||||||
|
// measured in bytes. The default value is 32768 bytes, and this option
|
||||||
|
// can only be used to increase it. Setting this option to a larger value
|
||||||
|
// should be safe, because the client decides the size of the requested payload.
|
||||||
|
//
|
||||||
|
// The default maximum packet size is 32768 bytes.
|
||||||
|
func WithRSMaxTxPacket(size uint32) RequestServerOption {
|
||||||
|
return func(rs *RequestServer) {
|
||||||
|
if size < defaultMaxTxPacket {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
rs.maxTxPacket = size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewRequestServer creates/allocates/returns new RequestServer.
|
// NewRequestServer creates/allocates/returns new RequestServer.
|
||||||
// Normally there will be one server per user-session.
|
// Normally there will be one server per user-session.
|
||||||
func NewRequestServer(rwc io.ReadWriteCloser, h Handlers, options ...RequestServerOption) *RequestServer {
|
func NewRequestServer(rwc io.ReadWriteCloser, h Handlers, options ...RequestServerOption) *RequestServer {
|
||||||
|
|
@ -73,6 +90,7 @@ func NewRequestServer(rwc io.ReadWriteCloser, h Handlers, options ...RequestServ
|
||||||
pktMgr: newPktMgr(svrConn),
|
pktMgr: newPktMgr(svrConn),
|
||||||
|
|
||||||
startDirectory: "/",
|
startDirectory: "/",
|
||||||
|
maxTxPacket: defaultMaxTxPacket,
|
||||||
|
|
||||||
openRequests: make(map[string]*Request),
|
openRequests: make(map[string]*Request),
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +148,7 @@ func (rs *RequestServer) serveLoop(pktChan chan<- orderedRequest) error {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var pkt requestPacket
|
var pkt requestPacket
|
||||||
var pktType uint8
|
var pktType fxp
|
||||||
var pktBytes []byte
|
var pktBytes []byte
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
@ -140,7 +158,7 @@ func (rs *RequestServer) serveLoop(pktChan chan<- orderedRequest) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt, err = makePacket(rxPacket{fxp(pktType), pktBytes})
|
pkt, err = makePacket(rxPacket{pktType, pktBytes})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, errUnknownExtendedPacket):
|
case errors.Is(err, errUnknownExtendedPacket):
|
||||||
|
|
@ -260,7 +278,7 @@ func (rs *RequestServer) packetWorker(ctx context.Context, pktChan chan orderedR
|
||||||
Method: "Stat",
|
Method: "Stat",
|
||||||
Filepath: cleanPathWithBase(rs.startDirectory, request.Filepath),
|
Filepath: cleanPathWithBase(rs.startDirectory, request.Filepath),
|
||||||
}
|
}
|
||||||
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID)
|
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID, rs.maxTxPacket)
|
||||||
}
|
}
|
||||||
case *sshFxpFsetstatPacket:
|
case *sshFxpFsetstatPacket:
|
||||||
handle := pkt.getHandle()
|
handle := pkt.getHandle()
|
||||||
|
|
@ -272,7 +290,7 @@ func (rs *RequestServer) packetWorker(ctx context.Context, pktChan chan orderedR
|
||||||
Method: "Setstat",
|
Method: "Setstat",
|
||||||
Filepath: cleanPathWithBase(rs.startDirectory, request.Filepath),
|
Filepath: cleanPathWithBase(rs.startDirectory, request.Filepath),
|
||||||
}
|
}
|
||||||
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID)
|
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID, rs.maxTxPacket)
|
||||||
}
|
}
|
||||||
case *sshFxpExtendedPacketPosixRename:
|
case *sshFxpExtendedPacketPosixRename:
|
||||||
request := &Request{
|
request := &Request{
|
||||||
|
|
@ -280,24 +298,24 @@ func (rs *RequestServer) packetWorker(ctx context.Context, pktChan chan orderedR
|
||||||
Filepath: cleanPathWithBase(rs.startDirectory, pkt.Oldpath),
|
Filepath: cleanPathWithBase(rs.startDirectory, pkt.Oldpath),
|
||||||
Target: cleanPathWithBase(rs.startDirectory, pkt.Newpath),
|
Target: cleanPathWithBase(rs.startDirectory, pkt.Newpath),
|
||||||
}
|
}
|
||||||
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID)
|
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID, rs.maxTxPacket)
|
||||||
case *sshFxpExtendedPacketStatVFS:
|
case *sshFxpExtendedPacketStatVFS:
|
||||||
request := &Request{
|
request := &Request{
|
||||||
Method: "StatVFS",
|
Method: "StatVFS",
|
||||||
Filepath: cleanPathWithBase(rs.startDirectory, pkt.Path),
|
Filepath: cleanPathWithBase(rs.startDirectory, pkt.Path),
|
||||||
}
|
}
|
||||||
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID)
|
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID, rs.maxTxPacket)
|
||||||
case hasHandle:
|
case hasHandle:
|
||||||
handle := pkt.getHandle()
|
handle := pkt.getHandle()
|
||||||
request, ok := rs.getRequest(handle)
|
request, ok := rs.getRequest(handle)
|
||||||
if !ok {
|
if !ok {
|
||||||
rpkt = statusFromError(pkt.id(), EBADF)
|
rpkt = statusFromError(pkt.id(), EBADF)
|
||||||
} else {
|
} else {
|
||||||
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID)
|
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID, rs.maxTxPacket)
|
||||||
}
|
}
|
||||||
case hasPath:
|
case hasPath:
|
||||||
request := requestFromPacket(ctx, pkt, rs.startDirectory)
|
request := requestFromPacket(ctx, pkt, rs.startDirectory)
|
||||||
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID)
|
rpkt = request.call(rs.Handlers, pkt, rs.pktMgr.alloc, orderID, rs.maxTxPacket)
|
||||||
request.close()
|
request.close()
|
||||||
default:
|
default:
|
||||||
rpkt = statusFromError(pkt.id(), ErrSSHFxOpUnsupported)
|
rpkt = statusFromError(pkt.id(), ErrSSHFxOpUnsupported)
|
||||||
|
|
|
||||||
45
vendor/github.com/pkg/sftp/request.go
generated
vendored
45
vendor/github.com/pkg/sftp/request.go
generated
vendored
|
|
@ -121,6 +121,22 @@ func (s *state) getListerAt() ListerAt {
|
||||||
return s.listerAt
|
return s.listerAt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *state) closeListerAt() error {
|
||||||
|
s.mu.Lock()
|
||||||
|
defer s.mu.Unlock()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if s.listerAt != nil {
|
||||||
|
if c, ok := s.listerAt.(io.Closer); ok {
|
||||||
|
err = c.Close()
|
||||||
|
}
|
||||||
|
s.listerAt = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Request contains the data and state for the incoming service request.
|
// Request contains the data and state for the incoming service request.
|
||||||
type Request struct {
|
type Request struct {
|
||||||
// Get, Put, Setstat, Stat, Rename, Remove
|
// Get, Put, Setstat, Stat, Rename, Remove
|
||||||
|
|
@ -178,6 +194,7 @@ func requestFromPacket(ctx context.Context, pkt hasPath, baseDir string) *Reques
|
||||||
switch p := pkt.(type) {
|
switch p := pkt.(type) {
|
||||||
case *sshFxpOpenPacket:
|
case *sshFxpOpenPacket:
|
||||||
request.Flags = p.Pflags
|
request.Flags = p.Pflags
|
||||||
|
request.Attrs = p.Attrs.([]byte)
|
||||||
case *sshFxpSetstatPacket:
|
case *sshFxpSetstatPacket:
|
||||||
request.Flags = p.Flags
|
request.Flags = p.Flags
|
||||||
request.Attrs = p.Attrs.([]byte)
|
request.Attrs = p.Attrs.([]byte)
|
||||||
|
|
@ -229,9 +246,9 @@ func (r *Request) close() error {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
rd, wr, rw := r.getAllReaderWriters()
|
err := r.state.closeListerAt()
|
||||||
|
|
||||||
var err error
|
rd, wr, rw := r.getAllReaderWriters()
|
||||||
|
|
||||||
// Close errors on a Writer are far more likely to be the important one.
|
// Close errors on a Writer are far more likely to be the important one.
|
||||||
// As they can be information that there was a loss of data.
|
// As they can be information that there was a loss of data.
|
||||||
|
|
@ -283,14 +300,14 @@ func (r *Request) transferError(err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// called from worker to handle packet/request
|
// called from worker to handle packet/request
|
||||||
func (r *Request) call(handlers Handlers, pkt requestPacket, alloc *allocator, orderID uint32) responsePacket {
|
func (r *Request) call(handlers Handlers, pkt requestPacket, alloc *allocator, orderID uint32, maxTxPacket uint32) responsePacket {
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case "Get":
|
case "Get":
|
||||||
return fileget(handlers.FileGet, r, pkt, alloc, orderID)
|
return fileget(handlers.FileGet, r, pkt, alloc, orderID, maxTxPacket)
|
||||||
case "Put":
|
case "Put":
|
||||||
return fileput(handlers.FilePut, r, pkt, alloc, orderID)
|
return fileput(handlers.FilePut, r, pkt, alloc, orderID, maxTxPacket)
|
||||||
case "Open":
|
case "Open":
|
||||||
return fileputget(handlers.FilePut, r, pkt, alloc, orderID)
|
return fileputget(handlers.FilePut, r, pkt, alloc, orderID, maxTxPacket)
|
||||||
case "Setstat", "Rename", "Rmdir", "Mkdir", "Link", "Symlink", "Remove", "PosixRename", "StatVFS":
|
case "Setstat", "Rename", "Rmdir", "Mkdir", "Link", "Symlink", "Remove", "PosixRename", "StatVFS":
|
||||||
return filecmd(handlers.FileCmd, r, pkt)
|
return filecmd(handlers.FileCmd, r, pkt)
|
||||||
case "List":
|
case "List":
|
||||||
|
|
@ -375,13 +392,13 @@ func (r *Request) opendir(h Handlers, pkt requestPacket) responsePacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrap FileReader handler
|
// wrap FileReader handler
|
||||||
func fileget(h FileReader, r *Request, pkt requestPacket, alloc *allocator, orderID uint32) responsePacket {
|
func fileget(h FileReader, r *Request, pkt requestPacket, alloc *allocator, orderID uint32, maxTxPacket uint32) responsePacket {
|
||||||
rd := r.getReaderAt()
|
rd := r.getReaderAt()
|
||||||
if rd == nil {
|
if rd == nil {
|
||||||
return statusFromError(pkt.id(), errors.New("unexpected read packet"))
|
return statusFromError(pkt.id(), errors.New("unexpected read packet"))
|
||||||
}
|
}
|
||||||
|
|
||||||
data, offset, _ := packetData(pkt, alloc, orderID)
|
data, offset, _ := packetData(pkt, alloc, orderID, maxTxPacket)
|
||||||
|
|
||||||
n, err := rd.ReadAt(data, offset)
|
n, err := rd.ReadAt(data, offset)
|
||||||
// only return EOF error if no data left to read
|
// only return EOF error if no data left to read
|
||||||
|
|
@ -397,20 +414,20 @@ func fileget(h FileReader, r *Request, pkt requestPacket, alloc *allocator, orde
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrap FileWriter handler
|
// wrap FileWriter handler
|
||||||
func fileput(h FileWriter, r *Request, pkt requestPacket, alloc *allocator, orderID uint32) responsePacket {
|
func fileput(h FileWriter, r *Request, pkt requestPacket, alloc *allocator, orderID uint32, maxTxPacket uint32) responsePacket {
|
||||||
wr := r.getWriterAt()
|
wr := r.getWriterAt()
|
||||||
if wr == nil {
|
if wr == nil {
|
||||||
return statusFromError(pkt.id(), errors.New("unexpected write packet"))
|
return statusFromError(pkt.id(), errors.New("unexpected write packet"))
|
||||||
}
|
}
|
||||||
|
|
||||||
data, offset, _ := packetData(pkt, alloc, orderID)
|
data, offset, _ := packetData(pkt, alloc, orderID, maxTxPacket)
|
||||||
|
|
||||||
_, err := wr.WriteAt(data, offset)
|
_, err := wr.WriteAt(data, offset)
|
||||||
return statusFromError(pkt.id(), err)
|
return statusFromError(pkt.id(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrap OpenFileWriter handler
|
// wrap OpenFileWriter handler
|
||||||
func fileputget(h FileWriter, r *Request, pkt requestPacket, alloc *allocator, orderID uint32) responsePacket {
|
func fileputget(h FileWriter, r *Request, pkt requestPacket, alloc *allocator, orderID uint32, maxTxPacket uint32) responsePacket {
|
||||||
rw := r.getWriterAtReaderAt()
|
rw := r.getWriterAtReaderAt()
|
||||||
if rw == nil {
|
if rw == nil {
|
||||||
return statusFromError(pkt.id(), errors.New("unexpected write and read packet"))
|
return statusFromError(pkt.id(), errors.New("unexpected write and read packet"))
|
||||||
|
|
@ -418,7 +435,7 @@ func fileputget(h FileWriter, r *Request, pkt requestPacket, alloc *allocator, o
|
||||||
|
|
||||||
switch p := pkt.(type) {
|
switch p := pkt.(type) {
|
||||||
case *sshFxpReadPacket:
|
case *sshFxpReadPacket:
|
||||||
data, offset := p.getDataSlice(alloc, orderID), int64(p.Offset)
|
data, offset := p.getDataSlice(alloc, orderID, maxTxPacket), int64(p.Offset)
|
||||||
|
|
||||||
n, err := rw.ReadAt(data, offset)
|
n, err := rw.ReadAt(data, offset)
|
||||||
// only return EOF error if no data left to read
|
// only return EOF error if no data left to read
|
||||||
|
|
@ -444,10 +461,10 @@ func fileputget(h FileWriter, r *Request, pkt requestPacket, alloc *allocator, o
|
||||||
}
|
}
|
||||||
|
|
||||||
// file data for additional read/write packets
|
// file data for additional read/write packets
|
||||||
func packetData(p requestPacket, alloc *allocator, orderID uint32) (data []byte, offset int64, length uint32) {
|
func packetData(p requestPacket, alloc *allocator, orderID uint32, maxTxPacket uint32) (data []byte, offset int64, length uint32) {
|
||||||
switch p := p.(type) {
|
switch p := p.(type) {
|
||||||
case *sshFxpReadPacket:
|
case *sshFxpReadPacket:
|
||||||
return p.getDataSlice(alloc, orderID), int64(p.Offset), p.Len
|
return p.getDataSlice(alloc, orderID, maxTxPacket), int64(p.Offset), p.Len
|
||||||
case *sshFxpWritePacket:
|
case *sshFxpWritePacket:
|
||||||
return p.Data, int64(p.Offset), p.Length
|
return p.Data, int64(p.Offset), p.Length
|
||||||
}
|
}
|
||||||
|
|
|
||||||
171
vendor/github.com/pkg/sftp/server.go
generated
vendored
171
vendor/github.com/pkg/sftp/server.go
generated
vendored
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -21,6 +22,18 @@ const (
|
||||||
SftpServerWorkerCount = 8
|
SftpServerWorkerCount = 8
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type file interface {
|
||||||
|
Stat() (os.FileInfo, error)
|
||||||
|
ReadAt(b []byte, off int64) (int, error)
|
||||||
|
WriteAt(b []byte, off int64) (int, error)
|
||||||
|
Readdir(int) ([]os.FileInfo, error)
|
||||||
|
Name() string
|
||||||
|
Truncate(int64) error
|
||||||
|
Chmod(mode fs.FileMode) error
|
||||||
|
Chown(uid, gid int) error
|
||||||
|
Close() error
|
||||||
|
}
|
||||||
|
|
||||||
// Server is an SSH File Transfer Protocol (sftp) server.
|
// Server is an SSH File Transfer Protocol (sftp) server.
|
||||||
// This is intended to provide the sftp subsystem to an ssh server daemon.
|
// This is intended to provide the sftp subsystem to an ssh server daemon.
|
||||||
// This implementation currently supports most of sftp server protocol version 3,
|
// This implementation currently supports most of sftp server protocol version 3,
|
||||||
|
|
@ -30,13 +43,15 @@ type Server struct {
|
||||||
debugStream io.Writer
|
debugStream io.Writer
|
||||||
readOnly bool
|
readOnly bool
|
||||||
pktMgr *packetManager
|
pktMgr *packetManager
|
||||||
openFiles map[string]*os.File
|
openFiles map[string]file
|
||||||
openFilesLock sync.RWMutex
|
openFilesLock sync.RWMutex
|
||||||
handleCount int
|
handleCount int
|
||||||
workDir string
|
workDir string
|
||||||
|
winRoot bool
|
||||||
|
maxTxPacket uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svr *Server) nextHandle(f *os.File) string {
|
func (svr *Server) nextHandle(f file) string {
|
||||||
svr.openFilesLock.Lock()
|
svr.openFilesLock.Lock()
|
||||||
defer svr.openFilesLock.Unlock()
|
defer svr.openFilesLock.Unlock()
|
||||||
svr.handleCount++
|
svr.handleCount++
|
||||||
|
|
@ -56,7 +71,7 @@ func (svr *Server) closeHandle(handle string) error {
|
||||||
return EBADF
|
return EBADF
|
||||||
}
|
}
|
||||||
|
|
||||||
func (svr *Server) getHandle(handle string) (*os.File, bool) {
|
func (svr *Server) getHandle(handle string) (file, bool) {
|
||||||
svr.openFilesLock.RLock()
|
svr.openFilesLock.RLock()
|
||||||
defer svr.openFilesLock.RUnlock()
|
defer svr.openFilesLock.RUnlock()
|
||||||
f, ok := svr.openFiles[handle]
|
f, ok := svr.openFiles[handle]
|
||||||
|
|
@ -85,7 +100,8 @@ func NewServer(rwc io.ReadWriteCloser, options ...ServerOption) (*Server, error)
|
||||||
serverConn: svrConn,
|
serverConn: svrConn,
|
||||||
debugStream: ioutil.Discard,
|
debugStream: ioutil.Discard,
|
||||||
pktMgr: newPktMgr(svrConn),
|
pktMgr: newPktMgr(svrConn),
|
||||||
openFiles: make(map[string]*os.File),
|
openFiles: make(map[string]file),
|
||||||
|
maxTxPacket: defaultMaxTxPacket,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, o := range options {
|
for _, o := range options {
|
||||||
|
|
@ -116,6 +132,14 @@ func ReadOnly() ServerOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WindowsRootEnumeratesDrives configures a Server to serve a virtual '/' for windows that lists all drives
|
||||||
|
func WindowsRootEnumeratesDrives() ServerOption {
|
||||||
|
return func(s *Server) error {
|
||||||
|
s.winRoot = true
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithAllocator enable the allocator.
|
// WithAllocator enable the allocator.
|
||||||
// After processing a packet we keep in memory the allocated slices
|
// After processing a packet we keep in memory the allocated slices
|
||||||
// and we reuse them for new packets.
|
// and we reuse them for new packets.
|
||||||
|
|
@ -139,6 +163,24 @@ func WithServerWorkingDirectory(workDir string) ServerOption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithMaxTxPacket sets the maximum size of the payload returned to the client,
|
||||||
|
// measured in bytes. The default value is 32768 bytes, and this option
|
||||||
|
// can only be used to increase it. Setting this option to a larger value
|
||||||
|
// should be safe, because the client decides the size of the requested payload.
|
||||||
|
//
|
||||||
|
// The default maximum packet size is 32768 bytes.
|
||||||
|
func WithMaxTxPacket(size uint32) ServerOption {
|
||||||
|
return func(s *Server) error {
|
||||||
|
if size < defaultMaxTxPacket {
|
||||||
|
return errors.New("size must be greater than or equal to 32768")
|
||||||
|
}
|
||||||
|
|
||||||
|
s.maxTxPacket = size
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type rxPacket struct {
|
type rxPacket struct {
|
||||||
pktType fxp
|
pktType fxp
|
||||||
pktBytes []byte
|
pktBytes []byte
|
||||||
|
|
@ -195,7 +237,7 @@ func handlePacket(s *Server, p orderedRequest) error {
|
||||||
}
|
}
|
||||||
case *sshFxpLstatPacket:
|
case *sshFxpLstatPacket:
|
||||||
// stat the requested file
|
// stat the requested file
|
||||||
info, err := os.Lstat(s.toLocalPath(p.Path))
|
info, err := s.lstat(s.toLocalPath(p.Path))
|
||||||
rpkt = &sshFxpStatResponse{
|
rpkt = &sshFxpStatResponse{
|
||||||
ID: p.ID,
|
ID: p.ID,
|
||||||
info: info,
|
info: info,
|
||||||
|
|
@ -269,7 +311,7 @@ func handlePacket(s *Server, p orderedRequest) error {
|
||||||
case *sshFxpOpendirPacket:
|
case *sshFxpOpendirPacket:
|
||||||
lp := s.toLocalPath(p.Path)
|
lp := s.toLocalPath(p.Path)
|
||||||
|
|
||||||
if stat, err := os.Stat(lp); err != nil {
|
if stat, err := s.stat(lp); err != nil {
|
||||||
rpkt = statusFromError(p.ID, err)
|
rpkt = statusFromError(p.ID, err)
|
||||||
} else if !stat.IsDir() {
|
} else if !stat.IsDir() {
|
||||||
rpkt = statusFromError(p.ID, &os.PathError{
|
rpkt = statusFromError(p.ID, &os.PathError{
|
||||||
|
|
@ -287,7 +329,7 @@ func handlePacket(s *Server, p orderedRequest) error {
|
||||||
f, ok := s.getHandle(p.Handle)
|
f, ok := s.getHandle(p.Handle)
|
||||||
if ok {
|
if ok {
|
||||||
err = nil
|
err = nil
|
||||||
data := p.getDataSlice(s.pktMgr.alloc, orderID)
|
data := p.getDataSlice(s.pktMgr.alloc, orderID, s.maxTxPacket)
|
||||||
n, _err := f.ReadAt(data, int64(p.Offset))
|
n, _err := f.ReadAt(data, int64(p.Offset))
|
||||||
if _err != nil && (_err != io.EOF || n == 0) {
|
if _err != nil && (_err != io.EOF || n == 0) {
|
||||||
err = _err
|
err = _err
|
||||||
|
|
@ -348,7 +390,7 @@ func (svr *Server) Serve() error {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var pkt requestPacket
|
var pkt requestPacket
|
||||||
var pktType uint8
|
var pktType fxp
|
||||||
var pktBytes []byte
|
var pktBytes []byte
|
||||||
for {
|
for {
|
||||||
pktType, pktBytes, err = svr.serverConn.recvPacket(svr.pktMgr.getNextOrderID())
|
pktType, pktBytes, err = svr.serverConn.recvPacket(svr.pktMgr.getNextOrderID())
|
||||||
|
|
@ -361,7 +403,7 @@ func (svr *Server) Serve() error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt, err = makePacket(rxPacket{fxp(pktType), pktBytes})
|
pkt, err = makePacket(rxPacket{pktType, pktBytes})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, errUnknownExtendedPacket):
|
case errors.Is(err, errUnknownExtendedPacket):
|
||||||
|
|
@ -462,7 +504,18 @@ func (p *sshFxpOpenPacket) respond(svr *Server) responsePacket {
|
||||||
osFlags |= os.O_EXCL
|
osFlags |= os.O_EXCL
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.OpenFile(svr.toLocalPath(p.Path), osFlags, 0o644)
|
mode := os.FileMode(0o644)
|
||||||
|
// Like OpenSSH, we only handle permissions here, and only when the file is being created.
|
||||||
|
// Otherwise, the permissions are ignored.
|
||||||
|
if p.Flags&sshFileXferAttrPermissions != 0 {
|
||||||
|
fs, err := p.unmarshalFileStat(p.Flags)
|
||||||
|
if err != nil {
|
||||||
|
return statusFromError(p.ID, err)
|
||||||
|
}
|
||||||
|
mode = fs.FileMode() & os.ModePerm
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := svr.openfile(svr.toLocalPath(p.Path), osFlags, mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return statusFromError(p.ID, err)
|
return statusFromError(p.ID, err)
|
||||||
}
|
}
|
||||||
|
|
@ -496,44 +549,23 @@ func (p *sshFxpReaddirPacket) respond(svr *Server) responsePacket {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *sshFxpSetstatPacket) respond(svr *Server) responsePacket {
|
func (p *sshFxpSetstatPacket) respond(svr *Server) responsePacket {
|
||||||
// additional unmarshalling is required for each possibility here
|
path := svr.toLocalPath(p.Path)
|
||||||
b := p.Attrs.([]byte)
|
|
||||||
var err error
|
|
||||||
|
|
||||||
p.Path = svr.toLocalPath(p.Path)
|
debug("setstat name %q", path)
|
||||||
|
|
||||||
debug("setstat name \"%s\"", p.Path)
|
fs, err := p.unmarshalFileStat(p.Flags)
|
||||||
if (p.Flags & sshFileXferAttrSize) != 0 {
|
|
||||||
var size uint64
|
if err == nil && (p.Flags&sshFileXferAttrSize) != 0 {
|
||||||
if size, b, err = unmarshalUint64Safe(b); err == nil {
|
err = os.Truncate(path, int64(fs.Size))
|
||||||
err = os.Truncate(p.Path, int64(size))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (p.Flags & sshFileXferAttrPermissions) != 0 {
|
if err == nil && (p.Flags&sshFileXferAttrPermissions) != 0 {
|
||||||
var mode uint32
|
err = os.Chmod(path, fs.FileMode())
|
||||||
if mode, b, err = unmarshalUint32Safe(b); err == nil {
|
|
||||||
err = os.Chmod(p.Path, os.FileMode(mode))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (p.Flags & sshFileXferAttrACmodTime) != 0 {
|
if err == nil && (p.Flags&sshFileXferAttrUIDGID) != 0 {
|
||||||
var atime uint32
|
err = os.Chown(path, int(fs.UID), int(fs.GID))
|
||||||
var mtime uint32
|
|
||||||
if atime, b, err = unmarshalUint32Safe(b); err != nil {
|
|
||||||
} else if mtime, b, err = unmarshalUint32Safe(b); err != nil {
|
|
||||||
} else {
|
|
||||||
atimeT := time.Unix(int64(atime), 0)
|
|
||||||
mtimeT := time.Unix(int64(mtime), 0)
|
|
||||||
err = os.Chtimes(p.Path, atimeT, mtimeT)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (p.Flags & sshFileXferAttrUIDGID) != 0 {
|
if err == nil && (p.Flags&sshFileXferAttrACmodTime) != 0 {
|
||||||
var uid uint32
|
err = os.Chtimes(path, fs.AccessTime(), fs.ModTime())
|
||||||
var gid uint32
|
|
||||||
if uid, b, err = unmarshalUint32Safe(b); err != nil {
|
|
||||||
} else if gid, _, err = unmarshalUint32Safe(b); err != nil {
|
|
||||||
} else {
|
|
||||||
err = os.Chown(p.Path, int(uid), int(gid))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return statusFromError(p.ID, err)
|
return statusFromError(p.ID, err)
|
||||||
|
|
@ -545,41 +577,32 @@ func (p *sshFxpFsetstatPacket) respond(svr *Server) responsePacket {
|
||||||
return statusFromError(p.ID, EBADF)
|
return statusFromError(p.ID, EBADF)
|
||||||
}
|
}
|
||||||
|
|
||||||
// additional unmarshalling is required for each possibility here
|
path := f.Name()
|
||||||
b := p.Attrs.([]byte)
|
|
||||||
var err error
|
|
||||||
|
|
||||||
debug("fsetstat name \"%s\"", f.Name())
|
debug("fsetstat name %q", path)
|
||||||
if (p.Flags & sshFileXferAttrSize) != 0 {
|
|
||||||
var size uint64
|
fs, err := p.unmarshalFileStat(p.Flags)
|
||||||
if size, b, err = unmarshalUint64Safe(b); err == nil {
|
|
||||||
err = f.Truncate(int64(size))
|
if err == nil && (p.Flags&sshFileXferAttrSize) != 0 {
|
||||||
}
|
err = f.Truncate(int64(fs.Size))
|
||||||
}
|
}
|
||||||
if (p.Flags & sshFileXferAttrPermissions) != 0 {
|
if err == nil && (p.Flags&sshFileXferAttrPermissions) != 0 {
|
||||||
var mode uint32
|
err = f.Chmod(fs.FileMode())
|
||||||
if mode, b, err = unmarshalUint32Safe(b); err == nil {
|
|
||||||
err = f.Chmod(os.FileMode(mode))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (p.Flags & sshFileXferAttrACmodTime) != 0 {
|
if err == nil && (p.Flags&sshFileXferAttrUIDGID) != 0 {
|
||||||
var atime uint32
|
err = f.Chown(int(fs.UID), int(fs.GID))
|
||||||
var mtime uint32
|
|
||||||
if atime, b, err = unmarshalUint32Safe(b); err != nil {
|
|
||||||
} else if mtime, b, err = unmarshalUint32Safe(b); err != nil {
|
|
||||||
} else {
|
|
||||||
atimeT := time.Unix(int64(atime), 0)
|
|
||||||
mtimeT := time.Unix(int64(mtime), 0)
|
|
||||||
err = os.Chtimes(f.Name(), atimeT, mtimeT)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (p.Flags & sshFileXferAttrUIDGID) != 0 {
|
if err == nil && (p.Flags&sshFileXferAttrACmodTime) != 0 {
|
||||||
var uid uint32
|
type chtimer interface {
|
||||||
var gid uint32
|
Chtimes(atime, mtime time.Time) error
|
||||||
if uid, b, err = unmarshalUint32Safe(b); err != nil {
|
}
|
||||||
} else if gid, _, err = unmarshalUint32Safe(b); err != nil {
|
|
||||||
} else {
|
switch f := interface{}(f).(type) {
|
||||||
err = f.Chown(int(uid), int(gid))
|
case chtimer:
|
||||||
|
// future-compatible, for when/if *os.File supports Chtimes.
|
||||||
|
err = f.Chtimes(fs.AccessTime(), fs.ModTime())
|
||||||
|
default:
|
||||||
|
err = os.Chtimes(path, fs.AccessTime(), fs.ModTime())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
21
vendor/github.com/pkg/sftp/server_posix.go
generated
vendored
Normal file
21
vendor/github.com/pkg/sftp/server_posix.go
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
//go:build !windows
|
||||||
|
// +build !windows
|
||||||
|
|
||||||
|
package sftp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/fs"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Server) openfile(path string, flag int, mode fs.FileMode) (file, error) {
|
||||||
|
return os.OpenFile(path, flag, mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) lstat(name string) (os.FileInfo, error) {
|
||||||
|
return os.Lstat(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) stat(name string) (os.FileInfo, error) {
|
||||||
|
return os.Stat(name)
|
||||||
|
}
|
||||||
156
vendor/github.com/pkg/sftp/server_windows.go
generated
vendored
156
vendor/github.com/pkg/sftp/server_windows.go
generated
vendored
|
|
@ -1,8 +1,15 @@
|
||||||
package sftp
|
package sftp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/fs"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Server) toLocalPath(p string) string {
|
func (s *Server) toLocalPath(p string) string {
|
||||||
|
|
@ -12,7 +19,11 @@ func (s *Server) toLocalPath(p string) string {
|
||||||
|
|
||||||
lp := filepath.FromSlash(p)
|
lp := filepath.FromSlash(p)
|
||||||
|
|
||||||
if path.IsAbs(p) {
|
if path.IsAbs(p) { // starts with '/'
|
||||||
|
if len(p) == 1 && s.winRoot {
|
||||||
|
return `\\.\` // for openfile
|
||||||
|
}
|
||||||
|
|
||||||
tmp := lp
|
tmp := lp
|
||||||
for len(tmp) > 0 && tmp[0] == '\\' {
|
for len(tmp) > 0 && tmp[0] == '\\' {
|
||||||
tmp = tmp[1:]
|
tmp = tmp[1:]
|
||||||
|
|
@ -33,7 +44,150 @@ func (s *Server) toLocalPath(p string) string {
|
||||||
// e.g. "/C:" to "C:\\"
|
// e.g. "/C:" to "C:\\"
|
||||||
return tmp
|
return tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s.winRoot {
|
||||||
|
// Make it so that "/Windows" is not found, and "/c:/Windows" has to be used
|
||||||
|
return `\\.\` + tmp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lp
|
return lp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func bitsToDrives(bitmap uint32) []string {
|
||||||
|
var drive rune = 'a'
|
||||||
|
var drives []string
|
||||||
|
|
||||||
|
for bitmap != 0 && drive <= 'z' {
|
||||||
|
if bitmap&1 == 1 {
|
||||||
|
drives = append(drives, string(drive)+":")
|
||||||
|
}
|
||||||
|
drive++
|
||||||
|
bitmap >>= 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return drives
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDrives() ([]string, error) {
|
||||||
|
mask, err := windows.GetLogicalDrives()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("GetLogicalDrives: %w", err)
|
||||||
|
}
|
||||||
|
return bitsToDrives(mask), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type driveInfo struct {
|
||||||
|
fs.FileInfo
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *driveInfo) Name() string {
|
||||||
|
return i.name // since the Name() returned from a os.Stat("C:\\") is "\\"
|
||||||
|
}
|
||||||
|
|
||||||
|
type winRoot struct {
|
||||||
|
drives []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func newWinRoot() (*winRoot, error) {
|
||||||
|
drives, err := getDrives()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &winRoot{
|
||||||
|
drives: drives,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *winRoot) Readdir(n int) ([]os.FileInfo, error) {
|
||||||
|
drives := f.drives
|
||||||
|
if n > 0 && len(drives) > n {
|
||||||
|
drives = drives[:n]
|
||||||
|
}
|
||||||
|
f.drives = f.drives[len(drives):]
|
||||||
|
if len(drives) == 0 {
|
||||||
|
return nil, io.EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
var infos []os.FileInfo
|
||||||
|
for _, drive := range drives {
|
||||||
|
fi, err := os.Stat(drive + `\`)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
di := &driveInfo{
|
||||||
|
FileInfo: fi,
|
||||||
|
name: drive,
|
||||||
|
}
|
||||||
|
infos = append(infos, di)
|
||||||
|
}
|
||||||
|
|
||||||
|
return infos, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *winRoot) Stat() (os.FileInfo, error) {
|
||||||
|
return rootFileInfo, nil
|
||||||
|
}
|
||||||
|
func (f *winRoot) ReadAt(b []byte, off int64) (int, error) {
|
||||||
|
return 0, os.ErrPermission
|
||||||
|
}
|
||||||
|
func (f *winRoot) WriteAt(b []byte, off int64) (int, error) {
|
||||||
|
return 0, os.ErrPermission
|
||||||
|
}
|
||||||
|
func (f *winRoot) Name() string {
|
||||||
|
return "/"
|
||||||
|
}
|
||||||
|
func (f *winRoot) Truncate(int64) error {
|
||||||
|
return os.ErrPermission
|
||||||
|
}
|
||||||
|
func (f *winRoot) Chmod(mode fs.FileMode) error {
|
||||||
|
return os.ErrPermission
|
||||||
|
}
|
||||||
|
func (f *winRoot) Chown(uid, gid int) error {
|
||||||
|
return os.ErrPermission
|
||||||
|
}
|
||||||
|
func (f *winRoot) Close() error {
|
||||||
|
f.drives = nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) openfile(path string, flag int, mode fs.FileMode) (file, error) {
|
||||||
|
if path == `\\.\` && s.winRoot {
|
||||||
|
return newWinRoot()
|
||||||
|
}
|
||||||
|
return os.OpenFile(path, flag, mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
type winRootFileInfo struct {
|
||||||
|
name string
|
||||||
|
modTime time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *winRootFileInfo) Name() string { return w.name }
|
||||||
|
func (w *winRootFileInfo) Size() int64 { return 0 }
|
||||||
|
func (w *winRootFileInfo) Mode() fs.FileMode { return fs.ModeDir | 0555 } // read+execute for all
|
||||||
|
func (w *winRootFileInfo) ModTime() time.Time { return w.modTime }
|
||||||
|
func (w *winRootFileInfo) IsDir() bool { return true }
|
||||||
|
func (w *winRootFileInfo) Sys() interface{} { return nil }
|
||||||
|
|
||||||
|
// Create a new root FileInfo
|
||||||
|
var rootFileInfo = &winRootFileInfo{
|
||||||
|
name: "/",
|
||||||
|
modTime: time.Now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) lstat(name string) (os.FileInfo, error) {
|
||||||
|
if name == `\\.\` && s.winRoot {
|
||||||
|
return rootFileInfo, nil
|
||||||
|
}
|
||||||
|
return os.Lstat(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) stat(name string) (os.FileInfo, error) {
|
||||||
|
if name == `\\.\` && s.winRoot {
|
||||||
|
return rootFileInfo, nil
|
||||||
|
}
|
||||||
|
return os.Stat(name)
|
||||||
|
}
|
||||||
|
|
|
||||||
8
vendor/github.com/pkg/sftp/sftp.go
generated
vendored
8
vendor/github.com/pkg/sftp/sftp.go
generated
vendored
|
|
@ -184,15 +184,15 @@ func (f fx) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
type unexpectedPacketErr struct {
|
type unexpectedPacketErr struct {
|
||||||
want, got uint8
|
want, got fxp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *unexpectedPacketErr) Error() string {
|
func (u *unexpectedPacketErr) Error() string {
|
||||||
return fmt.Sprintf("sftp: unexpected packet: want %v, got %v", fxp(u.want), fxp(u.got))
|
return fmt.Sprintf("sftp: unexpected packet: want %v, got %v", u.want, u.got)
|
||||||
}
|
}
|
||||||
|
|
||||||
func unimplementedPacketErr(u uint8) error {
|
func unimplementedPacketErr(u fxp) error {
|
||||||
return fmt.Errorf("sftp: unimplemented packet type: got %v", fxp(u))
|
return fmt.Errorf("sftp: unimplemented packet type: got %v", u)
|
||||||
}
|
}
|
||||||
|
|
||||||
type unexpectedIDErr struct{ want, got uint32 }
|
type unexpectedIDErr struct{ want, got uint32 }
|
||||||
|
|
|
||||||
94
vendor/github.com/pkg/sftp/stat.go
generated
vendored
Normal file
94
vendor/github.com/pkg/sftp/stat.go
generated
vendored
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
package sftp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
sshfx "github.com/pkg/sftp/internal/encoding/ssh/filexfer"
|
||||||
|
)
|
||||||
|
|
||||||
|
// isRegular returns true if the mode describes a regular file.
|
||||||
|
func isRegular(mode uint32) bool {
|
||||||
|
return sshfx.FileMode(mode)&sshfx.ModeType == sshfx.ModeRegular
|
||||||
|
}
|
||||||
|
|
||||||
|
// toFileMode converts sftp filemode bits to the os.FileMode specification
|
||||||
|
func toFileMode(mode uint32) os.FileMode {
|
||||||
|
var fm = os.FileMode(mode & 0777)
|
||||||
|
|
||||||
|
switch sshfx.FileMode(mode) & sshfx.ModeType {
|
||||||
|
case sshfx.ModeDevice:
|
||||||
|
fm |= os.ModeDevice
|
||||||
|
case sshfx.ModeCharDevice:
|
||||||
|
fm |= os.ModeDevice | os.ModeCharDevice
|
||||||
|
case sshfx.ModeDir:
|
||||||
|
fm |= os.ModeDir
|
||||||
|
case sshfx.ModeNamedPipe:
|
||||||
|
fm |= os.ModeNamedPipe
|
||||||
|
case sshfx.ModeSymlink:
|
||||||
|
fm |= os.ModeSymlink
|
||||||
|
case sshfx.ModeRegular:
|
||||||
|
// nothing to do
|
||||||
|
case sshfx.ModeSocket:
|
||||||
|
fm |= os.ModeSocket
|
||||||
|
}
|
||||||
|
|
||||||
|
if sshfx.FileMode(mode)&sshfx.ModeSetUID != 0 {
|
||||||
|
fm |= os.ModeSetuid
|
||||||
|
}
|
||||||
|
if sshfx.FileMode(mode)&sshfx.ModeSetGID != 0 {
|
||||||
|
fm |= os.ModeSetgid
|
||||||
|
}
|
||||||
|
if sshfx.FileMode(mode)&sshfx.ModeSticky != 0 {
|
||||||
|
fm |= os.ModeSticky
|
||||||
|
}
|
||||||
|
|
||||||
|
return fm
|
||||||
|
}
|
||||||
|
|
||||||
|
// fromFileMode converts from the os.FileMode specification to sftp filemode bits
|
||||||
|
func fromFileMode(mode os.FileMode) uint32 {
|
||||||
|
ret := sshfx.FileMode(mode & os.ModePerm)
|
||||||
|
|
||||||
|
switch mode & os.ModeType {
|
||||||
|
case os.ModeDevice | os.ModeCharDevice:
|
||||||
|
ret |= sshfx.ModeCharDevice
|
||||||
|
case os.ModeDevice:
|
||||||
|
ret |= sshfx.ModeDevice
|
||||||
|
case os.ModeDir:
|
||||||
|
ret |= sshfx.ModeDir
|
||||||
|
case os.ModeNamedPipe:
|
||||||
|
ret |= sshfx.ModeNamedPipe
|
||||||
|
case os.ModeSymlink:
|
||||||
|
ret |= sshfx.ModeSymlink
|
||||||
|
case 0:
|
||||||
|
ret |= sshfx.ModeRegular
|
||||||
|
case os.ModeSocket:
|
||||||
|
ret |= sshfx.ModeSocket
|
||||||
|
}
|
||||||
|
|
||||||
|
if mode&os.ModeSetuid != 0 {
|
||||||
|
ret |= sshfx.ModeSetUID
|
||||||
|
}
|
||||||
|
if mode&os.ModeSetgid != 0 {
|
||||||
|
ret |= sshfx.ModeSetGID
|
||||||
|
}
|
||||||
|
if mode&os.ModeSticky != 0 {
|
||||||
|
ret |= sshfx.ModeSticky
|
||||||
|
}
|
||||||
|
|
||||||
|
return uint32(ret)
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
s_ISUID = uint32(sshfx.ModeSetUID)
|
||||||
|
s_ISGID = uint32(sshfx.ModeSetGID)
|
||||||
|
s_ISVTX = uint32(sshfx.ModeSticky)
|
||||||
|
)
|
||||||
|
|
||||||
|
// S_IFMT is a legacy export, and was brought in to support GOOS environments whose sysconfig.S_IFMT may be different from the value used internally by SFTP standards.
|
||||||
|
// There should be no reason why you need to import it, or use it, but unexporting it could cause code to break in a way that cannot be readily fixed.
|
||||||
|
// As such, we continue to export this value as the value used in the SFTP standard.
|
||||||
|
//
|
||||||
|
// Deprecated: Remove use of this value, and avoid any future use as well.
|
||||||
|
// There is no alternative provided, you should never need to access this value.
|
||||||
|
const S_IFMT = uint32(sshfx.ModeType)
|
||||||
103
vendor/github.com/pkg/sftp/stat_plan9.go
generated
vendored
103
vendor/github.com/pkg/sftp/stat_plan9.go
generated
vendored
|
|
@ -1,103 +0,0 @@
|
||||||
package sftp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
var EBADF = syscall.NewError("fd out of range or not open")
|
|
||||||
|
|
||||||
func wrapPathError(filepath string, err error) error {
|
|
||||||
if errno, ok := err.(syscall.ErrorString); ok {
|
|
||||||
return &os.PathError{Path: filepath, Err: errno}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// translateErrno translates a syscall error number to a SFTP error code.
|
|
||||||
func translateErrno(errno syscall.ErrorString) uint32 {
|
|
||||||
switch errno {
|
|
||||||
case "":
|
|
||||||
return sshFxOk
|
|
||||||
case syscall.ENOENT:
|
|
||||||
return sshFxNoSuchFile
|
|
||||||
case syscall.EPERM:
|
|
||||||
return sshFxPermissionDenied
|
|
||||||
}
|
|
||||||
|
|
||||||
return sshFxFailure
|
|
||||||
}
|
|
||||||
|
|
||||||
func translateSyscallError(err error) (uint32, bool) {
|
|
||||||
switch e := err.(type) {
|
|
||||||
case syscall.ErrorString:
|
|
||||||
return translateErrno(e), true
|
|
||||||
case *os.PathError:
|
|
||||||
debug("statusFromError,pathError: error is %T %#v", e.Err, e.Err)
|
|
||||||
if errno, ok := e.Err.(syscall.ErrorString); ok {
|
|
||||||
return translateErrno(errno), true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
|
|
||||||
// isRegular returns true if the mode describes a regular file.
|
|
||||||
func isRegular(mode uint32) bool {
|
|
||||||
return mode&S_IFMT == syscall.S_IFREG
|
|
||||||
}
|
|
||||||
|
|
||||||
// toFileMode converts sftp filemode bits to the os.FileMode specification
|
|
||||||
func toFileMode(mode uint32) os.FileMode {
|
|
||||||
var fm = os.FileMode(mode & 0777)
|
|
||||||
|
|
||||||
switch mode & S_IFMT {
|
|
||||||
case syscall.S_IFBLK:
|
|
||||||
fm |= os.ModeDevice
|
|
||||||
case syscall.S_IFCHR:
|
|
||||||
fm |= os.ModeDevice | os.ModeCharDevice
|
|
||||||
case syscall.S_IFDIR:
|
|
||||||
fm |= os.ModeDir
|
|
||||||
case syscall.S_IFIFO:
|
|
||||||
fm |= os.ModeNamedPipe
|
|
||||||
case syscall.S_IFLNK:
|
|
||||||
fm |= os.ModeSymlink
|
|
||||||
case syscall.S_IFREG:
|
|
||||||
// nothing to do
|
|
||||||
case syscall.S_IFSOCK:
|
|
||||||
fm |= os.ModeSocket
|
|
||||||
}
|
|
||||||
|
|
||||||
return fm
|
|
||||||
}
|
|
||||||
|
|
||||||
// fromFileMode converts from the os.FileMode specification to sftp filemode bits
|
|
||||||
func fromFileMode(mode os.FileMode) uint32 {
|
|
||||||
ret := uint32(mode & os.ModePerm)
|
|
||||||
|
|
||||||
switch mode & os.ModeType {
|
|
||||||
case os.ModeDevice | os.ModeCharDevice:
|
|
||||||
ret |= syscall.S_IFCHR
|
|
||||||
case os.ModeDevice:
|
|
||||||
ret |= syscall.S_IFBLK
|
|
||||||
case os.ModeDir:
|
|
||||||
ret |= syscall.S_IFDIR
|
|
||||||
case os.ModeNamedPipe:
|
|
||||||
ret |= syscall.S_IFIFO
|
|
||||||
case os.ModeSymlink:
|
|
||||||
ret |= syscall.S_IFLNK
|
|
||||||
case 0:
|
|
||||||
ret |= syscall.S_IFREG
|
|
||||||
case os.ModeSocket:
|
|
||||||
ret |= syscall.S_IFSOCK
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plan 9 doesn't have setuid, setgid or sticky, but a Plan 9 client should
|
|
||||||
// be able to send these bits to a POSIX server.
|
|
||||||
const (
|
|
||||||
s_ISUID = 04000
|
|
||||||
s_ISGID = 02000
|
|
||||||
s_ISVTX = 01000
|
|
||||||
)
|
|
||||||
124
vendor/github.com/pkg/sftp/stat_posix.go
generated
vendored
124
vendor/github.com/pkg/sftp/stat_posix.go
generated
vendored
|
|
@ -1,124 +0,0 @@
|
||||||
//go:build !plan9
|
|
||||||
// +build !plan9
|
|
||||||
|
|
||||||
package sftp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
const EBADF = syscall.EBADF
|
|
||||||
|
|
||||||
func wrapPathError(filepath string, err error) error {
|
|
||||||
if errno, ok := err.(syscall.Errno); ok {
|
|
||||||
return &os.PathError{Path: filepath, Err: errno}
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// translateErrno translates a syscall error number to a SFTP error code.
|
|
||||||
func translateErrno(errno syscall.Errno) uint32 {
|
|
||||||
switch errno {
|
|
||||||
case 0:
|
|
||||||
return sshFxOk
|
|
||||||
case syscall.ENOENT:
|
|
||||||
return sshFxNoSuchFile
|
|
||||||
case syscall.EACCES, syscall.EPERM:
|
|
||||||
return sshFxPermissionDenied
|
|
||||||
}
|
|
||||||
|
|
||||||
return sshFxFailure
|
|
||||||
}
|
|
||||||
|
|
||||||
func translateSyscallError(err error) (uint32, bool) {
|
|
||||||
switch e := err.(type) {
|
|
||||||
case syscall.Errno:
|
|
||||||
return translateErrno(e), true
|
|
||||||
case *os.PathError:
|
|
||||||
debug("statusFromError,pathError: error is %T %#v", e.Err, e.Err)
|
|
||||||
if errno, ok := e.Err.(syscall.Errno); ok {
|
|
||||||
return translateErrno(errno), true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
|
|
||||||
// isRegular returns true if the mode describes a regular file.
|
|
||||||
func isRegular(mode uint32) bool {
|
|
||||||
return mode&S_IFMT == syscall.S_IFREG
|
|
||||||
}
|
|
||||||
|
|
||||||
// toFileMode converts sftp filemode bits to the os.FileMode specification
|
|
||||||
func toFileMode(mode uint32) os.FileMode {
|
|
||||||
var fm = os.FileMode(mode & 0777)
|
|
||||||
|
|
||||||
switch mode & S_IFMT {
|
|
||||||
case syscall.S_IFBLK:
|
|
||||||
fm |= os.ModeDevice
|
|
||||||
case syscall.S_IFCHR:
|
|
||||||
fm |= os.ModeDevice | os.ModeCharDevice
|
|
||||||
case syscall.S_IFDIR:
|
|
||||||
fm |= os.ModeDir
|
|
||||||
case syscall.S_IFIFO:
|
|
||||||
fm |= os.ModeNamedPipe
|
|
||||||
case syscall.S_IFLNK:
|
|
||||||
fm |= os.ModeSymlink
|
|
||||||
case syscall.S_IFREG:
|
|
||||||
// nothing to do
|
|
||||||
case syscall.S_IFSOCK:
|
|
||||||
fm |= os.ModeSocket
|
|
||||||
}
|
|
||||||
|
|
||||||
if mode&syscall.S_ISUID != 0 {
|
|
||||||
fm |= os.ModeSetuid
|
|
||||||
}
|
|
||||||
if mode&syscall.S_ISGID != 0 {
|
|
||||||
fm |= os.ModeSetgid
|
|
||||||
}
|
|
||||||
if mode&syscall.S_ISVTX != 0 {
|
|
||||||
fm |= os.ModeSticky
|
|
||||||
}
|
|
||||||
|
|
||||||
return fm
|
|
||||||
}
|
|
||||||
|
|
||||||
// fromFileMode converts from the os.FileMode specification to sftp filemode bits
|
|
||||||
func fromFileMode(mode os.FileMode) uint32 {
|
|
||||||
ret := uint32(mode & os.ModePerm)
|
|
||||||
|
|
||||||
switch mode & os.ModeType {
|
|
||||||
case os.ModeDevice | os.ModeCharDevice:
|
|
||||||
ret |= syscall.S_IFCHR
|
|
||||||
case os.ModeDevice:
|
|
||||||
ret |= syscall.S_IFBLK
|
|
||||||
case os.ModeDir:
|
|
||||||
ret |= syscall.S_IFDIR
|
|
||||||
case os.ModeNamedPipe:
|
|
||||||
ret |= syscall.S_IFIFO
|
|
||||||
case os.ModeSymlink:
|
|
||||||
ret |= syscall.S_IFLNK
|
|
||||||
case 0:
|
|
||||||
ret |= syscall.S_IFREG
|
|
||||||
case os.ModeSocket:
|
|
||||||
ret |= syscall.S_IFSOCK
|
|
||||||
}
|
|
||||||
|
|
||||||
if mode&os.ModeSetuid != 0 {
|
|
||||||
ret |= syscall.S_ISUID
|
|
||||||
}
|
|
||||||
if mode&os.ModeSetgid != 0 {
|
|
||||||
ret |= syscall.S_ISGID
|
|
||||||
}
|
|
||||||
if mode&os.ModeSticky != 0 {
|
|
||||||
ret |= syscall.S_ISVTX
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
s_ISUID = syscall.S_ISUID
|
|
||||||
s_ISGID = syscall.S_ISGID
|
|
||||||
s_ISVTX = syscall.S_ISVTX
|
|
||||||
)
|
|
||||||
10
vendor/github.com/pkg/sftp/syscall_fixed.go
generated
vendored
10
vendor/github.com/pkg/sftp/syscall_fixed.go
generated
vendored
|
|
@ -1,10 +0,0 @@
|
||||||
//go:build plan9 || windows || (js && wasm)
|
|
||||||
// +build plan9 windows js,wasm
|
|
||||||
|
|
||||||
// Go defines S_IFMT on windows, plan9 and js/wasm as 0x1f000 instead of
|
|
||||||
// 0xf000. None of the the other S_IFxyz values include the "1" (in 0x1f000)
|
|
||||||
// which prevents them from matching the bitmask.
|
|
||||||
|
|
||||||
package sftp
|
|
||||||
|
|
||||||
const S_IFMT = 0xf000
|
|
||||||
10
vendor/github.com/pkg/sftp/syscall_good.go
generated
vendored
10
vendor/github.com/pkg/sftp/syscall_good.go
generated
vendored
|
|
@ -1,10 +0,0 @@
|
||||||
//go:build !plan9 && !windows && (!js || !wasm)
|
|
||||||
// +build !plan9
|
|
||||||
// +build !windows
|
|
||||||
// +build !js !wasm
|
|
||||||
|
|
||||||
package sftp
|
|
||||||
|
|
||||||
import "syscall"
|
|
||||||
|
|
||||||
const S_IFMT = syscall.S_IFMT
|
|
||||||
35
vendor/github.com/stretchr/testify/assert/assertion_compare.go
generated
vendored
35
vendor/github.com/stretchr/testify/assert/assertion_compare.go
generated
vendored
|
|
@ -7,10 +7,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CompareType int
|
// Deprecated: CompareType has only ever been for internal use and has accidentally been published since v1.6.0. Do not use it.
|
||||||
|
type CompareType = compareResult
|
||||||
|
|
||||||
|
type compareResult int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
compareLess CompareType = iota - 1
|
compareLess compareResult = iota - 1
|
||||||
compareEqual
|
compareEqual
|
||||||
compareGreater
|
compareGreater
|
||||||
)
|
)
|
||||||
|
|
@ -39,7 +42,7 @@ var (
|
||||||
bytesType = reflect.TypeOf([]byte{})
|
bytesType = reflect.TypeOf([]byte{})
|
||||||
)
|
)
|
||||||
|
|
||||||
func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
|
func compare(obj1, obj2 interface{}, kind reflect.Kind) (compareResult, bool) {
|
||||||
obj1Value := reflect.ValueOf(obj1)
|
obj1Value := reflect.ValueOf(obj1)
|
||||||
obj2Value := reflect.ValueOf(obj2)
|
obj2Value := reflect.ValueOf(obj2)
|
||||||
|
|
||||||
|
|
@ -325,7 +328,13 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
|
||||||
timeObj2 = obj2Value.Convert(timeType).Interface().(time.Time)
|
timeObj2 = obj2Value.Convert(timeType).Interface().(time.Time)
|
||||||
}
|
}
|
||||||
|
|
||||||
return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64)
|
if timeObj1.Before(timeObj2) {
|
||||||
|
return compareLess, true
|
||||||
|
}
|
||||||
|
if timeObj1.Equal(timeObj2) {
|
||||||
|
return compareEqual, true
|
||||||
|
}
|
||||||
|
return compareGreater, true
|
||||||
}
|
}
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
{
|
{
|
||||||
|
|
@ -345,7 +354,7 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) {
|
||||||
bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte)
|
bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte)
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true
|
return compareResult(bytes.Compare(bytesObj1, bytesObj2)), true
|
||||||
}
|
}
|
||||||
case reflect.Uintptr:
|
case reflect.Uintptr:
|
||||||
{
|
{
|
||||||
|
|
@ -381,7 +390,7 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
return compareTwoValues(t, e1, e2, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
|
return compareTwoValues(t, e1, e2, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GreaterOrEqual asserts that the first element is greater than or equal to the second
|
// GreaterOrEqual asserts that the first element is greater than or equal to the second
|
||||||
|
|
@ -394,7 +403,7 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
return compareTwoValues(t, e1, e2, []CompareType{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
|
return compareTwoValues(t, e1, e2, []compareResult{compareGreater, compareEqual}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Less asserts that the first element is less than the second
|
// Less asserts that the first element is less than the second
|
||||||
|
|
@ -406,7 +415,7 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{})
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
return compareTwoValues(t, e1, e2, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
|
return compareTwoValues(t, e1, e2, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LessOrEqual asserts that the first element is less than or equal to the second
|
// LessOrEqual asserts that the first element is less than or equal to the second
|
||||||
|
|
@ -419,7 +428,7 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
return compareTwoValues(t, e1, e2, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
|
return compareTwoValues(t, e1, e2, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Positive asserts that the specified element is positive
|
// Positive asserts that the specified element is positive
|
||||||
|
|
@ -431,7 +440,7 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
zero := reflect.Zero(reflect.TypeOf(e))
|
zero := reflect.Zero(reflect.TypeOf(e))
|
||||||
return compareTwoValues(t, e, zero.Interface(), []CompareType{compareGreater}, "\"%v\" is not positive", msgAndArgs...)
|
return compareTwoValues(t, e, zero.Interface(), []compareResult{compareGreater}, "\"%v\" is not positive", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Negative asserts that the specified element is negative
|
// Negative asserts that the specified element is negative
|
||||||
|
|
@ -443,10 +452,10 @@ func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
zero := reflect.Zero(reflect.TypeOf(e))
|
zero := reflect.Zero(reflect.TypeOf(e))
|
||||||
return compareTwoValues(t, e, zero.Interface(), []CompareType{compareLess}, "\"%v\" is not negative", msgAndArgs...)
|
return compareTwoValues(t, e, zero.Interface(), []compareResult{compareLess}, "\"%v\" is not negative", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
|
func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
|
|
@ -469,7 +478,7 @@ func compareTwoValues(t TestingT, e1 interface{}, e2 interface{}, allowedCompare
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func containsValue(values []CompareType, value CompareType) bool {
|
func containsValue(values []compareResult, value compareResult) bool {
|
||||||
for _, v := range values {
|
for _, v := range values {
|
||||||
if v == value {
|
if v == value {
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
34
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
34
vendor/github.com/stretchr/testify/assert/assertion_format.go
generated
vendored
|
|
@ -104,8 +104,8 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{},
|
||||||
return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValuesf asserts that two objects are equal or convertible to the same types
|
// EqualValuesf asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
|
// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted")
|
||||||
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
|
@ -186,7 +186,7 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick
|
||||||
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
|
// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
|
func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
|
@ -568,6 +568,23 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a
|
||||||
return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
|
return NotContains(t, s, contains, append([]interface{}{msg}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
|
||||||
|
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
|
||||||
|
// the number of appearances of each of them in both lists should not match.
|
||||||
|
// This is an inverse of ElementsMatch.
|
||||||
|
//
|
||||||
|
// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
|
||||||
|
//
|
||||||
|
// assert.NotElementsMatchf(t, [1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
|
||||||
|
//
|
||||||
|
// assert.NotElementsMatchf(t, [1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
|
||||||
|
func NotElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return NotElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
// a slice or a channel with len == 0.
|
// a slice or a channel with len == 0.
|
||||||
//
|
//
|
||||||
|
|
@ -604,7 +621,16 @@ func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg s
|
||||||
return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
return NotEqualValues(t, expected, actual, append([]interface{}{msg}, args...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotErrorIsf asserts that at none of the errors in err's chain matches target.
|
// NotErrorAsf asserts that none of the errors in err's chain matches target,
|
||||||
|
// but if so, sets target to that error value.
|
||||||
|
func NotErrorAsf(t TestingT, err error, target interface{}, msg string, args ...interface{}) bool {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return NotErrorAs(t, err, target, append([]interface{}{msg}, args...)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotErrorIsf asserts that none of the errors in err's chain matches target.
|
||||||
// This is a wrapper for errors.Is.
|
// This is a wrapper for errors.Is.
|
||||||
func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
|
func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interface{}) bool {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
|
|
|
||||||
68
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
68
vendor/github.com/stretchr/testify/assert/assertion_forward.go
generated
vendored
|
|
@ -186,8 +186,8 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface
|
||||||
return EqualExportedValuesf(a.t, expected, actual, msg, args...)
|
return EqualExportedValuesf(a.t, expected, actual, msg, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertible to the same types
|
// EqualValues asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// a.EqualValues(uint32(123), int32(123))
|
// a.EqualValues(uint32(123), int32(123))
|
||||||
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
@ -197,8 +197,8 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn
|
||||||
return EqualValues(a.t, expected, actual, msgAndArgs...)
|
return EqualValues(a.t, expected, actual, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValuesf asserts that two objects are equal or convertible to the same types
|
// EqualValuesf asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
|
// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted")
|
||||||
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool {
|
||||||
|
|
@ -336,7 +336,7 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti
|
||||||
// a.EventuallyWithT(func(c *assert.CollectT) {
|
// a.EventuallyWithT(func(c *assert.CollectT) {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
|
||||||
if h, ok := a.t.(tHelper); ok {
|
if h, ok := a.t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
|
@ -361,7 +361,7 @@ func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor
|
||||||
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
|
// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
|
func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool {
|
||||||
if h, ok := a.t.(tHelper); ok {
|
if h, ok := a.t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
|
|
@ -1128,6 +1128,40 @@ func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg strin
|
||||||
return NotContainsf(a.t, s, contains, msg, args...)
|
return NotContainsf(a.t, s, contains, msg, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified
|
||||||
|
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
|
||||||
|
// the number of appearances of each of them in both lists should not match.
|
||||||
|
// This is an inverse of ElementsMatch.
|
||||||
|
//
|
||||||
|
// a.NotElementsMatch([1, 1, 2, 3], [1, 1, 2, 3]) -> false
|
||||||
|
//
|
||||||
|
// a.NotElementsMatch([1, 1, 2, 3], [1, 2, 3]) -> true
|
||||||
|
//
|
||||||
|
// a.NotElementsMatch([1, 2, 3], [1, 2, 4]) -> true
|
||||||
|
func (a *Assertions) NotElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return NotElementsMatch(a.t, listA, listB, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotElementsMatchf asserts that the specified listA(array, slice...) is NOT equal to specified
|
||||||
|
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
|
||||||
|
// the number of appearances of each of them in both lists should not match.
|
||||||
|
// This is an inverse of ElementsMatch.
|
||||||
|
//
|
||||||
|
// a.NotElementsMatchf([1, 1, 2, 3], [1, 1, 2, 3], "error message %s", "formatted") -> false
|
||||||
|
//
|
||||||
|
// a.NotElementsMatchf([1, 1, 2, 3], [1, 2, 3], "error message %s", "formatted") -> true
|
||||||
|
//
|
||||||
|
// a.NotElementsMatchf([1, 2, 3], [1, 2, 4], "error message %s", "formatted") -> true
|
||||||
|
func (a *Assertions) NotElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return NotElementsMatchf(a.t, listA, listB, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either
|
||||||
// a slice or a channel with len == 0.
|
// a slice or a channel with len == 0.
|
||||||
//
|
//
|
||||||
|
|
@ -1200,7 +1234,25 @@ func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg str
|
||||||
return NotEqualf(a.t, expected, actual, msg, args...)
|
return NotEqualf(a.t, expected, actual, msg, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotErrorIs asserts that at none of the errors in err's chain matches target.
|
// NotErrorAs asserts that none of the errors in err's chain matches target,
|
||||||
|
// but if so, sets target to that error value.
|
||||||
|
func (a *Assertions) NotErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return NotErrorAs(a.t, err, target, msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotErrorAsf asserts that none of the errors in err's chain matches target,
|
||||||
|
// but if so, sets target to that error value.
|
||||||
|
func (a *Assertions) NotErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool {
|
||||||
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
return NotErrorAsf(a.t, err, target, msg, args...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotErrorIs asserts that none of the errors in err's chain matches target.
|
||||||
// This is a wrapper for errors.Is.
|
// This is a wrapper for errors.Is.
|
||||||
func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
|
func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool {
|
||||||
if h, ok := a.t.(tHelper); ok {
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
|
@ -1209,7 +1261,7 @@ func (a *Assertions) NotErrorIs(err error, target error, msgAndArgs ...interface
|
||||||
return NotErrorIs(a.t, err, target, msgAndArgs...)
|
return NotErrorIs(a.t, err, target, msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotErrorIsf asserts that at none of the errors in err's chain matches target.
|
// NotErrorIsf asserts that none of the errors in err's chain matches target.
|
||||||
// This is a wrapper for errors.Is.
|
// This is a wrapper for errors.Is.
|
||||||
func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool {
|
func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...interface{}) bool {
|
||||||
if h, ok := a.t.(tHelper); ok {
|
if h, ok := a.t.(tHelper); ok {
|
||||||
|
|
|
||||||
10
vendor/github.com/stretchr/testify/assert/assertion_order.go
generated
vendored
10
vendor/github.com/stretchr/testify/assert/assertion_order.go
generated
vendored
|
|
@ -6,7 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// isOrdered checks that collection contains orderable elements.
|
// isOrdered checks that collection contains orderable elements.
|
||||||
func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
|
func isOrdered(t TestingT, object interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
|
||||||
objKind := reflect.TypeOf(object).Kind()
|
objKind := reflect.TypeOf(object).Kind()
|
||||||
if objKind != reflect.Slice && objKind != reflect.Array {
|
if objKind != reflect.Slice && objKind != reflect.Array {
|
||||||
return false
|
return false
|
||||||
|
|
@ -50,7 +50,7 @@ func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareT
|
||||||
// assert.IsIncreasing(t, []float{1, 2})
|
// assert.IsIncreasing(t, []float{1, 2})
|
||||||
// assert.IsIncreasing(t, []string{"a", "b"})
|
// assert.IsIncreasing(t, []string{"a", "b"})
|
||||||
func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return isOrdered(t, object, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
|
return isOrdered(t, object, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNonIncreasing asserts that the collection is not increasing
|
// IsNonIncreasing asserts that the collection is not increasing
|
||||||
|
|
@ -59,7 +59,7 @@ func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) boo
|
||||||
// assert.IsNonIncreasing(t, []float{2, 1})
|
// assert.IsNonIncreasing(t, []float{2, 1})
|
||||||
// assert.IsNonIncreasing(t, []string{"b", "a"})
|
// assert.IsNonIncreasing(t, []string{"b", "a"})
|
||||||
func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return isOrdered(t, object, []CompareType{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
|
return isOrdered(t, object, []compareResult{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsDecreasing asserts that the collection is decreasing
|
// IsDecreasing asserts that the collection is decreasing
|
||||||
|
|
@ -68,7 +68,7 @@ func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{})
|
||||||
// assert.IsDecreasing(t, []float{2, 1})
|
// assert.IsDecreasing(t, []float{2, 1})
|
||||||
// assert.IsDecreasing(t, []string{"b", "a"})
|
// assert.IsDecreasing(t, []string{"b", "a"})
|
||||||
func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return isOrdered(t, object, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
|
return isOrdered(t, object, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNonDecreasing asserts that the collection is not decreasing
|
// IsNonDecreasing asserts that the collection is not decreasing
|
||||||
|
|
@ -77,5 +77,5 @@ func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) boo
|
||||||
// assert.IsNonDecreasing(t, []float{1, 2})
|
// assert.IsNonDecreasing(t, []float{1, 2})
|
||||||
// assert.IsNonDecreasing(t, []string{"a", "b"})
|
// assert.IsNonDecreasing(t, []string{"a", "b"})
|
||||||
func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
|
||||||
return isOrdered(t, object, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
|
return isOrdered(t, object, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
157
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
157
vendor/github.com/stretchr/testify/assert/assertions.go
generated
vendored
|
|
@ -19,7 +19,9 @@ import (
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/pmezard/go-difflib/difflib"
|
"github.com/pmezard/go-difflib/difflib"
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
|
// Wrapper around gopkg.in/yaml.v3
|
||||||
|
"github.com/stretchr/testify/assert/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl"
|
//go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl"
|
||||||
|
|
@ -45,6 +47,10 @@ type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool
|
||||||
// for table driven tests.
|
// for table driven tests.
|
||||||
type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool
|
type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool
|
||||||
|
|
||||||
|
// PanicAssertionFunc is a common function prototype when validating a panic value. Can be useful
|
||||||
|
// for table driven tests.
|
||||||
|
type PanicAssertionFunc = func(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool
|
||||||
|
|
||||||
// Comparison is a custom function that returns true on success and false on failure
|
// Comparison is a custom function that returns true on success and false on failure
|
||||||
type Comparison func() (success bool)
|
type Comparison func() (success bool)
|
||||||
|
|
||||||
|
|
@ -496,7 +502,13 @@ func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) b
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !samePointers(expected, actual) {
|
same, ok := samePointers(expected, actual)
|
||||||
|
if !ok {
|
||||||
|
return Fail(t, "Both arguments must be pointers", msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !same {
|
||||||
|
// both are pointers but not the same type & pointing to the same address
|
||||||
return Fail(t, fmt.Sprintf("Not same: \n"+
|
return Fail(t, fmt.Sprintf("Not same: \n"+
|
||||||
"expected: %p %#v\n"+
|
"expected: %p %#v\n"+
|
||||||
"actual : %p %#v", expected, expected, actual, actual), msgAndArgs...)
|
"actual : %p %#v", expected, expected, actual, actual), msgAndArgs...)
|
||||||
|
|
@ -516,7 +528,13 @@ func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
|
|
||||||
if samePointers(expected, actual) {
|
same, ok := samePointers(expected, actual)
|
||||||
|
if !ok {
|
||||||
|
//fails when the arguments are not pointers
|
||||||
|
return !(Fail(t, "Both arguments must be pointers", msgAndArgs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
if same {
|
||||||
return Fail(t, fmt.Sprintf(
|
return Fail(t, fmt.Sprintf(
|
||||||
"Expected and actual point to the same object: %p %#v",
|
"Expected and actual point to the same object: %p %#v",
|
||||||
expected, expected), msgAndArgs...)
|
expected, expected), msgAndArgs...)
|
||||||
|
|
@ -524,21 +542,23 @@ func NotSame(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// samePointers compares two generic interface objects and returns whether
|
// samePointers checks if two generic interface objects are pointers of the same
|
||||||
// they point to the same object
|
// type pointing to the same object. It returns two values: same indicating if
|
||||||
func samePointers(first, second interface{}) bool {
|
// they are the same type and point to the same object, and ok indicating that
|
||||||
|
// both inputs are pointers.
|
||||||
|
func samePointers(first, second interface{}) (same bool, ok bool) {
|
||||||
firstPtr, secondPtr := reflect.ValueOf(first), reflect.ValueOf(second)
|
firstPtr, secondPtr := reflect.ValueOf(first), reflect.ValueOf(second)
|
||||||
if firstPtr.Kind() != reflect.Ptr || secondPtr.Kind() != reflect.Ptr {
|
if firstPtr.Kind() != reflect.Ptr || secondPtr.Kind() != reflect.Ptr {
|
||||||
return false
|
return false, false //not both are pointers
|
||||||
}
|
}
|
||||||
|
|
||||||
firstType, secondType := reflect.TypeOf(first), reflect.TypeOf(second)
|
firstType, secondType := reflect.TypeOf(first), reflect.TypeOf(second)
|
||||||
if firstType != secondType {
|
if firstType != secondType {
|
||||||
return false
|
return false, true // both are pointers, but of different types
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare pointer addresses
|
// compare pointer addresses
|
||||||
return first == second
|
return first == second, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// formatUnequalValues takes two values of arbitrary types and returns string
|
// formatUnequalValues takes two values of arbitrary types and returns string
|
||||||
|
|
@ -572,8 +592,8 @@ func truncatingFormat(data interface{}) string {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
// EqualValues asserts that two objects are equal or convertible to the same types
|
// EqualValues asserts that two objects are equal or convertible to the larger
|
||||||
// and equal.
|
// type and equal.
|
||||||
//
|
//
|
||||||
// assert.EqualValues(t, uint32(123), int32(123))
|
// assert.EqualValues(t, uint32(123), int32(123))
|
||||||
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
|
@ -615,21 +635,6 @@ func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ..
|
||||||
return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
|
return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if aType.Kind() == reflect.Ptr {
|
|
||||||
aType = aType.Elem()
|
|
||||||
}
|
|
||||||
if bType.Kind() == reflect.Ptr {
|
|
||||||
bType = bType.Elem()
|
|
||||||
}
|
|
||||||
|
|
||||||
if aType.Kind() != reflect.Struct {
|
|
||||||
return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
if bType.Kind() != reflect.Struct {
|
|
||||||
return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
expected = copyExportedFields(expected)
|
expected = copyExportedFields(expected)
|
||||||
actual = copyExportedFields(actual)
|
actual = copyExportedFields(actual)
|
||||||
|
|
||||||
|
|
@ -1170,6 +1175,39 @@ func formatListDiff(listA, listB interface{}, extraA, extraB []interface{}) stri
|
||||||
return msg.String()
|
return msg.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotElementsMatch asserts that the specified listA(array, slice...) is NOT equal to specified
|
||||||
|
// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements,
|
||||||
|
// the number of appearances of each of them in both lists should not match.
|
||||||
|
// This is an inverse of ElementsMatch.
|
||||||
|
//
|
||||||
|
// assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 1, 2, 3]) -> false
|
||||||
|
//
|
||||||
|
// assert.NotElementsMatch(t, [1, 1, 2, 3], [1, 2, 3]) -> true
|
||||||
|
//
|
||||||
|
// assert.NotElementsMatch(t, [1, 2, 3], [1, 2, 4]) -> true
|
||||||
|
func NotElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
if isEmpty(listA) && isEmpty(listB) {
|
||||||
|
return Fail(t, "listA and listB contain the same elements", msgAndArgs)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isList(t, listA, msgAndArgs...) {
|
||||||
|
return Fail(t, "listA is not a list type", msgAndArgs...)
|
||||||
|
}
|
||||||
|
if !isList(t, listB, msgAndArgs...) {
|
||||||
|
return Fail(t, "listB is not a list type", msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
|
extraA, extraB := diffLists(listA, listB)
|
||||||
|
if len(extraA) == 0 && len(extraB) == 0 {
|
||||||
|
return Fail(t, "listA and listB contain the same elements", msgAndArgs)
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// Condition uses a Comparison to assert a complex condition.
|
// Condition uses a Comparison to assert a complex condition.
|
||||||
func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool {
|
func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
|
|
@ -1488,6 +1526,9 @@ func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Fail(t, err.Error(), msgAndArgs...)
|
return Fail(t, err.Error(), msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
if math.IsNaN(actualEpsilon) {
|
||||||
|
return Fail(t, "relative error is NaN", msgAndArgs...)
|
||||||
|
}
|
||||||
if actualEpsilon > epsilon {
|
if actualEpsilon > epsilon {
|
||||||
return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+
|
return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+
|
||||||
" < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...)
|
" < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...)
|
||||||
|
|
@ -1611,7 +1652,6 @@ func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...in
|
||||||
|
|
||||||
// matchRegexp return true if a specified regexp matches a string.
|
// matchRegexp return true if a specified regexp matches a string.
|
||||||
func matchRegexp(rx interface{}, str interface{}) bool {
|
func matchRegexp(rx interface{}, str interface{}) bool {
|
||||||
|
|
||||||
var r *regexp.Regexp
|
var r *regexp.Regexp
|
||||||
if rr, ok := rx.(*regexp.Regexp); ok {
|
if rr, ok := rx.(*regexp.Regexp); ok {
|
||||||
r = rr
|
r = rr
|
||||||
|
|
@ -1619,7 +1659,14 @@ func matchRegexp(rx interface{}, str interface{}) bool {
|
||||||
r = regexp.MustCompile(fmt.Sprint(rx))
|
r = regexp.MustCompile(fmt.Sprint(rx))
|
||||||
}
|
}
|
||||||
|
|
||||||
return (r.FindStringIndex(fmt.Sprint(str)) != nil)
|
switch v := str.(type) {
|
||||||
|
case []byte:
|
||||||
|
return r.Match(v)
|
||||||
|
case string:
|
||||||
|
return r.MatchString(v)
|
||||||
|
default:
|
||||||
|
return r.MatchString(fmt.Sprint(v))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1872,7 +1919,7 @@ var spewConfigStringerEnabled = spew.ConfigState{
|
||||||
MaxDepth: 10,
|
MaxDepth: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
type tHelper interface {
|
type tHelper = interface {
|
||||||
Helper()
|
Helper()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1911,6 +1958,9 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t
|
||||||
|
|
||||||
// CollectT implements the TestingT interface and collects all errors.
|
// CollectT implements the TestingT interface and collects all errors.
|
||||||
type CollectT struct {
|
type CollectT struct {
|
||||||
|
// A slice of errors. Non-nil slice denotes a failure.
|
||||||
|
// If it's non-nil but len(c.errors) == 0, this is also a failure
|
||||||
|
// obtained by direct c.FailNow() call.
|
||||||
errors []error
|
errors []error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1919,9 +1969,10 @@ func (c *CollectT) Errorf(format string, args ...interface{}) {
|
||||||
c.errors = append(c.errors, fmt.Errorf(format, args...))
|
c.errors = append(c.errors, fmt.Errorf(format, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// FailNow panics.
|
// FailNow stops execution by calling runtime.Goexit.
|
||||||
func (*CollectT) FailNow() {
|
func (c *CollectT) FailNow() {
|
||||||
panic("Assertion failed")
|
c.fail()
|
||||||
|
runtime.Goexit()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: That was a method for internal usage that should not have been published. Now just panics.
|
// Deprecated: That was a method for internal usage that should not have been published. Now just panics.
|
||||||
|
|
@ -1934,6 +1985,16 @@ func (*CollectT) Copy(TestingT) {
|
||||||
panic("Copy() is deprecated")
|
panic("Copy() is deprecated")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CollectT) fail() {
|
||||||
|
if !c.failed() {
|
||||||
|
c.errors = []error{} // Make it non-nil to mark a failure.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *CollectT) failed() bool {
|
||||||
|
return c.errors != nil
|
||||||
|
}
|
||||||
|
|
||||||
// EventuallyWithT asserts that given condition will be met in waitFor time,
|
// EventuallyWithT asserts that given condition will be met in waitFor time,
|
||||||
// periodically checking target function each tick. In contrast to Eventually,
|
// periodically checking target function each tick. In contrast to Eventually,
|
||||||
// it supplies a CollectT to the condition function, so that the condition
|
// it supplies a CollectT to the condition function, so that the condition
|
||||||
|
|
@ -1951,14 +2012,14 @@ func (*CollectT) Copy(TestingT) {
|
||||||
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
// assert.EventuallyWithT(t, func(c *assert.CollectT) {
|
||||||
// // add assertions as needed; any assertion failure will fail the current tick
|
// // add assertions as needed; any assertion failure will fail the current tick
|
||||||
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
// assert.True(c, externalValue, "expected 'externalValue' to be true")
|
||||||
// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false")
|
// }, 10*time.Second, 1*time.Second, "external state has not changed to 'true'; still false")
|
||||||
func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
|
func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
h.Helper()
|
h.Helper()
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastFinishedTickErrs []error
|
var lastFinishedTickErrs []error
|
||||||
ch := make(chan []error, 1)
|
ch := make(chan *CollectT, 1)
|
||||||
|
|
||||||
timer := time.NewTimer(waitFor)
|
timer := time.NewTimer(waitFor)
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
|
|
@ -1978,16 +2039,16 @@ func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time
|
||||||
go func() {
|
go func() {
|
||||||
collect := new(CollectT)
|
collect := new(CollectT)
|
||||||
defer func() {
|
defer func() {
|
||||||
ch <- collect.errors
|
ch <- collect
|
||||||
}()
|
}()
|
||||||
condition(collect)
|
condition(collect)
|
||||||
}()
|
}()
|
||||||
case errs := <-ch:
|
case collect := <-ch:
|
||||||
if len(errs) == 0 {
|
if !collect.failed() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Keep the errors from the last ended condition, so that they can be copied to t if timeout is reached.
|
// Keep the errors from the last ended condition, so that they can be copied to t if timeout is reached.
|
||||||
lastFinishedTickErrs = errs
|
lastFinishedTickErrs = collect.errors
|
||||||
tick = ticker.C
|
tick = ticker.C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2049,7 +2110,7 @@ func ErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
|
||||||
), msgAndArgs...)
|
), msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotErrorIs asserts that at none of the errors in err's chain matches target.
|
// NotErrorIs asserts that none of the errors in err's chain matches target.
|
||||||
// This is a wrapper for errors.Is.
|
// This is a wrapper for errors.Is.
|
||||||
func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
|
func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
|
||||||
if h, ok := t.(tHelper); ok {
|
if h, ok := t.(tHelper); ok {
|
||||||
|
|
@ -2090,6 +2151,24 @@ func ErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{
|
||||||
), msgAndArgs...)
|
), msgAndArgs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotErrorAs asserts that none of the errors in err's chain matches target,
|
||||||
|
// but if so, sets target to that error value.
|
||||||
|
func NotErrorAs(t TestingT, err error, target interface{}, msgAndArgs ...interface{}) bool {
|
||||||
|
if h, ok := t.(tHelper); ok {
|
||||||
|
h.Helper()
|
||||||
|
}
|
||||||
|
if !errors.As(err, target) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
chain := buildErrorChainString(err)
|
||||||
|
|
||||||
|
return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+
|
||||||
|
"found: %q\n"+
|
||||||
|
"in chain: %s", target, chain,
|
||||||
|
), msgAndArgs...)
|
||||||
|
}
|
||||||
|
|
||||||
func buildErrorChainString(err error) string {
|
func buildErrorChainString(err error) string {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return ""
|
return ""
|
||||||
|
|
|
||||||
25
vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go
generated
vendored
Normal file
25
vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
//go:build testify_yaml_custom && !testify_yaml_fail && !testify_yaml_default
|
||||||
|
// +build testify_yaml_custom,!testify_yaml_fail,!testify_yaml_default
|
||||||
|
|
||||||
|
// Package yaml is an implementation of YAML functions that calls a pluggable implementation.
|
||||||
|
//
|
||||||
|
// This implementation is selected with the testify_yaml_custom build tag.
|
||||||
|
//
|
||||||
|
// go test -tags testify_yaml_custom
|
||||||
|
//
|
||||||
|
// This implementation can be used at build time to replace the default implementation
|
||||||
|
// to avoid linking with [gopkg.in/yaml.v3].
|
||||||
|
//
|
||||||
|
// In your test package:
|
||||||
|
//
|
||||||
|
// import assertYaml "github.com/stretchr/testify/assert/yaml"
|
||||||
|
//
|
||||||
|
// func init() {
|
||||||
|
// assertYaml.Unmarshal = func (in []byte, out interface{}) error {
|
||||||
|
// // ...
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
package yaml
|
||||||
|
|
||||||
|
var Unmarshal func(in []byte, out interface{}) error
|
||||||
37
vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go
generated
vendored
Normal file
37
vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go
generated
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
//go:build !testify_yaml_fail && !testify_yaml_custom
|
||||||
|
// +build !testify_yaml_fail,!testify_yaml_custom
|
||||||
|
|
||||||
|
// Package yaml is just an indirection to handle YAML deserialization.
|
||||||
|
//
|
||||||
|
// This package is just an indirection that allows the builder to override the
|
||||||
|
// indirection with an alternative implementation of this package that uses
|
||||||
|
// another implementation of YAML deserialization. This allows to not either not
|
||||||
|
// use YAML deserialization at all, or to use another implementation than
|
||||||
|
// [gopkg.in/yaml.v3] (for example for license compatibility reasons, see [PR #1120]).
|
||||||
|
//
|
||||||
|
// Alternative implementations are selected using build tags:
|
||||||
|
//
|
||||||
|
// - testify_yaml_fail: [Unmarshal] always fails with an error
|
||||||
|
// - testify_yaml_custom: [Unmarshal] is a variable. Caller must initialize it
|
||||||
|
// before calling any of [github.com/stretchr/testify/assert.YAMLEq] or
|
||||||
|
// [github.com/stretchr/testify/assert.YAMLEqf].
|
||||||
|
//
|
||||||
|
// Usage:
|
||||||
|
//
|
||||||
|
// go test -tags testify_yaml_fail
|
||||||
|
//
|
||||||
|
// You can check with "go list" which implementation is linked:
|
||||||
|
//
|
||||||
|
// go list -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
|
||||||
|
// go list -tags testify_yaml_fail -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
|
||||||
|
// go list -tags testify_yaml_custom -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
|
||||||
|
//
|
||||||
|
// [PR #1120]: https://github.com/stretchr/testify/pull/1120
|
||||||
|
package yaml
|
||||||
|
|
||||||
|
import goyaml "gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
// Unmarshal is just a wrapper of [gopkg.in/yaml.v3.Unmarshal].
|
||||||
|
func Unmarshal(in []byte, out interface{}) error {
|
||||||
|
return goyaml.Unmarshal(in, out)
|
||||||
|
}
|
||||||
18
vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go
generated
vendored
Normal file
18
vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go
generated
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
//go:build testify_yaml_fail && !testify_yaml_custom && !testify_yaml_default
|
||||||
|
// +build testify_yaml_fail,!testify_yaml_custom,!testify_yaml_default
|
||||||
|
|
||||||
|
// Package yaml is an implementation of YAML functions that always fail.
|
||||||
|
//
|
||||||
|
// This implementation can be used at build time to replace the default implementation
|
||||||
|
// to avoid linking with [gopkg.in/yaml.v3]:
|
||||||
|
//
|
||||||
|
// go test -tags testify_yaml_fail
|
||||||
|
package yaml
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
var errNotImplemented = errors.New("YAML functions are not available (see https://pkg.go.dev/github.com/stretchr/testify/assert/yaml)")
|
||||||
|
|
||||||
|
func Unmarshal([]byte, interface{}) error {
|
||||||
|
return errNotImplemented
|
||||||
|
}
|
||||||
2
vendor/golang.org/x/crypto/chacha20/chacha_noasm.go
generated
vendored
2
vendor/golang.org/x/crypto/chacha20/chacha_noasm.go
generated
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build (!arm64 && !s390x && !ppc64le) || !gc || purego
|
//go:build (!arm64 && !s390x && !ppc64 && !ppc64le) || !gc || purego
|
||||||
|
|
||||||
package chacha20
|
package chacha20
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build gc && !purego
|
//go:build gc && !purego && (ppc64 || ppc64le)
|
||||||
|
|
||||||
package chacha20
|
package chacha20
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
// The differences in this and the original implementation are
|
// The differences in this and the original implementation are
|
||||||
// due to the calling conventions and initialization of constants.
|
// due to the calling conventions and initialization of constants.
|
||||||
|
|
||||||
//go:build gc && !purego
|
//go:build gc && !purego && (ppc64 || ppc64le)
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
|
@ -36,32 +36,68 @@
|
||||||
// for VPERMXOR
|
// for VPERMXOR
|
||||||
#define MASK R18
|
#define MASK R18
|
||||||
|
|
||||||
DATA consts<>+0x00(SB)/8, $0x3320646e61707865
|
DATA consts<>+0x00(SB)/4, $0x61707865
|
||||||
DATA consts<>+0x08(SB)/8, $0x6b20657479622d32
|
DATA consts<>+0x04(SB)/4, $0x3320646e
|
||||||
DATA consts<>+0x10(SB)/8, $0x0000000000000001
|
DATA consts<>+0x08(SB)/4, $0x79622d32
|
||||||
DATA consts<>+0x18(SB)/8, $0x0000000000000000
|
DATA consts<>+0x0c(SB)/4, $0x6b206574
|
||||||
DATA consts<>+0x20(SB)/8, $0x0000000000000004
|
DATA consts<>+0x10(SB)/4, $0x00000001
|
||||||
DATA consts<>+0x28(SB)/8, $0x0000000000000000
|
DATA consts<>+0x14(SB)/4, $0x00000000
|
||||||
DATA consts<>+0x30(SB)/8, $0x0a0b08090e0f0c0d
|
DATA consts<>+0x18(SB)/4, $0x00000000
|
||||||
DATA consts<>+0x38(SB)/8, $0x0203000106070405
|
DATA consts<>+0x1c(SB)/4, $0x00000000
|
||||||
DATA consts<>+0x40(SB)/8, $0x090a0b080d0e0f0c
|
DATA consts<>+0x20(SB)/4, $0x00000004
|
||||||
DATA consts<>+0x48(SB)/8, $0x0102030005060704
|
DATA consts<>+0x24(SB)/4, $0x00000000
|
||||||
DATA consts<>+0x50(SB)/8, $0x6170786561707865
|
DATA consts<>+0x28(SB)/4, $0x00000000
|
||||||
DATA consts<>+0x58(SB)/8, $0x6170786561707865
|
DATA consts<>+0x2c(SB)/4, $0x00000000
|
||||||
DATA consts<>+0x60(SB)/8, $0x3320646e3320646e
|
DATA consts<>+0x30(SB)/4, $0x0e0f0c0d
|
||||||
DATA consts<>+0x68(SB)/8, $0x3320646e3320646e
|
DATA consts<>+0x34(SB)/4, $0x0a0b0809
|
||||||
DATA consts<>+0x70(SB)/8, $0x79622d3279622d32
|
DATA consts<>+0x38(SB)/4, $0x06070405
|
||||||
DATA consts<>+0x78(SB)/8, $0x79622d3279622d32
|
DATA consts<>+0x3c(SB)/4, $0x02030001
|
||||||
DATA consts<>+0x80(SB)/8, $0x6b2065746b206574
|
DATA consts<>+0x40(SB)/4, $0x0d0e0f0c
|
||||||
DATA consts<>+0x88(SB)/8, $0x6b2065746b206574
|
DATA consts<>+0x44(SB)/4, $0x090a0b08
|
||||||
DATA consts<>+0x90(SB)/8, $0x0000000100000000
|
DATA consts<>+0x48(SB)/4, $0x05060704
|
||||||
DATA consts<>+0x98(SB)/8, $0x0000000300000002
|
DATA consts<>+0x4c(SB)/4, $0x01020300
|
||||||
DATA consts<>+0xa0(SB)/8, $0x5566774411223300
|
DATA consts<>+0x50(SB)/4, $0x61707865
|
||||||
DATA consts<>+0xa8(SB)/8, $0xddeeffcc99aabb88
|
DATA consts<>+0x54(SB)/4, $0x61707865
|
||||||
DATA consts<>+0xb0(SB)/8, $0x6677445522330011
|
DATA consts<>+0x58(SB)/4, $0x61707865
|
||||||
DATA consts<>+0xb8(SB)/8, $0xeeffccddaabb8899
|
DATA consts<>+0x5c(SB)/4, $0x61707865
|
||||||
|
DATA consts<>+0x60(SB)/4, $0x3320646e
|
||||||
|
DATA consts<>+0x64(SB)/4, $0x3320646e
|
||||||
|
DATA consts<>+0x68(SB)/4, $0x3320646e
|
||||||
|
DATA consts<>+0x6c(SB)/4, $0x3320646e
|
||||||
|
DATA consts<>+0x70(SB)/4, $0x79622d32
|
||||||
|
DATA consts<>+0x74(SB)/4, $0x79622d32
|
||||||
|
DATA consts<>+0x78(SB)/4, $0x79622d32
|
||||||
|
DATA consts<>+0x7c(SB)/4, $0x79622d32
|
||||||
|
DATA consts<>+0x80(SB)/4, $0x6b206574
|
||||||
|
DATA consts<>+0x84(SB)/4, $0x6b206574
|
||||||
|
DATA consts<>+0x88(SB)/4, $0x6b206574
|
||||||
|
DATA consts<>+0x8c(SB)/4, $0x6b206574
|
||||||
|
DATA consts<>+0x90(SB)/4, $0x00000000
|
||||||
|
DATA consts<>+0x94(SB)/4, $0x00000001
|
||||||
|
DATA consts<>+0x98(SB)/4, $0x00000002
|
||||||
|
DATA consts<>+0x9c(SB)/4, $0x00000003
|
||||||
|
DATA consts<>+0xa0(SB)/4, $0x11223300
|
||||||
|
DATA consts<>+0xa4(SB)/4, $0x55667744
|
||||||
|
DATA consts<>+0xa8(SB)/4, $0x99aabb88
|
||||||
|
DATA consts<>+0xac(SB)/4, $0xddeeffcc
|
||||||
|
DATA consts<>+0xb0(SB)/4, $0x22330011
|
||||||
|
DATA consts<>+0xb4(SB)/4, $0x66774455
|
||||||
|
DATA consts<>+0xb8(SB)/4, $0xaabb8899
|
||||||
|
DATA consts<>+0xbc(SB)/4, $0xeeffccdd
|
||||||
GLOBL consts<>(SB), RODATA, $0xc0
|
GLOBL consts<>(SB), RODATA, $0xc0
|
||||||
|
|
||||||
|
#ifdef GOARCH_ppc64
|
||||||
|
#define BE_XXBRW_INIT() \
|
||||||
|
LVSL (R0)(R0), V24 \
|
||||||
|
VSPLTISB $3, V25 \
|
||||||
|
VXOR V24, V25, V24 \
|
||||||
|
|
||||||
|
#define BE_XXBRW(vr) VPERM vr, vr, V24, vr
|
||||||
|
#else
|
||||||
|
#define BE_XXBRW_INIT()
|
||||||
|
#define BE_XXBRW(vr)
|
||||||
|
#endif
|
||||||
|
|
||||||
//func chaCha20_ctr32_vsx(out, inp *byte, len int, key *[8]uint32, counter *uint32)
|
//func chaCha20_ctr32_vsx(out, inp *byte, len int, key *[8]uint32, counter *uint32)
|
||||||
TEXT ·chaCha20_ctr32_vsx(SB),NOSPLIT,$64-40
|
TEXT ·chaCha20_ctr32_vsx(SB),NOSPLIT,$64-40
|
||||||
MOVD out+0(FP), OUT
|
MOVD out+0(FP), OUT
|
||||||
|
|
@ -94,6 +130,8 @@ TEXT ·chaCha20_ctr32_vsx(SB),NOSPLIT,$64-40
|
||||||
// Clear V27
|
// Clear V27
|
||||||
VXOR V27, V27, V27
|
VXOR V27, V27, V27
|
||||||
|
|
||||||
|
BE_XXBRW_INIT()
|
||||||
|
|
||||||
// V28
|
// V28
|
||||||
LXVW4X (CONSTBASE)(R11), VS60
|
LXVW4X (CONSTBASE)(R11), VS60
|
||||||
|
|
||||||
|
|
@ -299,6 +337,11 @@ loop_vsx:
|
||||||
VADDUWM V8, V18, V8
|
VADDUWM V8, V18, V8
|
||||||
VADDUWM V12, V19, V12
|
VADDUWM V12, V19, V12
|
||||||
|
|
||||||
|
BE_XXBRW(V0)
|
||||||
|
BE_XXBRW(V4)
|
||||||
|
BE_XXBRW(V8)
|
||||||
|
BE_XXBRW(V12)
|
||||||
|
|
||||||
CMPU LEN, $64
|
CMPU LEN, $64
|
||||||
BLT tail_vsx
|
BLT tail_vsx
|
||||||
|
|
||||||
|
|
@ -327,6 +370,11 @@ loop_vsx:
|
||||||
VADDUWM V9, V18, V8
|
VADDUWM V9, V18, V8
|
||||||
VADDUWM V13, V19, V12
|
VADDUWM V13, V19, V12
|
||||||
|
|
||||||
|
BE_XXBRW(V0)
|
||||||
|
BE_XXBRW(V4)
|
||||||
|
BE_XXBRW(V8)
|
||||||
|
BE_XXBRW(V12)
|
||||||
|
|
||||||
CMPU LEN, $64
|
CMPU LEN, $64
|
||||||
BLT tail_vsx
|
BLT tail_vsx
|
||||||
|
|
||||||
|
|
@ -334,8 +382,8 @@ loop_vsx:
|
||||||
LXVW4X (INP)(R8), VS60
|
LXVW4X (INP)(R8), VS60
|
||||||
LXVW4X (INP)(R9), VS61
|
LXVW4X (INP)(R9), VS61
|
||||||
LXVW4X (INP)(R10), VS62
|
LXVW4X (INP)(R10), VS62
|
||||||
VXOR V27, V0, V27
|
|
||||||
|
|
||||||
|
VXOR V27, V0, V27
|
||||||
VXOR V28, V4, V28
|
VXOR V28, V4, V28
|
||||||
VXOR V29, V8, V29
|
VXOR V29, V8, V29
|
||||||
VXOR V30, V12, V30
|
VXOR V30, V12, V30
|
||||||
|
|
@ -354,6 +402,11 @@ loop_vsx:
|
||||||
VADDUWM V10, V18, V8
|
VADDUWM V10, V18, V8
|
||||||
VADDUWM V14, V19, V12
|
VADDUWM V14, V19, V12
|
||||||
|
|
||||||
|
BE_XXBRW(V0)
|
||||||
|
BE_XXBRW(V4)
|
||||||
|
BE_XXBRW(V8)
|
||||||
|
BE_XXBRW(V12)
|
||||||
|
|
||||||
CMPU LEN, $64
|
CMPU LEN, $64
|
||||||
BLT tail_vsx
|
BLT tail_vsx
|
||||||
|
|
||||||
|
|
@ -381,6 +434,11 @@ loop_vsx:
|
||||||
VADDUWM V11, V18, V8
|
VADDUWM V11, V18, V8
|
||||||
VADDUWM V15, V19, V12
|
VADDUWM V15, V19, V12
|
||||||
|
|
||||||
|
BE_XXBRW(V0)
|
||||||
|
BE_XXBRW(V4)
|
||||||
|
BE_XXBRW(V8)
|
||||||
|
BE_XXBRW(V12)
|
||||||
|
|
||||||
CMPU LEN, $64
|
CMPU LEN, $64
|
||||||
BLT tail_vsx
|
BLT tail_vsx
|
||||||
|
|
||||||
|
|
@ -408,9 +466,9 @@ loop_vsx:
|
||||||
|
|
||||||
done_vsx:
|
done_vsx:
|
||||||
// Increment counter by number of 64 byte blocks
|
// Increment counter by number of 64 byte blocks
|
||||||
MOVD (CNT), R14
|
MOVWZ (CNT), R14
|
||||||
ADD BLOCKS, R14
|
ADD BLOCKS, R14
|
||||||
MOVD R14, (CNT)
|
MOVWZ R14, (CNT)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
tail_vsx:
|
tail_vsx:
|
||||||
2
vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go
generated
vendored
2
vendor/golang.org/x/crypto/internal/poly1305/mac_noasm.go
generated
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build (!amd64 && !ppc64le && !s390x) || !gc || purego
|
//go:build (!amd64 && !loong64 && !ppc64le && !ppc64 && !s390x) || !gc || purego
|
||||||
|
|
||||||
package poly1305
|
package poly1305
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build gc && !purego
|
//go:build gc && !purego && (amd64 || loong64 || ppc64 || ppc64le)
|
||||||
|
|
||||||
package poly1305
|
package poly1305
|
||||||
|
|
||||||
123
vendor/golang.org/x/crypto/internal/poly1305/sum_loong64.s
generated
vendored
Normal file
123
vendor/golang.org/x/crypto/internal/poly1305/sum_loong64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
// Copyright 2025 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build gc && !purego
|
||||||
|
|
||||||
|
// func update(state *macState, msg []byte)
|
||||||
|
TEXT ·update(SB), $0-32
|
||||||
|
MOVV state+0(FP), R4
|
||||||
|
MOVV msg_base+8(FP), R5
|
||||||
|
MOVV msg_len+16(FP), R6
|
||||||
|
|
||||||
|
MOVV $0x10, R7
|
||||||
|
|
||||||
|
MOVV (R4), R8 // h0
|
||||||
|
MOVV 8(R4), R9 // h1
|
||||||
|
MOVV 16(R4), R10 // h2
|
||||||
|
MOVV 24(R4), R11 // r0
|
||||||
|
MOVV 32(R4), R12 // r1
|
||||||
|
|
||||||
|
BLT R6, R7, bytes_between_0_and_15
|
||||||
|
|
||||||
|
loop:
|
||||||
|
MOVV (R5), R14 // msg[0:8]
|
||||||
|
MOVV 8(R5), R16 // msg[8:16]
|
||||||
|
ADDV R14, R8, R8 // h0 (x1 + y1 = z1', if z1' < x1 then z1' overflow)
|
||||||
|
ADDV R16, R9, R27
|
||||||
|
SGTU R14, R8, R24 // h0.carry
|
||||||
|
SGTU R9, R27, R28
|
||||||
|
ADDV R27, R24, R9 // h1
|
||||||
|
SGTU R27, R9, R24
|
||||||
|
OR R24, R28, R24 // h1.carry
|
||||||
|
ADDV $0x01, R24, R24
|
||||||
|
ADDV R10, R24, R10 // h2
|
||||||
|
|
||||||
|
ADDV $16, R5, R5 // msg = msg[16:]
|
||||||
|
|
||||||
|
multiply:
|
||||||
|
MULV R8, R11, R14 // h0r0.lo
|
||||||
|
MULHVU R8, R11, R15 // h0r0.hi
|
||||||
|
MULV R9, R11, R13 // h1r0.lo
|
||||||
|
MULHVU R9, R11, R16 // h1r0.hi
|
||||||
|
ADDV R13, R15, R15
|
||||||
|
SGTU R13, R15, R24
|
||||||
|
ADDV R24, R16, R16
|
||||||
|
MULV R10, R11, R25
|
||||||
|
ADDV R16, R25, R25
|
||||||
|
MULV R8, R12, R13 // h0r1.lo
|
||||||
|
MULHVU R8, R12, R16 // h0r1.hi
|
||||||
|
ADDV R13, R15, R15
|
||||||
|
SGTU R13, R15, R24
|
||||||
|
ADDV R24, R16, R16
|
||||||
|
MOVV R16, R8
|
||||||
|
MULV R10, R12, R26 // h2r1
|
||||||
|
MULV R9, R12, R13 // h1r1.lo
|
||||||
|
MULHVU R9, R12, R16 // h1r1.hi
|
||||||
|
ADDV R13, R25, R25
|
||||||
|
ADDV R16, R26, R27
|
||||||
|
SGTU R13, R25, R24
|
||||||
|
ADDV R27, R24, R26
|
||||||
|
ADDV R8, R25, R25
|
||||||
|
SGTU R8, R25, R24
|
||||||
|
ADDV R24, R26, R26
|
||||||
|
AND $3, R25, R10
|
||||||
|
AND $-4, R25, R17
|
||||||
|
ADDV R17, R14, R8
|
||||||
|
ADDV R26, R15, R27
|
||||||
|
SGTU R17, R8, R24
|
||||||
|
SGTU R26, R27, R28
|
||||||
|
ADDV R27, R24, R9
|
||||||
|
SGTU R27, R9, R24
|
||||||
|
OR R24, R28, R24
|
||||||
|
ADDV R24, R10, R10
|
||||||
|
SLLV $62, R26, R27
|
||||||
|
SRLV $2, R25, R28
|
||||||
|
SRLV $2, R26, R26
|
||||||
|
OR R27, R28, R25
|
||||||
|
ADDV R25, R8, R8
|
||||||
|
ADDV R26, R9, R27
|
||||||
|
SGTU R25, R8, R24
|
||||||
|
SGTU R26, R27, R28
|
||||||
|
ADDV R27, R24, R9
|
||||||
|
SGTU R27, R9, R24
|
||||||
|
OR R24, R28, R24
|
||||||
|
ADDV R24, R10, R10
|
||||||
|
|
||||||
|
SUBV $16, R6, R6
|
||||||
|
BGE R6, R7, loop
|
||||||
|
|
||||||
|
bytes_between_0_and_15:
|
||||||
|
BEQ R6, R0, done
|
||||||
|
MOVV $1, R14
|
||||||
|
XOR R15, R15
|
||||||
|
ADDV R6, R5, R5
|
||||||
|
|
||||||
|
flush_buffer:
|
||||||
|
MOVBU -1(R5), R25
|
||||||
|
SRLV $56, R14, R24
|
||||||
|
SLLV $8, R15, R28
|
||||||
|
SLLV $8, R14, R14
|
||||||
|
OR R24, R28, R15
|
||||||
|
XOR R25, R14, R14
|
||||||
|
SUBV $1, R6, R6
|
||||||
|
SUBV $1, R5, R5
|
||||||
|
BNE R6, R0, flush_buffer
|
||||||
|
|
||||||
|
ADDV R14, R8, R8
|
||||||
|
SGTU R14, R8, R24
|
||||||
|
ADDV R15, R9, R27
|
||||||
|
SGTU R15, R27, R28
|
||||||
|
ADDV R27, R24, R9
|
||||||
|
SGTU R27, R9, R24
|
||||||
|
OR R24, R28, R24
|
||||||
|
ADDV R10, R24, R10
|
||||||
|
|
||||||
|
MOVV $16, R6
|
||||||
|
JMP multiply
|
||||||
|
|
||||||
|
done:
|
||||||
|
MOVV R8, (R4)
|
||||||
|
MOVV R9, 8(R4)
|
||||||
|
MOVV R10, 16(R4)
|
||||||
|
RET
|
||||||
47
vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go
generated
vendored
47
vendor/golang.org/x/crypto/internal/poly1305/sum_ppc64le.go
generated
vendored
|
|
@ -1,47 +0,0 @@
|
||||||
// Copyright 2019 The Go Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
//go:build gc && !purego
|
|
||||||
|
|
||||||
package poly1305
|
|
||||||
|
|
||||||
//go:noescape
|
|
||||||
func update(state *macState, msg []byte)
|
|
||||||
|
|
||||||
// mac is a wrapper for macGeneric that redirects calls that would have gone to
|
|
||||||
// updateGeneric to update.
|
|
||||||
//
|
|
||||||
// Its Write and Sum methods are otherwise identical to the macGeneric ones, but
|
|
||||||
// using function pointers would carry a major performance cost.
|
|
||||||
type mac struct{ macGeneric }
|
|
||||||
|
|
||||||
func (h *mac) Write(p []byte) (int, error) {
|
|
||||||
nn := len(p)
|
|
||||||
if h.offset > 0 {
|
|
||||||
n := copy(h.buffer[h.offset:], p)
|
|
||||||
if h.offset+n < TagSize {
|
|
||||||
h.offset += n
|
|
||||||
return nn, nil
|
|
||||||
}
|
|
||||||
p = p[n:]
|
|
||||||
h.offset = 0
|
|
||||||
update(&h.macState, h.buffer[:])
|
|
||||||
}
|
|
||||||
if n := len(p) - (len(p) % TagSize); n > 0 {
|
|
||||||
update(&h.macState, p[:n])
|
|
||||||
p = p[n:]
|
|
||||||
}
|
|
||||||
if len(p) > 0 {
|
|
||||||
h.offset += copy(h.buffer[h.offset:], p)
|
|
||||||
}
|
|
||||||
return nn, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *mac) Sum(out *[16]byte) {
|
|
||||||
state := h.macState
|
|
||||||
if h.offset > 0 {
|
|
||||||
update(&state, h.buffer[:h.offset])
|
|
||||||
}
|
|
||||||
finalize(out, &state.h, &state.s)
|
|
||||||
}
|
|
||||||
|
|
@ -2,15 +2,25 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build gc && !purego
|
//go:build gc && !purego && (ppc64 || ppc64le)
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
// This was ported from the amd64 implementation.
|
// This was ported from the amd64 implementation.
|
||||||
|
|
||||||
|
#ifdef GOARCH_ppc64le
|
||||||
|
#define LE_MOVD MOVD
|
||||||
|
#define LE_MOVWZ MOVWZ
|
||||||
|
#define LE_MOVHZ MOVHZ
|
||||||
|
#else
|
||||||
|
#define LE_MOVD MOVDBR
|
||||||
|
#define LE_MOVWZ MOVWBR
|
||||||
|
#define LE_MOVHZ MOVHBR
|
||||||
|
#endif
|
||||||
|
|
||||||
#define POLY1305_ADD(msg, h0, h1, h2, t0, t1, t2) \
|
#define POLY1305_ADD(msg, h0, h1, h2, t0, t1, t2) \
|
||||||
MOVD (msg), t0; \
|
LE_MOVD (msg)( R0), t0; \
|
||||||
MOVD 8(msg), t1; \
|
LE_MOVD (msg)(R24), t1; \
|
||||||
MOVD $1, t2; \
|
MOVD $1, t2; \
|
||||||
ADDC t0, h0, h0; \
|
ADDC t0, h0, h0; \
|
||||||
ADDE t1, h1, h1; \
|
ADDE t1, h1, h1; \
|
||||||
|
|
@ -50,10 +60,6 @@
|
||||||
ADDE t3, h1, h1; \
|
ADDE t3, h1, h1; \
|
||||||
ADDZE h2
|
ADDZE h2
|
||||||
|
|
||||||
DATA ·poly1305Mask<>+0x00(SB)/8, $0x0FFFFFFC0FFFFFFF
|
|
||||||
DATA ·poly1305Mask<>+0x08(SB)/8, $0x0FFFFFFC0FFFFFFC
|
|
||||||
GLOBL ·poly1305Mask<>(SB), RODATA, $16
|
|
||||||
|
|
||||||
// func update(state *[7]uint64, msg []byte)
|
// func update(state *[7]uint64, msg []byte)
|
||||||
TEXT ·update(SB), $0-32
|
TEXT ·update(SB), $0-32
|
||||||
MOVD state+0(FP), R3
|
MOVD state+0(FP), R3
|
||||||
|
|
@ -66,6 +72,8 @@ TEXT ·update(SB), $0-32
|
||||||
MOVD 24(R3), R11 // r0
|
MOVD 24(R3), R11 // r0
|
||||||
MOVD 32(R3), R12 // r1
|
MOVD 32(R3), R12 // r1
|
||||||
|
|
||||||
|
MOVD $8, R24
|
||||||
|
|
||||||
CMP R5, $16
|
CMP R5, $16
|
||||||
BLT bytes_between_0_and_15
|
BLT bytes_between_0_and_15
|
||||||
|
|
||||||
|
|
@ -94,7 +102,7 @@ flush_buffer:
|
||||||
|
|
||||||
// Greater than 8 -- load the rightmost remaining bytes in msg
|
// Greater than 8 -- load the rightmost remaining bytes in msg
|
||||||
// and put into R17 (h1)
|
// and put into R17 (h1)
|
||||||
MOVD (R4)(R21), R17
|
LE_MOVD (R4)(R21), R17
|
||||||
MOVD $16, R22
|
MOVD $16, R22
|
||||||
|
|
||||||
// Find the offset to those bytes
|
// Find the offset to those bytes
|
||||||
|
|
@ -118,7 +126,7 @@ just1:
|
||||||
BLT less8
|
BLT less8
|
||||||
|
|
||||||
// Exactly 8
|
// Exactly 8
|
||||||
MOVD (R4), R16
|
LE_MOVD (R4), R16
|
||||||
|
|
||||||
CMP R17, $0
|
CMP R17, $0
|
||||||
|
|
||||||
|
|
@ -133,7 +141,7 @@ less8:
|
||||||
MOVD $0, R22 // shift count
|
MOVD $0, R22 // shift count
|
||||||
CMP R5, $4
|
CMP R5, $4
|
||||||
BLT less4
|
BLT less4
|
||||||
MOVWZ (R4), R16
|
LE_MOVWZ (R4), R16
|
||||||
ADD $4, R4
|
ADD $4, R4
|
||||||
ADD $-4, R5
|
ADD $-4, R5
|
||||||
MOVD $32, R22
|
MOVD $32, R22
|
||||||
|
|
@ -141,7 +149,7 @@ less8:
|
||||||
less4:
|
less4:
|
||||||
CMP R5, $2
|
CMP R5, $2
|
||||||
BLT less2
|
BLT less2
|
||||||
MOVHZ (R4), R21
|
LE_MOVHZ (R4), R21
|
||||||
SLD R22, R21, R21
|
SLD R22, R21, R21
|
||||||
OR R16, R21, R16
|
OR R16, R21, R16
|
||||||
ADD $16, R22
|
ADD $16, R22
|
||||||
67
vendor/golang.org/x/crypto/ssh/certs.go
generated
vendored
67
vendor/golang.org/x/crypto/ssh/certs.go
generated
vendored
|
|
@ -20,14 +20,19 @@ import (
|
||||||
// returned by MultiAlgorithmSigner and don't appear in the Signature.Format
|
// returned by MultiAlgorithmSigner and don't appear in the Signature.Format
|
||||||
// field.
|
// field.
|
||||||
const (
|
const (
|
||||||
CertAlgoRSAv01 = "ssh-rsa-cert-v01@openssh.com"
|
CertAlgoRSAv01 = "ssh-rsa-cert-v01@openssh.com"
|
||||||
CertAlgoDSAv01 = "ssh-dss-cert-v01@openssh.com"
|
// Deprecated: DSA is only supported at insecure key sizes, and was removed
|
||||||
CertAlgoECDSA256v01 = "ecdsa-sha2-nistp256-cert-v01@openssh.com"
|
// from major implementations.
|
||||||
CertAlgoECDSA384v01 = "ecdsa-sha2-nistp384-cert-v01@openssh.com"
|
CertAlgoDSAv01 = InsecureCertAlgoDSAv01
|
||||||
CertAlgoECDSA521v01 = "ecdsa-sha2-nistp521-cert-v01@openssh.com"
|
// Deprecated: DSA is only supported at insecure key sizes, and was removed
|
||||||
CertAlgoSKECDSA256v01 = "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com"
|
// from major implementations.
|
||||||
CertAlgoED25519v01 = "ssh-ed25519-cert-v01@openssh.com"
|
InsecureCertAlgoDSAv01 = "ssh-dss-cert-v01@openssh.com"
|
||||||
CertAlgoSKED25519v01 = "sk-ssh-ed25519-cert-v01@openssh.com"
|
CertAlgoECDSA256v01 = "ecdsa-sha2-nistp256-cert-v01@openssh.com"
|
||||||
|
CertAlgoECDSA384v01 = "ecdsa-sha2-nistp384-cert-v01@openssh.com"
|
||||||
|
CertAlgoECDSA521v01 = "ecdsa-sha2-nistp521-cert-v01@openssh.com"
|
||||||
|
CertAlgoSKECDSA256v01 = "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com"
|
||||||
|
CertAlgoED25519v01 = "ssh-ed25519-cert-v01@openssh.com"
|
||||||
|
CertAlgoSKED25519v01 = "sk-ssh-ed25519-cert-v01@openssh.com"
|
||||||
|
|
||||||
// CertAlgoRSASHA256v01 and CertAlgoRSASHA512v01 can't appear as a
|
// CertAlgoRSASHA256v01 and CertAlgoRSASHA512v01 can't appear as a
|
||||||
// Certificate.Type (or PublicKey.Type), but only in
|
// Certificate.Type (or PublicKey.Type), but only in
|
||||||
|
|
@ -228,7 +233,11 @@ func parseCert(in []byte, privAlgo string) (*Certificate, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// The Type() function is intended to return only certificate key types, but
|
||||||
|
// we use certKeyAlgoNames anyway for safety, to match [Certificate.Type].
|
||||||
|
if _, ok := certKeyAlgoNames[k.Type()]; ok {
|
||||||
|
return nil, fmt.Errorf("ssh: the signature key type %q is invalid for certificates", k.Type())
|
||||||
|
}
|
||||||
c.SignatureKey = k
|
c.SignatureKey = k
|
||||||
c.Signature, rest, ok = parseSignatureBody(g.Signature)
|
c.Signature, rest, ok = parseSignatureBody(g.Signature)
|
||||||
if !ok || len(rest) > 0 {
|
if !ok || len(rest) > 0 {
|
||||||
|
|
@ -296,16 +305,13 @@ type CertChecker struct {
|
||||||
SupportedCriticalOptions []string
|
SupportedCriticalOptions []string
|
||||||
|
|
||||||
// IsUserAuthority should return true if the key is recognized as an
|
// IsUserAuthority should return true if the key is recognized as an
|
||||||
// authority for the given user certificate. This allows for
|
// authority for user certificate. This must be set if this CertChecker
|
||||||
// certificates to be signed by other certificates. This must be set
|
// will be checking user certificates.
|
||||||
// if this CertChecker will be checking user certificates.
|
|
||||||
IsUserAuthority func(auth PublicKey) bool
|
IsUserAuthority func(auth PublicKey) bool
|
||||||
|
|
||||||
// IsHostAuthority should report whether the key is recognized as
|
// IsHostAuthority should report whether the key is recognized as
|
||||||
// an authority for this host. This allows for certificates to be
|
// an authority for this host. This must be set if this CertChecker
|
||||||
// signed by other keys, and for those other keys to only be valid
|
// will be checking host certificates.
|
||||||
// signers for particular hostnames. This must be set if this
|
|
||||||
// CertChecker will be checking host certificates.
|
|
||||||
IsHostAuthority func(auth PublicKey, address string) bool
|
IsHostAuthority func(auth PublicKey, address string) bool
|
||||||
|
|
||||||
// Clock is used for verifying time stamps. If nil, time.Now
|
// Clock is used for verifying time stamps. If nil, time.Now
|
||||||
|
|
@ -442,12 +448,19 @@ func (c *CertChecker) CheckCert(principal string, cert *Certificate) error {
|
||||||
// SignCert signs the certificate with an authority, setting the Nonce,
|
// SignCert signs the certificate with an authority, setting the Nonce,
|
||||||
// SignatureKey, and Signature fields. If the authority implements the
|
// SignatureKey, and Signature fields. If the authority implements the
|
||||||
// MultiAlgorithmSigner interface the first algorithm in the list is used. This
|
// MultiAlgorithmSigner interface the first algorithm in the list is used. This
|
||||||
// is useful if you want to sign with a specific algorithm.
|
// is useful if you want to sign with a specific algorithm. As specified in
|
||||||
|
// [SSH-CERTS], Section 2.1.1, authority can't be a [Certificate].
|
||||||
func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {
|
func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {
|
||||||
c.Nonce = make([]byte, 32)
|
c.Nonce = make([]byte, 32)
|
||||||
if _, err := io.ReadFull(rand, c.Nonce); err != nil {
|
if _, err := io.ReadFull(rand, c.Nonce); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// The Type() function is intended to return only certificate key types, but
|
||||||
|
// we use certKeyAlgoNames anyway for safety, to match [Certificate.Type].
|
||||||
|
if _, ok := certKeyAlgoNames[authority.PublicKey().Type()]; ok {
|
||||||
|
return fmt.Errorf("ssh: certificates cannot be used as authority (public key type %q)",
|
||||||
|
authority.PublicKey().Type())
|
||||||
|
}
|
||||||
c.SignatureKey = authority.PublicKey()
|
c.SignatureKey = authority.PublicKey()
|
||||||
|
|
||||||
if v, ok := authority.(MultiAlgorithmSigner); ok {
|
if v, ok := authority.(MultiAlgorithmSigner); ok {
|
||||||
|
|
@ -485,16 +498,16 @@ func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {
|
||||||
//
|
//
|
||||||
// This map must be kept in sync with the one in agent/client.go.
|
// This map must be kept in sync with the one in agent/client.go.
|
||||||
var certKeyAlgoNames = map[string]string{
|
var certKeyAlgoNames = map[string]string{
|
||||||
CertAlgoRSAv01: KeyAlgoRSA,
|
CertAlgoRSAv01: KeyAlgoRSA,
|
||||||
CertAlgoRSASHA256v01: KeyAlgoRSASHA256,
|
CertAlgoRSASHA256v01: KeyAlgoRSASHA256,
|
||||||
CertAlgoRSASHA512v01: KeyAlgoRSASHA512,
|
CertAlgoRSASHA512v01: KeyAlgoRSASHA512,
|
||||||
CertAlgoDSAv01: KeyAlgoDSA,
|
InsecureCertAlgoDSAv01: InsecureKeyAlgoDSA,
|
||||||
CertAlgoECDSA256v01: KeyAlgoECDSA256,
|
CertAlgoECDSA256v01: KeyAlgoECDSA256,
|
||||||
CertAlgoECDSA384v01: KeyAlgoECDSA384,
|
CertAlgoECDSA384v01: KeyAlgoECDSA384,
|
||||||
CertAlgoECDSA521v01: KeyAlgoECDSA521,
|
CertAlgoECDSA521v01: KeyAlgoECDSA521,
|
||||||
CertAlgoSKECDSA256v01: KeyAlgoSKECDSA256,
|
CertAlgoSKECDSA256v01: KeyAlgoSKECDSA256,
|
||||||
CertAlgoED25519v01: KeyAlgoED25519,
|
CertAlgoED25519v01: KeyAlgoED25519,
|
||||||
CertAlgoSKED25519v01: KeyAlgoSKED25519,
|
CertAlgoSKED25519v01: KeyAlgoSKED25519,
|
||||||
}
|
}
|
||||||
|
|
||||||
// underlyingAlgo returns the signature algorithm associated with algo (which is
|
// underlyingAlgo returns the signature algorithm associated with algo (which is
|
||||||
|
|
|
||||||
40
vendor/golang.org/x/crypto/ssh/cipher.go
generated
vendored
40
vendor/golang.org/x/crypto/ssh/cipher.go
generated
vendored
|
|
@ -58,11 +58,11 @@ func newRC4(key, iv []byte) (cipher.Stream, error) {
|
||||||
type cipherMode struct {
|
type cipherMode struct {
|
||||||
keySize int
|
keySize int
|
||||||
ivSize int
|
ivSize int
|
||||||
create func(key, iv []byte, macKey []byte, algs directionAlgorithms) (packetCipher, error)
|
create func(key, iv []byte, macKey []byte, algs DirectionAlgorithms) (packetCipher, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func streamCipherMode(skip int, createFunc func(key, iv []byte) (cipher.Stream, error)) func(key, iv []byte, macKey []byte, algs directionAlgorithms) (packetCipher, error) {
|
func streamCipherMode(skip int, createFunc func(key, iv []byte) (cipher.Stream, error)) func(key, iv []byte, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) {
|
||||||
return func(key, iv, macKey []byte, algs directionAlgorithms) (packetCipher, error) {
|
return func(key, iv, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) {
|
||||||
stream, err := createFunc(key, iv)
|
stream, err := createFunc(key, iv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -98,36 +98,36 @@ func streamCipherMode(skip int, createFunc func(key, iv []byte) (cipher.Stream,
|
||||||
var cipherModes = map[string]*cipherMode{
|
var cipherModes = map[string]*cipherMode{
|
||||||
// Ciphers from RFC 4344, which introduced many CTR-based ciphers. Algorithms
|
// Ciphers from RFC 4344, which introduced many CTR-based ciphers. Algorithms
|
||||||
// are defined in the order specified in the RFC.
|
// are defined in the order specified in the RFC.
|
||||||
"aes128-ctr": {16, aes.BlockSize, streamCipherMode(0, newAESCTR)},
|
CipherAES128CTR: {16, aes.BlockSize, streamCipherMode(0, newAESCTR)},
|
||||||
"aes192-ctr": {24, aes.BlockSize, streamCipherMode(0, newAESCTR)},
|
CipherAES192CTR: {24, aes.BlockSize, streamCipherMode(0, newAESCTR)},
|
||||||
"aes256-ctr": {32, aes.BlockSize, streamCipherMode(0, newAESCTR)},
|
CipherAES256CTR: {32, aes.BlockSize, streamCipherMode(0, newAESCTR)},
|
||||||
|
|
||||||
// Ciphers from RFC 4345, which introduces security-improved arcfour ciphers.
|
// Ciphers from RFC 4345, which introduces security-improved arcfour ciphers.
|
||||||
// They are defined in the order specified in the RFC.
|
// They are defined in the order specified in the RFC.
|
||||||
"arcfour128": {16, 0, streamCipherMode(1536, newRC4)},
|
InsecureCipherRC4128: {16, 0, streamCipherMode(1536, newRC4)},
|
||||||
"arcfour256": {32, 0, streamCipherMode(1536, newRC4)},
|
InsecureCipherRC4256: {32, 0, streamCipherMode(1536, newRC4)},
|
||||||
|
|
||||||
// Cipher defined in RFC 4253, which describes SSH Transport Layer Protocol.
|
// Cipher defined in RFC 4253, which describes SSH Transport Layer Protocol.
|
||||||
// Note that this cipher is not safe, as stated in RFC 4253: "Arcfour (and
|
// Note that this cipher is not safe, as stated in RFC 4253: "Arcfour (and
|
||||||
// RC4) has problems with weak keys, and should be used with caution."
|
// RC4) has problems with weak keys, and should be used with caution."
|
||||||
// RFC 4345 introduces improved versions of Arcfour.
|
// RFC 4345 introduces improved versions of Arcfour.
|
||||||
"arcfour": {16, 0, streamCipherMode(0, newRC4)},
|
InsecureCipherRC4: {16, 0, streamCipherMode(0, newRC4)},
|
||||||
|
|
||||||
// AEAD ciphers
|
// AEAD ciphers
|
||||||
gcm128CipherID: {16, 12, newGCMCipher},
|
CipherAES128GCM: {16, 12, newGCMCipher},
|
||||||
gcm256CipherID: {32, 12, newGCMCipher},
|
CipherAES256GCM: {32, 12, newGCMCipher},
|
||||||
chacha20Poly1305ID: {64, 0, newChaCha20Cipher},
|
CipherChaCha20Poly1305: {64, 0, newChaCha20Cipher},
|
||||||
|
|
||||||
// CBC mode is insecure and so is not included in the default config.
|
// CBC mode is insecure and so is not included in the default config.
|
||||||
// (See https://www.ieee-security.org/TC/SP2013/papers/4977a526.pdf). If absolutely
|
// (See https://www.ieee-security.org/TC/SP2013/papers/4977a526.pdf). If absolutely
|
||||||
// needed, it's possible to specify a custom Config to enable it.
|
// needed, it's possible to specify a custom Config to enable it.
|
||||||
// You should expect that an active attacker can recover plaintext if
|
// You should expect that an active attacker can recover plaintext if
|
||||||
// you do.
|
// you do.
|
||||||
aes128cbcID: {16, aes.BlockSize, newAESCBCCipher},
|
InsecureCipherAES128CBC: {16, aes.BlockSize, newAESCBCCipher},
|
||||||
|
|
||||||
// 3des-cbc is insecure and is not included in the default
|
// 3des-cbc is insecure and is not included in the default
|
||||||
// config.
|
// config.
|
||||||
tripledescbcID: {24, des.BlockSize, newTripleDESCBCCipher},
|
InsecureCipherTripleDESCBC: {24, des.BlockSize, newTripleDESCBCCipher},
|
||||||
}
|
}
|
||||||
|
|
||||||
// prefixLen is the length of the packet prefix that contains the packet length
|
// prefixLen is the length of the packet prefix that contains the packet length
|
||||||
|
|
@ -307,7 +307,7 @@ type gcmCipher struct {
|
||||||
buf []byte
|
buf []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func newGCMCipher(key, iv, unusedMacKey []byte, unusedAlgs directionAlgorithms) (packetCipher, error) {
|
func newGCMCipher(key, iv, unusedMacKey []byte, unusedAlgs DirectionAlgorithms) (packetCipher, error) {
|
||||||
c, err := aes.NewCipher(key)
|
c, err := aes.NewCipher(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -429,7 +429,7 @@ type cbcCipher struct {
|
||||||
oracleCamouflage uint32
|
oracleCamouflage uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCBCCipher(c cipher.Block, key, iv, macKey []byte, algs directionAlgorithms) (packetCipher, error) {
|
func newCBCCipher(c cipher.Block, key, iv, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) {
|
||||||
cbc := &cbcCipher{
|
cbc := &cbcCipher{
|
||||||
mac: macModes[algs.MAC].new(macKey),
|
mac: macModes[algs.MAC].new(macKey),
|
||||||
decrypter: cipher.NewCBCDecrypter(c, iv),
|
decrypter: cipher.NewCBCDecrypter(c, iv),
|
||||||
|
|
@ -443,7 +443,7 @@ func newCBCCipher(c cipher.Block, key, iv, macKey []byte, algs directionAlgorith
|
||||||
return cbc, nil
|
return cbc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAESCBCCipher(key, iv, macKey []byte, algs directionAlgorithms) (packetCipher, error) {
|
func newAESCBCCipher(key, iv, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) {
|
||||||
c, err := aes.NewCipher(key)
|
c, err := aes.NewCipher(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -457,7 +457,7 @@ func newAESCBCCipher(key, iv, macKey []byte, algs directionAlgorithms) (packetCi
|
||||||
return cbc, nil
|
return cbc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTripleDESCBCCipher(key, iv, macKey []byte, algs directionAlgorithms) (packetCipher, error) {
|
func newTripleDESCBCCipher(key, iv, macKey []byte, algs DirectionAlgorithms) (packetCipher, error) {
|
||||||
c, err := des.NewTripleDESCipher(key)
|
c, err := des.NewTripleDESCipher(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -635,8 +635,6 @@ func (c *cbcCipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const chacha20Poly1305ID = "chacha20-poly1305@openssh.com"
|
|
||||||
|
|
||||||
// chacha20Poly1305Cipher implements the chacha20-poly1305@openssh.com
|
// chacha20Poly1305Cipher implements the chacha20-poly1305@openssh.com
|
||||||
// AEAD, which is described here:
|
// AEAD, which is described here:
|
||||||
//
|
//
|
||||||
|
|
@ -650,7 +648,7 @@ type chacha20Poly1305Cipher struct {
|
||||||
buf []byte
|
buf []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func newChaCha20Cipher(key, unusedIV, unusedMACKey []byte, unusedAlgs directionAlgorithms) (packetCipher, error) {
|
func newChaCha20Cipher(key, unusedIV, unusedMACKey []byte, unusedAlgs DirectionAlgorithms) (packetCipher, error) {
|
||||||
if len(key) != 64 {
|
if len(key) != 64 {
|
||||||
panic(len(key))
|
panic(len(key))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
vendor/golang.org/x/crypto/ssh/client.go
generated
vendored
1
vendor/golang.org/x/crypto/ssh/client.go
generated
vendored
|
|
@ -110,6 +110,7 @@ func (c *connection) clientHandshake(dialAddress string, config *ClientConfig) e
|
||||||
}
|
}
|
||||||
|
|
||||||
c.sessionID = c.transport.getSessionID()
|
c.sessionID = c.transport.getSessionID()
|
||||||
|
c.algorithms = c.transport.getAlgorithms()
|
||||||
return c.clientAuthenticate(config)
|
return c.clientAuthenticate(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
vendor/golang.org/x/crypto/ssh/client_auth.go
generated
vendored
7
vendor/golang.org/x/crypto/ssh/client_auth.go
generated
vendored
|
|
@ -289,7 +289,7 @@ func pickSignatureAlgorithm(signer Signer, extensions map[string][]byte) (MultiA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
algo, err := findCommon("public key signature algorithm", keyAlgos, serverAlgos)
|
algo, err := findCommon("public key signature algorithm", keyAlgos, serverAlgos, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If there is no overlap, return the fallback algorithm to support
|
// If there is no overlap, return the fallback algorithm to support
|
||||||
// servers that fail to list all supported algorithms.
|
// servers that fail to list all supported algorithms.
|
||||||
|
|
@ -555,6 +555,7 @@ func (cb KeyboardInteractiveChallenge) auth(session []byte, user string, c packe
|
||||||
}
|
}
|
||||||
|
|
||||||
gotMsgExtInfo := false
|
gotMsgExtInfo := false
|
||||||
|
gotUserAuthInfoRequest := false
|
||||||
for {
|
for {
|
||||||
packet, err := c.readPacket()
|
packet, err := c.readPacket()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -585,6 +586,9 @@ func (cb KeyboardInteractiveChallenge) auth(session []byte, user string, c packe
|
||||||
if msg.PartialSuccess {
|
if msg.PartialSuccess {
|
||||||
return authPartialSuccess, msg.Methods, nil
|
return authPartialSuccess, msg.Methods, nil
|
||||||
}
|
}
|
||||||
|
if !gotUserAuthInfoRequest {
|
||||||
|
return authFailure, msg.Methods, unexpectedMessageError(msgUserAuthInfoRequest, packet[0])
|
||||||
|
}
|
||||||
return authFailure, msg.Methods, nil
|
return authFailure, msg.Methods, nil
|
||||||
case msgUserAuthSuccess:
|
case msgUserAuthSuccess:
|
||||||
return authSuccess, nil, nil
|
return authSuccess, nil, nil
|
||||||
|
|
@ -596,6 +600,7 @@ func (cb KeyboardInteractiveChallenge) auth(session []byte, user string, c packe
|
||||||
if err := Unmarshal(packet, &msg); err != nil {
|
if err := Unmarshal(packet, &msg); err != nil {
|
||||||
return authFailure, nil, err
|
return authFailure, nil, err
|
||||||
}
|
}
|
||||||
|
gotUserAuthInfoRequest = true
|
||||||
|
|
||||||
// Manually unpack the prompt/echo pairs.
|
// Manually unpack the prompt/echo pairs.
|
||||||
rest := msg.Prompts
|
rest := msg.Prompts
|
||||||
|
|
|
||||||
414
vendor/golang.org/x/crypto/ssh/common.go
generated
vendored
414
vendor/golang.org/x/crypto/ssh/common.go
generated
vendored
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
_ "crypto/sha1"
|
_ "crypto/sha1"
|
||||||
|
|
@ -24,69 +25,258 @@ const (
|
||||||
serviceSSH = "ssh-connection"
|
serviceSSH = "ssh-connection"
|
||||||
)
|
)
|
||||||
|
|
||||||
// supportedCiphers lists ciphers we support but might not recommend.
|
// The ciphers currently or previously implemented by this library, to use in
|
||||||
var supportedCiphers = []string{
|
// [Config.Ciphers]. For a list, see the [Algorithms.Ciphers] returned by
|
||||||
"aes128-ctr", "aes192-ctr", "aes256-ctr",
|
// [SupportedAlgorithms] or [InsecureAlgorithms].
|
||||||
"aes128-gcm@openssh.com", gcm256CipherID,
|
const (
|
||||||
chacha20Poly1305ID,
|
CipherAES128GCM = "aes128-gcm@openssh.com"
|
||||||
"arcfour256", "arcfour128", "arcfour",
|
CipherAES256GCM = "aes256-gcm@openssh.com"
|
||||||
aes128cbcID,
|
CipherChaCha20Poly1305 = "chacha20-poly1305@openssh.com"
|
||||||
tripledescbcID,
|
CipherAES128CTR = "aes128-ctr"
|
||||||
|
CipherAES192CTR = "aes192-ctr"
|
||||||
|
CipherAES256CTR = "aes256-ctr"
|
||||||
|
InsecureCipherAES128CBC = "aes128-cbc"
|
||||||
|
InsecureCipherTripleDESCBC = "3des-cbc"
|
||||||
|
InsecureCipherRC4 = "arcfour"
|
||||||
|
InsecureCipherRC4128 = "arcfour128"
|
||||||
|
InsecureCipherRC4256 = "arcfour256"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The key exchanges currently or previously implemented by this library, to use
|
||||||
|
// in [Config.KeyExchanges]. For a list, see the
|
||||||
|
// [Algorithms.KeyExchanges] returned by [SupportedAlgorithms] or
|
||||||
|
// [InsecureAlgorithms].
|
||||||
|
const (
|
||||||
|
InsecureKeyExchangeDH1SHA1 = "diffie-hellman-group1-sha1"
|
||||||
|
InsecureKeyExchangeDH14SHA1 = "diffie-hellman-group14-sha1"
|
||||||
|
KeyExchangeDH14SHA256 = "diffie-hellman-group14-sha256"
|
||||||
|
KeyExchangeDH16SHA512 = "diffie-hellman-group16-sha512"
|
||||||
|
KeyExchangeECDHP256 = "ecdh-sha2-nistp256"
|
||||||
|
KeyExchangeECDHP384 = "ecdh-sha2-nistp384"
|
||||||
|
KeyExchangeECDHP521 = "ecdh-sha2-nistp521"
|
||||||
|
KeyExchangeCurve25519 = "curve25519-sha256"
|
||||||
|
InsecureKeyExchangeDHGEXSHA1 = "diffie-hellman-group-exchange-sha1"
|
||||||
|
KeyExchangeDHGEXSHA256 = "diffie-hellman-group-exchange-sha256"
|
||||||
|
// KeyExchangeMLKEM768X25519 is supported from Go 1.24.
|
||||||
|
KeyExchangeMLKEM768X25519 = "mlkem768x25519-sha256"
|
||||||
|
|
||||||
|
// An alias for KeyExchangeCurve25519SHA256. This kex ID will be added if
|
||||||
|
// KeyExchangeCurve25519SHA256 is requested for backward compatibility with
|
||||||
|
// OpenSSH versions up to 7.2.
|
||||||
|
keyExchangeCurve25519LibSSH = "curve25519-sha256@libssh.org"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The message authentication code (MAC) currently or previously implemented by
|
||||||
|
// this library, to use in [Config.MACs]. For a list, see the
|
||||||
|
// [Algorithms.MACs] returned by [SupportedAlgorithms] or
|
||||||
|
// [InsecureAlgorithms].
|
||||||
|
const (
|
||||||
|
HMACSHA256ETM = "hmac-sha2-256-etm@openssh.com"
|
||||||
|
HMACSHA512ETM = "hmac-sha2-512-etm@openssh.com"
|
||||||
|
HMACSHA256 = "hmac-sha2-256"
|
||||||
|
HMACSHA512 = "hmac-sha2-512"
|
||||||
|
HMACSHA1 = "hmac-sha1"
|
||||||
|
InsecureHMACSHA196 = "hmac-sha1-96"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// supportedKexAlgos specifies key-exchange algorithms implemented by this
|
||||||
|
// package in preference order, excluding those with security issues.
|
||||||
|
supportedKexAlgos = []string{
|
||||||
|
KeyExchangeCurve25519,
|
||||||
|
KeyExchangeECDHP256,
|
||||||
|
KeyExchangeECDHP384,
|
||||||
|
KeyExchangeECDHP521,
|
||||||
|
KeyExchangeDH14SHA256,
|
||||||
|
KeyExchangeDH16SHA512,
|
||||||
|
KeyExchangeDHGEXSHA256,
|
||||||
|
}
|
||||||
|
// defaultKexAlgos specifies the default preference for key-exchange
|
||||||
|
// algorithms in preference order.
|
||||||
|
defaultKexAlgos = []string{
|
||||||
|
KeyExchangeCurve25519,
|
||||||
|
KeyExchangeECDHP256,
|
||||||
|
KeyExchangeECDHP384,
|
||||||
|
KeyExchangeECDHP521,
|
||||||
|
KeyExchangeDH14SHA256,
|
||||||
|
InsecureKeyExchangeDH14SHA1,
|
||||||
|
}
|
||||||
|
// insecureKexAlgos specifies key-exchange algorithms implemented by this
|
||||||
|
// package and which have security issues.
|
||||||
|
insecureKexAlgos = []string{
|
||||||
|
InsecureKeyExchangeDH14SHA1,
|
||||||
|
InsecureKeyExchangeDH1SHA1,
|
||||||
|
InsecureKeyExchangeDHGEXSHA1,
|
||||||
|
}
|
||||||
|
// supportedCiphers specifies cipher algorithms implemented by this package
|
||||||
|
// in preference order, excluding those with security issues.
|
||||||
|
supportedCiphers = []string{
|
||||||
|
CipherAES128GCM,
|
||||||
|
CipherAES256GCM,
|
||||||
|
CipherChaCha20Poly1305,
|
||||||
|
CipherAES128CTR,
|
||||||
|
CipherAES192CTR,
|
||||||
|
CipherAES256CTR,
|
||||||
|
}
|
||||||
|
// defaultCiphers specifies the default preference for ciphers algorithms
|
||||||
|
// in preference order.
|
||||||
|
defaultCiphers = supportedCiphers
|
||||||
|
// insecureCiphers specifies cipher algorithms implemented by this
|
||||||
|
// package and which have security issues.
|
||||||
|
insecureCiphers = []string{
|
||||||
|
InsecureCipherAES128CBC,
|
||||||
|
InsecureCipherTripleDESCBC,
|
||||||
|
InsecureCipherRC4256,
|
||||||
|
InsecureCipherRC4128,
|
||||||
|
InsecureCipherRC4,
|
||||||
|
}
|
||||||
|
// supportedMACs specifies MAC algorithms implemented by this package in
|
||||||
|
// preference order, excluding those with security issues.
|
||||||
|
supportedMACs = []string{
|
||||||
|
HMACSHA256ETM,
|
||||||
|
HMACSHA512ETM,
|
||||||
|
HMACSHA256,
|
||||||
|
HMACSHA512,
|
||||||
|
HMACSHA1,
|
||||||
|
}
|
||||||
|
// defaultMACs specifies the default preference for MAC algorithms in
|
||||||
|
// preference order.
|
||||||
|
defaultMACs = []string{
|
||||||
|
HMACSHA256ETM,
|
||||||
|
HMACSHA512ETM,
|
||||||
|
HMACSHA256,
|
||||||
|
HMACSHA512,
|
||||||
|
HMACSHA1,
|
||||||
|
InsecureHMACSHA196,
|
||||||
|
}
|
||||||
|
// insecureMACs specifies MAC algorithms implemented by this
|
||||||
|
// package and which have security issues.
|
||||||
|
insecureMACs = []string{
|
||||||
|
InsecureHMACSHA196,
|
||||||
|
}
|
||||||
|
// supportedHostKeyAlgos specifies the supported host-key algorithms (i.e.
|
||||||
|
// methods of authenticating servers) implemented by this package in
|
||||||
|
// preference order, excluding those with security issues.
|
||||||
|
supportedHostKeyAlgos = []string{
|
||||||
|
CertAlgoRSASHA256v01,
|
||||||
|
CertAlgoRSASHA512v01,
|
||||||
|
CertAlgoECDSA256v01,
|
||||||
|
CertAlgoECDSA384v01,
|
||||||
|
CertAlgoECDSA521v01,
|
||||||
|
CertAlgoED25519v01,
|
||||||
|
KeyAlgoRSASHA256,
|
||||||
|
KeyAlgoRSASHA512,
|
||||||
|
KeyAlgoECDSA256,
|
||||||
|
KeyAlgoECDSA384,
|
||||||
|
KeyAlgoECDSA521,
|
||||||
|
KeyAlgoED25519,
|
||||||
|
}
|
||||||
|
// defaultHostKeyAlgos specifies the default preference for host-key
|
||||||
|
// algorithms in preference order.
|
||||||
|
defaultHostKeyAlgos = []string{
|
||||||
|
CertAlgoRSASHA256v01,
|
||||||
|
CertAlgoRSASHA512v01,
|
||||||
|
CertAlgoRSAv01,
|
||||||
|
InsecureCertAlgoDSAv01,
|
||||||
|
CertAlgoECDSA256v01,
|
||||||
|
CertAlgoECDSA384v01,
|
||||||
|
CertAlgoECDSA521v01,
|
||||||
|
CertAlgoED25519v01,
|
||||||
|
KeyAlgoECDSA256,
|
||||||
|
KeyAlgoECDSA384,
|
||||||
|
KeyAlgoECDSA521,
|
||||||
|
KeyAlgoRSASHA256,
|
||||||
|
KeyAlgoRSASHA512,
|
||||||
|
KeyAlgoRSA,
|
||||||
|
InsecureKeyAlgoDSA,
|
||||||
|
KeyAlgoED25519,
|
||||||
|
}
|
||||||
|
// insecureHostKeyAlgos specifies host-key algorithms implemented by this
|
||||||
|
// package and which have security issues.
|
||||||
|
insecureHostKeyAlgos = []string{
|
||||||
|
KeyAlgoRSA,
|
||||||
|
InsecureKeyAlgoDSA,
|
||||||
|
CertAlgoRSAv01,
|
||||||
|
InsecureCertAlgoDSAv01,
|
||||||
|
}
|
||||||
|
// supportedPubKeyAuthAlgos specifies the supported client public key
|
||||||
|
// authentication algorithms. Note that this doesn't include certificate
|
||||||
|
// types since those use the underlying algorithm. Order is irrelevant.
|
||||||
|
supportedPubKeyAuthAlgos = []string{
|
||||||
|
KeyAlgoED25519,
|
||||||
|
KeyAlgoSKED25519,
|
||||||
|
KeyAlgoSKECDSA256,
|
||||||
|
KeyAlgoECDSA256,
|
||||||
|
KeyAlgoECDSA384,
|
||||||
|
KeyAlgoECDSA521,
|
||||||
|
KeyAlgoRSASHA256,
|
||||||
|
KeyAlgoRSASHA512,
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaultPubKeyAuthAlgos specifies the preferred client public key
|
||||||
|
// authentication algorithms. This list is sent to the client if it supports
|
||||||
|
// the server-sig-algs extension. Order is irrelevant.
|
||||||
|
defaultPubKeyAuthAlgos = []string{
|
||||||
|
KeyAlgoED25519,
|
||||||
|
KeyAlgoSKED25519,
|
||||||
|
KeyAlgoSKECDSA256,
|
||||||
|
KeyAlgoECDSA256,
|
||||||
|
KeyAlgoECDSA384,
|
||||||
|
KeyAlgoECDSA521,
|
||||||
|
KeyAlgoRSASHA256,
|
||||||
|
KeyAlgoRSASHA512,
|
||||||
|
KeyAlgoRSA,
|
||||||
|
InsecureKeyAlgoDSA,
|
||||||
|
}
|
||||||
|
// insecurePubKeyAuthAlgos specifies client public key authentication
|
||||||
|
// algorithms implemented by this package and which have security issues.
|
||||||
|
insecurePubKeyAuthAlgos = []string{
|
||||||
|
KeyAlgoRSA,
|
||||||
|
InsecureKeyAlgoDSA,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NegotiatedAlgorithms defines algorithms negotiated between client and server.
|
||||||
|
type NegotiatedAlgorithms struct {
|
||||||
|
KeyExchange string
|
||||||
|
HostKey string
|
||||||
|
Read DirectionAlgorithms
|
||||||
|
Write DirectionAlgorithms
|
||||||
}
|
}
|
||||||
|
|
||||||
// preferredCiphers specifies the default preference for ciphers.
|
// Algorithms defines a set of algorithms that can be configured in the client
|
||||||
var preferredCiphers = []string{
|
// or server config for negotiation during a handshake.
|
||||||
"aes128-gcm@openssh.com", gcm256CipherID,
|
type Algorithms struct {
|
||||||
chacha20Poly1305ID,
|
KeyExchanges []string
|
||||||
"aes128-ctr", "aes192-ctr", "aes256-ctr",
|
Ciphers []string
|
||||||
|
MACs []string
|
||||||
|
HostKeys []string
|
||||||
|
PublicKeyAuths []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// supportedKexAlgos specifies the supported key-exchange algorithms in
|
// SupportedAlgorithms returns algorithms currently implemented by this package,
|
||||||
// preference order.
|
// excluding those with security issues, which are returned by
|
||||||
var supportedKexAlgos = []string{
|
// InsecureAlgorithms. The algorithms listed here are in preference order.
|
||||||
kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH,
|
func SupportedAlgorithms() Algorithms {
|
||||||
// P384 and P521 are not constant-time yet, but since we don't
|
return Algorithms{
|
||||||
// reuse ephemeral keys, using them for ECDH should be OK.
|
Ciphers: slices.Clone(supportedCiphers),
|
||||||
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
|
MACs: slices.Clone(supportedMACs),
|
||||||
kexAlgoDH14SHA256, kexAlgoDH16SHA512, kexAlgoDH14SHA1,
|
KeyExchanges: slices.Clone(supportedKexAlgos),
|
||||||
kexAlgoDH1SHA1,
|
HostKeys: slices.Clone(supportedHostKeyAlgos),
|
||||||
|
PublicKeyAuths: slices.Clone(supportedPubKeyAuthAlgos),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// serverForbiddenKexAlgos contains key exchange algorithms, that are forbidden
|
// InsecureAlgorithms returns algorithms currently implemented by this package
|
||||||
// for the server half.
|
// and which have security issues.
|
||||||
var serverForbiddenKexAlgos = map[string]struct{}{
|
func InsecureAlgorithms() Algorithms {
|
||||||
kexAlgoDHGEXSHA1: {}, // server half implementation is only minimal to satisfy the automated tests
|
return Algorithms{
|
||||||
kexAlgoDHGEXSHA256: {}, // server half implementation is only minimal to satisfy the automated tests
|
KeyExchanges: slices.Clone(insecureKexAlgos),
|
||||||
}
|
Ciphers: slices.Clone(insecureCiphers),
|
||||||
|
MACs: slices.Clone(insecureMACs),
|
||||||
// preferredKexAlgos specifies the default preference for key-exchange
|
HostKeys: slices.Clone(insecureHostKeyAlgos),
|
||||||
// algorithms in preference order. The diffie-hellman-group16-sha512 algorithm
|
PublicKeyAuths: slices.Clone(insecurePubKeyAuthAlgos),
|
||||||
// is disabled by default because it is a bit slower than the others.
|
}
|
||||||
var preferredKexAlgos = []string{
|
|
||||||
kexAlgoCurve25519SHA256, kexAlgoCurve25519SHA256LibSSH,
|
|
||||||
kexAlgoECDH256, kexAlgoECDH384, kexAlgoECDH521,
|
|
||||||
kexAlgoDH14SHA256, kexAlgoDH14SHA1,
|
|
||||||
}
|
|
||||||
|
|
||||||
// supportedHostKeyAlgos specifies the supported host-key algorithms (i.e. methods
|
|
||||||
// of authenticating servers) in preference order.
|
|
||||||
var supportedHostKeyAlgos = []string{
|
|
||||||
CertAlgoRSASHA256v01, CertAlgoRSASHA512v01,
|
|
||||||
CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01,
|
|
||||||
CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoED25519v01,
|
|
||||||
|
|
||||||
KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521,
|
|
||||||
KeyAlgoRSASHA256, KeyAlgoRSASHA512,
|
|
||||||
KeyAlgoRSA, KeyAlgoDSA,
|
|
||||||
|
|
||||||
KeyAlgoED25519,
|
|
||||||
}
|
|
||||||
|
|
||||||
// supportedMACs specifies a default set of MAC algorithms in preference order.
|
|
||||||
// This is based on RFC 4253, section 6.4, but with hmac-md5 variants removed
|
|
||||||
// because they have reached the end of their useful life.
|
|
||||||
var supportedMACs = []string{
|
|
||||||
"hmac-sha2-256-etm@openssh.com", "hmac-sha2-512-etm@openssh.com", "hmac-sha2-256", "hmac-sha2-512", "hmac-sha1", "hmac-sha1-96",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportedCompressions = []string{compressionNone}
|
var supportedCompressions = []string{compressionNone}
|
||||||
|
|
@ -94,13 +284,13 @@ var supportedCompressions = []string{compressionNone}
|
||||||
// hashFuncs keeps the mapping of supported signature algorithms to their
|
// hashFuncs keeps the mapping of supported signature algorithms to their
|
||||||
// respective hashes needed for signing and verification.
|
// respective hashes needed for signing and verification.
|
||||||
var hashFuncs = map[string]crypto.Hash{
|
var hashFuncs = map[string]crypto.Hash{
|
||||||
KeyAlgoRSA: crypto.SHA1,
|
KeyAlgoRSA: crypto.SHA1,
|
||||||
KeyAlgoRSASHA256: crypto.SHA256,
|
KeyAlgoRSASHA256: crypto.SHA256,
|
||||||
KeyAlgoRSASHA512: crypto.SHA512,
|
KeyAlgoRSASHA512: crypto.SHA512,
|
||||||
KeyAlgoDSA: crypto.SHA1,
|
InsecureKeyAlgoDSA: crypto.SHA1,
|
||||||
KeyAlgoECDSA256: crypto.SHA256,
|
KeyAlgoECDSA256: crypto.SHA256,
|
||||||
KeyAlgoECDSA384: crypto.SHA384,
|
KeyAlgoECDSA384: crypto.SHA384,
|
||||||
KeyAlgoECDSA521: crypto.SHA512,
|
KeyAlgoECDSA521: crypto.SHA512,
|
||||||
// KeyAlgoED25519 doesn't pre-hash.
|
// KeyAlgoED25519 doesn't pre-hash.
|
||||||
KeyAlgoSKECDSA256: crypto.SHA256,
|
KeyAlgoSKECDSA256: crypto.SHA256,
|
||||||
KeyAlgoSKED25519: crypto.SHA256,
|
KeyAlgoSKED25519: crypto.SHA256,
|
||||||
|
|
@ -135,18 +325,6 @@ func isRSACert(algo string) bool {
|
||||||
return isRSA(algo)
|
return isRSA(algo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// supportedPubKeyAuthAlgos specifies the supported client public key
|
|
||||||
// authentication algorithms. Note that this doesn't include certificate types
|
|
||||||
// since those use the underlying algorithm. This list is sent to the client if
|
|
||||||
// it supports the server-sig-algs extension. Order is irrelevant.
|
|
||||||
var supportedPubKeyAuthAlgos = []string{
|
|
||||||
KeyAlgoED25519,
|
|
||||||
KeyAlgoSKED25519, KeyAlgoSKECDSA256,
|
|
||||||
KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521,
|
|
||||||
KeyAlgoRSASHA256, KeyAlgoRSASHA512, KeyAlgoRSA,
|
|
||||||
KeyAlgoDSA,
|
|
||||||
}
|
|
||||||
|
|
||||||
// unexpectedMessageError results when the SSH message that we received didn't
|
// unexpectedMessageError results when the SSH message that we received didn't
|
||||||
// match what we wanted.
|
// match what we wanted.
|
||||||
func unexpectedMessageError(expected, got uint8) error {
|
func unexpectedMessageError(expected, got uint8) error {
|
||||||
|
|
@ -158,7 +336,7 @@ func parseError(tag uint8) error {
|
||||||
return fmt.Errorf("ssh: parse error in message type %d", tag)
|
return fmt.Errorf("ssh: parse error in message type %d", tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func findCommon(what string, client []string, server []string) (common string, err error) {
|
func findCommon(what string, client []string, server []string, isClient bool) (string, error) {
|
||||||
for _, c := range client {
|
for _, c := range client {
|
||||||
for _, s := range server {
|
for _, s := range server {
|
||||||
if c == s {
|
if c == s {
|
||||||
|
|
@ -166,23 +344,49 @@ func findCommon(what string, client []string, server []string) (common string, e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("ssh: no common algorithm for %s; client offered: %v, server offered: %v", what, client, server)
|
err := &AlgorithmNegotiationError{
|
||||||
|
What: what,
|
||||||
|
}
|
||||||
|
if isClient {
|
||||||
|
err.SupportedAlgorithms = client
|
||||||
|
err.RequestedAlgorithms = server
|
||||||
|
} else {
|
||||||
|
err.SupportedAlgorithms = server
|
||||||
|
err.RequestedAlgorithms = client
|
||||||
|
}
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// directionAlgorithms records algorithm choices in one direction (either read or write)
|
// AlgorithmNegotiationError defines the error returned if the client and the
|
||||||
type directionAlgorithms struct {
|
// server cannot agree on an algorithm for key exchange, host key, cipher, MAC.
|
||||||
|
type AlgorithmNegotiationError struct {
|
||||||
|
What string
|
||||||
|
// RequestedAlgorithms lists the algorithms supported by the peer.
|
||||||
|
RequestedAlgorithms []string
|
||||||
|
// SupportedAlgorithms lists the algorithms supported on our side.
|
||||||
|
SupportedAlgorithms []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AlgorithmNegotiationError) Error() string {
|
||||||
|
return fmt.Sprintf("ssh: no common algorithm for %s; we offered: %v, peer offered: %v",
|
||||||
|
a.What, a.SupportedAlgorithms, a.RequestedAlgorithms)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DirectionAlgorithms defines the algorithms negotiated in one direction
|
||||||
|
// (either read or write).
|
||||||
|
type DirectionAlgorithms struct {
|
||||||
Cipher string
|
Cipher string
|
||||||
MAC string
|
MAC string
|
||||||
Compression string
|
compression string
|
||||||
}
|
}
|
||||||
|
|
||||||
// rekeyBytes returns a rekeying intervals in bytes.
|
// rekeyBytes returns a rekeying intervals in bytes.
|
||||||
func (a *directionAlgorithms) rekeyBytes() int64 {
|
func (a *DirectionAlgorithms) rekeyBytes() int64 {
|
||||||
// According to RFC 4344 block ciphers should rekey after
|
// According to RFC 4344 block ciphers should rekey after
|
||||||
// 2^(BLOCKSIZE/4) blocks. For all AES flavors BLOCKSIZE is
|
// 2^(BLOCKSIZE/4) blocks. For all AES flavors BLOCKSIZE is
|
||||||
// 128.
|
// 128.
|
||||||
switch a.Cipher {
|
switch a.Cipher {
|
||||||
case "aes128-ctr", "aes192-ctr", "aes256-ctr", gcm128CipherID, gcm256CipherID, aes128cbcID:
|
case CipherAES128CTR, CipherAES192CTR, CipherAES256CTR, CipherAES128GCM, CipherAES256GCM, InsecureCipherAES128CBC:
|
||||||
return 16 * (1 << 32)
|
return 16 * (1 << 32)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -192,66 +396,59 @@ func (a *directionAlgorithms) rekeyBytes() int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
var aeadCiphers = map[string]bool{
|
var aeadCiphers = map[string]bool{
|
||||||
gcm128CipherID: true,
|
CipherAES128GCM: true,
|
||||||
gcm256CipherID: true,
|
CipherAES256GCM: true,
|
||||||
chacha20Poly1305ID: true,
|
CipherChaCha20Poly1305: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
type algorithms struct {
|
func findAgreedAlgorithms(isClient bool, clientKexInit, serverKexInit *kexInitMsg) (algs *NegotiatedAlgorithms, err error) {
|
||||||
kex string
|
result := &NegotiatedAlgorithms{}
|
||||||
hostKey string
|
|
||||||
w directionAlgorithms
|
|
||||||
r directionAlgorithms
|
|
||||||
}
|
|
||||||
|
|
||||||
func findAgreedAlgorithms(isClient bool, clientKexInit, serverKexInit *kexInitMsg) (algs *algorithms, err error) {
|
result.KeyExchange, err = findCommon("key exchange", clientKexInit.KexAlgos, serverKexInit.KexAlgos, isClient)
|
||||||
result := &algorithms{}
|
|
||||||
|
|
||||||
result.kex, err = findCommon("key exchange", clientKexInit.KexAlgos, serverKexInit.KexAlgos)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
result.hostKey, err = findCommon("host key", clientKexInit.ServerHostKeyAlgos, serverKexInit.ServerHostKeyAlgos)
|
result.HostKey, err = findCommon("host key", clientKexInit.ServerHostKeyAlgos, serverKexInit.ServerHostKeyAlgos, isClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stoc, ctos := &result.w, &result.r
|
stoc, ctos := &result.Write, &result.Read
|
||||||
if isClient {
|
if isClient {
|
||||||
ctos, stoc = stoc, ctos
|
ctos, stoc = stoc, ctos
|
||||||
}
|
}
|
||||||
|
|
||||||
ctos.Cipher, err = findCommon("client to server cipher", clientKexInit.CiphersClientServer, serverKexInit.CiphersClientServer)
|
ctos.Cipher, err = findCommon("client to server cipher", clientKexInit.CiphersClientServer, serverKexInit.CiphersClientServer, isClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stoc.Cipher, err = findCommon("server to client cipher", clientKexInit.CiphersServerClient, serverKexInit.CiphersServerClient)
|
stoc.Cipher, err = findCommon("server to client cipher", clientKexInit.CiphersServerClient, serverKexInit.CiphersServerClient, isClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !aeadCiphers[ctos.Cipher] {
|
if !aeadCiphers[ctos.Cipher] {
|
||||||
ctos.MAC, err = findCommon("client to server MAC", clientKexInit.MACsClientServer, serverKexInit.MACsClientServer)
|
ctos.MAC, err = findCommon("client to server MAC", clientKexInit.MACsClientServer, serverKexInit.MACsClientServer, isClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !aeadCiphers[stoc.Cipher] {
|
if !aeadCiphers[stoc.Cipher] {
|
||||||
stoc.MAC, err = findCommon("server to client MAC", clientKexInit.MACsServerClient, serverKexInit.MACsServerClient)
|
stoc.MAC, err = findCommon("server to client MAC", clientKexInit.MACsServerClient, serverKexInit.MACsServerClient, isClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctos.Compression, err = findCommon("client to server compression", clientKexInit.CompressionClientServer, serverKexInit.CompressionClientServer)
|
ctos.compression, err = findCommon("client to server compression", clientKexInit.CompressionClientServer, serverKexInit.CompressionClientServer, isClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
stoc.Compression, err = findCommon("server to client compression", clientKexInit.CompressionServerClient, serverKexInit.CompressionServerClient)
|
stoc.compression, err = findCommon("server to client compression", clientKexInit.CompressionServerClient, serverKexInit.CompressionServerClient, isClient)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +494,7 @@ func (c *Config) SetDefaults() {
|
||||||
c.Rand = rand.Reader
|
c.Rand = rand.Reader
|
||||||
}
|
}
|
||||||
if c.Ciphers == nil {
|
if c.Ciphers == nil {
|
||||||
c.Ciphers = preferredCiphers
|
c.Ciphers = defaultCiphers
|
||||||
}
|
}
|
||||||
var ciphers []string
|
var ciphers []string
|
||||||
for _, c := range c.Ciphers {
|
for _, c := range c.Ciphers {
|
||||||
|
|
@ -309,19 +506,22 @@ func (c *Config) SetDefaults() {
|
||||||
c.Ciphers = ciphers
|
c.Ciphers = ciphers
|
||||||
|
|
||||||
if c.KeyExchanges == nil {
|
if c.KeyExchanges == nil {
|
||||||
c.KeyExchanges = preferredKexAlgos
|
c.KeyExchanges = defaultKexAlgos
|
||||||
}
|
}
|
||||||
var kexs []string
|
var kexs []string
|
||||||
for _, k := range c.KeyExchanges {
|
for _, k := range c.KeyExchanges {
|
||||||
if kexAlgoMap[k] != nil {
|
if kexAlgoMap[k] != nil {
|
||||||
// Ignore the KEX if we have no kexAlgoMap definition.
|
// Ignore the KEX if we have no kexAlgoMap definition.
|
||||||
kexs = append(kexs, k)
|
kexs = append(kexs, k)
|
||||||
|
if k == KeyExchangeCurve25519 && !contains(c.KeyExchanges, keyExchangeCurve25519LibSSH) {
|
||||||
|
kexs = append(kexs, keyExchangeCurve25519LibSSH)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.KeyExchanges = kexs
|
c.KeyExchanges = kexs
|
||||||
|
|
||||||
if c.MACs == nil {
|
if c.MACs == nil {
|
||||||
c.MACs = supportedMACs
|
c.MACs = defaultMACs
|
||||||
}
|
}
|
||||||
var macs []string
|
var macs []string
|
||||||
for _, m := range c.MACs {
|
for _, m := range c.MACs {
|
||||||
|
|
|
||||||
12
vendor/golang.org/x/crypto/ssh/connection.go
generated
vendored
12
vendor/golang.org/x/crypto/ssh/connection.go
generated
vendored
|
|
@ -74,6 +74,13 @@ type Conn interface {
|
||||||
// Disconnect
|
// Disconnect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AlgorithmsConnMetadata is a ConnMetadata that can return the algorithms
|
||||||
|
// negotiated between client and server.
|
||||||
|
type AlgorithmsConnMetadata interface {
|
||||||
|
ConnMetadata
|
||||||
|
Algorithms() NegotiatedAlgorithms
|
||||||
|
}
|
||||||
|
|
||||||
// DiscardRequests consumes and rejects all requests from the
|
// DiscardRequests consumes and rejects all requests from the
|
||||||
// passed-in channel.
|
// passed-in channel.
|
||||||
func DiscardRequests(in <-chan *Request) {
|
func DiscardRequests(in <-chan *Request) {
|
||||||
|
|
@ -106,6 +113,7 @@ type sshConn struct {
|
||||||
sessionID []byte
|
sessionID []byte
|
||||||
clientVersion []byte
|
clientVersion []byte
|
||||||
serverVersion []byte
|
serverVersion []byte
|
||||||
|
algorithms NegotiatedAlgorithms
|
||||||
}
|
}
|
||||||
|
|
||||||
func dup(src []byte) []byte {
|
func dup(src []byte) []byte {
|
||||||
|
|
@ -141,3 +149,7 @@ func (c *sshConn) ClientVersion() []byte {
|
||||||
func (c *sshConn) ServerVersion() []byte {
|
func (c *sshConn) ServerVersion() []byte {
|
||||||
return dup(c.serverVersion)
|
return dup(c.serverVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *sshConn) Algorithms() NegotiatedAlgorithms {
|
||||||
|
return c.algorithms
|
||||||
|
}
|
||||||
|
|
|
||||||
1
vendor/golang.org/x/crypto/ssh/doc.go
generated
vendored
1
vendor/golang.org/x/crypto/ssh/doc.go
generated
vendored
|
|
@ -16,6 +16,7 @@ References:
|
||||||
[PROTOCOL]: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL?rev=HEAD
|
[PROTOCOL]: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL?rev=HEAD
|
||||||
[PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD
|
[PROTOCOL.certkeys]: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys?rev=HEAD
|
||||||
[SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1
|
[SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1
|
||||||
|
[SSH-CERTS]: https://datatracker.ietf.org/doc/html/draft-miller-ssh-cert-01
|
||||||
|
|
||||||
This package does not fall under the stability promise of the Go language itself,
|
This package does not fall under the stability promise of the Go language itself,
|
||||||
so its API may be changed when pressing needs arise.
|
so its API may be changed when pressing needs arise.
|
||||||
|
|
|
||||||
88
vendor/golang.org/x/crypto/ssh/handshake.go
generated
vendored
88
vendor/golang.org/x/crypto/ssh/handshake.go
generated
vendored
|
|
@ -5,7 +5,6 @@
|
||||||
package ssh
|
package ssh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -25,6 +24,11 @@ const debugHandshake = false
|
||||||
// quickly.
|
// quickly.
|
||||||
const chanSize = 16
|
const chanSize = 16
|
||||||
|
|
||||||
|
// maxPendingPackets sets the maximum number of packets to queue while waiting
|
||||||
|
// for KEX to complete. This limits the total pending data to maxPendingPackets
|
||||||
|
// * maxPacket bytes, which is ~16.8MB.
|
||||||
|
const maxPendingPackets = 64
|
||||||
|
|
||||||
// keyingTransport is a packet based transport that supports key
|
// keyingTransport is a packet based transport that supports key
|
||||||
// changes. It need not be thread-safe. It should pass through
|
// changes. It need not be thread-safe. It should pass through
|
||||||
// msgNewKeys in both directions.
|
// msgNewKeys in both directions.
|
||||||
|
|
@ -34,7 +38,7 @@ type keyingTransport interface {
|
||||||
// prepareKeyChange sets up a key change. The key change for a
|
// prepareKeyChange sets up a key change. The key change for a
|
||||||
// direction will be effected if a msgNewKeys message is sent
|
// direction will be effected if a msgNewKeys message is sent
|
||||||
// or received.
|
// or received.
|
||||||
prepareKeyChange(*algorithms, *kexResult) error
|
prepareKeyChange(*NegotiatedAlgorithms, *kexResult) error
|
||||||
|
|
||||||
// setStrictMode sets the strict KEX mode, notably triggering
|
// setStrictMode sets the strict KEX mode, notably triggering
|
||||||
// sequence number resets on sending or receiving msgNewKeys.
|
// sequence number resets on sending or receiving msgNewKeys.
|
||||||
|
|
@ -73,13 +77,22 @@ type handshakeTransport struct {
|
||||||
incoming chan []byte
|
incoming chan []byte
|
||||||
readError error
|
readError error
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
writeError error
|
// Condition for the above mutex. It is used to notify a completed key
|
||||||
sentInitPacket []byte
|
// exchange or a write failure. Writes can wait for this condition while a
|
||||||
sentInitMsg *kexInitMsg
|
// key exchange is in progress.
|
||||||
pendingPackets [][]byte // Used when a key exchange is in progress.
|
writeCond *sync.Cond
|
||||||
|
writeError error
|
||||||
|
sentInitPacket []byte
|
||||||
|
sentInitMsg *kexInitMsg
|
||||||
|
// Used to queue writes when a key exchange is in progress. The length is
|
||||||
|
// limited by pendingPacketsSize. Once full, writes will block until the key
|
||||||
|
// exchange is completed or an error occurs. If not empty, it is emptied
|
||||||
|
// all at once when the key exchange is completed in kexLoop.
|
||||||
|
pendingPackets [][]byte
|
||||||
writePacketsLeft uint32
|
writePacketsLeft uint32
|
||||||
writeBytesLeft int64
|
writeBytesLeft int64
|
||||||
|
userAuthComplete bool // whether the user authentication phase is complete
|
||||||
|
|
||||||
// If the read loop wants to schedule a kex, it pings this
|
// If the read loop wants to schedule a kex, it pings this
|
||||||
// channel, and the write loop will send out a kex
|
// channel, and the write loop will send out a kex
|
||||||
|
|
@ -102,7 +115,7 @@ type handshakeTransport struct {
|
||||||
bannerCallback BannerCallback
|
bannerCallback BannerCallback
|
||||||
|
|
||||||
// Algorithms agreed in the last key exchange.
|
// Algorithms agreed in the last key exchange.
|
||||||
algorithms *algorithms
|
algorithms *NegotiatedAlgorithms
|
||||||
|
|
||||||
// Counters exclusively owned by readLoop.
|
// Counters exclusively owned by readLoop.
|
||||||
readPacketsLeft uint32
|
readPacketsLeft uint32
|
||||||
|
|
@ -133,6 +146,7 @@ func newHandshakeTransport(conn keyingTransport, config *Config, clientVersion,
|
||||||
|
|
||||||
config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
|
t.writeCond = sync.NewCond(&t.mu)
|
||||||
t.resetReadThresholds()
|
t.resetReadThresholds()
|
||||||
t.resetWriteThresholds()
|
t.resetWriteThresholds()
|
||||||
|
|
||||||
|
|
@ -150,7 +164,7 @@ func newClientTransport(conn keyingTransport, clientVersion, serverVersion []byt
|
||||||
if config.HostKeyAlgorithms != nil {
|
if config.HostKeyAlgorithms != nil {
|
||||||
t.hostKeyAlgorithms = config.HostKeyAlgorithms
|
t.hostKeyAlgorithms = config.HostKeyAlgorithms
|
||||||
} else {
|
} else {
|
||||||
t.hostKeyAlgorithms = supportedHostKeyAlgos
|
t.hostKeyAlgorithms = defaultHostKeyAlgos
|
||||||
}
|
}
|
||||||
go t.readLoop()
|
go t.readLoop()
|
||||||
go t.kexLoop()
|
go t.kexLoop()
|
||||||
|
|
@ -170,6 +184,10 @@ func (t *handshakeTransport) getSessionID() []byte {
|
||||||
return t.sessionID
|
return t.sessionID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *handshakeTransport) getAlgorithms() NegotiatedAlgorithms {
|
||||||
|
return *t.algorithms
|
||||||
|
}
|
||||||
|
|
||||||
// waitSession waits for the session to be established. This should be
|
// waitSession waits for the session to be established. This should be
|
||||||
// the first thing to call after instantiating handshakeTransport.
|
// the first thing to call after instantiating handshakeTransport.
|
||||||
func (t *handshakeTransport) waitSession() error {
|
func (t *handshakeTransport) waitSession() error {
|
||||||
|
|
@ -259,6 +277,7 @@ func (t *handshakeTransport) recordWriteError(err error) {
|
||||||
defer t.mu.Unlock()
|
defer t.mu.Unlock()
|
||||||
if t.writeError == nil && err != nil {
|
if t.writeError == nil && err != nil {
|
||||||
t.writeError = err
|
t.writeError = err
|
||||||
|
t.writeCond.Broadcast()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,7 +294,7 @@ func (t *handshakeTransport) resetWriteThresholds() {
|
||||||
if t.config.RekeyThreshold > 0 {
|
if t.config.RekeyThreshold > 0 {
|
||||||
t.writeBytesLeft = int64(t.config.RekeyThreshold)
|
t.writeBytesLeft = int64(t.config.RekeyThreshold)
|
||||||
} else if t.algorithms != nil {
|
} else if t.algorithms != nil {
|
||||||
t.writeBytesLeft = t.algorithms.w.rekeyBytes()
|
t.writeBytesLeft = t.algorithms.Write.rekeyBytes()
|
||||||
} else {
|
} else {
|
||||||
t.writeBytesLeft = 1 << 30
|
t.writeBytesLeft = 1 << 30
|
||||||
}
|
}
|
||||||
|
|
@ -362,6 +381,8 @@ write:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.pendingPackets = t.pendingPackets[:0]
|
t.pendingPackets = t.pendingPackets[:0]
|
||||||
|
// Unblock writePacket if waiting for KEX.
|
||||||
|
t.writeCond.Broadcast()
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -390,7 +411,7 @@ func (t *handshakeTransport) resetReadThresholds() {
|
||||||
if t.config.RekeyThreshold > 0 {
|
if t.config.RekeyThreshold > 0 {
|
||||||
t.readBytesLeft = int64(t.config.RekeyThreshold)
|
t.readBytesLeft = int64(t.config.RekeyThreshold)
|
||||||
} else if t.algorithms != nil {
|
} else if t.algorithms != nil {
|
||||||
t.readBytesLeft = t.algorithms.r.rekeyBytes()
|
t.readBytesLeft = t.algorithms.Read.rekeyBytes()
|
||||||
} else {
|
} else {
|
||||||
t.readBytesLeft = 1 << 30
|
t.readBytesLeft = 1 << 30
|
||||||
}
|
}
|
||||||
|
|
@ -483,7 +504,7 @@ func (t *handshakeTransport) sendKexInit() error {
|
||||||
CompressionClientServer: supportedCompressions,
|
CompressionClientServer: supportedCompressions,
|
||||||
CompressionServerClient: supportedCompressions,
|
CompressionServerClient: supportedCompressions,
|
||||||
}
|
}
|
||||||
io.ReadFull(rand.Reader, msg.Cookie[:])
|
io.ReadFull(t.config.Rand, msg.Cookie[:])
|
||||||
|
|
||||||
// We mutate the KexAlgos slice, in order to add the kex-strict extension algorithm,
|
// We mutate the KexAlgos slice, in order to add the kex-strict extension algorithm,
|
||||||
// and possibly to add the ext-info extension algorithm. Since the slice may be the
|
// and possibly to add the ext-info extension algorithm. Since the slice may be the
|
||||||
|
|
@ -552,26 +573,44 @@ func (t *handshakeTransport) sendKexInit() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errSendBannerPhase = errors.New("ssh: SendAuthBanner outside of authentication phase")
|
||||||
|
|
||||||
func (t *handshakeTransport) writePacket(p []byte) error {
|
func (t *handshakeTransport) writePacket(p []byte) error {
|
||||||
|
t.mu.Lock()
|
||||||
|
defer t.mu.Unlock()
|
||||||
|
|
||||||
switch p[0] {
|
switch p[0] {
|
||||||
case msgKexInit:
|
case msgKexInit:
|
||||||
return errors.New("ssh: only handshakeTransport can send kexInit")
|
return errors.New("ssh: only handshakeTransport can send kexInit")
|
||||||
case msgNewKeys:
|
case msgNewKeys:
|
||||||
return errors.New("ssh: only handshakeTransport can send newKeys")
|
return errors.New("ssh: only handshakeTransport can send newKeys")
|
||||||
|
case msgUserAuthBanner:
|
||||||
|
if t.userAuthComplete {
|
||||||
|
return errSendBannerPhase
|
||||||
|
}
|
||||||
|
case msgUserAuthSuccess:
|
||||||
|
t.userAuthComplete = true
|
||||||
}
|
}
|
||||||
|
|
||||||
t.mu.Lock()
|
|
||||||
defer t.mu.Unlock()
|
|
||||||
if t.writeError != nil {
|
if t.writeError != nil {
|
||||||
return t.writeError
|
return t.writeError
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.sentInitMsg != nil {
|
if t.sentInitMsg != nil {
|
||||||
// Copy the packet so the writer can reuse the buffer.
|
if len(t.pendingPackets) < maxPendingPackets {
|
||||||
cp := make([]byte, len(p))
|
// Copy the packet so the writer can reuse the buffer.
|
||||||
copy(cp, p)
|
cp := make([]byte, len(p))
|
||||||
t.pendingPackets = append(t.pendingPackets, cp)
|
copy(cp, p)
|
||||||
return nil
|
t.pendingPackets = append(t.pendingPackets, cp)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for t.sentInitMsg != nil {
|
||||||
|
// Block and wait for KEX to complete or an error.
|
||||||
|
t.writeCond.Wait()
|
||||||
|
if t.writeError != nil {
|
||||||
|
return t.writeError
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.writeBytesLeft > 0 {
|
if t.writeBytesLeft > 0 {
|
||||||
|
|
@ -588,6 +627,7 @@ func (t *handshakeTransport) writePacket(p []byte) error {
|
||||||
|
|
||||||
if err := t.pushPacket(p); err != nil {
|
if err := t.pushPacket(p); err != nil {
|
||||||
t.writeError = err
|
t.writeError = err
|
||||||
|
t.writeCond.Broadcast()
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -664,9 +704,9 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kex, ok := kexAlgoMap[t.algorithms.kex]
|
kex, ok := kexAlgoMap[t.algorithms.KeyExchange]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("ssh: unexpected key exchange algorithm %v", t.algorithms.kex)
|
return fmt.Errorf("ssh: unexpected key exchange algorithm %v", t.algorithms.KeyExchange)
|
||||||
}
|
}
|
||||||
|
|
||||||
var result *kexResult
|
var result *kexResult
|
||||||
|
|
@ -773,12 +813,12 @@ func pickHostKey(hostKeys []Signer, algo string) AlgorithmSigner {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *handshakeTransport) server(kex kexAlgorithm, magics *handshakeMagics) (*kexResult, error) {
|
func (t *handshakeTransport) server(kex kexAlgorithm, magics *handshakeMagics) (*kexResult, error) {
|
||||||
hostKey := pickHostKey(t.hostKeys, t.algorithms.hostKey)
|
hostKey := pickHostKey(t.hostKeys, t.algorithms.HostKey)
|
||||||
if hostKey == nil {
|
if hostKey == nil {
|
||||||
return nil, errors.New("ssh: internal error: negotiated unsupported signature type")
|
return nil, errors.New("ssh: internal error: negotiated unsupported signature type")
|
||||||
}
|
}
|
||||||
|
|
||||||
r, err := kex.Server(t.conn, t.config.Rand, magics, hostKey, t.algorithms.hostKey)
|
r, err := kex.Server(t.conn, t.config.Rand, magics, hostKey, t.algorithms.HostKey)
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -793,7 +833,7 @@ func (t *handshakeTransport) client(kex kexAlgorithm, magics *handshakeMagics) (
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := verifyHostKeySignature(hostKey, t.algorithms.hostKey, result); err != nil {
|
if err := verifyHostKeySignature(hostKey, t.algorithms.HostKey, result); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
107
vendor/golang.org/x/crypto/ssh/kex.go
generated
vendored
107
vendor/golang.org/x/crypto/ssh/kex.go
generated
vendored
|
|
@ -20,21 +20,18 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
kexAlgoDH1SHA1 = "diffie-hellman-group1-sha1"
|
// This is the group called diffie-hellman-group1-sha1 in RFC 4253 and
|
||||||
kexAlgoDH14SHA1 = "diffie-hellman-group14-sha1"
|
// Oakley Group 2 in RFC 2409.
|
||||||
kexAlgoDH14SHA256 = "diffie-hellman-group14-sha256"
|
oakleyGroup2 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF"
|
||||||
kexAlgoDH16SHA512 = "diffie-hellman-group16-sha512"
|
// This is the group called diffie-hellman-group14-sha1 in RFC 4253 and
|
||||||
kexAlgoECDH256 = "ecdh-sha2-nistp256"
|
// Oakley Group 14 in RFC 3526.
|
||||||
kexAlgoECDH384 = "ecdh-sha2-nistp384"
|
oakleyGroup14 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF"
|
||||||
kexAlgoECDH521 = "ecdh-sha2-nistp521"
|
// This is the group called diffie-hellman-group15-sha512 in RFC 8268 and
|
||||||
kexAlgoCurve25519SHA256LibSSH = "curve25519-sha256@libssh.org"
|
// Oakley Group 15 in RFC 3526.
|
||||||
kexAlgoCurve25519SHA256 = "curve25519-sha256"
|
oakleyGroup15 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
|
||||||
|
// This is the group called diffie-hellman-group16-sha512 in RFC 8268 and
|
||||||
// For the following kex only the client half contains a production
|
// Oakley Group 16 in RFC 3526.
|
||||||
// ready implementation. The server half only consists of a minimal
|
oakleyGroup16 = "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199FFFFFFFFFFFFFFFF"
|
||||||
// implementation to satisfy the automated tests.
|
|
||||||
kexAlgoDHGEXSHA1 = "diffie-hellman-group-exchange-sha1"
|
|
||||||
kexAlgoDHGEXSHA256 = "diffie-hellman-group-exchange-sha256"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// kexResult captures the outcome of a key exchange.
|
// kexResult captures the outcome of a key exchange.
|
||||||
|
|
@ -402,53 +399,46 @@ func ecHash(curve elliptic.Curve) crypto.Hash {
|
||||||
var kexAlgoMap = map[string]kexAlgorithm{}
|
var kexAlgoMap = map[string]kexAlgorithm{}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// This is the group called diffie-hellman-group1-sha1 in
|
p, _ := new(big.Int).SetString(oakleyGroup2, 16)
|
||||||
// RFC 4253 and Oakley Group 2 in RFC 2409.
|
kexAlgoMap[InsecureKeyExchangeDH1SHA1] = &dhGroup{
|
||||||
p, _ := new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF", 16)
|
|
||||||
kexAlgoMap[kexAlgoDH1SHA1] = &dhGroup{
|
|
||||||
g: new(big.Int).SetInt64(2),
|
g: new(big.Int).SetInt64(2),
|
||||||
p: p,
|
p: p,
|
||||||
pMinus1: new(big.Int).Sub(p, bigOne),
|
pMinus1: new(big.Int).Sub(p, bigOne),
|
||||||
hashFunc: crypto.SHA1,
|
hashFunc: crypto.SHA1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This are the groups called diffie-hellman-group14-sha1 and
|
p, _ = new(big.Int).SetString(oakleyGroup14, 16)
|
||||||
// diffie-hellman-group14-sha256 in RFC 4253 and RFC 8268,
|
|
||||||
// and Oakley Group 14 in RFC 3526.
|
|
||||||
p, _ = new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF", 16)
|
|
||||||
group14 := &dhGroup{
|
group14 := &dhGroup{
|
||||||
g: new(big.Int).SetInt64(2),
|
g: new(big.Int).SetInt64(2),
|
||||||
p: p,
|
p: p,
|
||||||
pMinus1: new(big.Int).Sub(p, bigOne),
|
pMinus1: new(big.Int).Sub(p, bigOne),
|
||||||
}
|
}
|
||||||
|
|
||||||
kexAlgoMap[kexAlgoDH14SHA1] = &dhGroup{
|
kexAlgoMap[InsecureKeyExchangeDH14SHA1] = &dhGroup{
|
||||||
g: group14.g, p: group14.p, pMinus1: group14.pMinus1,
|
g: group14.g, p: group14.p, pMinus1: group14.pMinus1,
|
||||||
hashFunc: crypto.SHA1,
|
hashFunc: crypto.SHA1,
|
||||||
}
|
}
|
||||||
kexAlgoMap[kexAlgoDH14SHA256] = &dhGroup{
|
kexAlgoMap[KeyExchangeDH14SHA256] = &dhGroup{
|
||||||
g: group14.g, p: group14.p, pMinus1: group14.pMinus1,
|
g: group14.g, p: group14.p, pMinus1: group14.pMinus1,
|
||||||
hashFunc: crypto.SHA256,
|
hashFunc: crypto.SHA256,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the group called diffie-hellman-group16-sha512 in RFC
|
p, _ = new(big.Int).SetString(oakleyGroup16, 16)
|
||||||
// 8268 and Oakley Group 16 in RFC 3526.
|
|
||||||
p, _ = new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D788719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA993B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199FFFFFFFFFFFFFFFF", 16)
|
|
||||||
|
|
||||||
kexAlgoMap[kexAlgoDH16SHA512] = &dhGroup{
|
kexAlgoMap[KeyExchangeDH16SHA512] = &dhGroup{
|
||||||
g: new(big.Int).SetInt64(2),
|
g: new(big.Int).SetInt64(2),
|
||||||
p: p,
|
p: p,
|
||||||
pMinus1: new(big.Int).Sub(p, bigOne),
|
pMinus1: new(big.Int).Sub(p, bigOne),
|
||||||
hashFunc: crypto.SHA512,
|
hashFunc: crypto.SHA512,
|
||||||
}
|
}
|
||||||
|
|
||||||
kexAlgoMap[kexAlgoECDH521] = &ecdh{elliptic.P521()}
|
kexAlgoMap[KeyExchangeECDHP521] = &ecdh{elliptic.P521()}
|
||||||
kexAlgoMap[kexAlgoECDH384] = &ecdh{elliptic.P384()}
|
kexAlgoMap[KeyExchangeECDHP384] = &ecdh{elliptic.P384()}
|
||||||
kexAlgoMap[kexAlgoECDH256] = &ecdh{elliptic.P256()}
|
kexAlgoMap[KeyExchangeECDHP256] = &ecdh{elliptic.P256()}
|
||||||
kexAlgoMap[kexAlgoCurve25519SHA256] = &curve25519sha256{}
|
kexAlgoMap[KeyExchangeCurve25519] = &curve25519sha256{}
|
||||||
kexAlgoMap[kexAlgoCurve25519SHA256LibSSH] = &curve25519sha256{}
|
kexAlgoMap[keyExchangeCurve25519LibSSH] = &curve25519sha256{}
|
||||||
kexAlgoMap[kexAlgoDHGEXSHA1] = &dhGEXSHA{hashFunc: crypto.SHA1}
|
kexAlgoMap[InsecureKeyExchangeDHGEXSHA1] = &dhGEXSHA{hashFunc: crypto.SHA1}
|
||||||
kexAlgoMap[kexAlgoDHGEXSHA256] = &dhGEXSHA{hashFunc: crypto.SHA256}
|
kexAlgoMap[KeyExchangeDHGEXSHA256] = &dhGEXSHA{hashFunc: crypto.SHA256}
|
||||||
}
|
}
|
||||||
|
|
||||||
// curve25519sha256 implements the curve25519-sha256 (formerly known as
|
// curve25519sha256 implements the curve25519-sha256 (formerly known as
|
||||||
|
|
@ -601,9 +591,9 @@ const (
|
||||||
func (gex *dhGEXSHA) Client(c packetConn, randSource io.Reader, magics *handshakeMagics) (*kexResult, error) {
|
func (gex *dhGEXSHA) Client(c packetConn, randSource io.Reader, magics *handshakeMagics) (*kexResult, error) {
|
||||||
// Send GexRequest
|
// Send GexRequest
|
||||||
kexDHGexRequest := kexDHGexRequestMsg{
|
kexDHGexRequest := kexDHGexRequestMsg{
|
||||||
MinBits: dhGroupExchangeMinimumBits,
|
MinBits: dhGroupExchangeMinimumBits,
|
||||||
PreferedBits: dhGroupExchangePreferredBits,
|
PreferredBits: dhGroupExchangePreferredBits,
|
||||||
MaxBits: dhGroupExchangeMaximumBits,
|
MaxBits: dhGroupExchangeMaximumBits,
|
||||||
}
|
}
|
||||||
if err := c.writePacket(Marshal(&kexDHGexRequest)); err != nil {
|
if err := c.writePacket(Marshal(&kexDHGexRequest)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -690,9 +680,7 @@ func (gex *dhGEXSHA) Client(c packetConn, randSource io.Reader, magics *handshak
|
||||||
}
|
}
|
||||||
|
|
||||||
// Server half implementation of the Diffie Hellman Key Exchange with SHA1 and SHA256.
|
// Server half implementation of the Diffie Hellman Key Exchange with SHA1 and SHA256.
|
||||||
//
|
func (gex *dhGEXSHA) Server(c packetConn, randSource io.Reader, magics *handshakeMagics, priv AlgorithmSigner, algo string) (result *kexResult, err error) {
|
||||||
// This is a minimal implementation to satisfy the automated tests.
|
|
||||||
func (gex dhGEXSHA) Server(c packetConn, randSource io.Reader, magics *handshakeMagics, priv AlgorithmSigner, algo string) (result *kexResult, err error) {
|
|
||||||
// Receive GexRequest
|
// Receive GexRequest
|
||||||
packet, err := c.readPacket()
|
packet, err := c.readPacket()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -702,13 +690,32 @@ func (gex dhGEXSHA) Server(c packetConn, randSource io.Reader, magics *handshake
|
||||||
if err = Unmarshal(packet, &kexDHGexRequest); err != nil {
|
if err = Unmarshal(packet, &kexDHGexRequest); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// We check that the request received is valid and that the MaxBits
|
||||||
|
// requested are at least equal to our supported minimum. This is the same
|
||||||
|
// check done in OpenSSH:
|
||||||
|
// https://github.com/openssh/openssh-portable/blob/80a2f64b/kexgexs.c#L94
|
||||||
|
//
|
||||||
|
// Furthermore, we also check that the required MinBits are less than or
|
||||||
|
// equal to 4096 because we can use up to Oakley Group 16.
|
||||||
|
if kexDHGexRequest.MaxBits < kexDHGexRequest.MinBits || kexDHGexRequest.PreferredBits < kexDHGexRequest.MinBits ||
|
||||||
|
kexDHGexRequest.MaxBits < kexDHGexRequest.PreferredBits || kexDHGexRequest.MaxBits < dhGroupExchangeMinimumBits ||
|
||||||
|
kexDHGexRequest.MinBits > 4096 {
|
||||||
|
return nil, fmt.Errorf("ssh: DH GEX request out of range, min: %d, max: %d, preferred: %d", kexDHGexRequest.MinBits,
|
||||||
|
kexDHGexRequest.MaxBits, kexDHGexRequest.PreferredBits)
|
||||||
|
}
|
||||||
|
|
||||||
|
var p *big.Int
|
||||||
|
// We hardcode sending Oakley Group 14 (2048 bits), Oakley Group 15 (3072
|
||||||
|
// bits) or Oakley Group 16 (4096 bits), based on the requested max size.
|
||||||
|
if kexDHGexRequest.MaxBits < 3072 {
|
||||||
|
p, _ = new(big.Int).SetString(oakleyGroup14, 16)
|
||||||
|
} else if kexDHGexRequest.MaxBits < 4096 {
|
||||||
|
p, _ = new(big.Int).SetString(oakleyGroup15, 16)
|
||||||
|
} else {
|
||||||
|
p, _ = new(big.Int).SetString(oakleyGroup16, 16)
|
||||||
|
}
|
||||||
|
|
||||||
// Send GexGroup
|
|
||||||
// This is the group called diffie-hellman-group14-sha1 in RFC
|
|
||||||
// 4253 and Oakley Group 14 in RFC 3526.
|
|
||||||
p, _ := new(big.Int).SetString("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF", 16)
|
|
||||||
g := big.NewInt(2)
|
g := big.NewInt(2)
|
||||||
|
|
||||||
msg := &kexDHGexGroupMsg{
|
msg := &kexDHGexGroupMsg{
|
||||||
P: p,
|
P: p,
|
||||||
G: g,
|
G: g,
|
||||||
|
|
@ -746,9 +753,9 @@ func (gex dhGEXSHA) Server(c packetConn, randSource io.Reader, magics *handshake
|
||||||
h := gex.hashFunc.New()
|
h := gex.hashFunc.New()
|
||||||
magics.write(h)
|
magics.write(h)
|
||||||
writeString(h, hostKeyBytes)
|
writeString(h, hostKeyBytes)
|
||||||
binary.Write(h, binary.BigEndian, uint32(dhGroupExchangeMinimumBits))
|
binary.Write(h, binary.BigEndian, kexDHGexRequest.MinBits)
|
||||||
binary.Write(h, binary.BigEndian, uint32(dhGroupExchangePreferredBits))
|
binary.Write(h, binary.BigEndian, kexDHGexRequest.PreferredBits)
|
||||||
binary.Write(h, binary.BigEndian, uint32(dhGroupExchangeMaximumBits))
|
binary.Write(h, binary.BigEndian, kexDHGexRequest.MaxBits)
|
||||||
writeInt(h, p)
|
writeInt(h, p)
|
||||||
writeInt(h, g)
|
writeInt(h, g)
|
||||||
writeInt(h, kexDHGexInit.X)
|
writeInt(h, kexDHGexInit.X)
|
||||||
|
|
|
||||||
27
vendor/golang.org/x/crypto/ssh/keys.go
generated
vendored
27
vendor/golang.org/x/crypto/ssh/keys.go
generated
vendored
|
|
@ -36,14 +36,19 @@ import (
|
||||||
// ClientConfig.HostKeyAlgorithms, Signature.Format, or as AlgorithmSigner
|
// ClientConfig.HostKeyAlgorithms, Signature.Format, or as AlgorithmSigner
|
||||||
// arguments.
|
// arguments.
|
||||||
const (
|
const (
|
||||||
KeyAlgoRSA = "ssh-rsa"
|
KeyAlgoRSA = "ssh-rsa"
|
||||||
KeyAlgoDSA = "ssh-dss"
|
// Deprecated: DSA is only supported at insecure key sizes, and was removed
|
||||||
KeyAlgoECDSA256 = "ecdsa-sha2-nistp256"
|
// from major implementations.
|
||||||
KeyAlgoSKECDSA256 = "sk-ecdsa-sha2-nistp256@openssh.com"
|
KeyAlgoDSA = InsecureKeyAlgoDSA
|
||||||
KeyAlgoECDSA384 = "ecdsa-sha2-nistp384"
|
// Deprecated: DSA is only supported at insecure key sizes, and was removed
|
||||||
KeyAlgoECDSA521 = "ecdsa-sha2-nistp521"
|
// from major implementations.
|
||||||
KeyAlgoED25519 = "ssh-ed25519"
|
InsecureKeyAlgoDSA = "ssh-dss"
|
||||||
KeyAlgoSKED25519 = "sk-ssh-ed25519@openssh.com"
|
KeyAlgoECDSA256 = "ecdsa-sha2-nistp256"
|
||||||
|
KeyAlgoSKECDSA256 = "sk-ecdsa-sha2-nistp256@openssh.com"
|
||||||
|
KeyAlgoECDSA384 = "ecdsa-sha2-nistp384"
|
||||||
|
KeyAlgoECDSA521 = "ecdsa-sha2-nistp521"
|
||||||
|
KeyAlgoED25519 = "ssh-ed25519"
|
||||||
|
KeyAlgoSKED25519 = "sk-ssh-ed25519@openssh.com"
|
||||||
|
|
||||||
// KeyAlgoRSASHA256 and KeyAlgoRSASHA512 are only public key algorithms, not
|
// KeyAlgoRSASHA256 and KeyAlgoRSASHA512 are only public key algorithms, not
|
||||||
// public key formats, so they can't appear as a PublicKey.Type. The
|
// public key formats, so they can't appear as a PublicKey.Type. The
|
||||||
|
|
@ -67,7 +72,7 @@ func parsePubKey(in []byte, algo string) (pubKey PublicKey, rest []byte, err err
|
||||||
switch algo {
|
switch algo {
|
||||||
case KeyAlgoRSA:
|
case KeyAlgoRSA:
|
||||||
return parseRSA(in)
|
return parseRSA(in)
|
||||||
case KeyAlgoDSA:
|
case InsecureKeyAlgoDSA:
|
||||||
return parseDSA(in)
|
return parseDSA(in)
|
||||||
case KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521:
|
case KeyAlgoECDSA256, KeyAlgoECDSA384, KeyAlgoECDSA521:
|
||||||
return parseECDSA(in)
|
return parseECDSA(in)
|
||||||
|
|
@ -77,7 +82,7 @@ func parsePubKey(in []byte, algo string) (pubKey PublicKey, rest []byte, err err
|
||||||
return parseED25519(in)
|
return parseED25519(in)
|
||||||
case KeyAlgoSKED25519:
|
case KeyAlgoSKED25519:
|
||||||
return parseSKEd25519(in)
|
return parseSKEd25519(in)
|
||||||
case CertAlgoRSAv01, CertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoSKECDSA256v01, CertAlgoED25519v01, CertAlgoSKED25519v01:
|
case CertAlgoRSAv01, InsecureCertAlgoDSAv01, CertAlgoECDSA256v01, CertAlgoECDSA384v01, CertAlgoECDSA521v01, CertAlgoSKECDSA256v01, CertAlgoED25519v01, CertAlgoSKED25519v01:
|
||||||
cert, err := parseCert(in, certKeyAlgoNames[algo])
|
cert, err := parseCert(in, certKeyAlgoNames[algo])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|
@ -268,7 +273,7 @@ func ParseAuthorizedKey(in []byte) (out PublicKey, comment string, options []str
|
||||||
return nil, "", nil, nil, errors.New("ssh: no key found")
|
return nil, "", nil, nil, errors.New("ssh: no key found")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParsePublicKey parses an SSH public key formatted for use in
|
// ParsePublicKey parses an SSH public key or certificate formatted for use in
|
||||||
// the SSH wire protocol according to RFC 4253, section 6.6.
|
// the SSH wire protocol according to RFC 4253, section 6.6.
|
||||||
func ParsePublicKey(in []byte) (out PublicKey, err error) {
|
func ParsePublicKey(in []byte) (out PublicKey, err error) {
|
||||||
algo, in, ok := parseString(in)
|
algo, in, ok := parseString(in)
|
||||||
|
|
|
||||||
12
vendor/golang.org/x/crypto/ssh/mac.go
generated
vendored
12
vendor/golang.org/x/crypto/ssh/mac.go
generated
vendored
|
|
@ -47,22 +47,22 @@ func (t truncatingMAC) Size() int {
|
||||||
func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() }
|
func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() }
|
||||||
|
|
||||||
var macModes = map[string]*macMode{
|
var macModes = map[string]*macMode{
|
||||||
"hmac-sha2-512-etm@openssh.com": {64, true, func(key []byte) hash.Hash {
|
HMACSHA512ETM: {64, true, func(key []byte) hash.Hash {
|
||||||
return hmac.New(sha512.New, key)
|
return hmac.New(sha512.New, key)
|
||||||
}},
|
}},
|
||||||
"hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash {
|
HMACSHA256ETM: {32, true, func(key []byte) hash.Hash {
|
||||||
return hmac.New(sha256.New, key)
|
return hmac.New(sha256.New, key)
|
||||||
}},
|
}},
|
||||||
"hmac-sha2-512": {64, false, func(key []byte) hash.Hash {
|
HMACSHA512: {64, false, func(key []byte) hash.Hash {
|
||||||
return hmac.New(sha512.New, key)
|
return hmac.New(sha512.New, key)
|
||||||
}},
|
}},
|
||||||
"hmac-sha2-256": {32, false, func(key []byte) hash.Hash {
|
HMACSHA256: {32, false, func(key []byte) hash.Hash {
|
||||||
return hmac.New(sha256.New, key)
|
return hmac.New(sha256.New, key)
|
||||||
}},
|
}},
|
||||||
"hmac-sha1": {20, false, func(key []byte) hash.Hash {
|
HMACSHA1: {20, false, func(key []byte) hash.Hash {
|
||||||
return hmac.New(sha1.New, key)
|
return hmac.New(sha1.New, key)
|
||||||
}},
|
}},
|
||||||
"hmac-sha1-96": {20, false, func(key []byte) hash.Hash {
|
InsecureHMACSHA196: {20, false, func(key []byte) hash.Hash {
|
||||||
return truncatingMAC{12, hmac.New(sha1.New, key)}
|
return truncatingMAC{12, hmac.New(sha1.New, key)}
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
8
vendor/golang.org/x/crypto/ssh/messages.go
generated
vendored
8
vendor/golang.org/x/crypto/ssh/messages.go
generated
vendored
|
|
@ -122,9 +122,9 @@ type kexDHGexReplyMsg struct {
|
||||||
const msgKexDHGexRequest = 34
|
const msgKexDHGexRequest = 34
|
||||||
|
|
||||||
type kexDHGexRequestMsg struct {
|
type kexDHGexRequestMsg struct {
|
||||||
MinBits uint32 `sshtype:"34"`
|
MinBits uint32 `sshtype:"34"`
|
||||||
PreferedBits uint32
|
PreferredBits uint32
|
||||||
MaxBits uint32
|
MaxBits uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// See RFC 4253, section 10.
|
// See RFC 4253, section 10.
|
||||||
|
|
@ -818,6 +818,8 @@ func decode(packet []byte) (interface{}, error) {
|
||||||
return new(userAuthSuccessMsg), nil
|
return new(userAuthSuccessMsg), nil
|
||||||
case msgUserAuthFailure:
|
case msgUserAuthFailure:
|
||||||
msg = new(userAuthFailureMsg)
|
msg = new(userAuthFailureMsg)
|
||||||
|
case msgUserAuthBanner:
|
||||||
|
msg = new(userAuthBannerMsg)
|
||||||
case msgUserAuthPubKeyOk:
|
case msgUserAuthPubKeyOk:
|
||||||
msg = new(userAuthPubKeyOkMsg)
|
msg = new(userAuthPubKeyOkMsg)
|
||||||
case msgGlobalRequest:
|
case msgGlobalRequest:
|
||||||
|
|
|
||||||
183
vendor/golang.org/x/crypto/ssh/mlkem.go
generated
vendored
Normal file
183
vendor/golang.org/x/crypto/ssh/mlkem.go
generated
vendored
Normal file
|
|
@ -0,0 +1,183 @@
|
||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.24
|
||||||
|
|
||||||
|
package ssh
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
"crypto/mlkem"
|
||||||
|
"crypto/sha256"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"runtime"
|
||||||
|
"slices"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/curve25519"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// After Go 1.24rc1 mlkem swapped the order of return values of Encapsulate.
|
||||||
|
// See #70950.
|
||||||
|
if runtime.Version() == "go1.24rc1" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
supportedKexAlgos = slices.Insert(supportedKexAlgos, 0, KeyExchangeMLKEM768X25519)
|
||||||
|
defaultKexAlgos = slices.Insert(defaultKexAlgos, 0, KeyExchangeMLKEM768X25519)
|
||||||
|
kexAlgoMap[KeyExchangeMLKEM768X25519] = &mlkem768WithCurve25519sha256{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mlkem768WithCurve25519sha256 implements the hybrid ML-KEM768 with
|
||||||
|
// curve25519-sha256 key exchange method, as described by
|
||||||
|
// draft-kampanakis-curdle-ssh-pq-ke-05 section 2.3.3.
|
||||||
|
type mlkem768WithCurve25519sha256 struct{}
|
||||||
|
|
||||||
|
func (kex *mlkem768WithCurve25519sha256) Client(c packetConn, rand io.Reader, magics *handshakeMagics) (*kexResult, error) {
|
||||||
|
var c25519kp curve25519KeyPair
|
||||||
|
if err := c25519kp.generate(rand); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
seed := make([]byte, mlkem.SeedSize)
|
||||||
|
if _, err := io.ReadFull(rand, seed); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
mlkemDk, err := mlkem.NewDecapsulationKey768(seed)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
hybridKey := append(mlkemDk.EncapsulationKey().Bytes(), c25519kp.pub[:]...)
|
||||||
|
if err := c.writePacket(Marshal(&kexECDHInitMsg{hybridKey})); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
packet, err := c.readPacket()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var reply kexECDHReplyMsg
|
||||||
|
if err = Unmarshal(packet, &reply); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(reply.EphemeralPubKey) != mlkem.CiphertextSize768+32 {
|
||||||
|
return nil, errors.New("ssh: peer's mlkem768x25519 public value has wrong length")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform KEM decapsulate operation to obtain shared key from ML-KEM.
|
||||||
|
mlkem768Secret, err := mlkemDk.Decapsulate(reply.EphemeralPubKey[:mlkem.CiphertextSize768])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Complete Curve25519 ECDH to obtain its shared key.
|
||||||
|
c25519Secret, err := curve25519.X25519(c25519kp.priv[:], reply.EphemeralPubKey[mlkem.CiphertextSize768:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("ssh: peer's mlkem768x25519 public value is not valid: %w", err)
|
||||||
|
}
|
||||||
|
// Compute actual shared key.
|
||||||
|
h := sha256.New()
|
||||||
|
h.Write(mlkem768Secret)
|
||||||
|
h.Write(c25519Secret)
|
||||||
|
secret := h.Sum(nil)
|
||||||
|
|
||||||
|
h.Reset()
|
||||||
|
magics.write(h)
|
||||||
|
writeString(h, reply.HostKey)
|
||||||
|
writeString(h, hybridKey)
|
||||||
|
writeString(h, reply.EphemeralPubKey)
|
||||||
|
|
||||||
|
K := make([]byte, stringLength(len(secret)))
|
||||||
|
marshalString(K, secret)
|
||||||
|
h.Write(K)
|
||||||
|
|
||||||
|
return &kexResult{
|
||||||
|
H: h.Sum(nil),
|
||||||
|
K: K,
|
||||||
|
HostKey: reply.HostKey,
|
||||||
|
Signature: reply.Signature,
|
||||||
|
Hash: crypto.SHA256,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (kex *mlkem768WithCurve25519sha256) Server(c packetConn, rand io.Reader, magics *handshakeMagics, priv AlgorithmSigner, algo string) (*kexResult, error) {
|
||||||
|
packet, err := c.readPacket()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var kexInit kexECDHInitMsg
|
||||||
|
if err = Unmarshal(packet, &kexInit); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(kexInit.ClientPubKey) != mlkem.EncapsulationKeySize768+32 {
|
||||||
|
return nil, errors.New("ssh: peer's ML-KEM768/curve25519 public value has wrong length")
|
||||||
|
}
|
||||||
|
|
||||||
|
encapsulationKey, err := mlkem.NewEncapsulationKey768(kexInit.ClientPubKey[:mlkem.EncapsulationKeySize768])
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("ssh: peer's ML-KEM768 encapsulation key is not valid: %w", err)
|
||||||
|
}
|
||||||
|
// Perform KEM encapsulate operation to obtain ciphertext and shared key.
|
||||||
|
mlkem768Secret, mlkem768Ciphertext := encapsulationKey.Encapsulate()
|
||||||
|
|
||||||
|
// Perform server side of Curve25519 ECDH to obtain server public value and
|
||||||
|
// shared key.
|
||||||
|
var c25519kp curve25519KeyPair
|
||||||
|
if err := c25519kp.generate(rand); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
c25519Secret, err := curve25519.X25519(c25519kp.priv[:], kexInit.ClientPubKey[mlkem.EncapsulationKeySize768:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("ssh: peer's ML-KEM768/curve25519 public value is not valid: %w", err)
|
||||||
|
}
|
||||||
|
hybridKey := append(mlkem768Ciphertext, c25519kp.pub[:]...)
|
||||||
|
|
||||||
|
// Compute actual shared key.
|
||||||
|
h := sha256.New()
|
||||||
|
h.Write(mlkem768Secret)
|
||||||
|
h.Write(c25519Secret)
|
||||||
|
secret := h.Sum(nil)
|
||||||
|
|
||||||
|
hostKeyBytes := priv.PublicKey().Marshal()
|
||||||
|
|
||||||
|
h.Reset()
|
||||||
|
magics.write(h)
|
||||||
|
writeString(h, hostKeyBytes)
|
||||||
|
writeString(h, kexInit.ClientPubKey)
|
||||||
|
writeString(h, hybridKey)
|
||||||
|
|
||||||
|
K := make([]byte, stringLength(len(secret)))
|
||||||
|
marshalString(K, secret)
|
||||||
|
h.Write(K)
|
||||||
|
|
||||||
|
H := h.Sum(nil)
|
||||||
|
|
||||||
|
sig, err := signAndMarshal(priv, rand, H, algo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
reply := kexECDHReplyMsg{
|
||||||
|
EphemeralPubKey: hybridKey,
|
||||||
|
HostKey: hostKeyBytes,
|
||||||
|
Signature: sig,
|
||||||
|
}
|
||||||
|
if err := c.writePacket(Marshal(&reply)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &kexResult{
|
||||||
|
H: H,
|
||||||
|
K: K,
|
||||||
|
HostKey: hostKeyBytes,
|
||||||
|
Signature: sig,
|
||||||
|
Hash: crypto.SHA256,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
81
vendor/golang.org/x/crypto/ssh/server.go
generated
vendored
81
vendor/golang.org/x/crypto/ssh/server.go
generated
vendored
|
|
@ -59,6 +59,27 @@ type GSSAPIWithMICConfig struct {
|
||||||
Server GSSAPIServer
|
Server GSSAPIServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SendAuthBanner implements [ServerPreAuthConn].
|
||||||
|
func (s *connection) SendAuthBanner(msg string) error {
|
||||||
|
return s.transport.writePacket(Marshal(&userAuthBannerMsg{
|
||||||
|
Message: msg,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*connection) unexportedMethodForFutureProofing() {}
|
||||||
|
|
||||||
|
// ServerPreAuthConn is the interface available on an incoming server
|
||||||
|
// connection before authentication has completed.
|
||||||
|
type ServerPreAuthConn interface {
|
||||||
|
unexportedMethodForFutureProofing() // permits growing ServerPreAuthConn safely later, ala testing.TB
|
||||||
|
|
||||||
|
ConnMetadata
|
||||||
|
|
||||||
|
// SendAuthBanner sends a banner message to the client.
|
||||||
|
// It returns an error once the authentication phase has ended.
|
||||||
|
SendAuthBanner(string) error
|
||||||
|
}
|
||||||
|
|
||||||
// ServerConfig holds server specific configuration data.
|
// ServerConfig holds server specific configuration data.
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
// Config contains configuration shared between client and server.
|
// Config contains configuration shared between client and server.
|
||||||
|
|
@ -118,6 +139,12 @@ type ServerConfig struct {
|
||||||
// attempts.
|
// attempts.
|
||||||
AuthLogCallback func(conn ConnMetadata, method string, err error)
|
AuthLogCallback func(conn ConnMetadata, method string, err error)
|
||||||
|
|
||||||
|
// PreAuthConnCallback, if non-nil, is called upon receiving a new connection
|
||||||
|
// before any authentication has started. The provided ServerPreAuthConn
|
||||||
|
// can be used at any time before authentication is complete, including
|
||||||
|
// after this callback has returned.
|
||||||
|
PreAuthConnCallback func(ServerPreAuthConn)
|
||||||
|
|
||||||
// ServerVersion is the version identification string to announce in
|
// ServerVersion is the version identification string to announce in
|
||||||
// the public handshake.
|
// the public handshake.
|
||||||
// If empty, a reasonable default is used.
|
// If empty, a reasonable default is used.
|
||||||
|
|
@ -149,7 +176,7 @@ func (s *ServerConfig) AddHostKey(key Signer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// cachedPubKey contains the results of querying whether a public key is
|
// cachedPubKey contains the results of querying whether a public key is
|
||||||
// acceptable for a user.
|
// acceptable for a user. This is a FIFO cache.
|
||||||
type cachedPubKey struct {
|
type cachedPubKey struct {
|
||||||
user string
|
user string
|
||||||
pubKeyData []byte
|
pubKeyData []byte
|
||||||
|
|
@ -157,7 +184,13 @@ type cachedPubKey struct {
|
||||||
perms *Permissions
|
perms *Permissions
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxCachedPubKeys = 16
|
// maxCachedPubKeys is the number of cache entries we store.
|
||||||
|
//
|
||||||
|
// Due to consistent misuse of the PublicKeyCallback API, we have reduced this
|
||||||
|
// to 1, such that the only key in the cache is the most recently seen one. This
|
||||||
|
// forces the behavior that the last call to PublicKeyCallback will always be
|
||||||
|
// with the key that is used for authentication.
|
||||||
|
const maxCachedPubKeys = 1
|
||||||
|
|
||||||
// pubKeyCache caches tests for public keys. Since SSH clients
|
// pubKeyCache caches tests for public keys. Since SSH clients
|
||||||
// will query whether a public key is acceptable before attempting to
|
// will query whether a public key is acceptable before attempting to
|
||||||
|
|
@ -179,9 +212,10 @@ func (c *pubKeyCache) get(user string, pubKeyData []byte) (cachedPubKey, bool) {
|
||||||
|
|
||||||
// add adds the given tuple to the cache.
|
// add adds the given tuple to the cache.
|
||||||
func (c *pubKeyCache) add(candidate cachedPubKey) {
|
func (c *pubKeyCache) add(candidate cachedPubKey) {
|
||||||
if len(c.keys) < maxCachedPubKeys {
|
if len(c.keys) >= maxCachedPubKeys {
|
||||||
c.keys = append(c.keys, candidate)
|
c.keys = c.keys[1:]
|
||||||
}
|
}
|
||||||
|
c.keys = append(c.keys, candidate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerConn is an authenticated SSH connection, as seen from the
|
// ServerConn is an authenticated SSH connection, as seen from the
|
||||||
|
|
@ -209,22 +243,15 @@ func NewServerConn(c net.Conn, config *ServerConfig) (*ServerConn, <-chan NewCha
|
||||||
fullConf.MaxAuthTries = 6
|
fullConf.MaxAuthTries = 6
|
||||||
}
|
}
|
||||||
if len(fullConf.PublicKeyAuthAlgorithms) == 0 {
|
if len(fullConf.PublicKeyAuthAlgorithms) == 0 {
|
||||||
fullConf.PublicKeyAuthAlgorithms = supportedPubKeyAuthAlgos
|
fullConf.PublicKeyAuthAlgorithms = defaultPubKeyAuthAlgos
|
||||||
} else {
|
} else {
|
||||||
for _, algo := range fullConf.PublicKeyAuthAlgorithms {
|
for _, algo := range fullConf.PublicKeyAuthAlgorithms {
|
||||||
if !contains(supportedPubKeyAuthAlgos, algo) {
|
if !contains(SupportedAlgorithms().PublicKeyAuths, algo) && !contains(InsecureAlgorithms().PublicKeyAuths, algo) {
|
||||||
c.Close()
|
c.Close()
|
||||||
return nil, nil, nil, fmt.Errorf("ssh: unsupported public key authentication algorithm %s", algo)
|
return nil, nil, nil, fmt.Errorf("ssh: unsupported public key authentication algorithm %s", algo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if the config contains any unsupported key exchanges
|
|
||||||
for _, kex := range fullConf.KeyExchanges {
|
|
||||||
if _, ok := serverForbiddenKexAlgos[kex]; ok {
|
|
||||||
c.Close()
|
|
||||||
return nil, nil, nil, fmt.Errorf("ssh: unsupported key exchange %s for server", kex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s := &connection{
|
s := &connection{
|
||||||
sshConn: sshConn{conn: c},
|
sshConn: sshConn{conn: c},
|
||||||
|
|
@ -281,6 +308,7 @@ func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error)
|
||||||
|
|
||||||
// We just did the key change, so the session ID is established.
|
// We just did the key change, so the session ID is established.
|
||||||
s.sessionID = s.transport.getSessionID()
|
s.sessionID = s.transport.getSessionID()
|
||||||
|
s.algorithms = s.transport.getAlgorithms()
|
||||||
|
|
||||||
var packet []byte
|
var packet []byte
|
||||||
if packet, err = s.transport.readPacket(); err != nil {
|
if packet, err = s.transport.readPacket(); err != nil {
|
||||||
|
|
@ -481,6 +509,10 @@ func (b *BannerError) Error() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *connection) serverAuthenticate(config *ServerConfig) (*Permissions, error) {
|
func (s *connection) serverAuthenticate(config *ServerConfig) (*Permissions, error) {
|
||||||
|
if config.PreAuthConnCallback != nil {
|
||||||
|
config.PreAuthConnCallback(s)
|
||||||
|
}
|
||||||
|
|
||||||
sessionID := s.transport.getSessionID()
|
sessionID := s.transport.getSessionID()
|
||||||
var cache pubKeyCache
|
var cache pubKeyCache
|
||||||
var perms *Permissions
|
var perms *Permissions
|
||||||
|
|
@ -488,7 +520,7 @@ func (s *connection) serverAuthenticate(config *ServerConfig) (*Permissions, err
|
||||||
authFailures := 0
|
authFailures := 0
|
||||||
noneAuthCount := 0
|
noneAuthCount := 0
|
||||||
var authErrs []error
|
var authErrs []error
|
||||||
var displayedBanner bool
|
var calledBannerCallback bool
|
||||||
partialSuccessReturned := false
|
partialSuccessReturned := false
|
||||||
// Set the initial authentication callbacks from the config. They can be
|
// Set the initial authentication callbacks from the config. They can be
|
||||||
// changed if a PartialSuccessError is returned.
|
// changed if a PartialSuccessError is returned.
|
||||||
|
|
@ -510,8 +542,8 @@ userAuthLoop:
|
||||||
if err := s.transport.writePacket(Marshal(discMsg)); err != nil {
|
if err := s.transport.writePacket(Marshal(discMsg)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
authErrs = append(authErrs, discMsg)
|
||||||
return nil, discMsg
|
return nil, &ServerAuthError{Errors: authErrs}
|
||||||
}
|
}
|
||||||
|
|
||||||
var userAuthReq userAuthRequestMsg
|
var userAuthReq userAuthRequestMsg
|
||||||
|
|
@ -535,14 +567,10 @@ userAuthLoop:
|
||||||
|
|
||||||
s.user = userAuthReq.User
|
s.user = userAuthReq.User
|
||||||
|
|
||||||
if !displayedBanner && config.BannerCallback != nil {
|
if !calledBannerCallback && config.BannerCallback != nil {
|
||||||
displayedBanner = true
|
calledBannerCallback = true
|
||||||
msg := config.BannerCallback(s)
|
if msg := config.BannerCallback(s); msg != "" {
|
||||||
if msg != "" {
|
if err := s.SendAuthBanner(msg); err != nil {
|
||||||
bannerMsg := &userAuthBannerMsg{
|
|
||||||
Message: msg,
|
|
||||||
}
|
|
||||||
if err := s.transport.writePacket(Marshal(bannerMsg)); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -755,10 +783,7 @@ userAuthLoop:
|
||||||
var bannerErr *BannerError
|
var bannerErr *BannerError
|
||||||
if errors.As(authErr, &bannerErr) {
|
if errors.As(authErr, &bannerErr) {
|
||||||
if bannerErr.Message != "" {
|
if bannerErr.Message != "" {
|
||||||
bannerMsg := &userAuthBannerMsg{
|
if err := s.SendAuthBanner(bannerErr.Message); err != nil {
|
||||||
Message: bannerErr.Message,
|
|
||||||
}
|
|
||||||
if err := s.transport.writePacket(Marshal(bannerMsg)); err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/crypto/ssh/tcpip.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/tcpip.go
generated
vendored
|
|
@ -459,7 +459,7 @@ func (c *Client) dial(laddr string, lport int, raddr string, rport int) (Channel
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
go DiscardRequests(in)
|
go DiscardRequests(in)
|
||||||
return ch, err
|
return ch, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type tcpChan struct {
|
type tcpChan struct {
|
||||||
|
|
|
||||||
15
vendor/golang.org/x/crypto/ssh/transport.go
generated
vendored
15
vendor/golang.org/x/crypto/ssh/transport.go
generated
vendored
|
|
@ -16,13 +16,6 @@ import (
|
||||||
// wire. No message decoding is done, to minimize the impact on timing.
|
// wire. No message decoding is done, to minimize the impact on timing.
|
||||||
const debugTransport = false
|
const debugTransport = false
|
||||||
|
|
||||||
const (
|
|
||||||
gcm128CipherID = "aes128-gcm@openssh.com"
|
|
||||||
gcm256CipherID = "aes256-gcm@openssh.com"
|
|
||||||
aes128cbcID = "aes128-cbc"
|
|
||||||
tripledescbcID = "3des-cbc"
|
|
||||||
)
|
|
||||||
|
|
||||||
// packetConn represents a transport that implements packet based
|
// packetConn represents a transport that implements packet based
|
||||||
// operations.
|
// operations.
|
||||||
type packetConn interface {
|
type packetConn interface {
|
||||||
|
|
@ -92,14 +85,14 @@ func (t *transport) setInitialKEXDone() {
|
||||||
// prepareKeyChange sets up key material for a keychange. The key changes in
|
// prepareKeyChange sets up key material for a keychange. The key changes in
|
||||||
// both directions are triggered by reading and writing a msgNewKey packet
|
// both directions are triggered by reading and writing a msgNewKey packet
|
||||||
// respectively.
|
// respectively.
|
||||||
func (t *transport) prepareKeyChange(algs *algorithms, kexResult *kexResult) error {
|
func (t *transport) prepareKeyChange(algs *NegotiatedAlgorithms, kexResult *kexResult) error {
|
||||||
ciph, err := newPacketCipher(t.reader.dir, algs.r, kexResult)
|
ciph, err := newPacketCipher(t.reader.dir, algs.Read, kexResult)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
t.reader.pendingKeyChange <- ciph
|
t.reader.pendingKeyChange <- ciph
|
||||||
|
|
||||||
ciph, err = newPacketCipher(t.writer.dir, algs.w, kexResult)
|
ciph, err = newPacketCipher(t.writer.dir, algs.Write, kexResult)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -259,7 +252,7 @@ var (
|
||||||
// setupKeys sets the cipher and MAC keys from kex.K, kex.H and sessionId, as
|
// setupKeys sets the cipher and MAC keys from kex.K, kex.H and sessionId, as
|
||||||
// described in RFC 4253, section 6.4. direction should either be serverKeys
|
// described in RFC 4253, section 6.4. direction should either be serverKeys
|
||||||
// (to setup server->client keys) or clientKeys (for client->server keys).
|
// (to setup server->client keys) or clientKeys (for client->server keys).
|
||||||
func newPacketCipher(d direction, algs directionAlgorithms, kex *kexResult) (packetCipher, error) {
|
func newPacketCipher(d direction, algs DirectionAlgorithms, kex *kexResult) (packetCipher, error) {
|
||||||
cipherMode := cipherModes[algs.Cipher]
|
cipherMode := cipherModes[algs.Cipher]
|
||||||
|
|
||||||
iv := make([]byte, cipherMode.ivSize)
|
iv := make([]byte, cipherMode.ivSize)
|
||||||
|
|
|
||||||
17
vendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s
generated
vendored
Normal file
17
vendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build darwin && amd64 && gc
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_sysctl(SB)
|
||||||
|
GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB)
|
||||||
|
|
||||||
|
TEXT libc_sysctlbyname_trampoline<>(SB),NOSPLIT,$0-0
|
||||||
|
JMP libc_sysctlbyname(SB)
|
||||||
|
GLOBL ·libc_sysctlbyname_trampoline_addr(SB), RODATA, $8
|
||||||
|
DATA ·libc_sysctlbyname_trampoline_addr(SB)/8, $libc_sysctlbyname_trampoline<>(SB)
|
||||||
26
vendor/golang.org/x/sys/cpu/cpu.go
generated
vendored
26
vendor/golang.org/x/sys/cpu/cpu.go
generated
vendored
|
|
@ -72,6 +72,9 @@ var X86 struct {
|
||||||
HasSSSE3 bool // Supplemental streaming SIMD extension 3
|
HasSSSE3 bool // Supplemental streaming SIMD extension 3
|
||||||
HasSSE41 bool // Streaming SIMD extension 4 and 4.1
|
HasSSE41 bool // Streaming SIMD extension 4 and 4.1
|
||||||
HasSSE42 bool // Streaming SIMD extension 4 and 4.2
|
HasSSE42 bool // Streaming SIMD extension 4 and 4.2
|
||||||
|
HasAVXIFMA bool // Advanced vector extension Integer Fused Multiply Add
|
||||||
|
HasAVXVNNI bool // Advanced vector extension Vector Neural Network Instructions
|
||||||
|
HasAVXVNNIInt8 bool // Advanced vector extension Vector Neural Network Int8 instructions
|
||||||
_ CacheLinePad
|
_ CacheLinePad
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,6 +149,18 @@ var ARM struct {
|
||||||
_ CacheLinePad
|
_ CacheLinePad
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The booleans in Loong64 contain the correspondingly named cpu feature bit.
|
||||||
|
// The struct is padded to avoid false sharing.
|
||||||
|
var Loong64 struct {
|
||||||
|
_ CacheLinePad
|
||||||
|
HasLSX bool // support 128-bit vector extension
|
||||||
|
HasLASX bool // support 256-bit vector extension
|
||||||
|
HasCRC32 bool // support CRC instruction
|
||||||
|
HasLAM_BH bool // support AM{SWAP/ADD}[_DB].{B/H} instruction
|
||||||
|
HasLAMCAS bool // support AMCAS[_DB].{B/H/W/D} instruction
|
||||||
|
_ CacheLinePad
|
||||||
|
}
|
||||||
|
|
||||||
// MIPS64X contains the supported CPU features of the current mips64/mips64le
|
// MIPS64X contains the supported CPU features of the current mips64/mips64le
|
||||||
// platforms. If the current platform is not mips64/mips64le or the current
|
// platforms. If the current platform is not mips64/mips64le or the current
|
||||||
// operating system is not Linux then all feature flags are false.
|
// operating system is not Linux then all feature flags are false.
|
||||||
|
|
@ -217,6 +232,17 @@ var RISCV64 struct {
|
||||||
HasZba bool // Address generation instructions extension
|
HasZba bool // Address generation instructions extension
|
||||||
HasZbb bool // Basic bit-manipulation extension
|
HasZbb bool // Basic bit-manipulation extension
|
||||||
HasZbs bool // Single-bit instructions extension
|
HasZbs bool // Single-bit instructions extension
|
||||||
|
HasZvbb bool // Vector Basic Bit-manipulation
|
||||||
|
HasZvbc bool // Vector Carryless Multiplication
|
||||||
|
HasZvkb bool // Vector Cryptography Bit-manipulation
|
||||||
|
HasZvkt bool // Vector Data-Independent Execution Latency
|
||||||
|
HasZvkg bool // Vector GCM/GMAC
|
||||||
|
HasZvkn bool // NIST Algorithm Suite (AES/SHA256/SHA512)
|
||||||
|
HasZvknc bool // NIST Algorithm Suite with carryless multiply
|
||||||
|
HasZvkng bool // NIST Algorithm Suite with GCM
|
||||||
|
HasZvks bool // ShangMi Algorithm Suite
|
||||||
|
HasZvksc bool // ShangMi Algorithm Suite with carryless multiplication
|
||||||
|
HasZvksg bool // ShangMi Algorithm Suite with GCM
|
||||||
_ CacheLinePad
|
_ CacheLinePad
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
61
vendor/golang.org/x/sys/cpu/cpu_darwin_x86.go
generated
vendored
Normal file
61
vendor/golang.org/x/sys/cpu/cpu_darwin_x86.go
generated
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build darwin && amd64 && gc
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// darwinSupportsAVX512 checks Darwin kernel for AVX512 support via sysctl
|
||||||
|
// call (see issue 43089). It also restricts AVX512 support for Darwin to
|
||||||
|
// kernel version 21.3.0 (MacOS 12.2.0) or later (see issue 49233).
|
||||||
|
//
|
||||||
|
// Background:
|
||||||
|
// Darwin implements a special mechanism to economize on thread state when
|
||||||
|
// AVX512 specific registers are not in use. This scheme minimizes state when
|
||||||
|
// preempting threads that haven't yet used any AVX512 instructions, but adds
|
||||||
|
// special requirements to check for AVX512 hardware support at runtime (e.g.
|
||||||
|
// via sysctl call or commpage inspection). See issue 43089 and link below for
|
||||||
|
// full background:
|
||||||
|
// https://github.com/apple-oss-distributions/xnu/blob/xnu-11215.1.10/osfmk/i386/fpu.c#L214-L240
|
||||||
|
//
|
||||||
|
// Additionally, all versions of the Darwin kernel from 19.6.0 through 21.2.0
|
||||||
|
// (corresponding to MacOS 10.15.6 - 12.1) have a bug that can cause corruption
|
||||||
|
// of the AVX512 mask registers (K0-K7) upon signal return. For this reason
|
||||||
|
// AVX512 is considered unsafe to use on Darwin for kernel versions prior to
|
||||||
|
// 21.3.0, where a fix has been confirmed. See issue 49233 for full background.
|
||||||
|
func darwinSupportsAVX512() bool {
|
||||||
|
return darwinSysctlEnabled([]byte("hw.optional.avx512f\x00")) && darwinKernelVersionCheck(21, 3, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure Darwin kernel version is at least major.minor.patch, avoiding dependencies
|
||||||
|
func darwinKernelVersionCheck(major, minor, patch int) bool {
|
||||||
|
var release [256]byte
|
||||||
|
err := darwinOSRelease(&release)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var mmp [3]int
|
||||||
|
c := 0
|
||||||
|
Loop:
|
||||||
|
for _, b := range release[:] {
|
||||||
|
switch {
|
||||||
|
case b >= '0' && b <= '9':
|
||||||
|
mmp[c] = 10*mmp[c] + int(b-'0')
|
||||||
|
case b == '.':
|
||||||
|
c++
|
||||||
|
if c > 2 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
case b == 0:
|
||||||
|
break Loop
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if c != 2 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return mmp[0] > major || mmp[0] == major && (mmp[1] > minor || mmp[1] == minor && mmp[2] >= patch)
|
||||||
|
}
|
||||||
4
vendor/golang.org/x/sys/cpu/cpu_gc_x86.go
generated
vendored
4
vendor/golang.org/x/sys/cpu/cpu_gc_x86.go
generated
vendored
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
// cpuid is implemented in cpu_x86.s for gc compiler
|
// cpuid is implemented in cpu_gc_x86.s for gc compiler
|
||||||
// and in cpu_gccgo.c for gccgo.
|
// and in cpu_gccgo.c for gccgo.
|
||||||
func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
|
func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
|
||||||
|
|
||||||
// xgetbv with ecx = 0 is implemented in cpu_x86.s for gc compiler
|
// xgetbv with ecx = 0 is implemented in cpu_gc_x86.s for gc compiler
|
||||||
// and in cpu_gccgo.c for gccgo.
|
// and in cpu_gccgo.c for gccgo.
|
||||||
func xgetbv() (eax, edx uint32)
|
func xgetbv() (eax, edx uint32)
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/sys/cpu/cpu_x86.s → vendor/golang.org/x/sys/cpu/cpu_gc_x86.s
generated
vendored
2
vendor/golang.org/x/sys/cpu/cpu_x86.s → vendor/golang.org/x/sys/cpu/cpu_gc_x86.s
generated
vendored
|
|
@ -18,7 +18,7 @@ TEXT ·cpuid(SB), NOSPLIT, $0-24
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// func xgetbv() (eax, edx uint32)
|
// func xgetbv() (eax, edx uint32)
|
||||||
TEXT ·xgetbv(SB),NOSPLIT,$0-8
|
TEXT ·xgetbv(SB), NOSPLIT, $0-8
|
||||||
MOVL $0, CX
|
MOVL $0, CX
|
||||||
XGETBV
|
XGETBV
|
||||||
MOVL AX, eax+0(FP)
|
MOVL AX, eax+0(FP)
|
||||||
6
vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go
generated
vendored
6
vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go
generated
vendored
|
|
@ -23,9 +23,3 @@ func xgetbv() (eax, edx uint32) {
|
||||||
gccgoXgetbv(&a, &d)
|
gccgoXgetbv(&a, &d)
|
||||||
return a, d
|
return a, d
|
||||||
}
|
}
|
||||||
|
|
||||||
// gccgo doesn't build on Darwin, per:
|
|
||||||
// https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gcc.rb#L76
|
|
||||||
func darwinSupportsAVX512() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
|
||||||
1
vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go
generated
vendored
1
vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go
generated
vendored
|
|
@ -110,7 +110,6 @@ func doinit() {
|
||||||
ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM)
|
ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM)
|
||||||
ARM64.HasDIT = isSet(hwCap, hwcap_DIT)
|
ARM64.HasDIT = isSet(hwCap, hwcap_DIT)
|
||||||
|
|
||||||
|
|
||||||
// HWCAP2 feature bits
|
// HWCAP2 feature bits
|
||||||
ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2)
|
ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2)
|
||||||
ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM)
|
ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM)
|
||||||
|
|
|
||||||
22
vendor/golang.org/x/sys/cpu/cpu_linux_loong64.go
generated
vendored
Normal file
22
vendor/golang.org/x/sys/cpu/cpu_linux_loong64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright 2025 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
// HWCAP bits. These are exposed by the Linux kernel.
|
||||||
|
const (
|
||||||
|
hwcap_LOONGARCH_LSX = 1 << 4
|
||||||
|
hwcap_LOONGARCH_LASX = 1 << 5
|
||||||
|
)
|
||||||
|
|
||||||
|
func doinit() {
|
||||||
|
// TODO: Features that require kernel support like LSX and LASX can
|
||||||
|
// be detected here once needed in std library or by the compiler.
|
||||||
|
Loong64.HasLSX = hwcIsSet(hwCap, hwcap_LOONGARCH_LSX)
|
||||||
|
Loong64.HasLASX = hwcIsSet(hwCap, hwcap_LOONGARCH_LASX)
|
||||||
|
}
|
||||||
|
|
||||||
|
func hwcIsSet(hwc uint, val uint) bool {
|
||||||
|
return hwc&val != 0
|
||||||
|
}
|
||||||
2
vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go
generated
vendored
2
vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go
generated
vendored
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x && !riscv64
|
//go:build linux && !arm && !arm64 && !loong64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x && !riscv64
|
||||||
|
|
||||||
package cpu
|
package cpu
|
||||||
|
|
||||||
|
|
|
||||||
23
vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go
generated
vendored
23
vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go
generated
vendored
|
|
@ -58,6 +58,15 @@ const (
|
||||||
riscv_HWPROBE_EXT_ZBA = 0x8
|
riscv_HWPROBE_EXT_ZBA = 0x8
|
||||||
riscv_HWPROBE_EXT_ZBB = 0x10
|
riscv_HWPROBE_EXT_ZBB = 0x10
|
||||||
riscv_HWPROBE_EXT_ZBS = 0x20
|
riscv_HWPROBE_EXT_ZBS = 0x20
|
||||||
|
riscv_HWPROBE_EXT_ZVBB = 0x20000
|
||||||
|
riscv_HWPROBE_EXT_ZVBC = 0x40000
|
||||||
|
riscv_HWPROBE_EXT_ZVKB = 0x80000
|
||||||
|
riscv_HWPROBE_EXT_ZVKG = 0x100000
|
||||||
|
riscv_HWPROBE_EXT_ZVKNED = 0x200000
|
||||||
|
riscv_HWPROBE_EXT_ZVKNHB = 0x800000
|
||||||
|
riscv_HWPROBE_EXT_ZVKSED = 0x1000000
|
||||||
|
riscv_HWPROBE_EXT_ZVKSH = 0x2000000
|
||||||
|
riscv_HWPROBE_EXT_ZVKT = 0x4000000
|
||||||
riscv_HWPROBE_KEY_CPUPERF_0 = 0x5
|
riscv_HWPROBE_KEY_CPUPERF_0 = 0x5
|
||||||
riscv_HWPROBE_MISALIGNED_FAST = 0x3
|
riscv_HWPROBE_MISALIGNED_FAST = 0x3
|
||||||
riscv_HWPROBE_MISALIGNED_MASK = 0x7
|
riscv_HWPROBE_MISALIGNED_MASK = 0x7
|
||||||
|
|
@ -99,6 +108,20 @@ func doinit() {
|
||||||
RISCV64.HasZba = isSet(v, riscv_HWPROBE_EXT_ZBA)
|
RISCV64.HasZba = isSet(v, riscv_HWPROBE_EXT_ZBA)
|
||||||
RISCV64.HasZbb = isSet(v, riscv_HWPROBE_EXT_ZBB)
|
RISCV64.HasZbb = isSet(v, riscv_HWPROBE_EXT_ZBB)
|
||||||
RISCV64.HasZbs = isSet(v, riscv_HWPROBE_EXT_ZBS)
|
RISCV64.HasZbs = isSet(v, riscv_HWPROBE_EXT_ZBS)
|
||||||
|
RISCV64.HasZvbb = isSet(v, riscv_HWPROBE_EXT_ZVBB)
|
||||||
|
RISCV64.HasZvbc = isSet(v, riscv_HWPROBE_EXT_ZVBC)
|
||||||
|
RISCV64.HasZvkb = isSet(v, riscv_HWPROBE_EXT_ZVKB)
|
||||||
|
RISCV64.HasZvkg = isSet(v, riscv_HWPROBE_EXT_ZVKG)
|
||||||
|
RISCV64.HasZvkt = isSet(v, riscv_HWPROBE_EXT_ZVKT)
|
||||||
|
// Cryptography shorthand extensions
|
||||||
|
RISCV64.HasZvkn = isSet(v, riscv_HWPROBE_EXT_ZVKNED) &&
|
||||||
|
isSet(v, riscv_HWPROBE_EXT_ZVKNHB) && RISCV64.HasZvkb && RISCV64.HasZvkt
|
||||||
|
RISCV64.HasZvknc = RISCV64.HasZvkn && RISCV64.HasZvbc
|
||||||
|
RISCV64.HasZvkng = RISCV64.HasZvkn && RISCV64.HasZvkg
|
||||||
|
RISCV64.HasZvks = isSet(v, riscv_HWPROBE_EXT_ZVKSED) &&
|
||||||
|
isSet(v, riscv_HWPROBE_EXT_ZVKSH) && RISCV64.HasZvkb && RISCV64.HasZvkt
|
||||||
|
RISCV64.HasZvksc = RISCV64.HasZvks && RISCV64.HasZvbc
|
||||||
|
RISCV64.HasZvksg = RISCV64.HasZvks && RISCV64.HasZvkg
|
||||||
}
|
}
|
||||||
if pairs[1].key != -1 {
|
if pairs[1].key != -1 {
|
||||||
v := pairs[1].value & riscv_HWPROBE_MISALIGNED_MASK
|
v := pairs[1].value & riscv_HWPROBE_MISALIGNED_MASK
|
||||||
|
|
|
||||||
38
vendor/golang.org/x/sys/cpu/cpu_loong64.go
generated
vendored
38
vendor/golang.org/x/sys/cpu/cpu_loong64.go
generated
vendored
|
|
@ -8,5 +8,43 @@ package cpu
|
||||||
|
|
||||||
const cacheLineSize = 64
|
const cacheLineSize = 64
|
||||||
|
|
||||||
|
// Bit fields for CPUCFG registers, Related reference documents:
|
||||||
|
// https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_cpucfg
|
||||||
|
const (
|
||||||
|
// CPUCFG1 bits
|
||||||
|
cpucfg1_CRC32 = 1 << 25
|
||||||
|
|
||||||
|
// CPUCFG2 bits
|
||||||
|
cpucfg2_LAM_BH = 1 << 27
|
||||||
|
cpucfg2_LAMCAS = 1 << 28
|
||||||
|
)
|
||||||
|
|
||||||
func initOptions() {
|
func initOptions() {
|
||||||
|
options = []option{
|
||||||
|
{Name: "lsx", Feature: &Loong64.HasLSX},
|
||||||
|
{Name: "lasx", Feature: &Loong64.HasLASX},
|
||||||
|
{Name: "crc32", Feature: &Loong64.HasCRC32},
|
||||||
|
{Name: "lam_bh", Feature: &Loong64.HasLAM_BH},
|
||||||
|
{Name: "lamcas", Feature: &Loong64.HasLAMCAS},
|
||||||
|
}
|
||||||
|
|
||||||
|
// The CPUCFG data on Loong64 only reflects the hardware capabilities,
|
||||||
|
// not the kernel support status, so features such as LSX and LASX that
|
||||||
|
// require kernel support cannot be obtained from the CPUCFG data.
|
||||||
|
//
|
||||||
|
// These features only require hardware capability support and do not
|
||||||
|
// require kernel specific support, so they can be obtained directly
|
||||||
|
// through CPUCFG
|
||||||
|
cfg1 := get_cpucfg(1)
|
||||||
|
cfg2 := get_cpucfg(2)
|
||||||
|
|
||||||
|
Loong64.HasCRC32 = cfgIsSet(cfg1, cpucfg1_CRC32)
|
||||||
|
Loong64.HasLAMCAS = cfgIsSet(cfg2, cpucfg2_LAMCAS)
|
||||||
|
Loong64.HasLAM_BH = cfgIsSet(cfg2, cpucfg2_LAM_BH)
|
||||||
|
}
|
||||||
|
|
||||||
|
func get_cpucfg(reg uint32) uint32
|
||||||
|
|
||||||
|
func cfgIsSet(cfg uint32, val uint32) bool {
|
||||||
|
return cfg&val != 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
vendor/golang.org/x/sys/cpu/cpu_loong64.s
generated
vendored
Normal file
13
vendor/golang.org/x/sys/cpu/cpu_loong64.s
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2025 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// func get_cpucfg(reg uint32) uint32
|
||||||
|
TEXT ·get_cpucfg(SB), NOSPLIT|NOFRAME, $0
|
||||||
|
MOVW reg+0(FP), R5
|
||||||
|
// CPUCFG R5, R4 = 0x00006ca4
|
||||||
|
WORD $0x00006ca4
|
||||||
|
MOVW R4, ret+8(FP)
|
||||||
|
RET
|
||||||
11
vendor/golang.org/x/sys/cpu/cpu_other_x86.go
generated
vendored
Normal file
11
vendor/golang.org/x/sys/cpu/cpu_other_x86.go
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build 386 || amd64p32 || (amd64 && (!darwin || !gc))
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
func darwinSupportsAVX512() bool {
|
||||||
|
panic("only implemented for gc && amd64 && darwin")
|
||||||
|
}
|
||||||
12
vendor/golang.org/x/sys/cpu/cpu_riscv64.go
generated
vendored
12
vendor/golang.org/x/sys/cpu/cpu_riscv64.go
generated
vendored
|
|
@ -16,5 +16,17 @@ func initOptions() {
|
||||||
{Name: "zba", Feature: &RISCV64.HasZba},
|
{Name: "zba", Feature: &RISCV64.HasZba},
|
||||||
{Name: "zbb", Feature: &RISCV64.HasZbb},
|
{Name: "zbb", Feature: &RISCV64.HasZbb},
|
||||||
{Name: "zbs", Feature: &RISCV64.HasZbs},
|
{Name: "zbs", Feature: &RISCV64.HasZbs},
|
||||||
|
// RISC-V Cryptography Extensions
|
||||||
|
{Name: "zvbb", Feature: &RISCV64.HasZvbb},
|
||||||
|
{Name: "zvbc", Feature: &RISCV64.HasZvbc},
|
||||||
|
{Name: "zvkb", Feature: &RISCV64.HasZvkb},
|
||||||
|
{Name: "zvkg", Feature: &RISCV64.HasZvkg},
|
||||||
|
{Name: "zvkt", Feature: &RISCV64.HasZvkt},
|
||||||
|
{Name: "zvkn", Feature: &RISCV64.HasZvkn},
|
||||||
|
{Name: "zvknc", Feature: &RISCV64.HasZvknc},
|
||||||
|
{Name: "zvkng", Feature: &RISCV64.HasZvkng},
|
||||||
|
{Name: "zvks", Feature: &RISCV64.HasZvks},
|
||||||
|
{Name: "zvksc", Feature: &RISCV64.HasZvksc},
|
||||||
|
{Name: "zvksg", Feature: &RISCV64.HasZvksg},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
vendor/golang.org/x/sys/cpu/cpu_x86.go
generated
vendored
27
vendor/golang.org/x/sys/cpu/cpu_x86.go
generated
vendored
|
|
@ -53,6 +53,9 @@ func initOptions() {
|
||||||
{Name: "sse41", Feature: &X86.HasSSE41},
|
{Name: "sse41", Feature: &X86.HasSSE41},
|
||||||
{Name: "sse42", Feature: &X86.HasSSE42},
|
{Name: "sse42", Feature: &X86.HasSSE42},
|
||||||
{Name: "ssse3", Feature: &X86.HasSSSE3},
|
{Name: "ssse3", Feature: &X86.HasSSSE3},
|
||||||
|
{Name: "avxifma", Feature: &X86.HasAVXIFMA},
|
||||||
|
{Name: "avxvnni", Feature: &X86.HasAVXVNNI},
|
||||||
|
{Name: "avxvnniint8", Feature: &X86.HasAVXVNNIInt8},
|
||||||
|
|
||||||
// These capabilities should always be enabled on amd64:
|
// These capabilities should always be enabled on amd64:
|
||||||
{Name: "sse2", Feature: &X86.HasSSE2, Required: runtime.GOARCH == "amd64"},
|
{Name: "sse2", Feature: &X86.HasSSE2, Required: runtime.GOARCH == "amd64"},
|
||||||
|
|
@ -92,10 +95,8 @@ func archInit() {
|
||||||
osSupportsAVX = isSet(1, eax) && isSet(2, eax)
|
osSupportsAVX = isSet(1, eax) && isSet(2, eax)
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
// Darwin doesn't save/restore AVX-512 mask registers correctly across signal handlers.
|
// Darwin requires special AVX512 checks, see cpu_darwin_x86.go
|
||||||
// Since users can't rely on mask register contents, let's not advertise AVX-512 support.
|
osSupportsAVX512 = osSupportsAVX && darwinSupportsAVX512()
|
||||||
// See issue 49233.
|
|
||||||
osSupportsAVX512 = false
|
|
||||||
} else {
|
} else {
|
||||||
// Check if OPMASK and ZMM registers have OS support.
|
// Check if OPMASK and ZMM registers have OS support.
|
||||||
osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax)
|
osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax)
|
||||||
|
|
@ -108,7 +109,7 @@ func archInit() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ebx7, ecx7, edx7 := cpuid(7, 0)
|
eax7, ebx7, ecx7, edx7 := cpuid(7, 0)
|
||||||
X86.HasBMI1 = isSet(3, ebx7)
|
X86.HasBMI1 = isSet(3, ebx7)
|
||||||
X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX
|
X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX
|
||||||
X86.HasBMI2 = isSet(8, ebx7)
|
X86.HasBMI2 = isSet(8, ebx7)
|
||||||
|
|
@ -136,14 +137,24 @@ func archInit() {
|
||||||
X86.HasAVX512VAES = isSet(9, ecx7)
|
X86.HasAVX512VAES = isSet(9, ecx7)
|
||||||
X86.HasAVX512VBMI2 = isSet(6, ecx7)
|
X86.HasAVX512VBMI2 = isSet(6, ecx7)
|
||||||
X86.HasAVX512BITALG = isSet(12, ecx7)
|
X86.HasAVX512BITALG = isSet(12, ecx7)
|
||||||
|
|
||||||
eax71, _, _, _ := cpuid(7, 1)
|
|
||||||
X86.HasAVX512BF16 = isSet(5, eax71)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
X86.HasAMXTile = isSet(24, edx7)
|
X86.HasAMXTile = isSet(24, edx7)
|
||||||
X86.HasAMXInt8 = isSet(25, edx7)
|
X86.HasAMXInt8 = isSet(25, edx7)
|
||||||
X86.HasAMXBF16 = isSet(22, edx7)
|
X86.HasAMXBF16 = isSet(22, edx7)
|
||||||
|
|
||||||
|
// These features depend on the second level of extended features.
|
||||||
|
if eax7 >= 1 {
|
||||||
|
eax71, _, _, edx71 := cpuid(7, 1)
|
||||||
|
if X86.HasAVX512 {
|
||||||
|
X86.HasAVX512BF16 = isSet(5, eax71)
|
||||||
|
}
|
||||||
|
if X86.HasAVX {
|
||||||
|
X86.HasAVXIFMA = isSet(23, eax71)
|
||||||
|
X86.HasAVXVNNI = isSet(4, eax71)
|
||||||
|
X86.HasAVXVNNIInt8 = isSet(4, edx71)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isSet(bitpos uint, value uint32) bool {
|
func isSet(bitpos uint, value uint32) bool {
|
||||||
|
|
|
||||||
4
vendor/golang.org/x/sys/cpu/parse.go
generated
vendored
4
vendor/golang.org/x/sys/cpu/parse.go
generated
vendored
|
|
@ -13,7 +13,7 @@ import "strconv"
|
||||||
// https://golang.org/cl/209597.
|
// https://golang.org/cl/209597.
|
||||||
func parseRelease(rel string) (major, minor, patch int, ok bool) {
|
func parseRelease(rel string) (major, minor, patch int, ok bool) {
|
||||||
// Strip anything after a dash or plus.
|
// Strip anything after a dash or plus.
|
||||||
for i := 0; i < len(rel); i++ {
|
for i := range len(rel) {
|
||||||
if rel[i] == '-' || rel[i] == '+' {
|
if rel[i] == '-' || rel[i] == '+' {
|
||||||
rel = rel[:i]
|
rel = rel[:i]
|
||||||
break
|
break
|
||||||
|
|
@ -21,7 +21,7 @@ func parseRelease(rel string) (major, minor, patch int, ok bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
next := func() (int, bool) {
|
next := func() (int, bool) {
|
||||||
for i := 0; i < len(rel); i++ {
|
for i := range len(rel) {
|
||||||
if rel[i] == '.' {
|
if rel[i] == '.' {
|
||||||
ver, err := strconv.Atoi(rel[:i])
|
ver, err := strconv.Atoi(rel[:i])
|
||||||
rel = rel[i+1:]
|
rel = rel[i+1:]
|
||||||
|
|
|
||||||
98
vendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go
generated
vendored
Normal file
98
vendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go
generated
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Minimal copy of x/sys/unix so the cpu package can make a
|
||||||
|
// system call on Darwin without depending on x/sys/unix.
|
||||||
|
|
||||||
|
//go:build darwin && amd64 && gc
|
||||||
|
|
||||||
|
package cpu
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
type _C_int int32
|
||||||
|
|
||||||
|
// adapted from unix.Uname() at x/sys/unix/syscall_darwin.go L419
|
||||||
|
func darwinOSRelease(release *[256]byte) error {
|
||||||
|
// from x/sys/unix/zerrors_openbsd_amd64.go
|
||||||
|
const (
|
||||||
|
CTL_KERN = 0x1
|
||||||
|
KERN_OSRELEASE = 0x2
|
||||||
|
)
|
||||||
|
|
||||||
|
mib := []_C_int{CTL_KERN, KERN_OSRELEASE}
|
||||||
|
n := unsafe.Sizeof(*release)
|
||||||
|
|
||||||
|
return sysctl(mib, &release[0], &n, nil, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Errno = syscall.Errno
|
||||||
|
|
||||||
|
var _zero uintptr // Single-word zero for use when we need a valid pointer to 0 bytes.
|
||||||
|
|
||||||
|
// from x/sys/unix/zsyscall_darwin_amd64.go L791-807
|
||||||
|
func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
|
||||||
|
var _p0 unsafe.Pointer
|
||||||
|
if len(mib) > 0 {
|
||||||
|
_p0 = unsafe.Pointer(&mib[0])
|
||||||
|
} else {
|
||||||
|
_p0 = unsafe.Pointer(&_zero)
|
||||||
|
}
|
||||||
|
if _, _, err := syscall_syscall6(
|
||||||
|
libc_sysctl_trampoline_addr,
|
||||||
|
uintptr(_p0),
|
||||||
|
uintptr(len(mib)),
|
||||||
|
uintptr(unsafe.Pointer(old)),
|
||||||
|
uintptr(unsafe.Pointer(oldlen)),
|
||||||
|
uintptr(unsafe.Pointer(new)),
|
||||||
|
uintptr(newlen),
|
||||||
|
); err != 0 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var libc_sysctl_trampoline_addr uintptr
|
||||||
|
|
||||||
|
// adapted from internal/cpu/cpu_arm64_darwin.go
|
||||||
|
func darwinSysctlEnabled(name []byte) bool {
|
||||||
|
out := int32(0)
|
||||||
|
nout := unsafe.Sizeof(out)
|
||||||
|
if ret := sysctlbyname(&name[0], (*byte)(unsafe.Pointer(&out)), &nout, nil, 0); ret != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return out > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
|
var libc_sysctlbyname_trampoline_addr uintptr
|
||||||
|
|
||||||
|
// adapted from runtime/sys_darwin.go in the pattern of sysctl() above, as defined in x/sys/unix
|
||||||
|
func sysctlbyname(name *byte, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
|
||||||
|
if _, _, err := syscall_syscall6(
|
||||||
|
libc_sysctlbyname_trampoline_addr,
|
||||||
|
uintptr(unsafe.Pointer(name)),
|
||||||
|
uintptr(unsafe.Pointer(old)),
|
||||||
|
uintptr(unsafe.Pointer(oldlen)),
|
||||||
|
uintptr(unsafe.Pointer(new)),
|
||||||
|
uintptr(newlen),
|
||||||
|
0,
|
||||||
|
); err != 0 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//go:cgo_import_dynamic libc_sysctlbyname sysctlbyname "/usr/lib/libSystem.B.dylib"
|
||||||
|
|
||||||
|
// Implemented in the runtime package (runtime/sys_darwin.go)
|
||||||
|
func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
|
||||||
|
|
||||||
|
//go:linkname syscall_syscall6 syscall.syscall6
|
||||||
2
vendor/golang.org/x/sys/unix/README.md
generated
vendored
2
vendor/golang.org/x/sys/unix/README.md
generated
vendored
|
|
@ -156,7 +156,7 @@ from the generated architecture-specific files listed below, and merge these
|
||||||
into a common file for each OS.
|
into a common file for each OS.
|
||||||
|
|
||||||
The merge is performed in the following steps:
|
The merge is performed in the following steps:
|
||||||
1. Construct the set of common code that is idential in all architecture-specific files.
|
1. Construct the set of common code that is identical in all architecture-specific files.
|
||||||
2. Write this common code to the merged file.
|
2. Write this common code to the merged file.
|
||||||
3. Remove the common code from all architecture-specific files.
|
3. Remove the common code from all architecture-specific files.
|
||||||
|
|
||||||
|
|
|
||||||
36
vendor/golang.org/x/sys/unix/auxv.go
generated
vendored
Normal file
36
vendor/golang.org/x/sys/unix/auxv.go
generated
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2025 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:linkname runtime_getAuxv runtime.getAuxv
|
||||||
|
func runtime_getAuxv() []uintptr
|
||||||
|
|
||||||
|
// Auxv returns the ELF auxiliary vector as a sequence of key/value pairs.
|
||||||
|
// The returned slice is always a fresh copy, owned by the caller.
|
||||||
|
// It returns an error on non-ELF platforms, or if the auxiliary vector cannot be accessed,
|
||||||
|
// which happens in some locked-down environments and build modes.
|
||||||
|
func Auxv() ([][2]uintptr, error) {
|
||||||
|
vec := runtime_getAuxv()
|
||||||
|
vecLen := len(vec)
|
||||||
|
|
||||||
|
if vecLen == 0 {
|
||||||
|
return nil, syscall.ENOENT
|
||||||
|
}
|
||||||
|
|
||||||
|
if vecLen%2 != 0 {
|
||||||
|
return nil, syscall.EINVAL
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make([]uintptr, vecLen)
|
||||||
|
copy(result, vec)
|
||||||
|
return unsafe.Slice((*[2]uintptr)(unsafe.Pointer(&result[0])), vecLen/2), nil
|
||||||
|
}
|
||||||
13
vendor/golang.org/x/sys/unix/auxv_unsupported.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/auxv_unsupported.go
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2025 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !go1.21 && (aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos)
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func Auxv() ([][2]uintptr, error) {
|
||||||
|
return nil, syscall.ENOTSUP
|
||||||
|
}
|
||||||
96
vendor/golang.org/x/sys/unix/ioctl_linux.go
generated
vendored
96
vendor/golang.org/x/sys/unix/ioctl_linux.go
generated
vendored
|
|
@ -58,6 +58,102 @@ func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
|
||||||
return &value, err
|
return &value, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IoctlGetEthtoolTsInfo fetches ethtool timestamping and PHC
|
||||||
|
// association for the network device specified by ifname.
|
||||||
|
func IoctlGetEthtoolTsInfo(fd int, ifname string) (*EthtoolTsInfo, error) {
|
||||||
|
ifr, err := NewIfreq(ifname)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
value := EthtoolTsInfo{Cmd: ETHTOOL_GET_TS_INFO}
|
||||||
|
ifrd := ifr.withData(unsafe.Pointer(&value))
|
||||||
|
|
||||||
|
err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetHwTstamp retrieves the hardware timestamping configuration
|
||||||
|
// for the network device specified by ifname.
|
||||||
|
func IoctlGetHwTstamp(fd int, ifname string) (*HwTstampConfig, error) {
|
||||||
|
ifr, err := NewIfreq(ifname)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
value := HwTstampConfig{}
|
||||||
|
ifrd := ifr.withData(unsafe.Pointer(&value))
|
||||||
|
|
||||||
|
err = ioctlIfreqData(fd, SIOCGHWTSTAMP, &ifrd)
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlSetHwTstamp updates the hardware timestamping configuration for
|
||||||
|
// the network device specified by ifname.
|
||||||
|
func IoctlSetHwTstamp(fd int, ifname string, cfg *HwTstampConfig) error {
|
||||||
|
ifr, err := NewIfreq(ifname)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ifrd := ifr.withData(unsafe.Pointer(cfg))
|
||||||
|
return ioctlIfreqData(fd, SIOCSHWTSTAMP, &ifrd)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FdToClockID derives the clock ID from the file descriptor number
|
||||||
|
// - see clock_gettime(3), FD_TO_CLOCKID macros. The resulting ID is
|
||||||
|
// suitable for system calls like ClockGettime.
|
||||||
|
func FdToClockID(fd int) int32 { return int32((int(^fd) << 3) | 3) }
|
||||||
|
|
||||||
|
// IoctlPtpClockGetcaps returns the description of a given PTP device.
|
||||||
|
func IoctlPtpClockGetcaps(fd int) (*PtpClockCaps, error) {
|
||||||
|
var value PtpClockCaps
|
||||||
|
err := ioctlPtr(fd, PTP_CLOCK_GETCAPS2, unsafe.Pointer(&value))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpSysOffsetPrecise returns a description of the clock
|
||||||
|
// offset compared to the system clock.
|
||||||
|
func IoctlPtpSysOffsetPrecise(fd int) (*PtpSysOffsetPrecise, error) {
|
||||||
|
var value PtpSysOffsetPrecise
|
||||||
|
err := ioctlPtr(fd, PTP_SYS_OFFSET_PRECISE2, unsafe.Pointer(&value))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpSysOffsetExtended returns an extended description of the
|
||||||
|
// clock offset compared to the system clock. The samples parameter
|
||||||
|
// specifies the desired number of measurements.
|
||||||
|
func IoctlPtpSysOffsetExtended(fd int, samples uint) (*PtpSysOffsetExtended, error) {
|
||||||
|
value := PtpSysOffsetExtended{Samples: uint32(samples)}
|
||||||
|
err := ioctlPtr(fd, PTP_SYS_OFFSET_EXTENDED2, unsafe.Pointer(&value))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpPinGetfunc returns the configuration of the specified
|
||||||
|
// I/O pin on given PTP device.
|
||||||
|
func IoctlPtpPinGetfunc(fd int, index uint) (*PtpPinDesc, error) {
|
||||||
|
value := PtpPinDesc{Index: uint32(index)}
|
||||||
|
err := ioctlPtr(fd, PTP_PIN_GETFUNC2, unsafe.Pointer(&value))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpPinSetfunc updates configuration of the specified PTP
|
||||||
|
// I/O pin.
|
||||||
|
func IoctlPtpPinSetfunc(fd int, pd *PtpPinDesc) error {
|
||||||
|
return ioctlPtr(fd, PTP_PIN_SETFUNC2, unsafe.Pointer(pd))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpPeroutRequest configures the periodic output mode of the
|
||||||
|
// PTP I/O pins.
|
||||||
|
func IoctlPtpPeroutRequest(fd int, r *PtpPeroutRequest) error {
|
||||||
|
return ioctlPtr(fd, PTP_PEROUT_REQUEST2, unsafe.Pointer(r))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlPtpExttsRequest configures the external timestamping mode
|
||||||
|
// of the PTP I/O pins.
|
||||||
|
func IoctlPtpExttsRequest(fd int, r *PtpExttsRequest) error {
|
||||||
|
return ioctlPtr(fd, PTP_EXTTS_REQUEST2, unsafe.Pointer(r))
|
||||||
|
}
|
||||||
|
|
||||||
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
||||||
// Linux watchdog API. For more information, see:
|
// Linux watchdog API. For more information, see:
|
||||||
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||||
|
|
|
||||||
19
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
19
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
|
|
@ -158,6 +158,16 @@ includes_Linux='
|
||||||
#endif
|
#endif
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
// See the description in unix/linux/types.go
|
||||||
|
#if defined(__ARM_EABI__) || \
|
||||||
|
(defined(__mips__) && (_MIPS_SIM == _ABIO32)) || \
|
||||||
|
(defined(__powerpc__) && (!defined(__powerpc64__)))
|
||||||
|
# ifdef _TIME_BITS
|
||||||
|
# undef _TIME_BITS
|
||||||
|
# endif
|
||||||
|
# define _TIME_BITS 32
|
||||||
|
#endif
|
||||||
|
|
||||||
// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
|
// <sys/ioctl.h> is broken on powerpc64, as it fails to include definitions of
|
||||||
// these structures. We just include them copied from <bits/termios.h>.
|
// these structures. We just include them copied from <bits/termios.h>.
|
||||||
#if defined(__powerpc__)
|
#if defined(__powerpc__)
|
||||||
|
|
@ -256,6 +266,7 @@ struct ltchars {
|
||||||
#include <linux/nsfs.h>
|
#include <linux/nsfs.h>
|
||||||
#include <linux/perf_event.h>
|
#include <linux/perf_event.h>
|
||||||
#include <linux/pps.h>
|
#include <linux/pps.h>
|
||||||
|
#include <linux/ptp_clock.h>
|
||||||
#include <linux/ptrace.h>
|
#include <linux/ptrace.h>
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
|
|
@ -338,6 +349,9 @@ struct ltchars {
|
||||||
#define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN)
|
#define _HIDIOCGRAWPHYS HIDIOCGRAWPHYS(_HIDIOCGRAWPHYS_LEN)
|
||||||
#define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN)
|
#define _HIDIOCGRAWUNIQ HIDIOCGRAWUNIQ(_HIDIOCGRAWUNIQ_LEN)
|
||||||
|
|
||||||
|
// Renamed in v6.16, commit c6d732c38f93 ("net: ethtool: remove duplicate defines for family info")
|
||||||
|
#define ETHTOOL_FAMILY_NAME ETHTOOL_GENL_NAME
|
||||||
|
#define ETHTOOL_FAMILY_VERSION ETHTOOL_GENL_VERSION
|
||||||
'
|
'
|
||||||
|
|
||||||
includes_NetBSD='
|
includes_NetBSD='
|
||||||
|
|
@ -527,6 +541,7 @@ ccflags="$@"
|
||||||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ ||
|
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ ||
|
||||||
$2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
|
$2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ ||
|
||||||
$2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
|
$2 ~ /^NFC_.*_(MAX)?SIZE$/ ||
|
||||||
|
$2 ~ /^PTP_/ ||
|
||||||
$2 ~ /^RAW_PAYLOAD_/ ||
|
$2 ~ /^RAW_PAYLOAD_/ ||
|
||||||
$2 ~ /^[US]F_/ ||
|
$2 ~ /^[US]F_/ ||
|
||||||
$2 ~ /^TP_STATUS_/ ||
|
$2 ~ /^TP_STATUS_/ ||
|
||||||
|
|
@ -656,7 +671,7 @@ errors=$(
|
||||||
signals=$(
|
signals=$(
|
||||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' |
|
||||||
grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' |
|
grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
|
||||||
sort
|
sort
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -666,7 +681,7 @@ echo '#include <errno.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
sort >_error.grep
|
sort >_error.grep
|
||||||
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
echo '#include <signal.h>' | $CC -x c - -E -dM $ccflags |
|
||||||
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' |
|
||||||
grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' |
|
grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' |
|
||||||
sort >_signal.grep
|
sort >_signal.grep
|
||||||
|
|
||||||
echo '// mkerrors.sh' "$@"
|
echo '// mkerrors.sh' "$@"
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
|
|
@ -360,7 +360,7 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int,
|
||||||
var status _C_int
|
var status _C_int
|
||||||
var r Pid_t
|
var r Pid_t
|
||||||
err = ERESTART
|
err = ERESTART
|
||||||
// AIX wait4 may return with ERESTART errno, while the processus is still
|
// AIX wait4 may return with ERESTART errno, while the process is still
|
||||||
// active.
|
// active.
|
||||||
for err == ERESTART {
|
for err == ERESTART {
|
||||||
r, err = wait4(Pid_t(pid), &status, options, rusage)
|
r, err = wait4(Pid_t(pid), &status, options, rusage)
|
||||||
|
|
|
||||||
93
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
93
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
|
|
@ -602,6 +602,95 @@ func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocI
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const minIovec = 8
|
||||||
|
|
||||||
|
func Readv(fd int, iovs [][]byte) (n int, err error) {
|
||||||
|
iovecs := make([]Iovec, 0, minIovec)
|
||||||
|
iovecs = appendBytes(iovecs, iovs)
|
||||||
|
n, err = readv(fd, iovecs)
|
||||||
|
readvRacedetect(iovecs, n, err)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Preadv(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
||||||
|
iovecs := make([]Iovec, 0, minIovec)
|
||||||
|
iovecs = appendBytes(iovecs, iovs)
|
||||||
|
n, err = preadv(fd, iovecs, offset)
|
||||||
|
readvRacedetect(iovecs, n, err)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Writev(fd int, iovs [][]byte) (n int, err error) {
|
||||||
|
iovecs := make([]Iovec, 0, minIovec)
|
||||||
|
iovecs = appendBytes(iovecs, iovs)
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
n, err = writev(fd, iovecs)
|
||||||
|
writevRacedetect(iovecs, n)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func Pwritev(fd int, iovs [][]byte, offset int64) (n int, err error) {
|
||||||
|
iovecs := make([]Iovec, 0, minIovec)
|
||||||
|
iovecs = appendBytes(iovecs, iovs)
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
n, err = pwritev(fd, iovecs, offset)
|
||||||
|
writevRacedetect(iovecs, n)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func appendBytes(vecs []Iovec, bs [][]byte) []Iovec {
|
||||||
|
for _, b := range bs {
|
||||||
|
var v Iovec
|
||||||
|
v.SetLen(len(b))
|
||||||
|
if len(b) > 0 {
|
||||||
|
v.Base = &b[0]
|
||||||
|
} else {
|
||||||
|
v.Base = (*byte)(unsafe.Pointer(&_zero))
|
||||||
|
}
|
||||||
|
vecs = append(vecs, v)
|
||||||
|
}
|
||||||
|
return vecs
|
||||||
|
}
|
||||||
|
|
||||||
|
func writevRacedetect(iovecs []Iovec, n int) {
|
||||||
|
if !raceenabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||||
|
m := int(iovecs[i].Len)
|
||||||
|
if m > n {
|
||||||
|
m = n
|
||||||
|
}
|
||||||
|
n -= m
|
||||||
|
if m > 0 {
|
||||||
|
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func readvRacedetect(iovecs []Iovec, n int, err error) {
|
||||||
|
if !raceenabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||||
|
m := int(iovecs[i].Len)
|
||||||
|
if m > n {
|
||||||
|
m = n
|
||||||
|
}
|
||||||
|
n -= m
|
||||||
|
if m > 0 {
|
||||||
|
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
raceAcquire(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
|
//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error)
|
||||||
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
|
//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
|
||||||
|
|
||||||
|
|
@ -705,3 +794,7 @@ func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocI
|
||||||
//sys write(fd int, p []byte) (n int, err error)
|
//sys write(fd int, p []byte) (n int, err error)
|
||||||
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
|
||||||
//sys munmap(addr uintptr, length uintptr) (err error)
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
//sys readv(fd int, iovecs []Iovec) (n int, err error)
|
||||||
|
//sys preadv(fd int, iovecs []Iovec, offset int64) (n int, err error)
|
||||||
|
//sys writev(fd int, iovecs []Iovec) (n int, err error)
|
||||||
|
//sys pwritev(fd int, iovecs []Iovec, offset int64) (n int, err error)
|
||||||
|
|
|
||||||
12
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
12
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
|
|
@ -246,6 +246,18 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||||
return sendfile(outfd, infd, offset, count)
|
return sendfile(outfd, infd, offset, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Dup3(oldfd, newfd, flags int) error {
|
||||||
|
if oldfd == newfd || flags&^O_CLOEXEC != 0 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
how := F_DUP2FD
|
||||||
|
if flags&O_CLOEXEC != 0 {
|
||||||
|
how = F_DUP2FD_CLOEXEC
|
||||||
|
}
|
||||||
|
_, err := fcntl(oldfd, how, newfd)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exposed directly
|
* Exposed directly
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
106
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
106
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
|
|
@ -13,6 +13,7 @@ package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -417,7 +418,7 @@ func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
return nil, 0, EINVAL
|
return nil, 0, EINVAL
|
||||||
}
|
}
|
||||||
sa.raw.Family = AF_UNIX
|
sa.raw.Family = AF_UNIX
|
||||||
for i := 0; i < n; i++ {
|
for i := range n {
|
||||||
sa.raw.Path[i] = int8(name[i])
|
sa.raw.Path[i] = int8(name[i])
|
||||||
}
|
}
|
||||||
// length is family (uint16), name, NUL.
|
// length is family (uint16), name, NUL.
|
||||||
|
|
@ -507,7 +508,7 @@ func (sa *SockaddrL2) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
psm := (*[2]byte)(unsafe.Pointer(&sa.raw.Psm))
|
psm := (*[2]byte)(unsafe.Pointer(&sa.raw.Psm))
|
||||||
psm[0] = byte(sa.PSM)
|
psm[0] = byte(sa.PSM)
|
||||||
psm[1] = byte(sa.PSM >> 8)
|
psm[1] = byte(sa.PSM >> 8)
|
||||||
for i := 0; i < len(sa.Addr); i++ {
|
for i := range len(sa.Addr) {
|
||||||
sa.raw.Bdaddr[i] = sa.Addr[len(sa.Addr)-1-i]
|
sa.raw.Bdaddr[i] = sa.Addr[len(sa.Addr)-1-i]
|
||||||
}
|
}
|
||||||
cid := (*[2]byte)(unsafe.Pointer(&sa.raw.Cid))
|
cid := (*[2]byte)(unsafe.Pointer(&sa.raw.Cid))
|
||||||
|
|
@ -589,11 +590,11 @@ func (sa *SockaddrCAN) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
sa.raw.Family = AF_CAN
|
sa.raw.Family = AF_CAN
|
||||||
sa.raw.Ifindex = int32(sa.Ifindex)
|
sa.raw.Ifindex = int32(sa.Ifindex)
|
||||||
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID))
|
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID))
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
sa.raw.Addr[i] = rx[i]
|
sa.raw.Addr[i] = rx[i]
|
||||||
}
|
}
|
||||||
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID))
|
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID))
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
sa.raw.Addr[i+4] = tx[i]
|
sa.raw.Addr[i+4] = tx[i]
|
||||||
}
|
}
|
||||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrCAN, nil
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrCAN, nil
|
||||||
|
|
@ -618,11 +619,11 @@ func (sa *SockaddrCANJ1939) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
sa.raw.Family = AF_CAN
|
sa.raw.Family = AF_CAN
|
||||||
sa.raw.Ifindex = int32(sa.Ifindex)
|
sa.raw.Ifindex = int32(sa.Ifindex)
|
||||||
n := (*[8]byte)(unsafe.Pointer(&sa.Name))
|
n := (*[8]byte)(unsafe.Pointer(&sa.Name))
|
||||||
for i := 0; i < 8; i++ {
|
for i := range 8 {
|
||||||
sa.raw.Addr[i] = n[i]
|
sa.raw.Addr[i] = n[i]
|
||||||
}
|
}
|
||||||
p := (*[4]byte)(unsafe.Pointer(&sa.PGN))
|
p := (*[4]byte)(unsafe.Pointer(&sa.PGN))
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
sa.raw.Addr[i+8] = p[i]
|
sa.raw.Addr[i+8] = p[i]
|
||||||
}
|
}
|
||||||
sa.raw.Addr[12] = sa.Addr
|
sa.raw.Addr[12] = sa.Addr
|
||||||
|
|
@ -911,7 +912,7 @@ func (sa *SockaddrIUCV) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
// These are EBCDIC encoded by the kernel, but we still need to pad them
|
// These are EBCDIC encoded by the kernel, but we still need to pad them
|
||||||
// with blanks. Initializing with blanks allows the caller to feed in either
|
// with blanks. Initializing with blanks allows the caller to feed in either
|
||||||
// a padded or an unpadded string.
|
// a padded or an unpadded string.
|
||||||
for i := 0; i < 8; i++ {
|
for i := range 8 {
|
||||||
sa.raw.Nodeid[i] = ' '
|
sa.raw.Nodeid[i] = ' '
|
||||||
sa.raw.User_id[i] = ' '
|
sa.raw.User_id[i] = ' '
|
||||||
sa.raw.Name[i] = ' '
|
sa.raw.Name[i] = ' '
|
||||||
|
|
@ -1148,7 +1149,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
var user [8]byte
|
var user [8]byte
|
||||||
var name [8]byte
|
var name [8]byte
|
||||||
|
|
||||||
for i := 0; i < 8; i++ {
|
for i := range 8 {
|
||||||
user[i] = byte(pp.User_id[i])
|
user[i] = byte(pp.User_id[i])
|
||||||
name[i] = byte(pp.Name[i])
|
name[i] = byte(pp.Name[i])
|
||||||
}
|
}
|
||||||
|
|
@ -1173,11 +1174,11 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
Ifindex: int(pp.Ifindex),
|
Ifindex: int(pp.Ifindex),
|
||||||
}
|
}
|
||||||
name := (*[8]byte)(unsafe.Pointer(&sa.Name))
|
name := (*[8]byte)(unsafe.Pointer(&sa.Name))
|
||||||
for i := 0; i < 8; i++ {
|
for i := range 8 {
|
||||||
name[i] = pp.Addr[i]
|
name[i] = pp.Addr[i]
|
||||||
}
|
}
|
||||||
pgn := (*[4]byte)(unsafe.Pointer(&sa.PGN))
|
pgn := (*[4]byte)(unsafe.Pointer(&sa.PGN))
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
pgn[i] = pp.Addr[i+8]
|
pgn[i] = pp.Addr[i+8]
|
||||||
}
|
}
|
||||||
addr := (*[1]byte)(unsafe.Pointer(&sa.Addr))
|
addr := (*[1]byte)(unsafe.Pointer(&sa.Addr))
|
||||||
|
|
@ -1188,11 +1189,11 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
Ifindex: int(pp.Ifindex),
|
Ifindex: int(pp.Ifindex),
|
||||||
}
|
}
|
||||||
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID))
|
rx := (*[4]byte)(unsafe.Pointer(&sa.RxID))
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
rx[i] = pp.Addr[i]
|
rx[i] = pp.Addr[i]
|
||||||
}
|
}
|
||||||
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID))
|
tx := (*[4]byte)(unsafe.Pointer(&sa.TxID))
|
||||||
for i := 0; i < 4; i++ {
|
for i := range 4 {
|
||||||
tx[i] = pp.Addr[i+4]
|
tx[i] = pp.Addr[i+4]
|
||||||
}
|
}
|
||||||
return sa, nil
|
return sa, nil
|
||||||
|
|
@ -1295,6 +1296,48 @@ func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) {
|
||||||
return &value, err
|
return &value, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetsockoptTCPCCVegasInfo returns algorithm specific congestion control information for a socket using the "vegas"
|
||||||
|
// algorithm.
|
||||||
|
//
|
||||||
|
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||||
|
//
|
||||||
|
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||||
|
func GetsockoptTCPCCVegasInfo(fd, level, opt int) (*TCPVegasInfo, error) {
|
||||||
|
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||||
|
vallen := _Socklen(SizeofTCPCCInfo)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||||
|
out := (*TCPVegasInfo)(unsafe.Pointer(&value[0]))
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetsockoptTCPCCDCTCPInfo returns algorithm specific congestion control information for a socket using the "dctp"
|
||||||
|
// algorithm.
|
||||||
|
//
|
||||||
|
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||||
|
//
|
||||||
|
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||||
|
func GetsockoptTCPCCDCTCPInfo(fd, level, opt int) (*TCPDCTCPInfo, error) {
|
||||||
|
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||||
|
vallen := _Socklen(SizeofTCPCCInfo)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||||
|
out := (*TCPDCTCPInfo)(unsafe.Pointer(&value[0]))
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetsockoptTCPCCBBRInfo returns algorithm specific congestion control information for a socket using the "bbr"
|
||||||
|
// algorithm.
|
||||||
|
//
|
||||||
|
// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option:
|
||||||
|
//
|
||||||
|
// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION)
|
||||||
|
func GetsockoptTCPCCBBRInfo(fd, level, opt int) (*TCPBBRInfo, error) {
|
||||||
|
var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment
|
||||||
|
vallen := _Socklen(SizeofTCPCCInfo)
|
||||||
|
err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||||
|
out := (*TCPBBRInfo)(unsafe.Pointer(&value[0]))
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
// GetsockoptString returns the string value of the socket option opt for the
|
// GetsockoptString returns the string value of the socket option opt for the
|
||||||
// socket associated with fd at the given socket level.
|
// socket associated with fd at the given socket level.
|
||||||
func GetsockoptString(fd, level, opt int) (string, error) {
|
func GetsockoptString(fd, level, opt int) (string, error) {
|
||||||
|
|
@ -1818,6 +1861,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
||||||
//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
|
//sys ClockAdjtime(clockid int32, buf *Timex) (state int, err error)
|
||||||
//sys ClockGetres(clockid int32, res *Timespec) (err error)
|
//sys ClockGetres(clockid int32, res *Timespec) (err error)
|
||||||
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
||||||
|
//sys ClockSettime(clockid int32, time *Timespec) (err error)
|
||||||
//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
|
//sys ClockNanosleep(clockid int32, flags int, request *Timespec, remain *Timespec) (err error)
|
||||||
//sys Close(fd int) (err error)
|
//sys Close(fd int) (err error)
|
||||||
//sys CloseRange(first uint, last uint, flags uint) (err error)
|
//sys CloseRange(first uint, last uint, flags uint) (err error)
|
||||||
|
|
@ -1959,7 +2003,26 @@ func Getpgrp() (pid int) {
|
||||||
//sysnb Getpid() (pid int)
|
//sysnb Getpid() (pid int)
|
||||||
//sysnb Getppid() (ppid int)
|
//sysnb Getppid() (ppid int)
|
||||||
//sys Getpriority(which int, who int) (prio int, err error)
|
//sys Getpriority(which int, who int) (prio int, err error)
|
||||||
//sys Getrandom(buf []byte, flags int) (n int, err error)
|
|
||||||
|
func Getrandom(buf []byte, flags int) (n int, err error) {
|
||||||
|
vdsoRet, supported := vgetrandom(buf, uint32(flags))
|
||||||
|
if supported {
|
||||||
|
if vdsoRet < 0 {
|
||||||
|
return 0, errnoErr(syscall.Errno(-vdsoRet))
|
||||||
|
}
|
||||||
|
return vdsoRet, nil
|
||||||
|
}
|
||||||
|
var p *byte
|
||||||
|
if len(buf) > 0 {
|
||||||
|
p = &buf[0]
|
||||||
|
}
|
||||||
|
r, _, e := Syscall(SYS_GETRANDOM, uintptr(unsafe.Pointer(p)), uintptr(len(buf)), uintptr(flags))
|
||||||
|
if e != 0 {
|
||||||
|
return 0, errnoErr(e)
|
||||||
|
}
|
||||||
|
return int(r), nil
|
||||||
|
}
|
||||||
|
|
||||||
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
//sysnb Getrusage(who int, rusage *Rusage) (err error)
|
||||||
//sysnb Getsid(pid int) (sid int, err error)
|
//sysnb Getsid(pid int) (sid int, err error)
|
||||||
//sysnb Gettid() (tid int)
|
//sysnb Gettid() (tid int)
|
||||||
|
|
@ -2154,10 +2217,7 @@ func readvRacedetect(iovecs []Iovec, n int, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := 0; n > 0 && i < len(iovecs); i++ {
|
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||||
m := int(iovecs[i].Len)
|
m := min(int(iovecs[i].Len), n)
|
||||||
if m > n {
|
|
||||||
m = n
|
|
||||||
}
|
|
||||||
n -= m
|
n -= m
|
||||||
if m > 0 {
|
if m > 0 {
|
||||||
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
|
raceWriteRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||||
|
|
@ -2208,10 +2268,7 @@ func writevRacedetect(iovecs []Iovec, n int) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for i := 0; n > 0 && i < len(iovecs); i++ {
|
for i := 0; n > 0 && i < len(iovecs); i++ {
|
||||||
m := int(iovecs[i].Len)
|
m := min(int(iovecs[i].Len), n)
|
||||||
if m > n {
|
|
||||||
m = n
|
|
||||||
}
|
|
||||||
n -= m
|
n -= m
|
||||||
if m > 0 {
|
if m > 0 {
|
||||||
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
|
raceReadRange(unsafe.Pointer(iovecs[i].Base), m)
|
||||||
|
|
@ -2258,12 +2315,7 @@ func isGroupMember(gid int) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, g := range groups {
|
return slices.Contains(groups, gid)
|
||||||
if g == gid {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func isCapDacOverrideSet() bool {
|
func isCapDacOverrideSet() bool {
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
generated
vendored
|
|
@ -182,3 +182,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
|
||||||
}
|
}
|
||||||
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/sys/unix/syscall_linux_loong64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_loong64.go
generated
vendored
|
|
@ -214,3 +214,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error
|
||||||
}
|
}
|
||||||
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||||
|
|
|
||||||
2
vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
generated
vendored
|
|
@ -187,3 +187,5 @@ func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error
|
||||||
}
|
}
|
||||||
return riscvHWProbe(pairs, setSize, set, flags)
|
return riscvHWProbe(pairs, setSize, set, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SYS_FSTATAT = SYS_NEWFSTATAT
|
||||||
|
|
|
||||||
87
vendor/golang.org/x/sys/unix/syscall_solaris.go
generated
vendored
87
vendor/golang.org/x/sys/unix/syscall_solaris.go
generated
vendored
|
|
@ -1102,3 +1102,90 @@ func (s *Strioctl) SetInt(i int) {
|
||||||
func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) {
|
func IoctlSetStrioctlRetInt(fd int, req int, s *Strioctl) (int, error) {
|
||||||
return ioctlPtrRet(fd, req, unsafe.Pointer(s))
|
return ioctlPtrRet(fd, req, unsafe.Pointer(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ucred Helpers
|
||||||
|
// See ucred(3c) and getpeerucred(3c)
|
||||||
|
|
||||||
|
//sys getpeerucred(fd uintptr, ucred *uintptr) (err error)
|
||||||
|
//sys ucredFree(ucred uintptr) = ucred_free
|
||||||
|
//sys ucredGet(pid int) (ucred uintptr, err error) = ucred_get
|
||||||
|
//sys ucredGeteuid(ucred uintptr) (uid int) = ucred_geteuid
|
||||||
|
//sys ucredGetegid(ucred uintptr) (gid int) = ucred_getegid
|
||||||
|
//sys ucredGetruid(ucred uintptr) (uid int) = ucred_getruid
|
||||||
|
//sys ucredGetrgid(ucred uintptr) (gid int) = ucred_getrgid
|
||||||
|
//sys ucredGetsuid(ucred uintptr) (uid int) = ucred_getsuid
|
||||||
|
//sys ucredGetsgid(ucred uintptr) (gid int) = ucred_getsgid
|
||||||
|
//sys ucredGetpid(ucred uintptr) (pid int) = ucred_getpid
|
||||||
|
|
||||||
|
// Ucred is an opaque struct that holds user credentials.
|
||||||
|
type Ucred struct {
|
||||||
|
ucred uintptr
|
||||||
|
}
|
||||||
|
|
||||||
|
// We need to ensure that ucredFree is called on the underlying ucred
|
||||||
|
// when the Ucred is garbage collected.
|
||||||
|
func ucredFinalizer(u *Ucred) {
|
||||||
|
ucredFree(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPeerUcred(fd uintptr) (*Ucred, error) {
|
||||||
|
var ucred uintptr
|
||||||
|
err := getpeerucred(fd, &ucred)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &Ucred{
|
||||||
|
ucred: ucred,
|
||||||
|
}
|
||||||
|
// set the finalizer on the result so that the ucred will be freed
|
||||||
|
runtime.SetFinalizer(result, ucredFinalizer)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func UcredGet(pid int) (*Ucred, error) {
|
||||||
|
ucred, err := ucredGet(pid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &Ucred{
|
||||||
|
ucred: ucred,
|
||||||
|
}
|
||||||
|
// set the finalizer on the result so that the ucred will be freed
|
||||||
|
runtime.SetFinalizer(result, ucredFinalizer)
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Geteuid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGeteuid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getruid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetruid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getsuid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetsuid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getegid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetegid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getrgid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetrgid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getsgid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetsgid(u.ucred)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *Ucred) Getpid() int {
|
||||||
|
defer runtime.KeepAlive(u)
|
||||||
|
return ucredGetpid(u.ucred)
|
||||||
|
}
|
||||||
|
|
|
||||||
104
vendor/golang.org/x/sys/unix/syscall_zos_s390x.go
generated
vendored
104
vendor/golang.org/x/sys/unix/syscall_zos_s390x.go
generated
vendored
|
|
@ -768,6 +768,15 @@ func Munmap(b []byte) (err error) {
|
||||||
return mapper.Munmap(b)
|
return mapper.Munmap(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) {
|
||||||
|
xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset)
|
||||||
|
return unsafe.Pointer(xaddr), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) {
|
||||||
|
return mapper.munmap(uintptr(addr), length)
|
||||||
|
}
|
||||||
|
|
||||||
//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A
|
//sys Gethostname(buf []byte) (err error) = SYS___GETHOSTNAME_A
|
||||||
//sysnb Getgid() (gid int)
|
//sysnb Getgid() (gid int)
|
||||||
//sysnb Getpid() (pid int)
|
//sysnb Getpid() (pid int)
|
||||||
|
|
@ -816,10 +825,10 @@ func Lstat(path string, stat *Stat_t) (err error) {
|
||||||
// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/
|
// for checking symlinks begins with $VERSION/ $SYSNAME/ $SYSSYMR/ $SYSSYMA/
|
||||||
func isSpecialPath(path []byte) (v bool) {
|
func isSpecialPath(path []byte) (v bool) {
|
||||||
var special = [4][8]byte{
|
var special = [4][8]byte{
|
||||||
[8]byte{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
|
{'V', 'E', 'R', 'S', 'I', 'O', 'N', '/'},
|
||||||
[8]byte{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
|
{'S', 'Y', 'S', 'N', 'A', 'M', 'E', '/'},
|
||||||
[8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
|
{'S', 'Y', 'S', 'S', 'Y', 'M', 'R', '/'},
|
||||||
[8]byte{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
|
{'S', 'Y', 'S', 'S', 'Y', 'M', 'A', '/'}}
|
||||||
|
|
||||||
var i, j int
|
var i, j int
|
||||||
for i = 0; i < len(special); i++ {
|
for i = 0; i < len(special); i++ {
|
||||||
|
|
@ -3115,3 +3124,90 @@ func legacy_Mkfifoat(dirfd int, path string, mode uint32) (err error) {
|
||||||
//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT
|
//sys Posix_openpt(oflag int) (fd int, err error) = SYS_POSIX_OPENPT
|
||||||
//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT
|
//sys Grantpt(fildes int) (rc int, err error) = SYS_GRANTPT
|
||||||
//sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT
|
//sys Unlockpt(fildes int) (rc int, err error) = SYS_UNLOCKPT
|
||||||
|
|
||||||
|
func fcntlAsIs(fd uintptr, cmd int, arg uintptr) (val int, err error) {
|
||||||
|
runtime.EnterSyscall()
|
||||||
|
r0, e2, e1 := CallLeFuncWithErr(GetZosLibVec()+SYS_FCNTL<<4, uintptr(fd), uintptr(cmd), arg)
|
||||||
|
runtime.ExitSyscall()
|
||||||
|
val = int(r0)
|
||||||
|
if int64(r0) == -1 {
|
||||||
|
err = errnoErr2(e1, e2)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Fcntl(fd uintptr, cmd int, op interface{}) (ret int, err error) {
|
||||||
|
switch op.(type) {
|
||||||
|
case *Flock_t:
|
||||||
|
err = FcntlFlock(fd, cmd, op.(*Flock_t))
|
||||||
|
if err != nil {
|
||||||
|
ret = -1
|
||||||
|
}
|
||||||
|
return
|
||||||
|
case int:
|
||||||
|
return FcntlInt(fd, cmd, op.(int))
|
||||||
|
case *F_cnvrt:
|
||||||
|
return fcntlAsIs(fd, cmd, uintptr(unsafe.Pointer(op.(*F_cnvrt))))
|
||||||
|
case unsafe.Pointer:
|
||||||
|
return fcntlAsIs(fd, cmd, uintptr(op.(unsafe.Pointer)))
|
||||||
|
default:
|
||||||
|
return -1, EINVAL
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
if raceenabled {
|
||||||
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
}
|
||||||
|
return sendfile(outfd, infd, offset, count)
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
|
// TODO: use LE call instead if the call is implemented
|
||||||
|
originalOffset, err := Seek(infd, 0, SEEK_CUR)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
//start reading data from in_fd
|
||||||
|
if offset != nil {
|
||||||
|
_, err := Seek(infd, *offset, SEEK_SET)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := make([]byte, count)
|
||||||
|
readBuf := make([]byte, 0)
|
||||||
|
var n int = 0
|
||||||
|
for i := 0; i < count; i += n {
|
||||||
|
n, err := Read(infd, buf)
|
||||||
|
if n == 0 {
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
} else { // EOF
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readBuf = append(readBuf, buf...)
|
||||||
|
buf = buf[0:0]
|
||||||
|
}
|
||||||
|
|
||||||
|
n2, err := Write(outfd, readBuf)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//When sendfile() returns, this variable will be set to the
|
||||||
|
// offset of the byte following the last byte that was read.
|
||||||
|
if offset != nil {
|
||||||
|
*offset = *offset + int64(n)
|
||||||
|
// If offset is not NULL, then sendfile() does not modify the file
|
||||||
|
// offset of in_fd
|
||||||
|
_, err := Seek(infd, originalOffset, SEEK_SET)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n2, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
13
vendor/golang.org/x/sys/unix/vgetrandom_linux.go
generated
vendored
Normal file
13
vendor/golang.org/x/sys/unix/vgetrandom_linux.go
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build linux && go1.24
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import _ "unsafe"
|
||||||
|
|
||||||
|
//go:linkname vgetrandom runtime.vgetrandom
|
||||||
|
//go:noescape
|
||||||
|
func vgetrandom(p []byte, flags uint32) (ret int, supported bool)
|
||||||
11
vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go
generated
vendored
Normal file
11
vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go
generated
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Copyright 2024 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build !linux || !go1.24
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
func vgetrandom(p []byte, flags uint32) (ret int, supported bool) {
|
||||||
|
return -1, false
|
||||||
|
}
|
||||||
125
vendor/golang.org/x/sys/unix/zerrors_linux.go
generated
vendored
125
vendor/golang.org/x/sys/unix/zerrors_linux.go
generated
vendored
|
|
@ -319,11 +319,17 @@ const (
|
||||||
AUDIT_INTEGRITY_POLICY_RULE = 0x70f
|
AUDIT_INTEGRITY_POLICY_RULE = 0x70f
|
||||||
AUDIT_INTEGRITY_RULE = 0x70d
|
AUDIT_INTEGRITY_RULE = 0x70d
|
||||||
AUDIT_INTEGRITY_STATUS = 0x70a
|
AUDIT_INTEGRITY_STATUS = 0x70a
|
||||||
|
AUDIT_INTEGRITY_USERSPACE = 0x710
|
||||||
AUDIT_IPC = 0x517
|
AUDIT_IPC = 0x517
|
||||||
AUDIT_IPC_SET_PERM = 0x51f
|
AUDIT_IPC_SET_PERM = 0x51f
|
||||||
|
AUDIT_IPE_ACCESS = 0x58c
|
||||||
|
AUDIT_IPE_CONFIG_CHANGE = 0x58d
|
||||||
|
AUDIT_IPE_POLICY_LOAD = 0x58e
|
||||||
AUDIT_KERNEL = 0x7d0
|
AUDIT_KERNEL = 0x7d0
|
||||||
AUDIT_KERNEL_OTHER = 0x524
|
AUDIT_KERNEL_OTHER = 0x524
|
||||||
AUDIT_KERN_MODULE = 0x532
|
AUDIT_KERN_MODULE = 0x532
|
||||||
|
AUDIT_LANDLOCK_ACCESS = 0x58f
|
||||||
|
AUDIT_LANDLOCK_DOMAIN = 0x590
|
||||||
AUDIT_LAST_FEATURE = 0x1
|
AUDIT_LAST_FEATURE = 0x1
|
||||||
AUDIT_LAST_KERN_ANOM_MSG = 0x707
|
AUDIT_LAST_KERN_ANOM_MSG = 0x707
|
||||||
AUDIT_LAST_USER_MSG = 0x4af
|
AUDIT_LAST_USER_MSG = 0x4af
|
||||||
|
|
@ -488,13 +494,16 @@ const (
|
||||||
BPF_F_BEFORE = 0x8
|
BPF_F_BEFORE = 0x8
|
||||||
BPF_F_ID = 0x20
|
BPF_F_ID = 0x20
|
||||||
BPF_F_NETFILTER_IP_DEFRAG = 0x1
|
BPF_F_NETFILTER_IP_DEFRAG = 0x1
|
||||||
|
BPF_F_PREORDER = 0x40
|
||||||
BPF_F_QUERY_EFFECTIVE = 0x1
|
BPF_F_QUERY_EFFECTIVE = 0x1
|
||||||
|
BPF_F_REDIRECT_FLAGS = 0x19
|
||||||
BPF_F_REPLACE = 0x4
|
BPF_F_REPLACE = 0x4
|
||||||
BPF_F_SLEEPABLE = 0x10
|
BPF_F_SLEEPABLE = 0x10
|
||||||
BPF_F_STRICT_ALIGNMENT = 0x1
|
BPF_F_STRICT_ALIGNMENT = 0x1
|
||||||
BPF_F_TEST_REG_INVARIANTS = 0x80
|
BPF_F_TEST_REG_INVARIANTS = 0x80
|
||||||
BPF_F_TEST_RND_HI32 = 0x4
|
BPF_F_TEST_RND_HI32 = 0x4
|
||||||
BPF_F_TEST_RUN_ON_CPU = 0x1
|
BPF_F_TEST_RUN_ON_CPU = 0x1
|
||||||
|
BPF_F_TEST_SKB_CHECKSUM_COMPLETE = 0x4
|
||||||
BPF_F_TEST_STATE_FREQ = 0x8
|
BPF_F_TEST_STATE_FREQ = 0x8
|
||||||
BPF_F_TEST_XDP_LIVE_FRAMES = 0x2
|
BPF_F_TEST_XDP_LIVE_FRAMES = 0x2
|
||||||
BPF_F_XDP_DEV_BOUND_ONLY = 0x40
|
BPF_F_XDP_DEV_BOUND_ONLY = 0x40
|
||||||
|
|
@ -522,6 +531,7 @@ const (
|
||||||
BPF_LDX = 0x1
|
BPF_LDX = 0x1
|
||||||
BPF_LEN = 0x80
|
BPF_LEN = 0x80
|
||||||
BPF_LL_OFF = -0x200000
|
BPF_LL_OFF = -0x200000
|
||||||
|
BPF_LOAD_ACQ = 0x100
|
||||||
BPF_LSH = 0x60
|
BPF_LSH = 0x60
|
||||||
BPF_MAJOR_VERSION = 0x1
|
BPF_MAJOR_VERSION = 0x1
|
||||||
BPF_MAXINSNS = 0x1000
|
BPF_MAXINSNS = 0x1000
|
||||||
|
|
@ -549,6 +559,7 @@ const (
|
||||||
BPF_RET = 0x6
|
BPF_RET = 0x6
|
||||||
BPF_RSH = 0x70
|
BPF_RSH = 0x70
|
||||||
BPF_ST = 0x2
|
BPF_ST = 0x2
|
||||||
|
BPF_STORE_REL = 0x110
|
||||||
BPF_STX = 0x3
|
BPF_STX = 0x3
|
||||||
BPF_SUB = 0x10
|
BPF_SUB = 0x10
|
||||||
BPF_TAG_SIZE = 0x8
|
BPF_TAG_SIZE = 0x8
|
||||||
|
|
@ -838,9 +849,9 @@ const (
|
||||||
DM_UUID_FLAG = 0x4000
|
DM_UUID_FLAG = 0x4000
|
||||||
DM_UUID_LEN = 0x81
|
DM_UUID_LEN = 0x81
|
||||||
DM_VERSION = 0xc138fd00
|
DM_VERSION = 0xc138fd00
|
||||||
DM_VERSION_EXTRA = "-ioctl (2023-03-01)"
|
DM_VERSION_EXTRA = "-ioctl (2025-04-28)"
|
||||||
DM_VERSION_MAJOR = 0x4
|
DM_VERSION_MAJOR = 0x4
|
||||||
DM_VERSION_MINOR = 0x30
|
DM_VERSION_MINOR = 0x32
|
||||||
DM_VERSION_PATCHLEVEL = 0x0
|
DM_VERSION_PATCHLEVEL = 0x0
|
||||||
DT_BLK = 0x6
|
DT_BLK = 0x6
|
||||||
DT_CHR = 0x2
|
DT_CHR = 0x2
|
||||||
|
|
@ -931,11 +942,10 @@ const (
|
||||||
EPOLL_CTL_MOD = 0x3
|
EPOLL_CTL_MOD = 0x3
|
||||||
EPOLL_IOC_TYPE = 0x8a
|
EPOLL_IOC_TYPE = 0x8a
|
||||||
EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2
|
EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2
|
||||||
ESP_V4_FLOW = 0xa
|
|
||||||
ESP_V6_FLOW = 0xc
|
|
||||||
ETHER_FLOW = 0x12
|
|
||||||
ETHTOOL_BUSINFO_LEN = 0x20
|
ETHTOOL_BUSINFO_LEN = 0x20
|
||||||
ETHTOOL_EROMVERS_LEN = 0x20
|
ETHTOOL_EROMVERS_LEN = 0x20
|
||||||
|
ETHTOOL_FAMILY_NAME = "ethtool"
|
||||||
|
ETHTOOL_FAMILY_VERSION = 0x1
|
||||||
ETHTOOL_FEC_AUTO = 0x2
|
ETHTOOL_FEC_AUTO = 0x2
|
||||||
ETHTOOL_FEC_BASER = 0x10
|
ETHTOOL_FEC_BASER = 0x10
|
||||||
ETHTOOL_FEC_LLRS = 0x20
|
ETHTOOL_FEC_LLRS = 0x20
|
||||||
|
|
@ -1165,6 +1175,7 @@ const (
|
||||||
EXTA = 0xe
|
EXTA = 0xe
|
||||||
EXTB = 0xf
|
EXTB = 0xf
|
||||||
F2FS_SUPER_MAGIC = 0xf2f52010
|
F2FS_SUPER_MAGIC = 0xf2f52010
|
||||||
|
FALLOC_FL_ALLOCATE_RANGE = 0x0
|
||||||
FALLOC_FL_COLLAPSE_RANGE = 0x8
|
FALLOC_FL_COLLAPSE_RANGE = 0x8
|
||||||
FALLOC_FL_INSERT_RANGE = 0x20
|
FALLOC_FL_INSERT_RANGE = 0x20
|
||||||
FALLOC_FL_KEEP_SIZE = 0x1
|
FALLOC_FL_KEEP_SIZE = 0x1
|
||||||
|
|
@ -1197,13 +1208,18 @@ const (
|
||||||
FAN_DENY = 0x2
|
FAN_DENY = 0x2
|
||||||
FAN_ENABLE_AUDIT = 0x40
|
FAN_ENABLE_AUDIT = 0x40
|
||||||
FAN_EPIDFD = -0x2
|
FAN_EPIDFD = -0x2
|
||||||
|
FAN_ERRNO_BITS = 0x8
|
||||||
|
FAN_ERRNO_MASK = 0xff
|
||||||
|
FAN_ERRNO_SHIFT = 0x18
|
||||||
FAN_EVENT_INFO_TYPE_DFID = 0x3
|
FAN_EVENT_INFO_TYPE_DFID = 0x3
|
||||||
FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2
|
FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2
|
||||||
FAN_EVENT_INFO_TYPE_ERROR = 0x5
|
FAN_EVENT_INFO_TYPE_ERROR = 0x5
|
||||||
FAN_EVENT_INFO_TYPE_FID = 0x1
|
FAN_EVENT_INFO_TYPE_FID = 0x1
|
||||||
|
FAN_EVENT_INFO_TYPE_MNT = 0x7
|
||||||
FAN_EVENT_INFO_TYPE_NEW_DFID_NAME = 0xc
|
FAN_EVENT_INFO_TYPE_NEW_DFID_NAME = 0xc
|
||||||
FAN_EVENT_INFO_TYPE_OLD_DFID_NAME = 0xa
|
FAN_EVENT_INFO_TYPE_OLD_DFID_NAME = 0xa
|
||||||
FAN_EVENT_INFO_TYPE_PIDFD = 0x4
|
FAN_EVENT_INFO_TYPE_PIDFD = 0x4
|
||||||
|
FAN_EVENT_INFO_TYPE_RANGE = 0x6
|
||||||
FAN_EVENT_METADATA_LEN = 0x18
|
FAN_EVENT_METADATA_LEN = 0x18
|
||||||
FAN_EVENT_ON_CHILD = 0x8000000
|
FAN_EVENT_ON_CHILD = 0x8000000
|
||||||
FAN_FS_ERROR = 0x8000
|
FAN_FS_ERROR = 0x8000
|
||||||
|
|
@ -1218,9 +1234,12 @@ const (
|
||||||
FAN_MARK_IGNORED_SURV_MODIFY = 0x40
|
FAN_MARK_IGNORED_SURV_MODIFY = 0x40
|
||||||
FAN_MARK_IGNORE_SURV = 0x440
|
FAN_MARK_IGNORE_SURV = 0x440
|
||||||
FAN_MARK_INODE = 0x0
|
FAN_MARK_INODE = 0x0
|
||||||
|
FAN_MARK_MNTNS = 0x110
|
||||||
FAN_MARK_MOUNT = 0x10
|
FAN_MARK_MOUNT = 0x10
|
||||||
FAN_MARK_ONLYDIR = 0x8
|
FAN_MARK_ONLYDIR = 0x8
|
||||||
FAN_MARK_REMOVE = 0x2
|
FAN_MARK_REMOVE = 0x2
|
||||||
|
FAN_MNT_ATTACH = 0x1000000
|
||||||
|
FAN_MNT_DETACH = 0x2000000
|
||||||
FAN_MODIFY = 0x2
|
FAN_MODIFY = 0x2
|
||||||
FAN_MOVE = 0xc0
|
FAN_MOVE = 0xc0
|
||||||
FAN_MOVED_FROM = 0x40
|
FAN_MOVED_FROM = 0x40
|
||||||
|
|
@ -1234,12 +1253,15 @@ const (
|
||||||
FAN_OPEN_EXEC = 0x1000
|
FAN_OPEN_EXEC = 0x1000
|
||||||
FAN_OPEN_EXEC_PERM = 0x40000
|
FAN_OPEN_EXEC_PERM = 0x40000
|
||||||
FAN_OPEN_PERM = 0x10000
|
FAN_OPEN_PERM = 0x10000
|
||||||
|
FAN_PRE_ACCESS = 0x100000
|
||||||
FAN_Q_OVERFLOW = 0x4000
|
FAN_Q_OVERFLOW = 0x4000
|
||||||
FAN_RENAME = 0x10000000
|
FAN_RENAME = 0x10000000
|
||||||
FAN_REPORT_DFID_NAME = 0xc00
|
FAN_REPORT_DFID_NAME = 0xc00
|
||||||
FAN_REPORT_DFID_NAME_TARGET = 0x1e00
|
FAN_REPORT_DFID_NAME_TARGET = 0x1e00
|
||||||
FAN_REPORT_DIR_FID = 0x400
|
FAN_REPORT_DIR_FID = 0x400
|
||||||
|
FAN_REPORT_FD_ERROR = 0x2000
|
||||||
FAN_REPORT_FID = 0x200
|
FAN_REPORT_FID = 0x200
|
||||||
|
FAN_REPORT_MNT = 0x4000
|
||||||
FAN_REPORT_NAME = 0x800
|
FAN_REPORT_NAME = 0x800
|
||||||
FAN_REPORT_PIDFD = 0x80
|
FAN_REPORT_PIDFD = 0x80
|
||||||
FAN_REPORT_TARGET_FID = 0x1000
|
FAN_REPORT_TARGET_FID = 0x1000
|
||||||
|
|
@ -1259,6 +1281,7 @@ const (
|
||||||
FIB_RULE_PERMANENT = 0x1
|
FIB_RULE_PERMANENT = 0x1
|
||||||
FIB_RULE_UNRESOLVED = 0x4
|
FIB_RULE_UNRESOLVED = 0x4
|
||||||
FIDEDUPERANGE = 0xc0189436
|
FIDEDUPERANGE = 0xc0189436
|
||||||
|
FSCRYPT_ADD_KEY_FLAG_HW_WRAPPED = 0x1
|
||||||
FSCRYPT_KEY_DESCRIPTOR_SIZE = 0x8
|
FSCRYPT_KEY_DESCRIPTOR_SIZE = 0x8
|
||||||
FSCRYPT_KEY_DESC_PREFIX = "fscrypt:"
|
FSCRYPT_KEY_DESC_PREFIX = "fscrypt:"
|
||||||
FSCRYPT_KEY_DESC_PREFIX_SIZE = 0x8
|
FSCRYPT_KEY_DESC_PREFIX_SIZE = 0x8
|
||||||
|
|
@ -1324,8 +1347,10 @@ const (
|
||||||
FUSE_SUPER_MAGIC = 0x65735546
|
FUSE_SUPER_MAGIC = 0x65735546
|
||||||
FUTEXFS_SUPER_MAGIC = 0xbad1dea
|
FUTEXFS_SUPER_MAGIC = 0xbad1dea
|
||||||
F_ADD_SEALS = 0x409
|
F_ADD_SEALS = 0x409
|
||||||
|
F_CREATED_QUERY = 0x404
|
||||||
F_DUPFD = 0x0
|
F_DUPFD = 0x0
|
||||||
F_DUPFD_CLOEXEC = 0x406
|
F_DUPFD_CLOEXEC = 0x406
|
||||||
|
F_DUPFD_QUERY = 0x403
|
||||||
F_EXLCK = 0x4
|
F_EXLCK = 0x4
|
||||||
F_GETFD = 0x1
|
F_GETFD = 0x1
|
||||||
F_GETFL = 0x3
|
F_GETFL = 0x3
|
||||||
|
|
@ -1545,6 +1570,7 @@ const (
|
||||||
IPPROTO_ROUTING = 0x2b
|
IPPROTO_ROUTING = 0x2b
|
||||||
IPPROTO_RSVP = 0x2e
|
IPPROTO_RSVP = 0x2e
|
||||||
IPPROTO_SCTP = 0x84
|
IPPROTO_SCTP = 0x84
|
||||||
|
IPPROTO_SMC = 0x100
|
||||||
IPPROTO_TCP = 0x6
|
IPPROTO_TCP = 0x6
|
||||||
IPPROTO_TP = 0x1d
|
IPPROTO_TP = 0x1d
|
||||||
IPPROTO_UDP = 0x11
|
IPPROTO_UDP = 0x11
|
||||||
|
|
@ -1564,7 +1590,6 @@ const (
|
||||||
IPV6_DONTFRAG = 0x3e
|
IPV6_DONTFRAG = 0x3e
|
||||||
IPV6_DROP_MEMBERSHIP = 0x15
|
IPV6_DROP_MEMBERSHIP = 0x15
|
||||||
IPV6_DSTOPTS = 0x3b
|
IPV6_DSTOPTS = 0x3b
|
||||||
IPV6_FLOW = 0x11
|
|
||||||
IPV6_FREEBIND = 0x4e
|
IPV6_FREEBIND = 0x4e
|
||||||
IPV6_HDRINCL = 0x24
|
IPV6_HDRINCL = 0x24
|
||||||
IPV6_HOPLIMIT = 0x34
|
IPV6_HOPLIMIT = 0x34
|
||||||
|
|
@ -1615,8 +1640,9 @@ const (
|
||||||
IPV6_TRANSPARENT = 0x4b
|
IPV6_TRANSPARENT = 0x4b
|
||||||
IPV6_UNICAST_HOPS = 0x10
|
IPV6_UNICAST_HOPS = 0x10
|
||||||
IPV6_UNICAST_IF = 0x4c
|
IPV6_UNICAST_IF = 0x4c
|
||||||
IPV6_USER_FLOW = 0xe
|
|
||||||
IPV6_V6ONLY = 0x1a
|
IPV6_V6ONLY = 0x1a
|
||||||
|
IPV6_VERSION = 0x60
|
||||||
|
IPV6_VERSION_MASK = 0xf0
|
||||||
IPV6_XFRM_POLICY = 0x23
|
IPV6_XFRM_POLICY = 0x23
|
||||||
IP_ADD_MEMBERSHIP = 0x23
|
IP_ADD_MEMBERSHIP = 0x23
|
||||||
IP_ADD_SOURCE_MEMBERSHIP = 0x27
|
IP_ADD_SOURCE_MEMBERSHIP = 0x27
|
||||||
|
|
@ -1675,7 +1701,6 @@ const (
|
||||||
IP_TTL = 0x2
|
IP_TTL = 0x2
|
||||||
IP_UNBLOCK_SOURCE = 0x25
|
IP_UNBLOCK_SOURCE = 0x25
|
||||||
IP_UNICAST_IF = 0x32
|
IP_UNICAST_IF = 0x32
|
||||||
IP_USER_FLOW = 0xd
|
|
||||||
IP_XFRM_POLICY = 0x11
|
IP_XFRM_POLICY = 0x11
|
||||||
ISOFS_SUPER_MAGIC = 0x9660
|
ISOFS_SUPER_MAGIC = 0x9660
|
||||||
ISTRIP = 0x20
|
ISTRIP = 0x20
|
||||||
|
|
@ -1797,7 +1822,13 @@ const (
|
||||||
LANDLOCK_ACCESS_FS_WRITE_FILE = 0x2
|
LANDLOCK_ACCESS_FS_WRITE_FILE = 0x2
|
||||||
LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
|
LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
|
||||||
LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
|
LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
|
||||||
|
LANDLOCK_CREATE_RULESET_ERRATA = 0x2
|
||||||
LANDLOCK_CREATE_RULESET_VERSION = 0x1
|
LANDLOCK_CREATE_RULESET_VERSION = 0x1
|
||||||
|
LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON = 0x2
|
||||||
|
LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF = 0x1
|
||||||
|
LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF = 0x4
|
||||||
|
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET = 0x1
|
||||||
|
LANDLOCK_SCOPE_SIGNAL = 0x2
|
||||||
LINUX_REBOOT_CMD_CAD_OFF = 0x0
|
LINUX_REBOOT_CMD_CAD_OFF = 0x0
|
||||||
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
|
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
|
||||||
LINUX_REBOOT_CMD_HALT = 0xcdef0123
|
LINUX_REBOOT_CMD_HALT = 0xcdef0123
|
||||||
|
|
@ -1859,6 +1890,7 @@ const (
|
||||||
MADV_UNMERGEABLE = 0xd
|
MADV_UNMERGEABLE = 0xd
|
||||||
MADV_WILLNEED = 0x3
|
MADV_WILLNEED = 0x3
|
||||||
MADV_WIPEONFORK = 0x12
|
MADV_WIPEONFORK = 0x12
|
||||||
|
MAP_DROPPABLE = 0x8
|
||||||
MAP_FILE = 0x0
|
MAP_FILE = 0x0
|
||||||
MAP_FIXED = 0x10
|
MAP_FIXED = 0x10
|
||||||
MAP_FIXED_NOREPLACE = 0x100000
|
MAP_FIXED_NOREPLACE = 0x100000
|
||||||
|
|
@ -1922,6 +1954,8 @@ const (
|
||||||
MNT_EXPIRE = 0x4
|
MNT_EXPIRE = 0x4
|
||||||
MNT_FORCE = 0x1
|
MNT_FORCE = 0x1
|
||||||
MNT_ID_REQ_SIZE_VER0 = 0x18
|
MNT_ID_REQ_SIZE_VER0 = 0x18
|
||||||
|
MNT_ID_REQ_SIZE_VER1 = 0x20
|
||||||
|
MNT_NS_INFO_SIZE_VER0 = 0x10
|
||||||
MODULE_INIT_COMPRESSED_FILE = 0x4
|
MODULE_INIT_COMPRESSED_FILE = 0x4
|
||||||
MODULE_INIT_IGNORE_MODVERSIONS = 0x1
|
MODULE_INIT_IGNORE_MODVERSIONS = 0x1
|
||||||
MODULE_INIT_IGNORE_VERMAGIC = 0x2
|
MODULE_INIT_IGNORE_VERMAGIC = 0x2
|
||||||
|
|
@ -1957,6 +1991,7 @@ const (
|
||||||
MSG_PEEK = 0x2
|
MSG_PEEK = 0x2
|
||||||
MSG_PROXY = 0x10
|
MSG_PROXY = 0x10
|
||||||
MSG_RST = 0x1000
|
MSG_RST = 0x1000
|
||||||
|
MSG_SOCK_DEVMEM = 0x2000000
|
||||||
MSG_SYN = 0x400
|
MSG_SYN = 0x400
|
||||||
MSG_TRUNC = 0x20
|
MSG_TRUNC = 0x20
|
||||||
MSG_TRYHARD = 0x4
|
MSG_TRYHARD = 0x4
|
||||||
|
|
@ -2073,6 +2108,7 @@ const (
|
||||||
NFC_ATR_REQ_MAXSIZE = 0x40
|
NFC_ATR_REQ_MAXSIZE = 0x40
|
||||||
NFC_ATR_RES_GB_MAXSIZE = 0x2f
|
NFC_ATR_RES_GB_MAXSIZE = 0x2f
|
||||||
NFC_ATR_RES_MAXSIZE = 0x40
|
NFC_ATR_RES_MAXSIZE = 0x40
|
||||||
|
NFC_ATS_MAXSIZE = 0x14
|
||||||
NFC_COMM_ACTIVE = 0x0
|
NFC_COMM_ACTIVE = 0x0
|
||||||
NFC_COMM_PASSIVE = 0x1
|
NFC_COMM_PASSIVE = 0x1
|
||||||
NFC_DEVICE_NAME_MAXSIZE = 0x8
|
NFC_DEVICE_NAME_MAXSIZE = 0x8
|
||||||
|
|
@ -2153,6 +2189,7 @@ const (
|
||||||
NFNL_SUBSYS_QUEUE = 0x3
|
NFNL_SUBSYS_QUEUE = 0x3
|
||||||
NFNL_SUBSYS_ULOG = 0x4
|
NFNL_SUBSYS_ULOG = 0x4
|
||||||
NFS_SUPER_MAGIC = 0x6969
|
NFS_SUPER_MAGIC = 0x6969
|
||||||
|
NFT_BITWISE_BOOL = 0x0
|
||||||
NFT_CHAIN_FLAGS = 0x7
|
NFT_CHAIN_FLAGS = 0x7
|
||||||
NFT_CHAIN_MAXNAMELEN = 0x100
|
NFT_CHAIN_MAXNAMELEN = 0x100
|
||||||
NFT_CT_MAX = 0x17
|
NFT_CT_MAX = 0x17
|
||||||
|
|
@ -2187,7 +2224,7 @@ const (
|
||||||
NFT_REG_SIZE = 0x10
|
NFT_REG_SIZE = 0x10
|
||||||
NFT_REJECT_ICMPX_MAX = 0x3
|
NFT_REJECT_ICMPX_MAX = 0x3
|
||||||
NFT_RT_MAX = 0x4
|
NFT_RT_MAX = 0x4
|
||||||
NFT_SECMARK_CTX_MAXLEN = 0x100
|
NFT_SECMARK_CTX_MAXLEN = 0x1000
|
||||||
NFT_SET_MAXNAMELEN = 0x100
|
NFT_SET_MAXNAMELEN = 0x100
|
||||||
NFT_SOCKET_MAX = 0x3
|
NFT_SOCKET_MAX = 0x3
|
||||||
NFT_TABLE_F_MASK = 0x7
|
NFT_TABLE_F_MASK = 0x7
|
||||||
|
|
@ -2356,9 +2393,11 @@ const (
|
||||||
PERF_MEM_LVLNUM_IO = 0xa
|
PERF_MEM_LVLNUM_IO = 0xa
|
||||||
PERF_MEM_LVLNUM_L1 = 0x1
|
PERF_MEM_LVLNUM_L1 = 0x1
|
||||||
PERF_MEM_LVLNUM_L2 = 0x2
|
PERF_MEM_LVLNUM_L2 = 0x2
|
||||||
|
PERF_MEM_LVLNUM_L2_MHB = 0x5
|
||||||
PERF_MEM_LVLNUM_L3 = 0x3
|
PERF_MEM_LVLNUM_L3 = 0x3
|
||||||
PERF_MEM_LVLNUM_L4 = 0x4
|
PERF_MEM_LVLNUM_L4 = 0x4
|
||||||
PERF_MEM_LVLNUM_LFB = 0xc
|
PERF_MEM_LVLNUM_LFB = 0xc
|
||||||
|
PERF_MEM_LVLNUM_MSC = 0x6
|
||||||
PERF_MEM_LVLNUM_NA = 0xf
|
PERF_MEM_LVLNUM_NA = 0xf
|
||||||
PERF_MEM_LVLNUM_PMEM = 0xe
|
PERF_MEM_LVLNUM_PMEM = 0xe
|
||||||
PERF_MEM_LVLNUM_RAM = 0xd
|
PERF_MEM_LVLNUM_RAM = 0xd
|
||||||
|
|
@ -2431,6 +2470,7 @@ const (
|
||||||
PRIO_PGRP = 0x1
|
PRIO_PGRP = 0x1
|
||||||
PRIO_PROCESS = 0x0
|
PRIO_PROCESS = 0x0
|
||||||
PRIO_USER = 0x2
|
PRIO_USER = 0x2
|
||||||
|
PROCFS_IOCTL_MAGIC = 'f'
|
||||||
PROC_SUPER_MAGIC = 0x9fa0
|
PROC_SUPER_MAGIC = 0x9fa0
|
||||||
PROT_EXEC = 0x4
|
PROT_EXEC = 0x4
|
||||||
PROT_GROWSDOWN = 0x1000000
|
PROT_GROWSDOWN = 0x1000000
|
||||||
|
|
@ -2462,6 +2502,10 @@ const (
|
||||||
PR_FP_EXC_UND = 0x40000
|
PR_FP_EXC_UND = 0x40000
|
||||||
PR_FP_MODE_FR = 0x1
|
PR_FP_MODE_FR = 0x1
|
||||||
PR_FP_MODE_FRE = 0x2
|
PR_FP_MODE_FRE = 0x2
|
||||||
|
PR_FUTEX_HASH = 0x4e
|
||||||
|
PR_FUTEX_HASH_GET_IMMUTABLE = 0x3
|
||||||
|
PR_FUTEX_HASH_GET_SLOTS = 0x2
|
||||||
|
PR_FUTEX_HASH_SET_SLOTS = 0x1
|
||||||
PR_GET_AUXV = 0x41555856
|
PR_GET_AUXV = 0x41555856
|
||||||
PR_GET_CHILD_SUBREAPER = 0x25
|
PR_GET_CHILD_SUBREAPER = 0x25
|
||||||
PR_GET_DUMPABLE = 0x3
|
PR_GET_DUMPABLE = 0x3
|
||||||
|
|
@ -2478,6 +2522,7 @@ const (
|
||||||
PR_GET_PDEATHSIG = 0x2
|
PR_GET_PDEATHSIG = 0x2
|
||||||
PR_GET_SECCOMP = 0x15
|
PR_GET_SECCOMP = 0x15
|
||||||
PR_GET_SECUREBITS = 0x1b
|
PR_GET_SECUREBITS = 0x1b
|
||||||
|
PR_GET_SHADOW_STACK_STATUS = 0x4a
|
||||||
PR_GET_SPECULATION_CTRL = 0x34
|
PR_GET_SPECULATION_CTRL = 0x34
|
||||||
PR_GET_TAGGED_ADDR_CTRL = 0x38
|
PR_GET_TAGGED_ADDR_CTRL = 0x38
|
||||||
PR_GET_THP_DISABLE = 0x2a
|
PR_GET_THP_DISABLE = 0x2a
|
||||||
|
|
@ -2486,6 +2531,7 @@ const (
|
||||||
PR_GET_TIMING = 0xd
|
PR_GET_TIMING = 0xd
|
||||||
PR_GET_TSC = 0x19
|
PR_GET_TSC = 0x19
|
||||||
PR_GET_UNALIGN = 0x5
|
PR_GET_UNALIGN = 0x5
|
||||||
|
PR_LOCK_SHADOW_STACK_STATUS = 0x4c
|
||||||
PR_MCE_KILL = 0x21
|
PR_MCE_KILL = 0x21
|
||||||
PR_MCE_KILL_CLEAR = 0x0
|
PR_MCE_KILL_CLEAR = 0x0
|
||||||
PR_MCE_KILL_DEFAULT = 0x2
|
PR_MCE_KILL_DEFAULT = 0x2
|
||||||
|
|
@ -2512,6 +2558,8 @@ const (
|
||||||
PR_PAC_GET_ENABLED_KEYS = 0x3d
|
PR_PAC_GET_ENABLED_KEYS = 0x3d
|
||||||
PR_PAC_RESET_KEYS = 0x36
|
PR_PAC_RESET_KEYS = 0x36
|
||||||
PR_PAC_SET_ENABLED_KEYS = 0x3c
|
PR_PAC_SET_ENABLED_KEYS = 0x3c
|
||||||
|
PR_PMLEN_MASK = 0x7f000000
|
||||||
|
PR_PMLEN_SHIFT = 0x18
|
||||||
PR_PPC_DEXCR_CTRL_CLEAR = 0x4
|
PR_PPC_DEXCR_CTRL_CLEAR = 0x4
|
||||||
PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10
|
PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10
|
||||||
PR_PPC_DEXCR_CTRL_EDITABLE = 0x1
|
PR_PPC_DEXCR_CTRL_EDITABLE = 0x1
|
||||||
|
|
@ -2579,6 +2627,7 @@ const (
|
||||||
PR_SET_PTRACER = 0x59616d61
|
PR_SET_PTRACER = 0x59616d61
|
||||||
PR_SET_SECCOMP = 0x16
|
PR_SET_SECCOMP = 0x16
|
||||||
PR_SET_SECUREBITS = 0x1c
|
PR_SET_SECUREBITS = 0x1c
|
||||||
|
PR_SET_SHADOW_STACK_STATUS = 0x4b
|
||||||
PR_SET_SPECULATION_CTRL = 0x35
|
PR_SET_SPECULATION_CTRL = 0x35
|
||||||
PR_SET_SYSCALL_USER_DISPATCH = 0x3b
|
PR_SET_SYSCALL_USER_DISPATCH = 0x3b
|
||||||
PR_SET_TAGGED_ADDR_CTRL = 0x37
|
PR_SET_TAGGED_ADDR_CTRL = 0x37
|
||||||
|
|
@ -2589,6 +2638,9 @@ const (
|
||||||
PR_SET_UNALIGN = 0x6
|
PR_SET_UNALIGN = 0x6
|
||||||
PR_SET_VMA = 0x53564d41
|
PR_SET_VMA = 0x53564d41
|
||||||
PR_SET_VMA_ANON_NAME = 0x0
|
PR_SET_VMA_ANON_NAME = 0x0
|
||||||
|
PR_SHADOW_STACK_ENABLE = 0x1
|
||||||
|
PR_SHADOW_STACK_PUSH = 0x4
|
||||||
|
PR_SHADOW_STACK_WRITE = 0x2
|
||||||
PR_SME_GET_VL = 0x40
|
PR_SME_GET_VL = 0x40
|
||||||
PR_SME_SET_VL = 0x3f
|
PR_SME_SET_VL = 0x3f
|
||||||
PR_SME_SET_VL_ONEXEC = 0x40000
|
PR_SME_SET_VL_ONEXEC = 0x40000
|
||||||
|
|
@ -2613,6 +2665,10 @@ const (
|
||||||
PR_TAGGED_ADDR_ENABLE = 0x1
|
PR_TAGGED_ADDR_ENABLE = 0x1
|
||||||
PR_TASK_PERF_EVENTS_DISABLE = 0x1f
|
PR_TASK_PERF_EVENTS_DISABLE = 0x1f
|
||||||
PR_TASK_PERF_EVENTS_ENABLE = 0x20
|
PR_TASK_PERF_EVENTS_ENABLE = 0x20
|
||||||
|
PR_TIMER_CREATE_RESTORE_IDS = 0x4d
|
||||||
|
PR_TIMER_CREATE_RESTORE_IDS_GET = 0x2
|
||||||
|
PR_TIMER_CREATE_RESTORE_IDS_OFF = 0x0
|
||||||
|
PR_TIMER_CREATE_RESTORE_IDS_ON = 0x1
|
||||||
PR_TIMING_STATISTICAL = 0x0
|
PR_TIMING_STATISTICAL = 0x0
|
||||||
PR_TIMING_TIMESTAMP = 0x1
|
PR_TIMING_TIMESTAMP = 0x1
|
||||||
PR_TSC_ENABLE = 0x1
|
PR_TSC_ENABLE = 0x1
|
||||||
|
|
@ -2620,6 +2676,28 @@ const (
|
||||||
PR_UNALIGN_NOPRINT = 0x1
|
PR_UNALIGN_NOPRINT = 0x1
|
||||||
PR_UNALIGN_SIGBUS = 0x2
|
PR_UNALIGN_SIGBUS = 0x2
|
||||||
PSTOREFS_MAGIC = 0x6165676c
|
PSTOREFS_MAGIC = 0x6165676c
|
||||||
|
PTP_CLK_MAGIC = '='
|
||||||
|
PTP_ENABLE_FEATURE = 0x1
|
||||||
|
PTP_EXTTS_EDGES = 0x6
|
||||||
|
PTP_EXTTS_EVENT_VALID = 0x1
|
||||||
|
PTP_EXTTS_V1_VALID_FLAGS = 0x7
|
||||||
|
PTP_EXTTS_VALID_FLAGS = 0x1f
|
||||||
|
PTP_EXT_OFFSET = 0x10
|
||||||
|
PTP_FALLING_EDGE = 0x4
|
||||||
|
PTP_MAX_SAMPLES = 0x19
|
||||||
|
PTP_PEROUT_DUTY_CYCLE = 0x2
|
||||||
|
PTP_PEROUT_ONE_SHOT = 0x1
|
||||||
|
PTP_PEROUT_PHASE = 0x4
|
||||||
|
PTP_PEROUT_V1_VALID_FLAGS = 0x0
|
||||||
|
PTP_PEROUT_VALID_FLAGS = 0x7
|
||||||
|
PTP_PIN_GETFUNC = 0xc0603d06
|
||||||
|
PTP_PIN_GETFUNC2 = 0xc0603d0f
|
||||||
|
PTP_RISING_EDGE = 0x2
|
||||||
|
PTP_STRICT_FLAGS = 0x8
|
||||||
|
PTP_SYS_OFFSET_EXTENDED = 0xc4c03d09
|
||||||
|
PTP_SYS_OFFSET_EXTENDED2 = 0xc4c03d12
|
||||||
|
PTP_SYS_OFFSET_PRECISE = 0xc0403d08
|
||||||
|
PTP_SYS_OFFSET_PRECISE2 = 0xc0403d11
|
||||||
PTRACE_ATTACH = 0x10
|
PTRACE_ATTACH = 0x10
|
||||||
PTRACE_CONT = 0x7
|
PTRACE_CONT = 0x7
|
||||||
PTRACE_DETACH = 0x11
|
PTRACE_DETACH = 0x11
|
||||||
|
|
@ -2671,6 +2749,7 @@ const (
|
||||||
PTRACE_SETREGSET = 0x4205
|
PTRACE_SETREGSET = 0x4205
|
||||||
PTRACE_SETSIGINFO = 0x4203
|
PTRACE_SETSIGINFO = 0x4203
|
||||||
PTRACE_SETSIGMASK = 0x420b
|
PTRACE_SETSIGMASK = 0x420b
|
||||||
|
PTRACE_SET_SYSCALL_INFO = 0x4212
|
||||||
PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG = 0x4210
|
PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG = 0x4210
|
||||||
PTRACE_SINGLESTEP = 0x9
|
PTRACE_SINGLESTEP = 0x9
|
||||||
PTRACE_SYSCALL = 0x18
|
PTRACE_SYSCALL = 0x18
|
||||||
|
|
@ -2734,7 +2813,7 @@ const (
|
||||||
RTAX_UNSPEC = 0x0
|
RTAX_UNSPEC = 0x0
|
||||||
RTAX_WINDOW = 0x3
|
RTAX_WINDOW = 0x3
|
||||||
RTA_ALIGNTO = 0x4
|
RTA_ALIGNTO = 0x4
|
||||||
RTA_MAX = 0x1e
|
RTA_MAX = 0x1f
|
||||||
RTCF_DIRECTSRC = 0x4000000
|
RTCF_DIRECTSRC = 0x4000000
|
||||||
RTCF_DOREDIRECT = 0x1000000
|
RTCF_DOREDIRECT = 0x1000000
|
||||||
RTCF_LOG = 0x2000000
|
RTCF_LOG = 0x2000000
|
||||||
|
|
@ -2811,10 +2890,12 @@ const (
|
||||||
RTM_DELACTION = 0x31
|
RTM_DELACTION = 0x31
|
||||||
RTM_DELADDR = 0x15
|
RTM_DELADDR = 0x15
|
||||||
RTM_DELADDRLABEL = 0x49
|
RTM_DELADDRLABEL = 0x49
|
||||||
|
RTM_DELANYCAST = 0x3d
|
||||||
RTM_DELCHAIN = 0x65
|
RTM_DELCHAIN = 0x65
|
||||||
RTM_DELLINK = 0x11
|
RTM_DELLINK = 0x11
|
||||||
RTM_DELLINKPROP = 0x6d
|
RTM_DELLINKPROP = 0x6d
|
||||||
RTM_DELMDB = 0x55
|
RTM_DELMDB = 0x55
|
||||||
|
RTM_DELMULTICAST = 0x39
|
||||||
RTM_DELNEIGH = 0x1d
|
RTM_DELNEIGH = 0x1d
|
||||||
RTM_DELNETCONF = 0x51
|
RTM_DELNETCONF = 0x51
|
||||||
RTM_DELNEXTHOP = 0x69
|
RTM_DELNEXTHOP = 0x69
|
||||||
|
|
@ -2864,11 +2945,13 @@ const (
|
||||||
RTM_NEWACTION = 0x30
|
RTM_NEWACTION = 0x30
|
||||||
RTM_NEWADDR = 0x14
|
RTM_NEWADDR = 0x14
|
||||||
RTM_NEWADDRLABEL = 0x48
|
RTM_NEWADDRLABEL = 0x48
|
||||||
|
RTM_NEWANYCAST = 0x3c
|
||||||
RTM_NEWCACHEREPORT = 0x60
|
RTM_NEWCACHEREPORT = 0x60
|
||||||
RTM_NEWCHAIN = 0x64
|
RTM_NEWCHAIN = 0x64
|
||||||
RTM_NEWLINK = 0x10
|
RTM_NEWLINK = 0x10
|
||||||
RTM_NEWLINKPROP = 0x6c
|
RTM_NEWLINKPROP = 0x6c
|
||||||
RTM_NEWMDB = 0x54
|
RTM_NEWMDB = 0x54
|
||||||
|
RTM_NEWMULTICAST = 0x38
|
||||||
RTM_NEWNDUSEROPT = 0x44
|
RTM_NEWNDUSEROPT = 0x44
|
||||||
RTM_NEWNEIGH = 0x1c
|
RTM_NEWNEIGH = 0x1c
|
||||||
RTM_NEWNEIGHTBL = 0x40
|
RTM_NEWNEIGHTBL = 0x40
|
||||||
|
|
@ -2876,7 +2959,6 @@ const (
|
||||||
RTM_NEWNEXTHOP = 0x68
|
RTM_NEWNEXTHOP = 0x68
|
||||||
RTM_NEWNEXTHOPBUCKET = 0x74
|
RTM_NEWNEXTHOPBUCKET = 0x74
|
||||||
RTM_NEWNSID = 0x58
|
RTM_NEWNSID = 0x58
|
||||||
RTM_NEWNVLAN = 0x70
|
|
||||||
RTM_NEWPREFIX = 0x34
|
RTM_NEWPREFIX = 0x34
|
||||||
RTM_NEWQDISC = 0x24
|
RTM_NEWQDISC = 0x24
|
||||||
RTM_NEWROUTE = 0x18
|
RTM_NEWROUTE = 0x18
|
||||||
|
|
@ -2885,6 +2967,7 @@ const (
|
||||||
RTM_NEWTCLASS = 0x28
|
RTM_NEWTCLASS = 0x28
|
||||||
RTM_NEWTFILTER = 0x2c
|
RTM_NEWTFILTER = 0x2c
|
||||||
RTM_NEWTUNNEL = 0x78
|
RTM_NEWTUNNEL = 0x78
|
||||||
|
RTM_NEWVLAN = 0x70
|
||||||
RTM_NR_FAMILIES = 0x1b
|
RTM_NR_FAMILIES = 0x1b
|
||||||
RTM_NR_MSGTYPES = 0x6c
|
RTM_NR_MSGTYPES = 0x6c
|
||||||
RTM_SETDCB = 0x4f
|
RTM_SETDCB = 0x4f
|
||||||
|
|
@ -2917,6 +3000,7 @@ const (
|
||||||
RTPROT_NTK = 0xf
|
RTPROT_NTK = 0xf
|
||||||
RTPROT_OPENR = 0x63
|
RTPROT_OPENR = 0x63
|
||||||
RTPROT_OSPF = 0xbc
|
RTPROT_OSPF = 0xbc
|
||||||
|
RTPROT_OVN = 0x54
|
||||||
RTPROT_RA = 0x9
|
RTPROT_RA = 0x9
|
||||||
RTPROT_REDIRECT = 0x1
|
RTPROT_REDIRECT = 0x1
|
||||||
RTPROT_RIP = 0xbd
|
RTPROT_RIP = 0xbd
|
||||||
|
|
@ -2933,15 +3017,18 @@ const (
|
||||||
RUSAGE_SELF = 0x0
|
RUSAGE_SELF = 0x0
|
||||||
RUSAGE_THREAD = 0x1
|
RUSAGE_THREAD = 0x1
|
||||||
RWF_APPEND = 0x10
|
RWF_APPEND = 0x10
|
||||||
|
RWF_ATOMIC = 0x40
|
||||||
|
RWF_DONTCACHE = 0x80
|
||||||
RWF_DSYNC = 0x2
|
RWF_DSYNC = 0x2
|
||||||
RWF_HIPRI = 0x1
|
RWF_HIPRI = 0x1
|
||||||
RWF_NOAPPEND = 0x20
|
RWF_NOAPPEND = 0x20
|
||||||
RWF_NOWAIT = 0x8
|
RWF_NOWAIT = 0x8
|
||||||
RWF_SUPPORTED = 0x3f
|
RWF_SUPPORTED = 0xff
|
||||||
RWF_SYNC = 0x4
|
RWF_SYNC = 0x4
|
||||||
RWF_WRITE_LIFE_NOT_SET = 0x0
|
RWF_WRITE_LIFE_NOT_SET = 0x0
|
||||||
SCHED_BATCH = 0x3
|
SCHED_BATCH = 0x3
|
||||||
SCHED_DEADLINE = 0x6
|
SCHED_DEADLINE = 0x6
|
||||||
|
SCHED_EXT = 0x7
|
||||||
SCHED_FIFO = 0x1
|
SCHED_FIFO = 0x1
|
||||||
SCHED_FLAG_ALL = 0x7f
|
SCHED_FLAG_ALL = 0x7f
|
||||||
SCHED_FLAG_DL_OVERRUN = 0x4
|
SCHED_FLAG_DL_OVERRUN = 0x4
|
||||||
|
|
@ -3210,11 +3297,13 @@ const (
|
||||||
STATX_ATTR_MOUNT_ROOT = 0x2000
|
STATX_ATTR_MOUNT_ROOT = 0x2000
|
||||||
STATX_ATTR_NODUMP = 0x40
|
STATX_ATTR_NODUMP = 0x40
|
||||||
STATX_ATTR_VERITY = 0x100000
|
STATX_ATTR_VERITY = 0x100000
|
||||||
|
STATX_ATTR_WRITE_ATOMIC = 0x400000
|
||||||
STATX_BASIC_STATS = 0x7ff
|
STATX_BASIC_STATS = 0x7ff
|
||||||
STATX_BLOCKS = 0x400
|
STATX_BLOCKS = 0x400
|
||||||
STATX_BTIME = 0x800
|
STATX_BTIME = 0x800
|
||||||
STATX_CTIME = 0x80
|
STATX_CTIME = 0x80
|
||||||
STATX_DIOALIGN = 0x2000
|
STATX_DIOALIGN = 0x2000
|
||||||
|
STATX_DIO_READ_ALIGN = 0x20000
|
||||||
STATX_GID = 0x10
|
STATX_GID = 0x10
|
||||||
STATX_INO = 0x100
|
STATX_INO = 0x100
|
||||||
STATX_MNT_ID = 0x1000
|
STATX_MNT_ID = 0x1000
|
||||||
|
|
@ -3226,6 +3315,7 @@ const (
|
||||||
STATX_SUBVOL = 0x8000
|
STATX_SUBVOL = 0x8000
|
||||||
STATX_TYPE = 0x1
|
STATX_TYPE = 0x1
|
||||||
STATX_UID = 0x8
|
STATX_UID = 0x8
|
||||||
|
STATX_WRITE_ATOMIC = 0x10000
|
||||||
STATX__RESERVED = 0x80000000
|
STATX__RESERVED = 0x80000000
|
||||||
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||||
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||||
|
|
@ -3265,7 +3355,7 @@ const (
|
||||||
TASKSTATS_GENL_NAME = "TASKSTATS"
|
TASKSTATS_GENL_NAME = "TASKSTATS"
|
||||||
TASKSTATS_GENL_VERSION = 0x1
|
TASKSTATS_GENL_VERSION = 0x1
|
||||||
TASKSTATS_TYPE_MAX = 0x6
|
TASKSTATS_TYPE_MAX = 0x6
|
||||||
TASKSTATS_VERSION = 0xe
|
TASKSTATS_VERSION = 0x10
|
||||||
TCIFLUSH = 0x0
|
TCIFLUSH = 0x0
|
||||||
TCIOFF = 0x2
|
TCIOFF = 0x2
|
||||||
TCIOFLUSH = 0x2
|
TCIOFLUSH = 0x2
|
||||||
|
|
@ -3335,8 +3425,6 @@ const (
|
||||||
TCP_TX_DELAY = 0x25
|
TCP_TX_DELAY = 0x25
|
||||||
TCP_ULP = 0x1f
|
TCP_ULP = 0x1f
|
||||||
TCP_USER_TIMEOUT = 0x12
|
TCP_USER_TIMEOUT = 0x12
|
||||||
TCP_V4_FLOW = 0x1
|
|
||||||
TCP_V6_FLOW = 0x5
|
|
||||||
TCP_WINDOW_CLAMP = 0xa
|
TCP_WINDOW_CLAMP = 0xa
|
||||||
TCP_ZEROCOPY_RECEIVE = 0x23
|
TCP_ZEROCOPY_RECEIVE = 0x23
|
||||||
TFD_TIMER_ABSTIME = 0x1
|
TFD_TIMER_ABSTIME = 0x1
|
||||||
|
|
@ -3446,6 +3534,7 @@ const (
|
||||||
TP_STATUS_WRONG_FORMAT = 0x4
|
TP_STATUS_WRONG_FORMAT = 0x4
|
||||||
TRACEFS_MAGIC = 0x74726163
|
TRACEFS_MAGIC = 0x74726163
|
||||||
TS_COMM_LEN = 0x20
|
TS_COMM_LEN = 0x20
|
||||||
|
UBI_IOCECNFO = 0xc01c6f06
|
||||||
UDF_SUPER_MAGIC = 0x15013346
|
UDF_SUPER_MAGIC = 0x15013346
|
||||||
UDP_CORK = 0x1
|
UDP_CORK = 0x1
|
||||||
UDP_ENCAP = 0x64
|
UDP_ENCAP = 0x64
|
||||||
|
|
@ -3458,8 +3547,6 @@ const (
|
||||||
UDP_NO_CHECK6_RX = 0x66
|
UDP_NO_CHECK6_RX = 0x66
|
||||||
UDP_NO_CHECK6_TX = 0x65
|
UDP_NO_CHECK6_TX = 0x65
|
||||||
UDP_SEGMENT = 0x67
|
UDP_SEGMENT = 0x67
|
||||||
UDP_V4_FLOW = 0x2
|
|
||||||
UDP_V6_FLOW = 0x6
|
|
||||||
UMOUNT_NOFOLLOW = 0x8
|
UMOUNT_NOFOLLOW = 0x8
|
||||||
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
USBDEVICE_SUPER_MAGIC = 0x9fa2
|
||||||
UTIME_NOW = 0x3fffffff
|
UTIME_NOW = 0x3fffffff
|
||||||
|
|
@ -3502,7 +3589,7 @@ const (
|
||||||
WDIOS_TEMPPANIC = 0x4
|
WDIOS_TEMPPANIC = 0x4
|
||||||
WDIOS_UNKNOWN = -0x1
|
WDIOS_UNKNOWN = -0x1
|
||||||
WEXITED = 0x4
|
WEXITED = 0x4
|
||||||
WGALLOWEDIP_A_MAX = 0x3
|
WGALLOWEDIP_A_MAX = 0x4
|
||||||
WGDEVICE_A_MAX = 0x8
|
WGDEVICE_A_MAX = 0x8
|
||||||
WGPEER_A_MAX = 0xa
|
WGPEER_A_MAX = 0xa
|
||||||
WG_CMD_MAX = 0x1
|
WG_CMD_MAX = 0x1
|
||||||
|
|
@ -3616,6 +3703,7 @@ const (
|
||||||
XDP_SHARED_UMEM = 0x1
|
XDP_SHARED_UMEM = 0x1
|
||||||
XDP_STATISTICS = 0x7
|
XDP_STATISTICS = 0x7
|
||||||
XDP_TXMD_FLAGS_CHECKSUM = 0x2
|
XDP_TXMD_FLAGS_CHECKSUM = 0x2
|
||||||
|
XDP_TXMD_FLAGS_LAUNCH_TIME = 0x4
|
||||||
XDP_TXMD_FLAGS_TIMESTAMP = 0x1
|
XDP_TXMD_FLAGS_TIMESTAMP = 0x1
|
||||||
XDP_TX_METADATA = 0x2
|
XDP_TX_METADATA = 0x2
|
||||||
XDP_TX_RING = 0x3
|
XDP_TX_RING = 0x3
|
||||||
|
|
@ -3624,6 +3712,7 @@ const (
|
||||||
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000
|
||||||
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
XDP_UMEM_PGOFF_FILL_RING = 0x100000000
|
||||||
XDP_UMEM_REG = 0x4
|
XDP_UMEM_REG = 0x4
|
||||||
|
XDP_UMEM_TX_METADATA_LEN = 0x4
|
||||||
XDP_UMEM_TX_SW_CSUM = 0x2
|
XDP_UMEM_TX_SW_CSUM = 0x2
|
||||||
XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1
|
XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1
|
||||||
XDP_USE_NEED_WAKEUP = 0x8
|
XDP_USE_NEED_WAKEUP = 0x8
|
||||||
|
|
|
||||||
31
vendor/golang.org/x/sys/unix/zerrors_linux_386.go
generated
vendored
31
vendor/golang.org/x/sys/unix/zerrors_linux_386.go
generated
vendored
|
|
@ -68,6 +68,7 @@ const (
|
||||||
CS8 = 0x30
|
CS8 = 0x30
|
||||||
CSIZE = 0x30
|
CSIZE = 0x30
|
||||||
CSTOPB = 0x40
|
CSTOPB = 0x40
|
||||||
|
DM_MPATH_PROBE_PATHS = 0xfd12
|
||||||
ECCGETLAYOUT = 0x81484d11
|
ECCGETLAYOUT = 0x81484d11
|
||||||
ECCGETSTATS = 0x80104d12
|
ECCGETSTATS = 0x80104d12
|
||||||
ECHOCTL = 0x200
|
ECHOCTL = 0x200
|
||||||
|
|
@ -109,12 +110,15 @@ const (
|
||||||
HIDIOCGRAWINFO = 0x80084803
|
HIDIOCGRAWINFO = 0x80084803
|
||||||
HIDIOCGRDESC = 0x90044802
|
HIDIOCGRDESC = 0x90044802
|
||||||
HIDIOCGRDESCSIZE = 0x80044801
|
HIDIOCGRDESCSIZE = 0x80044801
|
||||||
|
HIDIOCREVOKE = 0x4004480d
|
||||||
HUPCL = 0x400
|
HUPCL = 0x400
|
||||||
ICANON = 0x2
|
ICANON = 0x2
|
||||||
IEXTEN = 0x8000
|
IEXTEN = 0x8000
|
||||||
IN_CLOEXEC = 0x80000
|
IN_CLOEXEC = 0x80000
|
||||||
IN_NONBLOCK = 0x800
|
IN_NONBLOCK = 0x800
|
||||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||||
|
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||||
|
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||||
ISIG = 0x1
|
ISIG = 0x1
|
||||||
IUCLC = 0x200
|
IUCLC = 0x200
|
||||||
IXOFF = 0x1000
|
IXOFF = 0x1000
|
||||||
|
|
@ -153,9 +157,14 @@ const (
|
||||||
NFDBITS = 0x20
|
NFDBITS = 0x20
|
||||||
NLDLY = 0x100
|
NLDLY = 0x100
|
||||||
NOFLSH = 0x80
|
NOFLSH = 0x80
|
||||||
|
NS_GET_MNTNS_ID = 0x8008b705
|
||||||
NS_GET_NSTYPE = 0xb703
|
NS_GET_NSTYPE = 0xb703
|
||||||
NS_GET_OWNER_UID = 0xb704
|
NS_GET_OWNER_UID = 0xb704
|
||||||
NS_GET_PARENT = 0xb702
|
NS_GET_PARENT = 0xb702
|
||||||
|
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||||
|
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||||
|
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||||
|
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||||
NS_GET_USERNS = 0xb701
|
NS_GET_USERNS = 0xb701
|
||||||
OLCUC = 0x2
|
OLCUC = 0x2
|
||||||
ONLCR = 0x4
|
ONLCR = 0x4
|
||||||
|
|
@ -232,6 +241,20 @@ const (
|
||||||
PPPIOCUNBRIDGECHAN = 0x7434
|
PPPIOCUNBRIDGECHAN = 0x7434
|
||||||
PPPIOCXFERUNIT = 0x744e
|
PPPIOCXFERUNIT = 0x744e
|
||||||
PR_SET_PTRACER_ANY = 0xffffffff
|
PR_SET_PTRACER_ANY = 0xffffffff
|
||||||
|
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||||
|
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||||
|
PTP_ENABLE_PPS = 0x40043d04
|
||||||
|
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||||
|
PTP_EXTTS_REQUEST = 0x40103d02
|
||||||
|
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||||
|
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||||
|
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||||
|
PTP_PEROUT_REQUEST = 0x40383d03
|
||||||
|
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||||
|
PTP_PIN_SETFUNC = 0x40603d07
|
||||||
|
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||||
|
PTP_SYS_OFFSET = 0x43403d05
|
||||||
|
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||||
PTRACE_GETFPREGS = 0xe
|
PTRACE_GETFPREGS = 0xe
|
||||||
PTRACE_GETFPXREGS = 0x12
|
PTRACE_GETFPXREGS = 0x12
|
||||||
PTRACE_GET_THREAD_AREA = 0x19
|
PTRACE_GET_THREAD_AREA = 0x19
|
||||||
|
|
@ -278,10 +301,13 @@ const (
|
||||||
RTC_WIE_ON = 0x700f
|
RTC_WIE_ON = 0x700f
|
||||||
RTC_WKALM_RD = 0x80287010
|
RTC_WKALM_RD = 0x80287010
|
||||||
RTC_WKALM_SET = 0x4028700f
|
RTC_WKALM_SET = 0x4028700f
|
||||||
|
SCM_DEVMEM_DMABUF = 0x4f
|
||||||
|
SCM_DEVMEM_LINEAR = 0x4e
|
||||||
SCM_TIMESTAMPING = 0x25
|
SCM_TIMESTAMPING = 0x25
|
||||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||||
SCM_TIMESTAMPNS = 0x23
|
SCM_TIMESTAMPNS = 0x23
|
||||||
|
SCM_TS_OPT_ID = 0x51
|
||||||
SCM_TXTIME = 0x3d
|
SCM_TXTIME = 0x3d
|
||||||
SCM_WIFI_STATUS = 0x29
|
SCM_WIFI_STATUS = 0x29
|
||||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||||
|
|
@ -316,6 +342,9 @@ const (
|
||||||
SO_CNX_ADVICE = 0x35
|
SO_CNX_ADVICE = 0x35
|
||||||
SO_COOKIE = 0x39
|
SO_COOKIE = 0x39
|
||||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||||
|
SO_DEVMEM_DMABUF = 0x4f
|
||||||
|
SO_DEVMEM_DONTNEED = 0x50
|
||||||
|
SO_DEVMEM_LINEAR = 0x4e
|
||||||
SO_DOMAIN = 0x27
|
SO_DOMAIN = 0x27
|
||||||
SO_DONTROUTE = 0x5
|
SO_DONTROUTE = 0x5
|
||||||
SO_ERROR = 0x4
|
SO_ERROR = 0x4
|
||||||
|
|
@ -332,6 +361,7 @@ const (
|
||||||
SO_OOBINLINE = 0xa
|
SO_OOBINLINE = 0xa
|
||||||
SO_PASSCRED = 0x10
|
SO_PASSCRED = 0x10
|
||||||
SO_PASSPIDFD = 0x4c
|
SO_PASSPIDFD = 0x4c
|
||||||
|
SO_PASSRIGHTS = 0x53
|
||||||
SO_PASSSEC = 0x22
|
SO_PASSSEC = 0x22
|
||||||
SO_PEEK_OFF = 0x2a
|
SO_PEEK_OFF = 0x2a
|
||||||
SO_PEERCRED = 0x11
|
SO_PEERCRED = 0x11
|
||||||
|
|
@ -344,6 +374,7 @@ const (
|
||||||
SO_RCVBUFFORCE = 0x21
|
SO_RCVBUFFORCE = 0x21
|
||||||
SO_RCVLOWAT = 0x12
|
SO_RCVLOWAT = 0x12
|
||||||
SO_RCVMARK = 0x4b
|
SO_RCVMARK = 0x4b
|
||||||
|
SO_RCVPRIORITY = 0x52
|
||||||
SO_RCVTIMEO = 0x14
|
SO_RCVTIMEO = 0x14
|
||||||
SO_RCVTIMEO_NEW = 0x42
|
SO_RCVTIMEO_NEW = 0x42
|
||||||
SO_RCVTIMEO_OLD = 0x14
|
SO_RCVTIMEO_OLD = 0x14
|
||||||
|
|
|
||||||
31
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
generated
vendored
31
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
generated
vendored
|
|
@ -68,6 +68,7 @@ const (
|
||||||
CS8 = 0x30
|
CS8 = 0x30
|
||||||
CSIZE = 0x30
|
CSIZE = 0x30
|
||||||
CSTOPB = 0x40
|
CSTOPB = 0x40
|
||||||
|
DM_MPATH_PROBE_PATHS = 0xfd12
|
||||||
ECCGETLAYOUT = 0x81484d11
|
ECCGETLAYOUT = 0x81484d11
|
||||||
ECCGETSTATS = 0x80104d12
|
ECCGETSTATS = 0x80104d12
|
||||||
ECHOCTL = 0x200
|
ECHOCTL = 0x200
|
||||||
|
|
@ -109,12 +110,15 @@ const (
|
||||||
HIDIOCGRAWINFO = 0x80084803
|
HIDIOCGRAWINFO = 0x80084803
|
||||||
HIDIOCGRDESC = 0x90044802
|
HIDIOCGRDESC = 0x90044802
|
||||||
HIDIOCGRDESCSIZE = 0x80044801
|
HIDIOCGRDESCSIZE = 0x80044801
|
||||||
|
HIDIOCREVOKE = 0x4004480d
|
||||||
HUPCL = 0x400
|
HUPCL = 0x400
|
||||||
ICANON = 0x2
|
ICANON = 0x2
|
||||||
IEXTEN = 0x8000
|
IEXTEN = 0x8000
|
||||||
IN_CLOEXEC = 0x80000
|
IN_CLOEXEC = 0x80000
|
||||||
IN_NONBLOCK = 0x800
|
IN_NONBLOCK = 0x800
|
||||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||||
|
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||||
|
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||||
ISIG = 0x1
|
ISIG = 0x1
|
||||||
IUCLC = 0x200
|
IUCLC = 0x200
|
||||||
IXOFF = 0x1000
|
IXOFF = 0x1000
|
||||||
|
|
@ -153,9 +157,14 @@ const (
|
||||||
NFDBITS = 0x40
|
NFDBITS = 0x40
|
||||||
NLDLY = 0x100
|
NLDLY = 0x100
|
||||||
NOFLSH = 0x80
|
NOFLSH = 0x80
|
||||||
|
NS_GET_MNTNS_ID = 0x8008b705
|
||||||
NS_GET_NSTYPE = 0xb703
|
NS_GET_NSTYPE = 0xb703
|
||||||
NS_GET_OWNER_UID = 0xb704
|
NS_GET_OWNER_UID = 0xb704
|
||||||
NS_GET_PARENT = 0xb702
|
NS_GET_PARENT = 0xb702
|
||||||
|
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||||
|
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||||
|
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||||
|
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||||
NS_GET_USERNS = 0xb701
|
NS_GET_USERNS = 0xb701
|
||||||
OLCUC = 0x2
|
OLCUC = 0x2
|
||||||
ONLCR = 0x4
|
ONLCR = 0x4
|
||||||
|
|
@ -232,6 +241,20 @@ const (
|
||||||
PPPIOCUNBRIDGECHAN = 0x7434
|
PPPIOCUNBRIDGECHAN = 0x7434
|
||||||
PPPIOCXFERUNIT = 0x744e
|
PPPIOCXFERUNIT = 0x744e
|
||||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||||
|
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||||
|
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||||
|
PTP_ENABLE_PPS = 0x40043d04
|
||||||
|
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||||
|
PTP_EXTTS_REQUEST = 0x40103d02
|
||||||
|
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||||
|
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||||
|
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||||
|
PTP_PEROUT_REQUEST = 0x40383d03
|
||||||
|
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||||
|
PTP_PIN_SETFUNC = 0x40603d07
|
||||||
|
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||||
|
PTP_SYS_OFFSET = 0x43403d05
|
||||||
|
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||||
PTRACE_ARCH_PRCTL = 0x1e
|
PTRACE_ARCH_PRCTL = 0x1e
|
||||||
PTRACE_GETFPREGS = 0xe
|
PTRACE_GETFPREGS = 0xe
|
||||||
PTRACE_GETFPXREGS = 0x12
|
PTRACE_GETFPXREGS = 0x12
|
||||||
|
|
@ -279,10 +302,13 @@ const (
|
||||||
RTC_WIE_ON = 0x700f
|
RTC_WIE_ON = 0x700f
|
||||||
RTC_WKALM_RD = 0x80287010
|
RTC_WKALM_RD = 0x80287010
|
||||||
RTC_WKALM_SET = 0x4028700f
|
RTC_WKALM_SET = 0x4028700f
|
||||||
|
SCM_DEVMEM_DMABUF = 0x4f
|
||||||
|
SCM_DEVMEM_LINEAR = 0x4e
|
||||||
SCM_TIMESTAMPING = 0x25
|
SCM_TIMESTAMPING = 0x25
|
||||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||||
SCM_TIMESTAMPNS = 0x23
|
SCM_TIMESTAMPNS = 0x23
|
||||||
|
SCM_TS_OPT_ID = 0x51
|
||||||
SCM_TXTIME = 0x3d
|
SCM_TXTIME = 0x3d
|
||||||
SCM_WIFI_STATUS = 0x29
|
SCM_WIFI_STATUS = 0x29
|
||||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||||
|
|
@ -317,6 +343,9 @@ const (
|
||||||
SO_CNX_ADVICE = 0x35
|
SO_CNX_ADVICE = 0x35
|
||||||
SO_COOKIE = 0x39
|
SO_COOKIE = 0x39
|
||||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||||
|
SO_DEVMEM_DMABUF = 0x4f
|
||||||
|
SO_DEVMEM_DONTNEED = 0x50
|
||||||
|
SO_DEVMEM_LINEAR = 0x4e
|
||||||
SO_DOMAIN = 0x27
|
SO_DOMAIN = 0x27
|
||||||
SO_DONTROUTE = 0x5
|
SO_DONTROUTE = 0x5
|
||||||
SO_ERROR = 0x4
|
SO_ERROR = 0x4
|
||||||
|
|
@ -333,6 +362,7 @@ const (
|
||||||
SO_OOBINLINE = 0xa
|
SO_OOBINLINE = 0xa
|
||||||
SO_PASSCRED = 0x10
|
SO_PASSCRED = 0x10
|
||||||
SO_PASSPIDFD = 0x4c
|
SO_PASSPIDFD = 0x4c
|
||||||
|
SO_PASSRIGHTS = 0x53
|
||||||
SO_PASSSEC = 0x22
|
SO_PASSSEC = 0x22
|
||||||
SO_PEEK_OFF = 0x2a
|
SO_PEEK_OFF = 0x2a
|
||||||
SO_PEERCRED = 0x11
|
SO_PEERCRED = 0x11
|
||||||
|
|
@ -345,6 +375,7 @@ const (
|
||||||
SO_RCVBUFFORCE = 0x21
|
SO_RCVBUFFORCE = 0x21
|
||||||
SO_RCVLOWAT = 0x12
|
SO_RCVLOWAT = 0x12
|
||||||
SO_RCVMARK = 0x4b
|
SO_RCVMARK = 0x4b
|
||||||
|
SO_RCVPRIORITY = 0x52
|
||||||
SO_RCVTIMEO = 0x14
|
SO_RCVTIMEO = 0x14
|
||||||
SO_RCVTIMEO_NEW = 0x42
|
SO_RCVTIMEO_NEW = 0x42
|
||||||
SO_RCVTIMEO_OLD = 0x14
|
SO_RCVTIMEO_OLD = 0x14
|
||||||
|
|
|
||||||
31
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
generated
vendored
31
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
generated
vendored
|
|
@ -68,6 +68,7 @@ const (
|
||||||
CS8 = 0x30
|
CS8 = 0x30
|
||||||
CSIZE = 0x30
|
CSIZE = 0x30
|
||||||
CSTOPB = 0x40
|
CSTOPB = 0x40
|
||||||
|
DM_MPATH_PROBE_PATHS = 0xfd12
|
||||||
ECCGETLAYOUT = 0x81484d11
|
ECCGETLAYOUT = 0x81484d11
|
||||||
ECCGETSTATS = 0x80104d12
|
ECCGETSTATS = 0x80104d12
|
||||||
ECHOCTL = 0x200
|
ECHOCTL = 0x200
|
||||||
|
|
@ -108,12 +109,15 @@ const (
|
||||||
HIDIOCGRAWINFO = 0x80084803
|
HIDIOCGRAWINFO = 0x80084803
|
||||||
HIDIOCGRDESC = 0x90044802
|
HIDIOCGRDESC = 0x90044802
|
||||||
HIDIOCGRDESCSIZE = 0x80044801
|
HIDIOCGRDESCSIZE = 0x80044801
|
||||||
|
HIDIOCREVOKE = 0x4004480d
|
||||||
HUPCL = 0x400
|
HUPCL = 0x400
|
||||||
ICANON = 0x2
|
ICANON = 0x2
|
||||||
IEXTEN = 0x8000
|
IEXTEN = 0x8000
|
||||||
IN_CLOEXEC = 0x80000
|
IN_CLOEXEC = 0x80000
|
||||||
IN_NONBLOCK = 0x800
|
IN_NONBLOCK = 0x800
|
||||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||||
|
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||||
|
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||||
ISIG = 0x1
|
ISIG = 0x1
|
||||||
IUCLC = 0x200
|
IUCLC = 0x200
|
||||||
IXOFF = 0x1000
|
IXOFF = 0x1000
|
||||||
|
|
@ -150,9 +154,14 @@ const (
|
||||||
NFDBITS = 0x20
|
NFDBITS = 0x20
|
||||||
NLDLY = 0x100
|
NLDLY = 0x100
|
||||||
NOFLSH = 0x80
|
NOFLSH = 0x80
|
||||||
|
NS_GET_MNTNS_ID = 0x8008b705
|
||||||
NS_GET_NSTYPE = 0xb703
|
NS_GET_NSTYPE = 0xb703
|
||||||
NS_GET_OWNER_UID = 0xb704
|
NS_GET_OWNER_UID = 0xb704
|
||||||
NS_GET_PARENT = 0xb702
|
NS_GET_PARENT = 0xb702
|
||||||
|
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||||
|
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||||
|
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||||
|
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||||
NS_GET_USERNS = 0xb701
|
NS_GET_USERNS = 0xb701
|
||||||
OLCUC = 0x2
|
OLCUC = 0x2
|
||||||
ONLCR = 0x4
|
ONLCR = 0x4
|
||||||
|
|
@ -229,6 +238,20 @@ const (
|
||||||
PPPIOCUNBRIDGECHAN = 0x7434
|
PPPIOCUNBRIDGECHAN = 0x7434
|
||||||
PPPIOCXFERUNIT = 0x744e
|
PPPIOCXFERUNIT = 0x744e
|
||||||
PR_SET_PTRACER_ANY = 0xffffffff
|
PR_SET_PTRACER_ANY = 0xffffffff
|
||||||
|
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||||
|
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||||
|
PTP_ENABLE_PPS = 0x40043d04
|
||||||
|
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||||
|
PTP_EXTTS_REQUEST = 0x40103d02
|
||||||
|
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||||
|
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||||
|
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||||
|
PTP_PEROUT_REQUEST = 0x40383d03
|
||||||
|
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||||
|
PTP_PIN_SETFUNC = 0x40603d07
|
||||||
|
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||||
|
PTP_SYS_OFFSET = 0x43403d05
|
||||||
|
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||||
PTRACE_GETCRUNCHREGS = 0x19
|
PTRACE_GETCRUNCHREGS = 0x19
|
||||||
PTRACE_GETFDPIC = 0x1f
|
PTRACE_GETFDPIC = 0x1f
|
||||||
PTRACE_GETFDPIC_EXEC = 0x0
|
PTRACE_GETFDPIC_EXEC = 0x0
|
||||||
|
|
@ -284,10 +307,13 @@ const (
|
||||||
RTC_WIE_ON = 0x700f
|
RTC_WIE_ON = 0x700f
|
||||||
RTC_WKALM_RD = 0x80287010
|
RTC_WKALM_RD = 0x80287010
|
||||||
RTC_WKALM_SET = 0x4028700f
|
RTC_WKALM_SET = 0x4028700f
|
||||||
|
SCM_DEVMEM_DMABUF = 0x4f
|
||||||
|
SCM_DEVMEM_LINEAR = 0x4e
|
||||||
SCM_TIMESTAMPING = 0x25
|
SCM_TIMESTAMPING = 0x25
|
||||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||||
SCM_TIMESTAMPNS = 0x23
|
SCM_TIMESTAMPNS = 0x23
|
||||||
|
SCM_TS_OPT_ID = 0x51
|
||||||
SCM_TXTIME = 0x3d
|
SCM_TXTIME = 0x3d
|
||||||
SCM_WIFI_STATUS = 0x29
|
SCM_WIFI_STATUS = 0x29
|
||||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||||
|
|
@ -322,6 +348,9 @@ const (
|
||||||
SO_CNX_ADVICE = 0x35
|
SO_CNX_ADVICE = 0x35
|
||||||
SO_COOKIE = 0x39
|
SO_COOKIE = 0x39
|
||||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||||
|
SO_DEVMEM_DMABUF = 0x4f
|
||||||
|
SO_DEVMEM_DONTNEED = 0x50
|
||||||
|
SO_DEVMEM_LINEAR = 0x4e
|
||||||
SO_DOMAIN = 0x27
|
SO_DOMAIN = 0x27
|
||||||
SO_DONTROUTE = 0x5
|
SO_DONTROUTE = 0x5
|
||||||
SO_ERROR = 0x4
|
SO_ERROR = 0x4
|
||||||
|
|
@ -338,6 +367,7 @@ const (
|
||||||
SO_OOBINLINE = 0xa
|
SO_OOBINLINE = 0xa
|
||||||
SO_PASSCRED = 0x10
|
SO_PASSCRED = 0x10
|
||||||
SO_PASSPIDFD = 0x4c
|
SO_PASSPIDFD = 0x4c
|
||||||
|
SO_PASSRIGHTS = 0x53
|
||||||
SO_PASSSEC = 0x22
|
SO_PASSSEC = 0x22
|
||||||
SO_PEEK_OFF = 0x2a
|
SO_PEEK_OFF = 0x2a
|
||||||
SO_PEERCRED = 0x11
|
SO_PEERCRED = 0x11
|
||||||
|
|
@ -350,6 +380,7 @@ const (
|
||||||
SO_RCVBUFFORCE = 0x21
|
SO_RCVBUFFORCE = 0x21
|
||||||
SO_RCVLOWAT = 0x12
|
SO_RCVLOWAT = 0x12
|
||||||
SO_RCVMARK = 0x4b
|
SO_RCVMARK = 0x4b
|
||||||
|
SO_RCVPRIORITY = 0x52
|
||||||
SO_RCVTIMEO = 0x14
|
SO_RCVTIMEO = 0x14
|
||||||
SO_RCVTIMEO_NEW = 0x42
|
SO_RCVTIMEO_NEW = 0x42
|
||||||
SO_RCVTIMEO_OLD = 0x14
|
SO_RCVTIMEO_OLD = 0x14
|
||||||
|
|
|
||||||
33
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
generated
vendored
33
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
generated
vendored
|
|
@ -68,6 +68,7 @@ const (
|
||||||
CS8 = 0x30
|
CS8 = 0x30
|
||||||
CSIZE = 0x30
|
CSIZE = 0x30
|
||||||
CSTOPB = 0x40
|
CSTOPB = 0x40
|
||||||
|
DM_MPATH_PROBE_PATHS = 0xfd12
|
||||||
ECCGETLAYOUT = 0x81484d11
|
ECCGETLAYOUT = 0x81484d11
|
||||||
ECCGETSTATS = 0x80104d12
|
ECCGETSTATS = 0x80104d12
|
||||||
ECHOCTL = 0x200
|
ECHOCTL = 0x200
|
||||||
|
|
@ -109,15 +110,19 @@ const (
|
||||||
F_SETOWN = 0x8
|
F_SETOWN = 0x8
|
||||||
F_UNLCK = 0x2
|
F_UNLCK = 0x2
|
||||||
F_WRLCK = 0x1
|
F_WRLCK = 0x1
|
||||||
|
GCS_MAGIC = 0x47435300
|
||||||
HIDIOCGRAWINFO = 0x80084803
|
HIDIOCGRAWINFO = 0x80084803
|
||||||
HIDIOCGRDESC = 0x90044802
|
HIDIOCGRDESC = 0x90044802
|
||||||
HIDIOCGRDESCSIZE = 0x80044801
|
HIDIOCGRDESCSIZE = 0x80044801
|
||||||
|
HIDIOCREVOKE = 0x4004480d
|
||||||
HUPCL = 0x400
|
HUPCL = 0x400
|
||||||
ICANON = 0x2
|
ICANON = 0x2
|
||||||
IEXTEN = 0x8000
|
IEXTEN = 0x8000
|
||||||
IN_CLOEXEC = 0x80000
|
IN_CLOEXEC = 0x80000
|
||||||
IN_NONBLOCK = 0x800
|
IN_NONBLOCK = 0x800
|
||||||
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
IOCTL_VM_SOCKETS_GET_LOCAL_CID = 0x7b9
|
||||||
|
IPV6_FLOWINFO_MASK = 0xffffff0f
|
||||||
|
IPV6_FLOWLABEL_MASK = 0xffff0f00
|
||||||
ISIG = 0x1
|
ISIG = 0x1
|
||||||
IUCLC = 0x200
|
IUCLC = 0x200
|
||||||
IXOFF = 0x1000
|
IXOFF = 0x1000
|
||||||
|
|
@ -154,9 +159,14 @@ const (
|
||||||
NFDBITS = 0x40
|
NFDBITS = 0x40
|
||||||
NLDLY = 0x100
|
NLDLY = 0x100
|
||||||
NOFLSH = 0x80
|
NOFLSH = 0x80
|
||||||
|
NS_GET_MNTNS_ID = 0x8008b705
|
||||||
NS_GET_NSTYPE = 0xb703
|
NS_GET_NSTYPE = 0xb703
|
||||||
NS_GET_OWNER_UID = 0xb704
|
NS_GET_OWNER_UID = 0xb704
|
||||||
NS_GET_PARENT = 0xb702
|
NS_GET_PARENT = 0xb702
|
||||||
|
NS_GET_PID_FROM_PIDNS = 0x8004b706
|
||||||
|
NS_GET_PID_IN_PIDNS = 0x8004b708
|
||||||
|
NS_GET_TGID_FROM_PIDNS = 0x8004b707
|
||||||
|
NS_GET_TGID_IN_PIDNS = 0x8004b709
|
||||||
NS_GET_USERNS = 0xb701
|
NS_GET_USERNS = 0xb701
|
||||||
OLCUC = 0x2
|
OLCUC = 0x2
|
||||||
ONLCR = 0x4
|
ONLCR = 0x4
|
||||||
|
|
@ -200,6 +210,7 @@ const (
|
||||||
PERF_EVENT_IOC_SET_BPF = 0x40042408
|
PERF_EVENT_IOC_SET_BPF = 0x40042408
|
||||||
PERF_EVENT_IOC_SET_FILTER = 0x40082406
|
PERF_EVENT_IOC_SET_FILTER = 0x40082406
|
||||||
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
|
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
|
||||||
|
POE_MAGIC = 0x504f4530
|
||||||
PPPIOCATTACH = 0x4004743d
|
PPPIOCATTACH = 0x4004743d
|
||||||
PPPIOCATTCHAN = 0x40047438
|
PPPIOCATTCHAN = 0x40047438
|
||||||
PPPIOCBRIDGECHAN = 0x40047435
|
PPPIOCBRIDGECHAN = 0x40047435
|
||||||
|
|
@ -235,6 +246,20 @@ const (
|
||||||
PROT_BTI = 0x10
|
PROT_BTI = 0x10
|
||||||
PROT_MTE = 0x20
|
PROT_MTE = 0x20
|
||||||
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
PR_SET_PTRACER_ANY = 0xffffffffffffffff
|
||||||
|
PTP_CLOCK_GETCAPS = 0x80503d01
|
||||||
|
PTP_CLOCK_GETCAPS2 = 0x80503d0a
|
||||||
|
PTP_ENABLE_PPS = 0x40043d04
|
||||||
|
PTP_ENABLE_PPS2 = 0x40043d0d
|
||||||
|
PTP_EXTTS_REQUEST = 0x40103d02
|
||||||
|
PTP_EXTTS_REQUEST2 = 0x40103d0b
|
||||||
|
PTP_MASK_CLEAR_ALL = 0x3d13
|
||||||
|
PTP_MASK_EN_SINGLE = 0x40043d14
|
||||||
|
PTP_PEROUT_REQUEST = 0x40383d03
|
||||||
|
PTP_PEROUT_REQUEST2 = 0x40383d0c
|
||||||
|
PTP_PIN_SETFUNC = 0x40603d07
|
||||||
|
PTP_PIN_SETFUNC2 = 0x40603d10
|
||||||
|
PTP_SYS_OFFSET = 0x43403d05
|
||||||
|
PTP_SYS_OFFSET2 = 0x43403d0e
|
||||||
PTRACE_PEEKMTETAGS = 0x21
|
PTRACE_PEEKMTETAGS = 0x21
|
||||||
PTRACE_POKEMTETAGS = 0x22
|
PTRACE_POKEMTETAGS = 0x22
|
||||||
PTRACE_SYSEMU = 0x1f
|
PTRACE_SYSEMU = 0x1f
|
||||||
|
|
@ -275,10 +300,13 @@ const (
|
||||||
RTC_WIE_ON = 0x700f
|
RTC_WIE_ON = 0x700f
|
||||||
RTC_WKALM_RD = 0x80287010
|
RTC_WKALM_RD = 0x80287010
|
||||||
RTC_WKALM_SET = 0x4028700f
|
RTC_WKALM_SET = 0x4028700f
|
||||||
|
SCM_DEVMEM_DMABUF = 0x4f
|
||||||
|
SCM_DEVMEM_LINEAR = 0x4e
|
||||||
SCM_TIMESTAMPING = 0x25
|
SCM_TIMESTAMPING = 0x25
|
||||||
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
SCM_TIMESTAMPING_OPT_STATS = 0x36
|
||||||
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
SCM_TIMESTAMPING_PKTINFO = 0x3a
|
||||||
SCM_TIMESTAMPNS = 0x23
|
SCM_TIMESTAMPNS = 0x23
|
||||||
|
SCM_TS_OPT_ID = 0x51
|
||||||
SCM_TXTIME = 0x3d
|
SCM_TXTIME = 0x3d
|
||||||
SCM_WIFI_STATUS = 0x29
|
SCM_WIFI_STATUS = 0x29
|
||||||
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
SECCOMP_IOCTL_NOTIF_ADDFD = 0x40182103
|
||||||
|
|
@ -313,6 +341,9 @@ const (
|
||||||
SO_CNX_ADVICE = 0x35
|
SO_CNX_ADVICE = 0x35
|
||||||
SO_COOKIE = 0x39
|
SO_COOKIE = 0x39
|
||||||
SO_DETACH_REUSEPORT_BPF = 0x44
|
SO_DETACH_REUSEPORT_BPF = 0x44
|
||||||
|
SO_DEVMEM_DMABUF = 0x4f
|
||||||
|
SO_DEVMEM_DONTNEED = 0x50
|
||||||
|
SO_DEVMEM_LINEAR = 0x4e
|
||||||
SO_DOMAIN = 0x27
|
SO_DOMAIN = 0x27
|
||||||
SO_DONTROUTE = 0x5
|
SO_DONTROUTE = 0x5
|
||||||
SO_ERROR = 0x4
|
SO_ERROR = 0x4
|
||||||
|
|
@ -329,6 +360,7 @@ const (
|
||||||
SO_OOBINLINE = 0xa
|
SO_OOBINLINE = 0xa
|
||||||
SO_PASSCRED = 0x10
|
SO_PASSCRED = 0x10
|
||||||
SO_PASSPIDFD = 0x4c
|
SO_PASSPIDFD = 0x4c
|
||||||
|
SO_PASSRIGHTS = 0x53
|
||||||
SO_PASSSEC = 0x22
|
SO_PASSSEC = 0x22
|
||||||
SO_PEEK_OFF = 0x2a
|
SO_PEEK_OFF = 0x2a
|
||||||
SO_PEERCRED = 0x11
|
SO_PEERCRED = 0x11
|
||||||
|
|
@ -341,6 +373,7 @@ const (
|
||||||
SO_RCVBUFFORCE = 0x21
|
SO_RCVBUFFORCE = 0x21
|
||||||
SO_RCVLOWAT = 0x12
|
SO_RCVLOWAT = 0x12
|
||||||
SO_RCVMARK = 0x4b
|
SO_RCVMARK = 0x4b
|
||||||
|
SO_RCVPRIORITY = 0x52
|
||||||
SO_RCVTIMEO = 0x14
|
SO_RCVTIMEO = 0x14
|
||||||
SO_RCVTIMEO_NEW = 0x42
|
SO_RCVTIMEO_NEW = 0x42
|
||||||
SO_RCVTIMEO_OLD = 0x14
|
SO_RCVTIMEO_OLD = 0x14
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue