Compare commits
No commits in common. "master" and "v0.1.0" have entirely different histories.
144
.drone.yml
144
.drone.yml
@ -1,144 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: cleanup-before
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: clean
|
|
||||||
image: alpine
|
|
||||||
commands:
|
|
||||||
- rm -rf /build/*
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
path: /build
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
host:
|
|
||||||
path: /tmp/adradius/build
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: default-linux-amd64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build
|
|
||||||
image: golang
|
|
||||||
commands:
|
|
||||||
- ./ci-build.sh build
|
|
||||||
environment:
|
|
||||||
GOOS: linux
|
|
||||||
GOARCH: amd64
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
path: /build
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
host:
|
|
||||||
path: /tmp/adradius/build
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- cleanup-before
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: default-linux-arm64
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: build
|
|
||||||
image: golang
|
|
||||||
commands:
|
|
||||||
- ./ci-build.sh build
|
|
||||||
environment:
|
|
||||||
GOOS: linux
|
|
||||||
GOARCH: arm64
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
path: /build
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
host:
|
|
||||||
path: /tmp/adradius/build
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- cleanup-before
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: gitea-release
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: move
|
|
||||||
image: alpine
|
|
||||||
commands:
|
|
||||||
- mv build/* ./
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
path: /drone/src/build
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
- name: release
|
|
||||||
image: plugins/gitea-release
|
|
||||||
settings:
|
|
||||||
base_url: https://git.paulbsd.com
|
|
||||||
api_key:
|
|
||||||
from_secret: gitea_token
|
|
||||||
files: "*.tar.gz"
|
|
||||||
checksum:
|
|
||||||
- sha256
|
|
||||||
- sha512
|
|
||||||
title: VERSION
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
path: /drone/src/build
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
- name: ls
|
|
||||||
image: alpine
|
|
||||||
commands:
|
|
||||||
- find .
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
path: /drone/src/build
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
host:
|
|
||||||
path: /tmp/adradius/build
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- default-linux-amd64
|
|
||||||
- default-linux-arm64
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
type: docker
|
|
||||||
name: cleanup-after
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: clean
|
|
||||||
image: alpine
|
|
||||||
commands:
|
|
||||||
- rm -rf /build/*
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
path: /build
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: build
|
|
||||||
host:
|
|
||||||
path: /tmp/adradius/build
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- gitea-release
|
|
@ -42,7 +42,7 @@ listen=localhost:1812 # listen params for radius server as a string
|
|||||||
|
|
||||||
## License
|
## License
|
||||||
```text
|
```text
|
||||||
Copyright (c) 2020 PaulBSD
|
Copyright (c) 2020, PaulBSD
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
@ -67,5 +67,5 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
The views and conclusions contained in the software and documentation are those
|
The views and conclusions contained in the software and documentation are those
|
||||||
of the authors and should not be interpreted as representing official policies,
|
of the authors and should not be interpreted as representing official policies,
|
||||||
either expressed or implied, of this project.
|
either expressed or implied, of the adradius project.
|
||||||
```
|
```
|
||||||
|
62
ci-build.sh
62
ci-build.sh
@ -1,62 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
PROJECTNAME=adradius
|
|
||||||
RELEASENAME=${PROJECTNAME}
|
|
||||||
VERSION="0"
|
|
||||||
|
|
||||||
GOOPTIONS="-mod=vendor"
|
|
||||||
SRCFILES=cmd/adradius/*.go
|
|
||||||
|
|
||||||
build() {
|
|
||||||
echo "Begin of build"
|
|
||||||
if [[ ! -z $DRONE_TAG ]]
|
|
||||||
then
|
|
||||||
echo "Drone tag set, let's do a release"
|
|
||||||
VERSION=$DRONE_TAG
|
|
||||||
echo "${PROJECTNAME} ${VERSION}" > /build/VERSION
|
|
||||||
elif [[ ! -z $DRONE_TAG ]]
|
|
||||||
then
|
|
||||||
echo "Drone not set, let's only do a build"
|
|
||||||
VERSION=$DRONE_COMMIT
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]]
|
|
||||||
then
|
|
||||||
echo "Let's set a release name"
|
|
||||||
RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH}
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Building project"
|
|
||||||
go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES}
|
|
||||||
|
|
||||||
if [[ ! -z $DRONE_TAG ]]
|
|
||||||
then
|
|
||||||
echo "Let's make archives"
|
|
||||||
mkdir -p /build
|
|
||||||
tar -czvf /build/${RELEASENAME}.tar.gz ${PROJECTNAME}
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Removing binary file"
|
|
||||||
rm ${PROJECTNAME}
|
|
||||||
|
|
||||||
echo "End of build"
|
|
||||||
}
|
|
||||||
|
|
||||||
clean() {
|
|
||||||
rm -rf $RELEASEDIR
|
|
||||||
}
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
"build")
|
|
||||||
build
|
|
||||||
;;
|
|
||||||
"clean")
|
|
||||||
clean
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "No options choosen"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
13
go.mod
13
go.mod
@ -1,16 +1,13 @@
|
|||||||
module git.paulbsd.com/paulbsd/adradius
|
module git.paulbsd.com/paulbsd/adradius
|
||||||
|
|
||||||
go 1.15
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.3 // indirect
|
|
||||||
github.com/go-ldap/ldap/v3 v3.2.4
|
|
||||||
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
|
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
|
||||||
github.com/sevlyar/go-daemon v0.1.5
|
github.com/sevlyar/go-daemon v0.1.5
|
||||||
github.com/smartystreets/goconvey v1.6.4 // indirect
|
github.com/smartystreets/goconvey v1.6.4 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
|
golang.org/x/text v0.3.2
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
|
gopkg.in/ini.v1 v1.52.0
|
||||||
golang.org/x/text v0.3.5
|
gopkg.in/ldap.v3 v3.1.0
|
||||||
gopkg.in/ini.v1 v1.62.0
|
layeh.com/radius v0.0.0-20190322222518-890bc1058917
|
||||||
layeh.com/radius v0.0.0-20201203135236-838e26d0c9be
|
|
||||||
)
|
)
|
||||||
|
37
go.sum
37
go.sum
@ -1,11 +1,3 @@
|
|||||||
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c h1:/IBSNwUN8+eKzUzbJPqhK839ygXJ82sde8x3ogr6R28=
|
|
||||||
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
|
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.1 h1:pDbRAunXzIUXfx4CB2QJFv5IuPiuoW+sWvr/Us009o8=
|
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.3 h1:u7utq56RUFiynqUzgVMFDymapcOtQ/MZkh3H4QYkxag=
|
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.3/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
|
||||||
github.com/go-ldap/ldap/v3 v3.2.4 h1:PFavAq2xTgzo/loE8qNXcQaofAaqIpI4WgaLdv+1l3E=
|
|
||||||
github.com/go-ldap/ldap/v3 v3.2.4/go.mod h1:iYS1MdmrmceOJ1QOTnRXrIs7i3kloqtmGQjRvjKpyMg=
|
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||||
@ -19,28 +11,19 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1
|
|||||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
|
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
|
|
||||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
|
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
|
|
||||||
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||||
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
|
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d h1:TxyelI5cVkbREznMhfzycHdkp5cLA7DpE+GKjSslYhM=
|
||||||
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
|
||||||
layeh.com/radius v0.0.0-20201203135236-838e26d0c9be h1:4YeDNYYOf9Pnn3pWEktFE+ZCZ5qX5ZVMaw3VAtfoXPk=
|
gopkg.in/ini.v1 v1.52.0 h1:j+Lt/M1oPPejkniCg1TkWE2J3Eh1oZTsHSXzMTzUXn4=
|
||||||
layeh.com/radius v0.0.0-20201203135236-838e26d0c9be/go.mod h1:pFWM9De99EY9TPVyHIyA56QmoRViVck/x41WFkUlc9A=
|
gopkg.in/ini.v1 v1.52.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
|
gopkg.in/ldap.v3 v3.1.0 h1:DIDWEjI7vQWREh0S8X5/NFPCZ3MCVd55LmXKPW4XLGE=
|
||||||
|
gopkg.in/ldap.v3 v3.1.0/go.mod h1:dQjCc0R0kfyFjIlWNMH1DORwUASZyDxo2Ry1B51dXaQ=
|
||||||
|
layeh.com/radius v0.0.0-20190322222518-890bc1058917 h1:BDXFaFzUt5EIqe/4wrTc4AcYZWP6iC6Ult+jQWLh5eU=
|
||||||
|
layeh.com/radius v0.0.0-20190322222518-890bc1058917/go.mod h1:fywZKyu//X7iRzaxLgPWsvc0L26IUpVvE/aeIL2JtIQ=
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import ldap "github.com/go-ldap/ldap/v3"
|
import ldap "gopkg.in/ldap.v3"
|
||||||
|
|
||||||
//Authenticate checks if the given credentials are valid, or returns an error if one occurred.
|
//Authenticate checks if the given credentials are valid, or returns an error if one occurred.
|
||||||
//username may be either the sAMAccountName or the userPrincipalName.
|
//username may be either the sAMAccountName or the userPrincipalName.
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
ldap "github.com/go-ldap/ldap/v3"
|
ldap "gopkg.in/ldap.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//Conn represents an Active Directory connection.
|
//Conn represents an Active Directory connection.
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
ldap "github.com/go-ldap/ldap/v3"
|
|
||||||
"golang.org/x/text/encoding/unicode"
|
"golang.org/x/text/encoding/unicode"
|
||||||
|
ldap "gopkg.in/ldap.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//ModifyDNPassword sets a new password for the given user or returns an error if one occurred.
|
//ModifyDNPassword sets a new password for the given user or returns an error if one occurred.
|
||||||
|
@ -3,7 +3,7 @@ package auth
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
ldap "github.com/go-ldap/ldap/v3"
|
ldap "gopkg.in/ldap.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//Search returns the entries for the given search criteria or an error if one occurred.
|
//Search returns the entries for the given search criteria or an error if one occurred.
|
||||||
|
17
vendor/github.com/Azure/go-ntlmssp/.travis.yml
generated
vendored
17
vendor/github.com/Azure/go-ntlmssp/.travis.yml
generated
vendored
@ -1,17 +0,0 @@
|
|||||||
sudo: false
|
|
||||||
|
|
||||||
language: go
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- go get -u golang.org/x/lint/golint
|
|
||||||
|
|
||||||
go:
|
|
||||||
- 1.10.x
|
|
||||||
- master
|
|
||||||
|
|
||||||
script:
|
|
||||||
- test -z "$(gofmt -s -l . | tee /dev/stderr)"
|
|
||||||
- test -z "$(golint ./... | tee /dev/stderr)"
|
|
||||||
- go vet ./...
|
|
||||||
- go build -v ./...
|
|
||||||
- go test -v ./...
|
|
21
vendor/github.com/Azure/go-ntlmssp/LICENSE
generated
vendored
21
vendor/github.com/Azure/go-ntlmssp/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2016 Microsoft
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
29
vendor/github.com/Azure/go-ntlmssp/README.md
generated
vendored
29
vendor/github.com/Azure/go-ntlmssp/README.md
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
# go-ntlmssp
|
|
||||||
Golang package that provides NTLM/Negotiate authentication over HTTP
|
|
||||||
|
|
||||||
[](https://godoc.org/github.com/Azure/go-ntlmssp) [](https://travis-ci.org/Azure/go-ntlmssp)
|
|
||||||
|
|
||||||
Protocol details from https://msdn.microsoft.com/en-us/library/cc236621.aspx
|
|
||||||
Implementation hints from http://davenport.sourceforge.net/ntlm.html
|
|
||||||
|
|
||||||
This package only implements authentication, no key exchange or encryption. It
|
|
||||||
only supports Unicode (UTF16LE) encoding of protocol strings, no OEM encoding.
|
|
||||||
This package implements NTLMv2.
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
```
|
|
||||||
url, user, password := "http://www.example.com/secrets", "robpike", "pw123"
|
|
||||||
client := &http.Client{
|
|
||||||
Transport: ntlmssp.Negotiator{
|
|
||||||
RoundTripper:&http.Transport{},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
req, _ := http.NewRequest("GET", url, nil)
|
|
||||||
req.SetBasicAuth(user, password)
|
|
||||||
res, _ := client.Do(req)
|
|
||||||
```
|
|
||||||
|
|
||||||
-----
|
|
||||||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
|
|
183
vendor/github.com/Azure/go-ntlmssp/authenticate_message.go
generated
vendored
183
vendor/github.com/Azure/go-ntlmssp/authenticate_message.go
generated
vendored
@ -1,183 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"crypto/rand"
|
|
||||||
"encoding/binary"
|
|
||||||
"encoding/hex"
|
|
||||||
"errors"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type authenicateMessage struct {
|
|
||||||
LmChallengeResponse []byte
|
|
||||||
NtChallengeResponse []byte
|
|
||||||
|
|
||||||
TargetName string
|
|
||||||
UserName string
|
|
||||||
|
|
||||||
// only set if negotiateFlag_NTLMSSP_NEGOTIATE_KEY_EXCH
|
|
||||||
EncryptedRandomSessionKey []byte
|
|
||||||
|
|
||||||
NegotiateFlags negotiateFlags
|
|
||||||
|
|
||||||
MIC []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
type authenticateMessageFields struct {
|
|
||||||
messageHeader
|
|
||||||
LmChallengeResponse varField
|
|
||||||
NtChallengeResponse varField
|
|
||||||
TargetName varField
|
|
||||||
UserName varField
|
|
||||||
Workstation varField
|
|
||||||
_ [8]byte
|
|
||||||
NegotiateFlags negotiateFlags
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m authenicateMessage) MarshalBinary() ([]byte, error) {
|
|
||||||
if !m.NegotiateFlags.Has(negotiateFlagNTLMSSPNEGOTIATEUNICODE) {
|
|
||||||
return nil, errors.New("Only unicode is supported")
|
|
||||||
}
|
|
||||||
|
|
||||||
target, user := toUnicode(m.TargetName), toUnicode(m.UserName)
|
|
||||||
workstation := toUnicode("go-ntlmssp")
|
|
||||||
|
|
||||||
ptr := binary.Size(&authenticateMessageFields{})
|
|
||||||
f := authenticateMessageFields{
|
|
||||||
messageHeader: newMessageHeader(3),
|
|
||||||
NegotiateFlags: m.NegotiateFlags,
|
|
||||||
LmChallengeResponse: newVarField(&ptr, len(m.LmChallengeResponse)),
|
|
||||||
NtChallengeResponse: newVarField(&ptr, len(m.NtChallengeResponse)),
|
|
||||||
TargetName: newVarField(&ptr, len(target)),
|
|
||||||
UserName: newVarField(&ptr, len(user)),
|
|
||||||
Workstation: newVarField(&ptr, len(workstation)),
|
|
||||||
}
|
|
||||||
|
|
||||||
f.NegotiateFlags.Unset(negotiateFlagNTLMSSPNEGOTIATEVERSION)
|
|
||||||
|
|
||||||
b := bytes.Buffer{}
|
|
||||||
if err := binary.Write(&b, binary.LittleEndian, &f); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := binary.Write(&b, binary.LittleEndian, &m.LmChallengeResponse); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := binary.Write(&b, binary.LittleEndian, &m.NtChallengeResponse); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := binary.Write(&b, binary.LittleEndian, &target); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := binary.Write(&b, binary.LittleEndian, &user); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if err := binary.Write(&b, binary.LittleEndian, &workstation); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.Bytes(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//ProcessChallenge crafts an AUTHENTICATE message in response to the CHALLENGE message
|
|
||||||
//that was received from the server
|
|
||||||
func ProcessChallenge(challengeMessageData []byte, user, password string) ([]byte, error) {
|
|
||||||
if user == "" && password == "" {
|
|
||||||
return nil, errors.New("Anonymous authentication not supported")
|
|
||||||
}
|
|
||||||
|
|
||||||
var cm challengeMessage
|
|
||||||
if err := cm.UnmarshalBinary(challengeMessageData); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if cm.NegotiateFlags.Has(negotiateFlagNTLMSSPNEGOTIATELMKEY) {
|
|
||||||
return nil, errors.New("Only NTLM v2 is supported, but server requested v1 (NTLMSSP_NEGOTIATE_LM_KEY)")
|
|
||||||
}
|
|
||||||
if cm.NegotiateFlags.Has(negotiateFlagNTLMSSPNEGOTIATEKEYEXCH) {
|
|
||||||
return nil, errors.New("Key exchange requested but not supported (NTLMSSP_NEGOTIATE_KEY_EXCH)")
|
|
||||||
}
|
|
||||||
|
|
||||||
am := authenicateMessage{
|
|
||||||
UserName: user,
|
|
||||||
TargetName: cm.TargetName,
|
|
||||||
NegotiateFlags: cm.NegotiateFlags,
|
|
||||||
}
|
|
||||||
|
|
||||||
timestamp := cm.TargetInfo[avIDMsvAvTimestamp]
|
|
||||||
if timestamp == nil { // no time sent, take current time
|
|
||||||
ft := uint64(time.Now().UnixNano()) / 100
|
|
||||||
ft += 116444736000000000 // add time between unix & windows offset
|
|
||||||
timestamp = make([]byte, 8)
|
|
||||||
binary.LittleEndian.PutUint64(timestamp, ft)
|
|
||||||
}
|
|
||||||
|
|
||||||
clientChallenge := make([]byte, 8)
|
|
||||||
rand.Reader.Read(clientChallenge)
|
|
||||||
|
|
||||||
ntlmV2Hash := getNtlmV2Hash(password, user, cm.TargetName)
|
|
||||||
|
|
||||||
am.NtChallengeResponse = computeNtlmV2Response(ntlmV2Hash,
|
|
||||||
cm.ServerChallenge[:], clientChallenge, timestamp, cm.TargetInfoRaw)
|
|
||||||
|
|
||||||
if cm.TargetInfoRaw == nil {
|
|
||||||
am.LmChallengeResponse = computeLmV2Response(ntlmV2Hash,
|
|
||||||
cm.ServerChallenge[:], clientChallenge)
|
|
||||||
}
|
|
||||||
return am.MarshalBinary()
|
|
||||||
}
|
|
||||||
|
|
||||||
func ProcessChallengeWithHash(challengeMessageData []byte, user, hash string) ([]byte, error) {
|
|
||||||
if user == "" && hash == "" {
|
|
||||||
return nil, errors.New("Anonymous authentication not supported")
|
|
||||||
}
|
|
||||||
|
|
||||||
var cm challengeMessage
|
|
||||||
if err := cm.UnmarshalBinary(challengeMessageData); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if cm.NegotiateFlags.Has(negotiateFlagNTLMSSPNEGOTIATELMKEY) {
|
|
||||||
return nil, errors.New("Only NTLM v2 is supported, but server requested v1 (NTLMSSP_NEGOTIATE_LM_KEY)")
|
|
||||||
}
|
|
||||||
if cm.NegotiateFlags.Has(negotiateFlagNTLMSSPNEGOTIATEKEYEXCH) {
|
|
||||||
return nil, errors.New("Key exchange requested but not supported (NTLMSSP_NEGOTIATE_KEY_EXCH)")
|
|
||||||
}
|
|
||||||
|
|
||||||
am := authenicateMessage{
|
|
||||||
UserName: user,
|
|
||||||
TargetName: cm.TargetName,
|
|
||||||
NegotiateFlags: cm.NegotiateFlags,
|
|
||||||
}
|
|
||||||
|
|
||||||
timestamp := cm.TargetInfo[avIDMsvAvTimestamp]
|
|
||||||
if timestamp == nil { // no time sent, take current time
|
|
||||||
ft := uint64(time.Now().UnixNano()) / 100
|
|
||||||
ft += 116444736000000000 // add time between unix & windows offset
|
|
||||||
timestamp = make([]byte, 8)
|
|
||||||
binary.LittleEndian.PutUint64(timestamp, ft)
|
|
||||||
}
|
|
||||||
|
|
||||||
clientChallenge := make([]byte, 8)
|
|
||||||
rand.Reader.Read(clientChallenge)
|
|
||||||
|
|
||||||
hashParts := strings.Split(hash, ":")
|
|
||||||
if len(hashParts) > 1 {
|
|
||||||
hash = hashParts[1]
|
|
||||||
}
|
|
||||||
hashBytes, err := hex.DecodeString(hash)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ntlmV2Hash := hmacMd5(hashBytes, toUnicode(strings.ToUpper(user)+cm.TargetName))
|
|
||||||
|
|
||||||
am.NtChallengeResponse = computeNtlmV2Response(ntlmV2Hash,
|
|
||||||
cm.ServerChallenge[:], clientChallenge, timestamp, cm.TargetInfoRaw)
|
|
||||||
|
|
||||||
if cm.TargetInfoRaw == nil {
|
|
||||||
am.LmChallengeResponse = computeLmV2Response(ntlmV2Hash,
|
|
||||||
cm.ServerChallenge[:], clientChallenge)
|
|
||||||
}
|
|
||||||
return am.MarshalBinary()
|
|
||||||
}
|
|
37
vendor/github.com/Azure/go-ntlmssp/authheader.go
generated
vendored
37
vendor/github.com/Azure/go-ntlmssp/authheader.go
generated
vendored
@ -1,37 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/base64"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type authheader string
|
|
||||||
|
|
||||||
func (h authheader) IsBasic() bool {
|
|
||||||
return strings.HasPrefix(string(h), "Basic ")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h authheader) IsNegotiate() bool {
|
|
||||||
return strings.HasPrefix(string(h), "Negotiate")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h authheader) IsNTLM() bool {
|
|
||||||
return strings.HasPrefix(string(h), "NTLM")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h authheader) GetData() ([]byte, error) {
|
|
||||||
p := strings.Split(string(h), " ")
|
|
||||||
if len(p) < 2 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
return base64.StdEncoding.DecodeString(string(p[1]))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h authheader) GetBasicCreds() (username, password string, err error) {
|
|
||||||
d, err := h.GetData()
|
|
||||||
if err != nil {
|
|
||||||
return "", "", err
|
|
||||||
}
|
|
||||||
parts := strings.SplitN(string(d), ":", 2)
|
|
||||||
return parts[0], parts[1], nil
|
|
||||||
}
|
|
17
vendor/github.com/Azure/go-ntlmssp/avids.go
generated
vendored
17
vendor/github.com/Azure/go-ntlmssp/avids.go
generated
vendored
@ -1,17 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
type avID uint16
|
|
||||||
|
|
||||||
const (
|
|
||||||
avIDMsvAvEOL avID = iota
|
|
||||||
avIDMsvAvNbComputerName
|
|
||||||
avIDMsvAvNbDomainName
|
|
||||||
avIDMsvAvDNSComputerName
|
|
||||||
avIDMsvAvDNSDomainName
|
|
||||||
avIDMsvAvDNSTreeName
|
|
||||||
avIDMsvAvFlags
|
|
||||||
avIDMsvAvTimestamp
|
|
||||||
avIDMsvAvSingleHost
|
|
||||||
avIDMsvAvTargetName
|
|
||||||
avIDMsvChannelBindings
|
|
||||||
)
|
|
82
vendor/github.com/Azure/go-ntlmssp/challenge_message.go
generated
vendored
82
vendor/github.com/Azure/go-ntlmssp/challenge_message.go
generated
vendored
@ -1,82 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/binary"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type challengeMessageFields struct {
|
|
||||||
messageHeader
|
|
||||||
TargetName varField
|
|
||||||
NegotiateFlags negotiateFlags
|
|
||||||
ServerChallenge [8]byte
|
|
||||||
_ [8]byte
|
|
||||||
TargetInfo varField
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m challengeMessageFields) IsValid() bool {
|
|
||||||
return m.messageHeader.IsValid() && m.MessageType == 2
|
|
||||||
}
|
|
||||||
|
|
||||||
type challengeMessage struct {
|
|
||||||
challengeMessageFields
|
|
||||||
TargetName string
|
|
||||||
TargetInfo map[avID][]byte
|
|
||||||
TargetInfoRaw []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *challengeMessage) UnmarshalBinary(data []byte) error {
|
|
||||||
r := bytes.NewReader(data)
|
|
||||||
err := binary.Read(r, binary.LittleEndian, &m.challengeMessageFields)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !m.challengeMessageFields.IsValid() {
|
|
||||||
return fmt.Errorf("Message is not a valid challenge message: %+v", m.challengeMessageFields.messageHeader)
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.challengeMessageFields.TargetName.Len > 0 {
|
|
||||||
m.TargetName, err = m.challengeMessageFields.TargetName.ReadStringFrom(data, m.NegotiateFlags.Has(negotiateFlagNTLMSSPNEGOTIATEUNICODE))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.challengeMessageFields.TargetInfo.Len > 0 {
|
|
||||||
d, err := m.challengeMessageFields.TargetInfo.ReadFrom(data)
|
|
||||||
m.TargetInfoRaw = d
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
m.TargetInfo = make(map[avID][]byte)
|
|
||||||
r := bytes.NewReader(d)
|
|
||||||
for {
|
|
||||||
var id avID
|
|
||||||
var l uint16
|
|
||||||
err = binary.Read(r, binary.LittleEndian, &id)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if id == avIDMsvAvEOL {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
err = binary.Read(r, binary.LittleEndian, &l)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
value := make([]byte, l)
|
|
||||||
n, err := r.Read(value)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if n != int(l) {
|
|
||||||
return fmt.Errorf("Expected to read %d bytes, got only %d", l, n)
|
|
||||||
}
|
|
||||||
m.TargetInfo[id] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
21
vendor/github.com/Azure/go-ntlmssp/messageheader.go
generated
vendored
21
vendor/github.com/Azure/go-ntlmssp/messageheader.go
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
)
|
|
||||||
|
|
||||||
var signature = [8]byte{'N', 'T', 'L', 'M', 'S', 'S', 'P', 0}
|
|
||||||
|
|
||||||
type messageHeader struct {
|
|
||||||
Signature [8]byte
|
|
||||||
MessageType uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h messageHeader) IsValid() bool {
|
|
||||||
return bytes.Equal(h.Signature[:], signature[:]) &&
|
|
||||||
h.MessageType > 0 && h.MessageType < 4
|
|
||||||
}
|
|
||||||
|
|
||||||
func newMessageHeader(messageType uint32) messageHeader {
|
|
||||||
return messageHeader{signature, messageType}
|
|
||||||
}
|
|
52
vendor/github.com/Azure/go-ntlmssp/negotiate_flags.go
generated
vendored
52
vendor/github.com/Azure/go-ntlmssp/negotiate_flags.go
generated
vendored
@ -1,52 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
type negotiateFlags uint32
|
|
||||||
|
|
||||||
const (
|
|
||||||
/*A*/ negotiateFlagNTLMSSPNEGOTIATEUNICODE negotiateFlags = 1 << 0
|
|
||||||
/*B*/ negotiateFlagNTLMNEGOTIATEOEM = 1 << 1
|
|
||||||
/*C*/ negotiateFlagNTLMSSPREQUESTTARGET = 1 << 2
|
|
||||||
|
|
||||||
/*D*/
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATESIGN = 1 << 4
|
|
||||||
/*E*/ negotiateFlagNTLMSSPNEGOTIATESEAL = 1 << 5
|
|
||||||
/*F*/ negotiateFlagNTLMSSPNEGOTIATEDATAGRAM = 1 << 6
|
|
||||||
/*G*/ negotiateFlagNTLMSSPNEGOTIATELMKEY = 1 << 7
|
|
||||||
|
|
||||||
/*H*/
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATENTLM = 1 << 9
|
|
||||||
|
|
||||||
/*J*/
|
|
||||||
negotiateFlagANONYMOUS = 1 << 11
|
|
||||||
/*K*/ negotiateFlagNTLMSSPNEGOTIATEOEMDOMAINSUPPLIED = 1 << 12
|
|
||||||
/*L*/ negotiateFlagNTLMSSPNEGOTIATEOEMWORKSTATIONSUPPLIED = 1 << 13
|
|
||||||
|
|
||||||
/*M*/
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATEALWAYSSIGN = 1 << 15
|
|
||||||
/*N*/ negotiateFlagNTLMSSPTARGETTYPEDOMAIN = 1 << 16
|
|
||||||
/*O*/ negotiateFlagNTLMSSPTARGETTYPESERVER = 1 << 17
|
|
||||||
|
|
||||||
/*P*/
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATEEXTENDEDSESSIONSECURITY = 1 << 19
|
|
||||||
/*Q*/ negotiateFlagNTLMSSPNEGOTIATEIDENTIFY = 1 << 20
|
|
||||||
|
|
||||||
/*R*/
|
|
||||||
negotiateFlagNTLMSSPREQUESTNONNTSESSIONKEY = 1 << 22
|
|
||||||
/*S*/ negotiateFlagNTLMSSPNEGOTIATETARGETINFO = 1 << 23
|
|
||||||
|
|
||||||
/*T*/
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATEVERSION = 1 << 25
|
|
||||||
|
|
||||||
/*U*/
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATE128 = 1 << 29
|
|
||||||
/*V*/ negotiateFlagNTLMSSPNEGOTIATEKEYEXCH = 1 << 30
|
|
||||||
/*W*/ negotiateFlagNTLMSSPNEGOTIATE56 = 1 << 31
|
|
||||||
)
|
|
||||||
|
|
||||||
func (field negotiateFlags) Has(flags negotiateFlags) bool {
|
|
||||||
return field&flags == flags
|
|
||||||
}
|
|
||||||
|
|
||||||
func (field *negotiateFlags) Unset(flags negotiateFlags) {
|
|
||||||
*field = *field ^ (*field & flags)
|
|
||||||
}
|
|
64
vendor/github.com/Azure/go-ntlmssp/negotiate_message.go
generated
vendored
64
vendor/github.com/Azure/go-ntlmssp/negotiate_message.go
generated
vendored
@ -1,64 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
const expMsgBodyLen = 40
|
|
||||||
|
|
||||||
type negotiateMessageFields struct {
|
|
||||||
messageHeader
|
|
||||||
NegotiateFlags negotiateFlags
|
|
||||||
|
|
||||||
Domain varField
|
|
||||||
Workstation varField
|
|
||||||
|
|
||||||
Version
|
|
||||||
}
|
|
||||||
|
|
||||||
var defaultFlags = negotiateFlagNTLMSSPNEGOTIATETARGETINFO |
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATE56 |
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATE128 |
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATEUNICODE |
|
|
||||||
negotiateFlagNTLMSSPNEGOTIATEEXTENDEDSESSIONSECURITY
|
|
||||||
|
|
||||||
//NewNegotiateMessage creates a new NEGOTIATE message with the
|
|
||||||
//flags that this package supports.
|
|
||||||
func NewNegotiateMessage(domainName, workstationName string) ([]byte, error) {
|
|
||||||
payloadOffset := expMsgBodyLen
|
|
||||||
flags := defaultFlags
|
|
||||||
|
|
||||||
if domainName != "" {
|
|
||||||
flags |= negotiateFlagNTLMSSPNEGOTIATEOEMDOMAINSUPPLIED
|
|
||||||
}
|
|
||||||
|
|
||||||
if workstationName != "" {
|
|
||||||
flags |= negotiateFlagNTLMSSPNEGOTIATEOEMWORKSTATIONSUPPLIED
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := negotiateMessageFields{
|
|
||||||
messageHeader: newMessageHeader(1),
|
|
||||||
NegotiateFlags: flags,
|
|
||||||
Domain: newVarField(&payloadOffset, len(domainName)),
|
|
||||||
Workstation: newVarField(&payloadOffset, len(workstationName)),
|
|
||||||
Version: DefaultVersion(),
|
|
||||||
}
|
|
||||||
|
|
||||||
b := bytes.Buffer{}
|
|
||||||
if err := binary.Write(&b, binary.LittleEndian, &msg); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if b.Len() != expMsgBodyLen {
|
|
||||||
return nil, errors.New("incorrect body length")
|
|
||||||
}
|
|
||||||
|
|
||||||
payload := strings.ToUpper(domainName + workstationName)
|
|
||||||
if _, err := b.WriteString(payload); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return b.Bytes(), nil
|
|
||||||
}
|
|
144
vendor/github.com/Azure/go-ntlmssp/negotiator.go
generated
vendored
144
vendor/github.com/Azure/go-ntlmssp/negotiator.go
generated
vendored
@ -1,144 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/base64"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetDomain : parse domain name from based on slashes in the input
|
|
||||||
func GetDomain(user string) (string, string) {
|
|
||||||
domain := ""
|
|
||||||
|
|
||||||
if strings.Contains(user, "\\") {
|
|
||||||
ucomponents := strings.SplitN(user, "\\", 2)
|
|
||||||
domain = ucomponents[0]
|
|
||||||
user = ucomponents[1]
|
|
||||||
}
|
|
||||||
return user, domain
|
|
||||||
}
|
|
||||||
|
|
||||||
//Negotiator is a http.Roundtripper decorator that automatically
|
|
||||||
//converts basic authentication to NTLM/Negotiate authentication when appropriate.
|
|
||||||
type Negotiator struct{ http.RoundTripper }
|
|
||||||
|
|
||||||
//RoundTrip sends the request to the server, handling any authentication
|
|
||||||
//re-sends as needed.
|
|
||||||
func (l Negotiator) RoundTrip(req *http.Request) (res *http.Response, err error) {
|
|
||||||
// Use default round tripper if not provided
|
|
||||||
rt := l.RoundTripper
|
|
||||||
if rt == nil {
|
|
||||||
rt = http.DefaultTransport
|
|
||||||
}
|
|
||||||
// If it is not basic auth, just round trip the request as usual
|
|
||||||
reqauth := authheader(req.Header.Get("Authorization"))
|
|
||||||
if !reqauth.IsBasic() {
|
|
||||||
return rt.RoundTrip(req)
|
|
||||||
}
|
|
||||||
// Save request body
|
|
||||||
body := bytes.Buffer{}
|
|
||||||
if req.Body != nil {
|
|
||||||
_, err = body.ReadFrom(req.Body)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Body.Close()
|
|
||||||
req.Body = ioutil.NopCloser(bytes.NewReader(body.Bytes()))
|
|
||||||
}
|
|
||||||
// first try anonymous, in case the server still finds us
|
|
||||||
// authenticated from previous traffic
|
|
||||||
req.Header.Del("Authorization")
|
|
||||||
res, err = rt.RoundTrip(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if res.StatusCode != http.StatusUnauthorized {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
|
|
||||||
resauth := authheader(res.Header.Get("Www-Authenticate"))
|
|
||||||
if !resauth.IsNegotiate() && !resauth.IsNTLM() {
|
|
||||||
// Unauthorized, Negotiate not requested, let's try with basic auth
|
|
||||||
req.Header.Set("Authorization", string(reqauth))
|
|
||||||
io.Copy(ioutil.Discard, res.Body)
|
|
||||||
res.Body.Close()
|
|
||||||
req.Body = ioutil.NopCloser(bytes.NewReader(body.Bytes()))
|
|
||||||
|
|
||||||
res, err = rt.RoundTrip(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if res.StatusCode != http.StatusUnauthorized {
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
resauth = authheader(res.Header.Get("Www-Authenticate"))
|
|
||||||
}
|
|
||||||
|
|
||||||
if resauth.IsNegotiate() || resauth.IsNTLM() {
|
|
||||||
// 401 with request:Basic and response:Negotiate
|
|
||||||
io.Copy(ioutil.Discard, res.Body)
|
|
||||||
res.Body.Close()
|
|
||||||
|
|
||||||
// recycle credentials
|
|
||||||
u, p, err := reqauth.GetBasicCreds()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// get domain from username
|
|
||||||
domain := ""
|
|
||||||
u, domain = GetDomain(u)
|
|
||||||
|
|
||||||
// send negotiate
|
|
||||||
negotiateMessage, err := NewNegotiateMessage(domain, "")
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if resauth.IsNTLM() {
|
|
||||||
req.Header.Set("Authorization", "NTLM "+base64.StdEncoding.EncodeToString(negotiateMessage))
|
|
||||||
} else {
|
|
||||||
req.Header.Set("Authorization", "Negotiate "+base64.StdEncoding.EncodeToString(negotiateMessage))
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Body = ioutil.NopCloser(bytes.NewReader(body.Bytes()))
|
|
||||||
|
|
||||||
res, err = rt.RoundTrip(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// receive challenge?
|
|
||||||
resauth = authheader(res.Header.Get("Www-Authenticate"))
|
|
||||||
challengeMessage, err := resauth.GetData()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !(resauth.IsNegotiate() || resauth.IsNTLM()) || len(challengeMessage) == 0 {
|
|
||||||
// Negotiation failed, let client deal with response
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
io.Copy(ioutil.Discard, res.Body)
|
|
||||||
res.Body.Close()
|
|
||||||
|
|
||||||
// send authenticate
|
|
||||||
authenticateMessage, err := ProcessChallenge(challengeMessage, u, p)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if resauth.IsNTLM() {
|
|
||||||
req.Header.Set("Authorization", "NTLM "+base64.StdEncoding.EncodeToString(authenticateMessage))
|
|
||||||
} else {
|
|
||||||
req.Header.Set("Authorization", "Negotiate "+base64.StdEncoding.EncodeToString(authenticateMessage))
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Body = ioutil.NopCloser(bytes.NewReader(body.Bytes()))
|
|
||||||
|
|
||||||
return rt.RoundTrip(req)
|
|
||||||
}
|
|
||||||
|
|
||||||
return res, err
|
|
||||||
}
|
|
51
vendor/github.com/Azure/go-ntlmssp/nlmp.go
generated
vendored
51
vendor/github.com/Azure/go-ntlmssp/nlmp.go
generated
vendored
@ -1,51 +0,0 @@
|
|||||||
// Package ntlmssp provides NTLM/Negotiate authentication over HTTP
|
|
||||||
//
|
|
||||||
// Protocol details from https://msdn.microsoft.com/en-us/library/cc236621.aspx,
|
|
||||||
// implementation hints from http://davenport.sourceforge.net/ntlm.html .
|
|
||||||
// This package only implements authentication, no key exchange or encryption. It
|
|
||||||
// only supports Unicode (UTF16LE) encoding of protocol strings, no OEM encoding.
|
|
||||||
// This package implements NTLMv2.
|
|
||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/hmac"
|
|
||||||
"crypto/md5"
|
|
||||||
"golang.org/x/crypto/md4"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func getNtlmV2Hash(password, username, target string) []byte {
|
|
||||||
return hmacMd5(getNtlmHash(password), toUnicode(strings.ToUpper(username)+target))
|
|
||||||
}
|
|
||||||
|
|
||||||
func getNtlmHash(password string) []byte {
|
|
||||||
hash := md4.New()
|
|
||||||
hash.Write(toUnicode(password))
|
|
||||||
return hash.Sum(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func computeNtlmV2Response(ntlmV2Hash, serverChallenge, clientChallenge,
|
|
||||||
timestamp, targetInfo []byte) []byte {
|
|
||||||
|
|
||||||
temp := []byte{1, 1, 0, 0, 0, 0, 0, 0}
|
|
||||||
temp = append(temp, timestamp...)
|
|
||||||
temp = append(temp, clientChallenge...)
|
|
||||||
temp = append(temp, 0, 0, 0, 0)
|
|
||||||
temp = append(temp, targetInfo...)
|
|
||||||
temp = append(temp, 0, 0, 0, 0)
|
|
||||||
|
|
||||||
NTProofStr := hmacMd5(ntlmV2Hash, serverChallenge, temp)
|
|
||||||
return append(NTProofStr, temp...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func computeLmV2Response(ntlmV2Hash, serverChallenge, clientChallenge []byte) []byte {
|
|
||||||
return append(hmacMd5(ntlmV2Hash, serverChallenge, clientChallenge), clientChallenge...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func hmacMd5(key []byte, data ...[]byte) []byte {
|
|
||||||
mac := hmac.New(md5.New, key)
|
|
||||||
for _, d := range data {
|
|
||||||
mac.Write(d)
|
|
||||||
}
|
|
||||||
return mac.Sum(nil)
|
|
||||||
}
|
|
29
vendor/github.com/Azure/go-ntlmssp/unicode.go
generated
vendored
29
vendor/github.com/Azure/go-ntlmssp/unicode.go
generated
vendored
@ -1,29 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/binary"
|
|
||||||
"errors"
|
|
||||||
"unicode/utf16"
|
|
||||||
)
|
|
||||||
|
|
||||||
// helper func's for dealing with Windows Unicode (UTF16LE)
|
|
||||||
|
|
||||||
func fromUnicode(d []byte) (string, error) {
|
|
||||||
if len(d)%2 > 0 {
|
|
||||||
return "", errors.New("Unicode (UTF 16 LE) specified, but uneven data length")
|
|
||||||
}
|
|
||||||
s := make([]uint16, len(d)/2)
|
|
||||||
err := binary.Read(bytes.NewReader(d), binary.LittleEndian, &s)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return string(utf16.Decode(s)), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func toUnicode(s string) []byte {
|
|
||||||
uints := utf16.Encode([]rune(s))
|
|
||||||
b := bytes.Buffer{}
|
|
||||||
binary.Write(&b, binary.LittleEndian, &uints)
|
|
||||||
return b.Bytes()
|
|
||||||
}
|
|
40
vendor/github.com/Azure/go-ntlmssp/varfield.go
generated
vendored
40
vendor/github.com/Azure/go-ntlmssp/varfield.go
generated
vendored
@ -1,40 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type varField struct {
|
|
||||||
Len uint16
|
|
||||||
MaxLen uint16
|
|
||||||
BufferOffset uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f varField) ReadFrom(buffer []byte) ([]byte, error) {
|
|
||||||
if len(buffer) < int(f.BufferOffset+uint32(f.Len)) {
|
|
||||||
return nil, errors.New("Error reading data, varField extends beyond buffer")
|
|
||||||
}
|
|
||||||
return buffer[f.BufferOffset : f.BufferOffset+uint32(f.Len)], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f varField) ReadStringFrom(buffer []byte, unicode bool) (string, error) {
|
|
||||||
d, err := f.ReadFrom(buffer)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if unicode { // UTF-16LE encoding scheme
|
|
||||||
return fromUnicode(d)
|
|
||||||
}
|
|
||||||
// OEM encoding, close enough to ASCII, since no code page is specified
|
|
||||||
return string(d), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func newVarField(ptr *int, fieldsize int) varField {
|
|
||||||
f := varField{
|
|
||||||
Len: uint16(fieldsize),
|
|
||||||
MaxLen: uint16(fieldsize),
|
|
||||||
BufferOffset: uint32(*ptr),
|
|
||||||
}
|
|
||||||
*ptr += fieldsize
|
|
||||||
return f
|
|
||||||
}
|
|
20
vendor/github.com/Azure/go-ntlmssp/version.go
generated
vendored
20
vendor/github.com/Azure/go-ntlmssp/version.go
generated
vendored
@ -1,20 +0,0 @@
|
|||||||
package ntlmssp
|
|
||||||
|
|
||||||
// Version is a struct representing https://msdn.microsoft.com/en-us/library/cc236654.aspx
|
|
||||||
type Version struct {
|
|
||||||
ProductMajorVersion uint8
|
|
||||||
ProductMinorVersion uint8
|
|
||||||
ProductBuild uint16
|
|
||||||
_ [3]byte
|
|
||||||
NTLMRevisionCurrent uint8
|
|
||||||
}
|
|
||||||
|
|
||||||
// DefaultVersion returns a Version with "sensible" defaults (Windows 7)
|
|
||||||
func DefaultVersion() Version {
|
|
||||||
return Version{
|
|
||||||
ProductMajorVersion: 6,
|
|
||||||
ProductMinorVersion: 1,
|
|
||||||
ProductBuild: 7601,
|
|
||||||
NTLMRevisionCurrent: 15,
|
|
||||||
}
|
|
||||||
}
|
|
43
vendor/github.com/go-asn1-ber/asn1-ber/.travis.yml
generated
vendored
43
vendor/github.com/go-asn1-ber/asn1-ber/.travis.yml
generated
vendored
@ -1,43 +0,0 @@
|
|||||||
language: go
|
|
||||||
|
|
||||||
go:
|
|
||||||
- 1.2.x
|
|
||||||
- 1.6.x
|
|
||||||
- 1.9.x
|
|
||||||
- 1.10.x
|
|
||||||
- 1.11.x
|
|
||||||
- 1.12.x
|
|
||||||
- 1.14.x
|
|
||||||
- tip
|
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
|
|
||||||
arch:
|
|
||||||
- amd64
|
|
||||||
- ppc64le
|
|
||||||
|
|
||||||
dist: xenial
|
|
||||||
|
|
||||||
env:
|
|
||||||
- GOARCH=amd64
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- os: windows
|
|
||||||
go: 1.14.x
|
|
||||||
- os: osx
|
|
||||||
go: 1.14.x
|
|
||||||
- os: linux
|
|
||||||
go: 1.14.x
|
|
||||||
arch: arm64
|
|
||||||
- os: linux
|
|
||||||
go: 1.14.x
|
|
||||||
env:
|
|
||||||
- GOARCH=386
|
|
||||||
|
|
||||||
script:
|
|
||||||
- go test -v -cover ./... || go test -v ./...
|
|
||||||
matrix:
|
|
||||||
allowfailures:
|
|
||||||
go: 1.2.x
|
|
105
vendor/github.com/go-asn1-ber/asn1-ber/generalizedTime.go
generated
vendored
105
vendor/github.com/go-asn1-ber/asn1-ber/generalizedTime.go
generated
vendored
@ -1,105 +0,0 @@
|
|||||||
package ber
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ErrInvalidTimeFormat is returned when the generalizedTime string was not correct.
|
|
||||||
var ErrInvalidTimeFormat = errors.New("invalid time format")
|
|
||||||
|
|
||||||
var zeroTime = time.Time{}
|
|
||||||
|
|
||||||
// ParseGeneralizedTime parses a string value and if it conforms to
|
|
||||||
// GeneralizedTime[^0] format, will return a time.Time for that value.
|
|
||||||
//
|
|
||||||
// [^0]: https://www.itu.int/rec/T-REC-X.690-201508-I/en Section 11.7
|
|
||||||
func ParseGeneralizedTime(v []byte) (time.Time, error) {
|
|
||||||
var format string
|
|
||||||
var fract time.Duration
|
|
||||||
|
|
||||||
str := []byte(DecodeString(v))
|
|
||||||
tzIndex := bytes.IndexAny(str, "Z+-")
|
|
||||||
if tzIndex < 0 {
|
|
||||||
return zeroTime, ErrInvalidTimeFormat
|
|
||||||
}
|
|
||||||
|
|
||||||
dot := bytes.IndexAny(str, ".,")
|
|
||||||
switch dot {
|
|
||||||
case -1:
|
|
||||||
switch tzIndex {
|
|
||||||
case 10:
|
|
||||||
format = `2006010215Z`
|
|
||||||
case 12:
|
|
||||||
format = `200601021504Z`
|
|
||||||
case 14:
|
|
||||||
format = `20060102150405Z`
|
|
||||||
default:
|
|
||||||
return zeroTime, ErrInvalidTimeFormat
|
|
||||||
}
|
|
||||||
|
|
||||||
case 10, 12:
|
|
||||||
if tzIndex < dot {
|
|
||||||
return zeroTime, ErrInvalidTimeFormat
|
|
||||||
}
|
|
||||||
// a "," is also allowed, but would not be parsed by time.Parse():
|
|
||||||
str[dot] = '.'
|
|
||||||
|
|
||||||
// If <minute> is omitted, then <fraction> represents a fraction of an
|
|
||||||
// hour; otherwise, if <second> and <leap-second> are omitted, then
|
|
||||||
// <fraction> represents a fraction of a minute; otherwise, <fraction>
|
|
||||||
// represents a fraction of a second.
|
|
||||||
|
|
||||||
// parse as float from dot to timezone
|
|
||||||
f, err := strconv.ParseFloat(string(str[dot:tzIndex]), 64)
|
|
||||||
if err != nil {
|
|
||||||
return zeroTime, fmt.Errorf("failed to parse float: %s", err)
|
|
||||||
}
|
|
||||||
// ...and strip that part
|
|
||||||
str = append(str[:dot], str[tzIndex:]...)
|
|
||||||
tzIndex = dot
|
|
||||||
|
|
||||||
if dot == 10 {
|
|
||||||
fract = time.Duration(int64(f * float64(time.Hour)))
|
|
||||||
format = `2006010215Z`
|
|
||||||
} else {
|
|
||||||
fract = time.Duration(int64(f * float64(time.Minute)))
|
|
||||||
format = `200601021504Z`
|
|
||||||
}
|
|
||||||
|
|
||||||
case 14:
|
|
||||||
if tzIndex < dot {
|
|
||||||
return zeroTime, ErrInvalidTimeFormat
|
|
||||||
}
|
|
||||||
str[dot] = '.'
|
|
||||||
// no need for fractional seconds, time.Parse() handles that
|
|
||||||
format = `20060102150405Z`
|
|
||||||
|
|
||||||
default:
|
|
||||||
return zeroTime, ErrInvalidTimeFormat
|
|
||||||
}
|
|
||||||
|
|
||||||
l := len(str)
|
|
||||||
switch l - tzIndex {
|
|
||||||
case 1:
|
|
||||||
if str[l-1] != 'Z' {
|
|
||||||
return zeroTime, ErrInvalidTimeFormat
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
format += `0700`
|
|
||||||
str = append(str, []byte("00")...)
|
|
||||||
case 5:
|
|
||||||
format += `0700`
|
|
||||||
default:
|
|
||||||
return zeroTime, ErrInvalidTimeFormat
|
|
||||||
}
|
|
||||||
|
|
||||||
t, err := time.Parse(format, string(str))
|
|
||||||
if err != nil {
|
|
||||||
return zeroTime, fmt.Errorf("%s: %s", ErrInvalidTimeFormat, err)
|
|
||||||
}
|
|
||||||
return t.Add(fract), nil
|
|
||||||
}
|
|
3
vendor/github.com/go-asn1-ber/asn1-ber/go.mod
generated
vendored
3
vendor/github.com/go-asn1-ber/asn1-ber/go.mod
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
module github.com/go-asn1-ber/asn1-ber
|
|
||||||
|
|
||||||
go 1.13
|
|
157
vendor/github.com/go-asn1-ber/asn1-ber/real.go
generated
vendored
157
vendor/github.com/go-asn1-ber/asn1-ber/real.go
generated
vendored
@ -1,157 +0,0 @@
|
|||||||
package ber
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"math"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func encodeFloat(v float64) []byte {
|
|
||||||
switch {
|
|
||||||
case math.IsInf(v, 1):
|
|
||||||
return []byte{0x40}
|
|
||||||
case math.IsInf(v, -1):
|
|
||||||
return []byte{0x41}
|
|
||||||
case math.IsNaN(v):
|
|
||||||
return []byte{0x42}
|
|
||||||
case v == 0.0:
|
|
||||||
if math.Signbit(v) {
|
|
||||||
return []byte{0x43}
|
|
||||||
}
|
|
||||||
return []byte{}
|
|
||||||
default:
|
|
||||||
// we take the easy part ;-)
|
|
||||||
value := []byte(strconv.FormatFloat(v, 'G', -1, 64))
|
|
||||||
var ret []byte
|
|
||||||
if bytes.Contains(value, []byte{'E'}) {
|
|
||||||
ret = []byte{0x03}
|
|
||||||
} else {
|
|
||||||
ret = []byte{0x02}
|
|
||||||
}
|
|
||||||
ret = append(ret, value...)
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseReal(v []byte) (val float64, err error) {
|
|
||||||
if len(v) == 0 {
|
|
||||||
return 0.0, nil
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case v[0]&0x80 == 0x80:
|
|
||||||
val, err = parseBinaryFloat(v)
|
|
||||||
case v[0]&0xC0 == 0x40:
|
|
||||||
val, err = parseSpecialFloat(v)
|
|
||||||
case v[0]&0xC0 == 0x0:
|
|
||||||
val, err = parseDecimalFloat(v)
|
|
||||||
default:
|
|
||||||
return 0.0, fmt.Errorf("invalid info block")
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return 0.0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if val == 0.0 && !math.Signbit(val) {
|
|
||||||
return 0.0, errors.New("REAL value +0 must be encoded with zero-length value block")
|
|
||||||
}
|
|
||||||
return val, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseBinaryFloat(v []byte) (float64, error) {
|
|
||||||
var info byte
|
|
||||||
var buf []byte
|
|
||||||
|
|
||||||
info, v = v[0], v[1:]
|
|
||||||
|
|
||||||
var base int
|
|
||||||
switch info & 0x30 {
|
|
||||||
case 0x00:
|
|
||||||
base = 2
|
|
||||||
case 0x10:
|
|
||||||
base = 8
|
|
||||||
case 0x20:
|
|
||||||
base = 16
|
|
||||||
case 0x30:
|
|
||||||
return 0.0, errors.New("bits 6 and 5 of information octet for REAL are equal to 11")
|
|
||||||
}
|
|
||||||
|
|
||||||
scale := uint((info & 0x0c) >> 2)
|
|
||||||
|
|
||||||
var expLen int
|
|
||||||
switch info & 0x03 {
|
|
||||||
case 0x00:
|
|
||||||
expLen = 1
|
|
||||||
case 0x01:
|
|
||||||
expLen = 2
|
|
||||||
case 0x02:
|
|
||||||
expLen = 3
|
|
||||||
case 0x03:
|
|
||||||
expLen = int(v[0])
|
|
||||||
if expLen > 8 {
|
|
||||||
return 0.0, errors.New("too big value of exponent")
|
|
||||||
}
|
|
||||||
v = v[1:]
|
|
||||||
}
|
|
||||||
buf, v = v[:expLen], v[expLen:]
|
|
||||||
exponent, err := ParseInt64(buf)
|
|
||||||
if err != nil {
|
|
||||||
return 0.0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(v) > 8 {
|
|
||||||
return 0.0, errors.New("too big value of mantissa")
|
|
||||||
}
|
|
||||||
|
|
||||||
mant, err := ParseInt64(v)
|
|
||||||
if err != nil {
|
|
||||||
return 0.0, err
|
|
||||||
}
|
|
||||||
mantissa := mant << scale
|
|
||||||
|
|
||||||
if info&0x40 == 0x40 {
|
|
||||||
mantissa = -mantissa
|
|
||||||
}
|
|
||||||
|
|
||||||
return float64(mantissa) * math.Pow(float64(base), float64(exponent)), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseDecimalFloat(v []byte) (val float64, err error) {
|
|
||||||
switch v[0] & 0x3F {
|
|
||||||
case 0x01: // NR form 1
|
|
||||||
var iVal int64
|
|
||||||
iVal, err = strconv.ParseInt(strings.TrimLeft(string(v[1:]), " "), 10, 64)
|
|
||||||
val = float64(iVal)
|
|
||||||
case 0x02, 0x03: // NR form 2, 3
|
|
||||||
val, err = strconv.ParseFloat(strings.Replace(strings.TrimLeft(string(v[1:]), " "), ",", ".", -1), 64)
|
|
||||||
default:
|
|
||||||
err = errors.New("incorrect NR form")
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return 0.0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if val == 0.0 && math.Signbit(val) {
|
|
||||||
return 0.0, errors.New("REAL value -0 must be encoded as a special value")
|
|
||||||
}
|
|
||||||
return val, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseSpecialFloat(v []byte) (float64, error) {
|
|
||||||
if len(v) != 1 {
|
|
||||||
return 0.0, errors.New(`encoding of "special value" must not contain exponent and mantissa`)
|
|
||||||
}
|
|
||||||
switch v[0] {
|
|
||||||
case 0x40:
|
|
||||||
return math.Inf(1), nil
|
|
||||||
case 0x41:
|
|
||||||
return math.Inf(-1), nil
|
|
||||||
case 0x42:
|
|
||||||
return math.NaN(), nil
|
|
||||||
case 0x43:
|
|
||||||
return math.Copysign(0, -1), nil
|
|
||||||
}
|
|
||||||
return 0.0, errors.New(`encoding of "special value" not from ASN.1 standard`)
|
|
||||||
}
|
|
540
vendor/github.com/go-ldap/ldap/v3/bind.go
generated
vendored
540
vendor/github.com/go-ldap/ldap/v3/bind.go
generated
vendored
@ -1,540 +0,0 @@
|
|||||||
package ldap
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"crypto/md5"
|
|
||||||
enchex "encoding/hex"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/Azure/go-ntlmssp"
|
|
||||||
ber "github.com/go-asn1-ber/asn1-ber"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SimpleBindRequest represents a username/password bind operation
|
|
||||||
type SimpleBindRequest struct {
|
|
||||||
// Username is the name of the Directory object that the client wishes to bind as
|
|
||||||
Username string
|
|
||||||
// Password is the credentials to bind with
|
|
||||||
Password string
|
|
||||||
// Controls are optional controls to send with the bind request
|
|
||||||
Controls []Control
|
|
||||||
// AllowEmptyPassword sets whether the client allows binding with an empty password
|
|
||||||
// (normally used for unauthenticated bind).
|
|
||||||
AllowEmptyPassword bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// SimpleBindResult contains the response from the server
|
|
||||||
type SimpleBindResult struct {
|
|
||||||
Controls []Control
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewSimpleBindRequest returns a bind request
|
|
||||||
func NewSimpleBindRequest(username string, password string, controls []Control) *SimpleBindRequest {
|
|
||||||
return &SimpleBindRequest{
|
|
||||||
Username: username,
|
|
||||||
Password: password,
|
|
||||||
Controls: controls,
|
|
||||||
AllowEmptyPassword: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req *SimpleBindRequest) appendTo(envelope *ber.Packet) error {
|
|
||||||
pkt := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
|
|
||||||
pkt.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
|
|
||||||
pkt.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, req.Username, "User Name"))
|
|
||||||
pkt.AppendChild(ber.NewString(ber.ClassContext, ber.TypePrimitive, 0, req.Password, "Password"))
|
|
||||||
|
|
||||||
envelope.AppendChild(pkt)
|
|
||||||
if len(req.Controls) > 0 {
|
|
||||||
envelope.AppendChild(encodeControls(req.Controls))
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SimpleBind performs the simple bind operation defined in the given request
|
|
||||||
func (l *Conn) SimpleBind(simpleBindRequest *SimpleBindRequest) (*SimpleBindResult, error) {
|
|
||||||
if simpleBindRequest.Password == "" && !simpleBindRequest.AllowEmptyPassword {
|
|
||||||
return nil, NewError(ErrorEmptyPassword, errors.New("ldap: empty password not allowed by the client"))
|
|
||||||
}
|
|
||||||
|
|
||||||
msgCtx, err := l.doRequest(simpleBindRequest)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer l.finishMessage(msgCtx)
|
|
||||||
|
|
||||||
packet, err := l.readPacket(msgCtx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result := &SimpleBindResult{
|
|
||||||
Controls: make([]Control, 0),
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(packet.Children) == 3 {
|
|
||||||
for _, child := range packet.Children[2].Children {
|
|
||||||
decodedChild, decodeErr := DecodeControl(child)
|
|
||||||
if decodeErr != nil {
|
|
||||||
return nil, fmt.Errorf("failed to decode child control: %s", decodeErr)
|
|
||||||
}
|
|
||||||
result.Controls = append(result.Controls, decodedChild)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = GetLDAPError(packet)
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bind performs a bind with the given username and password.
|
|
||||||
//
|
|
||||||
// It does not allow unauthenticated bind (i.e. empty password). Use the UnauthenticatedBind method
|
|
||||||
// for that.
|
|
||||||
func (l *Conn) Bind(username, password string) error {
|
|
||||||
req := &SimpleBindRequest{
|
|
||||||
Username: username,
|
|
||||||
Password: password,
|
|
||||||
AllowEmptyPassword: false,
|
|
||||||
}
|
|
||||||
_, err := l.SimpleBind(req)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnauthenticatedBind performs an unauthenticated bind.
|
|
||||||
//
|
|
||||||
// A username may be provided for trace (e.g. logging) purpose only, but it is normally not
|
|
||||||
// authenticated or otherwise validated by the LDAP server.
|
|
||||||
//
|
|
||||||
// See https://tools.ietf.org/html/rfc4513#section-5.1.2 .
|
|
||||||
// See https://tools.ietf.org/html/rfc4513#section-6.3.1 .
|
|
||||||
func (l *Conn) UnauthenticatedBind(username string) error {
|
|
||||||
req := &SimpleBindRequest{
|
|
||||||
Username: username,
|
|
||||||
Password: "",
|
|
||||||
AllowEmptyPassword: true,
|
|
||||||
}
|
|
||||||
_, err := l.SimpleBind(req)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DigestMD5BindRequest represents a digest-md5 bind operation
|
|
||||||
type DigestMD5BindRequest struct {
|
|
||||||
Host string
|
|
||||||
// Username is the name of the Directory object that the client wishes to bind as
|
|
||||||
Username string
|
|
||||||
// Password is the credentials to bind with
|
|
||||||
Password string
|
|
||||||
// Controls are optional controls to send with the bind request
|
|
||||||
Controls []Control
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req *DigestMD5BindRequest) appendTo(envelope *ber.Packet) error {
|
|
||||||
request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
|
|
||||||
request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
|
|
||||||
request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "", "User Name"))
|
|
||||||
|
|
||||||
auth := ber.Encode(ber.ClassContext, ber.TypeConstructed, 3, "", "authentication")
|
|
||||||
auth.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "DIGEST-MD5", "SASL Mech"))
|
|
||||||
request.AppendChild(auth)
|
|
||||||
envelope.AppendChild(request)
|
|
||||||
if len(req.Controls) > 0 {
|
|
||||||
envelope.AppendChild(encodeControls(req.Controls))
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DigestMD5BindResult contains the response from the server
|
|
||||||
type DigestMD5BindResult struct {
|
|
||||||
Controls []Control
|
|
||||||
}
|
|
||||||
|
|
||||||
// MD5Bind performs a digest-md5 bind with the given host, username and password.
|
|
||||||
func (l *Conn) MD5Bind(host, username, password string) error {
|
|
||||||
req := &DigestMD5BindRequest{
|
|
||||||
Host: host,
|
|
||||||
Username: username,
|
|
||||||
Password: password,
|
|
||||||
}
|
|
||||||
_, err := l.DigestMD5Bind(req)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// DigestMD5Bind performs the digest-md5 bind operation defined in the given request
|
|
||||||
func (l *Conn) DigestMD5Bind(digestMD5BindRequest *DigestMD5BindRequest) (*DigestMD5BindResult, error) {
|
|
||||||
if digestMD5BindRequest.Password == "" {
|
|
||||||
return nil, NewError(ErrorEmptyPassword, errors.New("ldap: empty password not allowed by the client"))
|
|
||||||
}
|
|
||||||
|
|
||||||
msgCtx, err := l.doRequest(digestMD5BindRequest)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer l.finishMessage(msgCtx)
|
|
||||||
|
|
||||||
packet, err := l.readPacket(msgCtx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
l.Debug.Printf("%d: got response %p", msgCtx.id, packet)
|
|
||||||
if l.Debug {
|
|
||||||
if err = addLDAPDescriptions(packet); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ber.PrintPacket(packet)
|
|
||||||
}
|
|
||||||
|
|
||||||
result := &DigestMD5BindResult{
|
|
||||||
Controls: make([]Control, 0),
|
|
||||||
}
|
|
||||||
var params map[string]string
|
|
||||||
if len(packet.Children) == 2 {
|
|
||||||
if len(packet.Children[1].Children) == 4 {
|
|
||||||
child := packet.Children[1].Children[0]
|
|
||||||
if child.Tag != ber.TagEnumerated {
|
|
||||||
return result, GetLDAPError(packet)
|
|
||||||
}
|
|
||||||
if child.Value.(int64) != 14 {
|
|
||||||
return result, GetLDAPError(packet)
|
|
||||||
}
|
|
||||||
child = packet.Children[1].Children[3]
|
|
||||||
if child.Tag != ber.TagObjectDescriptor {
|
|
||||||
return result, GetLDAPError(packet)
|
|
||||||
}
|
|
||||||
if child.Data == nil {
|
|
||||||
return result, GetLDAPError(packet)
|
|
||||||
}
|
|
||||||
data, _ := ioutil.ReadAll(child.Data)
|
|
||||||
params, err = parseParams(string(data))
|
|
||||||
if err != nil {
|
|
||||||
return result, fmt.Errorf("parsing digest-challenge: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if params != nil {
|
|
||||||
resp := computeResponse(
|
|
||||||
params,
|
|
||||||
"ldap/"+strings.ToLower(digestMD5BindRequest.Host),
|
|
||||||
digestMD5BindRequest.Username,
|
|
||||||
digestMD5BindRequest.Password,
|
|
||||||
)
|
|
||||||
packet = ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
|
|
||||||
packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, l.nextMessageID(), "MessageID"))
|
|
||||||
|
|
||||||
request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
|
|
||||||
request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
|
|
||||||
request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "", "User Name"))
|
|
||||||
|
|
||||||
auth := ber.Encode(ber.ClassContext, ber.TypeConstructed, 3, "", "authentication")
|
|
||||||
auth.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "DIGEST-MD5", "SASL Mech"))
|
|
||||||
auth.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, resp, "Credentials"))
|
|
||||||
request.AppendChild(auth)
|
|
||||||
packet.AppendChild(request)
|
|
||||||
msgCtx, err = l.sendMessage(packet)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("send message: %s", err)
|
|
||||||
}
|
|
||||||
defer l.finishMessage(msgCtx)
|
|
||||||
packetResponse, ok := <-msgCtx.responses
|
|
||||||
if !ok {
|
|
||||||
return nil, NewError(ErrorNetwork, errors.New("ldap: response channel closed"))
|
|
||||||
}
|
|
||||||
packet, err = packetResponse.ReadPacket()
|
|
||||||
l.Debug.Printf("%d: got response %p", msgCtx.id, packet)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("read packet: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
err = GetLDAPError(packet)
|
|
||||||
return result, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseParams(str string) (map[string]string, error) {
|
|
||||||
m := make(map[string]string)
|
|
||||||
var key, value string
|
|
||||||
var state int
|
|
||||||
for i := 0; i <= len(str); i++ {
|
|
||||||
switch state {
|
|
||||||
case 0: //reading key
|
|
||||||
if i == len(str) {
|
|
||||||
return nil, fmt.Errorf("syntax error on %d", i)
|
|
||||||
}
|
|
||||||
if str[i] != '=' {
|
|
||||||
key += string(str[i])
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
state = 1
|
|
||||||
case 1: //reading value
|
|
||||||
if i == len(str) {
|
|
||||||
m[key] = value
|
|
||||||
break
|
|
||||||
}
|
|
||||||
switch str[i] {
|
|
||||||
case ',':
|
|
||||||
m[key] = value
|
|
||||||
state = 0
|
|
||||||
key = ""
|
|
||||||
value = ""
|
|
||||||
case '"':
|
|
||||||
if value != "" {
|
|
||||||
return nil, fmt.Errorf("syntax error on %d", i)
|
|
||||||
}
|
|
||||||
state = 2
|
|
||||||
default:
|
|
||||||
value += string(str[i])
|
|
||||||
}
|
|
||||||
case 2: //inside quotes
|
|
||||||
if i == len(str) {
|
|
||||||
return nil, fmt.Errorf("syntax error on %d", i)
|
|
||||||
}
|
|
||||||
if str[i] != '"' {
|
|
||||||
value += string(str[i])
|
|
||||||
} else {
|
|
||||||
state = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func computeResponse(params map[string]string, uri, username, password string) string {
|
|
||||||
nc := "00000001"
|
|
||||||
qop := "auth"
|
|
||||||
cnonce := enchex.EncodeToString(randomBytes(16))
|
|
||||||
x := username + ":" + params["realm"] + ":" + password
|
|
||||||
y := md5Hash([]byte(x))
|
|
||||||
|
|
||||||
a1 := bytes.NewBuffer(y)
|
|
||||||
a1.WriteString(":" + params["nonce"] + ":" + cnonce)
|
|
||||||
if len(params["authzid"]) > 0 {
|
|
||||||
a1.WriteString(":" + params["authzid"])
|
|
||||||
}
|
|
||||||
a2 := bytes.NewBuffer([]byte("AUTHENTICATE"))
|
|
||||||
a2.WriteString(":" + uri)
|
|
||||||
ha1 := enchex.EncodeToString(md5Hash(a1.Bytes()))
|
|
||||||
ha2 := enchex.EncodeToString(md5Hash(a2.Bytes()))
|
|
||||||
|
|
||||||
kd := ha1
|
|
||||||
kd += ":" + params["nonce"]
|
|
||||||
kd += ":" + nc
|
|
||||||
kd += ":" + cnonce
|
|
||||||
kd += ":" + qop
|
|
||||||
kd += ":" + ha2
|
|
||||||
resp := enchex.EncodeToString(md5Hash([]byte(kd)))
|
|
||||||
return fmt.Sprintf(
|
|
||||||
`username="%s",realm="%s",nonce="%s",cnonce="%s",nc=00000001,qop=%s,digest-uri="%s",response=%s`,
|
|
||||||
username,
|
|
||||||
params["realm"],
|
|
||||||
params["nonce"],
|
|
||||||
cnonce,
|
|
||||||
qop,
|
|
||||||
uri,
|
|
||||||
resp,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func md5Hash(b []byte) []byte {
|
|
||||||
hasher := md5.New()
|
|
||||||
hasher.Write(b)
|
|
||||||
return hasher.Sum(nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func randomBytes(len int) []byte {
|
|
||||||
b := make([]byte, len)
|
|
||||||
for i := 0; i < len; i++ {
|
|
||||||
b[i] = byte(rand.Intn(256))
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
var externalBindRequest = requestFunc(func(envelope *ber.Packet) error {
|
|
||||||
pkt := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
|
|
||||||
pkt.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
|
|
||||||
pkt.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "", "User Name"))
|
|
||||||
|
|
||||||
saslAuth := ber.Encode(ber.ClassContext, ber.TypeConstructed, 3, "", "authentication")
|
|
||||||
saslAuth.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "EXTERNAL", "SASL Mech"))
|
|
||||||
saslAuth.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "", "SASL Cred"))
|
|
||||||
|
|
||||||
pkt.AppendChild(saslAuth)
|
|
||||||
|
|
||||||
envelope.AppendChild(pkt)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
// ExternalBind performs SASL/EXTERNAL authentication.
|
|
||||||
//
|
|
||||||
// Use ldap.DialURL("ldapi://") to connect to the Unix socket before ExternalBind.
|
|
||||||
//
|
|
||||||
// See https://tools.ietf.org/html/rfc4422#appendix-A
|
|
||||||
func (l *Conn) ExternalBind() error {
|
|
||||||
msgCtx, err := l.doRequest(externalBindRequest)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer l.finishMessage(msgCtx)
|
|
||||||
|
|
||||||
packet, err := l.readPacket(msgCtx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetLDAPError(packet)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NTLMBind performs an NTLMSSP bind leveraging https://github.com/Azure/go-ntlmssp
|
|
||||||
|
|
||||||
// NTLMBindRequest represents an NTLMSSP bind operation
|
|
||||||
type NTLMBindRequest struct {
|
|
||||||
// Domain is the AD Domain to authenticate too. If not specified, it will be grabbed from the NTLMSSP Challenge
|
|
||||||
Domain string
|
|
||||||
// Username is the name of the Directory object that the client wishes to bind as
|
|
||||||
Username string
|
|
||||||
// Password is the credentials to bind with
|
|
||||||
Password string
|
|
||||||
// Hash is the hex NTLM hash to bind with. Password or hash must be provided
|
|
||||||
Hash string
|
|
||||||
// Controls are optional controls to send with the bind request
|
|
||||||
Controls []Control
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req *NTLMBindRequest) appendTo(envelope *ber.Packet) error {
|
|
||||||
request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
|
|
||||||
request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
|
|
||||||
request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "", "User Name"))
|
|
||||||
|
|
||||||
// generate an NTLMSSP Negotiation message for the specified domain (it can be blank)
|
|
||||||
negMessage, err := ntlmssp.NewNegotiateMessage(req.Domain, "")
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("err creating negmessage: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// append the generated NTLMSSP message as a TagEnumerated BER value
|
|
||||||
auth := ber.Encode(ber.ClassContext, ber.TypePrimitive, ber.TagEnumerated, negMessage, "authentication")
|
|
||||||
request.AppendChild(auth)
|
|
||||||
envelope.AppendChild(request)
|
|
||||||
if len(req.Controls) > 0 {
|
|
||||||
envelope.AppendChild(encodeControls(req.Controls))
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NTLMBindResult contains the response from the server
|
|
||||||
type NTLMBindResult struct {
|
|
||||||
Controls []Control
|
|
||||||
}
|
|
||||||
|
|
||||||
// NTLMBind performs an NTLMSSP Bind with the given domain, username and password
|
|
||||||
func (l *Conn) NTLMBind(domain, username, password string) error {
|
|
||||||
req := &NTLMBindRequest{
|
|
||||||
Domain: domain,
|
|
||||||
Username: username,
|
|
||||||
Password: password,
|
|
||||||
}
|
|
||||||
_, err := l.NTLMChallengeBind(req)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// NTLMBindWithHash performs an NTLM Bind with an NTLM hash instead of plaintext password (pass-the-hash)
|
|
||||||
func (l *Conn) NTLMBindWithHash(domain, username, hash string) error {
|
|
||||||
req := &NTLMBindRequest{
|
|
||||||
Domain: domain,
|
|
||||||
Username: username,
|
|
||||||
Hash: hash,
|
|
||||||
}
|
|
||||||
_, err := l.NTLMChallengeBind(req)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// NTLMChallengeBind performs the NTLMSSP bind operation defined in the given request
|
|
||||||
func (l *Conn) NTLMChallengeBind(ntlmBindRequest *NTLMBindRequest) (*NTLMBindResult, error) {
|
|
||||||
if ntlmBindRequest.Password == "" && ntlmBindRequest.Hash == "" {
|
|
||||||
return nil, NewError(ErrorEmptyPassword, errors.New("ldap: empty password not allowed by the client"))
|
|
||||||
}
|
|
||||||
|
|
||||||
msgCtx, err := l.doRequest(ntlmBindRequest)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer l.finishMessage(msgCtx)
|
|
||||||
packet, err := l.readPacket(msgCtx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
l.Debug.Printf("%d: got response %p", msgCtx.id, packet)
|
|
||||||
if l.Debug {
|
|
||||||
if err = addLDAPDescriptions(packet); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
ber.PrintPacket(packet)
|
|
||||||
}
|
|
||||||
result := &NTLMBindResult{
|
|
||||||
Controls: make([]Control, 0),
|
|
||||||
}
|
|
||||||
var ntlmsspChallenge []byte
|
|
||||||
|
|
||||||
// now find the NTLM Response Message
|
|
||||||
if len(packet.Children) == 2 {
|
|
||||||
if len(packet.Children[1].Children) == 3 {
|
|
||||||
child := packet.Children[1].Children[1]
|
|
||||||
ntlmsspChallenge = child.ByteValue
|
|
||||||
// Check to make sure we got the right message. It will always start with NTLMSSP
|
|
||||||
if !bytes.Equal(ntlmsspChallenge[:7], []byte("NTLMSSP")) {
|
|
||||||
return result, GetLDAPError(packet)
|
|
||||||
}
|
|
||||||
l.Debug.Printf("%d: found ntlmssp challenge", msgCtx.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ntlmsspChallenge != nil {
|
|
||||||
var err error
|
|
||||||
var responseMessage []byte
|
|
||||||
// generate a response message to the challenge with the given Username/Password if password is provided
|
|
||||||
if ntlmBindRequest.Password != "" {
|
|
||||||
responseMessage, err = ntlmssp.ProcessChallenge(ntlmsspChallenge, ntlmBindRequest.Username, ntlmBindRequest.Password)
|
|
||||||
} else if ntlmBindRequest.Hash != "" {
|
|
||||||
responseMessage, err = ntlmssp.ProcessChallengeWithHash(ntlmsspChallenge, ntlmBindRequest.Username, ntlmBindRequest.Hash)
|
|
||||||
} else {
|
|
||||||
err = fmt.Errorf("need a password or hash to generate reply")
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return result, fmt.Errorf("parsing ntlm-challenge: %s", err)
|
|
||||||
}
|
|
||||||
packet = ber.Encode(ber.ClassUniversal, ber.TypeConstructed, ber.TagSequence, nil, "LDAP Request")
|
|
||||||
packet.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, l.nextMessageID(), "MessageID"))
|
|
||||||
|
|
||||||
request := ber.Encode(ber.ClassApplication, ber.TypeConstructed, ApplicationBindRequest, nil, "Bind Request")
|
|
||||||
request.AppendChild(ber.NewInteger(ber.ClassUniversal, ber.TypePrimitive, ber.TagInteger, 3, "Version"))
|
|
||||||
request.AppendChild(ber.NewString(ber.ClassUniversal, ber.TypePrimitive, ber.TagOctetString, "", "User Name"))
|
|
||||||
|
|
||||||
// append the challenge response message as a TagEmbeddedPDV BER value
|
|
||||||
auth := ber.Encode(ber.ClassContext, ber.TypePrimitive, ber.TagEmbeddedPDV, responseMessage, "authentication")
|
|
||||||
|
|
||||||
request.AppendChild(auth)
|
|
||||||
packet.AppendChild(request)
|
|
||||||
msgCtx, err = l.sendMessage(packet)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("send message: %s", err)
|
|
||||||
}
|
|
||||||
defer l.finishMessage(msgCtx)
|
|
||||||
packetResponse, ok := <-msgCtx.responses
|
|
||||||
if !ok {
|
|
||||||
return nil, NewError(ErrorNetwork, errors.New("ldap: response channel closed"))
|
|
||||||
}
|
|
||||||
packet, err = packetResponse.ReadPacket()
|
|
||||||
l.Debug.Printf("%d: got response %p", msgCtx.id, packet)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("read packet: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
err = GetLDAPError(packet)
|
|
||||||
return result, err
|
|
||||||
}
|
|
9
vendor/github.com/go-ldap/ldap/v3/go.mod
generated
vendored
9
vendor/github.com/go-ldap/ldap/v3/go.mod
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
module github.com/go-ldap/ldap/v3
|
|
||||||
|
|
||||||
go 1.13
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c
|
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.1
|
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 // indirect
|
|
||||||
)
|
|
11
vendor/github.com/go-ldap/ldap/v3/go.sum
generated
vendored
11
vendor/github.com/go-ldap/ldap/v3/go.sum
generated
vendored
@ -1,11 +0,0 @@
|
|||||||
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c h1:/IBSNwUN8+eKzUzbJPqhK839ygXJ82sde8x3ogr6R28=
|
|
||||||
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
|
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.1 h1:pDbRAunXzIUXfx4CB2QJFv5IuPiuoW+sWvr/Us009o8=
|
|
||||||
github.com/go-asn1-ber/asn1-ber v1.5.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
|
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
|
|
||||||
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
|
||||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
|
3
vendor/golang.org/x/crypto/AUTHORS
generated
vendored
3
vendor/golang.org/x/crypto/AUTHORS
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# This source code refers to The Go Authors for copyright purposes.
|
|
||||||
# The master list of authors is in the main Go distribution,
|
|
||||||
# visible at https://tip.golang.org/AUTHORS.
|
|
3
vendor/golang.org/x/crypto/CONTRIBUTORS
generated
vendored
3
vendor/golang.org/x/crypto/CONTRIBUTORS
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# This source code was written by the Go contributors.
|
|
||||||
# The master list of contributors is in the main Go distribution,
|
|
||||||
# visible at https://tip.golang.org/CONTRIBUTORS.
|
|
27
vendor/golang.org/x/crypto/LICENSE
generated
vendored
27
vendor/golang.org/x/crypto/LICENSE
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22
vendor/golang.org/x/crypto/PATENTS
generated
vendored
22
vendor/golang.org/x/crypto/PATENTS
generated
vendored
@ -1,22 +0,0 @@
|
|||||||
Additional IP Rights Grant (Patents)
|
|
||||||
|
|
||||||
"This implementation" means the copyrightable works distributed by
|
|
||||||
Google as part of the Go project.
|
|
||||||
|
|
||||||
Google hereby grants to You a perpetual, worldwide, non-exclusive,
|
|
||||||
no-charge, royalty-free, irrevocable (except as stated in this section)
|
|
||||||
patent license to make, have made, use, offer to sell, sell, import,
|
|
||||||
transfer and otherwise run, modify and propagate the contents of this
|
|
||||||
implementation of Go, where such license applies only to those patent
|
|
||||||
claims, both currently owned or controlled by Google and acquired in
|
|
||||||
the future, licensable by Google that are necessarily infringed by this
|
|
||||||
implementation of Go. This grant does not include claims that would be
|
|
||||||
infringed only as a consequence of further modification of this
|
|
||||||
implementation. If you or your agent or exclusive licensee institute or
|
|
||||||
order or agree to the institution of patent litigation against any
|
|
||||||
entity (including a cross-claim or counterclaim in a lawsuit) alleging
|
|
||||||
that this implementation of Go or any code incorporated within this
|
|
||||||
implementation of Go constitutes direct or contributory patent
|
|
||||||
infringement, or inducement of patent infringement, then any patent
|
|
||||||
rights granted to you under this License for this implementation of Go
|
|
||||||
shall terminate as of the date such litigation is filed.
|
|
122
vendor/golang.org/x/crypto/md4/md4.go
generated
vendored
122
vendor/golang.org/x/crypto/md4/md4.go
generated
vendored
@ -1,122 +0,0 @@
|
|||||||
// Copyright 2009 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 md4 implements the MD4 hash algorithm as defined in RFC 1320.
|
|
||||||
//
|
|
||||||
// Deprecated: MD4 is cryptographically broken and should should only be used
|
|
||||||
// where compatibility with legacy systems, not security, is the goal. Instead,
|
|
||||||
// use a secure hash like SHA-256 (from crypto/sha256).
|
|
||||||
package md4 // import "golang.org/x/crypto/md4"
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto"
|
|
||||||
"hash"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
crypto.RegisterHash(crypto.MD4, New)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The size of an MD4 checksum in bytes.
|
|
||||||
const Size = 16
|
|
||||||
|
|
||||||
// The blocksize of MD4 in bytes.
|
|
||||||
const BlockSize = 64
|
|
||||||
|
|
||||||
const (
|
|
||||||
_Chunk = 64
|
|
||||||
_Init0 = 0x67452301
|
|
||||||
_Init1 = 0xEFCDAB89
|
|
||||||
_Init2 = 0x98BADCFE
|
|
||||||
_Init3 = 0x10325476
|
|
||||||
)
|
|
||||||
|
|
||||||
// digest represents the partial evaluation of a checksum.
|
|
||||||
type digest struct {
|
|
||||||
s [4]uint32
|
|
||||||
x [_Chunk]byte
|
|
||||||
nx int
|
|
||||||
len uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *digest) Reset() {
|
|
||||||
d.s[0] = _Init0
|
|
||||||
d.s[1] = _Init1
|
|
||||||
d.s[2] = _Init2
|
|
||||||
d.s[3] = _Init3
|
|
||||||
d.nx = 0
|
|
||||||
d.len = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a new hash.Hash computing the MD4 checksum.
|
|
||||||
func New() hash.Hash {
|
|
||||||
d := new(digest)
|
|
||||||
d.Reset()
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *digest) Size() int { return Size }
|
|
||||||
|
|
||||||
func (d *digest) BlockSize() int { return BlockSize }
|
|
||||||
|
|
||||||
func (d *digest) Write(p []byte) (nn int, err error) {
|
|
||||||
nn = len(p)
|
|
||||||
d.len += uint64(nn)
|
|
||||||
if d.nx > 0 {
|
|
||||||
n := len(p)
|
|
||||||
if n > _Chunk-d.nx {
|
|
||||||
n = _Chunk - d.nx
|
|
||||||
}
|
|
||||||
for i := 0; i < n; i++ {
|
|
||||||
d.x[d.nx+i] = p[i]
|
|
||||||
}
|
|
||||||
d.nx += n
|
|
||||||
if d.nx == _Chunk {
|
|
||||||
_Block(d, d.x[0:])
|
|
||||||
d.nx = 0
|
|
||||||
}
|
|
||||||
p = p[n:]
|
|
||||||
}
|
|
||||||
n := _Block(d, p)
|
|
||||||
p = p[n:]
|
|
||||||
if len(p) > 0 {
|
|
||||||
d.nx = copy(d.x[:], p)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d0 *digest) Sum(in []byte) []byte {
|
|
||||||
// Make a copy of d0, so that caller can keep writing and summing.
|
|
||||||
d := new(digest)
|
|
||||||
*d = *d0
|
|
||||||
|
|
||||||
// Padding. Add a 1 bit and 0 bits until 56 bytes mod 64.
|
|
||||||
len := d.len
|
|
||||||
var tmp [64]byte
|
|
||||||
tmp[0] = 0x80
|
|
||||||
if len%64 < 56 {
|
|
||||||
d.Write(tmp[0 : 56-len%64])
|
|
||||||
} else {
|
|
||||||
d.Write(tmp[0 : 64+56-len%64])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Length in bits.
|
|
||||||
len <<= 3
|
|
||||||
for i := uint(0); i < 8; i++ {
|
|
||||||
tmp[i] = byte(len >> (8 * i))
|
|
||||||
}
|
|
||||||
d.Write(tmp[0:8])
|
|
||||||
|
|
||||||
if d.nx != 0 {
|
|
||||||
panic("d.nx != 0")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, s := range d.s {
|
|
||||||
in = append(in, byte(s>>0))
|
|
||||||
in = append(in, byte(s>>8))
|
|
||||||
in = append(in, byte(s>>16))
|
|
||||||
in = append(in, byte(s>>24))
|
|
||||||
}
|
|
||||||
return in
|
|
||||||
}
|
|
89
vendor/golang.org/x/crypto/md4/md4block.go
generated
vendored
89
vendor/golang.org/x/crypto/md4/md4block.go
generated
vendored
@ -1,89 +0,0 @@
|
|||||||
// Copyright 2009 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.
|
|
||||||
|
|
||||||
// MD4 block step.
|
|
||||||
// In its own file so that a faster assembly or C version
|
|
||||||
// can be substituted easily.
|
|
||||||
|
|
||||||
package md4
|
|
||||||
|
|
||||||
var shift1 = []uint{3, 7, 11, 19}
|
|
||||||
var shift2 = []uint{3, 5, 9, 13}
|
|
||||||
var shift3 = []uint{3, 9, 11, 15}
|
|
||||||
|
|
||||||
var xIndex2 = []uint{0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}
|
|
||||||
var xIndex3 = []uint{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}
|
|
||||||
|
|
||||||
func _Block(dig *digest, p []byte) int {
|
|
||||||
a := dig.s[0]
|
|
||||||
b := dig.s[1]
|
|
||||||
c := dig.s[2]
|
|
||||||
d := dig.s[3]
|
|
||||||
n := 0
|
|
||||||
var X [16]uint32
|
|
||||||
for len(p) >= _Chunk {
|
|
||||||
aa, bb, cc, dd := a, b, c, d
|
|
||||||
|
|
||||||
j := 0
|
|
||||||
for i := 0; i < 16; i++ {
|
|
||||||
X[i] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24
|
|
||||||
j += 4
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this needs to be made faster in the future,
|
|
||||||
// the usual trick is to unroll each of these
|
|
||||||
// loops by a factor of 4; that lets you replace
|
|
||||||
// the shift[] lookups with constants and,
|
|
||||||
// with suitable variable renaming in each
|
|
||||||
// unrolled body, delete the a, b, c, d = d, a, b, c
|
|
||||||
// (or you can let the optimizer do the renaming).
|
|
||||||
//
|
|
||||||
// The index variables are uint so that % by a power
|
|
||||||
// of two can be optimized easily by a compiler.
|
|
||||||
|
|
||||||
// Round 1.
|
|
||||||
for i := uint(0); i < 16; i++ {
|
|
||||||
x := i
|
|
||||||
s := shift1[i%4]
|
|
||||||
f := ((c ^ d) & b) ^ d
|
|
||||||
a += f + X[x]
|
|
||||||
a = a<<s | a>>(32-s)
|
|
||||||
a, b, c, d = d, a, b, c
|
|
||||||
}
|
|
||||||
|
|
||||||
// Round 2.
|
|
||||||
for i := uint(0); i < 16; i++ {
|
|
||||||
x := xIndex2[i]
|
|
||||||
s := shift2[i%4]
|
|
||||||
g := (b & c) | (b & d) | (c & d)
|
|
||||||
a += g + X[x] + 0x5a827999
|
|
||||||
a = a<<s | a>>(32-s)
|
|
||||||
a, b, c, d = d, a, b, c
|
|
||||||
}
|
|
||||||
|
|
||||||
// Round 3.
|
|
||||||
for i := uint(0); i < 16; i++ {
|
|
||||||
x := xIndex3[i]
|
|
||||||
s := shift3[i%4]
|
|
||||||
h := b ^ c ^ d
|
|
||||||
a += h + X[x] + 0x6ed9eba1
|
|
||||||
a = a<<s | a>>(32-s)
|
|
||||||
a, b, c, d = d, a, b, c
|
|
||||||
}
|
|
||||||
|
|
||||||
a += aa
|
|
||||||
b += bb
|
|
||||||
c += cc
|
|
||||||
d += dd
|
|
||||||
|
|
||||||
p = p[_Chunk:]
|
|
||||||
n += _Chunk
|
|
||||||
}
|
|
||||||
|
|
||||||
dig.s[0] = a
|
|
||||||
dig.s[1] = b
|
|
||||||
dig.s[2] = c
|
|
||||||
dig.s[3] = d
|
|
||||||
return n
|
|
||||||
}
|
|
30
vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go
generated
vendored
30
vendor/golang.org/x/sys/internal/unsafeheader/unsafeheader.go
generated
vendored
@ -1,30 +0,0 @@
|
|||||||
// Copyright 2020 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 unsafeheader contains header declarations for the Go runtime's
|
|
||||||
// slice and string implementations.
|
|
||||||
//
|
|
||||||
// This package allows x/sys to use types equivalent to
|
|
||||||
// reflect.SliceHeader and reflect.StringHeader without introducing
|
|
||||||
// a dependency on the (relatively heavy) "reflect" package.
|
|
||||||
package unsafeheader
|
|
||||||
|
|
||||||
import (
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Slice is the runtime representation of a slice.
|
|
||||||
// It cannot be used safely or portably and its representation may change in a later release.
|
|
||||||
type Slice struct {
|
|
||||||
Data unsafe.Pointer
|
|
||||||
Len int
|
|
||||||
Cap int
|
|
||||||
}
|
|
||||||
|
|
||||||
// String is the runtime representation of a string.
|
|
||||||
// It cannot be used safely or portably and its representation may change in a later release.
|
|
||||||
type String struct {
|
|
||||||
Data unsafe.Pointer
|
|
||||||
Len int
|
|
||||||
}
|
|
15
vendor/golang.org/x/sys/unix/README.md
generated
vendored
15
vendor/golang.org/x/sys/unix/README.md
generated
vendored
@ -89,7 +89,7 @@ constants.
|
|||||||
|
|
||||||
Adding new syscall numbers is mostly done by running the build on a sufficiently
|
Adding new syscall numbers is mostly done by running the build on a sufficiently
|
||||||
new installation of the target OS (or updating the source checkouts for the
|
new installation of the target OS (or updating the source checkouts for the
|
||||||
new build system). However, depending on the OS, you may need to update the
|
new build system). However, depending on the OS, you make need to update the
|
||||||
parsing in mksysnum.
|
parsing in mksysnum.
|
||||||
|
|
||||||
### mksyscall.go
|
### mksyscall.go
|
||||||
@ -149,21 +149,10 @@ To add a constant, add the header that includes it to the appropriate variable.
|
|||||||
Then, edit the regex (if necessary) to match the desired constant. Avoid making
|
Then, edit the regex (if necessary) to match the desired constant. Avoid making
|
||||||
the regex too broad to avoid matching unintended constants.
|
the regex too broad to avoid matching unintended constants.
|
||||||
|
|
||||||
### mkmerge.go
|
|
||||||
|
|
||||||
This program is used to extract duplicate const, func, and type declarations
|
|
||||||
from the generated architecture-specific files listed below, and merge these
|
|
||||||
into a common file for each OS.
|
|
||||||
|
|
||||||
The merge is performed in the following steps:
|
|
||||||
1. Construct the set of common code that is idential in all architecture-specific files.
|
|
||||||
2. Write this common code to the merged file.
|
|
||||||
3. Remove the common code from all architecture-specific files.
|
|
||||||
|
|
||||||
|
|
||||||
## Generated files
|
## Generated files
|
||||||
|
|
||||||
### `zerrors_${GOOS}_${GOARCH}.go`
|
### `zerror_${GOOS}_${GOARCH}.go`
|
||||||
|
|
||||||
A file containing all of the system's generated error numbers, error strings,
|
A file containing all of the system's generated error numbers, error strings,
|
||||||
signal numbers, and constants. Generated by `mkerrors.sh` (see above).
|
signal numbers, and constants. Generated by `mkerrors.sh` (see above).
|
||||||
|
42
vendor/golang.org/x/sys/unix/affinity_linux.go
generated
vendored
42
vendor/golang.org/x/sys/unix/affinity_linux.go
generated
vendored
@ -7,7 +7,6 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/bits"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -80,7 +79,46 @@ func (s *CPUSet) IsSet(cpu int) bool {
|
|||||||
func (s *CPUSet) Count() int {
|
func (s *CPUSet) Count() int {
|
||||||
c := 0
|
c := 0
|
||||||
for _, b := range s {
|
for _, b := range s {
|
||||||
c += bits.OnesCount64(uint64(b))
|
c += onesCount64(uint64(b))
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// onesCount64 is a copy of Go 1.9's math/bits.OnesCount64.
|
||||||
|
// Once this package can require Go 1.9, we can delete this
|
||||||
|
// and update the caller to use bits.OnesCount64.
|
||||||
|
func onesCount64(x uint64) int {
|
||||||
|
const m0 = 0x5555555555555555 // 01010101 ...
|
||||||
|
const m1 = 0x3333333333333333 // 00110011 ...
|
||||||
|
const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ...
|
||||||
|
const m3 = 0x00ff00ff00ff00ff // etc.
|
||||||
|
const m4 = 0x0000ffff0000ffff
|
||||||
|
|
||||||
|
// Implementation: Parallel summing of adjacent bits.
|
||||||
|
// See "Hacker's Delight", Chap. 5: Counting Bits.
|
||||||
|
// The following pattern shows the general approach:
|
||||||
|
//
|
||||||
|
// x = x>>1&(m0&m) + x&(m0&m)
|
||||||
|
// x = x>>2&(m1&m) + x&(m1&m)
|
||||||
|
// x = x>>4&(m2&m) + x&(m2&m)
|
||||||
|
// x = x>>8&(m3&m) + x&(m3&m)
|
||||||
|
// x = x>>16&(m4&m) + x&(m4&m)
|
||||||
|
// x = x>>32&(m5&m) + x&(m5&m)
|
||||||
|
// return int(x)
|
||||||
|
//
|
||||||
|
// Masking (& operations) can be left away when there's no
|
||||||
|
// danger that a field's sum will carry over into the next
|
||||||
|
// field: Since the result cannot be > 64, 8 bits is enough
|
||||||
|
// and we can ignore the masks for the shifts by 8 and up.
|
||||||
|
// Per "Hacker's Delight", the first line can be simplified
|
||||||
|
// more, but it saves at best one instruction, so we leave
|
||||||
|
// it alone for clarity.
|
||||||
|
const m = 1<<64 - 1
|
||||||
|
x = x>>1&(m0&m) + x&(m0&m)
|
||||||
|
x = x>>2&(m1&m) + x&(m1&m)
|
||||||
|
x = (x>>4 + x) & (m2 & m)
|
||||||
|
x += x >> 8
|
||||||
|
x += x >> 16
|
||||||
|
x += x >> 32
|
||||||
|
return int(x) & (1<<7 - 1)
|
||||||
|
}
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_darwin_386.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
// +build arm,darwin
|
// +build arm,darwin
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
// +build arm64,darwin
|
// +build arm64,darwin
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_386.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_arm.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build arm64
|
// +build arm64
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build mips64 mips64le
|
// +build mips64 mips64le
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build mips mipsle
|
// +build mips mipsle
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build ppc64 ppc64le
|
// +build ppc64 ppc64le
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
47
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
generated
vendored
47
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
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.
|
|
||||||
|
|
||||||
// +build riscv64,gc
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System calls for linux/riscv64.
|
|
||||||
//
|
|
||||||
// Where available, just jump to package syscall's implementation of
|
|
||||||
// these functions.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
|
||||||
CALL runtime·entersyscall(SB)
|
|
||||||
MOV a1+8(FP), A0
|
|
||||||
MOV a2+16(FP), A1
|
|
||||||
MOV a3+24(FP), A2
|
|
||||||
MOV trap+0(FP), A7 // syscall entry
|
|
||||||
ECALL
|
|
||||||
MOV A0, r1+32(FP) // r1
|
|
||||||
MOV A1, r2+40(FP) // r2
|
|
||||||
CALL runtime·exitsyscall(SB)
|
|
||||||
RET
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
|
||||||
MOV a1+8(FP), A0
|
|
||||||
MOV a2+16(FP), A1
|
|
||||||
MOV a3+24(FP), A2
|
|
||||||
MOV trap+0(FP), A7 // syscall entry
|
|
||||||
ECALL
|
|
||||||
MOV A0, r1+32(FP)
|
|
||||||
MOV A1, r2+40(FP)
|
|
||||||
RET
|
|
2
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build s390x
|
// +build s390x
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_openbsd_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_openbsd_arm.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s
generated
vendored
@ -1,29 +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.
|
|
||||||
|
|
||||||
// +build gc
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for arm64, OpenBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
generated
vendored
29
vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
generated
vendored
@ -1,29 +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.
|
|
||||||
|
|
||||||
// +build gc
|
|
||||||
|
|
||||||
#include "textflag.h"
|
|
||||||
|
|
||||||
//
|
|
||||||
// System call support for mips64, OpenBSD
|
|
||||||
//
|
|
||||||
|
|
||||||
// Just jump to package syscall's implementation for all these functions.
|
|
||||||
// The runtime may know about them.
|
|
||||||
|
|
||||||
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·Syscall(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·Syscall6(SB)
|
|
||||||
|
|
||||||
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
|
||||||
JMP syscall·Syscall9(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
|
||||||
JMP syscall·RawSyscall(SB)
|
|
||||||
|
|
||||||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
|
||||||
JMP syscall·RawSyscall6(SB)
|
|
2
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
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.
|
||||||
|
|
||||||
// +build gc
|
// +build !gccgo
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
1
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
1
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
@ -23,7 +23,6 @@ const (
|
|||||||
HCI_CHANNEL_USER = 1
|
HCI_CHANNEL_USER = 1
|
||||||
HCI_CHANNEL_MONITOR = 2
|
HCI_CHANNEL_MONITOR = 2
|
||||||
HCI_CHANNEL_CONTROL = 3
|
HCI_CHANNEL_CONTROL = 3
|
||||||
HCI_CHANNEL_LOGGING = 4
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Socketoption Level
|
// Socketoption Level
|
||||||
|
91
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
91
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
@ -2,101 +2,16 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import "unsafe"
|
import "syscall"
|
||||||
|
|
||||||
// readInt returns the size-bytes unsigned integer in native byte order at offset off.
|
|
||||||
func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
|
|
||||||
if len(b) < int(off+size) {
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
if isBigEndian {
|
|
||||||
return readIntBE(b[off:], size), true
|
|
||||||
}
|
|
||||||
return readIntLE(b[off:], size), true
|
|
||||||
}
|
|
||||||
|
|
||||||
func readIntBE(b []byte, size uintptr) uint64 {
|
|
||||||
switch size {
|
|
||||||
case 1:
|
|
||||||
return uint64(b[0])
|
|
||||||
case 2:
|
|
||||||
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[1]) | uint64(b[0])<<8
|
|
||||||
case 4:
|
|
||||||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
|
|
||||||
case 8:
|
|
||||||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
|
|
||||||
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
|
|
||||||
default:
|
|
||||||
panic("syscall: readInt with unsupported size")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func readIntLE(b []byte, size uintptr) uint64 {
|
|
||||||
switch size {
|
|
||||||
case 1:
|
|
||||||
return uint64(b[0])
|
|
||||||
case 2:
|
|
||||||
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[0]) | uint64(b[1])<<8
|
|
||||||
case 4:
|
|
||||||
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
|
|
||||||
case 8:
|
|
||||||
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
|
||||||
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
|
|
||||||
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
|
|
||||||
default:
|
|
||||||
panic("syscall: readInt with unsupported size")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ParseDirent parses up to max directory entries in buf,
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
// appending the names to names. It returns the number of
|
// appending the names to names. It returns the number of
|
||||||
// bytes consumed from buf, the number of entries added
|
// bytes consumed from buf, the number of entries added
|
||||||
// to names, and the new names slice.
|
// to names, and the new names slice.
|
||||||
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
origlen := len(buf)
|
return syscall.ParseDirent(buf, max, names)
|
||||||
count = 0
|
|
||||||
for max != 0 && len(buf) > 0 {
|
|
||||||
reclen, ok := direntReclen(buf)
|
|
||||||
if !ok || reclen > uint64(len(buf)) {
|
|
||||||
return origlen, count, names
|
|
||||||
}
|
|
||||||
rec := buf[:reclen]
|
|
||||||
buf = buf[reclen:]
|
|
||||||
ino, ok := direntIno(rec)
|
|
||||||
if !ok {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if ino == 0 { // File absent in directory.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
|
|
||||||
namlen, ok := direntNamlen(rec)
|
|
||||||
if !ok || namoff+namlen > uint64(len(rec)) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
name := rec[namoff : namoff+namlen]
|
|
||||||
for i, c := range name {
|
|
||||||
if c == 0 {
|
|
||||||
name = name[:i]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check for useless names before allocating a string.
|
|
||||||
if string(name) == "." || string(name) == ".." {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
max--
|
|
||||||
count++
|
|
||||||
names = append(names, string(name))
|
|
||||||
}
|
|
||||||
return origlen - len(buf), count, names
|
|
||||||
}
|
}
|
||||||
|
2
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
2
vendor/golang.org/x/sys/unix/endian_big.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.
|
||||||
//
|
//
|
||||||
// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64
|
// +build ppc64 s390x mips mips64
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
2
vendor/golang.org/x/sys/unix/endian_little.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.
|
||||||
//
|
//
|
||||||
// +build 386 amd64 amd64p32 alpha arm arm64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh
|
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
6
vendor/golang.org/x/sys/unix/errors_freebsd_386.go
generated
vendored
6
vendor/golang.org/x/sys/unix/errors_freebsd_386.go
generated
vendored
@ -8,7 +8,6 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DLT_HHDLC = 0x79
|
|
||||||
IFF_SMART = 0x20
|
IFF_SMART = 0x20
|
||||||
IFT_1822 = 0x2
|
IFT_1822 = 0x2
|
||||||
IFT_A12MPPSWITCH = 0x82
|
IFT_A12MPPSWITCH = 0x82
|
||||||
@ -211,18 +210,13 @@ const (
|
|||||||
IFT_XETHER = 0x1a
|
IFT_XETHER = 0x1a
|
||||||
IPPROTO_MAXID = 0x34
|
IPPROTO_MAXID = 0x34
|
||||||
IPV6_FAITH = 0x1d
|
IPV6_FAITH = 0x1d
|
||||||
IPV6_MIN_MEMBERSHIPS = 0x1f
|
|
||||||
IP_FAITH = 0x16
|
IP_FAITH = 0x16
|
||||||
IP_MAX_SOURCE_FILTER = 0x400
|
|
||||||
IP_MIN_MEMBERSHIPS = 0x1f
|
|
||||||
MAP_NORESERVE = 0x40
|
MAP_NORESERVE = 0x40
|
||||||
MAP_RENAME = 0x20
|
MAP_RENAME = 0x20
|
||||||
NET_RT_MAXID = 0x6
|
NET_RT_MAXID = 0x6
|
||||||
RTF_PRCLONING = 0x10000
|
RTF_PRCLONING = 0x10000
|
||||||
RTM_OLDADD = 0x9
|
RTM_OLDADD = 0x9
|
||||||
RTM_OLDDEL = 0xa
|
RTM_OLDDEL = 0xa
|
||||||
RT_CACHING_CONTEXT = 0x1
|
|
||||||
RT_NORTREF = 0x2
|
|
||||||
SIOCADDRT = 0x8030720a
|
SIOCADDRT = 0x8030720a
|
||||||
SIOCALIFADDR = 0x8118691b
|
SIOCALIFADDR = 0x8118691b
|
||||||
SIOCDELRT = 0x8030720b
|
SIOCDELRT = 0x8030720b
|
||||||
|
6
vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
generated
vendored
6
vendor/golang.org/x/sys/unix/errors_freebsd_amd64.go
generated
vendored
@ -8,7 +8,6 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DLT_HHDLC = 0x79
|
|
||||||
IFF_SMART = 0x20
|
IFF_SMART = 0x20
|
||||||
IFT_1822 = 0x2
|
IFT_1822 = 0x2
|
||||||
IFT_A12MPPSWITCH = 0x82
|
IFT_A12MPPSWITCH = 0x82
|
||||||
@ -211,18 +210,13 @@ const (
|
|||||||
IFT_XETHER = 0x1a
|
IFT_XETHER = 0x1a
|
||||||
IPPROTO_MAXID = 0x34
|
IPPROTO_MAXID = 0x34
|
||||||
IPV6_FAITH = 0x1d
|
IPV6_FAITH = 0x1d
|
||||||
IPV6_MIN_MEMBERSHIPS = 0x1f
|
|
||||||
IP_FAITH = 0x16
|
IP_FAITH = 0x16
|
||||||
IP_MAX_SOURCE_FILTER = 0x400
|
|
||||||
IP_MIN_MEMBERSHIPS = 0x1f
|
|
||||||
MAP_NORESERVE = 0x40
|
MAP_NORESERVE = 0x40
|
||||||
MAP_RENAME = 0x20
|
MAP_RENAME = 0x20
|
||||||
NET_RT_MAXID = 0x6
|
NET_RT_MAXID = 0x6
|
||||||
RTF_PRCLONING = 0x10000
|
RTF_PRCLONING = 0x10000
|
||||||
RTM_OLDADD = 0x9
|
RTM_OLDADD = 0x9
|
||||||
RTM_OLDDEL = 0xa
|
RTM_OLDDEL = 0xa
|
||||||
RT_CACHING_CONTEXT = 0x1
|
|
||||||
RT_NORTREF = 0x2
|
|
||||||
SIOCADDRT = 0x8040720a
|
SIOCADDRT = 0x8040720a
|
||||||
SIOCALIFADDR = 0x8118691b
|
SIOCALIFADDR = 0x8118691b
|
||||||
SIOCDELRT = 0x8040720b
|
SIOCDELRT = 0x8040720b
|
||||||
|
17
vendor/golang.org/x/sys/unix/errors_freebsd_arm64.go
generated
vendored
17
vendor/golang.org/x/sys/unix/errors_freebsd_arm64.go
generated
vendored
@ -1,17 +0,0 @@
|
|||||||
// Copyright 2020 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.
|
|
||||||
|
|
||||||
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
|
||||||
// them here for backwards compatibility.
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
const (
|
|
||||||
DLT_HHDLC = 0x79
|
|
||||||
IPV6_MIN_MEMBERSHIPS = 0x1f
|
|
||||||
IP_MAX_SOURCE_FILTER = 0x400
|
|
||||||
IP_MIN_MEMBERSHIPS = 0x1f
|
|
||||||
RT_CACHING_CONTEXT = 0x1
|
|
||||||
RT_NORTREF = 0x2
|
|
||||||
)
|
|
12
vendor/golang.org/x/sys/unix/fcntl.go
generated
vendored
12
vendor/golang.org/x/sys/unix/fcntl.go
generated
vendored
@ -9,11 +9,12 @@ package unix
|
|||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
||||||
// systems by fcntl_linux_32bit.go to be SYS_FCNTL64.
|
// systems by flock_linux_32bit.go to be SYS_FCNTL64.
|
||||||
var fcntl64Syscall uintptr = SYS_FCNTL
|
var fcntl64Syscall uintptr = SYS_FCNTL
|
||||||
|
|
||||||
func fcntl(fd int, cmd, arg int) (int, error) {
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))
|
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
||||||
|
valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg))
|
||||||
var err error
|
var err error
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
err = errno
|
err = errno
|
||||||
@ -21,11 +22,6 @@ func fcntl(fd int, cmd, arg int) (int, error) {
|
|||||||
return int(valptr), err
|
return int(valptr), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
|
||||||
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
|
||||||
return fcntl(int(fd), cmd, arg)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
||||||
|
6
vendor/golang.org/x/sys/unix/fcntl_darwin.go
generated
vendored
6
vendor/golang.org/x/sys/unix/fcntl_darwin.go
generated
vendored
@ -16,9 +16,3 @@ func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
|||||||
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
|
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command.
|
|
||||||
func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error {
|
|
||||||
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore))))
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
4
vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
generated
vendored
4
vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
generated
vendored
@ -1,9 +1,9 @@
|
|||||||
|
// +build linux,386 linux,arm linux,mips linux,mipsle
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
// 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.
|
||||||
|
|
||||||
// +build linux,386 linux,arm linux,mips linux,mipsle
|
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
29
vendor/golang.org/x/sys/unix/fdset.go
generated
vendored
29
vendor/golang.org/x/sys/unix/fdset.go
generated
vendored
@ -1,29 +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.
|
|
||||||
|
|
||||||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
// Set adds fd to the set fds.
|
|
||||||
func (fds *FdSet) Set(fd int) {
|
|
||||||
fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear removes fd from the set fds.
|
|
||||||
func (fds *FdSet) Clear(fd int) {
|
|
||||||
fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsSet returns whether fd is in the set fds.
|
|
||||||
func (fds *FdSet) IsSet(fd int) bool {
|
|
||||||
return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Zero clears the set fds.
|
|
||||||
func (fds *FdSet) Zero() {
|
|
||||||
for i := range fds.Bits {
|
|
||||||
fds.Bits[i] = 0
|
|
||||||
}
|
|
||||||
}
|
|
2
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
2
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
@ -12,8 +12,10 @@ import "syscall"
|
|||||||
// We can't use the gc-syntax .s files for gccgo. On the plus side
|
// We can't use the gc-syntax .s files for gccgo. On the plus side
|
||||||
// much of the functionality can be written directly in Go.
|
// much of the functionality can be written directly in Go.
|
||||||
|
|
||||||
|
//extern gccgoRealSyscallNoError
|
||||||
func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
|
func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
|
||||||
|
|
||||||
|
//extern gccgoRealSyscall
|
||||||
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
|
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
|
||||||
|
|
||||||
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
|
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
|
||||||
|
6
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
6
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
@ -21,9 +21,6 @@ struct ret {
|
|||||||
uintptr_t err;
|
uintptr_t err;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
|
||||||
__asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall");
|
|
||||||
|
|
||||||
struct ret
|
struct ret
|
||||||
gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
||||||
{
|
{
|
||||||
@ -35,9 +32,6 @@ gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintp
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
|
||||||
__asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError");
|
|
||||||
|
|
||||||
uintptr_t
|
uintptr_t
|
||||||
gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
||||||
{
|
{
|
||||||
|
50
vendor/golang.org/x/sys/unix/ioctl.go
generated
vendored
50
vendor/golang.org/x/sys/unix/ioctl.go
generated
vendored
@ -6,28 +6,7 @@
|
|||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import "runtime"
|
||||||
"runtime"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ioctl itself should not be exposed directly, but additional get/set
|
|
||||||
// functions for specific types are permissible.
|
|
||||||
|
|
||||||
// IoctlSetInt performs an ioctl operation which sets an integer value
|
|
||||||
// on fd, using the specified request number.
|
|
||||||
func IoctlSetInt(fd int, req uint, value int) error {
|
|
||||||
return ioctl(fd, req, uintptr(value))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IoctlSetPointerInt performs an ioctl operation which sets an
|
|
||||||
// integer value on fd, using the specified request number. The ioctl
|
|
||||||
// argument is called with a pointer to the integer value, rather than
|
|
||||||
// passing the integer value directly.
|
|
||||||
func IoctlSetPointerInt(fd int, req uint, value int) error {
|
|
||||||
v := int32(value)
|
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(&v)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
||||||
//
|
//
|
||||||
@ -35,7 +14,7 @@ func IoctlSetPointerInt(fd int, req uint, value int) error {
|
|||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
// TODO: if we get the chance, remove the req parameter and
|
// TODO: if we get the chance, remove the req parameter and
|
||||||
// hardcode TIOCSWINSZ.
|
// hardcode TIOCSWINSZ.
|
||||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
err := ioctlSetWinsize(fd, req, value)
|
||||||
runtime.KeepAlive(value)
|
runtime.KeepAlive(value)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -45,30 +24,7 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
|||||||
// The req value will usually be TCSETA or TIOCSETA.
|
// The req value will usually be TCSETA or TIOCSETA.
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
// TODO: if we get the chance, remove the req parameter.
|
// TODO: if we get the chance, remove the req parameter.
|
||||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
err := ioctlSetTermios(fd, req, value)
|
||||||
runtime.KeepAlive(value)
|
runtime.KeepAlive(value)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// IoctlGetInt performs an ioctl operation which gets an integer value
|
|
||||||
// from fd, using the specified request number.
|
|
||||||
//
|
|
||||||
// A few ioctl requests use the return value as an output parameter;
|
|
||||||
// for those, IoctlRetInt should be used instead of this function.
|
|
||||||
func IoctlGetInt(fd int, req uint) (int, error) {
|
|
||||||
var value int
|
|
||||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
|
||||||
return value, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
|
|
||||||
var value Winsize
|
|
||||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
|
||||||
return &value, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
|
|
||||||
var value Termios
|
|
||||||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
|
||||||
return &value, err
|
|
||||||
}
|
|
||||||
|
65
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
65
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
@ -50,7 +50,7 @@ if [[ "$GOOS" = "linux" ]]; then
|
|||||||
# Use the Docker-based build system
|
# Use the Docker-based build system
|
||||||
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
||||||
$cmd docker build --tag generate:$GOOS $GOOS
|
$cmd docker build --tag generate:$GOOS $GOOS
|
||||||
$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")" && /bin/pwd):/build generate:$GOOS
|
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -73,22 +73,26 @@ aix_ppc64)
|
|||||||
darwin_386)
|
darwin_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="go run mksyscall.go -l32"
|
mksyscall="go run mksyscall.go -l32"
|
||||||
|
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
mkasm="go run mkasm_darwin.go"
|
mkasm="go run mkasm_darwin.go"
|
||||||
;;
|
;;
|
||||||
darwin_amd64)
|
darwin_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
mkasm="go run mkasm_darwin.go"
|
mkasm="go run mkasm_darwin.go"
|
||||||
;;
|
;;
|
||||||
darwin_arm)
|
darwin_arm)
|
||||||
mkerrors="$mkerrors"
|
mkerrors="$mkerrors"
|
||||||
mksyscall="go run mksyscall.go -l32"
|
mksyscall="go run mksyscall.go -l32"
|
||||||
|
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
mkasm="go run mkasm_darwin.go"
|
mkasm="go run mkasm_darwin.go"
|
||||||
;;
|
;;
|
||||||
darwin_arm64)
|
darwin_arm64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
mkasm="go run mkasm_darwin.go"
|
mkasm="go run mkasm_darwin.go"
|
||||||
;;
|
;;
|
||||||
@ -101,26 +105,26 @@ dragonfly_amd64)
|
|||||||
freebsd_386)
|
freebsd_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="go run mksyscall.go -l32"
|
mksyscall="go run mksyscall.go -l32"
|
||||||
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
freebsd_amd64)
|
freebsd_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
freebsd_arm)
|
freebsd_arm)
|
||||||
mkerrors="$mkerrors"
|
mkerrors="$mkerrors"
|
||||||
mksyscall="go run mksyscall.go -l32 -arm"
|
mksyscall="go run mksyscall.go -l32 -arm"
|
||||||
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master'"
|
||||||
# Let the type of C char be signed for making the bare syscall
|
# Let the type of C char be signed for making the bare syscall
|
||||||
# API consistent across platforms.
|
# API consistent across platforms.
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
;;
|
;;
|
||||||
freebsd_arm64)
|
freebsd_arm64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
netbsd_386)
|
netbsd_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
@ -142,48 +146,24 @@ netbsd_arm)
|
|||||||
# API consistent across platforms.
|
# API consistent across platforms.
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
;;
|
;;
|
||||||
netbsd_arm64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksyscall="go run mksyscall.go -netbsd"
|
|
||||||
mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
|
||||||
;;
|
|
||||||
openbsd_386)
|
openbsd_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="go run mksyscall.go -l32 -openbsd"
|
mksyscall="go run mksyscall.go -l32 -openbsd"
|
||||||
mksysctl="go run mksysctl_openbsd.go"
|
mksysctl="./mksysctl_openbsd.pl"
|
||||||
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
openbsd_amd64)
|
openbsd_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksyscall="go run mksyscall.go -openbsd"
|
mksyscall="go run mksyscall.go -openbsd"
|
||||||
mksysctl="go run mksysctl_openbsd.go"
|
mksysctl="./mksysctl_openbsd.pl"
|
||||||
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
openbsd_arm)
|
openbsd_arm)
|
||||||
mkerrors="$mkerrors"
|
mkerrors="$mkerrors"
|
||||||
mksyscall="go run mksyscall.go -l32 -openbsd -arm"
|
mksyscall="go run mksyscall.go -l32 -openbsd -arm"
|
||||||
mksysctl="go run mksysctl_openbsd.go"
|
mksysctl="./mksysctl_openbsd.pl"
|
||||||
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
|
||||||
# Let the type of C char be signed for making the bare syscall
|
|
||||||
# API consistent across platforms.
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
|
||||||
;;
|
|
||||||
openbsd_arm64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksyscall="go run mksyscall.go -openbsd"
|
|
||||||
mksysctl="go run mksysctl_openbsd.go"
|
|
||||||
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
|
||||||
# Let the type of C char be signed for making the bare syscall
|
|
||||||
# API consistent across platforms.
|
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
|
||||||
;;
|
|
||||||
openbsd_mips64)
|
|
||||||
mkerrors="$mkerrors -m64"
|
|
||||||
mksyscall="go run mksyscall.go -openbsd"
|
|
||||||
mksysctl="go run mksysctl_openbsd.go"
|
|
||||||
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
# Let the type of C char be signed for making the bare syscall
|
# Let the type of C char be signed for making the bare syscall
|
||||||
# API consistent across platforms.
|
# API consistent across platforms.
|
||||||
@ -195,12 +175,6 @@ solaris_amd64)
|
|||||||
mksysnum=
|
mksysnum=
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
illumos_amd64)
|
|
||||||
mksyscall="go run mksyscall_solaris.go"
|
|
||||||
mkerrors=
|
|
||||||
mksysnum=
|
|
||||||
mktypes=
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
|
echo 'unrecognized $GOOS_$GOARCH: ' "$GOOSARCH" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -222,15 +196,10 @@ esac
|
|||||||
# aix/ppc64 script generates files instead of writing to stdin.
|
# aix/ppc64 script generates files instead of writing to stdin.
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
|
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
|
||||||
elif [ "$GOOS" == "darwin" ]; then
|
elif [ "$GOOS" == "darwin" ]; then
|
||||||
|
# pre-1.12, direct syscalls
|
||||||
|
echo "$mksyscall -tags $GOOS,$GOARCH,!go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.1_11.go";
|
||||||
# 1.12 and later, syscalls via libSystem
|
# 1.12 and later, syscalls via libSystem
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
||||||
# 1.13 and later, syscalls via libSystem (including syscallPtr)
|
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH,go1.13 syscall_darwin.1_13.go |gofmt >zsyscall_$GOOSARCH.1_13.go";
|
|
||||||
elif [ "$GOOS" == "illumos" ]; then
|
|
||||||
# illumos code generation requires a --illumos switch
|
|
||||||
echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go";
|
|
||||||
# illumos implies solaris, so solaris code generation is also required
|
|
||||||
echo "$mksyscall -tags solaris,$GOARCH syscall_solaris.go syscall_solaris_$GOARCH.go |gofmt >zsyscall_solaris_$GOARCH.go";
|
|
||||||
else
|
else
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
||||||
fi
|
fi
|
||||||
@ -238,6 +207,8 @@ esac
|
|||||||
esac
|
esac
|
||||||
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
|
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
|
||||||
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
||||||
if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi
|
if [ -n "$mktypes" ]; then
|
||||||
|
echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go";
|
||||||
if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
|
if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
|
||||||
|
fi
|
||||||
) | $run
|
) | $run
|
||||||
|
111
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
111
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
@ -44,7 +44,6 @@ includes_AIX='
|
|||||||
#include <sys/stropts.h>
|
#include <sys/stropts.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/termio.h>
|
#include <sys/termio.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -58,15 +57,11 @@ includes_Darwin='
|
|||||||
#define _DARWIN_USE_64_BIT_INODE
|
#define _DARWIN_USE_64_BIT_INODE
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/attr.h>
|
#include <sys/attr.h>
|
||||||
#include <sys/clonefile.h>
|
|
||||||
#include <sys/kern_control.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/sys_domain.h>
|
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
@ -85,7 +80,6 @@ includes_Darwin='
|
|||||||
includes_DragonFly='
|
includes_DragonFly='
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -96,7 +90,6 @@ includes_DragonFly='
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <net/if_clone.h>
|
|
||||||
#include <net/if_types.h>
|
#include <net/if_types.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -109,10 +102,7 @@ includes_FreeBSD='
|
|||||||
#include <sys/capsicum.h>
|
#include <sys/capsicum.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/disk.h>
|
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/sched.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -189,68 +179,48 @@ struct ltchars {
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/signalfd.h>
|
#include <sys/signalfd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/timerfd.h>
|
|
||||||
#include <sys/uio.h>
|
|
||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
#include <linux/bpf.h>
|
|
||||||
#include <linux/can.h>
|
|
||||||
#include <linux/can/error.h>
|
|
||||||
#include <linux/can/raw.h>
|
|
||||||
#include <linux/capability.h>
|
|
||||||
#include <linux/cryptouser.h>
|
|
||||||
#include <linux/devlink.h>
|
|
||||||
#include <linux/dm-ioctl.h>
|
|
||||||
#include <linux/errqueue.h>
|
#include <linux/errqueue.h>
|
||||||
#include <linux/ethtool_netlink.h>
|
|
||||||
#include <linux/falloc.h>
|
|
||||||
#include <linux/fanotify.h>
|
|
||||||
#include <linux/filter.h>
|
|
||||||
#include <linux/fs.h>
|
|
||||||
#include <linux/fscrypt.h>
|
|
||||||
#include <linux/fsverity.h>
|
|
||||||
#include <linux/genetlink.h>
|
|
||||||
#include <linux/hdreg.h>
|
|
||||||
#include <linux/icmpv6.h>
|
|
||||||
#include <linux/if.h>
|
#include <linux/if.h>
|
||||||
#include <linux/if_addr.h>
|
|
||||||
#include <linux/if_alg.h>
|
#include <linux/if_alg.h>
|
||||||
#include <linux/if_arp.h>
|
#include <linux/if_arp.h>
|
||||||
#include <linux/if_ether.h>
|
#include <linux/if_ether.h>
|
||||||
#include <linux/if_ppp.h>
|
#include <linux/if_ppp.h>
|
||||||
#include <linux/if_tun.h>
|
#include <linux/if_tun.h>
|
||||||
#include <linux/if_packet.h>
|
#include <linux/if_packet.h>
|
||||||
#include <linux/if_xdp.h>
|
#include <linux/if_addr.h>
|
||||||
|
#include <linux/falloc.h>
|
||||||
|
#include <linux/filter.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
#include <linux/kexec.h>
|
#include <linux/kexec.h>
|
||||||
#include <linux/keyctl.h>
|
#include <linux/keyctl.h>
|
||||||
#include <linux/loop.h>
|
|
||||||
#include <linux/lwtunnel.h>
|
|
||||||
#include <linux/magic.h>
|
#include <linux/magic.h>
|
||||||
#include <linux/memfd.h>
|
#include <linux/memfd.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/netfilter/nfnetlink.h>
|
#include <linux/netfilter/nfnetlink.h>
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
#include <linux/net_namespace.h>
|
#include <linux/net_namespace.h>
|
||||||
#include <linux/nsfs.h>
|
|
||||||
#include <linux/perf_event.h>
|
#include <linux/perf_event.h>
|
||||||
#include <linux/pps.h>
|
|
||||||
#include <linux/ptrace.h>
|
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
#include <linux/rtc.h>
|
|
||||||
#include <linux/rtnetlink.h>
|
#include <linux/rtnetlink.h>
|
||||||
|
#include <linux/ptrace.h>
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/seccomp.h>
|
#include <linux/seccomp.h>
|
||||||
#include <linux/serial.h>
|
|
||||||
#include <linux/sockios.h>
|
#include <linux/sockios.h>
|
||||||
#include <linux/taskstats.h>
|
|
||||||
#include <linux/tipc.h>
|
|
||||||
#include <linux/vm_sockets.h>
|
|
||||||
#include <linux/wait.h>
|
#include <linux/wait.h>
|
||||||
|
#include <linux/icmpv6.h>
|
||||||
|
#include <linux/serial.h>
|
||||||
|
#include <linux/can.h>
|
||||||
|
#include <linux/vm_sockets.h>
|
||||||
|
#include <linux/taskstats.h>
|
||||||
|
#include <linux/genetlink.h>
|
||||||
#include <linux/watchdog.h>
|
#include <linux/watchdog.h>
|
||||||
|
#include <linux/hdreg.h>
|
||||||
|
#include <linux/rtc.h>
|
||||||
|
#include <linux/if_xdp.h>
|
||||||
#include <mtd/ubi-user.h>
|
#include <mtd/ubi-user.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
|
|
||||||
@ -289,16 +259,6 @@ struct ltchars {
|
|||||||
#define FS_KEY_DESC_PREFIX "fscrypt:"
|
#define FS_KEY_DESC_PREFIX "fscrypt:"
|
||||||
#define FS_KEY_DESC_PREFIX_SIZE 8
|
#define FS_KEY_DESC_PREFIX_SIZE 8
|
||||||
#define FS_MAX_KEY_SIZE 64
|
#define FS_MAX_KEY_SIZE 64
|
||||||
|
|
||||||
// The code generator produces -0x1 for (~0), but an unsigned value is necessary
|
|
||||||
// for the tipc_subscr timeout __u32 field.
|
|
||||||
#undef TIPC_WAIT_FOREVER
|
|
||||||
#define TIPC_WAIT_FOREVER 0xffffffff
|
|
||||||
|
|
||||||
// Copied from linux/l2tp.h
|
|
||||||
// Including linux/l2tp.h here causes conflicts between linux/in.h
|
|
||||||
// and netinet/in.h included via net/route.h above.
|
|
||||||
#define IPPROTO_L2TP 115
|
|
||||||
'
|
'
|
||||||
|
|
||||||
includes_NetBSD='
|
includes_NetBSD='
|
||||||
@ -308,8 +268,6 @@ includes_NetBSD='
|
|||||||
#include <sys/extattr.h>
|
#include <sys/extattr.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/sched.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
@ -336,8 +294,6 @@ includes_OpenBSD='
|
|||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/sched.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -374,11 +330,9 @@ includes_OpenBSD='
|
|||||||
includes_SunOS='
|
includes_SunOS='
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/select.h>
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/stream.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@ -468,7 +422,6 @@ ccflags="$@"
|
|||||||
$2 == "XCASE" ||
|
$2 == "XCASE" ||
|
||||||
$2 == "ALTWERASE" ||
|
$2 == "ALTWERASE" ||
|
||||||
$2 == "NOKERNINFO" ||
|
$2 == "NOKERNINFO" ||
|
||||||
$2 == "NFDBITS" ||
|
|
||||||
$2 ~ /^PAR/ ||
|
$2 ~ /^PAR/ ||
|
||||||
$2 ~ /^SIG[^_]/ ||
|
$2 ~ /^SIG[^_]/ ||
|
||||||
$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
|
$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
|
||||||
@ -478,9 +431,7 @@ ccflags="$@"
|
|||||||
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
||||||
$2 ~ /^IN_/ ||
|
$2 ~ /^IN_/ ||
|
||||||
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
||||||
$2 ~ /^LO_(KEY|NAME)_SIZE$/ ||
|
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
||||||
$2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ ||
|
|
||||||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|MCAST|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
|
||||||
$2 ~ /^TP_STATUS_/ ||
|
$2 ~ /^TP_STATUS_/ ||
|
||||||
$2 ~ /^FALLOC_/ ||
|
$2 ~ /^FALLOC_/ ||
|
||||||
$2 == "ICMPV6_FILTER" ||
|
$2 == "ICMPV6_FILTER" ||
|
||||||
@ -493,50 +444,38 @@ ccflags="$@"
|
|||||||
$2 ~ /^SYSCTL_VERS/ ||
|
$2 ~ /^SYSCTL_VERS/ ||
|
||||||
$2 !~ "MNT_BITS" &&
|
$2 !~ "MNT_BITS" &&
|
||||||
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
||||||
$2 ~ /^NS_GET_/ ||
|
|
||||||
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
||||||
$2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT|TFD)_/ ||
|
$2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT)_/ ||
|
||||||
$2 ~ /^KEXEC_/ ||
|
$2 ~ /^KEXEC_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
||||||
$2 ~ /^MODULE_INIT_/ ||
|
$2 ~ /^MODULE_INIT_/ ||
|
||||||
$2 !~ "NLA_TYPE_MASK" &&
|
$2 !~ "NLA_TYPE_MASK" &&
|
||||||
$2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ &&
|
|
||||||
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
||||||
$2 ~ /^FIORDCHK$/ ||
|
|
||||||
$2 ~ /^SIOC/ ||
|
$2 ~ /^SIOC/ ||
|
||||||
$2 ~ /^TIOC/ ||
|
$2 ~ /^TIOC/ ||
|
||||||
$2 ~ /^TCGET/ ||
|
$2 ~ /^TCGET/ ||
|
||||||
$2 ~ /^TCSET/ ||
|
$2 ~ /^TCSET/ ||
|
||||||
$2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
|
$2 ~ /^TC(FLSH|SBRKP?|XONC)$/ ||
|
||||||
$2 !~ "RTF_BITS" &&
|
$2 !~ "RTF_BITS" &&
|
||||||
$2 ~ /^(IFF|IFT|NET_RT|RTM(GRP)?|RTF|RTV|RTA|RTAX)_/ ||
|
$2 ~ /^(IFF|IFT|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
|
||||||
$2 ~ /^BIOC/ ||
|
$2 ~ /^BIOC/ ||
|
||||||
$2 ~ /^DIOC/ ||
|
|
||||||
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
$2 ~ /^RUSAGE_(SELF|CHILDREN|THREAD)/ ||
|
||||||
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
|
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
|
||||||
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
||||||
$2 ~ /^CLONE_[A-Z_]+/ ||
|
$2 ~ /^CLONE_[A-Z_]+/ ||
|
||||||
$2 !~ /^(BPF_TIMEVAL|BPF_FIB_LOOKUP_[A-Z]+)$/ &&
|
$2 !~ /^(BPF_TIMEVAL)$/ &&
|
||||||
$2 ~ /^(BPF|DLT)_/ ||
|
$2 ~ /^(BPF|DLT)_/ ||
|
||||||
$2 ~ /^(CLOCK|TIMER)_/ ||
|
$2 ~ /^(CLOCK|TIMER)_/ ||
|
||||||
$2 ~ /^CAN_/ ||
|
$2 ~ /^CAN_/ ||
|
||||||
$2 ~ /^CAP_/ ||
|
$2 ~ /^CAP_/ ||
|
||||||
$2 ~ /^CP_/ ||
|
|
||||||
$2 ~ /^CPUSTATES$/ ||
|
|
||||||
$2 ~ /^CTLIOCGINFO$/ ||
|
|
||||||
$2 ~ /^ALG_/ ||
|
$2 ~ /^ALG_/ ||
|
||||||
$2 ~ /^FI(CLONE|DEDUPERANGE)/ ||
|
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE|IOC_(GET|SET)_ENCRYPTION)/ ||
|
||||||
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ ||
|
|
||||||
$2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ ||
|
|
||||||
$2 ~ /^FS_VERITY_/ ||
|
|
||||||
$2 ~ /^FSCRYPT_/ ||
|
|
||||||
$2 ~ /^DM_/ ||
|
|
||||||
$2 ~ /^GRND_/ ||
|
$2 ~ /^GRND_/ ||
|
||||||
$2 ~ /^RND/ ||
|
$2 ~ /^RND/ ||
|
||||||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
||||||
$2 ~ /^KEYCTL_/ ||
|
$2 ~ /^KEYCTL_/ ||
|
||||||
$2 ~ /^PERF_/ ||
|
$2 ~ /^PERF_EVENT_IOC_/ ||
|
||||||
$2 ~ /^SECCOMP_MODE_/ ||
|
$2 ~ /^SECCOMP_MODE_/ ||
|
||||||
$2 ~ /^SPLICE_/ ||
|
$2 ~ /^SPLICE_/ ||
|
||||||
$2 ~ /^SYNC_FILE_RANGE_/ ||
|
$2 ~ /^SYNC_FILE_RANGE_/ ||
|
||||||
@ -555,21 +494,13 @@ ccflags="$@"
|
|||||||
$2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ ||
|
$2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ ||
|
||||||
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
||||||
$2 ~ /^FSOPT_/ ||
|
$2 ~ /^FSOPT_/ ||
|
||||||
$2 ~ /^WDIO[CFS]_/ ||
|
$2 ~ /^WDIOC_/ ||
|
||||||
$2 ~ /^NFN/ ||
|
$2 ~ /^NFN/ ||
|
||||||
$2 ~ /^XDP_/ ||
|
$2 ~ /^XDP_/ ||
|
||||||
$2 ~ /^RWF_/ ||
|
|
||||||
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
||||||
$2 ~ /^CRYPTO_/ ||
|
|
||||||
$2 ~ /^TIPC_/ ||
|
|
||||||
$2 !~ "DEVLINK_RELOAD_LIMITS_VALID_MASK" &&
|
|
||||||
$2 ~ /^DEVLINK_/ ||
|
|
||||||
$2 ~ /^ETHTOOL_/ ||
|
|
||||||
$2 ~ /^LWTUNNEL_IP/ ||
|
|
||||||
$2 !~ "WMESGLEN" &&
|
$2 !~ "WMESGLEN" &&
|
||||||
$2 ~ /^W[A-Z0-9]+$/ ||
|
$2 ~ /^W[A-Z0-9]+$/ ||
|
||||||
$2 ~/^PPPIOC/ ||
|
$2 ~/^PPPIOC/ ||
|
||||||
$2 ~ /^FAN_|FANOTIFY_/ ||
|
|
||||||
$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
|
$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
|
||||||
$2 ~ /^__WCOREFLAG$/ {next}
|
$2 ~ /^__WCOREFLAG$/ {next}
|
||||||
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
||||||
|
265
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
generated
vendored
Normal file
265
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl
generated
vendored
Normal file
@ -0,0 +1,265 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
# Copyright 2011 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.
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parse the header files for OpenBSD and generate a Go usable sysctl MIB.
|
||||||
|
#
|
||||||
|
# Build a MIB with each entry being an array containing the level, type and
|
||||||
|
# a hash that will contain additional entries if the current entry is a node.
|
||||||
|
# We then walk this MIB and create a flattened sysctl name to OID hash.
|
||||||
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
|
||||||
|
print STDERR "GOARCH or GOOS not defined in environment\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $debug = 0;
|
||||||
|
my %ctls = ();
|
||||||
|
|
||||||
|
my @headers = qw (
|
||||||
|
sys/sysctl.h
|
||||||
|
sys/socket.h
|
||||||
|
sys/tty.h
|
||||||
|
sys/malloc.h
|
||||||
|
sys/mount.h
|
||||||
|
sys/namei.h
|
||||||
|
sys/sem.h
|
||||||
|
sys/shm.h
|
||||||
|
sys/vmmeter.h
|
||||||
|
uvm/uvmexp.h
|
||||||
|
uvm/uvm_param.h
|
||||||
|
uvm/uvm_swap_encrypt.h
|
||||||
|
ddb/db_var.h
|
||||||
|
net/if.h
|
||||||
|
net/if_pfsync.h
|
||||||
|
net/pipex.h
|
||||||
|
netinet/in.h
|
||||||
|
netinet/icmp_var.h
|
||||||
|
netinet/igmp_var.h
|
||||||
|
netinet/ip_ah.h
|
||||||
|
netinet/ip_carp.h
|
||||||
|
netinet/ip_divert.h
|
||||||
|
netinet/ip_esp.h
|
||||||
|
netinet/ip_ether.h
|
||||||
|
netinet/ip_gre.h
|
||||||
|
netinet/ip_ipcomp.h
|
||||||
|
netinet/ip_ipip.h
|
||||||
|
netinet/pim_var.h
|
||||||
|
netinet/tcp_var.h
|
||||||
|
netinet/udp_var.h
|
||||||
|
netinet6/in6.h
|
||||||
|
netinet6/ip6_divert.h
|
||||||
|
netinet6/pim6_var.h
|
||||||
|
netinet/icmp6.h
|
||||||
|
netmpls/mpls.h
|
||||||
|
);
|
||||||
|
|
||||||
|
my @ctls = qw (
|
||||||
|
kern
|
||||||
|
vm
|
||||||
|
fs
|
||||||
|
net
|
||||||
|
#debug # Special handling required
|
||||||
|
hw
|
||||||
|
#machdep # Arch specific
|
||||||
|
user
|
||||||
|
ddb
|
||||||
|
#vfs # Special handling required
|
||||||
|
fs.posix
|
||||||
|
kern.forkstat
|
||||||
|
kern.intrcnt
|
||||||
|
kern.malloc
|
||||||
|
kern.nchstats
|
||||||
|
kern.seminfo
|
||||||
|
kern.shminfo
|
||||||
|
kern.timecounter
|
||||||
|
kern.tty
|
||||||
|
kern.watchdog
|
||||||
|
net.bpf
|
||||||
|
net.ifq
|
||||||
|
net.inet
|
||||||
|
net.inet.ah
|
||||||
|
net.inet.carp
|
||||||
|
net.inet.divert
|
||||||
|
net.inet.esp
|
||||||
|
net.inet.etherip
|
||||||
|
net.inet.gre
|
||||||
|
net.inet.icmp
|
||||||
|
net.inet.igmp
|
||||||
|
net.inet.ip
|
||||||
|
net.inet.ip.ifq
|
||||||
|
net.inet.ipcomp
|
||||||
|
net.inet.ipip
|
||||||
|
net.inet.mobileip
|
||||||
|
net.inet.pfsync
|
||||||
|
net.inet.pim
|
||||||
|
net.inet.tcp
|
||||||
|
net.inet.udp
|
||||||
|
net.inet6
|
||||||
|
net.inet6.divert
|
||||||
|
net.inet6.ip6
|
||||||
|
net.inet6.icmp6
|
||||||
|
net.inet6.pim6
|
||||||
|
net.inet6.tcp6
|
||||||
|
net.inet6.udp6
|
||||||
|
net.mpls
|
||||||
|
net.mpls.ifq
|
||||||
|
net.key
|
||||||
|
net.pflow
|
||||||
|
net.pfsync
|
||||||
|
net.pipex
|
||||||
|
net.rt
|
||||||
|
vm.swapencrypt
|
||||||
|
#vfsgenctl # Special handling required
|
||||||
|
);
|
||||||
|
|
||||||
|
# Node name "fixups"
|
||||||
|
my %ctl_map = (
|
||||||
|
"ipproto" => "net.inet",
|
||||||
|
"net.inet.ipproto" => "net.inet",
|
||||||
|
"net.inet6.ipv6proto" => "net.inet6",
|
||||||
|
"net.inet6.ipv6" => "net.inet6.ip6",
|
||||||
|
"net.inet.icmpv6" => "net.inet6.icmp6",
|
||||||
|
"net.inet6.divert6" => "net.inet6.divert",
|
||||||
|
"net.inet6.tcp6" => "net.inet.tcp",
|
||||||
|
"net.inet6.udp6" => "net.inet.udp",
|
||||||
|
"mpls" => "net.mpls",
|
||||||
|
"swpenc" => "vm.swapencrypt"
|
||||||
|
);
|
||||||
|
|
||||||
|
# Node mappings
|
||||||
|
my %node_map = (
|
||||||
|
"net.inet.ip.ifq" => "net.ifq",
|
||||||
|
"net.inet.pfsync" => "net.pfsync",
|
||||||
|
"net.mpls.ifq" => "net.ifq"
|
||||||
|
);
|
||||||
|
|
||||||
|
my $ctlname;
|
||||||
|
my %mib = ();
|
||||||
|
my %sysctl = ();
|
||||||
|
my $node;
|
||||||
|
|
||||||
|
sub debug() {
|
||||||
|
print STDERR "$_[0]\n" if $debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Walk the MIB and build a sysctl name to OID mapping.
|
||||||
|
sub build_sysctl() {
|
||||||
|
my ($node, $name, $oid) = @_;
|
||||||
|
my %node = %{$node};
|
||||||
|
my @oid = @{$oid};
|
||||||
|
|
||||||
|
foreach my $key (sort keys %node) {
|
||||||
|
my @node = @{$node{$key}};
|
||||||
|
my $nodename = $name.($name ne '' ? '.' : '').$key;
|
||||||
|
my @nodeoid = (@oid, $node[0]);
|
||||||
|
if ($node[1] eq 'CTLTYPE_NODE') {
|
||||||
|
if (exists $node_map{$nodename}) {
|
||||||
|
$node = \%mib;
|
||||||
|
$ctlname = $node_map{$nodename};
|
||||||
|
foreach my $part (split /\./, $ctlname) {
|
||||||
|
$node = \%{@{$$node{$part}}[2]};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$node = $node[2];
|
||||||
|
}
|
||||||
|
&build_sysctl($node, $nodename, \@nodeoid);
|
||||||
|
} elsif ($node[1] ne '') {
|
||||||
|
$sysctl{$nodename} = \@nodeoid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $ctl (@ctls) {
|
||||||
|
$ctls{$ctl} = $ctl;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Build MIB
|
||||||
|
foreach my $header (@headers) {
|
||||||
|
&debug("Processing $header...");
|
||||||
|
open HEADER, "/usr/include/$header" ||
|
||||||
|
print STDERR "Failed to open $header\n";
|
||||||
|
while (<HEADER>) {
|
||||||
|
if ($_ =~ /^#define\s+(CTL_NAMES)\s+{/ ||
|
||||||
|
$_ =~ /^#define\s+(CTL_(.*)_NAMES)\s+{/ ||
|
||||||
|
$_ =~ /^#define\s+((.*)CTL_NAMES)\s+{/) {
|
||||||
|
if ($1 eq 'CTL_NAMES') {
|
||||||
|
# Top level.
|
||||||
|
$node = \%mib;
|
||||||
|
} else {
|
||||||
|
# Node.
|
||||||
|
my $nodename = lc($2);
|
||||||
|
if ($header =~ /^netinet\//) {
|
||||||
|
$ctlname = "net.inet.$nodename";
|
||||||
|
} elsif ($header =~ /^netinet6\//) {
|
||||||
|
$ctlname = "net.inet6.$nodename";
|
||||||
|
} elsif ($header =~ /^net\//) {
|
||||||
|
$ctlname = "net.$nodename";
|
||||||
|
} else {
|
||||||
|
$ctlname = "$nodename";
|
||||||
|
$ctlname =~ s/^(fs|net|kern)_/$1\./;
|
||||||
|
}
|
||||||
|
if (exists $ctl_map{$ctlname}) {
|
||||||
|
$ctlname = $ctl_map{$ctlname};
|
||||||
|
}
|
||||||
|
if (not exists $ctls{$ctlname}) {
|
||||||
|
&debug("Ignoring $ctlname...");
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Walk down from the top of the MIB.
|
||||||
|
$node = \%mib;
|
||||||
|
foreach my $part (split /\./, $ctlname) {
|
||||||
|
if (not exists $$node{$part}) {
|
||||||
|
&debug("Missing node $part");
|
||||||
|
$$node{$part} = [ 0, '', {} ];
|
||||||
|
}
|
||||||
|
$node = \%{@{$$node{$part}}[2]};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Populate current node with entries.
|
||||||
|
my $i = -1;
|
||||||
|
while (defined($_) && $_ !~ /^}/) {
|
||||||
|
$_ = <HEADER>;
|
||||||
|
$i++ if $_ =~ /{.*}/;
|
||||||
|
next if $_ !~ /{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}/;
|
||||||
|
$$node{$1} = [ $i, $2, {} ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
&build_sysctl(\%mib, "", []);
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
// mksysctl_openbsd.pl
|
||||||
|
// Code generated by the command above; DO NOT EDIT.
|
||||||
|
|
||||||
|
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
|
||||||
|
|
||||||
|
package unix;
|
||||||
|
|
||||||
|
type mibentry struct {
|
||||||
|
ctlname string
|
||||||
|
ctloid []_C_int
|
||||||
|
}
|
||||||
|
|
||||||
|
var sysctlMib = []mibentry {
|
||||||
|
EOF
|
||||||
|
|
||||||
|
foreach my $name (sort keys %sysctl) {
|
||||||
|
my @oid = @{$sysctl{$name}};
|
||||||
|
print "\t{ \"$name\", []_C_int{ ", join(', ', @oid), " } }, \n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print <<EOF;
|
||||||
|
}
|
||||||
|
EOF
|
@ -2,6 +2,9 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
// +build openbsd
|
||||||
|
// +build 386 amd64 arm
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
@ -2,6 +2,8 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
// +build openbsd
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
11
vendor/golang.org/x/sys/unix/ptrace_darwin.go
generated
vendored
11
vendor/golang.org/x/sys/unix/ptrace_darwin.go
generated
vendored
@ -1,11 +0,0 @@
|
|||||||
// Copyright 2020 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.
|
|
||||||
|
|
||||||
// +build darwin,!ios
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
func ptrace(request int, pid int, addr uintptr, data uintptr) error {
|
|
||||||
return ptrace1(request, pid, addr, data)
|
|
||||||
}
|
|
11
vendor/golang.org/x/sys/unix/ptrace_ios.go
generated
vendored
11
vendor/golang.org/x/sys/unix/ptrace_ios.go
generated
vendored
@ -1,11 +0,0 @@
|
|||||||
// Copyright 2020 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.
|
|
||||||
|
|
||||||
// +build ios
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
|
|
||||||
return ENOTSUP
|
|
||||||
}
|
|
12
vendor/golang.org/x/sys/unix/readdirent_getdents.go
generated
vendored
12
vendor/golang.org/x/sys/unix/readdirent_getdents.go
generated
vendored
@ -1,12 +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.
|
|
||||||
|
|
||||||
// +build aix dragonfly freebsd linux netbsd openbsd
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
// ReadDirent reads directory entries from fd and writes them into buf.
|
|
||||||
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
|
||||||
return Getdents(fd, buf)
|
|
||||||
}
|
|
19
vendor/golang.org/x/sys/unix/readdirent_getdirentries.go
generated
vendored
19
vendor/golang.org/x/sys/unix/readdirent_getdirentries.go
generated
vendored
@ -1,19 +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.
|
|
||||||
|
|
||||||
// +build darwin
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import "unsafe"
|
|
||||||
|
|
||||||
// ReadDirent reads directory entries from fd and writes them into buf.
|
|
||||||
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
|
||||||
// Final argument is (basep *uintptr) and the syscall doesn't take nil.
|
|
||||||
// 64 bits should be enough. (32 bits isn't even on 386). Since the
|
|
||||||
// actual system call is getdirentries64, 64 is a good guess.
|
|
||||||
// TODO(rsc): Can we use a single global basep for all calls?
|
|
||||||
var base = (*uintptr)(unsafe.Pointer(new(uint64)))
|
|
||||||
return Getdirentries(fd, buf, base)
|
|
||||||
}
|
|
16
vendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go
generated
vendored
16
vendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go
generated
vendored
@ -1,16 +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.
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
// Round the length of a raw sockaddr up to align it properly.
|
|
||||||
func cmsgAlignOf(salen int) int {
|
|
||||||
salign := SizeofPtr
|
|
||||||
if SizeofPtr == 8 && !supportsABI(_dragonflyABIChangeVersion) {
|
|
||||||
// 64-bit Dragonfly before the September 2019 ABI changes still requires
|
|
||||||
// 32-bit aligned access to network subsystem.
|
|
||||||
salign = 4
|
|
||||||
}
|
|
||||||
return (salen + salign - 1) & ^(salign - 1)
|
|
||||||
}
|
|
2
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
2
vendor/golang.org/x/sys/unix/sockcmsg_linux.go
generated
vendored
@ -17,7 +17,7 @@ func UnixCredentials(ucred *Ucred) []byte {
|
|||||||
h.Level = SOL_SOCKET
|
h.Level = SOL_SOCKET
|
||||||
h.Type = SCM_CREDENTIALS
|
h.Type = SCM_CREDENTIALS
|
||||||
h.SetLen(CmsgLen(SizeofUcred))
|
h.SetLen(CmsgLen(SizeofUcred))
|
||||||
*(*Ucred)(h.data(0)) = *ucred
|
*((*Ucred)(cmsgData(h))) = *ucred
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
33
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
33
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
generated
vendored
@ -9,9 +9,32 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Round the length of a raw sockaddr up to align it properly.
|
||||||
|
func cmsgAlignOf(salen int) int {
|
||||||
|
salign := SizeofPtr
|
||||||
|
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "darwin", "dragonfly", "solaris":
|
||||||
|
// NOTE: It seems like 64-bit Darwin, DragonFly BSD and
|
||||||
|
// Solaris kernels still require 32-bit aligned access to
|
||||||
|
// network subsystem.
|
||||||
|
if SizeofPtr == 8 {
|
||||||
|
salign = 4
|
||||||
|
}
|
||||||
|
case "openbsd":
|
||||||
|
// OpenBSD armv7 requires 64-bit alignment.
|
||||||
|
if runtime.GOARCH == "arm" {
|
||||||
|
salign = 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (salen + salign - 1) & ^(salign - 1)
|
||||||
|
}
|
||||||
|
|
||||||
// CmsgLen returns the value to store in the Len field of the Cmsghdr
|
// CmsgLen returns the value to store in the Len field of the Cmsghdr
|
||||||
// structure, taking into account any necessary alignment.
|
// structure, taking into account any necessary alignment.
|
||||||
func CmsgLen(datalen int) int {
|
func CmsgLen(datalen int) int {
|
||||||
@ -24,8 +47,8 @@ func CmsgSpace(datalen int) int {
|
|||||||
return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
|
return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Cmsghdr) data(offset uintptr) unsafe.Pointer {
|
func cmsgData(h *Cmsghdr) unsafe.Pointer {
|
||||||
return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)) + offset)
|
return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SocketControlMessage represents a socket control message.
|
// SocketControlMessage represents a socket control message.
|
||||||
@ -68,8 +91,10 @@ func UnixRights(fds ...int) []byte {
|
|||||||
h.Level = SOL_SOCKET
|
h.Level = SOL_SOCKET
|
||||||
h.Type = SCM_RIGHTS
|
h.Type = SCM_RIGHTS
|
||||||
h.SetLen(CmsgLen(datalen))
|
h.SetLen(CmsgLen(datalen))
|
||||||
for i, fd := range fds {
|
data := cmsgData(h)
|
||||||
*(*int32)(h.data(4 * uintptr(i))) = int32(fd)
|
for _, fd := range fds {
|
||||||
|
*(*int32)(data) = int32(fd)
|
||||||
|
data = unsafe.Pointer(uintptr(data) + 4)
|
||||||
}
|
}
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
42
vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go
generated
vendored
42
vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go
generated
vendored
@ -1,42 +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.
|
|
||||||
|
|
||||||
// +build aix darwin freebsd linux netbsd openbsd solaris
|
|
||||||
|
|
||||||
package unix
|
|
||||||
|
|
||||||
import (
|
|
||||||
"runtime"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Round the length of a raw sockaddr up to align it properly.
|
|
||||||
func cmsgAlignOf(salen int) int {
|
|
||||||
salign := SizeofPtr
|
|
||||||
|
|
||||||
// dragonfly needs to check ABI version at runtime, see cmsgAlignOf in
|
|
||||||
// sockcmsg_dragonfly.go
|
|
||||||
switch runtime.GOOS {
|
|
||||||
case "aix":
|
|
||||||
// There is no alignment on AIX.
|
|
||||||
salign = 1
|
|
||||||
case "darwin", "ios", "illumos", "solaris":
|
|
||||||
// NOTE: It seems like 64-bit Darwin, Illumos and Solaris
|
|
||||||
// kernels still require 32-bit aligned access to network
|
|
||||||
// subsystem.
|
|
||||||
if SizeofPtr == 8 {
|
|
||||||
salign = 4
|
|
||||||
}
|
|
||||||
case "netbsd", "openbsd":
|
|
||||||
// NetBSD and OpenBSD armv7 require 64-bit alignment.
|
|
||||||
if runtime.GOARCH == "arm" {
|
|
||||||
salign = 8
|
|
||||||
}
|
|
||||||
// NetBSD aarch64 requires 128-bit alignment.
|
|
||||||
if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" {
|
|
||||||
salign = 16
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (salen + salign - 1) & ^(salign - 1)
|
|
||||||
}
|
|
44
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
44
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
@ -24,13 +24,7 @@
|
|||||||
// holds a value of type syscall.Errno.
|
// holds a value of type syscall.Errno.
|
||||||
package unix // import "golang.org/x/sys/unix"
|
package unix // import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
import (
|
import "strings"
|
||||||
"bytes"
|
|
||||||
"strings"
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"golang.org/x/sys/internal/unsafeheader"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ByteSliceFromString returns a NUL-terminated slice of bytes
|
// ByteSliceFromString returns a NUL-terminated slice of bytes
|
||||||
// containing the text of s. If s contains a NUL byte at any
|
// containing the text of s. If s contains a NUL byte at any
|
||||||
@ -55,40 +49,6 @@ func BytePtrFromString(s string) (*byte, error) {
|
|||||||
return &a[0], nil
|
return &a[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ByteSliceToString returns a string form of the text represented by the slice s, with a terminating NUL and any
|
|
||||||
// bytes after the NUL removed.
|
|
||||||
func ByteSliceToString(s []byte) string {
|
|
||||||
if i := bytes.IndexByte(s, 0); i != -1 {
|
|
||||||
s = s[:i]
|
|
||||||
}
|
|
||||||
return string(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BytePtrToString takes a pointer to a sequence of text and returns the corresponding string.
|
|
||||||
// If the pointer is nil, it returns the empty string. It assumes that the text sequence is terminated
|
|
||||||
// at a zero byte; if the zero byte is not present, the program may crash.
|
|
||||||
func BytePtrToString(p *byte) string {
|
|
||||||
if p == nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
if *p == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find NUL terminator.
|
|
||||||
n := 0
|
|
||||||
for ptr := unsafe.Pointer(p); *(*byte)(ptr) != 0; n++ {
|
|
||||||
ptr = unsafe.Pointer(uintptr(ptr) + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
var s []byte
|
|
||||||
h := (*unsafeheader.Slice)(unsafe.Pointer(&s))
|
|
||||||
h.Data = unsafe.Pointer(p)
|
|
||||||
h.Len = n
|
|
||||||
h.Cap = n
|
|
||||||
|
|
||||||
return string(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
||||||
|
// See mkunix.pl.
|
||||||
var _zero uintptr
|
var _zero uintptr
|
||||||
|
103
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
103
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
@ -19,22 +19,6 @@ import "unsafe"
|
|||||||
* Wrapped
|
* Wrapped
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func Access(path string, mode uint32) (err error) {
|
|
||||||
return Faccessat(AT_FDCWD, path, mode, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Chmod(path string, mode uint32) (err error) {
|
|
||||||
return Fchmodat(AT_FDCWD, path, mode, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Chown(path string, uid int, gid int) (err error) {
|
|
||||||
return Fchownat(AT_FDCWD, path, uid, gid, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Creat(path string, mode uint32) (fd int, err error) {
|
|
||||||
return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode)
|
|
||||||
}
|
|
||||||
|
|
||||||
//sys utimes(path string, times *[2]Timeval) (err error)
|
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||||
func Utimes(path string, tv []Timeval) error {
|
func Utimes(path string, tv []Timeval) error {
|
||||||
if len(tv) != 2 {
|
if len(tv) != 2 {
|
||||||
@ -296,24 +280,8 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
return -1, ENOSYS
|
return -1, ENOSYS
|
||||||
}
|
}
|
||||||
|
|
||||||
func direntIno(buf []byte) (uint64, bool) {
|
|
||||||
return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
|
|
||||||
}
|
|
||||||
|
|
||||||
func direntReclen(buf []byte) (uint64, bool) {
|
|
||||||
return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
|
|
||||||
}
|
|
||||||
|
|
||||||
func direntNamlen(buf []byte) (uint64, bool) {
|
|
||||||
reclen, ok := direntReclen(buf)
|
|
||||||
if !ok {
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
return reclen - uint64(unsafe.Offsetof(Dirent{}.Name)), true
|
|
||||||
}
|
|
||||||
|
|
||||||
//sys getdirent(fd int, buf []byte) (n int, err error)
|
//sys getdirent(fd int, buf []byte) (n int, err error)
|
||||||
func Getdents(fd int, buf []byte) (n int, err error) {
|
func ReadDirent(fd int, buf []byte) (n int, err error) {
|
||||||
return getdirent(fd, buf)
|
return getdirent(fd, buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,12 +334,49 @@ func (w WaitStatus) Signal() Signal {
|
|||||||
|
|
||||||
func (w WaitStatus) Continued() bool { return w&0x01000000 != 0 }
|
func (w WaitStatus) Continued() bool { return w&0x01000000 != 0 }
|
||||||
|
|
||||||
func (w WaitStatus) CoreDump() bool { return w&0x80 == 0x80 }
|
func (w WaitStatus) CoreDump() bool { return w&0x200 != 0 }
|
||||||
|
|
||||||
func (w WaitStatus) TrapCause() int { return -1 }
|
func (w WaitStatus) TrapCause() int { return -1 }
|
||||||
|
|
||||||
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
|
// ioctl itself should not be exposed directly, but additional get/set
|
||||||
|
// functions for specific types are permissible.
|
||||||
|
|
||||||
|
// IoctlSetInt performs an ioctl operation which sets an integer value
|
||||||
|
// on fd, using the specified request number.
|
||||||
|
func IoctlSetInt(fd int, req uint, value int) error {
|
||||||
|
return ioctl(fd, req, uintptr(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func ioctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
|
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetInt performs an ioctl operation which gets an integer value
|
||||||
|
// from fd, using the specified request number.
|
||||||
|
func IoctlGetInt(fd int, req uint) (int, error) {
|
||||||
|
var value int
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
|
||||||
|
var value Winsize
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
|
||||||
|
var value Termios
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
// fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX
|
// fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX
|
||||||
// There is no way to create a custom fcntl and to keep //sys fcntl easily,
|
// There is no way to create a custom fcntl and to keep //sys fcntl easily,
|
||||||
// Therefore, the programmer must call dup2 instead of fcntl in this case.
|
// Therefore, the programmer must call dup2 instead of fcntl in this case.
|
||||||
@ -439,6 +444,8 @@ func (w WaitStatus) TrapCause() int { return -1 }
|
|||||||
//sysnb Times(tms *Tms) (ticks uintptr, err error)
|
//sysnb Times(tms *Tms) (ticks uintptr, err error)
|
||||||
//sysnb Umask(mask int) (oldmask int)
|
//sysnb Umask(mask int) (oldmask int)
|
||||||
//sysnb Uname(buf *Utsname) (err error)
|
//sysnb Uname(buf *Utsname) (err error)
|
||||||
|
//TODO umount
|
||||||
|
// //sys Unmount(target string, flags int) (err error) = umount
|
||||||
//sys Unlink(path string) (err error)
|
//sys Unlink(path string) (err error)
|
||||||
//sys Unlinkat(dirfd int, path string, flags int) (err error)
|
//sys Unlinkat(dirfd int, path string, flags int) (err error)
|
||||||
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
//sys Ustat(dev int, ubuf *Ustat_t) (err error)
|
||||||
@ -449,8 +456,8 @@ func (w WaitStatus) TrapCause() int { return -1 }
|
|||||||
//sys Dup2(oldfd int, newfd int) (err error)
|
//sys Dup2(oldfd int, newfd int) (err error)
|
||||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = posix_fadvise64
|
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = posix_fadvise64
|
||||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
//sys fstat(fd int, stat *Stat_t) (err error)
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
//sys fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = fstatat
|
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = fstatat
|
||||||
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||||
//sys Ftruncate(fd int, length int64) (err error)
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
//sysnb Getegid() (egid int)
|
//sysnb Getegid() (egid int)
|
||||||
@ -459,17 +466,18 @@ func (w WaitStatus) TrapCause() int { return -1 }
|
|||||||
//sysnb Getuid() (uid int)
|
//sysnb Getuid() (uid int)
|
||||||
//sys Lchown(path string, uid int, gid int) (err error)
|
//sys Lchown(path string, uid int, gid int) (err error)
|
||||||
//sys Listen(s int, n int) (err error)
|
//sys Listen(s int, n int) (err error)
|
||||||
//sys lstat(path string, stat *Stat_t) (err error)
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
//sys Pause() (err error)
|
//sys Pause() (err error)
|
||||||
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = pread64
|
//sys Pread(fd int, p []byte, offset int64) (n int, err error) = pread64
|
||||||
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = pwrite64
|
//sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = pwrite64
|
||||||
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
|
//TODO Select
|
||||||
|
// //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
|
||||||
//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
|
//sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
|
||||||
//sysnb Setregid(rgid int, egid int) (err error)
|
//sysnb Setregid(rgid int, egid int) (err error)
|
||||||
//sysnb Setreuid(ruid int, euid int) (err error)
|
//sysnb Setreuid(ruid int, euid int) (err error)
|
||||||
//sys Shutdown(fd int, how int) (err error)
|
//sys Shutdown(fd int, how int) (err error)
|
||||||
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
|
//sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error)
|
||||||
//sys stat(path string, statptr *Stat_t) (err error)
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
//sys Statfs(path string, buf *Statfs_t) (err error)
|
//sys Statfs(path string, buf *Statfs_t) (err error)
|
||||||
//sys Truncate(path string, length int64) (err error)
|
//sys Truncate(path string, length int64) (err error)
|
||||||
|
|
||||||
@ -485,10 +493,8 @@ func (w WaitStatus) TrapCause() int { return -1 }
|
|||||||
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||||
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
// In order to use msghdr structure with Control, Controllen, nrecvmsg and nsendmsg must be used.
|
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = nrecvmsg
|
|
||||||
//sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = nsendmsg
|
|
||||||
|
|
||||||
//sys munmap(addr uintptr, length uintptr) (err error)
|
//sys munmap(addr uintptr, length uintptr) (err error)
|
||||||
|
|
||||||
@ -539,14 +545,3 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
|
|||||||
//sys gettimeofday(tv *Timeval, tzp *Timezone) (err error)
|
//sys gettimeofday(tv *Timeval, tzp *Timezone) (err error)
|
||||||
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
//sysnb Time(t *Time_t) (tt Time_t, err error)
|
||||||
//sys Utime(path string, buf *Utimbuf) (err error)
|
//sys Utime(path string, buf *Utimbuf) (err error)
|
||||||
|
|
||||||
//sys Getsystemcfg(label int) (n uint64)
|
|
||||||
|
|
||||||
//sys umount(target string) (err error)
|
|
||||||
func Unmount(target string, flags int) (err error) {
|
|
||||||
if flags != 0 {
|
|
||||||
// AIX doesn't have any flags for umount.
|
|
||||||
return ENOSYS
|
|
||||||
}
|
|
||||||
return umount(target)
|
|
||||||
}
|
|
||||||
|
20
vendor/golang.org/x/sys/unix/syscall_aix_ppc.go
generated
vendored
20
vendor/golang.org/x/sys/unix/syscall_aix_ppc.go
generated
vendored
@ -29,26 +29,6 @@ func (msghdr *Msghdr) SetControllen(length int) {
|
|||||||
msghdr.Controllen = uint32(length)
|
msghdr.Controllen = uint32(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msghdr *Msghdr) SetIovlen(length int) {
|
|
||||||
msghdr.Iovlen = int32(length)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
cmsg.Len = uint32(length)
|
cmsg.Len = uint32(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Fstat(fd int, stat *Stat_t) error {
|
|
||||||
return fstat(fd, stat)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error {
|
|
||||||
return fstatat(dirfd, path, stat, flags)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Lstat(path string, stat *Stat_t) error {
|
|
||||||
return lstat(path, stat)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Stat(path string, statptr *Stat_t) error {
|
|
||||||
return stat(path, statptr)
|
|
||||||
}
|
|
||||||
|
51
vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go
generated
vendored
51
vendor/golang.org/x/sys/unix/syscall_aix_ppc64.go
generated
vendored
@ -29,57 +29,6 @@ func (msghdr *Msghdr) SetControllen(length int) {
|
|||||||
msghdr.Controllen = uint32(length)
|
msghdr.Controllen = uint32(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msghdr *Msghdr) SetIovlen(length int) {
|
|
||||||
msghdr.Iovlen = int32(length)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (cmsg *Cmsghdr) SetLen(length int) {
|
func (cmsg *Cmsghdr) SetLen(length int) {
|
||||||
cmsg.Len = uint32(length)
|
cmsg.Len = uint32(length)
|
||||||
}
|
}
|
||||||
|
|
||||||
// In order to only have Timespec structure, type of Stat_t's fields
|
|
||||||
// Atim, Mtim and Ctim is changed from StTimespec to Timespec during
|
|
||||||
// ztypes generation.
|
|
||||||
// On ppc64, Timespec.Nsec is an int64 while StTimespec.Nsec is an
|
|
||||||
// int32, so the fields' value must be modified.
|
|
||||||
func fixStatTimFields(stat *Stat_t) {
|
|
||||||
stat.Atim.Nsec >>= 32
|
|
||||||
stat.Mtim.Nsec >>= 32
|
|
||||||
stat.Ctim.Nsec >>= 32
|
|
||||||
}
|
|
||||||
|
|
||||||
func Fstat(fd int, stat *Stat_t) error {
|
|
||||||
err := fstat(fd, stat)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fixStatTimFields(stat)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Fstatat(dirfd int, path string, stat *Stat_t, flags int) error {
|
|
||||||
err := fstatat(dirfd, path, stat, flags)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fixStatTimFields(stat)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Lstat(path string, stat *Stat_t) error {
|
|
||||||
err := lstat(path, stat)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fixStatTimFields(stat)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Stat(path string, statptr *Stat_t) error {
|
|
||||||
err := stat(path, statptr)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fixStatTimFields(statptr)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user