├── .gitignore ├── .travis.yml ├── Dockerfile ├── Dockerfile_build ├── LICENSE ├── Makefile ├── README.md ├── glide.lock ├── glide.yaml ├── main.go ├── main_test.go ├── pamhook_cert.crt ├── pamhook_key.crt └── vendor ├── github.com ├── SermoDigital │ └── jose │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── _test.sh │ │ ├── base64.go │ │ ├── base64_test.go │ │ ├── crypto │ │ ├── doc.go │ │ ├── ecdsa.go │ │ ├── ecdsa_test.go │ │ ├── ecdsa_utils.go │ │ ├── errors.go │ │ ├── hmac.go │ │ ├── hmac_test.go │ │ ├── none.go │ │ ├── rsa.go │ │ ├── rsa_pss.go │ │ ├── rsa_pss_test.go │ │ ├── rsa_test.go │ │ ├── rsa_utils.go │ │ ├── signature.go │ │ ├── signature_test.go │ │ ├── signing_method.go │ │ └── stubs_test.go │ │ ├── doc.go │ │ ├── header.go │ │ ├── header_test.go │ │ ├── jws │ │ ├── claims.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── jws.go │ │ ├── jws_serialize.go │ │ ├── jws_serialize_test.go │ │ ├── jws_test.go │ │ ├── jws_validate.go │ │ ├── jwt.go │ │ ├── jwt_test.go │ │ ├── payload.go │ │ ├── payload_test.go │ │ ├── rawbase64.go │ │ ├── rawbase64_test.go │ │ ├── signing_methods.go │ │ ├── signing_methods_test.go │ │ ├── stubs_test.go │ │ └── test │ │ │ ├── ec256-private.pem │ │ │ ├── ec256-public.pem │ │ │ ├── ec384-private.pem │ │ │ ├── ec384-public.pem │ │ │ ├── ec512-private.pem │ │ │ ├── ec512-public.pem │ │ │ ├── hmacTestKey │ │ │ ├── sample_key.priv │ │ │ ├── sample_key.pub │ │ │ └── test.go │ │ ├── jwt │ │ ├── claims.go │ │ ├── claims_test.go │ │ ├── doc.go │ │ ├── eq.go │ │ ├── eq_test.go │ │ ├── errors.go │ │ └── jwt.go │ │ ├── stubs_test.go │ │ └── time.go ├── golang │ └── glog │ │ ├── LICENSE │ │ ├── README │ │ ├── glog.go │ │ ├── glog_file.go │ │ └── glog_test.go └── msteinert │ └── pam │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── callback.go │ ├── callback_test.go │ ├── example_test.go │ ├── transaction.c │ ├── transaction.go │ └── transaction_test.go └── golang.org └── x └── sys ├── .gitattributes ├── .gitignore ├── AUTHORS ├── CONTRIBUTING.md ├── CONTRIBUTORS ├── LICENSE ├── PATENTS ├── README ├── codereview.cfg ├── plan9 ├── asm.s ├── asm_plan9_386.s ├── asm_plan9_amd64.s ├── const_plan9.go ├── dir_plan9.go ├── env_plan9.go ├── env_unset.go ├── errors_plan9.go ├── mkall.sh ├── mkerrors.sh ├── mksyscall.pl ├── mksysnum_plan9.sh ├── pwd_go15_plan9.go ├── pwd_plan9.go ├── race.go ├── race0.go ├── str.go ├── syscall.go ├── syscall_plan9.go ├── syscall_test.go ├── zsyscall_plan9_386.go ├── zsyscall_plan9_amd64.go └── zsysnum_plan9.go ├── unix ├── .gitignore ├── asm.s ├── asm_darwin_386.s ├── asm_darwin_amd64.s ├── asm_darwin_arm.s ├── asm_darwin_arm64.s ├── asm_dragonfly_amd64.s ├── asm_freebsd_386.s ├── asm_freebsd_amd64.s ├── asm_freebsd_arm.s ├── asm_linux_386.s ├── asm_linux_amd64.s ├── asm_linux_arm.s ├── asm_linux_arm64.s ├── asm_linux_mips64x.s ├── asm_linux_ppc64x.s ├── asm_linux_s390x.s ├── asm_netbsd_386.s ├── asm_netbsd_amd64.s ├── asm_netbsd_arm.s ├── asm_openbsd_386.s ├── asm_openbsd_amd64.s ├── asm_solaris_amd64.s ├── bluetooth_linux.go ├── constants.go ├── creds_test.go ├── env_unix.go ├── env_unset.go ├── export_test.go ├── flock.go ├── flock_linux_32bit.go ├── gccgo.go ├── gccgo_c.c ├── gccgo_linux_amd64.go ├── mkall.sh ├── mkerrors.sh ├── mkpost.go ├── mksyscall.pl ├── mksyscall_solaris.pl ├── mksysctl_openbsd.pl ├── mksysnum_darwin.pl ├── mksysnum_dragonfly.pl ├── mksysnum_freebsd.pl ├── mksysnum_linux.pl ├── mksysnum_netbsd.pl ├── mksysnum_openbsd.pl ├── mmap_unix_test.go ├── race.go ├── race0.go ├── sockcmsg_linux.go ├── sockcmsg_unix.go ├── str.go ├── syscall.go ├── syscall_bsd.go ├── syscall_bsd_test.go ├── syscall_darwin.go ├── syscall_darwin_386.go ├── syscall_darwin_amd64.go ├── syscall_darwin_arm.go ├── syscall_darwin_arm64.go ├── syscall_dragonfly.go ├── syscall_dragonfly_amd64.go ├── syscall_freebsd.go ├── syscall_freebsd_386.go ├── syscall_freebsd_amd64.go ├── syscall_freebsd_arm.go ├── syscall_freebsd_test.go ├── syscall_linux.go ├── syscall_linux_386.go ├── syscall_linux_amd64.go ├── syscall_linux_arm.go ├── syscall_linux_arm64.go ├── syscall_linux_mips64x.go ├── syscall_linux_ppc64x.go ├── syscall_linux_s390x.go ├── syscall_linux_test.go ├── syscall_netbsd.go ├── syscall_netbsd_386.go ├── syscall_netbsd_amd64.go ├── syscall_netbsd_arm.go ├── syscall_no_getwd.go ├── syscall_openbsd.go ├── syscall_openbsd_386.go ├── syscall_openbsd_amd64.go ├── syscall_solaris.go ├── syscall_solaris_amd64.go ├── syscall_test.go ├── syscall_unix.go ├── syscall_unix_test.go ├── types_darwin.go ├── types_dragonfly.go ├── types_freebsd.go ├── types_linux.go ├── types_netbsd.go ├── types_openbsd.go ├── types_solaris.go ├── zerrors_darwin_386.go ├── zerrors_darwin_amd64.go ├── zerrors_darwin_arm.go ├── zerrors_darwin_arm64.go ├── zerrors_dragonfly_amd64.go ├── zerrors_freebsd_386.go ├── zerrors_freebsd_amd64.go ├── zerrors_freebsd_arm.go ├── zerrors_linux_386.go ├── zerrors_linux_amd64.go ├── zerrors_linux_arm.go ├── zerrors_linux_arm64.go ├── zerrors_linux_mips64.go ├── zerrors_linux_mips64le.go ├── zerrors_linux_ppc64.go ├── zerrors_linux_ppc64le.go ├── zerrors_linux_s390x.go ├── zerrors_netbsd_386.go ├── zerrors_netbsd_amd64.go ├── zerrors_netbsd_arm.go ├── zerrors_openbsd_386.go ├── zerrors_openbsd_amd64.go ├── zerrors_solaris_amd64.go ├── zsyscall_darwin_386.go ├── zsyscall_darwin_amd64.go ├── zsyscall_darwin_arm.go ├── zsyscall_darwin_arm64.go ├── zsyscall_dragonfly_amd64.go ├── zsyscall_freebsd_386.go ├── zsyscall_freebsd_amd64.go ├── zsyscall_freebsd_arm.go ├── zsyscall_linux_386.go ├── zsyscall_linux_amd64.go ├── zsyscall_linux_arm.go ├── zsyscall_linux_arm64.go ├── zsyscall_linux_mips64.go ├── zsyscall_linux_mips64le.go ├── zsyscall_linux_ppc64.go ├── zsyscall_linux_ppc64le.go ├── zsyscall_linux_s390x.go ├── zsyscall_netbsd_386.go ├── zsyscall_netbsd_amd64.go ├── zsyscall_netbsd_arm.go ├── zsyscall_openbsd_386.go ├── zsyscall_openbsd_amd64.go ├── zsyscall_solaris_amd64.go ├── zsysctl_openbsd.go ├── zsysnum_darwin_386.go ├── zsysnum_darwin_amd64.go ├── zsysnum_darwin_arm.go ├── zsysnum_darwin_arm64.go ├── zsysnum_dragonfly_amd64.go ├── zsysnum_freebsd_386.go ├── zsysnum_freebsd_amd64.go ├── zsysnum_freebsd_arm.go ├── zsysnum_linux_386.go ├── zsysnum_linux_amd64.go ├── zsysnum_linux_arm.go ├── zsysnum_linux_arm64.go ├── zsysnum_linux_mips64.go ├── zsysnum_linux_mips64le.go ├── zsysnum_linux_ppc64.go ├── zsysnum_linux_ppc64le.go ├── zsysnum_linux_s390x.go ├── zsysnum_netbsd_386.go ├── zsysnum_netbsd_amd64.go ├── zsysnum_netbsd_arm.go ├── zsysnum_openbsd_386.go ├── zsysnum_openbsd_amd64.go ├── zsysnum_solaris_amd64.go ├── ztypes_darwin_386.go ├── ztypes_darwin_amd64.go ├── ztypes_darwin_arm.go ├── ztypes_darwin_arm64.go ├── ztypes_dragonfly_amd64.go ├── ztypes_freebsd_386.go ├── ztypes_freebsd_amd64.go ├── ztypes_freebsd_arm.go ├── ztypes_linux_386.go ├── ztypes_linux_amd64.go ├── ztypes_linux_arm.go ├── ztypes_linux_arm64.go ├── ztypes_linux_mips64.go ├── ztypes_linux_mips64le.go ├── ztypes_linux_ppc64.go ├── ztypes_linux_ppc64le.go ├── ztypes_linux_s390x.go ├── ztypes_netbsd_386.go ├── ztypes_netbsd_amd64.go ├── ztypes_netbsd_arm.go ├── ztypes_openbsd_386.go ├── ztypes_openbsd_amd64.go └── ztypes_solaris_amd64.go └── windows ├── asm_windows_386.s ├── asm_windows_amd64.s ├── dll_windows.go ├── env_unset.go ├── env_windows.go ├── eventlog.go ├── exec_windows.go ├── mksyscall.go ├── race.go ├── race0.go ├── registry ├── export_test.go ├── key.go ├── mksyscall.go ├── registry_test.go ├── syscall.go ├── value.go └── zsyscall_windows.go ├── security_windows.go ├── service.go ├── str.go ├── svc ├── debug │ ├── log.go │ └── service.go ├── event.go ├── eventlog │ ├── install.go │ ├── log.go │ └── log_test.go ├── example │ ├── beep.go │ ├── install.go │ ├── main.go │ ├── manage.go │ └── service.go ├── go12.c ├── go12.go ├── go13.go ├── mgr │ ├── config.go │ ├── mgr.go │ ├── mgr_test.go │ └── service.go ├── security.go ├── service.go ├── svc_test.go ├── sys_386.s └── sys_amd64.s ├── syscall.go ├── syscall_test.go ├── syscall_windows.go ├── syscall_windows_test.go ├── zsyscall_windows.go ├── ztypes_windows.go ├── ztypes_windows_386.go └── ztypes_windows_amd64.go /.gitignore: -------------------------------------------------------------------------------- 1 | pam_hook 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | services: 3 | - docker 4 | script: 5 | - make test 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stretch 2 | ADD pam_hook /usr/bin/pam_hook 3 | RUN apt-get update && \ 4 | env DEBIAN_FRONTEND=noninteractive \ 5 | apt-get install -y libpam0g:amd64 libpam0g-dev:amd64 6 | -------------------------------------------------------------------------------- /Dockerfile_build: -------------------------------------------------------------------------------- 1 | FROM debian:stretch 2 | RUN apt-get update && \ 3 | apt-get install -y libpam0g:amd64 git\ 4 | libpam0g-dev:amd64 wget tar build-essential && \ 5 | rm -rf /var/lib/apt/lists/* && \ 6 | wget https://storage.googleapis.com/golang/go1.12.4.linux-amd64.tar.gz && \ 7 | tar -C /usr/local -xzf go1.12.4.linux-amd64.tar.gz && \ 8 | rm -f go1.12.4.linux-amd64.tar.gz && \ 9 | ln -sf /usr/local/go/bin/go /usr/bin/go && \ 10 | go get -u honnef.co/go/tools/cmd/... 11 | ENV PATH=/root/go/bin:$PATH 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Ayodele Abejide 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TAG = bjhaid/pam_hook:0.4.2 2 | 3 | build: 4 | docker build -t pam_hook -f Dockerfile_build . 5 | docker run -v $(PWD):/usr/local/go/src/github.com/bjhaid/pam_hook \ 6 | --rm pam_hook \ 7 | /bin/bash -c "cd /usr/local/go/src/github.com/bjhaid/pam_hook && go build" 8 | docker build --tag $(TAG) . 9 | 10 | shell: 11 | docker run -it -v $(PWD):/usr/local/go/src/github.com/bjhaid/pam_hook \ 12 | --rm pam_hook bash 13 | 14 | test: build 15 | docker run -v $(PWD):/usr/local/go/src/github.com/bjhaid/pam_hook \ 16 | --rm pam_hook \ 17 | /bin/bash -c "cd /usr/local/go/src/github.com/bjhaid/pam_hook && staticcheck github.com/bjhaid/pam_hook && go test" 18 | 19 | push: test 20 | docker push $(TAG) 21 | 22 | all: push 23 | -------------------------------------------------------------------------------- /glide.lock: -------------------------------------------------------------------------------- 1 | hash: ba680fd166def8c4bad4bc347e9ccd91035365a950a926da3225e4df88cc34f5 2 | updated: 2017-11-13T16:06:31.132275306Z 3 | imports: 4 | - name: github.com/golang/glog 5 | version: 23def4e6c14b4da8ac2ed8007337bc5eb5007998 6 | - name: github.com/msteinert/pam 7 | version: f4cd9f5e29232537a12db1678f48c702ad6896b7 8 | - name: github.com/SermoDigital/jose 9 | version: 2bd9b81ac51d6d6134fcd4fd846bd2e7347a15f9 10 | subpackages: 11 | - crypto 12 | - jws 13 | - jwt 14 | - name: golang.org/x/sys 15 | version: 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9 16 | subpackages: 17 | - unix 18 | testImports: [] 19 | -------------------------------------------------------------------------------- /glide.yaml: -------------------------------------------------------------------------------- 1 | package: github.com/bjhaid/pam_auth 2 | import: 3 | - package: golang.org/x/sys 4 | subpackages: 5 | - unix 6 | - package: github.com/golang/glog 7 | -------------------------------------------------------------------------------- /pamhook_cert.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC4TCCAcmgAwIBAgIJANdD24XeYEJ6MA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNV 3 | BAMTCWxvY2FsaG9zdDAeFw0xNzA2MTIwMTEwNTFaFw0xODA2MTIwMTEwNTFaMBQx 4 | EjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC 5 | ggEBAKPmJ0mRgKA+pEM4mwHEFy7FZ4w7Xepw5Hd29NaLmaH8yMc3ugRGz10fzCFq 6 | 1dTArlkxczd6S2T/yR11cbHTGtxNfr9pvHHBvNZLN8jY6k1g+uZ3ryxD3er1VCft 7 | dCZ7wgU8l1pEtmrcxlSEzwN/3YSJ5J8zYaetJvlf1qh1at6XStVtz/6sorrOebC+ 8 | LkxDeGJ4h9RKY2rZFghmw2SaGzS46EiLoS/Xm7aM4JG/MtYeC3JeMGR5M/geqN+K 9 | 20NIxil7bXn195ZTmlBVaxXY71D1d/FyDOkFMRphgoy6uUdBLTbELhZpMpzthsju 10 | 600yfo9pQIcq3IyrUsvjEzec5GkCAwEAAaM2MDQwMgYDVR0RBCswKYIJbG9jYWxo 11 | b3N0gg93d3cucGFtaG9vay5jb22CC3BhbWhvb2suY29tMA0GCSqGSIb3DQEBCwUA 12 | A4IBAQAZcvIQcBM/U6YogqO0+u4i3gwabsHbzLX7jhZuSiWh7x41z+rp8ZUjidqB 13 | EFdn3AJfUzif4BtcjoAghx8nwPzczrub0nUayTqZwb2nRNpucHGnQpPS1R0LIkX5 14 | dQvJMevsXeltMqxUiXdhdUDuoVqpW1wmfeueiziYnp7OXdptRKyyPERDo4noHT28 15 | XsFcpoaO8rEs7sXlwzIoDXpzfb4KHRDhfxLqRN+lqMOcngnGkQVr3stSC4aKpM+s 16 | tPvsIgVL2XqB5hak92XWVPUHqSOvbLrwGb1O0A4LmIk/WanNSd6eSRWJN/y299U5 17 | J4YKZrqRRvgrMCm02Sk+JChDTUmm 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /pamhook_key.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCj5idJkYCgPqRD 3 | OJsBxBcuxWeMO13qcOR3dvTWi5mh/MjHN7oERs9dH8whatXUwK5ZMXM3ektk/8kd 4 | dXGx0xrcTX6/abxxwbzWSzfI2OpNYPrmd68sQ93q9VQn7XQme8IFPJdaRLZq3MZU 5 | hM8Df92EieSfM2GnrSb5X9aodWrel0rVbc/+rKK6znmwvi5MQ3hieIfUSmNq2RYI 6 | ZsNkmhs0uOhIi6Ev15u2jOCRvzLWHgtyXjBkeTP4HqjfittDSMYpe2159feWU5pQ 7 | VWsV2O9Q9XfxcgzpBTEaYYKMurlHQS02xC4WaTKc7YbI7utNMn6PaUCHKtyMq1LL 8 | 4xM3nORpAgMBAAECggEAAuVgMFaX1T0GHgH0CzXxyuvGBp5N7ISOJOY/MUNKNaiH 9 | y61aZhTyOQ0EyFpg6N92tTDAfmx0xJYYcaLPnXrDcL0VzkAKCmCH+6lclPnwOenK 10 | xSO8PqX8V9h54jK56KwrI3iMnBW2u3CnOHsYRVGPEnZ1SbLYuOPAWous+VEJ0GEI 11 | vIdWy1w0Iz8lcs/qKq5skZIYmWVFnZnWqcQHo2EeWwuXJoxAutfLGuI7O095ckGn 12 | dlv2gFGfAHw7DKzyQ6er9PLrEB1RhgtS6dnYmgITD+ZVfaEBRPXCDLbiuf4tz90B 13 | Dng3t+c7O1cyAkOYsaLny9AH7OfD2t9DpLwP3wvo+QKBgQDWFwc8RxfdYZQ8pW4v 14 | Jpj7hAC0G8qoD0P53YveGSZUA2jc9M0HtTo4A0gb9egOYLwyTIhfpSSHAc83NJ/V 15 | HFxcxTfLS0SpsuJQDfvI1fOlxL88nqwTpATZIMtWopO9b1+hmCX95vo0P9oMyJw2 16 | X9ocjxzKraaLRwyd+WfjvV743wKBgQDD+9d5CLbtQ0dZWbZbbEcr9U//Kbc32UV3 17 | VgggOuz7xXEpXLggiDSdB2wX1Smn1Yabr+kUVTCR985xBnE6MRtdUQ8EHAnQBNui 18 | bYMYVWlARLfp+jxE4i04CUwD7X0+mOqghD/4ct8L8YqOdZPukzynQjdLo6TeLJzS 19 | 41kBsR2jtwKBgQDBrs+y7rZeZ9sOCrPmIEsisEdaqhHrfPQIZzAUXDhapUMHMskS 20 | ghgLeJyR/yRTbZyU/Lwbm3GyWia3UPqQeDnvC9TwLEYQKG+p8RyqkzT78UT5eKtA 21 | kZB5RrvuwuJZ7RpdPSKR05bkEigYjJ0WbB0M3UQ08GjNdBesC2i7liUHjQKBgQCQ 22 | mKH8ocpdOZNNwBwETdog+6hfCYcthHd1OZtbND6e76izLL6I+hVfehdtag+Gzcq3 23 | 2UztfIEOYTgGOguWNJ8M9X5PuOQgf0URDR14+aNjEJBk6ARJilp0ip90EmeipK4P 24 | aiPMiew44qgovWU805MfkII9o2pDpcS675Q+5E+K9wKBgQDPBLnNwslbWrpYBgkY 25 | bq2G1QNkyFeqCdZCnNuESrLgb2Nc3w/ld2EtQ//iI9wRxFHbf3WgdjvcXffKysDn 26 | RmhIcgW86bsDiuJAsZRr8ZMYy+NOcAAJIePlvWLyaz2VZMyNlK3Z3VyAlneru7J1 27 | KUdx5FYyKjIYVr3ypqKorkOPAw== 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | 26 | *.out 27 | *.tmp 28 | tags 29 | 30 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.6 5 | - 1.7 6 | - tip 7 | 8 | sudo: false 9 | 10 | install: 11 | - go get -u github.com/golang/lint/golint 12 | 13 | script: 14 | - ./_test.sh 15 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Sermo Digital LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/README.md: -------------------------------------------------------------------------------- 1 | JOSE 2 | ============ 3 | [![Build Status](https://travis-ci.org/SermoDigital/jose.svg?branch=master)](https://travis-ci.org/SermoDigital/jose) 4 | [![GoDoc](https://godoc.org/github.com/SermoDigital/jose?status.svg)](https://godoc.org/github.com/SermoDigital/jose) 5 | 6 | JOSE is a comprehensive set of JWT, JWS, and JWE libraries. 7 | 8 | ## Why 9 | 10 | The only other JWS/JWE/JWT implementations are specific to JWT, and none 11 | were particularly pleasant to work with. 12 | 13 | These libraries should provide an easy, straightforward way to securely 14 | create, parse, and validate JWS, JWE, and JWTs. 15 | 16 | ## Notes: 17 | JWE is currently unimplemented. 18 | 19 | ## Version 0.9: 20 | 21 | ## Documentation 22 | 23 | The docs can be found at [godoc.org] [docs], as usual. 24 | 25 | A gopkg.in mirror can be found at https://gopkg.in/jose.v1, thanks to 26 | @zia-newversion. (For context, see issue #30.) 27 | 28 | ### [JWS RFC][jws] 29 | ### [JWE RFC][jwe] 30 | ### [JWT RFC][jwt] 31 | 32 | ## License 33 | 34 | [MIT] [license]. 35 | 36 | [docs]: https://godoc.org/github.com/SermoDigital/jose 37 | [license]: https://github.com/SermoDigital/jose/blob/master/LICENSE.md 38 | [jws]: https://tools.ietf.org/html/rfc7515 39 | [jwe]: https://tools.ietf.org/html/rfc7516 40 | [jwt]: https://tools.ietf.org/html/rfc7519 41 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | go build ./... 6 | go test ./... 7 | golint ./... 8 | go vet ./... -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/base64.go: -------------------------------------------------------------------------------- 1 | package jose 2 | 3 | import "encoding/base64" 4 | 5 | // Encoder is satisfied if the type can marshal itself into a valid 6 | // structure for a JWS. 7 | type Encoder interface { 8 | // Base64 implies T -> JSON -> RawURLEncodingBase64 9 | Base64() ([]byte, error) 10 | } 11 | 12 | // Base64Decode decodes a base64-encoded byte slice. 13 | func Base64Decode(b []byte) ([]byte, error) { 14 | buf := make([]byte, base64.RawURLEncoding.DecodedLen(len(b))) 15 | n, err := base64.RawURLEncoding.Decode(buf, b) 16 | return buf[:n], err 17 | } 18 | 19 | // Base64Encode encodes a byte slice. 20 | func Base64Encode(b []byte) []byte { 21 | buf := make([]byte, base64.RawURLEncoding.EncodedLen(len(b))) 22 | base64.RawURLEncoding.Encode(buf, b) 23 | return buf 24 | } 25 | 26 | // EncodeEscape base64-encodes a byte slice but escapes it for JSON. 27 | // It'll return the format: `"base64"` 28 | func EncodeEscape(b []byte) []byte { 29 | buf := make([]byte, base64.RawURLEncoding.EncodedLen(len(b))+2) 30 | buf[0] = '"' 31 | base64.RawURLEncoding.Encode(buf[1:], b) 32 | buf[len(buf)-1] = '"' 33 | return buf 34 | } 35 | 36 | // DecodeEscaped decodes a base64-encoded byte slice straight from a JSON 37 | // structure. It assumes it's in the format: `"base64"`, but can handle 38 | // cases where it's not. 39 | func DecodeEscaped(b []byte) ([]byte, error) { 40 | if len(b) > 1 && b[0] == '"' && b[len(b)-1] == '"' { 41 | b = b[1 : len(b)-1] 42 | } 43 | return Base64Decode(b) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/base64_test.go: -------------------------------------------------------------------------------- 1 | package jose 2 | 3 | import ( 4 | "bytes" 5 | "testing" 6 | ) 7 | 8 | func TestBase64(t *testing.T) { 9 | encoded := []byte("SGVsbG8sIHBsYXlncm91bmQ") 10 | raw := []byte("Hello, playground") 11 | 12 | testEnc := Base64Encode(raw) 13 | if !bytes.Equal(testEnc, encoded) { 14 | Error(t, encoded, testEnc) 15 | } 16 | 17 | testDec, err := Base64Decode(testEnc) 18 | if err != nil { 19 | t.Error(err) 20 | } 21 | 22 | if !bytes.Equal(testDec, raw) { 23 | Error(t, raw, testDec) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/doc.go: -------------------------------------------------------------------------------- 1 | // Package crypto implements "SigningMethods" and "EncryptionMethods"; 2 | // that is, ways to sign and encrypt JWS and JWEs, respectively, as well 3 | // as JWTs. 4 | package crypto 5 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/ecdsa_utils.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "crypto/ecdsa" 5 | "crypto/x509" 6 | "encoding/pem" 7 | "errors" 8 | ) 9 | 10 | // ECDSA parsing errors. 11 | var ( 12 | ErrNotECPublicKey = errors.New("Key is not a valid ECDSA public key") 13 | ErrNotECPrivateKey = errors.New("Key is not a valid ECDSA private key") 14 | ) 15 | 16 | // ParseECPrivateKeyFromPEM will parse a PEM encoded EC Private 17 | // Key Structure. 18 | func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) { 19 | block, _ := pem.Decode(key) 20 | if block == nil { 21 | return nil, ErrKeyMustBePEMEncoded 22 | } 23 | return x509.ParseECPrivateKey(block.Bytes) 24 | } 25 | 26 | // ParseECPublicKeyFromPEM will parse a PEM encoded PKCS1 or PKCS8 public key 27 | func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) { 28 | 29 | block, _ := pem.Decode(key) 30 | if block == nil { 31 | return nil, ErrKeyMustBePEMEncoded 32 | } 33 | 34 | parsedKey, err := x509.ParsePKIXPublicKey(block.Bytes) 35 | if err != nil { 36 | cert, err := x509.ParseCertificate(block.Bytes) 37 | if err != nil { 38 | return nil, err 39 | } 40 | parsedKey = cert.PublicKey 41 | } 42 | 43 | pkey, ok := parsedKey.(*ecdsa.PublicKey) 44 | if !ok { 45 | return nil, ErrNotECPublicKey 46 | } 47 | return pkey, nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/errors.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import "errors" 4 | 5 | var ( 6 | // ErrInvalidKey means the key argument passed to SigningMethod.Verify 7 | // was not the correct type. 8 | ErrInvalidKey = errors.New("key is invalid") 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/hmac.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "crypto" 5 | "crypto/hmac" 6 | "encoding/json" 7 | "errors" 8 | ) 9 | 10 | // SigningMethodHMAC implements the HMAC-SHA family of SigningMethods. 11 | type SigningMethodHMAC struct { 12 | Name string 13 | Hash crypto.Hash 14 | _ struct{} 15 | } 16 | 17 | // Specific instances of HMAC-SHA SigningMethods. 18 | var ( 19 | // SigningMethodHS256 implements HS256. 20 | SigningMethodHS256 = &SigningMethodHMAC{ 21 | Name: "HS256", 22 | Hash: crypto.SHA256, 23 | } 24 | 25 | // SigningMethodHS384 implements HS384. 26 | SigningMethodHS384 = &SigningMethodHMAC{ 27 | Name: "HS384", 28 | Hash: crypto.SHA384, 29 | } 30 | 31 | // SigningMethodHS512 implements HS512. 32 | SigningMethodHS512 = &SigningMethodHMAC{ 33 | Name: "HS512", 34 | Hash: crypto.SHA512, 35 | } 36 | 37 | // ErrSignatureInvalid is returned when the provided signature is found 38 | // to be invalid. 39 | ErrSignatureInvalid = errors.New("signature is invalid") 40 | ) 41 | 42 | // Alg implements the SigningMethod interface. 43 | func (m *SigningMethodHMAC) Alg() string { return m.Name } 44 | 45 | // Verify implements the Verify method from SigningMethod. 46 | // For this signing method, must be a []byte. 47 | func (m *SigningMethodHMAC) Verify(raw []byte, signature Signature, key interface{}) error { 48 | keyBytes, ok := key.([]byte) 49 | if !ok { 50 | return ErrInvalidKey 51 | } 52 | hasher := hmac.New(m.Hash.New, keyBytes) 53 | hasher.Write(raw) 54 | if hmac.Equal(signature, hasher.Sum(nil)) { 55 | return nil 56 | } 57 | return ErrSignatureInvalid 58 | } 59 | 60 | // Sign implements the Sign method from SigningMethod for this signing method. 61 | // Key must be a []byte. 62 | func (m *SigningMethodHMAC) Sign(data []byte, key interface{}) (Signature, error) { 63 | keyBytes, ok := key.([]byte) 64 | if !ok { 65 | return nil, ErrInvalidKey 66 | } 67 | hasher := hmac.New(m.Hash.New, keyBytes) 68 | hasher.Write(data) 69 | return Signature(hasher.Sum(nil)), nil 70 | } 71 | 72 | // Hasher implements the SigningMethod interface. 73 | func (m *SigningMethodHMAC) Hasher() crypto.Hash { return m.Hash } 74 | 75 | // MarshalJSON implements json.Marshaler. 76 | // See SigningMethodECDSA.MarshalJSON() for information. 77 | func (m *SigningMethodHMAC) MarshalJSON() ([]byte, error) { 78 | return []byte(`"` + m.Alg() + `"`), nil 79 | } 80 | 81 | var _ json.Marshaler = (*SigningMethodHMAC)(nil) 82 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/none.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "crypto" 5 | "encoding/json" 6 | "hash" 7 | "io" 8 | ) 9 | 10 | func init() { 11 | crypto.RegisterHash(crypto.Hash(0), h) 12 | } 13 | 14 | // h is passed to crypto.RegisterHash. 15 | func h() hash.Hash { 16 | return &f{Writer: nil} 17 | } 18 | 19 | type f struct{ io.Writer } 20 | 21 | // Sum helps implement the hash.Hash interface. 22 | func (_ *f) Sum(b []byte) []byte { return nil } 23 | 24 | // Reset helps implement the hash.Hash interface. 25 | func (_ *f) Reset() {} 26 | 27 | // Size helps implement the hash.Hash interface. 28 | func (_ *f) Size() int { return -1 } 29 | 30 | // BlockSize helps implement the hash.Hash interface. 31 | func (_ *f) BlockSize() int { return -1 } 32 | 33 | // Unsecured is the default "none" algorithm. 34 | var Unsecured = &SigningMethodNone{ 35 | Name: "none", 36 | Hash: crypto.Hash(0), 37 | } 38 | 39 | // SigningMethodNone is the default "none" algorithm. 40 | type SigningMethodNone struct { 41 | Name string 42 | Hash crypto.Hash 43 | _ struct{} 44 | } 45 | 46 | // Verify helps implement the SigningMethod interface. 47 | func (_ *SigningMethodNone) Verify(_ []byte, _ Signature, _ interface{}) error { 48 | return nil 49 | } 50 | 51 | // Sign helps implement the SigningMethod interface. 52 | func (_ *SigningMethodNone) Sign(_ []byte, _ interface{}) (Signature, error) { 53 | return nil, nil 54 | } 55 | 56 | // Alg helps implement the SigningMethod interface. 57 | func (m *SigningMethodNone) Alg() string { 58 | return m.Name 59 | } 60 | 61 | // Hasher helps implement the SigningMethod interface. 62 | func (m *SigningMethodNone) Hasher() crypto.Hash { 63 | return m.Hash 64 | } 65 | 66 | // MarshalJSON implements json.Marshaler. 67 | // See SigningMethodECDSA.MarshalJSON() for information. 68 | func (m *SigningMethodNone) MarshalJSON() ([]byte, error) { 69 | return []byte(`"` + m.Alg() + `"`), nil 70 | } 71 | 72 | var _ json.Marshaler = (*SigningMethodNone)(nil) 73 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/rsa.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "crypto" 5 | "crypto/rand" 6 | "crypto/rsa" 7 | "encoding/json" 8 | ) 9 | 10 | // SigningMethodRSA implements the RSA family of SigningMethods. 11 | type SigningMethodRSA struct { 12 | Name string 13 | Hash crypto.Hash 14 | _ struct{} 15 | } 16 | 17 | // Specific instances of RSA SigningMethods. 18 | var ( 19 | // SigningMethodRS256 implements RS256. 20 | SigningMethodRS256 = &SigningMethodRSA{ 21 | Name: "RS256", 22 | Hash: crypto.SHA256, 23 | } 24 | 25 | // SigningMethodRS384 implements RS384. 26 | SigningMethodRS384 = &SigningMethodRSA{ 27 | Name: "RS384", 28 | Hash: crypto.SHA384, 29 | } 30 | 31 | // SigningMethodRS512 implements RS512. 32 | SigningMethodRS512 = &SigningMethodRSA{ 33 | Name: "RS512", 34 | Hash: crypto.SHA512, 35 | } 36 | ) 37 | 38 | // Alg implements the SigningMethod interface. 39 | func (m *SigningMethodRSA) Alg() string { return m.Name } 40 | 41 | // Verify implements the Verify method from SigningMethod. 42 | // For this signing method, must be an *rsa.PublicKey. 43 | func (m *SigningMethodRSA) Verify(raw []byte, sig Signature, key interface{}) error { 44 | rsaKey, ok := key.(*rsa.PublicKey) 45 | if !ok { 46 | return ErrInvalidKey 47 | } 48 | return rsa.VerifyPKCS1v15(rsaKey, m.Hash, m.sum(raw), sig) 49 | } 50 | 51 | // Sign implements the Sign method from SigningMethod. 52 | // For this signing method, must be an *rsa.PrivateKey structure. 53 | func (m *SigningMethodRSA) Sign(data []byte, key interface{}) (Signature, error) { 54 | rsaKey, ok := key.(*rsa.PrivateKey) 55 | if !ok { 56 | return nil, ErrInvalidKey 57 | } 58 | sigBytes, err := rsa.SignPKCS1v15(rand.Reader, rsaKey, m.Hash, m.sum(data)) 59 | if err != nil { 60 | return nil, err 61 | } 62 | return Signature(sigBytes), nil 63 | } 64 | 65 | func (m *SigningMethodRSA) sum(b []byte) []byte { 66 | h := m.Hash.New() 67 | h.Write(b) 68 | return h.Sum(nil) 69 | } 70 | 71 | // Hasher implements the SigningMethod interface. 72 | func (m *SigningMethodRSA) Hasher() crypto.Hash { return m.Hash } 73 | 74 | // MarshalJSON implements json.Marshaler. 75 | // See SigningMethodECDSA.MarshalJSON() for information. 76 | func (m *SigningMethodRSA) MarshalJSON() ([]byte, error) { 77 | return []byte(`"` + m.Alg() + `"`), nil 78 | } 79 | 80 | var _ json.Marshaler = (*SigningMethodRSA)(nil) 81 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/rsa_pss.go: -------------------------------------------------------------------------------- 1 | // +build go1.4 2 | 3 | package crypto 4 | 5 | import ( 6 | "crypto" 7 | "crypto/rand" 8 | "crypto/rsa" 9 | "encoding/json" 10 | ) 11 | 12 | // SigningMethodRSAPSS implements the RSAPSS family of SigningMethods. 13 | type SigningMethodRSAPSS struct { 14 | *SigningMethodRSA 15 | Options *rsa.PSSOptions 16 | } 17 | 18 | // Specific instances for RS/PS SigningMethods. 19 | var ( 20 | // SigningMethodPS256 implements PS256. 21 | SigningMethodPS256 = &SigningMethodRSAPSS{ 22 | &SigningMethodRSA{ 23 | Name: "PS256", 24 | Hash: crypto.SHA256, 25 | }, 26 | &rsa.PSSOptions{ 27 | SaltLength: rsa.PSSSaltLengthAuto, 28 | Hash: crypto.SHA256, 29 | }, 30 | } 31 | 32 | // SigningMethodPS384 implements PS384. 33 | SigningMethodPS384 = &SigningMethodRSAPSS{ 34 | &SigningMethodRSA{ 35 | Name: "PS384", 36 | Hash: crypto.SHA384, 37 | }, 38 | &rsa.PSSOptions{ 39 | SaltLength: rsa.PSSSaltLengthAuto, 40 | Hash: crypto.SHA384, 41 | }, 42 | } 43 | 44 | // SigningMethodPS512 implements PS512. 45 | SigningMethodPS512 = &SigningMethodRSAPSS{ 46 | &SigningMethodRSA{ 47 | Name: "PS512", 48 | Hash: crypto.SHA512, 49 | }, 50 | &rsa.PSSOptions{ 51 | SaltLength: rsa.PSSSaltLengthAuto, 52 | Hash: crypto.SHA512, 53 | }, 54 | } 55 | ) 56 | 57 | // Verify implements the Verify method from SigningMethod. 58 | // For this verify method, key must be an *rsa.PublicKey. 59 | func (m *SigningMethodRSAPSS) Verify(raw []byte, signature Signature, key interface{}) error { 60 | rsaKey, ok := key.(*rsa.PublicKey) 61 | if !ok { 62 | return ErrInvalidKey 63 | } 64 | return rsa.VerifyPSS(rsaKey, m.Hash, m.sum(raw), signature, m.Options) 65 | } 66 | 67 | // Sign implements the Sign method from SigningMethod. 68 | // For this signing method, key must be an *rsa.PrivateKey. 69 | func (m *SigningMethodRSAPSS) Sign(raw []byte, key interface{}) (Signature, error) { 70 | rsaKey, ok := key.(*rsa.PrivateKey) 71 | if !ok { 72 | return nil, ErrInvalidKey 73 | } 74 | sigBytes, err := rsa.SignPSS(rand.Reader, rsaKey, m.Hash, m.sum(raw), m.Options) 75 | if err != nil { 76 | return nil, err 77 | } 78 | return Signature(sigBytes), nil 79 | } 80 | 81 | func (m *SigningMethodRSAPSS) sum(b []byte) []byte { 82 | h := m.Hash.New() 83 | h.Write(b) 84 | return h.Sum(nil) 85 | } 86 | 87 | // Hasher implements the Hasher method from SigningMethod. 88 | func (m *SigningMethodRSAPSS) Hasher() crypto.Hash { return m.Hash } 89 | 90 | // MarshalJSON implements json.Marshaler. 91 | // See SigningMethodECDSA.MarshalJSON() for information. 92 | func (m *SigningMethodRSAPSS) MarshalJSON() ([]byte, error) { 93 | return []byte(`"` + m.Alg() + `"`), nil 94 | } 95 | 96 | var _ json.Marshaler = (*SigningMethodRSAPSS)(nil) 97 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/rsa_utils.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "crypto/rsa" 5 | "crypto/x509" 6 | "encoding/pem" 7 | "errors" 8 | ) 9 | 10 | // Errors specific to rsa_utils. 11 | var ( 12 | ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be PEM encoded PKCS1 or PKCS8 private key") 13 | ErrNotRSAPrivateKey = errors.New("key is not a valid RSA private key") 14 | ErrNotRSAPublicKey = errors.New("key is not a valid RSA public key") 15 | ) 16 | 17 | // ParseRSAPrivateKeyFromPEM parses a PEM encoded PKCS1 or PKCS8 private key. 18 | func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) { 19 | var err error 20 | 21 | // Parse PEM block 22 | var block *pem.Block 23 | if block, _ = pem.Decode(key); block == nil { 24 | return nil, ErrKeyMustBePEMEncoded 25 | } 26 | 27 | var parsedKey interface{} 28 | if parsedKey, err = x509.ParsePKCS1PrivateKey(block.Bytes); err != nil { 29 | if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { 30 | return nil, err 31 | } 32 | } 33 | 34 | var pkey *rsa.PrivateKey 35 | var ok bool 36 | if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok { 37 | return nil, ErrNotRSAPrivateKey 38 | } 39 | 40 | return pkey, nil 41 | } 42 | 43 | // ParseRSAPublicKeyFromPEM parses PEM encoded PKCS1 or PKCS8 public key. 44 | func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) { 45 | var err error 46 | 47 | // Parse PEM block 48 | var block *pem.Block 49 | if block, _ = pem.Decode(key); block == nil { 50 | return nil, ErrKeyMustBePEMEncoded 51 | } 52 | 53 | // Parse the key 54 | var parsedKey interface{} 55 | if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { 56 | if cert, err := x509.ParseCertificate(block.Bytes); err == nil { 57 | parsedKey = cert.PublicKey 58 | } else { 59 | return nil, err 60 | } 61 | } 62 | 63 | var pkey *rsa.PublicKey 64 | var ok bool 65 | if pkey, ok = parsedKey.(*rsa.PublicKey); !ok { 66 | return nil, ErrNotRSAPublicKey 67 | } 68 | 69 | return pkey, nil 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/signature.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/SermoDigital/jose" 7 | ) 8 | 9 | // Signature is a JWS signature. 10 | type Signature []byte 11 | 12 | // MarshalJSON implements json.Marshaler for a signature. 13 | func (s Signature) MarshalJSON() ([]byte, error) { 14 | return jose.EncodeEscape(s), nil 15 | } 16 | 17 | // Base64 helps implements jose.Encoder for Signature. 18 | func (s Signature) Base64() ([]byte, error) { 19 | return jose.Base64Encode(s), nil 20 | } 21 | 22 | // UnmarshalJSON implements json.Unmarshaler for signature. 23 | func (s *Signature) UnmarshalJSON(b []byte) error { 24 | dec, err := jose.DecodeEscaped(b) 25 | if err != nil { 26 | return err 27 | } 28 | *s = Signature(dec) 29 | return nil 30 | } 31 | 32 | var ( 33 | _ json.Marshaler = (Signature)(nil) 34 | _ json.Unmarshaler = (*Signature)(nil) 35 | _ jose.Encoder = (Signature)(nil) 36 | ) 37 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/signature_test.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "testing" 7 | ) 8 | 9 | func TestMarshalSignature(t *testing.T) { 10 | s := Signature("Test string!") 11 | 12 | enc, err := json.Marshal(s) 13 | if err != nil { 14 | t.Error(err) 15 | } 16 | 17 | var ss Signature 18 | if err = json.Unmarshal(enc, &ss); err != nil { 19 | t.Error(err) 20 | } 21 | 22 | if !bytes.Equal(ss, s) { 23 | Error(t, s, ss) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/signing_method.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import "crypto" 4 | 5 | // SigningMethod is an interface that provides a way to sign JWS tokens. 6 | type SigningMethod interface { 7 | // Alg describes the signing algorithm, and is used to uniquely 8 | // describe the specific crypto.SigningMethod. 9 | Alg() string 10 | 11 | // Verify accepts the raw content, the signature, and the key used 12 | // to sign the raw content, and returns any errors found while validating 13 | // the signature and content. 14 | Verify(raw []byte, sig Signature, key interface{}) error 15 | 16 | // Sign returns a Signature for the raw bytes, as well as any errors 17 | // that occurred during the signing. 18 | Sign(raw []byte, key interface{}) (Signature, error) 19 | 20 | // Used to cause quick panics when a crypto.SigningMethod whose form of hashing 21 | // isn't linked in the binary when you register a crypto.SigningMethod. 22 | // To spoof this, see "crypto.SigningMethodNone". 23 | Hasher() crypto.Hash 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/crypto/stubs_test.go: -------------------------------------------------------------------------------- 1 | package crypto 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func Error(t *testing.T, want, got interface{}) { 9 | format := "\nWanted: %s\nGot: %s" 10 | 11 | switch want.(type) { 12 | case []byte, string, nil: 13 | default: 14 | format = fmt.Sprintf(format, "%v", "%v") 15 | } 16 | 17 | t.Errorf(format, want, got) 18 | } 19 | 20 | func ErrorTypes(t *testing.T, want, got interface{}) { 21 | t.Errorf("\nWanted: %T\nGot: %T", want, got) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/doc.go: -------------------------------------------------------------------------------- 1 | // Package jose implements some helper functions and types for the children 2 | // packages, jws, jwt, and jwe. 3 | package jose 4 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/header_test.go: -------------------------------------------------------------------------------- 1 | package jose 2 | 3 | import ( 4 | "encoding/json" 5 | "testing" 6 | ) 7 | 8 | func TestMarshalProtectedHeader(t *testing.T) { 9 | p := Protected{ 10 | "alg": "HM256", 11 | } 12 | 13 | b, err := json.Marshal(p) 14 | if err != nil { 15 | t.Error(err) 16 | } 17 | 18 | var p2 Protected 19 | 20 | if json.Unmarshal(b, &p2); err != nil { 21 | t.Error(err) 22 | } 23 | 24 | if p2["alg"] != p["alg"] { 25 | Error(t, p["alg"], p2["alg"]) 26 | } 27 | } 28 | 29 | func TestMarshalHeader(t *testing.T) { 30 | h := Header{ 31 | "alg": "HM256", 32 | } 33 | 34 | b, err := json.Marshal(h) 35 | if err != nil { 36 | t.Error(err) 37 | } 38 | 39 | var p2 Protected 40 | 41 | if json.Unmarshal(b, &p2); err != nil { 42 | t.Error(err) 43 | } 44 | 45 | if p2["alg"] != h["alg"] { 46 | Error(t, h["alg"], p2["alg"]) 47 | } 48 | } 49 | 50 | func TestBasicHeaderFunctions(t *testing.T) { 51 | var h Header 52 | 53 | if v := h.Get("b"); v != nil { 54 | Error(t, nil, v) 55 | } 56 | 57 | h = Header{} 58 | 59 | h.Set("a", "b") 60 | 61 | if v := h.Get("a"); v != "b" { 62 | Error(t, "a", v) 63 | } 64 | 65 | if !h.Has("a") { 66 | t.Error("h should have `a`") 67 | } 68 | 69 | if v := h.Get("b"); v != nil { 70 | Error(t, nil, v) 71 | } 72 | 73 | h.Del("a") 74 | 75 | if v := h.Get("a"); v != nil { 76 | Error(t, nil, v) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/doc.go: -------------------------------------------------------------------------------- 1 | // Package jws implements JWSs per RFC 7515 2 | package jws 3 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/errors.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import "errors" 4 | 5 | var ( 6 | 7 | // ErrNotEnoughMethods is returned if New was called _or_ the Flat/Compact 8 | // methods were called with 0 SigningMethods. 9 | ErrNotEnoughMethods = errors.New("not enough methods provided") 10 | 11 | // ErrCouldNotUnmarshal is returned when Parse's json.Unmarshaler 12 | // parameter returns an error. 13 | ErrCouldNotUnmarshal = errors.New("custom unmarshal failed") 14 | 15 | // ErrNotCompact signals that the provided potential JWS is not 16 | // in its compact representation. 17 | ErrNotCompact = errors.New("not a compact JWS") 18 | 19 | // ErrDuplicateHeaderParameter signals that there are duplicate parameters 20 | // in the provided Headers. 21 | ErrDuplicateHeaderParameter = errors.New("duplicate parameters in the JOSE Header") 22 | 23 | // ErrTwoEmptyHeaders is returned if both Headers are empty. 24 | ErrTwoEmptyHeaders = errors.New("both headers cannot be empty") 25 | 26 | // ErrNotEnoughKeys is returned when not enough keys are provided for 27 | // the given SigningMethods. 28 | ErrNotEnoughKeys = errors.New("not enough keys (for given methods)") 29 | 30 | // ErrDidNotValidate means the given JWT did not properly validate 31 | ErrDidNotValidate = errors.New("did not validate") 32 | 33 | // ErrNoAlgorithm means no algorithm ("alg") was found in the Protected 34 | // Header. 35 | ErrNoAlgorithm = errors.New("no algorithm found") 36 | 37 | // ErrAlgorithmDoesntExist means the algorithm asked for cannot be 38 | // found inside the signingMethod cache. 39 | ErrAlgorithmDoesntExist = errors.New("algorithm doesn't exist") 40 | 41 | // ErrMismatchedAlgorithms means the algorithm inside the JWT was 42 | // different than the algorithm the caller wanted to use. 43 | ErrMismatchedAlgorithms = errors.New("mismatched algorithms") 44 | 45 | // ErrCannotValidate means the JWS cannot be validated for various 46 | // reasons. For example, if there aren't any signatures/payloads/headers 47 | // to actually validate. 48 | ErrCannotValidate = errors.New("cannot validate") 49 | 50 | // ErrIsNotJWT means the given JWS is not a JWT. 51 | ErrIsNotJWT = errors.New("JWS is not a JWT") 52 | 53 | // ErrHoldsJWE means the given JWS holds a JWE inside its payload. 54 | ErrHoldsJWE = errors.New("JWS holds JWE") 55 | 56 | // ErrNotEnoughValidSignatures means the JWS did not meet the required 57 | // number of signatures. 58 | ErrNotEnoughValidSignatures = errors.New("not enough valid signatures in the JWS") 59 | 60 | // ErrNoTokenInRequest means there's no token present inside the *http.Request. 61 | ErrNoTokenInRequest = errors.New("no token present in request") 62 | ) 63 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/jws_serialize_test.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "testing" 7 | 8 | "github.com/SermoDigital/jose" 9 | "github.com/SermoDigital/jose/crypto" 10 | ) 11 | 12 | var dataRaw = struct { 13 | H jose.Protected 14 | Name string 15 | Scopes []string 16 | Admin bool 17 | Data struct{ Foo, Bar int } 18 | }{ 19 | H: jose.Protected{ 20 | "1234": "5678", 21 | }, 22 | Name: "Eric", 23 | Scopes: []string{ 24 | "user.account.info", 25 | "user.account.update", 26 | "user.account.delete", 27 | }, 28 | Admin: true, 29 | Data: struct { 30 | Foo, Bar int 31 | }{ 32 | Foo: 12, 33 | Bar: int(^uint(0) >> 1), 34 | }, 35 | } 36 | 37 | var dataSerialized []byte 38 | 39 | func init() { 40 | var err error 41 | dataSerialized, err = json.Marshal(dataRaw) 42 | if err != nil { 43 | panic(err) 44 | } 45 | } 46 | 47 | func TestGeneralIntegrity(t *testing.T) { 48 | j := New(dataRaw, crypto.SigningMethodRS512) 49 | b, err := j.General(rsaPriv) 50 | if err != nil { 51 | t.Error(err) 52 | } 53 | 54 | var jj struct { 55 | Payload json.RawMessage `json:"payload"` 56 | Signatures []sigHead `json:"signatures"` 57 | } 58 | 59 | if err := json.Unmarshal(b, &jj); err != nil { 60 | t.Error(err) 61 | } 62 | 63 | got, err := jose.DecodeEscaped(jj.Payload) 64 | if err != nil { 65 | t.Error(err) 66 | } 67 | 68 | if !bytes.Equal(got, dataSerialized) { 69 | Error(t, dataSerialized, got) 70 | } 71 | } 72 | 73 | func TestFlatIntegrity(t *testing.T) { 74 | j := New(dataRaw, crypto.SigningMethodRS512) 75 | b, err := j.Flat(rsaPriv) 76 | if err != nil { 77 | t.Error(err) 78 | } 79 | 80 | var jj struct { 81 | Payload json.RawMessage `json:"payload"` 82 | sigHead 83 | } 84 | 85 | if err := json.Unmarshal(b, &jj); err != nil { 86 | t.Error(err) 87 | } 88 | 89 | got, err := jose.DecodeEscaped(jj.Payload) 90 | if err != nil { 91 | t.Error(err) 92 | } 93 | 94 | if !bytes.Equal(got, dataSerialized) { 95 | Error(t, dataSerialized, got) 96 | } 97 | } 98 | 99 | func TestCompactIntegrity(t *testing.T) { 100 | j := New(dataRaw, crypto.SigningMethodRS512) 101 | b, err := j.Compact(rsaPriv) 102 | if err != nil { 103 | t.Error(err) 104 | } 105 | 106 | parts := bytes.Split(b, []byte{'.'}) 107 | 108 | dec, err := jose.Base64Decode(parts[1]) 109 | if err != nil { 110 | t.Error(err) 111 | } 112 | 113 | if !bytes.Equal(dec, dataSerialized) { 114 | Error(t, dec, dataSerialized) 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/jwt.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import ( 4 | "net/http" 5 | "time" 6 | 7 | "github.com/SermoDigital/jose" 8 | "github.com/SermoDigital/jose/crypto" 9 | "github.com/SermoDigital/jose/jwt" 10 | ) 11 | 12 | // NewJWT creates a new JWT with the given claims. 13 | func NewJWT(claims Claims, method crypto.SigningMethod) jwt.JWT { 14 | j, ok := New(claims, method).(*jws) 15 | if !ok { 16 | panic("jws.NewJWT: runtime panic: New(...).(*jws) != true") 17 | } 18 | j.sb[0].protected.Set("typ", "JWT") 19 | j.isJWT = true 20 | return j 21 | } 22 | 23 | // Serialize helps implements jwt.JWT. 24 | func (j *jws) Serialize(key interface{}) ([]byte, error) { 25 | if j.isJWT { 26 | return j.Compact(key) 27 | } 28 | return nil, ErrIsNotJWT 29 | } 30 | 31 | // Claims helps implements jwt.JWT. 32 | func (j *jws) Claims() jwt.Claims { 33 | if j.isJWT { 34 | if c, ok := j.payload.v.(Claims); ok { 35 | return jwt.Claims(c) 36 | } 37 | } 38 | return nil 39 | } 40 | 41 | // ParseJWTFromRequest tries to find the JWT in an http.Request. 42 | // This method will call ParseMultipartForm if there's no token in the header. 43 | func ParseJWTFromRequest(req *http.Request) (jwt.JWT, error) { 44 | if b, ok := fromHeader(req); ok { 45 | return ParseJWT(b) 46 | } 47 | if b, ok := fromForm(req); ok { 48 | return ParseJWT(b) 49 | } 50 | return nil, ErrNoTokenInRequest 51 | } 52 | 53 | // ParseJWT parses a serialized jwt.JWT into a physical jwt.JWT. 54 | // If its payload isn't a set of claims (or able to be coerced into 55 | // a set of claims) it'll return an error stating the 56 | // JWT isn't a JWT. 57 | func ParseJWT(encoded []byte) (jwt.JWT, error) { 58 | t, err := parseCompact(encoded, true) 59 | if err != nil { 60 | return nil, err 61 | } 62 | c, ok := t.Payload().(map[string]interface{}) 63 | if !ok { 64 | return nil, ErrIsNotJWT 65 | } 66 | t.SetPayload(Claims(c)) 67 | return t, nil 68 | } 69 | 70 | // IsJWT returns true if the JWS is a JWT. 71 | func (j *jws) IsJWT() bool { 72 | return j.isJWT 73 | } 74 | 75 | func (j *jws) Validate(key interface{}, m crypto.SigningMethod, v ...*jwt.Validator) error { 76 | if j.isJWT { 77 | if err := j.Verify(key, m); err != nil { 78 | return err 79 | } 80 | var v1 jwt.Validator 81 | if len(v) > 0 { 82 | v1 = *v[0] 83 | } 84 | c, ok := j.payload.v.(Claims) 85 | if ok { 86 | if err := v1.Validate(j); err != nil { 87 | return err 88 | } 89 | return jwt.Claims(c).Validate(jose.Now(), v1.EXP, v1.NBF) 90 | } 91 | } 92 | return ErrIsNotJWT 93 | } 94 | 95 | // Conv converts a func(Claims) error to type jwt.ValidateFunc. 96 | func Conv(fn func(Claims) error) jwt.ValidateFunc { 97 | if fn == nil { 98 | return nil 99 | } 100 | return func(c jwt.Claims) error { 101 | return fn(Claims(c)) 102 | } 103 | } 104 | 105 | // NewValidator returns a jwt.Validator. 106 | func NewValidator(c Claims, exp, nbf time.Duration, fn func(Claims) error) *jwt.Validator { 107 | return &jwt.Validator{ 108 | Expected: jwt.Claims(c), 109 | EXP: exp, 110 | NBF: nbf, 111 | Fn: Conv(fn), 112 | } 113 | } 114 | 115 | var _ jwt.JWT = (*jws)(nil) 116 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/payload.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/SermoDigital/jose" 7 | ) 8 | 9 | // payload represents the payload of a JWS. 10 | type payload struct { 11 | v interface{} 12 | u json.Unmarshaler 13 | _ struct{} 14 | } 15 | 16 | // MarshalJSON implements json.Marshaler for payload. 17 | func (p *payload) MarshalJSON() ([]byte, error) { 18 | b, err := json.Marshal(p.v) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return jose.EncodeEscape(b), nil 23 | } 24 | 25 | // Base64 implements jose.Encoder. 26 | func (p *payload) Base64() ([]byte, error) { 27 | b, err := json.Marshal(p.v) 28 | if err != nil { 29 | return nil, err 30 | } 31 | return jose.Base64Encode(b), nil 32 | } 33 | 34 | // MarshalJSON implements json.Unmarshaler for payload. 35 | func (p *payload) UnmarshalJSON(b []byte) error { 36 | b2, err := jose.DecodeEscaped(b) 37 | if err != nil { 38 | return err 39 | } 40 | if p.u != nil { 41 | err := p.u.UnmarshalJSON(b2) 42 | p.v = p.u 43 | return err 44 | } 45 | return json.Unmarshal(b2, &p.v) 46 | } 47 | 48 | var ( 49 | _ json.Marshaler = (*payload)(nil) 50 | _ json.Unmarshaler = (*payload)(nil) 51 | _ jose.Encoder = (*payload)(nil) 52 | ) 53 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/payload_test.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import ( 4 | "encoding/json" 5 | "testing" 6 | 7 | "github.com/SermoDigital/jose" 8 | ) 9 | 10 | func TestPayloadMarshal(t *testing.T) { 11 | p := &payload{v: "Test string!"} 12 | 13 | enc, err := json.Marshal(p) 14 | if err != nil { 15 | t.Error(err) 16 | } 17 | 18 | var pp payload 19 | if err = json.Unmarshal(enc, &pp); err != nil { 20 | t.Error(err) 21 | } 22 | 23 | if pp.v != "Test string!" { 24 | Error(t, "Test string!", pp.v) 25 | } 26 | } 27 | 28 | func TestComplexPayloadMarshal(t *testing.T) { 29 | p := payload{ 30 | v: map[string]interface{}{ 31 | "alg": "HM256", 32 | "typ": "JWT", 33 | }, 34 | } 35 | 36 | enc, err := json.Marshal(&p) 37 | if err != nil { 38 | t.Error(err) 39 | } 40 | 41 | var pp payload 42 | if err = json.Unmarshal(enc, &pp); err != nil { 43 | t.Error(err) 44 | } 45 | 46 | h, ok := pp.v.(map[string]interface{}) 47 | if !ok { 48 | ErrorTypes(t, map[string]interface{}{}, pp.v) 49 | } 50 | 51 | ph := jose.Protected(h) 52 | 53 | if alg := ph.Get("alg"); alg != "HM256" { 54 | Error(t, "HM256", alg) 55 | } 56 | 57 | if typ := ph.Get("typ"); typ != "JWT" { 58 | Error(t, "JWT", typ) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/rawbase64.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import "encoding/json" 4 | 5 | type rawBase64 []byte 6 | 7 | // MarshalJSON implements json.Marshaler for rawBase64. 8 | func (r rawBase64) MarshalJSON() ([]byte, error) { 9 | buf := make([]byte, len(r)+2) 10 | buf[0] = '"' 11 | copy(buf[1:], r) 12 | buf[len(buf)-1] = '"' 13 | return buf, nil 14 | } 15 | 16 | // MarshalJSON implements json.Unmarshaler for rawBase64. 17 | func (r *rawBase64) UnmarshalJSON(b []byte) error { 18 | if len(b) > 1 && b[0] == '"' && b[len(b)-1] == '"' { 19 | b = b[1 : len(b)-1] 20 | } 21 | *r = rawBase64(b) 22 | return nil 23 | } 24 | 25 | var ( 26 | _ json.Marshaler = (rawBase64)(nil) 27 | _ json.Unmarshaler = (*rawBase64)(nil) 28 | ) 29 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/rawbase64_test.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "testing" 7 | ) 8 | 9 | func TestMarshalRawBase64(t *testing.T) { 10 | s := rawBase64("Test string!") 11 | 12 | enc, err := json.Marshal(s) 13 | if err != nil { 14 | t.Error(err) 15 | } 16 | 17 | var ss rawBase64 18 | if err = json.Unmarshal(enc, &ss); err != nil { 19 | t.Error(err) 20 | } 21 | 22 | if !bytes.Equal(ss, s) { 23 | Error(t, s, ss) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/signing_methods.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import ( 4 | "sync" 5 | 6 | "github.com/SermoDigital/jose/crypto" 7 | ) 8 | 9 | var ( 10 | mu sync.RWMutex 11 | 12 | signingMethods = map[string]crypto.SigningMethod{ 13 | crypto.SigningMethodES256.Alg(): crypto.SigningMethodES256, 14 | crypto.SigningMethodES384.Alg(): crypto.SigningMethodES384, 15 | crypto.SigningMethodES512.Alg(): crypto.SigningMethodES512, 16 | 17 | crypto.SigningMethodPS256.Alg(): crypto.SigningMethodPS256, 18 | crypto.SigningMethodPS384.Alg(): crypto.SigningMethodPS384, 19 | crypto.SigningMethodPS512.Alg(): crypto.SigningMethodPS512, 20 | 21 | crypto.SigningMethodRS256.Alg(): crypto.SigningMethodRS256, 22 | crypto.SigningMethodRS384.Alg(): crypto.SigningMethodRS384, 23 | crypto.SigningMethodRS512.Alg(): crypto.SigningMethodRS512, 24 | 25 | crypto.SigningMethodHS256.Alg(): crypto.SigningMethodHS256, 26 | crypto.SigningMethodHS384.Alg(): crypto.SigningMethodHS384, 27 | crypto.SigningMethodHS512.Alg(): crypto.SigningMethodHS512, 28 | 29 | crypto.Unsecured.Alg(): crypto.Unsecured, 30 | } 31 | ) 32 | 33 | // RegisterSigningMethod registers the crypto.SigningMethod in the global map. 34 | // This is typically done inside the caller's init function. 35 | func RegisterSigningMethod(sm crypto.SigningMethod) { 36 | alg := sm.Alg() 37 | if GetSigningMethod(alg) != nil { 38 | panic("jose/jws: cannot duplicate signing methods") 39 | } 40 | 41 | if !sm.Hasher().Available() { 42 | panic("jose/jws: specific hash is unavailable") 43 | } 44 | 45 | mu.Lock() 46 | signingMethods[alg] = sm 47 | mu.Unlock() 48 | } 49 | 50 | // RemoveSigningMethod removes the crypto.SigningMethod from the global map. 51 | func RemoveSigningMethod(sm crypto.SigningMethod) { 52 | mu.Lock() 53 | delete(signingMethods, sm.Alg()) 54 | mu.Unlock() 55 | } 56 | 57 | // GetSigningMethod retrieves a crypto.SigningMethod from the global map. 58 | func GetSigningMethod(alg string) (method crypto.SigningMethod) { 59 | mu.RLock() 60 | method = signingMethods[alg] 61 | mu.RUnlock() 62 | return method 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/signing_methods_test.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import ( 4 | "crypto" 5 | "hash" 6 | "io" 7 | "testing" 8 | 9 | c "github.com/SermoDigital/jose/crypto" 10 | ) 11 | 12 | func init() { crypto.RegisterHash(crypto.Hash(0), HH) } 13 | 14 | func HH() hash.Hash { return &ff{Writer: nil} } 15 | 16 | type ff struct{ io.Writer } 17 | 18 | func (f *ff) Sum(b []byte) []byte { return nil } 19 | func (f *ff) Reset() {} 20 | func (f *ff) Size() int { return -1 } 21 | func (f *ff) BlockSize() int { return -1 } 22 | 23 | // MySigningMethod is the default "none" algorithm. 24 | var MySigningMethod = &TestSigningMethod{ 25 | Name: "SuperSignerAlgorithm1000", 26 | Hash: crypto.Hash(0), 27 | } 28 | 29 | type TestSigningMethod struct { 30 | Name string 31 | Hash crypto.Hash 32 | } 33 | 34 | func (m *TestSigningMethod) Verify(_ []byte, _ c.Signature, _ interface{}) error { 35 | return nil 36 | } 37 | 38 | func (m *TestSigningMethod) Sign(_ []byte, _ interface{}) (c.Signature, error) { 39 | return nil, nil 40 | } 41 | 42 | func (m *TestSigningMethod) Alg() string { return m.Name } 43 | func (m *TestSigningMethod) Sum(b []byte) []byte { return nil } 44 | func (m *TestSigningMethod) Hasher() crypto.Hash { return m.Hash } 45 | 46 | // GetSigningMethod is implicitly tested inside the following two functions. 47 | 48 | func TestRegisterSigningMethod(t *testing.T) { 49 | 50 | RegisterSigningMethod(MySigningMethod) 51 | 52 | if GetSigningMethod("SuperSignerAlgorithm1000") == nil { 53 | t.Error("Expected SuperSignerAlgorithm1000, got nil") 54 | } 55 | 56 | RemoveSigningMethod(MySigningMethod) 57 | } 58 | 59 | func TestRemoveSigningMethod(t *testing.T) { 60 | RegisterSigningMethod(MySigningMethod) 61 | 62 | if GetSigningMethod("SuperSignerAlgorithm1000") == nil { 63 | t.Error("Expected SuperSignerAlgorithm1000, got nil") 64 | } 65 | 66 | RemoveSigningMethod(MySigningMethod) 67 | 68 | if a := GetSigningMethod("SuperSignerAlgorithm1000"); a != nil { 69 | t.Errorf("Expected nil, got %v", a) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/stubs_test.go: -------------------------------------------------------------------------------- 1 | package jws 2 | 3 | import ( 4 | "crypto/ecdsa" 5 | "crypto/rsa" 6 | "crypto/x509" 7 | "encoding/pem" 8 | "fmt" 9 | "io/ioutil" 10 | "path/filepath" 11 | "testing" 12 | 13 | "github.com/SermoDigital/jose/crypto" 14 | ) 15 | 16 | func Error(t *testing.T, want, got interface{}) { 17 | format := "\nWanted: %s\nGot: %s" 18 | 19 | switch want.(type) { 20 | case []byte, string, nil, rawBase64, easy: 21 | default: 22 | format = fmt.Sprintf(format, "%v", "%v") 23 | } 24 | 25 | t.Errorf(format, want, got) 26 | } 27 | 28 | func ErrorTypes(t *testing.T, want, got interface{}) { 29 | t.Errorf("\nWanted: %T\nGot: %T", want, got) 30 | } 31 | 32 | var ( 33 | rsaPriv *rsa.PrivateKey 34 | rsaPub interface{} 35 | ec256Priv *ecdsa.PrivateKey 36 | ec256Pub *ecdsa.PublicKey 37 | ec384Priv *ecdsa.PrivateKey 38 | ec384Pub *ecdsa.PublicKey 39 | ec512Priv *ecdsa.PrivateKey 40 | ec512Pub *ecdsa.PublicKey 41 | hm256 interface{} 42 | ) 43 | 44 | func init() { 45 | derBytes, err := ioutil.ReadFile(filepath.Join("test", "sample_key.pub")) 46 | if err != nil { 47 | panic(err) 48 | } 49 | block, _ := pem.Decode(derBytes) 50 | 51 | rsaPub, err = x509.ParsePKIXPublicKey(block.Bytes) 52 | if err != nil { 53 | panic(err) 54 | } 55 | 56 | der, err := ioutil.ReadFile(filepath.Join("test", "sample_key.priv")) 57 | if err != nil { 58 | panic(err) 59 | } 60 | block2, _ := pem.Decode(der) 61 | 62 | rsaPriv, err = x509.ParsePKCS1PrivateKey(block2.Bytes) 63 | if err != nil { 64 | panic(err) 65 | } 66 | 67 | ecData, err := ioutil.ReadFile(filepath.Join("test", "ec256-private.pem")) 68 | if err != nil { 69 | panic(err) 70 | } 71 | ec256Priv, err = crypto.ParseECPrivateKeyFromPEM(ecData) 72 | if err != nil { 73 | panic(err) 74 | } 75 | ecData, err = ioutil.ReadFile(filepath.Join("test", "ec256-public.pem")) 76 | if err != nil { 77 | panic(err) 78 | } 79 | ec256Pub, err = crypto.ParseECPublicKeyFromPEM(ecData) 80 | if err != nil { 81 | panic(err) 82 | } 83 | ecData, err = ioutil.ReadFile(filepath.Join("test", "ec384-private.pem")) 84 | if err != nil { 85 | panic(err) 86 | } 87 | ec384Priv, err = crypto.ParseECPrivateKeyFromPEM(ecData) 88 | if err != nil { 89 | panic(err) 90 | } 91 | ecData, err = ioutil.ReadFile(filepath.Join("test", "ec384-public.pem")) 92 | if err != nil { 93 | panic(err) 94 | } 95 | ec384Pub, err = crypto.ParseECPublicKeyFromPEM(ecData) 96 | if err != nil { 97 | panic(err) 98 | } 99 | ecData, err = ioutil.ReadFile(filepath.Join("test", "ec512-private.pem")) 100 | if err != nil { 101 | panic(err) 102 | } 103 | ec512Priv, err = crypto.ParseECPrivateKeyFromPEM(ecData) 104 | if err != nil { 105 | panic(err) 106 | } 107 | ecData, err = ioutil.ReadFile(filepath.Join("test", "ec512-public.pem")) 108 | if err != nil { 109 | panic(err) 110 | } 111 | ec512Pub, err = crypto.ParseECPublicKeyFromPEM(ecData) 112 | if err != nil { 113 | panic(err) 114 | } 115 | 116 | hm256, err = ioutil.ReadFile(filepath.Join("test", "hmacTestKey")) 117 | if err != nil { 118 | panic(err) 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/ec256-private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MHcCAQEEIAh5qA3rmqQQuu0vbKV/+zouz/y/Iy2pLpIcWUSyImSwoAoGCCqGSM49 3 | AwEHoUQDQgAEYD54V/vp+54P9DXarYqx4MPcm+HKRIQzNasYSoRQHQ/6S6Ps8tpM 4 | cT+KvIIC8W/e9k0W7Cm72M1P9jU7SLf/vg== 5 | -----END EC PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/ec256-public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEYD54V/vp+54P9DXarYqx4MPcm+HK 3 | RIQzNasYSoRQHQ/6S6Ps8tpMcT+KvIIC8W/e9k0W7Cm72M1P9jU7SLf/vg== 4 | -----END PUBLIC KEY----- 5 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/ec384-private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MIGkAgEBBDCaCvMHKhcG/qT7xsNLYnDT7sE/D+TtWIol1ROdaK1a564vx5pHbsRy 3 | SEKcIxISi1igBwYFK4EEACKhZANiAATYa7rJaU7feLMqrAx6adZFNQOpaUH/Uylb 4 | ZLriOLON5YFVwtVUpO1FfEXZUIQpptRPtc5ixIPY658yhBSb6irfIJUSP9aYTflJ 5 | GKk/mDkK4t8mWBzhiD5B6jg9cEGhGgA= 6 | -----END EC PRIVATE KEY----- 7 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/ec384-public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE2Gu6yWlO33izKqwMemnWRTUDqWlB/1Mp 3 | W2S64jizjeWBVcLVVKTtRXxF2VCEKabUT7XOYsSD2OufMoQUm+oq3yCVEj/WmE35 4 | SRipP5g5CuLfJlgc4Yg+Qeo4PXBBoRoA 5 | -----END PUBLIC KEY----- 6 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/ec512-private.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PRIVATE KEY----- 2 | MIHcAgEBBEIB0pE4uFaWRx7t03BsYlYvF1YvKaBGyvoakxnodm9ou0R9wC+sJAjH 3 | QZZJikOg4SwNqgQ/hyrOuDK2oAVHhgVGcYmgBwYFK4EEACOhgYkDgYYABAAJXIuw 4 | 12MUzpHggia9POBFYXSxaOGKGbMjIyDI+6q7wi7LMw3HgbaOmgIqFG72o8JBQwYN 5 | 4IbXHf+f86CRY1AA2wHzbHvt6IhkCXTNxBEffa1yMUgu8n9cKKF2iLgyQKcKqW33 6 | 8fGOw/n3Rm2Yd/EB56u2rnD29qS+nOM9eGS+gy39OQ== 7 | -----END EC PRIVATE KEY----- 8 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/ec512-public.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQACVyLsNdjFM6R4IImvTzgRWF0sWjh 3 | ihmzIyMgyPuqu8IuyzMNx4G2jpoCKhRu9qPCQUMGDeCG1x3/n/OgkWNQANsB82x7 4 | 7eiIZAl0zcQRH32tcjFILvJ/XCihdoi4MkCnCqlt9/HxjsP590ZtmHfxAeertq5w 5 | 9vakvpzjPXhkvoMt/Tk= 6 | -----END PUBLIC KEY----- 7 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/hmacTestKey: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bjhaid/pam_hook/bb0596aa853a63ef09119f7602ffa47ba066a93c/vendor/github.com/SermoDigital/jose/jws/test/hmacTestKey -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/sample_key.priv: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEA1/yKYrWdyTMGWKZ2ZUrY7T9h1VyZCOJPo7jobC3/4gLQqb0v 3 | GLJ3KQxN3IyW+XHBElGLGS3ol4swnq+EutFZFqq2Rkl2NTn5KTuvNqgxLj0aDYae 4 | fD576ip623rZVG8KsfdtW5kYgb/Vna83Isc6rbNbuwZGSqRF7BN9VJTWQyrjT+ul 5 | e0FCW060LbWfp3WPDfJION5AznukFHsl/zPFSMfreobaaY+L4CQiRmbI0eNgnibP 6 | Ej1IyCwHhzAIfR8Dhw5JYXOGYnB4adePD1/ImahR93opO/BylUxHcIPg4cW0G7KA 7 | G7lZXG7bbQoP8MJMubsDqnJ6O2XZ5+2U+BSZeQIDAQABAoIBAF43P3aHmuilZWNO 8 | Wd8dozr6pwaXefoyHmNgyaJG/pPsfnFMoTq4vtodD+nhOgpd4MbI41B8gjV49iCC 9 | l/eWUrJcjV5jtTjKrTGbY3cIL0voQ3EbBA9Wgl9HYIhVMnBub8/qCr4mLlaLA/fg 10 | 8sAtAB+9WYpf1lHBDu9IISfANSbexVuw7rpSbIkSsvsDtqgfQlAZZCmt7b/yTBKJ 11 | nbr/xAqS8PWFUqO3OJR/S+a95joRhs3G8uLcb50k9bWIayBLEO/lFfKQhyBPF5j3 12 | 2GpzW/TKw8YPQaKt0uKZwiYerYIS7HYbl3xBMLkxqcDiseorqRTjmorNgxtaKbRh 13 | ig6V9zECgYEA6tIQLlWT5XX7FOg4yGKe6YFwl37lMWFTBuVPCq562cbDYzYxRYS8 14 | xTexwki3ONcuKKlnWPIaLq/ds8j3k71uw6jXE/kLKq/cwu3+hWUkWaBOKejQ4tZ5 15 | MvzLMdlB0klZJejUm1plic4Sqq5EdjELi2MOKaJXXEvwktxidTYCD+sCgYEA63ea 16 | rr7LSDuM5YiNjbKbc5Y3XPQf5LaNRA7902uuSkzoKur7EKPUos4zi2K3OBRI9w7P 17 | AEOarh8kbcwQQs93EiwIYFu0miinMgbU1aKIdYcQgdAX/rRqje22YGsV5S6AsvCi 18 | 9Ok5VOPEgWMkbMCPN64s6RcKxConilOeVk9FhysCgYEAm9GIqzZeTYVcdyMhitbm 19 | XExoSh8KNxo93fWL3aqqGpiqTstHJrpOCRBMBH/8FNu05YaD7aG5fgF1PDe/EWpC 20 | ddMz5Sz9G/ZWp4MFwb67wD1/oI+9DMkE47CbpRhldQT3AxDdA7mYZzk3acr54vPo 21 | lTXF0BrJnZVGri1PqDeOZsECgYA1xlfeJpaYRXlVBk2Fmc+kox67rMkH26UBcQcI 22 | 3KOuNkgjXQy/bRrnn33oDEBZn1BWk9w0bDwMHfKc3KiuCWFhFgtHrkndlwEwDJ1Y 23 | uMi/Rnw/mT2RnrRi+3HWLT6P24Hq28frdMPyHh5HilPMPmG2zqFVDj0YNaRYE+aq 24 | QWpYhwKBgFfiE7ld9WMymVdT65PNJVTf2XR94ec99Y/BK8RC2HsqFLiRIMIKf5cz 25 | qouqEutKwXdF5tRS9681Bzu4txwzHuRH+r/Y1cIhPq4/slE727aaEedqvgY51C0m 26 | U92DBkXyBEtk3G07Xqk3Z6NKLDbMCnxhOYz9XN2iOMJRwkBi00xK 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/sample_key.pub: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1/yKYrWdyTMGWKZ2ZUrY 3 | 7T9h1VyZCOJPo7jobC3/4gLQqb0vGLJ3KQxN3IyW+XHBElGLGS3ol4swnq+EutFZ 4 | Fqq2Rkl2NTn5KTuvNqgxLj0aDYaefD576ip623rZVG8KsfdtW5kYgb/Vna83Isc6 5 | rbNbuwZGSqRF7BN9VJTWQyrjT+ule0FCW060LbWfp3WPDfJION5AznukFHsl/zPF 6 | SMfreobaaY+L4CQiRmbI0eNgnibPEj1IyCwHhzAIfR8Dhw5JYXOGYnB4adePD1/I 7 | mahR93opO/BylUxHcIPg4cW0G7KAG7lZXG7bbQoP8MJMubsDqnJ6O2XZ5+2U+BSZ 8 | eQIDAQAB 9 | -----END PUBLIC KEY----- 10 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jws/test/test.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "crypto/rand" 7 | "crypto/rsa" 8 | "crypto/x509" 9 | "encoding/pem" 10 | "os" 11 | ) 12 | 13 | func main() { 14 | 15 | f1, err := os.Create("sample_key.priv") 16 | if err != nil { 17 | panic(err) 18 | } 19 | f2, err := os.Create("sample_key.pub") 20 | if err != nil { 21 | panic(err) 22 | } 23 | 24 | privateKey, err := rsa.GenerateKey(rand.Reader, 2048) 25 | if err != nil { 26 | panic(err) 27 | } 28 | 29 | privateKeyDer := x509.MarshalPKCS1PrivateKey(privateKey) 30 | privateKeyBlock := pem.Block{ 31 | Type: "RSA PRIVATE KEY", 32 | Headers: nil, 33 | Bytes: privateKeyDer, 34 | } 35 | pem.Encode(f1, &privateKeyBlock) 36 | 37 | publicKey := privateKey.PublicKey 38 | publicKeyDer, err := x509.MarshalPKIXPublicKey(&publicKey) 39 | if err != nil { 40 | panic(err) 41 | } 42 | 43 | publicKeyBlock := pem.Block{ 44 | Type: "PUBLIC KEY", 45 | Headers: nil, 46 | Bytes: publicKeyDer, 47 | } 48 | pem.Encode(f2, &publicKeyBlock) 49 | 50 | f1.Close() 51 | f2.Close() 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jwt/doc.go: -------------------------------------------------------------------------------- 1 | // Package jwt implements JWTs per RFC 7519 2 | package jwt 3 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jwt/eq.go: -------------------------------------------------------------------------------- 1 | package jwt 2 | 3 | func verifyPrincipals(pcpls, auds []string) bool { 4 | // "Each principal intended to process the JWT MUST 5 | // identify itself with a value in the audience claim." 6 | // - https://tools.ietf.org/html/rfc7519#section-4.1.3 7 | 8 | found := -1 9 | for i, p := range pcpls { 10 | for _, v := range auds { 11 | if p == v { 12 | found++ 13 | break 14 | } 15 | } 16 | if found != i { 17 | return false 18 | } 19 | } 20 | return true 21 | } 22 | 23 | // ValidAudience returns true iff: 24 | // - a and b are strings and a == b 25 | // - a is string, b is []string and a is in b 26 | // - a is []string, b is []string and all of a is in b 27 | // - a is []string, b is string and len(a) == 1 and a[0] == b 28 | func ValidAudience(a, b interface{}) bool { 29 | s1, ok := a.(string) 30 | if ok { 31 | if s2, ok := b.(string); ok { 32 | return s1 == s2 33 | } 34 | a2, ok := b.([]string) 35 | return ok && verifyPrincipals([]string{s1}, a2) 36 | } 37 | 38 | a1, ok := a.([]string) 39 | if !ok { 40 | return false 41 | } 42 | if a2, ok := b.([]string); ok { 43 | return verifyPrincipals(a1, a2) 44 | } 45 | s2, ok := b.(string) 46 | return ok && len(a1) == 1 && a1[0] == s2 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jwt/eq_test.go: -------------------------------------------------------------------------------- 1 | package jwt_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/SermoDigital/jose/jwt" 7 | ) 8 | 9 | func TestValidAudience(t *testing.T) { 10 | tests := [...]struct { 11 | a interface{} 12 | b interface{} 13 | v bool 14 | }{ 15 | 0: {"https://www.google.com", "https://www.google.com", true}, 16 | 1: {[]string{"example.com", "google.com"}, []string{"example.com"}, false}, 17 | 2: {500, 43, false}, 18 | 3: {"google.com", "facebook.com", false}, 19 | 4: {[]string{"example.com"}, []string{"example.com", "foo.com"}, true}, 20 | } 21 | for i, v := range tests { 22 | if x := jwt.ValidAudience(v.a, v.b); x != v.v { 23 | t.Fatalf("#%d: wanted %t, got %t", i, v.v, x) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/jwt/errors.go: -------------------------------------------------------------------------------- 1 | package jwt 2 | 3 | import "errors" 4 | 5 | var ( 6 | // ErrTokenIsExpired is return when time.Now().Unix() is after 7 | // the token's "exp" claim. 8 | ErrTokenIsExpired = errors.New("token is expired") 9 | 10 | // ErrTokenNotYetValid is return when time.Now().Unix() is before 11 | // the token's "nbf" claim. 12 | ErrTokenNotYetValid = errors.New("token is not yet valid") 13 | 14 | // ErrInvalidISSClaim means the "iss" claim is invalid. 15 | ErrInvalidISSClaim = errors.New("claim \"iss\" is invalid") 16 | 17 | // ErrInvalidSUBClaim means the "sub" claim is invalid. 18 | ErrInvalidSUBClaim = errors.New("claim \"sub\" is invalid") 19 | 20 | // ErrInvalidIATClaim means the "iat" claim is invalid. 21 | ErrInvalidIATClaim = errors.New("claim \"iat\" is invalid") 22 | 23 | // ErrInvalidJTIClaim means the "jti" claim is invalid. 24 | ErrInvalidJTIClaim = errors.New("claim \"jti\" is invalid") 25 | 26 | // ErrInvalidAUDClaim means the "aud" claim is invalid. 27 | ErrInvalidAUDClaim = errors.New("claim \"aud\" is invalid") 28 | ) 29 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/stubs_test.go: -------------------------------------------------------------------------------- 1 | package jose 2 | 3 | import "testing" 4 | 5 | func Error(t *testing.T, want, got interface{}) { 6 | t.Errorf("Wanted: %q\n\t Got: %q", want, got) 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/SermoDigital/jose/time.go: -------------------------------------------------------------------------------- 1 | package jose 2 | 3 | import "time" 4 | 5 | // Now returns the current time in UTC. 6 | func Now() time.Time { return time.Now().UTC() } 7 | -------------------------------------------------------------------------------- /vendor/github.com/golang/glog/README: -------------------------------------------------------------------------------- 1 | glog 2 | ==== 3 | 4 | Leveled execution logs for Go. 5 | 6 | This is an efficient pure Go implementation of leveled logs in the 7 | manner of the open source C++ package 8 | https://github.com/google/glog 9 | 10 | By binding methods to booleans it is possible to use the log package 11 | without paying the expense of evaluating the arguments to the log. 12 | Through the -vmodule flag, the package also provides fine-grained 13 | control over logging at the file level. 14 | 15 | The comment from glog.go introduces the ideas: 16 | 17 | Package glog implements logging analogous to the Google-internal 18 | C++ INFO/ERROR/V setup. It provides functions Info, Warning, 19 | Error, Fatal, plus formatting variants such as Infof. It 20 | also provides V-style logging controlled by the -v and 21 | -vmodule=file=2 flags. 22 | 23 | Basic examples: 24 | 25 | glog.Info("Prepare to repel boarders") 26 | 27 | glog.Fatalf("Initialization failed: %s", err) 28 | 29 | See the documentation for the V function for an explanation 30 | of these examples: 31 | 32 | if glog.V(2) { 33 | glog.Info("Starting transaction...") 34 | } 35 | 36 | glog.V(2).Infoln("Processed", nItems, "elements") 37 | 38 | 39 | The repository contains an open source version of the log package 40 | used inside Google. The master copy of the source lives inside 41 | Google, not here. The code in this repo is for export only and is not itself 42 | under development. Feature requests will be ignored. 43 | 44 | Send bug reports to golang-nuts@googlegroups.com. 45 | -------------------------------------------------------------------------------- /vendor/github.com/msteinert/pam/.gitignore: -------------------------------------------------------------------------------- 1 | coverage.out 2 | -------------------------------------------------------------------------------- /vendor/github.com/msteinert/pam/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.8.x 5 | - 1.9.x 6 | - tip 7 | 8 | before_install: 9 | - sudo apt-get update -qq 10 | - sudo apt-get install -qq --no-install-recommends libpam0g-dev 11 | - sudo useradd -d /tmp/test -p '$1$Qd8H95T5$RYSZQeoFbEB.gS19zS99A0' -s /bin/false test 12 | - go get github.com/axw/gocov/gocov 13 | - go get github.com/mattn/goveralls 14 | - go get golang.org/x/tools/cmd/cover 15 | 16 | script: 17 | - sudo GOROOT=$GOROOT GOPATH=$GOPATH $(which go) test -v -covermode=count -coverprofile=coverage.out . 18 | - if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then goveralls -coverprofile=coverage.out -service travis-ci -repotoken $REPO_TOKEN; fi 19 | -------------------------------------------------------------------------------- /vendor/github.com/msteinert/pam/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011, krockot 2 | Copyright 2015, Michael Steinert 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /vendor/github.com/msteinert/pam/README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/msteinert/pam.svg?branch=master)](https://travis-ci.org/msteinert/pam) 2 | [![GoDoc](https://godoc.org/github.com/msteinert/pam?status.svg)](http://godoc.org/github.com/msteinert/pam) 3 | [![Coverage Status](https://coveralls.io/repos/msteinert/pam/badge.svg?branch=master)](https://coveralls.io/r/msteinert/pam?branch=master) 4 | [![Go Report Card](http://goreportcard.com/badge/msteinert/pam)](http://goreportcard.com/report/msteinert/pam) 5 | 6 | # Go PAM 7 | 8 | This is a Go wrapper for the PAM application API. 9 | 10 | ## Testing 11 | 12 | To run the full suite, the tests must be run as the root user. To setup your 13 | system for testing, create a user named "test" with the password "secret". For 14 | example: 15 | 16 | ``` 17 | $ sudo useradd test \ 18 | -d /tmp/test \ 19 | -p '$1$Qd8H95T5$RYSZQeoFbEB.gS19zS99A0' \ 20 | -s /bin/false 21 | ``` 22 | 23 | Then execute the tests: 24 | 25 | ``` 26 | $ sudo GOPATH=$GOPATH $(which go) test -v 27 | ``` 28 | 29 | [1]: http://godoc.org/github.com/msteinert/pam 30 | [2]: http://www.linux-pam.org/Linux-PAM-html/Linux-PAM_ADG.html 31 | -------------------------------------------------------------------------------- /vendor/github.com/msteinert/pam/callback.go: -------------------------------------------------------------------------------- 1 | package pam 2 | 3 | import "sync" 4 | 5 | var cb struct { 6 | sync.Mutex 7 | m map[int]interface{} 8 | c int 9 | } 10 | 11 | func init() { 12 | cb.m = make(map[int]interface{}) 13 | } 14 | 15 | func cbAdd(v interface{}) int { 16 | cb.Lock() 17 | defer cb.Unlock() 18 | cb.c++ 19 | cb.m[cb.c] = v 20 | return cb.c 21 | } 22 | 23 | func cbGet(c int) interface{} { 24 | cb.Lock() 25 | defer cb.Unlock() 26 | if v, ok := cb.m[c]; ok { 27 | return v 28 | } 29 | panic("Callback pointer not found") 30 | } 31 | 32 | func cbDelete(c int) { 33 | cb.Lock() 34 | defer cb.Unlock() 35 | if _, ok := cb.m[c]; !ok { 36 | panic("Callback pointer not found") 37 | } 38 | delete(cb.m, c) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/msteinert/pam/callback_test.go: -------------------------------------------------------------------------------- 1 | package pam 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestCallback_001(t *testing.T) { 9 | c := cbAdd(TestCallback_001) 10 | v := cbGet(c) 11 | if reflect.TypeOf(v) != reflect.TypeOf(TestCallback_001) { 12 | t.Error("Received unexpected value") 13 | } 14 | cbDelete(c) 15 | } 16 | 17 | func TestCallback_002(t *testing.T) { 18 | defer func() { 19 | recover() 20 | }() 21 | c := cbAdd(TestCallback_002) 22 | cbGet(c + 1) 23 | t.Error("Expected a panic") 24 | } 25 | 26 | func TestCallback_003(t *testing.T) { 27 | defer func() { 28 | recover() 29 | }() 30 | c := cbAdd(TestCallback_003) 31 | cbDelete(c + 1) 32 | t.Error("Expected a panic") 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/msteinert/pam/example_test.go: -------------------------------------------------------------------------------- 1 | package pam_test 2 | 3 | import ( 4 | "bufio" 5 | "errors" 6 | "fmt" 7 | "log" 8 | "os" 9 | 10 | "github.com/bgentry/speakeasy" 11 | "github.com/msteinert/pam" 12 | ) 13 | 14 | // This example uses whatever default PAM service configuration is available 15 | // on the system, and tries to authenticate any user. This should cause PAM 16 | // to ask its conversation handler for a username and password, in sequence. 17 | // 18 | // This application will handle those requests by displaying the 19 | // PAM-provided prompt and sending back the first line of stdin input 20 | // it can read for each. 21 | // 22 | // Keep in mind that unless run as root (or setuid root), the only 23 | // user's authentication that can succeed is that of the process owner. 24 | func Example_authenticate() { 25 | t, err := pam.StartFunc("", "", func(s pam.Style, msg string) (string, error) { 26 | switch s { 27 | case pam.PromptEchoOff: 28 | return speakeasy.Ask(msg) 29 | case pam.PromptEchoOn: 30 | fmt.Print(msg + " ") 31 | input, err := bufio.NewReader(os.Stdin).ReadString('\n') 32 | if err != nil { 33 | return "", err 34 | } 35 | return input[:len(input)-1], nil 36 | case pam.ErrorMsg: 37 | log.Print(msg) 38 | return "", nil 39 | case pam.TextInfo: 40 | fmt.Println(msg) 41 | return "", nil 42 | } 43 | return "", errors.New("Unrecognized message style") 44 | }) 45 | if err != nil { 46 | log.Fatalf("Start: %s", err.Error()) 47 | } 48 | err = t.Authenticate(0) 49 | if err != nil { 50 | log.Fatalf("Authenticate: %s", err.Error()) 51 | } 52 | fmt.Println("Authentication succeeded!") 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/msteinert/pam/transaction.c: -------------------------------------------------------------------------------- 1 | #include "_cgo_export.h" 2 | #include 3 | #include 4 | 5 | int cb_pam_conv( 6 | int num_msg, 7 | const struct pam_message **msg, 8 | struct pam_response **resp, 9 | void *appdata_ptr) 10 | { 11 | *resp = calloc(num_msg, sizeof **resp); 12 | if (num_msg <= 0 || num_msg > PAM_MAX_NUM_MSG) { 13 | return PAM_CONV_ERR; 14 | } 15 | if (!*resp) { 16 | return PAM_BUF_ERR; 17 | } 18 | for (size_t i = 0; i < num_msg; ++i) { 19 | struct cbPAMConv_return result = cbPAMConv( 20 | msg[i]->msg_style, 21 | (char *)msg[i]->msg, 22 | (long)appdata_ptr); 23 | if (result.r1 != PAM_SUCCESS) { 24 | goto error; 25 | } 26 | (*resp)[i].resp = result.r0; 27 | } 28 | return PAM_SUCCESS; 29 | error: 30 | for (size_t i = 0; i < num_msg; ++i) { 31 | if ((*resp)[i].resp) { 32 | memset((*resp)[i].resp, 0, strlen((*resp)[i].resp)); 33 | free((*resp)[i].resp); 34 | } 35 | } 36 | memset(*resp, 0, num_msg * sizeof *resp); 37 | free(*resp); 38 | *resp = NULL; 39 | return PAM_CONV_ERR; 40 | } 41 | 42 | void init_pam_conv(struct pam_conv *conv, long c) 43 | { 44 | conv->conv = cb_pam_conv; 45 | conv->appdata_ptr = (void *)c; 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .hgignore except for files generated by the build. 2 | last-change 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | 8 | ## Filing issues 9 | 10 | When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: 11 | 12 | 1. What version of Go are you using (`go version`)? 13 | 2. What operating system and processor architecture are you using? 14 | 3. What did you do? 15 | 4. What did you expect to see? 16 | 5. What did you see instead? 17 | 18 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 19 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 20 | 21 | ## Contributing code 22 | 23 | Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) 24 | before sending patches. 25 | 26 | **We do not accept GitHub pull requests** 27 | (we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). 28 | 29 | Unless otherwise noted, the Go source files are distributed under 30 | the BSD-style license found in the LICENSE file. 31 | 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/README: -------------------------------------------------------------------------------- 1 | This repository holds supplemental Go packages for low-level interactions with the operating system. 2 | 3 | To submit changes to this repository, see http://golang.org/doc/contribute.html. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·use(SB),NOSPLIT,$0 8 | RET 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/asm_plan9_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | // 8 | // System call support for 386, Plan 9 9 | // 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-32 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-36 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$4-4 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/asm_plan9_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | // 8 | // System call support for amd64, Plan 9 9 | // 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-64 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-56 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$8-8 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/const_plan9.go: -------------------------------------------------------------------------------- 1 | package plan9 2 | 3 | // Plan 9 Constants 4 | 5 | // Open modes 6 | const ( 7 | O_RDONLY = 0 8 | O_WRONLY = 1 9 | O_RDWR = 2 10 | O_TRUNC = 16 11 | O_CLOEXEC = 32 12 | O_EXCL = 0x1000 13 | ) 14 | 15 | // Rfork flags 16 | const ( 17 | RFNAMEG = 1 << 0 18 | RFENVG = 1 << 1 19 | RFFDG = 1 << 2 20 | RFNOTEG = 1 << 3 21 | RFPROC = 1 << 4 22 | RFMEM = 1 << 5 23 | RFNOWAIT = 1 << 6 24 | RFCNAMEG = 1 << 10 25 | RFCENVG = 1 << 11 26 | RFCFDG = 1 << 12 27 | RFREND = 1 << 13 28 | RFNOMNT = 1 << 14 29 | ) 30 | 31 | // Qid.Type bits 32 | const ( 33 | QTDIR = 0x80 34 | QTAPPEND = 0x40 35 | QTEXCL = 0x20 36 | QTMOUNT = 0x10 37 | QTAUTH = 0x08 38 | QTTMP = 0x04 39 | QTFILE = 0x00 40 | ) 41 | 42 | // Dir.Mode bits 43 | const ( 44 | DMDIR = 0x80000000 45 | DMAPPEND = 0x40000000 46 | DMEXCL = 0x20000000 47 | DMMOUNT = 0x10000000 48 | DMAUTH = 0x08000000 49 | DMTMP = 0x04000000 50 | DMREAD = 0x4 51 | DMWRITE = 0x2 52 | DMEXEC = 0x1 53 | ) 54 | 55 | const ( 56 | STATMAX = 65535 57 | ERRMAX = 128 58 | STATFIXLEN = 49 59 | ) 60 | 61 | // Mount and bind flags 62 | const ( 63 | MREPL = 0x0000 64 | MBEFORE = 0x0001 65 | MAFTER = 0x0002 66 | MORDER = 0x0003 67 | MCREATE = 0x0004 68 | MCACHE = 0x0010 69 | MMASK = 0x0017 70 | ) 71 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/env_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Plan 9 environment variables. 6 | 7 | package plan9 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package plan9 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/errors_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package plan9 6 | 7 | import "syscall" 8 | 9 | // Constants 10 | const ( 11 | // Invented values to support what package os expects. 12 | O_CREAT = 0x02000 13 | O_APPEND = 0x00400 14 | O_NOCTTY = 0x00000 15 | O_NONBLOCK = 0x00000 16 | O_SYNC = 0x00000 17 | O_ASYNC = 0x00000 18 | 19 | S_IFMT = 0x1f000 20 | S_IFIFO = 0x1000 21 | S_IFCHR = 0x2000 22 | S_IFDIR = 0x4000 23 | S_IFBLK = 0x6000 24 | S_IFREG = 0x8000 25 | S_IFLNK = 0xa000 26 | S_IFSOCK = 0xc000 27 | ) 28 | 29 | // Errors 30 | var ( 31 | EINVAL = syscall.NewError("bad arg in system call") 32 | ENOTDIR = syscall.NewError("not a directory") 33 | EISDIR = syscall.NewError("file is a directory") 34 | ENOENT = syscall.NewError("file does not exist") 35 | EEXIST = syscall.NewError("file already exists") 36 | EMFILE = syscall.NewError("no free file descriptors") 37 | EIO = syscall.NewError("i/o error") 38 | ENAMETOOLONG = syscall.NewError("file name too long") 39 | EINTR = syscall.NewError("interrupted") 40 | EPERM = syscall.NewError("permission denied") 41 | EBUSY = syscall.NewError("no free devices") 42 | ETIMEDOUT = syscall.NewError("connection timed out") 43 | EPLAN9 = syscall.NewError("not supported by plan 9") 44 | 45 | // The following errors do not correspond to any 46 | // Plan 9 system messages. Invented to support 47 | // what package os and others expect. 48 | EACCES = syscall.NewError("access permission denied") 49 | EAFNOSUPPORT = syscall.NewError("address family not supported by protocol") 50 | ) 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | 6 | COMMAND="mksysnum_plan9.sh $@" 7 | 8 | cat <= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build plan9 6 | 7 | // Package plan9 contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display the OS-specific documentation for the current 10 | // system. If you want godoc to display documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.ErrorString. 22 | package plan9 // import "golang.org/x/sys/plan9" 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mksyscall.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | // use is a no-op, but the compiler cannot see that it is. 72 | // Calling use(p) ensures that p is kept live until that point. 73 | //go:noescape 74 | func use(p unsafe.Pointer) 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/syscall_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build plan9 6 | 7 | package plan9_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/sys/plan9" 13 | ) 14 | 15 | func testSetGetenv(t *testing.T, key, value string) { 16 | err := plan9.Setenv(key, value) 17 | if err != nil { 18 | t.Fatalf("Setenv failed to set %q: %v", value, err) 19 | } 20 | newvalue, found := plan9.Getenv(key) 21 | if !found { 22 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 23 | } 24 | if newvalue != value { 25 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 26 | } 27 | } 28 | 29 | func TestEnv(t *testing.T) { 30 | testSetGetenv(t, "TESTENV", "AVALUE") 31 | // make sure TESTENV gets set to "", not deleted 32 | testSetGetenv(t, "TESTENV", "") 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/plan9/zsysnum_plan9.go: -------------------------------------------------------------------------------- 1 | // mksysnum_plan9.sh /opt/plan9/sys/src/libc/9syscall/sys.h 2 | // MACHINE GENERATED BY THE ABOVE COMMAND; DO NOT EDIT 3 | 4 | package plan9 5 | 6 | const ( 7 | SYS_SYSR1 = 0 8 | SYS_BIND = 2 9 | SYS_CHDIR = 3 10 | SYS_CLOSE = 4 11 | SYS_DUP = 5 12 | SYS_ALARM = 6 13 | SYS_EXEC = 7 14 | SYS_EXITS = 8 15 | SYS_FAUTH = 10 16 | SYS_SEGBRK = 12 17 | SYS_OPEN = 14 18 | SYS_OSEEK = 16 19 | SYS_SLEEP = 17 20 | SYS_RFORK = 19 21 | SYS_PIPE = 21 22 | SYS_CREATE = 22 23 | SYS_FD2PATH = 23 24 | SYS_BRK_ = 24 25 | SYS_REMOVE = 25 26 | SYS_NOTIFY = 28 27 | SYS_NOTED = 29 28 | SYS_SEGATTACH = 30 29 | SYS_SEGDETACH = 31 30 | SYS_SEGFREE = 32 31 | SYS_SEGFLUSH = 33 32 | SYS_RENDEZVOUS = 34 33 | SYS_UNMOUNT = 35 34 | SYS_SEMACQUIRE = 37 35 | SYS_SEMRELEASE = 38 36 | SYS_SEEK = 39 37 | SYS_FVERSION = 40 38 | SYS_ERRSTR = 41 39 | SYS_STAT = 42 40 | SYS_FSTAT = 43 41 | SYS_WSTAT = 44 42 | SYS_FWSTAT = 45 43 | SYS_MOUNT = 46 44 | SYS_AWAIT = 47 45 | SYS_PREAD = 50 46 | SYS_PWRITE = 51 47 | SYS_TSEMACQUIRE = 52 48 | SYS_NSEC = 53 49 | ) 50 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/export_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | var Itoa = itoa 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | 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) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mkpost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 72 | 73 | // use is a no-op, but the compiler cannot see that it is. 74 | // Calling use(p) ensures that p is kept live until that point. 75 | //go:noescape 76 | func use(p unsafe.Pointer) 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_bsd_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd openbsd 6 | 7 | package unix_test 8 | 9 | import ( 10 | "os/exec" 11 | "runtime" 12 | "testing" 13 | 14 | "golang.org/x/sys/unix" 15 | ) 16 | 17 | const MNT_WAIT = 1 18 | const MNT_NOWAIT = 2 19 | 20 | func TestGetfsstat(t *testing.T) { 21 | const flags = MNT_NOWAIT // see golang.org/issue/16937 22 | n, err := unix.Getfsstat(nil, flags) 23 | if err != nil { 24 | t.Fatal(err) 25 | } 26 | 27 | data := make([]unix.Statfs_t, n) 28 | n2, err := unix.Getfsstat(data, flags) 29 | if err != nil { 30 | t.Fatal(err) 31 | } 32 | if n != n2 { 33 | t.Errorf("Getfsstat(nil) = %d, but subsequent Getfsstat(slice) = %d", n, n2) 34 | } 35 | for i, stat := range data { 36 | if stat == (unix.Statfs_t{}) { 37 | t.Errorf("index %v is an empty Statfs_t struct", i) 38 | } 39 | } 40 | if t.Failed() { 41 | for i, stat := range data[:n2] { 42 | t.Logf("data[%v] = %+v", i, stat) 43 | } 44 | mount, err := exec.Command("mount").CombinedOutput() 45 | if err != nil { 46 | t.Logf("mount: %v\n%s", err, mount) 47 | } else { 48 | t.Logf("mount: %s", mount) 49 | } 50 | } 51 | } 52 | 53 | func TestSysctlRaw(t *testing.T) { 54 | if runtime.GOOS == "openbsd" { 55 | t.Skip("kern.proc.pid does not exist on OpenBSD") 56 | } 57 | 58 | _, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid()) 59 | if err != nil { 60 | t.Fatal(err) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build freebsd 6 | 7 | package unix_test 8 | 9 | import ( 10 | "os" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func TestSysctUint64(t *testing.T) { 17 | _, err := unix.SysctlUint64("vm.max_kernel_address") 18 | if err != nil { 19 | if os.Getenv("GO_BUILDER_NAME") == "freebsd-386-gce101" { 20 | t.Skipf("Ignoring known failing test (golang.org/issue/15186). Failed with: %v", err) 21 | } 22 | t.Fatal(err) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix_test 8 | 9 | import ( 10 | "fmt" 11 | "testing" 12 | 13 | "golang.org/x/sys/unix" 14 | ) 15 | 16 | func testSetGetenv(t *testing.T, key, value string) { 17 | err := unix.Setenv(key, value) 18 | if err != nil { 19 | t.Fatalf("Setenv failed to set %q: %v", value, err) 20 | } 21 | newvalue, found := unix.Getenv(key) 22 | if !found { 23 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 24 | } 25 | if newvalue != value { 26 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 27 | } 28 | } 29 | 30 | func TestEnv(t *testing.T) { 31 | testSetGetenv(t, "TESTENV", "AVALUE") 32 | // make sure TESTENV gets set to "", not deleted 33 | testSetGetenv(t, "TESTENV", "") 34 | } 35 | 36 | func TestItoa(t *testing.T) { 37 | // Make most negative integer: 0x8000... 38 | i := 1 39 | for i<<1 != 0 { 40 | i <<= 1 41 | } 42 | if i >= 0 { 43 | t.Fatal("bad math") 44 | } 45 | s := unix.Itoa(i) 46 | f := fmt.Sprint(i) 47 | if s != f { 48 | t.Fatalf("itoa(%d) = %s, want %s", i, s, f) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-8 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-4 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/asm_windows_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-8 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build go1.4 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | func Unsetenv(key string) error { 13 | // This was added in Go 1.4. 14 | return syscall.Unsetenv(key) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/env_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/eventlog.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | const ( 10 | EVENTLOG_SUCCESS = 0 11 | EVENTLOG_ERROR_TYPE = 1 12 | EVENTLOG_WARNING_TYPE = 2 13 | EVENTLOG_INFORMATION_TYPE = 4 14 | EVENTLOG_AUDIT_SUCCESS = 8 15 | EVENTLOG_AUDIT_FAILURE = 16 16 | ) 17 | 18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW 19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource 20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/exec_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Fork, exec, wait, etc. 6 | 7 | package windows 8 | 9 | // EscapeArg rewrites command line argument s as prescribed 10 | // in http://msdn.microsoft.com/en-us/library/ms880421. 11 | // This function returns "" (2 double quotes) if s is empty. 12 | // Alternatively, these transformations are done: 13 | // - every back slash (\) is doubled, but only if immediately 14 | // followed by double quote ("); 15 | // - every double quote (") is escaped by back slash (\); 16 | // - finally, s is wrapped with double quotes (arg -> "arg"), 17 | // but only if there is space or tab inside s. 18 | func EscapeArg(s string) string { 19 | if len(s) == 0 { 20 | return "\"\"" 21 | } 22 | n := len(s) 23 | hasSpace := false 24 | for i := 0; i < len(s); i++ { 25 | switch s[i] { 26 | case '"', '\\': 27 | n++ 28 | case ' ', '\t': 29 | hasSpace = true 30 | } 31 | } 32 | if hasSpace { 33 | n += 2 34 | } 35 | if n == len(s) { 36 | return s 37 | } 38 | 39 | qs := make([]byte, n) 40 | j := 0 41 | if hasSpace { 42 | qs[j] = '"' 43 | j++ 44 | } 45 | slashes := 0 46 | for i := 0; i < len(s); i++ { 47 | switch s[i] { 48 | default: 49 | slashes = 0 50 | qs[j] = s[i] 51 | case '\\': 52 | slashes++ 53 | qs[j] = s[i] 54 | case '"': 55 | for ; slashes > 0; slashes-- { 56 | qs[j] = '\\' 57 | j++ 58 | } 59 | qs[j] = '\\' 60 | j++ 61 | qs[j] = s[i] 62 | } 63 | j++ 64 | } 65 | if hasSpace { 66 | for ; slashes > 0; slashes-- { 67 | qs[j] = '\\' 68 | j++ 69 | } 70 | qs[j] = '"' 71 | j++ 72 | } 73 | return string(qs[:j]) 74 | } 75 | 76 | func CloseOnExec(fd Handle) { 77 | SetHandleInformation(Handle(fd), HANDLE_FLAG_INHERIT, 0) 78 | } 79 | 80 | // FullPath retrieves the full path of the specified file. 81 | func FullPath(name string) (path string, err error) { 82 | p, err := UTF16PtrFromString(name) 83 | if err != nil { 84 | return "", err 85 | } 86 | n := uint32(100) 87 | for { 88 | buf := make([]uint16, n) 89 | n, err = GetFullPathName(p, uint32(len(buf)), &buf[0], nil) 90 | if err != nil { 91 | return "", err 92 | } 93 | if n <= uint32(len(buf)) { 94 | return UTF16ToString(buf[:n]), nil 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/mksyscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,race 6 | 7 | package windows 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows,!race 6 | 7 | package windows 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/registry/export_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package registry 8 | 9 | func (k Key) SetValue(name string, valtype uint32, data []byte) error { 10 | return k.setValue(name, valtype, data) 11 | } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/registry/mksyscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package registry 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go 8 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/registry/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package registry 8 | 9 | import "syscall" 10 | 11 | const ( 12 | _REG_OPTION_NON_VOLATILE = 0 13 | 14 | _REG_CREATED_NEW_KEY = 1 15 | _REG_OPENED_EXISTING_KEY = 2 16 | 17 | _ERROR_NO_MORE_ITEMS syscall.Errno = 259 18 | ) 19 | 20 | func LoadRegLoadMUIString() error { 21 | return procRegLoadMUIStringW.Find() 22 | } 23 | 24 | //sys regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) = advapi32.RegCreateKeyExW 25 | //sys regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) = advapi32.RegDeleteKeyW 26 | //sys regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) = advapi32.RegSetValueExW 27 | //sys regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegEnumValueW 28 | //sys regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) = advapi32.RegDeleteValueW 29 | //sys regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) = advapi32.RegLoadMUIStringW 30 | 31 | //sys expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) = kernel32.ExpandEnvironmentStringsW 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/debug/log.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package debug 8 | 9 | import ( 10 | "os" 11 | "strconv" 12 | ) 13 | 14 | // Log interface allows different log implementations to be used. 15 | type Log interface { 16 | Close() error 17 | Info(eid uint32, msg string) error 18 | Warning(eid uint32, msg string) error 19 | Error(eid uint32, msg string) error 20 | } 21 | 22 | // ConsoleLog provides access to the console. 23 | type ConsoleLog struct { 24 | Name string 25 | } 26 | 27 | // New creates new ConsoleLog. 28 | func New(source string) *ConsoleLog { 29 | return &ConsoleLog{Name: source} 30 | } 31 | 32 | // Close closes console log l. 33 | func (l *ConsoleLog) Close() error { 34 | return nil 35 | } 36 | 37 | func (l *ConsoleLog) report(kind string, eid uint32, msg string) error { 38 | s := l.Name + "." + kind + "(" + strconv.Itoa(int(eid)) + "): " + msg + "\n" 39 | _, err := os.Stdout.Write([]byte(s)) 40 | return err 41 | } 42 | 43 | // Info writes an information event msg with event id eid to the console l. 44 | func (l *ConsoleLog) Info(eid uint32, msg string) error { 45 | return l.report("info", eid, msg) 46 | } 47 | 48 | // Warning writes an warning event msg with event id eid to the console l. 49 | func (l *ConsoleLog) Warning(eid uint32, msg string) error { 50 | return l.report("warn", eid, msg) 51 | } 52 | 53 | // Error writes an error event msg with event id eid to the console l. 54 | func (l *ConsoleLog) Error(eid uint32, msg string) error { 55 | return l.report("error", eid, msg) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/debug/service.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package debug provides facilities to execute svc.Handler on console. 8 | // 9 | package debug 10 | 11 | import ( 12 | "os" 13 | "os/signal" 14 | "syscall" 15 | 16 | "golang.org/x/sys/windows/svc" 17 | ) 18 | 19 | // Run executes service name by calling appropriate handler function. 20 | // The process is running on console, unlike real service. Use Ctrl+C to 21 | // send "Stop" command to your service. 22 | func Run(name string, handler svc.Handler) error { 23 | cmds := make(chan svc.ChangeRequest) 24 | changes := make(chan svc.Status) 25 | 26 | sig := make(chan os.Signal) 27 | signal.Notify(sig) 28 | 29 | go func() { 30 | status := svc.Status{State: svc.Stopped} 31 | for { 32 | select { 33 | case <-sig: 34 | cmds <- svc.ChangeRequest{svc.Stop, status} 35 | case status = <-changes: 36 | } 37 | } 38 | }() 39 | 40 | _, errno := handler.Execute([]string{name}, cmds, changes) 41 | if errno != 0 { 42 | return syscall.Errno(errno) 43 | } 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/event.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package svc 8 | 9 | import ( 10 | "errors" 11 | 12 | "golang.org/x/sys/windows" 13 | ) 14 | 15 | // event represents auto-reset, initially non-signaled Windows event. 16 | // It is used to communicate between go and asm parts of this package. 17 | type event struct { 18 | h windows.Handle 19 | } 20 | 21 | func newEvent() (*event, error) { 22 | h, err := windows.CreateEvent(nil, 0, 0, nil) 23 | if err != nil { 24 | return nil, err 25 | } 26 | return &event{h: h}, nil 27 | } 28 | 29 | func (e *event) Close() error { 30 | return windows.CloseHandle(e.h) 31 | } 32 | 33 | func (e *event) Set() error { 34 | return windows.SetEvent(e.h) 35 | } 36 | 37 | func (e *event) Wait() error { 38 | s, err := windows.WaitForSingleObject(e.h, windows.INFINITE) 39 | switch s { 40 | case windows.WAIT_OBJECT_0: 41 | break 42 | case windows.WAIT_FAILED: 43 | return err 44 | default: 45 | return errors.New("unexpected result from WaitForSingleObject") 46 | } 47 | return nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/eventlog/install.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package eventlog 8 | 9 | import ( 10 | "errors" 11 | 12 | "golang.org/x/sys/windows" 13 | "golang.org/x/sys/windows/registry" 14 | ) 15 | 16 | const ( 17 | // Log levels. 18 | Info = windows.EVENTLOG_INFORMATION_TYPE 19 | Warning = windows.EVENTLOG_WARNING_TYPE 20 | Error = windows.EVENTLOG_ERROR_TYPE 21 | ) 22 | 23 | const addKeyName = `SYSTEM\CurrentControlSet\Services\EventLog\Application` 24 | 25 | // Install modifies PC registry to allow logging with an event source src. 26 | // It adds all required keys and values to the event log registry key. 27 | // Install uses msgFile as the event message file. If useExpandKey is true, 28 | // the event message file is installed as REG_EXPAND_SZ value, 29 | // otherwise as REG_SZ. Use bitwise of log.Error, log.Warning and 30 | // log.Info to specify events supported by the new event source. 31 | func Install(src, msgFile string, useExpandKey bool, eventsSupported uint32) error { 32 | appkey, err := registry.OpenKey(registry.LOCAL_MACHINE, addKeyName, registry.CREATE_SUB_KEY) 33 | if err != nil { 34 | return err 35 | } 36 | defer appkey.Close() 37 | 38 | sk, alreadyExist, err := registry.CreateKey(appkey, src, registry.SET_VALUE) 39 | if err != nil { 40 | return err 41 | } 42 | defer sk.Close() 43 | if alreadyExist { 44 | return errors.New(addKeyName + `\` + src + " registry key already exists") 45 | } 46 | 47 | err = sk.SetDWordValue("CustomSource", 1) 48 | if err != nil { 49 | return err 50 | } 51 | if useExpandKey { 52 | err = sk.SetExpandStringValue("EventMessageFile", msgFile) 53 | } else { 54 | err = sk.SetStringValue("EventMessageFile", msgFile) 55 | } 56 | if err != nil { 57 | return err 58 | } 59 | err = sk.SetDWordValue("TypesSupported", eventsSupported) 60 | if err != nil { 61 | return err 62 | } 63 | return nil 64 | } 65 | 66 | // InstallAsEventCreate is the same as Install, but uses 67 | // %SystemRoot%\System32\EventCreate.exe as the event message file. 68 | func InstallAsEventCreate(src string, eventsSupported uint32) error { 69 | return Install(src, "%SystemRoot%\\System32\\EventCreate.exe", true, eventsSupported) 70 | } 71 | 72 | // Remove deletes all registry elements installed by the correspondent Install. 73 | func Remove(src string) error { 74 | appkey, err := registry.OpenKey(registry.LOCAL_MACHINE, addKeyName, registry.SET_VALUE) 75 | if err != nil { 76 | return err 77 | } 78 | defer appkey.Close() 79 | return registry.DeleteKey(appkey, src) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/eventlog/log.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package eventlog implements access to Windows event log. 8 | // 9 | package eventlog 10 | 11 | import ( 12 | "errors" 13 | "syscall" 14 | 15 | "golang.org/x/sys/windows" 16 | ) 17 | 18 | // Log provides access to the system log. 19 | type Log struct { 20 | Handle windows.Handle 21 | } 22 | 23 | // Open retrieves a handle to the specified event log. 24 | func Open(source string) (*Log, error) { 25 | return OpenRemote("", source) 26 | } 27 | 28 | // OpenRemote does the same as Open, but on different computer host. 29 | func OpenRemote(host, source string) (*Log, error) { 30 | if source == "" { 31 | return nil, errors.New("Specify event log source") 32 | } 33 | var s *uint16 34 | if host != "" { 35 | s = syscall.StringToUTF16Ptr(host) 36 | } 37 | h, err := windows.RegisterEventSource(s, syscall.StringToUTF16Ptr(source)) 38 | if err != nil { 39 | return nil, err 40 | } 41 | return &Log{Handle: h}, nil 42 | } 43 | 44 | // Close closes event log l. 45 | func (l *Log) Close() error { 46 | return windows.DeregisterEventSource(l.Handle) 47 | } 48 | 49 | func (l *Log) report(etype uint16, eid uint32, msg string) error { 50 | ss := []*uint16{syscall.StringToUTF16Ptr(msg)} 51 | return windows.ReportEvent(l.Handle, etype, 0, eid, 0, 1, 0, &ss[0], nil) 52 | } 53 | 54 | // Info writes an information event msg with event id eid to the end of event log l. 55 | // When EventCreate.exe is used, eid must be between 1 and 1000. 56 | func (l *Log) Info(eid uint32, msg string) error { 57 | return l.report(windows.EVENTLOG_INFORMATION_TYPE, eid, msg) 58 | } 59 | 60 | // Warning writes an warning event msg with event id eid to the end of event log l. 61 | // When EventCreate.exe is used, eid must be between 1 and 1000. 62 | func (l *Log) Warning(eid uint32, msg string) error { 63 | return l.report(windows.EVENTLOG_WARNING_TYPE, eid, msg) 64 | } 65 | 66 | // Error writes an error event msg with event id eid to the end of event log l. 67 | // When EventCreate.exe is used, eid must be between 1 and 1000. 68 | func (l *Log) Error(eid uint32, msg string) error { 69 | return l.report(windows.EVENTLOG_ERROR_TYPE, eid, msg) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/eventlog/log_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package eventlog_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/sys/windows/svc/eventlog" 13 | ) 14 | 15 | func TestLog(t *testing.T) { 16 | if testing.Short() { 17 | t.Skip("skipping test in short mode - it modifies system logs") 18 | } 19 | 20 | const name = "mylog" 21 | const supports = eventlog.Error | eventlog.Warning | eventlog.Info 22 | err := eventlog.InstallAsEventCreate(name, supports) 23 | if err != nil { 24 | t.Fatalf("Install failed: %s", err) 25 | } 26 | defer func() { 27 | err = eventlog.Remove(name) 28 | if err != nil { 29 | t.Fatalf("Remove failed: %s", err) 30 | } 31 | }() 32 | 33 | l, err := eventlog.Open(name) 34 | if err != nil { 35 | t.Fatalf("Open failed: %s", err) 36 | } 37 | defer l.Close() 38 | 39 | err = l.Info(1, "info") 40 | if err != nil { 41 | t.Fatalf("Info failed: %s", err) 42 | } 43 | err = l.Warning(2, "warning") 44 | if err != nil { 45 | t.Fatalf("Warning failed: %s", err) 46 | } 47 | err = l.Error(3, "error") 48 | if err != nil { 49 | t.Fatalf("Error failed: %s", err) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/beep.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package main 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | // BUG(brainman): MessageBeep Windows api is broken on Windows 7, 14 | // so this example does not beep when runs as service on Windows 7. 15 | 16 | var ( 17 | beepFunc = syscall.MustLoadDLL("user32.dll").MustFindProc("MessageBeep") 18 | ) 19 | 20 | func beep() { 21 | beepFunc.Call(0xffffffff) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/install.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "os" 12 | "path/filepath" 13 | 14 | "golang.org/x/sys/windows/svc/eventlog" 15 | "golang.org/x/sys/windows/svc/mgr" 16 | ) 17 | 18 | func exePath() (string, error) { 19 | prog := os.Args[0] 20 | p, err := filepath.Abs(prog) 21 | if err != nil { 22 | return "", err 23 | } 24 | fi, err := os.Stat(p) 25 | if err == nil { 26 | if !fi.Mode().IsDir() { 27 | return p, nil 28 | } 29 | err = fmt.Errorf("%s is directory", p) 30 | } 31 | if filepath.Ext(p) == "" { 32 | p += ".exe" 33 | fi, err := os.Stat(p) 34 | if err == nil { 35 | if !fi.Mode().IsDir() { 36 | return p, nil 37 | } 38 | err = fmt.Errorf("%s is directory", p) 39 | } 40 | } 41 | return "", err 42 | } 43 | 44 | func installService(name, desc string) error { 45 | exepath, err := exePath() 46 | if err != nil { 47 | return err 48 | } 49 | m, err := mgr.Connect() 50 | if err != nil { 51 | return err 52 | } 53 | defer m.Disconnect() 54 | s, err := m.OpenService(name) 55 | if err == nil { 56 | s.Close() 57 | return fmt.Errorf("service %s already exists", name) 58 | } 59 | s, err = m.CreateService(name, exepath, mgr.Config{DisplayName: desc}, "is", "auto-started") 60 | if err != nil { 61 | return err 62 | } 63 | defer s.Close() 64 | err = eventlog.InstallAsEventCreate(name, eventlog.Error|eventlog.Warning|eventlog.Info) 65 | if err != nil { 66 | s.Delete() 67 | return fmt.Errorf("SetupEventLogSource() failed: %s", err) 68 | } 69 | return nil 70 | } 71 | 72 | func removeService(name string) error { 73 | m, err := mgr.Connect() 74 | if err != nil { 75 | return err 76 | } 77 | defer m.Disconnect() 78 | s, err := m.OpenService(name) 79 | if err != nil { 80 | return fmt.Errorf("service %s is not installed", name) 81 | } 82 | defer s.Close() 83 | err = s.Delete() 84 | if err != nil { 85 | return err 86 | } 87 | err = eventlog.Remove(name) 88 | if err != nil { 89 | return fmt.Errorf("RemoveEventLogSource() failed: %s", err) 90 | } 91 | return nil 92 | } 93 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Example service program that beeps. 8 | // 9 | // The program demonstrates how to create Windows service and 10 | // install / remove it on a computer. It also shows how to 11 | // stop / start / pause / continue any service, and how to 12 | // write to event log. It also shows how to use debug 13 | // facilities available in debug package. 14 | // 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | "log" 20 | "os" 21 | "strings" 22 | 23 | "golang.org/x/sys/windows/svc" 24 | ) 25 | 26 | func usage(errmsg string) { 27 | fmt.Fprintf(os.Stderr, 28 | "%s\n\n"+ 29 | "usage: %s \n"+ 30 | " where is one of\n"+ 31 | " install, remove, debug, start, stop, pause or continue.\n", 32 | errmsg, os.Args[0]) 33 | os.Exit(2) 34 | } 35 | 36 | func main() { 37 | const svcName = "myservice" 38 | 39 | isIntSess, err := svc.IsAnInteractiveSession() 40 | if err != nil { 41 | log.Fatalf("failed to determine if we are running in an interactive session: %v", err) 42 | } 43 | if !isIntSess { 44 | runService(svcName, false) 45 | return 46 | } 47 | 48 | if len(os.Args) < 2 { 49 | usage("no command specified") 50 | } 51 | 52 | cmd := strings.ToLower(os.Args[1]) 53 | switch cmd { 54 | case "debug": 55 | runService(svcName, true) 56 | return 57 | case "install": 58 | err = installService(svcName, "my service") 59 | case "remove": 60 | err = removeService(svcName) 61 | case "start": 62 | err = startService(svcName) 63 | case "stop": 64 | err = controlService(svcName, svc.Stop, svc.Stopped) 65 | case "pause": 66 | err = controlService(svcName, svc.Pause, svc.Paused) 67 | case "continue": 68 | err = controlService(svcName, svc.Continue, svc.Running) 69 | default: 70 | usage(fmt.Sprintf("invalid command %s", cmd)) 71 | } 72 | if err != nil { 73 | log.Fatalf("failed to %s %s: %v", cmd, svcName, err) 74 | } 75 | return 76 | } 77 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/manage.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "time" 12 | 13 | "golang.org/x/sys/windows/svc" 14 | "golang.org/x/sys/windows/svc/mgr" 15 | ) 16 | 17 | func startService(name string) error { 18 | m, err := mgr.Connect() 19 | if err != nil { 20 | return err 21 | } 22 | defer m.Disconnect() 23 | s, err := m.OpenService(name) 24 | if err != nil { 25 | return fmt.Errorf("could not access service: %v", err) 26 | } 27 | defer s.Close() 28 | err = s.Start("is", "manual-started") 29 | if err != nil { 30 | return fmt.Errorf("could not start service: %v", err) 31 | } 32 | return nil 33 | } 34 | 35 | func controlService(name string, c svc.Cmd, to svc.State) error { 36 | m, err := mgr.Connect() 37 | if err != nil { 38 | return err 39 | } 40 | defer m.Disconnect() 41 | s, err := m.OpenService(name) 42 | if err != nil { 43 | return fmt.Errorf("could not access service: %v", err) 44 | } 45 | defer s.Close() 46 | status, err := s.Control(c) 47 | if err != nil { 48 | return fmt.Errorf("could not send control=%d: %v", c, err) 49 | } 50 | timeout := time.Now().Add(10 * time.Second) 51 | for status.State != to { 52 | if timeout.Before(time.Now()) { 53 | return fmt.Errorf("timeout waiting for service to go to state=%d", to) 54 | } 55 | time.Sleep(300 * time.Millisecond) 56 | status, err = s.Query() 57 | if err != nil { 58 | return fmt.Errorf("could not retrieve service status: %v", err) 59 | } 60 | } 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/example/service.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package main 8 | 9 | import ( 10 | "fmt" 11 | "time" 12 | 13 | "golang.org/x/sys/windows/svc" 14 | "golang.org/x/sys/windows/svc/debug" 15 | "golang.org/x/sys/windows/svc/eventlog" 16 | ) 17 | 18 | var elog debug.Log 19 | 20 | type myservice struct{} 21 | 22 | func (m *myservice) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) { 23 | const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue 24 | changes <- svc.Status{State: svc.StartPending} 25 | fasttick := time.Tick(500 * time.Millisecond) 26 | slowtick := time.Tick(2 * time.Second) 27 | tick := fasttick 28 | changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} 29 | loop: 30 | for { 31 | select { 32 | case <-tick: 33 | beep() 34 | elog.Info(1, "beep") 35 | case c := <-r: 36 | switch c.Cmd { 37 | case svc.Interrogate: 38 | changes <- c.CurrentStatus 39 | // Testing deadlock from https://code.google.com/p/winsvc/issues/detail?id=4 40 | time.Sleep(100 * time.Millisecond) 41 | changes <- c.CurrentStatus 42 | case svc.Stop, svc.Shutdown: 43 | break loop 44 | case svc.Pause: 45 | changes <- svc.Status{State: svc.Paused, Accepts: cmdsAccepted} 46 | tick = slowtick 47 | case svc.Continue: 48 | changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} 49 | tick = fasttick 50 | default: 51 | elog.Error(1, fmt.Sprintf("unexpected control request #%d", c)) 52 | } 53 | } 54 | } 55 | changes <- svc.Status{State: svc.StopPending} 56 | return 57 | } 58 | 59 | func runService(name string, isDebug bool) { 60 | var err error 61 | if isDebug { 62 | elog = debug.New(name) 63 | } else { 64 | elog, err = eventlog.Open(name) 65 | if err != nil { 66 | return 67 | } 68 | } 69 | defer elog.Close() 70 | 71 | elog.Info(1, fmt.Sprintf("starting %s service", name)) 72 | run := svc.Run 73 | if isDebug { 74 | run = debug.Run 75 | } 76 | err = run(name, &myservice{}) 77 | if err != nil { 78 | elog.Error(1, fmt.Sprintf("%s service failed: %v", name, err)) 79 | return 80 | } 81 | elog.Info(1, fmt.Sprintf("%s service stopped", name)) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go12.c: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build !go1.3 7 | 8 | // copied from pkg/runtime 9 | typedef unsigned int uint32; 10 | typedef unsigned long long int uint64; 11 | #ifdef _64BIT 12 | typedef uint64 uintptr; 13 | #else 14 | typedef uint32 uintptr; 15 | #endif 16 | 17 | // from sys_386.s or sys_amd64.s 18 | void ·servicemain(void); 19 | 20 | void 21 | ·getServiceMain(uintptr *r) 22 | { 23 | *r = (uintptr)·servicemain; 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go12.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build !go1.3 7 | 8 | package svc 9 | 10 | // from go12.c 11 | func getServiceMain(r *uintptr) 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/go13.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build go1.3 7 | 8 | package svc 9 | 10 | import "unsafe" 11 | 12 | const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const 13 | 14 | // Should be a built-in for unsafe.Pointer? 15 | func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { 16 | return unsafe.Pointer(uintptr(p) + x) 17 | } 18 | 19 | // funcPC returns the entry PC of the function f. 20 | // It assumes that f is a func value. Otherwise the behavior is undefined. 21 | func funcPC(f interface{}) uintptr { 22 | return **(**uintptr)(add(unsafe.Pointer(&f), ptrSize)) 23 | } 24 | 25 | // from sys_386.s and sys_amd64.s 26 | func servicectlhandler(ctl uint32) uintptr 27 | func servicemain(argc uint32, argv **uint16) 28 | 29 | func getServiceMain(r *uintptr) { 30 | *r = funcPC(servicemain) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/mgr/service.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package mgr 8 | 9 | import ( 10 | "syscall" 11 | 12 | "golang.org/x/sys/windows" 13 | "golang.org/x/sys/windows/svc" 14 | ) 15 | 16 | // TODO(brainman): Use EnumDependentServices to enumerate dependent services. 17 | 18 | // TODO(brainman): Use EnumServicesStatus to enumerate services in the specified service control manager database. 19 | 20 | // Service is used to access Windows service. 21 | type Service struct { 22 | Name string 23 | Handle windows.Handle 24 | } 25 | 26 | // Delete marks service s for deletion from the service control manager database. 27 | func (s *Service) Delete() error { 28 | return windows.DeleteService(s.Handle) 29 | } 30 | 31 | // Close relinquish access to the service s. 32 | func (s *Service) Close() error { 33 | return windows.CloseServiceHandle(s.Handle) 34 | } 35 | 36 | // Start starts service s. 37 | // args will be passed to svc.Handler.Execute. 38 | func (s *Service) Start(args ...string) error { 39 | var p **uint16 40 | if len(args) > 0 { 41 | vs := make([]*uint16, len(args)) 42 | for i, _ := range vs { 43 | vs[i] = syscall.StringToUTF16Ptr(args[i]) 44 | } 45 | p = &vs[0] 46 | } 47 | return windows.StartService(s.Handle, uint32(len(args)), p) 48 | } 49 | 50 | // Control sends state change request c to the servce s. 51 | func (s *Service) Control(c svc.Cmd) (svc.Status, error) { 52 | var t windows.SERVICE_STATUS 53 | err := windows.ControlService(s.Handle, uint32(c), &t) 54 | if err != nil { 55 | return svc.Status{}, err 56 | } 57 | return svc.Status{ 58 | State: svc.State(t.CurrentState), 59 | Accepts: svc.Accepted(t.ControlsAccepted), 60 | }, nil 61 | } 62 | 63 | // Query returns current status of service s. 64 | func (s *Service) Query() (svc.Status, error) { 65 | var t windows.SERVICE_STATUS 66 | err := windows.QueryServiceStatus(s.Handle, &t) 67 | if err != nil { 68 | return svc.Status{}, err 69 | } 70 | return svc.Status{ 71 | State: svc.State(t.CurrentState), 72 | Accepts: svc.Accepted(t.ControlsAccepted), 73 | }, nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/security.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package svc 8 | 9 | import ( 10 | "unsafe" 11 | 12 | "golang.org/x/sys/windows" 13 | ) 14 | 15 | func allocSid(subAuth0 uint32) (*windows.SID, error) { 16 | var sid *windows.SID 17 | err := windows.AllocateAndInitializeSid(&windows.SECURITY_NT_AUTHORITY, 18 | 1, subAuth0, 0, 0, 0, 0, 0, 0, 0, &sid) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return sid, nil 23 | } 24 | 25 | // IsAnInteractiveSession determines if calling process is running interactively. 26 | // It queries the process token for membership in the Interactive group. 27 | // http://stackoverflow.com/questions/2668851/how-do-i-detect-that-my-application-is-running-as-service-or-in-an-interactive-s 28 | func IsAnInteractiveSession() (bool, error) { 29 | interSid, err := allocSid(windows.SECURITY_INTERACTIVE_RID) 30 | if err != nil { 31 | return false, err 32 | } 33 | defer windows.FreeSid(interSid) 34 | 35 | serviceSid, err := allocSid(windows.SECURITY_SERVICE_RID) 36 | if err != nil { 37 | return false, err 38 | } 39 | defer windows.FreeSid(serviceSid) 40 | 41 | t, err := windows.OpenCurrentProcessToken() 42 | if err != nil { 43 | return false, err 44 | } 45 | defer t.Close() 46 | 47 | gs, err := t.GetTokenGroups() 48 | if err != nil { 49 | return false, err 50 | } 51 | p := unsafe.Pointer(&gs.Groups[0]) 52 | groups := (*[2 << 20]windows.SIDAndAttributes)(p)[:gs.GroupCount] 53 | for _, g := range groups { 54 | if windows.EqualSid(g.Sid, interSid) { 55 | return true, nil 56 | } 57 | if windows.EqualSid(g.Sid, serviceSid) { 58 | return false, nil 59 | } 60 | } 61 | return false, nil 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/svc_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package svc_test 8 | 9 | import ( 10 | "io/ioutil" 11 | "os" 12 | "os/exec" 13 | "path/filepath" 14 | "testing" 15 | "time" 16 | 17 | "golang.org/x/sys/windows/svc" 18 | "golang.org/x/sys/windows/svc/mgr" 19 | ) 20 | 21 | func getState(t *testing.T, s *mgr.Service) svc.State { 22 | status, err := s.Query() 23 | if err != nil { 24 | t.Fatalf("Query(%s) failed: %s", s.Name, err) 25 | } 26 | return status.State 27 | } 28 | 29 | func testState(t *testing.T, s *mgr.Service, want svc.State) { 30 | have := getState(t, s) 31 | if have != want { 32 | t.Fatalf("%s state is=%d want=%d", s.Name, have, want) 33 | } 34 | } 35 | 36 | func waitState(t *testing.T, s *mgr.Service, want svc.State) { 37 | for i := 0; ; i++ { 38 | have := getState(t, s) 39 | if have == want { 40 | return 41 | } 42 | if i > 10 { 43 | t.Fatalf("%s state is=%d, waiting timeout", s.Name, have) 44 | } 45 | time.Sleep(300 * time.Millisecond) 46 | } 47 | } 48 | 49 | func TestExample(t *testing.T) { 50 | if testing.Short() { 51 | t.Skip("skipping test in short mode - it modifies system services") 52 | } 53 | 54 | const name = "myservice" 55 | 56 | m, err := mgr.Connect() 57 | if err != nil { 58 | t.Fatalf("SCM connection failed: %s", err) 59 | } 60 | defer m.Disconnect() 61 | 62 | dir, err := ioutil.TempDir("", "svc") 63 | if err != nil { 64 | t.Fatalf("failed to create temp directory: %v", err) 65 | } 66 | defer os.RemoveAll(dir) 67 | 68 | exepath := filepath.Join(dir, "a.exe") 69 | o, err := exec.Command("go", "build", "-o", exepath, "golang.org/x/sys/windows/svc/example").CombinedOutput() 70 | if err != nil { 71 | t.Fatalf("failed to build service program: %v\n%v", err, string(o)) 72 | } 73 | 74 | s, err := m.OpenService(name) 75 | if err == nil { 76 | err = s.Delete() 77 | if err != nil { 78 | s.Close() 79 | t.Fatalf("Delete failed: %s", err) 80 | } 81 | s.Close() 82 | } 83 | s, err = m.CreateService(name, exepath, mgr.Config{DisplayName: "my service"}, "is", "auto-started") 84 | if err != nil { 85 | t.Fatalf("CreateService(%s) failed: %v", name, err) 86 | } 87 | defer s.Close() 88 | 89 | testState(t, s, svc.Stopped) 90 | err = s.Start("is", "manual-started") 91 | if err != nil { 92 | t.Fatalf("Start(%s) failed: %s", s.Name, err) 93 | } 94 | waitState(t, s, svc.Running) 95 | time.Sleep(1 * time.Second) 96 | 97 | // testing deadlock from issues 4. 98 | _, err = s.Control(svc.Interrogate) 99 | if err != nil { 100 | t.Fatalf("Control(%s) failed: %s", s.Name, err) 101 | } 102 | _, err = s.Control(svc.Interrogate) 103 | if err != nil { 104 | t.Fatalf("Control(%s) failed: %s", s.Name, err) 105 | } 106 | time.Sleep(1 * time.Second) 107 | 108 | _, err = s.Control(svc.Stop) 109 | if err != nil { 110 | t.Fatalf("Control(%s) failed: %s", s.Name, err) 111 | } 112 | waitState(t, s, svc.Stopped) 113 | 114 | err = s.Delete() 115 | if err != nil { 116 | t.Fatalf("Delete failed: %s", err) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/sys_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // func servicemain(argc uint32, argv **uint16) 8 | TEXT ·servicemain(SB),7,$0 9 | MOVL argc+0(FP), AX 10 | MOVL AX, ·sArgc(SB) 11 | MOVL argv+4(FP), AX 12 | MOVL AX, ·sArgv(SB) 13 | 14 | PUSHL BP 15 | PUSHL BX 16 | PUSHL SI 17 | PUSHL DI 18 | 19 | SUBL $12, SP 20 | 21 | MOVL ·sName(SB), AX 22 | MOVL AX, (SP) 23 | MOVL $·servicectlhandler(SB), AX 24 | MOVL AX, 4(SP) 25 | MOVL ·cRegisterServiceCtrlHandlerW(SB), AX 26 | MOVL SP, BP 27 | CALL AX 28 | MOVL BP, SP 29 | CMPL AX, $0 30 | JE exit 31 | MOVL AX, ·ssHandle(SB) 32 | 33 | MOVL ·goWaitsH(SB), AX 34 | MOVL AX, (SP) 35 | MOVL ·cSetEvent(SB), AX 36 | MOVL SP, BP 37 | CALL AX 38 | MOVL BP, SP 39 | 40 | MOVL ·cWaitsH(SB), AX 41 | MOVL AX, (SP) 42 | MOVL $-1, AX 43 | MOVL AX, 4(SP) 44 | MOVL ·cWaitForSingleObject(SB), AX 45 | MOVL SP, BP 46 | CALL AX 47 | MOVL BP, SP 48 | 49 | exit: 50 | ADDL $12, SP 51 | 52 | POPL DI 53 | POPL SI 54 | POPL BX 55 | POPL BP 56 | 57 | MOVL 0(SP), CX 58 | ADDL $12, SP 59 | JMP CX 60 | 61 | // I do not know why, but this seems to be the only way to call 62 | // ctlHandlerProc on Windows 7. 63 | 64 | // func servicectlhandler(ctl uint32) uintptr 65 | TEXT ·servicectlhandler(SB),7,$0 66 | MOVL ·ctlHandlerProc(SB), CX 67 | JMP CX 68 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/svc/sys_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // func servicemain(argc uint32, argv **uint16) 8 | TEXT ·servicemain(SB),7,$0 9 | MOVL CX, ·sArgc(SB) 10 | MOVL DX, ·sArgv(SB) 11 | 12 | SUBQ $32, SP // stack for the first 4 syscall params 13 | 14 | MOVQ ·sName(SB), CX 15 | MOVQ $·servicectlhandler(SB), DX 16 | MOVQ ·cRegisterServiceCtrlHandlerW(SB), AX 17 | CALL AX 18 | CMPQ AX, $0 19 | JE exit 20 | MOVQ AX, ·ssHandle(SB) 21 | 22 | MOVQ ·goWaitsH(SB), CX 23 | MOVQ ·cSetEvent(SB), AX 24 | CALL AX 25 | 26 | MOVQ ·cWaitsH(SB), CX 27 | MOVQ $4294967295, DX 28 | MOVQ ·cWaitForSingleObject(SB), AX 29 | CALL AX 30 | 31 | exit: 32 | ADDQ $32, SP 33 | RET 34 | 35 | // I do not know why, but this seems to be the only way to call 36 | // ctlHandlerProc on Windows 7. 37 | 38 | // func servicectlhandler(ctl uint32) uintptr 39 | TEXT ·servicectlhandler(SB),7,$0 40 | MOVQ ·ctlHandlerProc(SB), AX 41 | JMP AX 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | // Package windows contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display the OS-specific documentation for the current 10 | // system. If you want godoc to display syscall documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package windows // import "golang.org/x/sys/windows" 23 | 24 | import ( 25 | "syscall" 26 | ) 27 | 28 | // ByteSliceFromString returns a NUL-terminated slice of bytes 29 | // containing the text of s. If s contains a NUL byte at any 30 | // location, it returns (nil, syscall.EINVAL). 31 | func ByteSliceFromString(s string) ([]byte, error) { 32 | for i := 0; i < len(s); i++ { 33 | if s[i] == 0 { 34 | return nil, syscall.EINVAL 35 | } 36 | } 37 | a := make([]byte, len(s)+1) 38 | copy(a, s) 39 | return a, nil 40 | } 41 | 42 | // BytePtrFromString returns a pointer to a NUL-terminated array of 43 | // bytes containing the text of s. If s contains a NUL byte at any 44 | // location, it returns (nil, syscall.EINVAL). 45 | func BytePtrFromString(s string) (*byte, error) { 46 | a, err := ByteSliceFromString(s) 47 | if err != nil { 48 | return nil, err 49 | } 50 | return &a[0], nil 51 | } 52 | 53 | // Single-word zero for use when we need a valid pointer to 0 bytes. 54 | // See mksyscall.pl. 55 | var _zero uintptr 56 | 57 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 58 | return int64(ts.Sec), int64(ts.Nsec) 59 | } 60 | 61 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 62 | return int64(tv.Sec), int64(tv.Usec) * 1000 63 | } 64 | 65 | func (ts *Timespec) Nano() int64 { 66 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 67 | } 68 | 69 | func (tv *Timeval) Nano() int64 { 70 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 71 | } 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/syscall_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | 7 | package windows_test 8 | 9 | import ( 10 | "testing" 11 | 12 | "golang.org/x/sys/windows" 13 | ) 14 | 15 | func testSetGetenv(t *testing.T, key, value string) { 16 | err := windows.Setenv(key, value) 17 | if err != nil { 18 | t.Fatalf("Setenv failed to set %q: %v", value, err) 19 | } 20 | newvalue, found := windows.Getenv(key) 21 | if !found { 22 | t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 23 | } 24 | if newvalue != value { 25 | t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 26 | } 27 | } 28 | 29 | func TestEnv(t *testing.T) { 30 | testSetGetenv(t, "TESTENV", "AVALUE") 31 | // make sure TESTENV gets set to "", not deleted 32 | testSetGetenv(t, "TESTENV", "") 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/syscall_windows_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows_test 6 | 7 | import ( 8 | "io/ioutil" 9 | "os" 10 | "path/filepath" 11 | "syscall" 12 | "testing" 13 | "unsafe" 14 | 15 | "golang.org/x/sys/windows" 16 | ) 17 | 18 | func TestWin32finddata(t *testing.T) { 19 | dir, err := ioutil.TempDir("", "go-build") 20 | if err != nil { 21 | t.Fatalf("failed to create temp directory: %v", err) 22 | } 23 | defer os.RemoveAll(dir) 24 | 25 | path := filepath.Join(dir, "long_name.and_extension") 26 | f, err := os.Create(path) 27 | if err != nil { 28 | t.Fatalf("failed to create %v: %v", path, err) 29 | } 30 | f.Close() 31 | 32 | type X struct { 33 | fd windows.Win32finddata 34 | got byte 35 | pad [10]byte // to protect ourselves 36 | 37 | } 38 | var want byte = 2 // it is unlikely to have this character in the filename 39 | x := X{got: want} 40 | 41 | pathp, _ := windows.UTF16PtrFromString(path) 42 | h, err := windows.FindFirstFile(pathp, &(x.fd)) 43 | if err != nil { 44 | t.Fatalf("FindFirstFile failed: %v", err) 45 | } 46 | err = windows.FindClose(h) 47 | if err != nil { 48 | t.Fatalf("FindClose failed: %v", err) 49 | } 50 | 51 | if x.got != want { 52 | t.Fatalf("memory corruption: want=%d got=%d", want, x.got) 53 | } 54 | } 55 | 56 | func TestFormatMessage(t *testing.T) { 57 | dll := windows.MustLoadDLL("pdh.dll") 58 | 59 | pdhOpenQuery := func(datasrc *uint16, userdata uint32, query *windows.Handle) (errno uintptr) { 60 | r0, _, _ := syscall.Syscall(dll.MustFindProc("PdhOpenQueryW").Addr(), 3, uintptr(unsafe.Pointer(datasrc)), uintptr(userdata), uintptr(unsafe.Pointer(query))) 61 | return r0 62 | } 63 | 64 | pdhCloseQuery := func(query windows.Handle) (errno uintptr) { 65 | r0, _, _ := syscall.Syscall(dll.MustFindProc("PdhCloseQuery").Addr(), 1, uintptr(query), 0, 0) 66 | return r0 67 | } 68 | 69 | var q windows.Handle 70 | name, err := windows.UTF16PtrFromString("no_such_source") 71 | if err != nil { 72 | t.Fatal(err) 73 | } 74 | errno := pdhOpenQuery(name, 0, &q) 75 | if errno == 0 { 76 | pdhCloseQuery(q) 77 | t.Fatal("PdhOpenQuery succeeded, but expected to fail.") 78 | } 79 | 80 | const flags uint32 = syscall.FORMAT_MESSAGE_FROM_HMODULE | syscall.FORMAT_MESSAGE_ARGUMENT_ARRAY | syscall.FORMAT_MESSAGE_IGNORE_INSERTS 81 | buf := make([]uint16, 300) 82 | _, err = windows.FormatMessage(flags, uintptr(dll.Handle), uint32(errno), 0, buf, nil) 83 | if err != nil { 84 | t.Fatal("FormatMessage for handle=%x and errno=%x failed: %v", dll.Handle, errno, err) 85 | } 86 | } 87 | 88 | func abort(funcname string, err error) { 89 | panic(funcname + " failed: " + err.Error()) 90 | } 91 | 92 | func ExampleLoadLibrary() { 93 | h, err := windows.LoadLibrary("kernel32.dll") 94 | if err != nil { 95 | abort("LoadLibrary", err) 96 | } 97 | defer windows.FreeLibrary(h) 98 | proc, err := windows.GetProcAddress(h, "GetVersion") 99 | if err != nil { 100 | abort("GetProcAddress", err) 101 | } 102 | r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0, 0) 103 | major := byte(r) 104 | minor := uint8(r >> 8) 105 | build := uint16(r >> 16) 106 | print("windows version ", major, ".", minor, " (Build ", build, ")\n") 107 | } 108 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/ztypes_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/windows/ztypes_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | --------------------------------------------------------------------------------