]> source.dussan.org Git - gitea.git/commitdiff
Handle CORS requests (#6289)
authorTamal Saha <tamal@appscode.com>
Mon, 13 May 2019 15:38:53 +0000 (08:38 -0700)
committertechknowlogick <techknowlogick@gitea.io>
Mon, 13 May 2019 15:38:53 +0000 (11:38 -0400)
171 files changed:
custom/conf/app.ini.sample
docs/content/doc/advanced/config-cheat-sheet.en-us.md
go.mod
go.sum
integrations/cors_test.go [new file with mode: 0644]
modules/setting/cors.go [new file with mode: 0644]
modules/setting/setting.go
routers/api/v1/api.go
vendor/github.com/Unknwon/com/dir.go
vendor/github.com/Unknwon/com/go.mod [new file with mode: 0644]
vendor/github.com/Unknwon/com/go.sum [new file with mode: 0644]
vendor/github.com/Unknwon/com/html.go
vendor/github.com/Unknwon/com/http.go
vendor/github.com/Unknwon/com/math.go
vendor/github.com/Unknwon/com/regex.go
vendor/github.com/Unknwon/com/slice.go
vendor/github.com/go-macaron/cors/.gitignore [new file with mode: 0644]
vendor/github.com/go-macaron/cors/LICENSE [new file with mode: 0644]
vendor/github.com/go-macaron/cors/README.md [new file with mode: 0644]
vendor/github.com/go-macaron/cors/cors.go [new file with mode: 0644]
vendor/github.com/go-macaron/cors/go.mod [new file with mode: 0644]
vendor/github.com/go-macaron/cors/go.sum [new file with mode: 0644]
vendor/golang.org/x/crypto/acme/acme.go
vendor/golang.org/x/crypto/acme/autocert/autocert.go
vendor/golang.org/x/crypto/acme/jws.go
vendor/golang.org/x/crypto/blowfish/cipher.go
vendor/golang.org/x/crypto/cast5/cast5.go
vendor/golang.org/x/crypto/curve25519/curve25519.go
vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s
vendor/golang.org/x/crypto/curve25519/mul_amd64.s
vendor/golang.org/x/crypto/curve25519/square_amd64.s
vendor/golang.org/x/crypto/internal/chacha20/asm_arm64.s [new file with mode: 0644]
vendor/golang.org/x/crypto/internal/chacha20/chacha_arm64.go [new file with mode: 0644]
vendor/golang.org/x/crypto/internal/chacha20/chacha_noasm.go
vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.go
vendor/golang.org/x/crypto/internal/chacha20/chacha_s390x.s
vendor/golang.org/x/crypto/md4/md4.go
vendor/golang.org/x/crypto/openpgp/keys.go
vendor/golang.org/x/crypto/openpgp/packet/packet.go
vendor/golang.org/x/crypto/openpgp/packet/private_key.go
vendor/golang.org/x/crypto/openpgp/packet/signature.go
vendor/golang.org/x/crypto/openpgp/packet/userattribute.go
vendor/golang.org/x/crypto/openpgp/write.go
vendor/golang.org/x/crypto/poly1305/mac_noasm.go [new file with mode: 0644]
vendor/golang.org/x/crypto/poly1305/poly1305.go
vendor/golang.org/x/crypto/poly1305/sum_amd64.go
vendor/golang.org/x/crypto/poly1305/sum_amd64.s
vendor/golang.org/x/crypto/poly1305/sum_generic.go [new file with mode: 0644]
vendor/golang.org/x/crypto/poly1305/sum_noasm.go
vendor/golang.org/x/crypto/poly1305/sum_ref.go [deleted file]
vendor/golang.org/x/crypto/poly1305/sum_s390x.go
vendor/golang.org/x/crypto/poly1305/sum_s390x.s
vendor/golang.org/x/crypto/poly1305/sum_vmsl_s390x.s
vendor/golang.org/x/crypto/ssh/agent/client.go
vendor/golang.org/x/crypto/ssh/agent/keyring.go
vendor/golang.org/x/crypto/ssh/agent/server.go
vendor/golang.org/x/crypto/ssh/certs.go
vendor/golang.org/x/crypto/ssh/cipher.go
vendor/golang.org/x/crypto/ssh/client.go
vendor/golang.org/x/crypto/ssh/common.go
vendor/golang.org/x/crypto/ssh/handshake.go
vendor/golang.org/x/crypto/ssh/keys.go
vendor/golang.org/x/crypto/ssh/knownhosts/knownhosts.go
vendor/golang.org/x/crypto/ssh/messages.go
vendor/golang.org/x/crypto/ssh/server.go
vendor/golang.org/x/crypto/ssh/transport.go
vendor/golang.org/x/sys/cpu/byteorder.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_aix_ppc64.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_arm.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_gc_x86.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_gccgo.c [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_gccgo.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_linux.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_mips64x.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_mipsx.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_other_arm64.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_s390x.s [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_wasm.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_x86.go [new file with mode: 0644]
vendor/golang.org/x/sys/cpu/cpu_x86.s [new file with mode: 0644]
vendor/golang.org/x/sys/unix/mkall.sh
vendor/golang.org/x/sys/unix/mkerrors.sh
vendor/golang.org/x/sys/unix/mksyscall.go
vendor/golang.org/x/sys/unix/sockcmsg_unix.go
vendor/golang.org/x/sys/unix/syscall_aix.go
vendor/golang.org/x/sys/unix/syscall_darwin.go
vendor/golang.org/x/sys/unix/syscall_linux.go
vendor/golang.org/x/sys/unix/syscall_linux_arm.go
vendor/golang.org/x/sys/unix/syscall_linux_arm64.go
vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go
vendor/golang.org/x/sys/unix/syscall_openbsd.go
vendor/golang.org/x/sys/unix/syscall_unix.go
vendor/golang.org/x/sys/unix/types_darwin.go
vendor/golang.org/x/sys/unix/types_openbsd.go
vendor/golang.org/x/sys/unix/zerrors_linux_386.go
vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go
vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go
vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go
vendor/golang.org/x/sys/unix/zsyscall_linux_386.go
vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go
vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go
vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go
vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go
vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go
vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go
vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go
vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go
vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go
vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go
vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go
vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go
vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
vendor/golang.org/x/sys/unix/ztypes_darwin_386.go
vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go
vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
vendor/golang.org/x/sys/unix/ztypes_linux_386.go
vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go
vendor/golang.org/x/sys/unix/ztypes_linux_arm.go
vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go
vendor/golang.org/x/sys/unix/ztypes_linux_mips.go
vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go
vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go
vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go
vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go
vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go
vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go
vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go
vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go
vendor/golang.org/x/sys/unix/ztypes_openbsd_386.go
vendor/golang.org/x/sys/unix/ztypes_openbsd_amd64.go
vendor/golang.org/x/sys/unix/ztypes_openbsd_arm.go
vendor/golang.org/x/sys/windows/dll_windows.go
vendor/golang.org/x/sys/windows/security_windows.go
vendor/golang.org/x/sys/windows/svc/service.go
vendor/golang.org/x/sys/windows/svc/sys_386.s
vendor/golang.org/x/sys/windows/svc/sys_amd64.s
vendor/golang.org/x/sys/windows/syscall_windows.go
vendor/golang.org/x/sys/windows/types_windows.go
vendor/golang.org/x/sys/windows/zsyscall_windows.go
vendor/gopkg.in/ini.v1/.travis.yml
vendor/gopkg.in/ini.v1/Makefile
vendor/gopkg.in/ini.v1/README.md
vendor/gopkg.in/ini.v1/README_ZH.md [deleted file]
vendor/gopkg.in/ini.v1/file.go
vendor/gopkg.in/ini.v1/ini.go
vendor/gopkg.in/ini.v1/key.go
vendor/gopkg.in/ini.v1/parser.go
vendor/gopkg.in/ini.v1/section.go
vendor/gopkg.in/ini.v1/struct.go
vendor/modules.txt

index 6f7844962b4409a6c2cff28b2d326757f08e1ab2..599569464c3f8a1ea45704902944a614014de063 100644 (file)
@@ -74,6 +74,23 @@ WORK_IN_PROGRESS_PREFIXES=WIP:,[WIP]
 ; List of reasons why a Pull Request or Issue can be locked
 LOCK_REASONS=Too heated,Off-topic,Resolved,Spam
 
+[cors]
+; More information about CORS can be found here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#The_HTTP_response_headers
+; enable cors headers (disabled by default)
+ENABLED=false
+; scheme of allowed requests
+SCHEME=http
+; list of requesting domains that are allowed
+ALLOW_DOMAIN=*
+; allow subdomains of headers listed above to request
+ALLOW_SUBDOMAIN=false
+; list of methods allowed to request
+METHODS=GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS
+; max time to cache response
+MAX_AGE=10m
+; allow request with credentials
+ALLOW_CREDENTIALS=false
+
 [ui]
 ; Number of repositories that are displayed on one explore page
 EXPLORE_PAGING_NUM = 20
index 87a92eb60d3956ed0729fb2148e696f63dfb84e9..6b209b97bb603382262070ad20ea3219c62680c9 100644 (file)
@@ -76,6 +76,16 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
 
 - `LOCK_REASONS`: **Too heated,Off-topic,Resolved,Spam**: A list of reasons why a Pull Request or Issue can be locked
 
+## CORS (`cors`)
+
+- `ENABLED`: **false**: enable cors headers (disabled by default)
+- `SCHEME`: **http**: scheme of allowed requests
+- `ALLOW_DOMAIN`: **\***: list of requesting domains that are allowed
+- `ALLOW_SUBDOMAIN`: **false**: allow subdomains of headers listed above to request
+- `METHODS`: **GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS**: list of methods allowed to request
+- `MAX_AGE`: **10m**: max time to cache response
+- `ALLOW_CREDENTIALS`: **false**: allow request with credentials
+
 ## UI (`ui`)
 
 - `EXPLORE_PAGING_NUM`: **20**: Number of repositories that are shown in one explore page.
diff --git a/go.mod b/go.mod
index 45f62e676b1b33babf8cf31f8cbcfd9c57cecd6a..d02765fb10f44c35a2a9f1636b6aa1cc3ce039bc 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@ require (
        github.com/PuerkitoBio/goquery v0.0.0-20170324135448-ed7d758e9a34
        github.com/RoaringBitmap/roaring v0.4.7 // indirect
        github.com/Unknwon/cae v0.0.0-20160715032808-c6aac99ea2ca
-       github.com/Unknwon/com v0.0.0-20170819223952-7677a1d7c113
+       github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755
        github.com/Unknwon/i18n v0.0.0-20171114194641-b64d33658966
        github.com/Unknwon/paginater v0.0.0-20151104151617-7748a72e0141
        github.com/andybalholm/cascadia v0.0.0-20161224141413-349dd0209470 // indirect
@@ -48,6 +48,7 @@ require (
        github.com/go-macaron/binding v0.0.0-20160711225916-9440f336b443
        github.com/go-macaron/cache v0.0.0-20151013081102-561735312776
        github.com/go-macaron/captcha v0.0.0-20151123225153-8aa5919789ab
+       github.com/go-macaron/cors v0.0.0-20190309005821-6fd6a9bfe14e9
        github.com/go-macaron/csrf v0.0.0-20180426211211-503617c6b372
        github.com/go-macaron/i18n v0.0.0-20160612092837-ef57533c3b0f
        github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191
@@ -113,17 +114,17 @@ require (
        github.com/willf/bitset v0.0.0-20180426185212-8ce1146b8621 // indirect
        github.com/yohcop/openid-go v0.0.0-20160914080427-2c050d2dae53
        go.etcd.io/bbolt v1.3.2 // indirect
-       golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
+       golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480
        golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519
        golang.org/x/oauth2 v0.0.0-20181101160152-c453e0c75759
-       golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
+       golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e
        golang.org/x/text v0.3.0
        gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
        gopkg.in/asn1-ber.v1 v1.0.0-20150924051756-4e86f4367175 // indirect
        gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e // indirect
        gopkg.in/editorconfig/editorconfig-core-go.v1 v1.2.0
        gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
-       gopkg.in/ini.v1 v1.31.1
+       gopkg.in/ini.v1 v1.42.0
        gopkg.in/ldap.v3 v3.0.2
        gopkg.in/macaron.v1 v1.3.2
        gopkg.in/redis.v2 v2.3.2 // indirect
@@ -135,6 +136,6 @@ require (
 )
 
 replace (
-       github.com/denisenkom/go-mssqldb v0.0.0-20181014144952-4e0d7dc8888f => github.com/denisenkom/go-mssqldb v0.0.0-20161128230840-e32ca5036449
-       github.com/go-sql-driver/mysql v1.4.0 => github.com/go-sql-driver/mysql v0.0.0-20181218123637-c45f530f8e7f
+       github.com/denisenkom/go-mssqldb => github.com/denisenkom/go-mssqldb v0.0.0-20161128230840-e32ca5036449
+       github.com/go-sql-driver/mysql => github.com/go-sql-driver/mysql v0.0.0-20181218123637-c45f530f8e7f
 )
diff --git a/go.sum b/go.sum
index df3c606eb44ce38919bb6f1e72278f3b41e02b14..6b0a59d5b513839eed8886e97619df2e0731ed14 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -7,8 +7,8 @@ github.com/RoaringBitmap/roaring v0.4.7 h1:eGUudvFzvF7Kxh7JjYvXfI1f7l22/2duFby7r
 github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w=
 github.com/Unknwon/cae v0.0.0-20160715032808-c6aac99ea2ca h1:xU8R31tsvj6TesCBog973+UgI3TXjh/LqN5clki6hcc=
 github.com/Unknwon/cae v0.0.0-20160715032808-c6aac99ea2ca/go.mod h1:IRSre9/SEhVuy972TVuJLyaPTS73+8Owhe0Y0l9NXHc=
-github.com/Unknwon/com v0.0.0-20170819223952-7677a1d7c113 h1:YwXm6KwmrA5R5yJRhcnpqRUHmBXSKciHuWtK9zP5qKQ=
-github.com/Unknwon/com v0.0.0-20170819223952-7677a1d7c113/go.mod h1:KYCjqMOeHpNuTOiFQU6WEcTG7poCJrUs0YgyHNtn1no=
+github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755 h1:1B7wb36fHLSwZfHg6ngZhhtIEHQjiC5H4p7qQGBEffg=
+github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755/go.mod h1:voKvFVpXBJxdIPeqjoJuLK+UVcRlo/JLjeToGxPYu68=
 github.com/Unknwon/i18n v0.0.0-20171114194641-b64d33658966 h1:Mp8GNJ/tdTZIEdLdZfykEJaL3mTyEYrSzYNcdoQKpJk=
 github.com/Unknwon/i18n v0.0.0-20171114194641-b64d33658966/go.mod h1:SFtfq0zFPsENI7DpE87QM2hcYu5QQ0fRdCgP+P1Hrqo=
 github.com/Unknwon/paginater v0.0.0-20151104151617-7748a72e0141 h1:SSvHGK7iMpeypcHjI8UzNMz7zW/K8/dcgqk/82lCYP0=
@@ -105,6 +105,8 @@ github.com/go-macaron/cache v0.0.0-20151013081102-561735312776 h1:UYIHS1r0WotqB5
 github.com/go-macaron/cache v0.0.0-20151013081102-561735312776/go.mod h1:hHAsZm/oBZVcY+S7qdQL6Vbg5VrXF6RuKGuqsszt3Ok=
 github.com/go-macaron/captcha v0.0.0-20151123225153-8aa5919789ab h1:4VFhsA3GE5Wwq1Ymr8KWCmrOWi1wRLEgdj48LPfQjxI=
 github.com/go-macaron/captcha v0.0.0-20151123225153-8aa5919789ab/go.mod h1:j9TJ+0nwUOWBvNnm0bheHIPFf3cC62EQo7n7O6PbjZA=
+github.com/go-macaron/cors v0.0.0-20190309005821-6fd6a9bfe14e9 h1:A0QGzY6UHHEil0I2e7C21JenNNG0mmrj5d9SFWTlgr8=
+github.com/go-macaron/cors v0.0.0-20190309005821-6fd6a9bfe14e9/go.mod h1:utmMRnVIrXPSfA9MFcpIYKEpKawjKxf62vv62k4707E=
 github.com/go-macaron/csrf v0.0.0-20180426211211-503617c6b372 h1:acrx8CnDmlKl+BPoOOLEK9Ko+SrWFB5pxRuGkKj4iqo=
 github.com/go-macaron/csrf v0.0.0-20180426211211-503617c6b372/go.mod h1:oZGMxI7MBnicI0jJqJvH4qQzyrWKhtiKxLSJKHC+ydc=
 github.com/go-macaron/i18n v0.0.0-20160612092837-ef57533c3b0f h1:wDKrZFc9pYJlqFOf7EzGbFMrSFFtyHt3plr2uTdo8Rg=
@@ -148,6 +150,8 @@ github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASu
 github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
+github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
 github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
 github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
 github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk=
@@ -178,6 +182,7 @@ github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U
 github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
 github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
 github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
+github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
 github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
 github.com/kballard/go-shellquote v0.0.0-20170619183022-cd60e84ee657 h1:vE7J1m7cCpiRVEIr1B5ccDxRpbPsWT5JU3if2Di5nE4=
@@ -281,6 +286,9 @@ github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d h1:qQWKKOvHN7
 github.com/siddontang/go-snappy v0.0.0-20140704025258-d8f7bb82a96d/go.mod h1:vq0tzqLRu6TS7Id0wMo2N5QzJoKedVeovOpHjnykSzY=
 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
 github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff h1:86HlEv0yBCry9syNuylzqznKXDK11p6D0DT596yNMys=
 github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs=
 github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4=
@@ -316,6 +324,8 @@ go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
 golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
 golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
 golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 h1:O5YqonU5IWby+w98jVUG9h7zlCWCcH4RHyPVReBmhzk=
+golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -332,6 +342,8 @@ golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5h
 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
 golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e h1:nFYrTHrdrAOpShe27kaFHjsqYSEQ0KWqdWLu3xuZJts=
+golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -353,8 +365,8 @@ gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
 gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
 gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
-gopkg.in/ini.v1 v1.31.1 h1:8EY/6KDwKM9Qg4vu1+01ZpsxClC/XV71R+nZ/TL7D4M=
-gopkg.in/ini.v1 v1.31.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk=
+gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/ldap.v3 v3.0.2 h1:R6RBtabK6e1GO0eQKtkyOFbAHO73QesLzI2w2DZ6b9w=
 gopkg.in/ldap.v3 v3.0.2/go.mod h1:oxD7NyBuxchC+SgJDE1Q5Od05eGt29SDQVBmV+HYbzw=
 gopkg.in/macaron.v1 v1.3.2 h1:AvWIaPmwBUA87/OWzePkoxeaw6YJWDfBt1pDFPBnLf8=
diff --git a/integrations/cors_test.go b/integrations/cors_test.go
new file mode 100644 (file)
index 0000000..02b6b9d
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package integrations
+
+import (
+       "net/http"
+       "testing"
+
+       "github.com/stretchr/testify/assert"
+)
+
+func TestCORSNotSet(t *testing.T) {
+       prepareTestEnv(t)
+       req := NewRequestf(t, "GET", "/api/v1/version")
+       session := loginUser(t, "user2")
+       resp := session.MakeRequest(t, req, http.StatusOK)
+       assert.Equal(t, resp.Code, http.StatusOK)
+       corsHeader := resp.Header().Get("Access-Control-Allow-Origin")
+       assert.Equal(t, corsHeader, "", "Access-Control-Allow-Origin: generated header should match") // header not set
+}
diff --git a/modules/setting/cors.go b/modules/setting/cors.go
new file mode 100644 (file)
index 0000000..c1c3bfb
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package setting
+
+import (
+       "time"
+
+       "code.gitea.io/gitea/modules/log"
+
+       "github.com/go-macaron/cors"
+)
+
+var (
+       // CORSConfig defines CORS settings
+       CORSConfig cors.Options
+       // EnableCORS defines whether CORS settings is enabled or not
+       EnableCORS bool
+)
+
+func newCORSService() {
+       sec := Cfg.Section("cors")
+       // Check cors setting.
+       EnableCORS = sec.Key("ENABLED").MustBool(false)
+
+       maxAge := sec.Key("MAX_AGE").MustDuration(10 * time.Minute)
+
+       CORSConfig = cors.Options{
+               Scheme:           sec.Key("SCHEME").String(),
+               AllowDomain:      sec.Key("ALLOW_DOMAIN").String(),
+               AllowSubdomain:   sec.Key("ALLOW_SUBDOMAIN").MustBool(),
+               Methods:          sec.Key("METHODS").Strings(","),
+               MaxAgeSeconds:    int(maxAge.Seconds()),
+               AllowCredentials: sec.Key("ALLOW_CREDENTIALS").MustBool(),
+       }
+
+       if EnableCORS {
+               log.Info("CORS Service Enabled")
+       }
+}
index 687f01bc2963320ee41f2cba02e7ddde0f75e387..d7f361c01e88fcf1dbca93c5d95181545bb6580f 100644 (file)
@@ -1006,6 +1006,7 @@ func NewServices() {
        NewLogServices(false)
        newCacheService()
        newSessionService()
+       newCORSService()
        newMailService()
        newRegisterMailService()
        newNotifyMailService()
index dfe705f7a8b114b1d5853aa05cd6f3dd8f1916f1..ae64e887caabd0a88f61163004429deb044510ee 100644 (file)
@@ -74,7 +74,8 @@ import (
        "code.gitea.io/gitea/routers/api/v1/user"
 
        "github.com/go-macaron/binding"
-       "gopkg.in/macaron.v1"
+       "github.com/go-macaron/cors"
+       macaron "gopkg.in/macaron.v1"
 )
 
 func sudo() macaron.Handler {
@@ -500,6 +501,12 @@ func RegisterRoutes(m *macaron.Macaron) {
                m.Get("/swagger", misc.Swagger) //Render V1 by default
        }
 
+       var handlers []macaron.Handler
+       if setting.EnableCORS {
+               handlers = append(handlers, cors.CORS(setting.CORSConfig))
+       }
+       handlers = append(handlers, securityHeaders(), context.APIContexter(), sudo())
+
        m.Group("/v1", func() {
                // Miscellaneous
                if setting.API.EnableSwagger {
@@ -841,5 +848,15 @@ func RegisterRoutes(m *macaron.Macaron) {
                m.Group("/topics", func() {
                        m.Get("/search", repo.TopicSearch)
                })
-       }, context.APIContexter(), sudo())
+       }, handlers...)
+}
+
+func securityHeaders() macaron.Handler {
+       return func(ctx *macaron.Context) {
+               ctx.Resp.Before(func(w macaron.ResponseWriter) {
+                       // CORB: https://www.chromium.org/Home/chromium-security/corb-for-developers
+                       // http://stackoverflow.com/a/3146618/244009
+                       w.Header().Set("x-content-type-options", "nosniff")
+               })
+       }
 }
index c126d79da861a2cf63c53fb53837ca19ce3200b5..c16e9de333059cf95cd7d3cb4cacf67926bb83c4 100644 (file)
@@ -32,7 +32,7 @@ func IsDir(dir string) bool {
        return f.IsDir()
 }
 
-func statDir(dirPath, recPath string, includeDir, isDirOnly bool) ([]string, error) {
+func statDir(dirPath, recPath string, includeDir, isDirOnly, followSymlinks bool) ([]string, error) {
        dir, err := os.Open(dirPath)
        if err != nil {
                return nil, err
@@ -56,13 +56,29 @@ func statDir(dirPath, recPath string, includeDir, isDirOnly bool) ([]string, err
                        if includeDir {
                                statList = append(statList, relPath+"/")
                        }
-                       s, err := statDir(curPath, relPath, includeDir, isDirOnly)
+                       s, err := statDir(curPath, relPath, includeDir, isDirOnly, followSymlinks)
                        if err != nil {
                                return nil, err
                        }
                        statList = append(statList, s...)
                } else if !isDirOnly {
                        statList = append(statList, relPath)
+               } else if followSymlinks && fi.Mode()&os.ModeSymlink != 0 {
+                       link, err := os.Readlink(curPath)
+                       if err != nil {
+                               return nil, err
+                       }
+
+                       if IsDir(link) {
+                               if includeDir {
+                                       statList = append(statList, relPath+"/")
+                               }
+                               s, err := statDir(curPath, relPath, includeDir, isDirOnly, followSymlinks)
+                               if err != nil {
+                                       return nil, err
+                               }
+                               statList = append(statList, s...)
+                       }
                }
        }
        return statList, nil
@@ -84,7 +100,26 @@ func StatDir(rootPath string, includeDir ...bool) ([]string, error) {
        if len(includeDir) >= 1 {
                isIncludeDir = includeDir[0]
        }
-       return statDir(rootPath, "", isIncludeDir, false)
+       return statDir(rootPath, "", isIncludeDir, false, false)
+}
+
+// LstatDir gathers information of given directory by depth-first.
+// It returns slice of file list, follows symbolic links and includes subdirectories if enabled;
+// it returns error and nil slice when error occurs in underlying functions,
+// or given path is not a directory or does not exist.
+//
+// Slice does not include given path itself.
+// If subdirectories is enabled, they will have suffix '/'.
+func LstatDir(rootPath string, includeDir ...bool) ([]string, error) {
+       if !IsDir(rootPath) {
+               return nil, errors.New("not a directory or does not exist: " + rootPath)
+       }
+
+       isIncludeDir := false
+       if len(includeDir) >= 1 {
+               isIncludeDir = includeDir[0]
+       }
+       return statDir(rootPath, "", isIncludeDir, false, true)
 }
 
 // GetAllSubDirs returns all subdirectories of given root path.
@@ -93,7 +128,17 @@ func GetAllSubDirs(rootPath string) ([]string, error) {
        if !IsDir(rootPath) {
                return nil, errors.New("not a directory or does not exist: " + rootPath)
        }
-       return statDir(rootPath, "", true, true)
+       return statDir(rootPath, "", true, true, false)
+}
+
+// LgetAllSubDirs returns all subdirectories of given root path, including
+// following symbolic links, if any.
+// Slice does not include given path itself.
+func LgetAllSubDirs(rootPath string) ([]string, error) {
+       if !IsDir(rootPath) {
+               return nil, errors.New("not a directory or does not exist: " + rootPath)
+       }
+       return statDir(rootPath, "", true, true, true)
 }
 
 // GetFileListBySuffix returns an ordered list of file paths.
diff --git a/vendor/github.com/Unknwon/com/go.mod b/vendor/github.com/Unknwon/com/go.mod
new file mode 100644 (file)
index 0000000..0bb87b4
--- /dev/null
@@ -0,0 +1,8 @@
+module github.com/Unknwon/com
+
+require (
+       github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
+       github.com/jtolds/gls v4.2.1+incompatible // indirect
+       github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 // indirect
+       github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c
+)
diff --git a/vendor/github.com/Unknwon/com/go.sum b/vendor/github.com/Unknwon/com/go.sum
new file mode 100644 (file)
index 0000000..3fcc303
--- /dev/null
@@ -0,0 +1,8 @@
+github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
+github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE=
+github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c h1:Ho+uVpkel/udgjbwB5Lktg9BtvJSh2DT0Hi6LPSyI2w=
+github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
index 762d94b050de7ea495429c2fa0346565e934682f..8a99df4e0872ca7818cf1f298ffa17bbb7db7e9a 100644 (file)
@@ -36,7 +36,7 @@ func HtmlEncode(str string) string {
        return html.EscapeString(str)
 }
 
-// decode string to html chars
+// HtmlDecode decodes string to html chars
 func HtmlDecode(str string) string {
        return html.UnescapeString(str)
 }
index 3415059ae9042ccdb92b1879b5f4373c3dd06002..cf0820f37829447054ff7ef0701f224d88334ed3 100644 (file)
@@ -177,7 +177,7 @@ func FetchFiles(client *http.Client, files []RawFile, header http.Header) error
        return nil
 }
 
-// FetchFiles uses command `curl` to fetch files specified by the rawURL field in parallel.
+// FetchFilesCurl uses command `curl` to fetch files specified by the rawURL field in parallel.
 func FetchFilesCurl(files []RawFile, curlOptions ...string) error {
        ch := make(chan error, len(files))
        for i := range files {
index 99c56b65947e1a8ed91beac6d6d974f065d57be7..62b77e87c8c462f447f9b91108143e04c18f6f4b 100644 (file)
 
 package com
 
-// PowInt is int type of math.Pow function. 
+// PowInt is int type of math.Pow function.
 func PowInt(x int, y int) int {
        if y <= 0 {
                return 1
        } else {
-               if y % 2 == 0 {
+               if y%2 == 0 {
                        sqrt := PowInt(x, y/2)
                        return sqrt * sqrt
                } else {
index 765bfc43113116aa763c2816fc8f633a9f308f09..14926474e0d2403a45d28ba07dfe7bab44af9de3 100644 (file)
@@ -37,19 +37,19 @@ func init() {
        regex_url = regexp.MustCompile(regex_url_pattern)
 }
 
-// validate string is an email address, if not return false
+// IsEmail validates string is an email address, if not return false
 // basically validation can match 99% cases
 func IsEmail(email string) bool {
        return regex_email.MatchString(email)
 }
 
-// validate string is an email address, if not return false
+// IsEmailRFC validates string is an email address, if not return false
 // this validation omits RFC 2822
 func IsEmailRFC(email string) bool {
        return regex_strict_email.MatchString(email)
 }
 
-// validate string is a url link, if not return false
+// IsUrl validates string is a url link, if not return false
 // simple validation can match 99% cases
 func IsUrl(url string) bool {
        return regex_url.MatchString(url)
index 27801a4d7dfd6e2a9dda215a6ae7db8d11e31299..c3c9ab2e722064ffdca1f3ab490f592ff9bbd952 100644 (file)
@@ -44,7 +44,7 @@ func CompareSliceStr(s1, s2 []string) bool {
        return true
 }
 
-// CompareSliceStr compares two 'string' type slices.
+// CompareSliceStrU compares two 'string' type slices.
 // It returns true if elements are the same, and ignores the order.
 func CompareSliceStrU(s1, s2 []string) bool {
        if len(s1) != len(s2) {
diff --git a/vendor/github.com/go-macaron/cors/.gitignore b/vendor/github.com/go-macaron/cors/.gitignore
new file mode 100644 (file)
index 0000000..f1c181e
--- /dev/null
@@ -0,0 +1,12 @@
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, build with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
diff --git a/vendor/github.com/go-macaron/cors/LICENSE b/vendor/github.com/go-macaron/cors/LICENSE
new file mode 100644 (file)
index 0000000..261eeb9
--- /dev/null
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/vendor/github.com/go-macaron/cors/README.md b/vendor/github.com/go-macaron/cors/README.md
new file mode 100644 (file)
index 0000000..be1cdca
--- /dev/null
@@ -0,0 +1,2 @@
+# cors
+Package cors is a middleware that handles CORS requests &amp; headers for Macaron.
diff --git a/vendor/github.com/go-macaron/cors/cors.go b/vendor/github.com/go-macaron/cors/cors.go
new file mode 100644 (file)
index 0000000..b0cec3d
--- /dev/null
@@ -0,0 +1,139 @@
+package cors
+
+import (
+       "fmt"
+       "log"
+       "net/http"
+       "net/url"
+       "strconv"
+       "strings"
+
+       macaron "gopkg.in/macaron.v1"
+)
+
+const _VERSION = "0.1.0"
+
+func Version() string {
+       return _VERSION
+}
+
+// Options represents a struct for specifying configuration options for the CORS middleware.
+type Options struct {
+       Section          string
+       Scheme           string
+       AllowDomain      string
+       AllowSubdomain   bool
+       Methods          []string
+       MaxAgeSeconds    int
+       AllowCredentials bool
+}
+
+func prepareOptions(options []Options) Options {
+       var opt Options
+       if len(options) > 0 {
+               opt = options[0]
+       }
+
+       if len(opt.Section) == 0 {
+               opt.Section = "cors"
+       }
+       sec := macaron.Config().Section(opt.Section)
+
+       if len(opt.Scheme) == 0 {
+               opt.Scheme = sec.Key("SCHEME").MustString("http")
+       }
+       if len(opt.AllowDomain) == 0 {
+               opt.AllowDomain = sec.Key("ALLOW_DOMAIN").MustString("*")
+       }
+       if !opt.AllowSubdomain {
+               opt.AllowSubdomain = sec.Key("ALLOW_SUBDOMAIN").MustBool(false)
+       }
+       if len(opt.Methods) == 0 {
+               opt.Methods = sec.Key("METHODS").Strings(",")
+               if len(opt.Methods) == 0 {
+                       opt.Methods = []string{
+                               http.MethodGet,
+                               http.MethodHead,
+                               http.MethodPost,
+                               http.MethodPut,
+                               http.MethodPatch,
+                               http.MethodDelete,
+                               http.MethodOptions,
+                       }
+               }
+       }
+       if opt.MaxAgeSeconds <= 0 {
+               // cache options response for 600 secs
+               // ref: https://stackoverflow.com/questions/54300997/is-it-possible-to-cache-http-options-response?noredirect=1#comment95790277_54300997
+               // ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
+               opt.MaxAgeSeconds = sec.Key("MAX_AGE_SECONDS").MustInt(600)
+       }
+       if !opt.AllowCredentials {
+               opt.AllowCredentials = sec.Key("ALLOW_CREDENTIALS").MustBool(true)
+       }
+
+       return opt
+}
+
+// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
+// https://fetch.spec.whatwg.org/#cors-protocol-and-credentials
+// For requests without credentials, the server may specify "*" as a wildcard, thereby allowing any origin to access the resource.
+func CORS(options ...Options) macaron.Handler {
+       opt := prepareOptions(options)
+       return func(ctx *macaron.Context, log *log.Logger) {
+               reqOptions := ctx.Req.Method == http.MethodOptions
+
+               headers := map[string]string{
+                       "access-control-allow-methods": strings.Join(opt.Methods, ","),
+                       "access-control-allow-headers": ctx.Req.Header.Get("access-control-request-headers"),
+                       "access-control-max-age":       strconv.Itoa(opt.MaxAgeSeconds),
+               }
+               if opt.AllowDomain == "*" {
+                       headers["access-control-allow-origin"] = "*"
+               } else if opt.AllowDomain != "" {
+                       origin := ctx.Req.Header.Get("Origin")
+                       if reqOptions && origin == "" {
+                               respErrorf(ctx, log, http.StatusBadRequest, "missing origin header in CORS request")
+                               return
+                       }
+
+                       u, err := url.Parse(origin)
+                       if err != nil {
+                               respErrorf(ctx, log, http.StatusBadRequest, "Failed to parse CORS origin header. Reason: %v", err)
+                               return
+                       }
+
+                       ok := u.Hostname() == opt.AllowDomain ||
+                               (opt.AllowSubdomain && strings.HasSuffix(u.Hostname(), "."+opt.AllowDomain))
+                       if ok {
+                               u.Scheme = opt.Scheme
+                               headers["access-control-allow-origin"] = u.String()
+                               headers["access-control-allow-credentials"] = strconv.FormatBool(opt.AllowCredentials)
+                               headers["vary"] = "Origin"
+                       }
+                       if reqOptions && !ok {
+                               respErrorf(ctx, log, http.StatusBadRequest, "CORS request from prohibited domain %v", origin)
+                               return
+                       }
+               }
+               ctx.Resp.Before(func(w macaron.ResponseWriter) {
+                       for k, v := range headers {
+                               w.Header().Set(k, v)
+                       }
+               })
+               if reqOptions {
+                       ctx.Status(200) // return response
+               }
+       }
+}
+
+func respErrorf(ctx *macaron.Context, log *log.Logger, statusCode int, format string, a ...interface{}) {
+       msg := fmt.Sprintf(format, a...)
+       log.Println(msg)
+       ctx.WriteHeader(statusCode)
+       _, err := ctx.Write([]byte(msg))
+       if err != nil {
+               panic(err)
+       }
+       return
+}
diff --git a/vendor/github.com/go-macaron/cors/go.mod b/vendor/github.com/go-macaron/cors/go.mod
new file mode 100644 (file)
index 0000000..6e03401
--- /dev/null
@@ -0,0 +1,11 @@
+module github.com/go-macaron/cors
+
+go 1.12
+
+require (
+       github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755 // indirect
+       github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191 // indirect
+       golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 // indirect
+       gopkg.in/ini.v1 v1.42.0 // indirect
+       gopkg.in/macaron.v1 v1.3.2
+)
diff --git a/vendor/github.com/go-macaron/cors/go.sum b/vendor/github.com/go-macaron/cors/go.sum
new file mode 100644 (file)
index 0000000..782d98c
--- /dev/null
@@ -0,0 +1,19 @@
+github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755 h1:1B7wb36fHLSwZfHg6ngZhhtIEHQjiC5H4p7qQGBEffg=
+github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755/go.mod h1:voKvFVpXBJxdIPeqjoJuLK+UVcRlo/JLjeToGxPYu68=
+github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191 h1:NjHlg70DuOkcAMqgt0+XA+NHwtu66MkTVVgR4fFWbcI=
+github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191/go.mod h1:VFI2o2q9kYsC4o7VP1HrEVosiZZTd+MVT3YZx4gqvJw=
+github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1ks85zJ1lfDGgIiMDuIptTOhJq+zKyg=
+github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE=
+github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 h1:Jpy1PXuP99tXNrhbq2BaPz9B+jNAvH1JPQQpG/9GCXY=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c h1:Ho+uVpkel/udgjbwB5Lktg9BtvJSh2DT0Hi6LPSyI2w=
+github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
+golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 h1:O5YqonU5IWby+w98jVUG9h7zlCWCcH4RHyPVReBmhzk=
+golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
+golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+gopkg.in/ini.v1 v1.42.0 h1:7N3gPTt50s8GuLortA00n8AqRTk75qOP98+mTPpgzRk=
+gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/macaron.v1 v1.3.2 h1:AvWIaPmwBUA87/OWzePkoxeaw6YJWDfBt1pDFPBnLf8=
+gopkg.in/macaron.v1 v1.3.2/go.mod h1:PrsiawTWAGZs6wFbT5hlr7SQ2Ns9h7cUVtcUu4lQOVo=
index 7df647641270dc4f52276bce4b233abbd16d6976..00ee9555036d04b8d9685b93ecee6bcc84b6563a 100644 (file)
@@ -77,6 +77,10 @@ const (
 type Client struct {
        // Key is the account key used to register with a CA and sign requests.
        // Key.Public() must return a *rsa.PublicKey or *ecdsa.PublicKey.
+       //
+       // The following algorithms are supported:
+       // RS256, ES256, ES384 and ES512.
+       // See RFC7518 for more details about the algorithms.
        Key crypto.Signer
 
        // HTTPClient optionally specifies an HTTP client to use
@@ -124,11 +128,7 @@ func (c *Client) Discover(ctx context.Context) (Directory, error) {
                return *c.dir, nil
        }
 
-       dirURL := c.DirectoryURL
-       if dirURL == "" {
-               dirURL = LetsEncryptURL
-       }
-       res, err := c.get(ctx, dirURL, wantStatus(http.StatusOK))
+       res, err := c.get(ctx, c.directoryURL(), wantStatus(http.StatusOK))
        if err != nil {
                return Directory{}, err
        }
@@ -161,6 +161,13 @@ func (c *Client) Discover(ctx context.Context) (Directory, error) {
        return *c.dir, nil
 }
 
+func (c *Client) directoryURL() string {
+       if c.DirectoryURL != "" {
+               return c.DirectoryURL
+       }
+       return LetsEncryptURL
+}
+
 // CreateCert requests a new certificate using the Certificate Signing Request csr encoded in DER format.
 // The exp argument indicates the desired certificate validity duration. CA may issue a certificate
 // with a different duration.
@@ -319,6 +326,20 @@ func (c *Client) UpdateReg(ctx context.Context, a *Account) (*Account, error) {
 // a valid authorization (Authorization.Status is StatusValid). If so, the caller
 // need not fulfill any challenge and can proceed to requesting a certificate.
 func (c *Client) Authorize(ctx context.Context, domain string) (*Authorization, error) {
+       return c.authorize(ctx, "dns", domain)
+}
+
+// AuthorizeIP is the same as Authorize but requests IP address authorization.
+// Clients which successfully obtain such authorization may request to issue
+// a certificate for IP addresses.
+//
+// See the ACME spec extension for more details about IP address identifiers:
+// https://tools.ietf.org/html/draft-ietf-acme-ip.
+func (c *Client) AuthorizeIP(ctx context.Context, ipaddr string) (*Authorization, error) {
+       return c.authorize(ctx, "ip", ipaddr)
+}
+
+func (c *Client) authorize(ctx context.Context, typ, val string) (*Authorization, error) {
        if _, err := c.Discover(ctx); err != nil {
                return nil, err
        }
@@ -332,7 +353,7 @@ func (c *Client) Authorize(ctx context.Context, domain string) (*Authorization,
                Identifier authzID `json:"identifier"`
        }{
                Resource:   "new-authz",
-               Identifier: authzID{Type: "dns", Value: domain},
+               Identifier: authzID{Type: typ, Value: val},
        }
        res, err := c.post(ctx, c.Key, c.dir.AuthzURL, req, wantStatus(http.StatusCreated))
        if err != nil {
@@ -693,12 +714,18 @@ func (c *Client) doReg(ctx context.Context, url string, typ string, acct *Accoun
 }
 
 // popNonce returns a nonce value previously stored with c.addNonce
-// or fetches a fresh one from the given URL.
+// or fetches a fresh one from a URL by issuing a HEAD request.
+// It first tries c.directoryURL() and then the provided url if the former fails.
 func (c *Client) popNonce(ctx context.Context, url string) (string, error) {
        c.noncesMu.Lock()
        defer c.noncesMu.Unlock()
        if len(c.nonces) == 0 {
-               return c.fetchNonce(ctx, url)
+               dirURL := c.directoryURL()
+               v, err := c.fetchNonce(ctx, dirURL)
+               if err != nil && url != dirURL {
+                       v, err = c.fetchNonce(ctx, url)
+               }
+               return v, err
        }
        var nonce string
        for nonce = range c.nonces {
index 4c2fc07226582d49580a55af9461bf05fda7eebd..a50d9bfc95853f67060c62befc579b6f30511fdc 100644 (file)
@@ -69,7 +69,7 @@ func HostWhitelist(hosts ...string) HostPolicy {
        }
        return func(_ context.Context, host string) error {
                if !whitelist[host] {
-                       return errors.New("acme/autocert: host not configured")
+                       return fmt.Errorf("acme/autocert: host %q not configured in HostWhitelist", host)
                }
                return nil
        }
index 6cbca25de973a247f8349d11c893fc3c15552ac9..1093b50390144c099611e12cff099f68b60050e9 100644 (file)
@@ -25,7 +25,7 @@ func jwsEncodeJSON(claimset interface{}, key crypto.Signer, nonce string) ([]byt
        if err != nil {
                return nil, err
        }
-       alg, sha := jwsHasher(key)
+       alg, sha := jwsHasher(key.Public())
        if alg == "" || !sha.Available() {
                return nil, ErrUnsupportedKey
        }
@@ -97,13 +97,16 @@ func jwkEncode(pub crypto.PublicKey) (string, error) {
 }
 
 // jwsSign signs the digest using the given key.
-// It returns ErrUnsupportedKey if the key type is unknown.
-// The hash is used only for RSA keys.
+// The hash is unused for ECDSA keys.
+//
+// Note: non-stdlib crypto.Signer implementations are expected to return
+// the signature in the format as specified in RFC7518.
+// See https://tools.ietf.org/html/rfc7518 for more details.
 func jwsSign(key crypto.Signer, hash crypto.Hash, digest []byte) ([]byte, error) {
-       switch key := key.(type) {
-       case *rsa.PrivateKey:
-               return key.Sign(rand.Reader, digest, hash)
-       case *ecdsa.PrivateKey:
+       if key, ok := key.(*ecdsa.PrivateKey); ok {
+               // The key.Sign method of ecdsa returns ASN1-encoded signature.
+               // So, we use the package Sign function instead
+               // to get R and S values directly and format the result accordingly.
                r, s, err := ecdsa.Sign(rand.Reader, key, digest)
                if err != nil {
                        return nil, err
@@ -118,18 +121,18 @@ func jwsSign(key crypto.Signer, hash crypto.Hash, digest []byte) ([]byte, error)
                copy(sig[size*2-len(sb):], sb)
                return sig, nil
        }
-       return nil, ErrUnsupportedKey
+       return key.Sign(rand.Reader, digest, hash)
 }
 
 // jwsHasher indicates suitable JWS algorithm name and a hash function
 // to use for signing a digest with the provided key.
 // It returns ("", 0) if the key is not supported.
-func jwsHasher(key crypto.Signer) (string, crypto.Hash) {
-       switch key := key.(type) {
-       case *rsa.PrivateKey:
+func jwsHasher(pub crypto.PublicKey) (string, crypto.Hash) {
+       switch pub := pub.(type) {
+       case *rsa.PublicKey:
                return "RS256", crypto.SHA256
-       case *ecdsa.PrivateKey:
-               switch key.Params().Name {
+       case *ecdsa.PublicKey:
+               switch pub.Params().Name {
                case "P-256":
                        return "ES256", crypto.SHA256
                case "P-384":
index 2641dadd6494e8ff5295e1d53842191ce5dadbe1..213bf204afea5bb048b8e2dd61f68cfeb9ee2afb 100644 (file)
@@ -3,6 +3,14 @@
 // license that can be found in the LICENSE file.
 
 // Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
+//
+// Blowfish is a legacy cipher and its short block size makes it vulnerable to
+// birthday bound attacks (see https://sweet32.info). It should only be used
+// where compatibility with legacy systems, not security, is the goal.
+//
+// Deprecated: any new system should use AES (from crypto/aes, if necessary in
+// an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
+// golang.org/x/crypto/chacha20poly1305).
 package blowfish // import "golang.org/x/crypto/blowfish"
 
 // The code is a port of Bruce Schneier's C implementation.
index 0b4af37bdc294c35c754df9c06d9f5b707a3fa59..ddcbeb6f2ad1dcb988863ed4df6ccb615bc5d594 100644 (file)
@@ -2,8 +2,15 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Package cast5 implements CAST5, as defined in RFC 2144. CAST5 is a common
-// OpenPGP cipher.
+// Package cast5 implements CAST5, as defined in RFC 2144.
+//
+// CAST5 is a legacy cipher and its short block size makes it vulnerable to
+// birthday bound attacks (see https://sweet32.info). It should only be used
+// where compatibility with legacy systems, not security, is the goal.
+//
+// Deprecated: any new system should use AES (from crypto/aes, if necessary in
+// an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
+// golang.org/x/crypto/chacha20poly1305).
 package cast5 // import "golang.org/x/crypto/cast5"
 
 import "errors"
index cb8fbc57b97a6ce068dd45e58a4c5c1b72209bae..75f24babb694b192be6bf6424d6c5e92f130bb53 100644 (file)
@@ -86,7 +86,7 @@ func feFromBytes(dst *fieldElement, src *[32]byte) {
        h6 := load3(src[20:]) << 7
        h7 := load3(src[23:]) << 5
        h8 := load3(src[26:]) << 4
-       h9 := load3(src[29:]) << 2
+       h9 := (load3(src[29:]) & 0x7fffff) << 2
 
        var carry [10]int64
        carry[9] = (h9 + 1<<24) >> 25
index 9e9040b2502f8e6bf156531a1cbe7feead9eee10..e0ac30c70f11f892a49424811ae1ea582a020ef1 100644 (file)
@@ -121,18 +121,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
@@ -236,18 +236,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
@@ -441,18 +441,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
@@ -591,18 +591,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
@@ -731,18 +731,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
@@ -846,18 +846,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
@@ -996,18 +996,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
@@ -1146,18 +1146,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
@@ -1332,18 +1332,18 @@ TEXT ·ladderstep(SB),0,$296-8
        ADDQ AX,R12
        ADCQ DX,R13
        MOVQ $REDMASK51,DX
-       SHLQ $13,CX:SI
+       SHLQ $13,SI,CX
        ANDQ DX,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ DX,R8
        ADDQ CX,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ DX,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ DX,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ DX,R14
        ADDQ R13,R14
        IMUL3Q $19,R15,CX
index 5ce80a2e56b975ca0297dfd3cfae522b15f4c1b9..1f76d1a3f59aa574b3f5b07999149b65ba8c020b 100644 (file)
@@ -124,18 +124,18 @@ TEXT ·mul(SB),0,$16-24
        ADDQ AX,R14
        ADCQ DX,R15
        MOVQ $REDMASK51,SI
-       SHLQ $13,R9:R8
+       SHLQ $13,R8,R9
        ANDQ SI,R8
-       SHLQ $13,R11:R10
+       SHLQ $13,R10,R11
        ANDQ SI,R10
        ADDQ R9,R10
-       SHLQ $13,R13:R12
+       SHLQ $13,R12,R13
        ANDQ SI,R12
        ADDQ R11,R12
-       SHLQ $13,R15:R14
+       SHLQ $13,R14,R15
        ANDQ SI,R14
        ADDQ R13,R14
-       SHLQ $13,BP:BX
+       SHLQ $13,BX,BP
        ANDQ SI,BX
        ADDQ R15,BX
        IMUL3Q $19,BP,DX
index 12f73734ff5aede956c2098faf473b862c72afe5..07511a45af22de6e95bb3222fbb13aab414c7345 100644 (file)
@@ -87,18 +87,18 @@ TEXT ·square(SB),7,$0-16
        ADDQ AX,R13
        ADCQ DX,R14
        MOVQ $REDMASK51,SI
-       SHLQ $13,R8:CX
+       SHLQ $13,CX,R8
        ANDQ SI,CX
-       SHLQ $13,R10:R9
+       SHLQ $13,R9,R10
        ANDQ SI,R9
        ADDQ R8,R9
-       SHLQ $13,R12:R11
+       SHLQ $13,R11,R12
        ANDQ SI,R11
        ADDQ R10,R11
-       SHLQ $13,R14:R13
+       SHLQ $13,R13,R14
        ANDQ SI,R13
        ADDQ R12,R13
-       SHLQ $13,BX:R15
+       SHLQ $13,R15,BX
        ANDQ SI,R15
        ADDQ R14,R15
        IMUL3Q $19,BX,DX
diff --git a/vendor/golang.org/x/crypto/internal/chacha20/asm_arm64.s b/vendor/golang.org/x/crypto/internal/chacha20/asm_arm64.s
new file mode 100644 (file)
index 0000000..b3a16ef
--- /dev/null
@@ -0,0 +1,308 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.11
+// +build !gccgo,!appengine
+
+#include "textflag.h"
+
+#define NUM_ROUNDS 10
+
+// func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32)
+TEXT ·xorKeyStreamVX(SB), NOSPLIT, $0
+       MOVD    dst+0(FP), R1
+       MOVD    src+24(FP), R2
+       MOVD    src_len+32(FP), R3
+       MOVD    key+48(FP), R4
+       MOVD    nonce+56(FP), R6
+       MOVD    counter+64(FP), R7
+
+       MOVD    $·constants(SB), R10
+       MOVD    $·incRotMatrix(SB), R11
+
+       MOVW    (R7), R20
+
+       AND     $~255, R3, R13
+       ADD     R2, R13, R12 // R12 for block end
+       AND     $255, R3, R13
+loop:
+       MOVD    $NUM_ROUNDS, R21
+       VLD1    (R11), [V30.S4, V31.S4]
+
+       // load contants
+       // VLD4R (R10), [V0.S4, V1.S4, V2.S4, V3.S4]
+       WORD    $0x4D60E940
+
+       // load keys
+       // VLD4R 16(R4), [V4.S4, V5.S4, V6.S4, V7.S4]
+       WORD    $0x4DFFE884
+       // VLD4R 16(R4), [V8.S4, V9.S4, V10.S4, V11.S4]
+       WORD    $0x4DFFE888
+       SUB     $32, R4
+
+       // load counter + nonce
+       // VLD1R (R7), [V12.S4]
+       WORD    $0x4D40C8EC
+
+       // VLD3R (R6), [V13.S4, V14.S4, V15.S4]
+       WORD    $0x4D40E8CD
+
+       // update counter
+       VADD    V30.S4, V12.S4, V12.S4
+
+chacha:
+       // V0..V3 += V4..V7
+       // V12..V15 <<<= ((V12..V15 XOR V0..V3), 16)
+       VADD    V0.S4, V4.S4, V0.S4
+       VADD    V1.S4, V5.S4, V1.S4
+       VADD    V2.S4, V6.S4, V2.S4
+       VADD    V3.S4, V7.S4, V3.S4
+       VEOR    V12.B16, V0.B16, V12.B16
+       VEOR    V13.B16, V1.B16, V13.B16
+       VEOR    V14.B16, V2.B16, V14.B16
+       VEOR    V15.B16, V3.B16, V15.B16
+       VREV32  V12.H8, V12.H8
+       VREV32  V13.H8, V13.H8
+       VREV32  V14.H8, V14.H8
+       VREV32  V15.H8, V15.H8
+       // V8..V11 += V12..V15
+       // V4..V7 <<<= ((V4..V7 XOR V8..V11), 12)
+       VADD    V8.S4, V12.S4, V8.S4
+       VADD    V9.S4, V13.S4, V9.S4
+       VADD    V10.S4, V14.S4, V10.S4
+       VADD    V11.S4, V15.S4, V11.S4
+       VEOR    V8.B16, V4.B16, V16.B16
+       VEOR    V9.B16, V5.B16, V17.B16
+       VEOR    V10.B16, V6.B16, V18.B16
+       VEOR    V11.B16, V7.B16, V19.B16
+       VSHL    $12, V16.S4, V4.S4
+       VSHL    $12, V17.S4, V5.S4
+       VSHL    $12, V18.S4, V6.S4
+       VSHL    $12, V19.S4, V7.S4
+       VSRI    $20, V16.S4, V4.S4
+       VSRI    $20, V17.S4, V5.S4
+       VSRI    $20, V18.S4, V6.S4
+       VSRI    $20, V19.S4, V7.S4
+
+       // V0..V3 += V4..V7
+       // V12..V15 <<<= ((V12..V15 XOR V0..V3), 8)
+       VADD    V0.S4, V4.S4, V0.S4
+       VADD    V1.S4, V5.S4, V1.S4
+       VADD    V2.S4, V6.S4, V2.S4
+       VADD    V3.S4, V7.S4, V3.S4
+       VEOR    V12.B16, V0.B16, V12.B16
+       VEOR    V13.B16, V1.B16, V13.B16
+       VEOR    V14.B16, V2.B16, V14.B16
+       VEOR    V15.B16, V3.B16, V15.B16
+       VTBL    V31.B16, [V12.B16], V12.B16
+       VTBL    V31.B16, [V13.B16], V13.B16
+       VTBL    V31.B16, [V14.B16], V14.B16
+       VTBL    V31.B16, [V15.B16], V15.B16
+
+       // V8..V11 += V12..V15
+       // V4..V7 <<<= ((V4..V7 XOR V8..V11), 7)
+       VADD    V12.S4, V8.S4, V8.S4
+       VADD    V13.S4, V9.S4, V9.S4
+       VADD    V14.S4, V10.S4, V10.S4
+       VADD    V15.S4, V11.S4, V11.S4
+       VEOR    V8.B16, V4.B16, V16.B16
+       VEOR    V9.B16, V5.B16, V17.B16
+       VEOR    V10.B16, V6.B16, V18.B16
+       VEOR    V11.B16, V7.B16, V19.B16
+       VSHL    $7, V16.S4, V4.S4
+       VSHL    $7, V17.S4, V5.S4
+       VSHL    $7, V18.S4, V6.S4
+       VSHL    $7, V19.S4, V7.S4
+       VSRI    $25, V16.S4, V4.S4
+       VSRI    $25, V17.S4, V5.S4
+       VSRI    $25, V18.S4, V6.S4
+       VSRI    $25, V19.S4, V7.S4
+
+       // V0..V3 += V5..V7, V4
+       // V15,V12-V14 <<<= ((V15,V12-V14 XOR V0..V3), 16)
+       VADD    V0.S4, V5.S4, V0.S4
+       VADD    V1.S4, V6.S4, V1.S4
+       VADD    V2.S4, V7.S4, V2.S4
+       VADD    V3.S4, V4.S4, V3.S4
+       VEOR    V15.B16, V0.B16, V15.B16
+       VEOR    V12.B16, V1.B16, V12.B16
+       VEOR    V13.B16, V2.B16, V13.B16
+       VEOR    V14.B16, V3.B16, V14.B16
+       VREV32  V12.H8, V12.H8
+       VREV32  V13.H8, V13.H8
+       VREV32  V14.H8, V14.H8
+       VREV32  V15.H8, V15.H8
+
+       // V10 += V15; V5 <<<= ((V10 XOR V5), 12)
+       // ...
+       VADD    V15.S4, V10.S4, V10.S4
+       VADD    V12.S4, V11.S4, V11.S4
+       VADD    V13.S4, V8.S4, V8.S4
+       VADD    V14.S4, V9.S4, V9.S4
+       VEOR    V10.B16, V5.B16, V16.B16
+       VEOR    V11.B16, V6.B16, V17.B16
+       VEOR    V8.B16, V7.B16, V18.B16
+       VEOR    V9.B16, V4.B16, V19.B16
+       VSHL    $12, V16.S4, V5.S4
+       VSHL    $12, V17.S4, V6.S4
+       VSHL    $12, V18.S4, V7.S4
+       VSHL    $12, V19.S4, V4.S4
+       VSRI    $20, V16.S4, V5.S4
+       VSRI    $20, V17.S4, V6.S4
+       VSRI    $20, V18.S4, V7.S4
+       VSRI    $20, V19.S4, V4.S4
+
+       // V0 += V5; V15 <<<= ((V0 XOR V15), 8)
+       // ...
+       VADD    V5.S4, V0.S4, V0.S4
+       VADD    V6.S4, V1.S4, V1.S4
+       VADD    V7.S4, V2.S4, V2.S4
+       VADD    V4.S4, V3.S4, V3.S4
+       VEOR    V0.B16, V15.B16, V15.B16
+       VEOR    V1.B16, V12.B16, V12.B16
+       VEOR    V2.B16, V13.B16, V13.B16
+       VEOR    V3.B16, V14.B16, V14.B16
+       VTBL    V31.B16, [V12.B16], V12.B16
+       VTBL    V31.B16, [V13.B16], V13.B16
+       VTBL    V31.B16, [V14.B16], V14.B16
+       VTBL    V31.B16, [V15.B16], V15.B16
+
+       // V10 += V15; V5 <<<= ((V10 XOR V5), 7)
+       // ...
+       VADD    V15.S4, V10.S4, V10.S4
+       VADD    V12.S4, V11.S4, V11.S4
+       VADD    V13.S4, V8.S4, V8.S4
+       VADD    V14.S4, V9.S4, V9.S4
+       VEOR    V10.B16, V5.B16, V16.B16
+       VEOR    V11.B16, V6.B16, V17.B16
+       VEOR    V8.B16, V7.B16, V18.B16
+       VEOR    V9.B16, V4.B16, V19.B16
+       VSHL    $7, V16.S4, V5.S4
+       VSHL    $7, V17.S4, V6.S4
+       VSHL    $7, V18.S4, V7.S4
+       VSHL    $7, V19.S4, V4.S4
+       VSRI    $25, V16.S4, V5.S4
+       VSRI    $25, V17.S4, V6.S4
+       VSRI    $25, V18.S4, V7.S4
+       VSRI    $25, V19.S4, V4.S4
+
+       SUB     $1, R21
+       CBNZ    R21, chacha
+
+       // VLD4R (R10), [V16.S4, V17.S4, V18.S4, V19.S4]
+       WORD    $0x4D60E950
+
+       // VLD4R 16(R4), [V20.S4, V21.S4, V22.S4, V23.S4]
+       WORD    $0x4DFFE894
+       VADD    V30.S4, V12.S4, V12.S4
+       VADD    V16.S4, V0.S4, V0.S4
+       VADD    V17.S4, V1.S4, V1.S4
+       VADD    V18.S4, V2.S4, V2.S4
+       VADD    V19.S4, V3.S4, V3.S4
+       // VLD4R 16(R4), [V24.S4, V25.S4, V26.S4, V27.S4]
+       WORD    $0x4DFFE898
+       // restore R4
+       SUB     $32, R4
+
+       // load counter + nonce
+       // VLD1R (R7), [V28.S4]
+       WORD    $0x4D40C8FC
+       // VLD3R (R6), [V29.S4, V30.S4, V31.S4]
+       WORD    $0x4D40E8DD
+
+       VADD    V20.S4, V4.S4, V4.S4
+       VADD    V21.S4, V5.S4, V5.S4
+       VADD    V22.S4, V6.S4, V6.S4
+       VADD    V23.S4, V7.S4, V7.S4
+       VADD    V24.S4, V8.S4, V8.S4
+       VADD    V25.S4, V9.S4, V9.S4
+       VADD    V26.S4, V10.S4, V10.S4
+       VADD    V27.S4, V11.S4, V11.S4
+       VADD    V28.S4, V12.S4, V12.S4
+       VADD    V29.S4, V13.S4, V13.S4
+       VADD    V30.S4, V14.S4, V14.S4
+       VADD    V31.S4, V15.S4, V15.S4
+
+       VZIP1   V1.S4, V0.S4, V16.S4
+       VZIP2   V1.S4, V0.S4, V17.S4
+       VZIP1   V3.S4, V2.S4, V18.S4
+       VZIP2   V3.S4, V2.S4, V19.S4
+       VZIP1   V5.S4, V4.S4, V20.S4
+       VZIP2   V5.S4, V4.S4, V21.S4
+       VZIP1   V7.S4, V6.S4, V22.S4
+       VZIP2   V7.S4, V6.S4, V23.S4
+       VZIP1   V9.S4, V8.S4, V24.S4
+       VZIP2   V9.S4, V8.S4, V25.S4
+       VZIP1   V11.S4, V10.S4, V26.S4
+       VZIP2   V11.S4, V10.S4, V27.S4
+       VZIP1   V13.S4, V12.S4, V28.S4
+       VZIP2   V13.S4, V12.S4, V29.S4
+       VZIP1   V15.S4, V14.S4, V30.S4
+       VZIP2   V15.S4, V14.S4, V31.S4
+       VZIP1   V18.D2, V16.D2, V0.D2
+       VZIP2   V18.D2, V16.D2, V4.D2
+       VZIP1   V19.D2, V17.D2, V8.D2
+       VZIP2   V19.D2, V17.D2, V12.D2
+       VLD1.P  64(R2), [V16.B16, V17.B16, V18.B16, V19.B16]
+
+       VZIP1   V22.D2, V20.D2, V1.D2
+       VZIP2   V22.D2, V20.D2, V5.D2
+       VZIP1   V23.D2, V21.D2, V9.D2
+       VZIP2   V23.D2, V21.D2, V13.D2
+       VLD1.P  64(R2), [V20.B16, V21.B16, V22.B16, V23.B16]
+       VZIP1   V26.D2, V24.D2, V2.D2
+       VZIP2   V26.D2, V24.D2, V6.D2
+       VZIP1   V27.D2, V25.D2, V10.D2
+       VZIP2   V27.D2, V25.D2, V14.D2
+       VLD1.P  64(R2), [V24.B16, V25.B16, V26.B16, V27.B16]
+       VZIP1   V30.D2, V28.D2, V3.D2
+       VZIP2   V30.D2, V28.D2, V7.D2
+       VZIP1   V31.D2, V29.D2, V11.D2
+       VZIP2   V31.D2, V29.D2, V15.D2
+       VLD1.P  64(R2), [V28.B16, V29.B16, V30.B16, V31.B16]
+       VEOR    V0.B16, V16.B16, V16.B16
+       VEOR    V1.B16, V17.B16, V17.B16
+       VEOR    V2.B16, V18.B16, V18.B16
+       VEOR    V3.B16, V19.B16, V19.B16
+       VST1.P  [V16.B16, V17.B16, V18.B16, V19.B16], 64(R1)
+       VEOR    V4.B16, V20.B16, V20.B16
+       VEOR    V5.B16, V21.B16, V21.B16
+       VEOR    V6.B16, V22.B16, V22.B16
+       VEOR    V7.B16, V23.B16, V23.B16
+       VST1.P  [V20.B16, V21.B16, V22.B16, V23.B16], 64(R1)
+       VEOR    V8.B16, V24.B16, V24.B16
+       VEOR    V9.B16, V25.B16, V25.B16
+       VEOR    V10.B16, V26.B16, V26.B16
+       VEOR    V11.B16, V27.B16, V27.B16
+       VST1.P  [V24.B16, V25.B16, V26.B16, V27.B16], 64(R1)
+       VEOR    V12.B16, V28.B16, V28.B16
+       VEOR    V13.B16, V29.B16, V29.B16
+       VEOR    V14.B16, V30.B16, V30.B16
+       VEOR    V15.B16, V31.B16, V31.B16
+       VST1.P  [V28.B16, V29.B16, V30.B16, V31.B16], 64(R1)
+
+       ADD     $4, R20
+       MOVW    R20, (R7) // update counter
+
+       CMP     R2, R12
+       BGT     loop
+
+       RET
+
+
+DATA   ·constants+0x00(SB)/4, $0x61707865
+DATA   ·constants+0x04(SB)/4, $0x3320646e
+DATA   ·constants+0x08(SB)/4, $0x79622d32
+DATA   ·constants+0x0c(SB)/4, $0x6b206574
+GLOBL  ·constants(SB), NOPTR|RODATA, $32
+
+DATA   ·incRotMatrix+0x00(SB)/4, $0x00000000
+DATA   ·incRotMatrix+0x04(SB)/4, $0x00000001
+DATA   ·incRotMatrix+0x08(SB)/4, $0x00000002
+DATA   ·incRotMatrix+0x0c(SB)/4, $0x00000003
+DATA   ·incRotMatrix+0x10(SB)/4, $0x02010003
+DATA   ·incRotMatrix+0x14(SB)/4, $0x06050407
+DATA   ·incRotMatrix+0x18(SB)/4, $0x0A09080B
+DATA   ·incRotMatrix+0x1c(SB)/4, $0x0E0D0C0F
+GLOBL  ·incRotMatrix(SB), NOPTR|RODATA, $32
diff --git a/vendor/golang.org/x/crypto/internal/chacha20/chacha_arm64.go b/vendor/golang.org/x/crypto/internal/chacha20/chacha_arm64.go
new file mode 100644 (file)
index 0000000..ad74e23
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build go1.11
+// +build !gccgo
+
+package chacha20
+
+const (
+       haveAsm = true
+       bufSize = 256
+)
+
+//go:noescape
+func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32)
+
+func (c *Cipher) xorKeyStreamAsm(dst, src []byte) {
+
+       if len(src) >= bufSize {
+               xorKeyStreamVX(dst, src, &c.key, &c.nonce, &c.counter)
+       }
+
+       if len(src)%bufSize != 0 {
+               i := len(src) - len(src)%bufSize
+               c.buf = [bufSize]byte{}
+               copy(c.buf[:], src[i:])
+               xorKeyStreamVX(c.buf[:], c.buf[:], &c.key, &c.nonce, &c.counter)
+               c.len = bufSize - copy(dst[i:], c.buf[:len(src)%bufSize])
+       }
+}
index 91520d1de079f2958f132a50dbdfba24c3bb4814..47eac0314c9d054a9884b4ed3e14b6dddb8a61aa 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build !s390x gccgo appengine
+// +build !arm64,!s390x arm64,!go1.11 gccgo appengine
 
 package chacha20
 
index 0c1c671c40b77f6bdce6ecf16c4fc69ce57efb55..aad645b44762d72752906a8b4aa9d013cdc74bd8 100644 (file)
@@ -6,14 +6,13 @@
 
 package chacha20
 
-var haveAsm = hasVectorFacility()
+import (
+       "golang.org/x/sys/cpu"
+)
 
-const bufSize = 256
+var haveAsm = cpu.S390X.HasVX
 
-// hasVectorFacility reports whether the machine supports the vector
-// facility (vx).
-// Implementation in asm_s390x.s.
-func hasVectorFacility() bool
+const bufSize = 256
 
 // xorKeyStreamVX is an assembly implementation of XORKeyStream. It must only
 // be called when the vector facility is available.
index 98427c5e222afb50882af5fc9a8846aa90aa3dde..57df404465c2223fe7cedba41e47e6aae8fc077b 100644 (file)
@@ -258,26 +258,3 @@ tail:
        MOVD R8, R3
        MOVD $0, R4
        JMP  continue
-
-// func hasVectorFacility() bool
-TEXT ·hasVectorFacility(SB), NOSPLIT, $24-1
-       MOVD  $x-24(SP), R1
-       XC    $24, 0(R1), 0(R1) // clear the storage
-       MOVD  $2, R0            // R0 is the number of double words stored -1
-       WORD  $0xB2B01000       // STFLE 0(R1)
-       XOR   R0, R0            // reset the value of R0
-       MOVBZ z-8(SP), R1
-       AND   $0x40, R1
-       BEQ   novector
-
-vectorinstalled:
-       // check if the vector instruction has been enabled
-       VLEIB  $0, $0xF, V16
-       VLGVB  $0, V16, R1
-       CMPBNE R1, $0xF, novector
-       MOVB   $1, ret+0(FP)      // have vx
-       RET
-
-novector:
-       MOVB $0, ret+0(FP) // no vx
-       RET
index 6d9ba9e5f330a7c82e37d424ee1247b1f43b05ad..59d3480693050fd78af3684a6723de98f5d30385 100644 (file)
@@ -3,6 +3,10 @@
 // license that can be found in the LICENSE file.
 
 // Package md4 implements the MD4 hash algorithm as defined in RFC 1320.
+//
+// Deprecated: MD4 is cryptographically broken and should should only be used
+// where compatibility with legacy systems, not security, is the goal. Instead,
+// use a secure hash like SHA-256 (from crypto/sha256).
 package md4 // import "golang.org/x/crypto/md4"
 
 import (
index a79a8c13ae78607c715089e1a76b1f2d9d360978..3e2518600e29e9e736125ed119cd5ea0bc99539c 100644 (file)
@@ -333,7 +333,6 @@ func ReadEntity(packets *packet.Reader) (*Entity, error) {
                return nil, errors.StructuralError("primary key cannot be used for signatures")
        }
 
-       var current *Identity
        var revocations []*packet.Signature
 EachPacket:
        for {
@@ -346,36 +345,8 @@ EachPacket:
 
                switch pkt := p.(type) {
                case *packet.UserId:
-                       // Make a new Identity object, that we might wind up throwing away.
-                       // We'll only add it if we get a valid self-signature over this
-                       // userID.
-                       current = new(Identity)
-                       current.Name = pkt.Id
-                       current.UserId = pkt
-
-                       for {
-                               p, err = packets.Next()
-                               if err == io.EOF {
-                                       break EachPacket
-                               } else if err != nil {
-                                       return nil, err
-                               }
-
-                               sig, ok := p.(*packet.Signature)
-                               if !ok {
-                                       packets.Unread(p)
-                                       continue EachPacket
-                               }
-
-                               if (sig.SigType == packet.SigTypePositiveCert || sig.SigType == packet.SigTypeGenericCert) && sig.IssuerKeyId != nil && *sig.IssuerKeyId == e.PrimaryKey.KeyId {
-                                       if err = e.PrimaryKey.VerifyUserIdSignature(pkt.Id, e.PrimaryKey, sig); err != nil {
-                                               return nil, errors.StructuralError("user ID self-signature invalid: " + err.Error())
-                                       }
-                                       current.SelfSignature = sig
-                                       e.Identities[pkt.Id] = current
-                               } else {
-                                       current.Signatures = append(current.Signatures, sig)
-                               }
+                       if err := addUserID(e, packets, pkt); err != nil {
+                               return nil, err
                        }
                case *packet.Signature:
                        if pkt.SigType == packet.SigTypeKeyRevocation {
@@ -384,11 +355,9 @@ EachPacket:
                                // TODO: RFC4880 5.2.1 permits signatures
                                // directly on keys (eg. to bind additional
                                // revocation keys).
-                       } else if current == nil {
-                               return nil, errors.StructuralError("signature packet found before user id packet")
-                       } else {
-                               current.Signatures = append(current.Signatures, pkt)
                        }
+                       // Else, ignoring the signature as it does not follow anything
+                       // we would know to attach it to.
                case *packet.PrivateKey:
                        if pkt.IsSubkey == false {
                                packets.Unread(p)
@@ -429,33 +398,105 @@ EachPacket:
        return e, nil
 }
 
+func addUserID(e *Entity, packets *packet.Reader, pkt *packet.UserId) error {
+       // Make a new Identity object, that we might wind up throwing away.
+       // We'll only add it if we get a valid self-signature over this
+       // userID.
+       identity := new(Identity)
+       identity.Name = pkt.Id
+       identity.UserId = pkt
+
+       for {
+               p, err := packets.Next()
+               if err == io.EOF {
+                       break
+               } else if err != nil {
+                       return err
+               }
+
+               sig, ok := p.(*packet.Signature)
+               if !ok {
+                       packets.Unread(p)
+                       break
+               }
+
+               if (sig.SigType == packet.SigTypePositiveCert || sig.SigType == packet.SigTypeGenericCert) && sig.IssuerKeyId != nil && *sig.IssuerKeyId == e.PrimaryKey.KeyId {
+                       if err = e.PrimaryKey.VerifyUserIdSignature(pkt.Id, e.PrimaryKey, sig); err != nil {
+                               return errors.StructuralError("user ID self-signature invalid: " + err.Error())
+                       }
+                       identity.SelfSignature = sig
+                       e.Identities[pkt.Id] = identity
+               } else {
+                       identity.Signatures = append(identity.Signatures, sig)
+               }
+       }
+
+       return nil
+}
+
 func addSubkey(e *Entity, packets *packet.Reader, pub *packet.PublicKey, priv *packet.PrivateKey) error {
        var subKey Subkey
        subKey.PublicKey = pub
        subKey.PrivateKey = priv
-       p, err := packets.Next()
-       if err == io.EOF {
-               return io.ErrUnexpectedEOF
-       }
-       if err != nil {
-               return errors.StructuralError("subkey signature invalid: " + err.Error())
+
+       for {
+               p, err := packets.Next()
+               if err == io.EOF {
+                       break
+               } else if err != nil {
+                       return errors.StructuralError("subkey signature invalid: " + err.Error())
+               }
+
+               sig, ok := p.(*packet.Signature)
+               if !ok {
+                       packets.Unread(p)
+                       break
+               }
+
+               if sig.SigType != packet.SigTypeSubkeyBinding && sig.SigType != packet.SigTypeSubkeyRevocation {
+                       return errors.StructuralError("subkey signature with wrong type")
+               }
+
+               if err := e.PrimaryKey.VerifyKeySignature(subKey.PublicKey, sig); err != nil {
+                       return errors.StructuralError("subkey signature invalid: " + err.Error())
+               }
+
+               switch sig.SigType {
+               case packet.SigTypeSubkeyRevocation:
+                       subKey.Sig = sig
+               case packet.SigTypeSubkeyBinding:
+
+                       if shouldReplaceSubkeySig(subKey.Sig, sig) {
+                               subKey.Sig = sig
+                       }
+               }
        }
-       var ok bool
-       subKey.Sig, ok = p.(*packet.Signature)
-       if !ok {
+
+       if subKey.Sig == nil {
                return errors.StructuralError("subkey packet not followed by signature")
        }
-       if subKey.Sig.SigType != packet.SigTypeSubkeyBinding && subKey.Sig.SigType != packet.SigTypeSubkeyRevocation {
-               return errors.StructuralError("subkey signature with wrong type")
-       }
-       err = e.PrimaryKey.VerifyKeySignature(subKey.PublicKey, subKey.Sig)
-       if err != nil {
-               return errors.StructuralError("subkey signature invalid: " + err.Error())
-       }
+
        e.Subkeys = append(e.Subkeys, subKey)
+
        return nil
 }
 
+func shouldReplaceSubkeySig(existingSig, potentialNewSig *packet.Signature) bool {
+       if potentialNewSig == nil {
+               return false
+       }
+
+       if existingSig == nil {
+               return true
+       }
+
+       if existingSig.SigType == packet.SigTypeSubkeyRevocation {
+               return false // never override a revocation signature
+       }
+
+       return potentialNewSig.CreationTime.After(existingSig.CreationTime)
+}
+
 const defaultRSAKeyBits = 2048
 
 // NewEntity returns an Entity that contains a fresh RSA/RSA keypair with a
index 625bb5ac8090ae69b6c0b3c7eafa85738758fe93..5af64c5421b6a2aed990828c53bb6edf1855c525 100644 (file)
@@ -404,14 +404,16 @@ const (
 type PublicKeyAlgorithm uint8
 
 const (
-       PubKeyAlgoRSA            PublicKeyAlgorithm = 1
-       PubKeyAlgoRSAEncryptOnly PublicKeyAlgorithm = 2
-       PubKeyAlgoRSASignOnly    PublicKeyAlgorithm = 3
-       PubKeyAlgoElGamal        PublicKeyAlgorithm = 16
-       PubKeyAlgoDSA            PublicKeyAlgorithm = 17
+       PubKeyAlgoRSA     PublicKeyAlgorithm = 1
+       PubKeyAlgoElGamal PublicKeyAlgorithm = 16
+       PubKeyAlgoDSA     PublicKeyAlgorithm = 17
        // RFC 6637, Section 5.
        PubKeyAlgoECDH  PublicKeyAlgorithm = 18
        PubKeyAlgoECDSA PublicKeyAlgorithm = 19
+
+       // Deprecated in RFC 4880, Section 13.5. Use key flags instead.
+       PubKeyAlgoRSAEncryptOnly PublicKeyAlgorithm = 2
+       PubKeyAlgoRSASignOnly    PublicKeyAlgorithm = 3
 )
 
 // CanEncrypt returns true if it's possible to encrypt a message to a public
index 34734cc63d14dec7bffc9898a47b14c8515aed79..bd31cceac62e595679b4c11d4ea379eafefd582d 100644 (file)
@@ -64,14 +64,19 @@ func NewECDSAPrivateKey(currentTime time.Time, priv *ecdsa.PrivateKey) *PrivateK
        return pk
 }
 
-// NewSignerPrivateKey creates a sign-only PrivateKey from a crypto.Signer that
+// NewSignerPrivateKey creates a PrivateKey from a crypto.Signer that
 // implements RSA or ECDSA.
 func NewSignerPrivateKey(currentTime time.Time, signer crypto.Signer) *PrivateKey {
        pk := new(PrivateKey)
+       // In general, the public Keys should be used as pointers. We still
+       // type-switch on the values, for backwards-compatibility.
        switch pubkey := signer.Public().(type) {
+       case *rsa.PublicKey:
+               pk.PublicKey = *NewRSAPublicKey(currentTime, pubkey)
        case rsa.PublicKey:
                pk.PublicKey = *NewRSAPublicKey(currentTime, &pubkey)
-               pk.PubKeyAlgo = PubKeyAlgoRSASignOnly
+       case *ecdsa.PublicKey:
+               pk.PublicKey = *NewECDSAPublicKey(currentTime, pubkey)
        case ecdsa.PublicKey:
                pk.PublicKey = *NewECDSAPublicKey(currentTime, &pubkey)
        default:
index 6ce0cbedbeae429bb23809b52bfbe283ff847acc..b2a24a532327b5cd326f8128d8c5ce154e6e5d18 100644 (file)
@@ -542,7 +542,7 @@ func (sig *Signature) Sign(h hash.Hash, priv *PrivateKey, config *Config) (err e
                        r, s, err = ecdsa.Sign(config.Random(), pk, digest)
                } else {
                        var b []byte
-                       b, err = priv.PrivateKey.(crypto.Signer).Sign(config.Random(), digest, nil)
+                       b, err = priv.PrivateKey.(crypto.Signer).Sign(config.Random(), digest, sig.Hash)
                        if err == nil {
                                r, s, err = unwrapECDSASig(b)
                        }
index 96a2b382a1de036fd13217c846b5b6bd795330c9..d19ffbc78671058e3f4e002394228682aa53bd5f 100644 (file)
@@ -80,7 +80,7 @@ func (uat *UserAttribute) Serialize(w io.Writer) (err error) {
 
 // ImageData returns zero or more byte slices, each containing
 // JPEG File Interchange Format (JFIF), for each photo in the
-// the user attribute packet.
+// user attribute packet.
 func (uat *UserAttribute) ImageData() (imageData [][]byte) {
        for _, sp := range uat.Contents {
                if sp.SubType == UserAttrImageSubpacket && len(sp.Contents) > 16 {
index d6dede74e97cde523f91d671677155e6f435be9b..4ee71784ebe0f17ea952acad950bdde46870166b 100644 (file)
@@ -271,6 +271,7 @@ func Encrypt(ciphertext io.Writer, to []*Entity, signed *Entity, hints *FileHint
        // These are the possible hash functions that we'll use for the signature.
        candidateHashes := []uint8{
                hashToHashId(crypto.SHA256),
+               hashToHashId(crypto.SHA384),
                hashToHashId(crypto.SHA512),
                hashToHashId(crypto.SHA1),
                hashToHashId(crypto.RIPEMD160),
@@ -349,6 +350,7 @@ func Sign(output io.Writer, signed *Entity, hints *FileHints, config *packet.Con
        // These are the possible hash functions that we'll use for the signature.
        candidateHashes := []uint8{
                hashToHashId(crypto.SHA256),
+               hashToHashId(crypto.SHA384),
                hashToHashId(crypto.SHA512),
                hashToHashId(crypto.SHA1),
                hashToHashId(crypto.RIPEMD160),
diff --git a/vendor/golang.org/x/crypto/poly1305/mac_noasm.go b/vendor/golang.org/x/crypto/poly1305/mac_noasm.go
new file mode 100644 (file)
index 0000000..8387d29
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !amd64 gccgo appengine
+
+package poly1305
+
+type mac struct{ macGeneric }
+
+func newMAC(key *[32]byte) mac { return mac{newMACGeneric(key)} }
index f562fa5712ba09a1bed13121c08a98b502ab328f..d076a562351f4f01093c42749ca48c2442a9c133 100644 (file)
@@ -2,21 +2,19 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-/*
-Package poly1305 implements Poly1305 one-time message authentication code as
-specified in https://cr.yp.to/mac/poly1305-20050329.pdf.
-
-Poly1305 is a fast, one-time authentication function. It is infeasible for an
-attacker to generate an authenticator for a message without the key. However, a
-key must only be used for a single message. Authenticating two different
-messages with the same key allows an attacker to forge authenticators for other
-messages with the same key.
-
-Poly1305 was originally coupled with AES in order to make Poly1305-AES. AES was
-used with a fixed key in order to generate one-time keys from an nonce.
-However, in this package AES isn't used and the one-time key is specified
-directly.
-*/
+// Package poly1305 implements Poly1305 one-time message authentication code as
+// specified in https://cr.yp.to/mac/poly1305-20050329.pdf.
+//
+// Poly1305 is a fast, one-time authentication function. It is infeasible for an
+// attacker to generate an authenticator for a message without the key. However, a
+// key must only be used for a single message. Authenticating two different
+// messages with the same key allows an attacker to forge authenticators for other
+// messages with the same key.
+//
+// Poly1305 was originally coupled with AES in order to make Poly1305-AES. AES was
+// used with a fixed key in order to generate one-time keys from an nonce.
+// However, in this package AES isn't used and the one-time key is specified
+// directly.
 package poly1305 // import "golang.org/x/crypto/poly1305"
 
 import "crypto/subtle"
@@ -31,3 +29,55 @@ func Verify(mac *[16]byte, m []byte, key *[32]byte) bool {
        Sum(&tmp, m, key)
        return subtle.ConstantTimeCompare(tmp[:], mac[:]) == 1
 }
+
+// New returns a new MAC computing an authentication
+// tag of all data written to it with the given key.
+// This allows writing the message progressively instead
+// of passing it as a single slice. Common users should use
+// the Sum function instead.
+//
+// The key must be unique for each message, as authenticating
+// two different messages with the same key allows an attacker
+// to forge messages at will.
+func New(key *[32]byte) *MAC {
+       return &MAC{
+               mac:       newMAC(key),
+               finalized: false,
+       }
+}
+
+// MAC is an io.Writer computing an authentication tag
+// of the data written to it.
+//
+// MAC cannot be used like common hash.Hash implementations,
+// because using a poly1305 key twice breaks its security.
+// Therefore writing data to a running MAC after calling
+// Sum causes it to panic.
+type MAC struct {
+       mac // platform-dependent implementation
+
+       finalized bool
+}
+
+// Size returns the number of bytes Sum will return.
+func (h *MAC) Size() int { return TagSize }
+
+// Write adds more data to the running message authentication code.
+// It never returns an error.
+//
+// It must not be called after the first call of Sum.
+func (h *MAC) Write(p []byte) (n int, err error) {
+       if h.finalized {
+               panic("poly1305: write to MAC after Sum")
+       }
+       return h.mac.Write(p)
+}
+
+// Sum computes the authenticator of all data written to the
+// message authentication code.
+func (h *MAC) Sum(b []byte) []byte {
+       var mac [TagSize]byte
+       h.mac.Sum(&mac)
+       h.finalized = true
+       return append(b, mac[:]...)
+}
index 4dd72fe799b2d3524b9af7457df67fbad4444170..2dbf42aa537a5910eb40d0b6e767d7dc3121d5d8 100644 (file)
@@ -6,17 +6,63 @@
 
 package poly1305
 
-// This function is implemented in sum_amd64.s
 //go:noescape
-func poly1305(out *[16]byte, m *byte, mlen uint64, key *[32]byte)
+func initialize(state *[7]uint64, key *[32]byte)
+
+//go:noescape
+func update(state *[7]uint64, msg []byte)
+
+//go:noescape
+func finalize(tag *[TagSize]byte, state *[7]uint64)
 
 // Sum generates an authenticator for m using a one-time key and puts the
 // 16-byte result into out. Authenticating two different messages with the same
 // key allows an attacker to forge messages at will.
 func Sum(out *[16]byte, m []byte, key *[32]byte) {
-       var mPtr *byte
-       if len(m) > 0 {
-               mPtr = &m[0]
+       h := newMAC(key)
+       h.Write(m)
+       h.Sum(out)
+}
+
+func newMAC(key *[32]byte) (h mac) {
+       initialize(&h.state, key)
+       return
+}
+
+type mac struct {
+       state [7]uint64 // := uint64{ h0, h1, h2, r0, r1, pad0, pad1 }
+
+       buffer [TagSize]byte
+       offset int
+}
+
+func (h *mac) Write(p []byte) (n int, err error) {
+       n = len(p)
+       if h.offset > 0 {
+               remaining := TagSize - h.offset
+               if n < remaining {
+                       h.offset += copy(h.buffer[h.offset:], p)
+                       return n, nil
+               }
+               copy(h.buffer[h.offset:], p[:remaining])
+               p = p[remaining:]
+               h.offset = 0
+               update(&h.state, h.buffer[:])
+       }
+       if nn := len(p) - (len(p) % TagSize); nn > 0 {
+               update(&h.state, p[:nn])
+               p = p[nn:]
+       }
+       if len(p) > 0 {
+               h.offset += copy(h.buffer[h.offset:], p)
+       }
+       return n, nil
+}
+
+func (h *mac) Sum(out *[16]byte) {
+       state := h.state
+       if h.offset > 0 {
+               update(&state, h.buffer[:h.offset])
        }
-       poly1305(out, mPtr, uint64(len(m)), key)
+       finalize(out, &state)
 }
index 2edae63828a5f0d3efa73585d3882a31c3f4343c..7d600f13cc87a51f57d75364fd1dae5d05aa73c6 100644 (file)
@@ -58,20 +58,17 @@ DATA ·poly1305Mask<>+0x00(SB)/8, $0x0FFFFFFC0FFFFFFF
 DATA ·poly1305Mask<>+0x08(SB)/8, $0x0FFFFFFC0FFFFFFC
 GLOBL ·poly1305Mask<>(SB), RODATA, $16
 
-// func poly1305(out *[16]byte, m *byte, mlen uint64, key *[32]key)
-TEXT ·poly1305(SB), $0-32
-       MOVQ out+0(FP), DI
-       MOVQ m+8(FP), SI
-       MOVQ mlen+16(FP), R15
-       MOVQ key+24(FP), AX
-
-       MOVQ 0(AX), R11
-       MOVQ 8(AX), R12
-       ANDQ ·poly1305Mask<>(SB), R11   // r0
-       ANDQ ·poly1305Mask<>+8(SB), R12 // r1
-       XORQ R8, R8                    // h0
-       XORQ R9, R9                    // h1
-       XORQ R10, R10                  // h2
+// func update(state *[7]uint64, msg []byte)
+TEXT ·update(SB), $0-32
+       MOVQ state+0(FP), DI
+       MOVQ msg_base+8(FP), SI
+       MOVQ msg_len+16(FP), R15
+
+       MOVQ 0(DI), R8   // h0
+       MOVQ 8(DI), R9   // h1
+       MOVQ 16(DI), R10 // h2
+       MOVQ 24(DI), R11 // r0
+       MOVQ 32(DI), R12 // r1
 
        CMPQ R15, $16
        JB   bytes_between_0_and_15
@@ -109,16 +106,42 @@ flush_buffer:
        JMP  multiply
 
 done:
-       MOVQ    R8, AX
-       MOVQ    R9, BX
+       MOVQ R8, 0(DI)
+       MOVQ R9, 8(DI)
+       MOVQ R10, 16(DI)
+       RET
+
+// func initialize(state *[7]uint64, key *[32]byte)
+TEXT ·initialize(SB), $0-16
+       MOVQ state+0(FP), DI
+       MOVQ key+8(FP), SI
+
+       // state[0...7] is initialized with zero
+       MOVOU 0(SI), X0
+       MOVOU 16(SI), X1
+       MOVOU ·poly1305Mask<>(SB), X2
+       PAND  X2, X0
+       MOVOU X0, 24(DI)
+       MOVOU X1, 40(DI)
+       RET
+
+// func finalize(tag *[TagSize]byte, state *[7]uint64)
+TEXT ·finalize(SB), $0-16
+       MOVQ tag+0(FP), DI
+       MOVQ state+8(FP), SI
+
+       MOVQ    0(SI), AX
+       MOVQ    8(SI), BX
+       MOVQ    16(SI), CX
+       MOVQ    AX, R8
+       MOVQ    BX, R9
        SUBQ    $0xFFFFFFFFFFFFFFFB, AX
        SBBQ    $0xFFFFFFFFFFFFFFFF, BX
-       SBBQ    $3, R10
+       SBBQ    $3, CX
        CMOVQCS R8, AX
        CMOVQCS R9, BX
-       MOVQ    key+24(FP), R8
-       ADDQ    16(R8), AX
-       ADCQ    24(R8), BX
+       ADDQ    40(SI), AX
+       ADCQ    48(SI), BX
 
        MOVQ AX, 0(DI)
        MOVQ BX, 8(DI)
diff --git a/vendor/golang.org/x/crypto/poly1305/sum_generic.go b/vendor/golang.org/x/crypto/poly1305/sum_generic.go
new file mode 100644 (file)
index 0000000..bab76ef
--- /dev/null
@@ -0,0 +1,172 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package poly1305
+
+import "encoding/binary"
+
+const (
+       msgBlock   = uint32(1 << 24)
+       finalBlock = uint32(0)
+)
+
+// sumGeneric generates an authenticator for msg using a one-time key and
+// puts the 16-byte result into out. This is the generic implementation of
+// Sum and should be called if no assembly implementation is available.
+func sumGeneric(out *[TagSize]byte, msg []byte, key *[32]byte) {
+       h := newMACGeneric(key)
+       h.Write(msg)
+       h.Sum(out)
+}
+
+func newMACGeneric(key *[32]byte) (h macGeneric) {
+       h.r[0] = binary.LittleEndian.Uint32(key[0:]) & 0x3ffffff
+       h.r[1] = (binary.LittleEndian.Uint32(key[3:]) >> 2) & 0x3ffff03
+       h.r[2] = (binary.LittleEndian.Uint32(key[6:]) >> 4) & 0x3ffc0ff
+       h.r[3] = (binary.LittleEndian.Uint32(key[9:]) >> 6) & 0x3f03fff
+       h.r[4] = (binary.LittleEndian.Uint32(key[12:]) >> 8) & 0x00fffff
+
+       h.s[0] = binary.LittleEndian.Uint32(key[16:])
+       h.s[1] = binary.LittleEndian.Uint32(key[20:])
+       h.s[2] = binary.LittleEndian.Uint32(key[24:])
+       h.s[3] = binary.LittleEndian.Uint32(key[28:])
+       return
+}
+
+type macGeneric struct {
+       h, r [5]uint32
+       s    [4]uint32
+
+       buffer [TagSize]byte
+       offset int
+}
+
+func (h *macGeneric) Write(p []byte) (n int, err error) {
+       n = len(p)
+       if h.offset > 0 {
+               remaining := TagSize - h.offset
+               if n < remaining {
+                       h.offset += copy(h.buffer[h.offset:], p)
+                       return n, nil
+               }
+               copy(h.buffer[h.offset:], p[:remaining])
+               p = p[remaining:]
+               h.offset = 0
+               updateGeneric(h.buffer[:], msgBlock, &(h.h), &(h.r))
+       }
+       if nn := len(p) - (len(p) % TagSize); nn > 0 {
+               updateGeneric(p, msgBlock, &(h.h), &(h.r))
+               p = p[nn:]
+       }
+       if len(p) > 0 {
+               h.offset += copy(h.buffer[h.offset:], p)
+       }
+       return n, nil
+}
+
+func (h *macGeneric) Sum(out *[16]byte) {
+       H, R := h.h, h.r
+       if h.offset > 0 {
+               var buffer [TagSize]byte
+               copy(buffer[:], h.buffer[:h.offset])
+               buffer[h.offset] = 1 // invariant: h.offset < TagSize
+               updateGeneric(buffer[:], finalBlock, &H, &R)
+       }
+       finalizeGeneric(out, &H, &(h.s))
+}
+
+func updateGeneric(msg []byte, flag uint32, h, r *[5]uint32) {
+       h0, h1, h2, h3, h4 := h[0], h[1], h[2], h[3], h[4]
+       r0, r1, r2, r3, r4 := uint64(r[0]), uint64(r[1]), uint64(r[2]), uint64(r[3]), uint64(r[4])
+       R1, R2, R3, R4 := r1*5, r2*5, r3*5, r4*5
+
+       for len(msg) >= TagSize {
+               // h += msg
+               h0 += binary.LittleEndian.Uint32(msg[0:]) & 0x3ffffff
+               h1 += (binary.LittleEndian.Uint32(msg[3:]) >> 2) & 0x3ffffff
+               h2 += (binary.LittleEndian.Uint32(msg[6:]) >> 4) & 0x3ffffff
+               h3 += (binary.LittleEndian.Uint32(msg[9:]) >> 6) & 0x3ffffff
+               h4 += (binary.LittleEndian.Uint32(msg[12:]) >> 8) | flag
+
+               // h *= r
+               d0 := (uint64(h0) * r0) + (uint64(h1) * R4) + (uint64(h2) * R3) + (uint64(h3) * R2) + (uint64(h4) * R1)
+               d1 := (d0 >> 26) + (uint64(h0) * r1) + (uint64(h1) * r0) + (uint64(h2) * R4) + (uint64(h3) * R3) + (uint64(h4) * R2)
+               d2 := (d1 >> 26) + (uint64(h0) * r2) + (uint64(h1) * r1) + (uint64(h2) * r0) + (uint64(h3) * R4) + (uint64(h4) * R3)
+               d3 := (d2 >> 26) + (uint64(h0) * r3) + (uint64(h1) * r2) + (uint64(h2) * r1) + (uint64(h3) * r0) + (uint64(h4) * R4)
+               d4 := (d3 >> 26) + (uint64(h0) * r4) + (uint64(h1) * r3) + (uint64(h2) * r2) + (uint64(h3) * r1) + (uint64(h4) * r0)
+
+               // h %= p
+               h0 = uint32(d0) & 0x3ffffff
+               h1 = uint32(d1) & 0x3ffffff
+               h2 = uint32(d2) & 0x3ffffff
+               h3 = uint32(d3) & 0x3ffffff
+               h4 = uint32(d4) & 0x3ffffff
+
+               h0 += uint32(d4>>26) * 5
+               h1 += h0 >> 26
+               h0 = h0 & 0x3ffffff
+
+               msg = msg[TagSize:]
+       }
+
+       h[0], h[1], h[2], h[3], h[4] = h0, h1, h2, h3, h4
+}
+
+func finalizeGeneric(out *[TagSize]byte, h *[5]uint32, s *[4]uint32) {
+       h0, h1, h2, h3, h4 := h[0], h[1], h[2], h[3], h[4]
+
+       // h %= p reduction
+       h2 += h1 >> 26
+       h1 &= 0x3ffffff
+       h3 += h2 >> 26
+       h2 &= 0x3ffffff
+       h4 += h3 >> 26
+       h3 &= 0x3ffffff
+       h0 += 5 * (h4 >> 26)
+       h4 &= 0x3ffffff
+       h1 += h0 >> 26
+       h0 &= 0x3ffffff
+
+       // h - p
+       t0 := h0 + 5
+       t1 := h1 + (t0 >> 26)
+       t2 := h2 + (t1 >> 26)
+       t3 := h3 + (t2 >> 26)
+       t4 := h4 + (t3 >> 26) - (1 << 26)
+       t0 &= 0x3ffffff
+       t1 &= 0x3ffffff
+       t2 &= 0x3ffffff
+       t3 &= 0x3ffffff
+
+       // select h if h < p else h - p
+       t_mask := (t4 >> 31) - 1
+       h_mask := ^t_mask
+       h0 = (h0 & h_mask) | (t0 & t_mask)
+       h1 = (h1 & h_mask) | (t1 & t_mask)
+       h2 = (h2 & h_mask) | (t2 & t_mask)
+       h3 = (h3 & h_mask) | (t3 & t_mask)
+       h4 = (h4 & h_mask) | (t4 & t_mask)
+
+       // h %= 2^128
+       h0 |= h1 << 26
+       h1 = ((h1 >> 6) | (h2 << 20))
+       h2 = ((h2 >> 12) | (h3 << 14))
+       h3 = ((h3 >> 18) | (h4 << 8))
+
+       // s: the s part of the key
+       // tag = (h + s) % (2^128)
+       t := uint64(h0) + uint64(s[0])
+       h0 = uint32(t)
+       t = uint64(h1) + uint64(s[1]) + (t >> 32)
+       h1 = uint32(t)
+       t = uint64(h2) + uint64(s[2]) + (t >> 32)
+       h2 = uint32(t)
+       t = uint64(h3) + uint64(s[3]) + (t >> 32)
+       h3 = uint32(t)
+
+       binary.LittleEndian.PutUint32(out[0:], h0)
+       binary.LittleEndian.PutUint32(out[4:], h1)
+       binary.LittleEndian.PutUint32(out[8:], h2)
+       binary.LittleEndian.PutUint32(out[12:], h3)
+}
index 751eec52743ce32579f4716559abf942d1e6c050..fcdef46ab6e7c76ecfd489e09be26478f1a5c8aa 100644 (file)
@@ -10,5 +10,7 @@ package poly1305
 // 16-byte result into out. Authenticating two different messages with the same
 // key allows an attacker to forge messages at will.
 func Sum(out *[TagSize]byte, msg []byte, key *[32]byte) {
-       sumGeneric(out, msg, key)
+       h := newMAC(key)
+       h.Write(msg)
+       h.Sum(out)
 }
diff --git a/vendor/golang.org/x/crypto/poly1305/sum_ref.go b/vendor/golang.org/x/crypto/poly1305/sum_ref.go
deleted file mode 100644 (file)
index c4d59bd..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 2012 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package poly1305
-
-import "encoding/binary"
-
-// sumGeneric generates an authenticator for msg using a one-time key and
-// puts the 16-byte result into out. This is the generic implementation of
-// Sum and should be called if no assembly implementation is available.
-func sumGeneric(out *[TagSize]byte, msg []byte, key *[32]byte) {
-       var (
-               h0, h1, h2, h3, h4 uint32 // the hash accumulators
-               r0, r1, r2, r3, r4 uint64 // the r part of the key
-       )
-
-       r0 = uint64(binary.LittleEndian.Uint32(key[0:]) & 0x3ffffff)
-       r1 = uint64((binary.LittleEndian.Uint32(key[3:]) >> 2) & 0x3ffff03)
-       r2 = uint64((binary.LittleEndian.Uint32(key[6:]) >> 4) & 0x3ffc0ff)
-       r3 = uint64((binary.LittleEndian.Uint32(key[9:]) >> 6) & 0x3f03fff)
-       r4 = uint64((binary.LittleEndian.Uint32(key[12:]) >> 8) & 0x00fffff)
-
-       R1, R2, R3, R4 := r1*5, r2*5, r3*5, r4*5
-
-       for len(msg) >= TagSize {
-               // h += msg
-               h0 += binary.LittleEndian.Uint32(msg[0:]) & 0x3ffffff
-               h1 += (binary.LittleEndian.Uint32(msg[3:]) >> 2) & 0x3ffffff
-               h2 += (binary.LittleEndian.Uint32(msg[6:]) >> 4) & 0x3ffffff
-               h3 += (binary.LittleEndian.Uint32(msg[9:]) >> 6) & 0x3ffffff
-               h4 += (binary.LittleEndian.Uint32(msg[12:]) >> 8) | (1 << 24)
-
-               // h *= r
-               d0 := (uint64(h0) * r0) + (uint64(h1) * R4) + (uint64(h2) * R3) + (uint64(h3) * R2) + (uint64(h4) * R1)
-               d1 := (d0 >> 26) + (uint64(h0) * r1) + (uint64(h1) * r0) + (uint64(h2) * R4) + (uint64(h3) * R3) + (uint64(h4) * R2)
-               d2 := (d1 >> 26) + (uint64(h0) * r2) + (uint64(h1) * r1) + (uint64(h2) * r0) + (uint64(h3) * R4) + (uint64(h4) * R3)
-               d3 := (d2 >> 26) + (uint64(h0) * r3) + (uint64(h1) * r2) + (uint64(h2) * r1) + (uint64(h3) * r0) + (uint64(h4) * R4)
-               d4 := (d3 >> 26) + (uint64(h0) * r4) + (uint64(h1) * r3) + (uint64(h2) * r2) + (uint64(h3) * r1) + (uint64(h4) * r0)
-
-               // h %= p
-               h0 = uint32(d0) & 0x3ffffff
-               h1 = uint32(d1) & 0x3ffffff
-               h2 = uint32(d2) & 0x3ffffff
-               h3 = uint32(d3) & 0x3ffffff
-               h4 = uint32(d4) & 0x3ffffff
-
-               h0 += uint32(d4>>26) * 5
-               h1 += h0 >> 26
-               h0 = h0 & 0x3ffffff
-
-               msg = msg[TagSize:]
-       }
-
-       if len(msg) > 0 {
-               var block [TagSize]byte
-               off := copy(block[:], msg)
-               block[off] = 0x01
-
-               // h += msg
-               h0 += binary.LittleEndian.Uint32(block[0:]) & 0x3ffffff
-               h1 += (binary.LittleEndian.Uint32(block[3:]) >> 2) & 0x3ffffff
-               h2 += (binary.LittleEndian.Uint32(block[6:]) >> 4) & 0x3ffffff
-               h3 += (binary.LittleEndian.Uint32(block[9:]) >> 6) & 0x3ffffff
-               h4 += (binary.LittleEndian.Uint32(block[12:]) >> 8)
-
-               // h *= r
-               d0 := (uint64(h0) * r0) + (uint64(h1) * R4) + (uint64(h2) * R3) + (uint64(h3) * R2) + (uint64(h4) * R1)
-               d1 := (d0 >> 26) + (uint64(h0) * r1) + (uint64(h1) * r0) + (uint64(h2) * R4) + (uint64(h3) * R3) + (uint64(h4) * R2)
-               d2 := (d1 >> 26) + (uint64(h0) * r2) + (uint64(h1) * r1) + (uint64(h2) * r0) + (uint64(h3) * R4) + (uint64(h4) * R3)
-               d3 := (d2 >> 26) + (uint64(h0) * r3) + (uint64(h1) * r2) + (uint64(h2) * r1) + (uint64(h3) * r0) + (uint64(h4) * R4)
-               d4 := (d3 >> 26) + (uint64(h0) * r4) + (uint64(h1) * r3) + (uint64(h2) * r2) + (uint64(h3) * r1) + (uint64(h4) * r0)
-
-               // h %= p
-               h0 = uint32(d0) & 0x3ffffff
-               h1 = uint32(d1) & 0x3ffffff
-               h2 = uint32(d2) & 0x3ffffff
-               h3 = uint32(d3) & 0x3ffffff
-               h4 = uint32(d4) & 0x3ffffff
-
-               h0 += uint32(d4>>26) * 5
-               h1 += h0 >> 26
-               h0 = h0 & 0x3ffffff
-       }
-
-       // h %= p reduction
-       h2 += h1 >> 26
-       h1 &= 0x3ffffff
-       h3 += h2 >> 26
-       h2 &= 0x3ffffff
-       h4 += h3 >> 26
-       h3 &= 0x3ffffff
-       h0 += 5 * (h4 >> 26)
-       h4 &= 0x3ffffff
-       h1 += h0 >> 26
-       h0 &= 0x3ffffff
-
-       // h - p
-       t0 := h0 + 5
-       t1 := h1 + (t0 >> 26)
-       t2 := h2 + (t1 >> 26)
-       t3 := h3 + (t2 >> 26)
-       t4 := h4 + (t3 >> 26) - (1 << 26)
-       t0 &= 0x3ffffff
-       t1 &= 0x3ffffff
-       t2 &= 0x3ffffff
-       t3 &= 0x3ffffff
-
-       // select h if h < p else h - p
-       t_mask := (t4 >> 31) - 1
-       h_mask := ^t_mask
-       h0 = (h0 & h_mask) | (t0 & t_mask)
-       h1 = (h1 & h_mask) | (t1 & t_mask)
-       h2 = (h2 & h_mask) | (t2 & t_mask)
-       h3 = (h3 & h_mask) | (t3 & t_mask)
-       h4 = (h4 & h_mask) | (t4 & t_mask)
-
-       // h %= 2^128
-       h0 |= h1 << 26
-       h1 = ((h1 >> 6) | (h2 << 20))
-       h2 = ((h2 >> 12) | (h3 << 14))
-       h3 = ((h3 >> 18) | (h4 << 8))
-
-       // s: the s part of the key
-       // tag = (h + s) % (2^128)
-       t := uint64(h0) + uint64(binary.LittleEndian.Uint32(key[16:]))
-       h0 = uint32(t)
-       t = uint64(h1) + uint64(binary.LittleEndian.Uint32(key[20:])) + (t >> 32)
-       h1 = uint32(t)
-       t = uint64(h2) + uint64(binary.LittleEndian.Uint32(key[24:])) + (t >> 32)
-       h2 = uint32(t)
-       t = uint64(h3) + uint64(binary.LittleEndian.Uint32(key[28:])) + (t >> 32)
-       h3 = uint32(t)
-
-       binary.LittleEndian.PutUint32(out[0:], h0)
-       binary.LittleEndian.PutUint32(out[4:], h1)
-       binary.LittleEndian.PutUint32(out[8:], h2)
-       binary.LittleEndian.PutUint32(out[12:], h3)
-}
index 7a266cece46adad6e09165b48e7afa83e90c9fca..ec99e07e9fb4963224bbb6f985c82357923b4ab9 100644 (file)
@@ -6,16 +6,9 @@
 
 package poly1305
 
-// hasVectorFacility reports whether the machine supports
-// the vector facility (vx).
-func hasVectorFacility() bool
-
-// hasVMSLFacility reports whether the machine supports
-// Vector Multiply Sum Logical (VMSL).
-func hasVMSLFacility() bool
-
-var hasVX = hasVectorFacility()
-var hasVMSL = hasVMSLFacility()
+import (
+       "golang.org/x/sys/cpu"
+)
 
 // poly1305vx is an assembly implementation of Poly1305 that uses vector
 // instructions. It must only be called if the vector facility (vx) is
@@ -33,12 +26,12 @@ func poly1305vmsl(out *[16]byte, m *byte, mlen uint64, key *[32]byte)
 // 16-byte result into out. Authenticating two different messages with the same
 // key allows an attacker to forge messages at will.
 func Sum(out *[16]byte, m []byte, key *[32]byte) {
-       if hasVX {
+       if cpu.S390X.HasVX {
                var mPtr *byte
                if len(m) > 0 {
                        mPtr = &m[0]
                }
-               if hasVMSL && len(m) > 256 {
+               if cpu.S390X.HasVXE && len(m) > 256 {
                        poly1305vmsl(out, mPtr, uint64(len(m)), key)
                } else {
                        poly1305vx(out, mPtr, uint64(len(m)), key)
index 356c07a6c2b122ec9c205dca9c8d6a35229756b9..ca5a309d8672ceb31e43bc2236505fb257acdbff 100644 (file)
@@ -376,25 +376,3 @@ b1:
 
        MOVD $0, R3
        BR   multiply
-
-TEXT ·hasVectorFacility(SB), NOSPLIT, $24-1
-       MOVD  $x-24(SP), R1
-       XC    $24, 0(R1), 0(R1) // clear the storage
-       MOVD  $2, R0            // R0 is the number of double words stored -1
-       WORD  $0xB2B01000       // STFLE 0(R1)
-       XOR   R0, R0            // reset the value of R0
-       MOVBZ z-8(SP), R1
-       AND   $0x40, R1
-       BEQ   novector
-
-vectorinstalled:
-       // check if the vector instruction has been enabled
-       VLEIB  $0, $0xF, V16
-       VLGVB  $0, V16, R1
-       CMPBNE R1, $0xF, novector
-       MOVB   $1, ret+0(FP)      // have vx
-       RET
-
-novector:
-       MOVB $0, ret+0(FP) // no vx
-       RET
index e548020b14e198b9824ab47927365bc86f68a91a..e60bbc1d7f89f88a298f9ffcd271288017f68a77 100644 (file)
@@ -907,25 +907,3 @@ square:
        MULTIPLY(H0_0, H1_0, H2_0, H0_1, H1_1, H2_1, R_0, R_1, R_2, R5_1, R5_2, M0, M1, M2, M3, M4, M5, T_0, T_1, T_2, T_3, T_4, T_5, T_6, T_7, T_8, T_9)
        REDUCE2(H0_0, H1_0, H2_0, M0, M1, M2, M3, M4, T_9, T_10, H0_1, M5)
        BR next
-
-TEXT ·hasVMSLFacility(SB), NOSPLIT, $24-1
-       MOVD  $x-24(SP), R1
-       XC    $24, 0(R1), 0(R1) // clear the storage
-       MOVD  $2, R0            // R0 is the number of double words stored -1
-       WORD  $0xB2B01000       // STFLE 0(R1)
-       XOR   R0, R0            // reset the value of R0
-       MOVBZ z-8(SP), R1
-       AND   $0x01, R1
-       BEQ   novmsl
-
-vectorinstalled:
-       // check if the vector instruction has been enabled
-       VLEIB  $0, $0xF, V16
-       VLGVB  $0, V16, R1
-       CMPBNE R1, $0xF, novmsl
-       MOVB   $1, ret+0(FP)    // have vx
-       RET
-
-novmsl:
-       MOVB $0, ret+0(FP) // no vx
-       RET
index b1808dd26798e71ef2601c8b21649cfb85c2bcce..51f740500e68decf9f2d693d9dcc17edf9584ace 100644 (file)
@@ -25,10 +25,22 @@ import (
        "math/big"
        "sync"
 
+       "crypto"
        "golang.org/x/crypto/ed25519"
        "golang.org/x/crypto/ssh"
 )
 
+// SignatureFlags represent additional flags that can be passed to the signature
+// requests an defined in [PROTOCOL.agent] section 4.5.1.
+type SignatureFlags uint32
+
+// SignatureFlag values as defined in [PROTOCOL.agent] section 5.3.
+const (
+       SignatureFlagReserved SignatureFlags = 1 << iota
+       SignatureFlagRsaSha256
+       SignatureFlagRsaSha512
+)
+
 // Agent represents the capabilities of an ssh-agent.
 type Agent interface {
        // List returns the identities known to the agent.
@@ -57,6 +69,26 @@ type Agent interface {
        Signers() ([]ssh.Signer, error)
 }
 
+type ExtendedAgent interface {
+       Agent
+
+       // SignWithFlags signs like Sign, but allows for additional flags to be sent/received
+       SignWithFlags(key ssh.PublicKey, data []byte, flags SignatureFlags) (*ssh.Signature, error)
+
+       // Extension processes a custom extension request. Standard-compliant agents are not
+       // required to support any extensions, but this method allows agents to implement
+       // vendor-specific methods or add experimental features. See [PROTOCOL.agent] section 4.7.
+       // If agent extensions are unsupported entirely this method MUST return an
+       // ErrExtensionUnsupported error. Similarly, if just the specific extensionType in
+       // the request is unsupported by the agent then ErrExtensionUnsupported MUST be
+       // returned.
+       //
+       // In the case of success, since [PROTOCOL.agent] section 4.7 specifies that the contents
+       // of the response are unspecified (including the type of the message), the complete
+       // response will be returned as a []byte slice, including the "type" byte of the message.
+       Extension(extensionType string, contents []byte) ([]byte, error)
+}
+
 // ConstraintExtension describes an optional constraint defined by users.
 type ConstraintExtension struct {
        // ExtensionName consist of a UTF-8 string suffixed by the
@@ -179,6 +211,23 @@ type constrainExtensionAgentMsg struct {
        Rest []byte `ssh:"rest"`
 }
 
+// See [PROTOCOL.agent], section 4.7
+const agentExtension = 27
+const agentExtensionFailure = 28
+
+// ErrExtensionUnsupported indicates that an extension defined in
+// [PROTOCOL.agent] section 4.7 is unsupported by the agent. Specifically this
+// error indicates that the agent returned a standard SSH_AGENT_FAILURE message
+// as the result of a SSH_AGENTC_EXTENSION request. Note that the protocol
+// specification (and therefore this error) does not distinguish between a
+// specific extension being unsupported and extensions being unsupported entirely.
+var ErrExtensionUnsupported = errors.New("agent: extension unsupported")
+
+type extensionAgentMsg struct {
+       ExtensionType string `sshtype:"27"`
+       Contents      []byte
+}
+
 // Key represents a protocol 2 public key as defined in
 // [PROTOCOL.agent], section 2.5.2.
 type Key struct {
@@ -260,7 +309,7 @@ type client struct {
 
 // NewClient returns an Agent that talks to an ssh-agent process over
 // the given connection.
-func NewClient(rw io.ReadWriter) Agent {
+func NewClient(rw io.ReadWriter) ExtendedAgent {
        return &client{conn: rw}
 }
 
@@ -268,6 +317,21 @@ func NewClient(rw io.ReadWriter) Agent {
 // unmarshaled into reply and replyType is set to the first byte of
 // the reply, which contains the type of the message.
 func (c *client) call(req []byte) (reply interface{}, err error) {
+       buf, err := c.callRaw(req)
+       if err != nil {
+               return nil, err
+       }
+       reply, err = unmarshal(buf)
+       if err != nil {
+               return nil, clientErr(err)
+       }
+       return reply, nil
+}
+
+// callRaw sends an RPC to the agent. On success, the raw
+// bytes of the response are returned; no unmarshalling is
+// performed on the response.
+func (c *client) callRaw(req []byte) (reply []byte, err error) {
        c.mu.Lock()
        defer c.mu.Unlock()
 
@@ -284,18 +348,14 @@ func (c *client) call(req []byte) (reply interface{}, err error) {
        }
        respSize := binary.BigEndian.Uint32(respSizeBuf[:])
        if respSize > maxAgentResponseBytes {
-               return nil, clientErr(err)
+               return nil, clientErr(errors.New("response too large"))
        }
 
        buf := make([]byte, respSize)
        if _, err = io.ReadFull(c.conn, buf); err != nil {
                return nil, clientErr(err)
        }
-       reply, err = unmarshal(buf)
-       if err != nil {
-               return nil, clientErr(err)
-       }
-       return reply, err
+       return buf, nil
 }
 
 func (c *client) simpleCall(req []byte) error {
@@ -369,9 +429,14 @@ func (c *client) List() ([]*Key, error) {
 // Sign has the agent sign the data using a protocol 2 key as defined
 // in [PROTOCOL.agent] section 2.6.2.
 func (c *client) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error) {
+       return c.SignWithFlags(key, data, 0)
+}
+
+func (c *client) SignWithFlags(key ssh.PublicKey, data []byte, flags SignatureFlags) (*ssh.Signature, error) {
        req := ssh.Marshal(signRequestAgentMsg{
                KeyBlob: key.Marshal(),
                Data:    data,
+               Flags:   uint32(flags),
        })
 
        msg, err := c.call(req)
@@ -681,3 +746,44 @@ func (s *agentKeyringSigner) Sign(rand io.Reader, data []byte) (*ssh.Signature,
        // The agent has its own entropy source, so the rand argument is ignored.
        return s.agent.Sign(s.pub, data)
 }
+
+func (s *agentKeyringSigner) SignWithOpts(rand io.Reader, data []byte, opts crypto.SignerOpts) (*ssh.Signature, error) {
+       var flags SignatureFlags
+       if opts != nil {
+               switch opts.HashFunc() {
+               case crypto.SHA256:
+                       flags = SignatureFlagRsaSha256
+               case crypto.SHA512:
+                       flags = SignatureFlagRsaSha512
+               }
+       }
+       return s.agent.SignWithFlags(s.pub, data, flags)
+}
+
+// Calls an extension method. It is up to the agent implementation as to whether or not
+// any particular extension is supported and may always return an error. Because the
+// type of the response is up to the implementation, this returns the bytes of the
+// response and does not attempt any type of unmarshalling.
+func (c *client) Extension(extensionType string, contents []byte) ([]byte, error) {
+       req := ssh.Marshal(extensionAgentMsg{
+               ExtensionType: extensionType,
+               Contents:      contents,
+       })
+       buf, err := c.callRaw(req)
+       if err != nil {
+               return nil, err
+       }
+       if len(buf) == 0 {
+               return nil, errors.New("agent: failure; empty response")
+       }
+       // [PROTOCOL.agent] section 4.7 indicates that an SSH_AGENT_FAILURE message
+       // represents an agent that does not support the extension
+       if buf[0] == agentFailure {
+               return nil, ErrExtensionUnsupported
+       }
+       if buf[0] == agentExtensionFailure {
+               return nil, errors.New("agent: generic extension failure")
+       }
+
+       return buf, nil
+}
index 1a5163270c051b79e5208037809f13d51a512960..c9d9794307125ca27d85ca91f3040de15e504f3f 100644 (file)
@@ -182,6 +182,10 @@ func (r *keyring) Add(key AddedKey) error {
 
 // Sign returns a signature for the data.
 func (r *keyring) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error) {
+       return r.SignWithFlags(key, data, 0)
+}
+
+func (r *keyring) SignWithFlags(key ssh.PublicKey, data []byte, flags SignatureFlags) (*ssh.Signature, error) {
        r.mu.Lock()
        defer r.mu.Unlock()
        if r.locked {
@@ -192,7 +196,24 @@ func (r *keyring) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error) {
        wanted := key.Marshal()
        for _, k := range r.keys {
                if bytes.Equal(k.signer.PublicKey().Marshal(), wanted) {
-                       return k.signer.Sign(rand.Reader, data)
+                       if flags == 0 {
+                               return k.signer.Sign(rand.Reader, data)
+                       } else {
+                               if algorithmSigner, ok := k.signer.(ssh.AlgorithmSigner); !ok {
+                                       return nil, fmt.Errorf("agent: signature does not support non-default signature algorithm: %T", k.signer)
+                               } else {
+                                       var algorithm string
+                                       switch flags {
+                                       case SignatureFlagRsaSha256:
+                                               algorithm = ssh.SigAlgoRSASHA2256
+                                       case SignatureFlagRsaSha512:
+                                               algorithm = ssh.SigAlgoRSASHA2512
+                                       default:
+                                               return nil, fmt.Errorf("agent: unsupported signature flags: %d", flags)
+                                       }
+                                       return algorithmSigner.SignWithAlgorithm(rand.Reader, data, algorithm)
+                               }
+                       }
                }
        }
        return nil, errors.New("not found")
@@ -213,3 +234,8 @@ func (r *keyring) Signers() ([]ssh.Signer, error) {
        }
        return s, nil
 }
+
+// The keyring does not support any extensions
+func (r *keyring) Extension(extensionType string, contents []byte) ([]byte, error) {
+       return nil, ErrExtensionUnsupported
+}
index 2e4692cbd5a033e30474cc0f01ea209a88f132fc..6e7a1e02f27bc12aa333baad31ef390e78d22299 100644 (file)
@@ -128,7 +128,14 @@ func (s *server) processRequest(data []byte) (interface{}, error) {
                        Blob:   req.KeyBlob,
                }
 
-               sig, err := s.agent.Sign(k, req.Data) //  TODO(hanwen): flags.
+               var sig *ssh.Signature
+               var err error
+               if extendedAgent, ok := s.agent.(ExtendedAgent); ok {
+                       sig, err = extendedAgent.SignWithFlags(k, req.Data, SignatureFlags(req.Flags))
+               } else {
+                       sig, err = s.agent.Sign(k, req.Data)
+               }
+
                if err != nil {
                        return nil, err
                }
@@ -150,6 +157,43 @@ func (s *server) processRequest(data []byte) (interface{}, error) {
 
        case agentAddIDConstrained, agentAddIdentity:
                return nil, s.insertIdentity(data)
+
+       case agentExtension:
+               // Return a stub object where the whole contents of the response gets marshaled.
+               var responseStub struct {
+                       Rest []byte `ssh:"rest"`
+               }
+
+               if extendedAgent, ok := s.agent.(ExtendedAgent); !ok {
+                       // If this agent doesn't implement extensions, [PROTOCOL.agent] section 4.7
+                       // requires that we return a standard SSH_AGENT_FAILURE message.
+                       responseStub.Rest = []byte{agentFailure}
+               } else {
+                       var req extensionAgentMsg
+                       if err := ssh.Unmarshal(data, &req); err != nil {
+                               return nil, err
+                       }
+                       res, err := extendedAgent.Extension(req.ExtensionType, req.Contents)
+                       if err != nil {
+                               // If agent extensions are unsupported, return a standard SSH_AGENT_FAILURE
+                               // message as required by [PROTOCOL.agent] section 4.7.
+                               if err == ErrExtensionUnsupported {
+                                       responseStub.Rest = []byte{agentFailure}
+                               } else {
+                                       // As the result of any other error processing an extension request,
+                                       // [PROTOCOL.agent] section 4.7 requires that we return a
+                                       // SSH_AGENT_EXTENSION_FAILURE code.
+                                       responseStub.Rest = []byte{agentExtensionFailure}
+                               }
+                       } else {
+                               if len(res) == 0 {
+                                       return nil, nil
+                               }
+                               responseStub.Rest = res
+                       }
+               }
+
+               return responseStub, nil
        }
 
        return nil, fmt.Errorf("unknown opcode %d", data[0])
@@ -497,6 +541,9 @@ func ServeAgent(agent Agent, c io.ReadWriter) error {
                        return err
                }
                l := binary.BigEndian.Uint32(length[:])
+               if l == 0 {
+                       return fmt.Errorf("agent: request size is 0")
+               }
                if l > maxAgentResponseBytes {
                        // We also cap requests.
                        return fmt.Errorf("agent: request too large: %d", l)
index 42106f3f2cb11ed4615735c588e71edff7a6bf11..00ed9923e784be4f362611a11cbb8767ecac05a8 100644 (file)
@@ -222,6 +222,11 @@ type openSSHCertSigner struct {
        signer Signer
 }
 
+type algorithmOpenSSHCertSigner struct {
+       *openSSHCertSigner
+       algorithmSigner AlgorithmSigner
+}
+
 // NewCertSigner returns a Signer that signs with the given Certificate, whose
 // private key is held by signer. It returns an error if the public key in cert
 // doesn't match the key used by signer.
@@ -230,7 +235,12 @@ func NewCertSigner(cert *Certificate, signer Signer) (Signer, error) {
                return nil, errors.New("ssh: signer and cert have different public key")
        }
 
-       return &openSSHCertSigner{cert, signer}, nil
+       if algorithmSigner, ok := signer.(AlgorithmSigner); ok {
+               return &algorithmOpenSSHCertSigner{
+                       &openSSHCertSigner{cert, signer}, algorithmSigner}, nil
+       } else {
+               return &openSSHCertSigner{cert, signer}, nil
+       }
 }
 
 func (s *openSSHCertSigner) Sign(rand io.Reader, data []byte) (*Signature, error) {
@@ -241,6 +251,10 @@ func (s *openSSHCertSigner) PublicKey() PublicKey {
        return s.pub
 }
 
+func (s *algorithmOpenSSHCertSigner) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error) {
+       return s.algorithmSigner.SignWithAlgorithm(rand, data, algorithm)
+}
+
 const sourceAddressCriticalOption = "source-address"
 
 // CertChecker does the work of verifying a certificate. Its methods
index 67b0126105944fa06accf88bde03bb0b5c397da0..a65a923be3d13c82e246753eaec6e3feebfdf445 100644 (file)
@@ -149,8 +149,8 @@ type streamPacketCipher struct {
        macResult   []byte
 }
 
-// readPacket reads and decrypt a single packet from the reader argument.
-func (s *streamPacketCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
+// readCipherPacket reads and decrypt a single packet from the reader argument.
+func (s *streamPacketCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) {
        if _, err := io.ReadFull(r, s.prefix[:]); err != nil {
                return nil, err
        }
@@ -221,8 +221,8 @@ func (s *streamPacketCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, err
        return s.packetData[:length-paddingLength-1], nil
 }
 
-// writePacket encrypts and sends a packet of data to the writer argument
-func (s *streamPacketCipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
+// writeCipherPacket encrypts and sends a packet of data to the writer argument
+func (s *streamPacketCipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
        if len(packet) > maxPacket {
                return errors.New("ssh: packet too large")
        }
@@ -327,7 +327,7 @@ func newGCMCipher(key, iv, unusedMacKey []byte, unusedAlgs directionAlgorithms)
 
 const gcmTagSize = 16
 
-func (c *gcmCipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
+func (c *gcmCipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
        // Pad out to multiple of 16 bytes. This is different from the
        // stream cipher because that encrypts the length too.
        padding := byte(packetSizeMultiple - (1+len(packet))%packetSizeMultiple)
@@ -370,7 +370,7 @@ func (c *gcmCipher) incIV() {
        }
 }
 
-func (c *gcmCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
+func (c *gcmCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) {
        if _, err := io.ReadFull(r, c.prefix[:]); err != nil {
                return nil, err
        }
@@ -486,8 +486,8 @@ type cbcError string
 
 func (e cbcError) Error() string { return string(e) }
 
-func (c *cbcCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
-       p, err := c.readPacketLeaky(seqNum, r)
+func (c *cbcCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) {
+       p, err := c.readCipherPacketLeaky(seqNum, r)
        if err != nil {
                if _, ok := err.(cbcError); ok {
                        // Verification error: read a fixed amount of
@@ -500,7 +500,7 @@ func (c *cbcCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
        return p, err
 }
 
-func (c *cbcCipher) readPacketLeaky(seqNum uint32, r io.Reader) ([]byte, error) {
+func (c *cbcCipher) readCipherPacketLeaky(seqNum uint32, r io.Reader) ([]byte, error) {
        blockSize := c.decrypter.BlockSize()
 
        // Read the header, which will include some of the subsequent data in the
@@ -576,7 +576,7 @@ func (c *cbcCipher) readPacketLeaky(seqNum uint32, r io.Reader) ([]byte, error)
        return c.packetData[prefixLen:paddingStart], nil
 }
 
-func (c *cbcCipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
+func (c *cbcCipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, packet []byte) error {
        effectiveBlockSize := maxUInt32(cbcMinPacketSizeMultiple, c.encrypter.BlockSize())
 
        // Length of encrypted portion of the packet (header, payload, padding).
@@ -665,7 +665,7 @@ func newChaCha20Cipher(key, unusedIV, unusedMACKey []byte, unusedAlgs directionA
        return c, nil
 }
 
-func (c *chacha20Poly1305Cipher) readPacket(seqNum uint32, r io.Reader) ([]byte, error) {
+func (c *chacha20Poly1305Cipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) {
        nonce := [3]uint32{0, 0, bits.ReverseBytes32(seqNum)}
        s := chacha20.New(c.contentKey, nonce)
        var polyKey [32]byte
@@ -723,7 +723,7 @@ func (c *chacha20Poly1305Cipher) readPacket(seqNum uint32, r io.Reader) ([]byte,
        return plain, nil
 }
 
-func (c *chacha20Poly1305Cipher) writePacket(seqNum uint32, w io.Writer, rand io.Reader, payload []byte) error {
+func (c *chacha20Poly1305Cipher) writeCipherPacket(seqNum uint32, w io.Writer, rand io.Reader, payload []byte) error {
        nonce := [3]uint32{0, 0, bits.ReverseBytes32(seqNum)}
        s := chacha20.New(c.contentKey, nonce)
        var polyKey [32]byte
index ae6ca775eed63f44582010b355e062a02e3afc7d..7b00bff1caa5e74bfecf45b90eb00d89ae2483e4 100644 (file)
@@ -185,7 +185,7 @@ func Dial(network, addr string, config *ClientConfig) (*Client, error) {
 // keys.  A HostKeyCallback must return nil if the host key is OK, or
 // an error to reject it. It receives the hostname as passed to Dial
 // or NewClientConn. The remote address is the RemoteAddr of the
-// net.Conn underlying the the SSH connection.
+// net.Conn underlying the SSH connection.
 type HostKeyCallback func(hostname string, remote net.Addr, key PublicKey) error
 
 // BannerCallback is the function type used for treat the banner sent by
index 04f3620b3d5ebe9252b0c8cabe2c4a54181d1548..d97415d2d365fd7d7b2ccb9adeaac335a8abc7e7 100644 (file)
@@ -109,6 +109,7 @@ func findCommon(what string, client []string, server []string) (common string, e
        return "", fmt.Errorf("ssh: no common algorithm for %s; client offered: %v, server offered: %v", what, client, server)
 }
 
+// directionAlgorithms records algorithm choices in one direction (either read or write)
 type directionAlgorithms struct {
        Cipher      string
        MAC         string
@@ -137,7 +138,7 @@ type algorithms struct {
        r       directionAlgorithms
 }
 
-func findAgreedAlgorithms(clientKexInit, serverKexInit *kexInitMsg) (algs *algorithms, err error) {
+func findAgreedAlgorithms(isClient bool, clientKexInit, serverKexInit *kexInitMsg) (algs *algorithms, err error) {
        result := &algorithms{}
 
        result.kex, err = findCommon("key exchange", clientKexInit.KexAlgos, serverKexInit.KexAlgos)
@@ -150,32 +151,37 @@ func findAgreedAlgorithms(clientKexInit, serverKexInit *kexInitMsg) (algs *algor
                return
        }
 
-       result.w.Cipher, err = findCommon("client to server cipher", clientKexInit.CiphersClientServer, serverKexInit.CiphersClientServer)
+       stoc, ctos := &result.w, &result.r
+       if isClient {
+               ctos, stoc = stoc, ctos
+       }
+
+       ctos.Cipher, err = findCommon("client to server cipher", clientKexInit.CiphersClientServer, serverKexInit.CiphersClientServer)
        if err != nil {
                return
        }
 
-       result.r.Cipher, err = findCommon("server to client cipher", clientKexInit.CiphersServerClient, serverKexInit.CiphersServerClient)
+       stoc.Cipher, err = findCommon("server to client cipher", clientKexInit.CiphersServerClient, serverKexInit.CiphersServerClient)
        if err != nil {
                return
        }
 
-       result.w.MAC, err = findCommon("client to server MAC", clientKexInit.MACsClientServer, serverKexInit.MACsClientServer)
+       ctos.MAC, err = findCommon("client to server MAC", clientKexInit.MACsClientServer, serverKexInit.MACsClientServer)
        if err != nil {
                return
        }
 
-       result.r.MAC, err = findCommon("server to client MAC", clientKexInit.MACsServerClient, serverKexInit.MACsServerClient)
+       stoc.MAC, err = findCommon("server to client MAC", clientKexInit.MACsServerClient, serverKexInit.MACsServerClient)
        if err != nil {
                return
        }
 
-       result.w.Compression, err = findCommon("client to server compression", clientKexInit.CompressionClientServer, serverKexInit.CompressionClientServer)
+       ctos.Compression, err = findCommon("client to server compression", clientKexInit.CompressionClientServer, serverKexInit.CompressionClientServer)
        if err != nil {
                return
        }
 
-       result.r.Compression, err = findCommon("server to client compression", clientKexInit.CompressionServerClient, serverKexInit.CompressionServerClient)
+       stoc.Compression, err = findCommon("server to client compression", clientKexInit.CompressionServerClient, serverKexInit.CompressionServerClient)
        if err != nil {
                return
        }
index 4f7912ecd6565bf1b5405b7c2a68d31493411697..2b10b05a498c18b27f82f4266596573c7d56a82d 100644 (file)
@@ -543,7 +543,8 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
 
        clientInit := otherInit
        serverInit := t.sentInitMsg
-       if len(t.hostKeys) == 0 {
+       isClient := len(t.hostKeys) == 0
+       if isClient {
                clientInit, serverInit = serverInit, clientInit
 
                magics.clientKexInit = t.sentInitPacket
@@ -551,7 +552,7 @@ func (t *handshakeTransport) enterKeyExchange(otherInitPacket []byte) error {
        }
 
        var err error
-       t.algorithms, err = findAgreedAlgorithms(clientInit, serverInit)
+       t.algorithms, err = findAgreedAlgorithms(isClient, clientInit, serverInit)
        if err != nil {
                return err
        }
index 2261dc386c30987b471a60ef7dae25217ba2b38e..969804794fb80c1d24598f52959d390f12128295 100644 (file)
@@ -38,6 +38,16 @@ const (
        KeyAlgoED25519  = "ssh-ed25519"
 )
 
+// These constants represent non-default signature algorithms that are supported
+// as algorithm parameters to AlgorithmSigner.SignWithAlgorithm methods. See
+// [PROTOCOL.agent] section 4.5.1 and
+// https://tools.ietf.org/html/draft-ietf-curdle-rsa-sha2-10
+const (
+       SigAlgoRSA        = "ssh-rsa"
+       SigAlgoRSASHA2256 = "rsa-sha2-256"
+       SigAlgoRSASHA2512 = "rsa-sha2-512"
+)
+
 // parsePubKey parses a public key of the given algorithm.
 // Use ParsePublicKey for keys with prepended algorithm.
 func parsePubKey(in []byte, algo string) (pubKey PublicKey, rest []byte, err error) {
@@ -301,6 +311,19 @@ type Signer interface {
        Sign(rand io.Reader, data []byte) (*Signature, error)
 }
 
+// A AlgorithmSigner is a Signer that also supports specifying a specific
+// algorithm to use for signing.
+type AlgorithmSigner interface {
+       Signer
+
+       // SignWithAlgorithm is like Signer.Sign, but allows specification of a
+       // non-default signing algorithm. See the SigAlgo* constants in this
+       // package for signature algorithms supported by this package. Callers may
+       // pass an empty string for the algorithm in which case the AlgorithmSigner
+       // will use its default algorithm.
+       SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error)
+}
+
 type rsaPublicKey rsa.PublicKey
 
 func (r *rsaPublicKey) Type() string {
@@ -349,13 +372,21 @@ func (r *rsaPublicKey) Marshal() []byte {
 }
 
 func (r *rsaPublicKey) Verify(data []byte, sig *Signature) error {
-       if sig.Format != r.Type() {
+       var hash crypto.Hash
+       switch sig.Format {
+       case SigAlgoRSA:
+               hash = crypto.SHA1
+       case SigAlgoRSASHA2256:
+               hash = crypto.SHA256
+       case SigAlgoRSASHA2512:
+               hash = crypto.SHA512
+       default:
                return fmt.Errorf("ssh: signature type %s for key type %s", sig.Format, r.Type())
        }
-       h := crypto.SHA1.New()
+       h := hash.New()
        h.Write(data)
        digest := h.Sum(nil)
-       return rsa.VerifyPKCS1v15((*rsa.PublicKey)(r), crypto.SHA1, digest, sig.Blob)
+       return rsa.VerifyPKCS1v15((*rsa.PublicKey)(r), hash, digest, sig.Blob)
 }
 
 func (r *rsaPublicKey) CryptoPublicKey() crypto.PublicKey {
@@ -459,6 +490,14 @@ func (k *dsaPrivateKey) PublicKey() PublicKey {
 }
 
 func (k *dsaPrivateKey) Sign(rand io.Reader, data []byte) (*Signature, error) {
+       return k.SignWithAlgorithm(rand, data, "")
+}
+
+func (k *dsaPrivateKey) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error) {
+       if algorithm != "" && algorithm != k.PublicKey().Type() {
+               return nil, fmt.Errorf("ssh: unsupported signature algorithm %s", algorithm)
+       }
+
        h := crypto.SHA1.New()
        h.Write(data)
        digest := h.Sum(nil)
@@ -691,16 +730,42 @@ func (s *wrappedSigner) PublicKey() PublicKey {
 }
 
 func (s *wrappedSigner) Sign(rand io.Reader, data []byte) (*Signature, error) {
+       return s.SignWithAlgorithm(rand, data, "")
+}
+
+func (s *wrappedSigner) SignWithAlgorithm(rand io.Reader, data []byte, algorithm string) (*Signature, error) {
        var hashFunc crypto.Hash
 
-       switch key := s.pubKey.(type) {
-       case *rsaPublicKey, *dsaPublicKey:
-               hashFunc = crypto.SHA1
-       case *ecdsaPublicKey:
-               hashFunc = ecHash(key.Curve)
-       case ed25519PublicKey:
-       default:
-               return nil, fmt.Errorf("ssh: unsupported key type %T", key)
+       if _, ok := s.pubKey.(*rsaPublicKey); ok {
+               // RSA keys support a few hash functions determined by the requested signature algorithm
+               switch algorithm {
+               case "", SigAlgoRSA:
+                       algorithm = SigAlgoRSA
+                       hashFunc = crypto.SHA1
+               case SigAlgoRSASHA2256:
+                       hashFunc = crypto.SHA256
+               case SigAlgoRSASHA2512:
+                       hashFunc = crypto.SHA512
+               default:
+                       return nil, fmt.Errorf("ssh: unsupported signature algorithm %s", algorithm)
+               }
+       } else {
+               // The only supported algorithm for all other key types is the same as the type of the key
+               if algorithm == "" {
+                       algorithm = s.pubKey.Type()
+               } else if algorithm != s.pubKey.Type() {
+                       return nil, fmt.Errorf("ssh: unsupported signature algorithm %s", algorithm)
+               }
+
+               switch key := s.pubKey.(type) {
+               case *dsaPublicKey:
+                       hashFunc = crypto.SHA1
+               case *ecdsaPublicKey:
+                       hashFunc = ecHash(key.Curve)
+               case ed25519PublicKey:
+               default:
+                       return nil, fmt.Errorf("ssh: unsupported key type %T", key)
+               }
        }
 
        var digest []byte
@@ -745,7 +810,7 @@ func (s *wrappedSigner) Sign(rand io.Reader, data []byte) (*Signature, error) {
        }
 
        return &Signature{
-               Format: s.pubKey.Type(),
+               Format: algorithm,
                Blob:   signature,
        }, nil
 }
index bc3db737e5daee9834256eda7322acba38aa763d..260cfe58c65448d633da0da9bc972fc7ce967333 100644 (file)
@@ -350,8 +350,8 @@ func (db *hostKeyDB) check(address string, remote net.Addr, remoteKey ssh.Public
        return db.checkAddr(hostToCheck, remoteKey)
 }
 
-// checkAddrs checks if we can find the given public key for any of
-// the given addresses.  If we only find an entry for the IP address,
+// checkAddr checks if we can find the given public key for the
+// given address.  If we only find an entry for the IP address,
 // or only the hostname, then this still succeeds.
 func (db *hostKeyDB) checkAddr(a addr, remoteKey ssh.PublicKey) error {
        // TODO(hanwen): are these the right semantics? What if there
index 08d28117305d9d3ec4c6cfeef36931203e1aac96..5ec42afa3bcfe106a0a1d79970f7df87df40ed10 100644 (file)
@@ -764,3 +764,29 @@ func decode(packet []byte) (interface{}, error) {
        }
        return msg, nil
 }
+
+var packetTypeNames = map[byte]string{
+       msgDisconnect:          "disconnectMsg",
+       msgServiceRequest:      "serviceRequestMsg",
+       msgServiceAccept:       "serviceAcceptMsg",
+       msgKexInit:             "kexInitMsg",
+       msgKexDHInit:           "kexDHInitMsg",
+       msgKexDHReply:          "kexDHReplyMsg",
+       msgUserAuthRequest:     "userAuthRequestMsg",
+       msgUserAuthSuccess:     "userAuthSuccessMsg",
+       msgUserAuthFailure:     "userAuthFailureMsg",
+       msgUserAuthPubKeyOk:    "userAuthPubKeyOkMsg",
+       msgGlobalRequest:       "globalRequestMsg",
+       msgRequestSuccess:      "globalRequestSuccessMsg",
+       msgRequestFailure:      "globalRequestFailureMsg",
+       msgChannelOpen:         "channelOpenMsg",
+       msgChannelData:         "channelDataMsg",
+       msgChannelOpenConfirm:  "channelOpenConfirmMsg",
+       msgChannelOpenFailure:  "channelOpenFailureMsg",
+       msgChannelWindowAdjust: "windowAdjustMsg",
+       msgChannelEOF:          "channelEOFMsg",
+       msgChannelClose:        "channelCloseMsg",
+       msgChannelRequest:      "channelRequestMsg",
+       msgChannelSuccess:      "channelRequestSuccessMsg",
+       msgChannelFailure:      "channelRequestFailureMsg",
+}
index d0f48253196661f04def95f5784009d7a0b9d06a..e86e89661a06a67d6aaece7633d381a0f24cd36c 100644 (file)
@@ -404,7 +404,7 @@ userAuthLoop:
                        perms, authErr = config.PasswordCallback(s, password)
                case "keyboard-interactive":
                        if config.KeyboardInteractiveCallback == nil {
-                               authErr = errors.New("ssh: keyboard-interactive auth not configubred")
+                               authErr = errors.New("ssh: keyboard-interactive auth not configured")
                                break
                        }
 
@@ -484,6 +484,7 @@ userAuthLoop:
                                // sig.Format.  This is usually the same, but
                                // for certs, the names differ.
                                if !isAcceptableAlgo(sig.Format) {
+                                       authErr = fmt.Errorf("ssh: algorithm %q not accepted", sig.Format)
                                        break
                                }
                                signedData := buildDataSignedForAuth(sessionID, userAuthReq, algoBytes, pubKeyData)
index f6fae1db460465b4991e6ff07e12e31508367aaa..49ddc2e7de46c550e80b4025be64106c6f0795c3 100644 (file)
@@ -53,14 +53,14 @@ type transport struct {
 // packetCipher represents a combination of SSH encryption/MAC
 // protocol.  A single instance should be used for one direction only.
 type packetCipher interface {
-       // writePacket encrypts the packet and writes it to w. The
+       // writeCipherPacket encrypts the packet and writes it to w. The
        // contents of the packet are generally scrambled.
-       writePacket(seqnum uint32, w io.Writer, rand io.Reader, packet []byte) error
+       writeCipherPacket(seqnum uint32, w io.Writer, rand io.Reader, packet []byte) error
 
-       // readPacket reads and decrypts a packet of data. The
+       // readCipherPacket reads and decrypts a packet of data. The
        // returned packet may be overwritten by future calls of
        // readPacket.
-       readPacket(seqnum uint32, r io.Reader) ([]byte, error)
+       readCipherPacket(seqnum uint32, r io.Reader) ([]byte, error)
 }
 
 // connectionState represents one side (read or write) of the
@@ -127,7 +127,7 @@ func (t *transport) readPacket() (p []byte, err error) {
 }
 
 func (s *connectionState) readPacket(r *bufio.Reader) ([]byte, error) {
-       packet, err := s.packetCipher.readPacket(s.seqNum, r)
+       packet, err := s.packetCipher.readCipherPacket(s.seqNum, r)
        s.seqNum++
        if err == nil && len(packet) == 0 {
                err = errors.New("ssh: zero length packet")
@@ -175,7 +175,7 @@ func (t *transport) writePacket(packet []byte) error {
 func (s *connectionState) writePacket(w *bufio.Writer, rand io.Reader, packet []byte) error {
        changeKeys := len(packet) > 0 && packet[0] == msgNewKeys
 
-       err := s.packetCipher.writePacket(s.seqNum, w, rand, packet)
+       err := s.packetCipher.writeCipherPacket(s.seqNum, w, rand, packet)
        if err != nil {
                return err
        }
diff --git a/vendor/golang.org/x/sys/cpu/byteorder.go b/vendor/golang.org/x/sys/cpu/byteorder.go
new file mode 100644 (file)
index 0000000..da6b9e4
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cpu
+
+import (
+       "encoding/binary"
+       "runtime"
+)
+
+// hostByteOrder returns binary.LittleEndian on little-endian machines and
+// binary.BigEndian on big-endian machines.
+func hostByteOrder() binary.ByteOrder {
+       switch runtime.GOARCH {
+       case "386", "amd64", "amd64p32",
+               "arm", "arm64",
+               "mipsle", "mips64le", "mips64p32le",
+               "ppc64le",
+               "riscv", "riscv64":
+               return binary.LittleEndian
+       case "armbe", "arm64be",
+               "mips", "mips64", "mips64p32",
+               "ppc", "ppc64",
+               "s390", "s390x",
+               "sparc", "sparc64":
+               return binary.BigEndian
+       }
+       panic("unknown architecture")
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go
new file mode 100644 (file)
index 0000000..679e78c
--- /dev/null
@@ -0,0 +1,126 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package cpu implements processor feature detection for
+// various CPU architectures.
+package cpu
+
+// Initialized reports whether the CPU features were initialized.
+//
+// For some GOOS/GOARCH combinations initialization of the CPU features depends
+// on reading an operating specific file, e.g. /proc/self/auxv on linux/arm
+// Initialized will report false if reading the file fails.
+var Initialized bool
+
+// CacheLinePad is used to pad structs to avoid false sharing.
+type CacheLinePad struct{ _ [cacheLineSize]byte }
+
+// X86 contains the supported CPU features of the
+// current X86/AMD64 platform. If the current platform
+// is not X86/AMD64 then all feature flags are false.
+//
+// X86 is padded to avoid false sharing. Further the HasAVX
+// and HasAVX2 are only set if the OS supports XMM and YMM
+// registers in addition to the CPUID feature bit being set.
+var X86 struct {
+       _            CacheLinePad
+       HasAES       bool // AES hardware implementation (AES NI)
+       HasADX       bool // Multi-precision add-carry instruction extensions
+       HasAVX       bool // Advanced vector extension
+       HasAVX2      bool // Advanced vector extension 2
+       HasBMI1      bool // Bit manipulation instruction set 1
+       HasBMI2      bool // Bit manipulation instruction set 2
+       HasERMS      bool // Enhanced REP for MOVSB and STOSB
+       HasFMA       bool // Fused-multiply-add instructions
+       HasOSXSAVE   bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers.
+       HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM
+       HasPOPCNT    bool // Hamming weight instruction POPCNT.
+       HasRDRAND    bool // RDRAND instruction (on-chip random number generator)
+       HasRDSEED    bool // RDSEED instruction (on-chip random number generator)
+       HasSSE2      bool // Streaming SIMD extension 2 (always available on amd64)
+       HasSSE3      bool // Streaming SIMD extension 3
+       HasSSSE3     bool // Supplemental streaming SIMD extension 3
+       HasSSE41     bool // Streaming SIMD extension 4 and 4.1
+       HasSSE42     bool // Streaming SIMD extension 4 and 4.2
+       _            CacheLinePad
+}
+
+// ARM64 contains the supported CPU features of the
+// current ARMv8(aarch64) platform. If the current platform
+// is not arm64 then all feature flags are false.
+var ARM64 struct {
+       _           CacheLinePad
+       HasFP       bool // Floating-point instruction set (always available)
+       HasASIMD    bool // Advanced SIMD (always available)
+       HasEVTSTRM  bool // Event stream support
+       HasAES      bool // AES hardware implementation
+       HasPMULL    bool // Polynomial multiplication instruction set
+       HasSHA1     bool // SHA1 hardware implementation
+       HasSHA2     bool // SHA2 hardware implementation
+       HasCRC32    bool // CRC32 hardware implementation
+       HasATOMICS  bool // Atomic memory operation instruction set
+       HasFPHP     bool // Half precision floating-point instruction set
+       HasASIMDHP  bool // Advanced SIMD half precision instruction set
+       HasCPUID    bool // CPUID identification scheme registers
+       HasASIMDRDM bool // Rounding double multiply add/subtract instruction set
+       HasJSCVT    bool // Javascript conversion from floating-point to integer
+       HasFCMA     bool // Floating-point multiplication and addition of complex numbers
+       HasLRCPC    bool // Release Consistent processor consistent support
+       HasDCPOP    bool // Persistent memory support
+       HasSHA3     bool // SHA3 hardware implementation
+       HasSM3      bool // SM3 hardware implementation
+       HasSM4      bool // SM4 hardware implementation
+       HasASIMDDP  bool // Advanced SIMD double precision instruction set
+       HasSHA512   bool // SHA512 hardware implementation
+       HasSVE      bool // Scalable Vector Extensions
+       HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32
+       _           CacheLinePad
+}
+
+// PPC64 contains the supported CPU features of the current ppc64/ppc64le platforms.
+// If the current platform is not ppc64/ppc64le then all feature flags are false.
+//
+// For ppc64/ppc64le, it is safe to check only for ISA level starting on ISA v3.00,
+// since there are no optional categories. There are some exceptions that also
+// require kernel support to work (DARN, SCV), so there are feature bits for
+// those as well. The minimum processor requirement is POWER8 (ISA 2.07).
+// The struct is padded to avoid false sharing.
+var PPC64 struct {
+       _        CacheLinePad
+       HasDARN  bool // Hardware random number generator (requires kernel enablement)
+       HasSCV   bool // Syscall vectored (requires kernel enablement)
+       IsPOWER8 bool // ISA v2.07 (POWER8)
+       IsPOWER9 bool // ISA v3.00 (POWER9)
+       _        CacheLinePad
+}
+
+// S390X contains the supported CPU features of the current IBM Z
+// (s390x) platform. If the current platform is not IBM Z then all
+// feature flags are false.
+//
+// S390X is padded to avoid false sharing. Further HasVX is only set
+// if the OS supports vector registers in addition to the STFLE
+// feature bit being set.
+var S390X struct {
+       _         CacheLinePad
+       HasZARCH  bool // z/Architecture mode is active [mandatory]
+       HasSTFLE  bool // store facility list extended
+       HasLDISP  bool // long (20-bit) displacements
+       HasEIMM   bool // 32-bit immediates
+       HasDFP    bool // decimal floating point
+       HasETF3EH bool // ETF-3 enhanced
+       HasMSA    bool // message security assist (CPACF)
+       HasAES    bool // KM-AES{128,192,256} functions
+       HasAESCBC bool // KMC-AES{128,192,256} functions
+       HasAESCTR bool // KMCTR-AES{128,192,256} functions
+       HasAESGCM bool // KMA-GCM-AES{128,192,256} functions
+       HasGHASH  bool // KIMD-GHASH function
+       HasSHA1   bool // K{I,L}MD-SHA-1 functions
+       HasSHA256 bool // K{I,L}MD-SHA-256 functions
+       HasSHA512 bool // K{I,L}MD-SHA-512 functions
+       HasSHA3   bool // K{I,L}MD-SHA3-{224,256,384,512} and K{I,L}MD-SHAKE-{128,256} functions
+       HasVX     bool // vector facility
+       HasVXE    bool // vector-enhancements facility 1
+       _         CacheLinePad
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_aix_ppc64.go b/vendor/golang.org/x/sys/cpu/cpu_aix_ppc64.go
new file mode 100644 (file)
index 0000000..d8c26a0
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build aix,ppc64
+
+package cpu
+
+import "golang.org/x/sys/unix"
+
+const cacheLineSize = 128
+
+const (
+       // getsystemcfg constants
+       _SC_IMPL     = 2
+       _IMPL_POWER8 = 0x10000
+       _IMPL_POWER9 = 0x20000
+)
+
+func init() {
+       impl := unix.Getsystemcfg(_SC_IMPL)
+       if impl&_IMPL_POWER8 != 0 {
+               PPC64.IsPOWER8 = true
+       }
+       if impl&_IMPL_POWER9 != 0 {
+               PPC64.IsPOWER9 = true
+       }
+
+       Initialized = true
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm.go b/vendor/golang.org/x/sys/cpu/cpu_arm.go
new file mode 100644 (file)
index 0000000..7f2348b
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cpu
+
+const cacheLineSize = 32
+
+func doinit() {}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go b/vendor/golang.org/x/sys/cpu/cpu_gc_s390x.go
new file mode 100644 (file)
index 0000000..568bcd0
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+package cpu
+
+// haveAsmFunctions reports whether the other functions in this file can
+// be safely called.
+func haveAsmFunctions() bool { return true }
+
+// The following feature detection functions are defined in cpu_s390x.s.
+// They are likely to be expensive to call so the results should be cached.
+func stfle() facilityList
+func kmQuery() queryResult
+func kmcQuery() queryResult
+func kmctrQuery() queryResult
+func kmaQuery() queryResult
+func kimdQuery() queryResult
+func klmdQuery() queryResult
diff --git a/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go b/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go
new file mode 100644 (file)
index 0000000..f7cb469
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386 amd64 amd64p32
+// +build !gccgo
+
+package cpu
+
+// cpuid is implemented in cpu_x86.s for gc compiler
+// and in cpu_gccgo.c for gccgo.
+func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
+
+// xgetbv with ecx = 0 is implemented in cpu_x86.s for gc compiler
+// and in cpu_gccgo.c for gccgo.
+func xgetbv() (eax, edx uint32)
diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo.c b/vendor/golang.org/x/sys/cpu/cpu_gccgo.c
new file mode 100644 (file)
index 0000000..e363c7d
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386 amd64 amd64p32
+// +build gccgo
+
+#include <cpuid.h>
+#include <stdint.h>
+
+// Need to wrap __get_cpuid_count because it's declared as static.
+int
+gccgoGetCpuidCount(uint32_t leaf, uint32_t subleaf,
+                   uint32_t *eax, uint32_t *ebx,
+                   uint32_t *ecx, uint32_t *edx)
+{
+       return __get_cpuid_count(leaf, subleaf, eax, ebx, ecx, edx);
+}
+
+// xgetbv reads the contents of an XCR (Extended Control Register)
+// specified in the ECX register into registers EDX:EAX.
+// Currently, the only supported value for XCR is 0.
+//
+// TODO: Replace with a better alternative:
+//
+//     #include <xsaveintrin.h>
+//
+//     #pragma GCC target("xsave")
+//
+//     void gccgoXgetbv(uint32_t *eax, uint32_t *edx) {
+//       unsigned long long x = _xgetbv(0);
+//       *eax = x & 0xffffffff;
+//       *edx = (x >> 32) & 0xffffffff;
+//     }
+//
+// Note that _xgetbv is defined starting with GCC 8.
+void
+gccgoXgetbv(uint32_t *eax, uint32_t *edx)
+{
+       __asm("  xorl %%ecx, %%ecx\n"
+             "  xgetbv"
+           : "=a"(*eax), "=d"(*edx));
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo.go
new file mode 100644 (file)
index 0000000..ba49b91
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386 amd64 amd64p32
+// +build gccgo
+
+package cpu
+
+//extern gccgoGetCpuidCount
+func gccgoGetCpuidCount(eaxArg, ecxArg uint32, eax, ebx, ecx, edx *uint32)
+
+func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) {
+       var a, b, c, d uint32
+       gccgoGetCpuidCount(eaxArg, ecxArg, &a, &b, &c, &d)
+       return a, b, c, d
+}
+
+//extern gccgoXgetbv
+func gccgoXgetbv(eax, edx *uint32)
+
+func xgetbv() (eax, edx uint32) {
+       var a, d uint32
+       gccgoXgetbv(&a, &d)
+       return a, d
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go b/vendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go
new file mode 100644 (file)
index 0000000..aa986f7
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gccgo
+
+package cpu
+
+// haveAsmFunctions reports whether the other functions in this file can
+// be safely called.
+func haveAsmFunctions() bool { return false }
+
+// TODO(mundaym): the following feature detection functions are currently
+// stubs. See https://golang.org/cl/162887 for how to fix this.
+// They are likely to be expensive to call so the results should be cached.
+func stfle() facilityList     { panic("not implemented for gccgo") }
+func kmQuery() queryResult    { panic("not implemented for gccgo") }
+func kmcQuery() queryResult   { panic("not implemented for gccgo") }
+func kmctrQuery() queryResult { panic("not implemented for gccgo") }
+func kmaQuery() queryResult   { panic("not implemented for gccgo") }
+func kimdQuery() queryResult  { panic("not implemented for gccgo") }
+func klmdQuery() queryResult  { panic("not implemented for gccgo") }
diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux.go b/vendor/golang.org/x/sys/cpu/cpu_linux.go
new file mode 100644 (file)
index 0000000..76b5f50
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//+build !amd64,!amd64p32,!386
+
+package cpu
+
+import (
+       "io/ioutil"
+)
+
+const (
+       _AT_HWCAP  = 16
+       _AT_HWCAP2 = 26
+
+       procAuxv = "/proc/self/auxv"
+
+       uintSize = int(32 << (^uint(0) >> 63))
+)
+
+// For those platforms don't have a 'cpuid' equivalent we use HWCAP/HWCAP2
+// These are initialized in cpu_$GOARCH.go
+// and should not be changed after they are initialized.
+var hwCap uint
+var hwCap2 uint
+
+func init() {
+       buf, err := ioutil.ReadFile(procAuxv)
+       if err != nil {
+               // e.g. on android /proc/self/auxv is not accessible, so silently
+               // ignore the error and leave Initialized = false
+               return
+       }
+
+       bo := hostByteOrder()
+       for len(buf) >= 2*(uintSize/8) {
+               var tag, val uint
+               switch uintSize {
+               case 32:
+                       tag = uint(bo.Uint32(buf[0:]))
+                       val = uint(bo.Uint32(buf[4:]))
+                       buf = buf[8:]
+               case 64:
+                       tag = uint(bo.Uint64(buf[0:]))
+                       val = uint(bo.Uint64(buf[8:]))
+                       buf = buf[16:]
+               }
+               switch tag {
+               case _AT_HWCAP:
+                       hwCap = val
+               case _AT_HWCAP2:
+                       hwCap2 = val
+               }
+       }
+       doinit()
+
+       Initialized = true
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go
new file mode 100644 (file)
index 0000000..fa7fb1b
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cpu
+
+const cacheLineSize = 64
+
+// HWCAP/HWCAP2 bits. These are exposed by Linux.
+const (
+       hwcap_FP       = 1 << 0
+       hwcap_ASIMD    = 1 << 1
+       hwcap_EVTSTRM  = 1 << 2
+       hwcap_AES      = 1 << 3
+       hwcap_PMULL    = 1 << 4
+       hwcap_SHA1     = 1 << 5
+       hwcap_SHA2     = 1 << 6
+       hwcap_CRC32    = 1 << 7
+       hwcap_ATOMICS  = 1 << 8
+       hwcap_FPHP     = 1 << 9
+       hwcap_ASIMDHP  = 1 << 10
+       hwcap_CPUID    = 1 << 11
+       hwcap_ASIMDRDM = 1 << 12
+       hwcap_JSCVT    = 1 << 13
+       hwcap_FCMA     = 1 << 14
+       hwcap_LRCPC    = 1 << 15
+       hwcap_DCPOP    = 1 << 16
+       hwcap_SHA3     = 1 << 17
+       hwcap_SM3      = 1 << 18
+       hwcap_SM4      = 1 << 19
+       hwcap_ASIMDDP  = 1 << 20
+       hwcap_SHA512   = 1 << 21
+       hwcap_SVE      = 1 << 22
+       hwcap_ASIMDFHM = 1 << 23
+)
+
+func doinit() {
+       // HWCAP feature bits
+       ARM64.HasFP = isSet(hwCap, hwcap_FP)
+       ARM64.HasASIMD = isSet(hwCap, hwcap_ASIMD)
+       ARM64.HasEVTSTRM = isSet(hwCap, hwcap_EVTSTRM)
+       ARM64.HasAES = isSet(hwCap, hwcap_AES)
+       ARM64.HasPMULL = isSet(hwCap, hwcap_PMULL)
+       ARM64.HasSHA1 = isSet(hwCap, hwcap_SHA1)
+       ARM64.HasSHA2 = isSet(hwCap, hwcap_SHA2)
+       ARM64.HasCRC32 = isSet(hwCap, hwcap_CRC32)
+       ARM64.HasATOMICS = isSet(hwCap, hwcap_ATOMICS)
+       ARM64.HasFPHP = isSet(hwCap, hwcap_FPHP)
+       ARM64.HasASIMDHP = isSet(hwCap, hwcap_ASIMDHP)
+       ARM64.HasCPUID = isSet(hwCap, hwcap_CPUID)
+       ARM64.HasASIMDRDM = isSet(hwCap, hwcap_ASIMDRDM)
+       ARM64.HasJSCVT = isSet(hwCap, hwcap_JSCVT)
+       ARM64.HasFCMA = isSet(hwCap, hwcap_FCMA)
+       ARM64.HasLRCPC = isSet(hwCap, hwcap_LRCPC)
+       ARM64.HasDCPOP = isSet(hwCap, hwcap_DCPOP)
+       ARM64.HasSHA3 = isSet(hwCap, hwcap_SHA3)
+       ARM64.HasSM3 = isSet(hwCap, hwcap_SM3)
+       ARM64.HasSM4 = isSet(hwCap, hwcap_SM4)
+       ARM64.HasASIMDDP = isSet(hwCap, hwcap_ASIMDDP)
+       ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512)
+       ARM64.HasSVE = isSet(hwCap, hwcap_SVE)
+       ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM)
+}
+
+func isSet(hwc uint, value uint) bool {
+       return hwc&value != 0
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go b/vendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go
new file mode 100644 (file)
index 0000000..6c8d975
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+// +build ppc64 ppc64le
+
+package cpu
+
+const cacheLineSize = 128
+
+// HWCAP/HWCAP2 bits. These are exposed by the kernel.
+const (
+       // ISA Level
+       _PPC_FEATURE2_ARCH_2_07 = 0x80000000
+       _PPC_FEATURE2_ARCH_3_00 = 0x00800000
+
+       // CPU features
+       _PPC_FEATURE2_DARN = 0x00200000
+       _PPC_FEATURE2_SCV  = 0x00100000
+)
+
+func doinit() {
+       // HWCAP2 feature bits
+       PPC64.IsPOWER8 = isSet(hwCap2, _PPC_FEATURE2_ARCH_2_07)
+       PPC64.IsPOWER9 = isSet(hwCap2, _PPC_FEATURE2_ARCH_3_00)
+       PPC64.HasDARN = isSet(hwCap2, _PPC_FEATURE2_DARN)
+       PPC64.HasSCV = isSet(hwCap2, _PPC_FEATURE2_SCV)
+}
+
+func isSet(hwc uint, value uint) bool {
+       return hwc&value != 0
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go b/vendor/golang.org/x/sys/cpu/cpu_linux_s390x.go
new file mode 100644 (file)
index 0000000..d579eae
--- /dev/null
@@ -0,0 +1,161 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package cpu
+
+const cacheLineSize = 256
+
+const (
+       // bit mask values from /usr/include/bits/hwcap.h
+       hwcap_ZARCH  = 2
+       hwcap_STFLE  = 4
+       hwcap_MSA    = 8
+       hwcap_LDISP  = 16
+       hwcap_EIMM   = 32
+       hwcap_DFP    = 64
+       hwcap_ETF3EH = 256
+       hwcap_VX     = 2048
+       hwcap_VXE    = 8192
+)
+
+// bitIsSet reports whether the bit at index is set. The bit index
+// is in big endian order, so bit index 0 is the leftmost bit.
+func bitIsSet(bits []uint64, index uint) bool {
+       return bits[index/64]&((1<<63)>>(index%64)) != 0
+}
+
+// function is the code for the named cryptographic function.
+type function uint8
+
+const (
+       // KM{,A,C,CTR} function codes
+       aes128 function = 18 // AES-128
+       aes192 function = 19 // AES-192
+       aes256 function = 20 // AES-256
+
+       // K{I,L}MD function codes
+       sha1     function = 1  // SHA-1
+       sha256   function = 2  // SHA-256
+       sha512   function = 3  // SHA-512
+       sha3_224 function = 32 // SHA3-224
+       sha3_256 function = 33 // SHA3-256
+       sha3_384 function = 34 // SHA3-384
+       sha3_512 function = 35 // SHA3-512
+       shake128 function = 36 // SHAKE-128
+       shake256 function = 37 // SHAKE-256
+
+       // KLMD function codes
+       ghash function = 65 // GHASH
+)
+
+// queryResult contains the result of a Query function
+// call. Bits are numbered in big endian order so the
+// leftmost bit (the MSB) is at index 0.
+type queryResult struct {
+       bits [2]uint64
+}
+
+// Has reports whether the given functions are present.
+func (q *queryResult) Has(fns ...function) bool {
+       if len(fns) == 0 {
+               panic("no function codes provided")
+       }
+       for _, f := range fns {
+               if !bitIsSet(q.bits[:], uint(f)) {
+                       return false
+               }
+       }
+       return true
+}
+
+// facility is a bit index for the named facility.
+type facility uint8
+
+const (
+       // cryptography facilities
+       msa4 facility = 77  // message-security-assist extension 4
+       msa8 facility = 146 // message-security-assist extension 8
+)
+
+// facilityList contains the result of an STFLE call.
+// Bits are numbered in big endian order so the
+// leftmost bit (the MSB) is at index 0.
+type facilityList struct {
+       bits [4]uint64
+}
+
+// Has reports whether the given facilities are present.
+func (s *facilityList) Has(fs ...facility) bool {
+       if len(fs) == 0 {
+               panic("no facility bits provided")
+       }
+       for _, f := range fs {
+               if !bitIsSet(s.bits[:], uint(f)) {
+                       return false
+               }
+       }
+       return true
+}
+
+func doinit() {
+       // test HWCAP bit vector
+       has := func(featureMask uint) bool {
+               return hwCap&featureMask == featureMask
+       }
+
+       // mandatory
+       S390X.HasZARCH = has(hwcap_ZARCH)
+
+       // optional
+       S390X.HasSTFLE = has(hwcap_STFLE)
+       S390X.HasLDISP = has(hwcap_LDISP)
+       S390X.HasEIMM = has(hwcap_EIMM)
+       S390X.HasETF3EH = has(hwcap_ETF3EH)
+       S390X.HasDFP = has(hwcap_DFP)
+       S390X.HasMSA = has(hwcap_MSA)
+       S390X.HasVX = has(hwcap_VX)
+       if S390X.HasVX {
+               S390X.HasVXE = has(hwcap_VXE)
+       }
+
+       // We need implementations of stfle, km and so on
+       // to detect cryptographic features.
+       if !haveAsmFunctions() {
+               return
+       }
+
+       // optional cryptographic functions
+       if S390X.HasMSA {
+               aes := []function{aes128, aes192, aes256}
+
+               // cipher message
+               km, kmc := kmQuery(), kmcQuery()
+               S390X.HasAES = km.Has(aes...)
+               S390X.HasAESCBC = kmc.Has(aes...)
+               if S390X.HasSTFLE {
+                       facilities := stfle()
+                       if facilities.Has(msa4) {
+                               kmctr := kmctrQuery()
+                               S390X.HasAESCTR = kmctr.Has(aes...)
+                       }
+                       if facilities.Has(msa8) {
+                               kma := kmaQuery()
+                               S390X.HasAESGCM = kma.Has(aes...)
+                       }
+               }
+
+               // compute message digest
+               kimd := kimdQuery() // intermediate (no padding)
+               klmd := klmdQuery() // last (padding)
+               S390X.HasSHA1 = kimd.Has(sha1) && klmd.Has(sha1)
+               S390X.HasSHA256 = kimd.Has(sha256) && klmd.Has(sha256)
+               S390X.HasSHA512 = kimd.Has(sha512) && klmd.Has(sha512)
+               S390X.HasGHASH = kimd.Has(ghash) // KLMD-GHASH does not exist
+               sha3 := []function{
+                       sha3_224, sha3_256, sha3_384, sha3_512,
+                       shake128, shake256,
+               }
+               S390X.HasSHA3 = kimd.Has(sha3...) && klmd.Has(sha3...)
+       }
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_mips64x.go b/vendor/golang.org/x/sys/cpu/cpu_mips64x.go
new file mode 100644 (file)
index 0000000..f55e0c8
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build mips64 mips64le
+
+package cpu
+
+const cacheLineSize = 32
+
+func doinit() {}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_mipsx.go b/vendor/golang.org/x/sys/cpu/cpu_mipsx.go
new file mode 100644 (file)
index 0000000..cda87b1
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build mips mipsle
+
+package cpu
+
+const cacheLineSize = 32
+
+func doinit() {}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go
new file mode 100644 (file)
index 0000000..dd1e76d
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !linux,arm64
+
+package cpu
+
+const cacheLineSize = 64
+
+func doinit() {}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_s390x.s b/vendor/golang.org/x/sys/cpu/cpu_s390x.s
new file mode 100644 (file)
index 0000000..e5037d9
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !gccgo
+
+#include "textflag.h"
+
+// func stfle() facilityList
+TEXT ·stfle(SB), NOSPLIT|NOFRAME, $0-32
+       MOVD $ret+0(FP), R1
+       MOVD $3, R0          // last doubleword index to store
+       XC   $32, (R1), (R1) // clear 4 doublewords (32 bytes)
+       WORD $0xb2b01000     // store facility list extended (STFLE)
+       RET
+
+// func kmQuery() queryResult
+TEXT ·kmQuery(SB), NOSPLIT|NOFRAME, $0-16
+       MOVD $0, R0         // set function code to 0 (KM-Query)
+       MOVD $ret+0(FP), R1 // address of 16-byte return value
+       WORD $0xB92E0024    // cipher message (KM)
+       RET
+
+// func kmcQuery() queryResult
+TEXT ·kmcQuery(SB), NOSPLIT|NOFRAME, $0-16
+       MOVD $0, R0         // set function code to 0 (KMC-Query)
+       MOVD $ret+0(FP), R1 // address of 16-byte return value
+       WORD $0xB92F0024    // cipher message with chaining (KMC)
+       RET
+
+// func kmctrQuery() queryResult
+TEXT ·kmctrQuery(SB), NOSPLIT|NOFRAME, $0-16
+       MOVD $0, R0         // set function code to 0 (KMCTR-Query)
+       MOVD $ret+0(FP), R1 // address of 16-byte return value
+       WORD $0xB92D4024    // cipher message with counter (KMCTR)
+       RET
+
+// func kmaQuery() queryResult
+TEXT ·kmaQuery(SB), NOSPLIT|NOFRAME, $0-16
+       MOVD $0, R0         // set function code to 0 (KMA-Query)
+       MOVD $ret+0(FP), R1 // address of 16-byte return value
+       WORD $0xb9296024    // cipher message with authentication (KMA)
+       RET
+
+// func kimdQuery() queryResult
+TEXT ·kimdQuery(SB), NOSPLIT|NOFRAME, $0-16
+       MOVD $0, R0         // set function code to 0 (KIMD-Query)
+       MOVD $ret+0(FP), R1 // address of 16-byte return value
+       WORD $0xB93E0024    // compute intermediate message digest (KIMD)
+       RET
+
+// func klmdQuery() queryResult
+TEXT ·klmdQuery(SB), NOSPLIT|NOFRAME, $0-16
+       MOVD $0, R0         // set function code to 0 (KLMD-Query)
+       MOVD $ret+0(FP), R1 // address of 16-byte return value
+       WORD $0xB93F0024    // compute last message digest (KLMD)
+       RET
diff --git a/vendor/golang.org/x/sys/cpu/cpu_wasm.go b/vendor/golang.org/x/sys/cpu/cpu_wasm.go
new file mode 100644 (file)
index 0000000..bd9bbda
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build wasm
+
+package cpu
+
+// We're compiling the cpu package for an unknown (software-abstracted) CPU.
+// Make CacheLinePad an empty struct and hope that the usual struct alignment
+// rules are good enough.
+
+const cacheLineSize = 0
+
+func doinit() {}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.go b/vendor/golang.org/x/sys/cpu/cpu_x86.go
new file mode 100644 (file)
index 0000000..d70d317
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386 amd64 amd64p32
+
+package cpu
+
+const cacheLineSize = 64
+
+func init() {
+       Initialized = true
+
+       maxID, _, _, _ := cpuid(0, 0)
+
+       if maxID < 1 {
+               return
+       }
+
+       _, _, ecx1, edx1 := cpuid(1, 0)
+       X86.HasSSE2 = isSet(26, edx1)
+
+       X86.HasSSE3 = isSet(0, ecx1)
+       X86.HasPCLMULQDQ = isSet(1, ecx1)
+       X86.HasSSSE3 = isSet(9, ecx1)
+       X86.HasFMA = isSet(12, ecx1)
+       X86.HasSSE41 = isSet(19, ecx1)
+       X86.HasSSE42 = isSet(20, ecx1)
+       X86.HasPOPCNT = isSet(23, ecx1)
+       X86.HasAES = isSet(25, ecx1)
+       X86.HasOSXSAVE = isSet(27, ecx1)
+       X86.HasRDRAND = isSet(30, ecx1)
+
+       osSupportsAVX := false
+       // For XGETBV, OSXSAVE bit is required and sufficient.
+       if X86.HasOSXSAVE {
+               eax, _ := xgetbv()
+               // Check if XMM and YMM registers have OS support.
+               osSupportsAVX = isSet(1, eax) && isSet(2, eax)
+       }
+
+       X86.HasAVX = isSet(28, ecx1) && osSupportsAVX
+
+       if maxID < 7 {
+               return
+       }
+
+       _, ebx7, _, _ := cpuid(7, 0)
+       X86.HasBMI1 = isSet(3, ebx7)
+       X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX
+       X86.HasBMI2 = isSet(8, ebx7)
+       X86.HasERMS = isSet(9, ebx7)
+       X86.HasRDSEED = isSet(18, ebx7)
+       X86.HasADX = isSet(19, ebx7)
+}
+
+func isSet(bitpos uint, value uint32) bool {
+       return value&(1<<bitpos) != 0
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.s b/vendor/golang.org/x/sys/cpu/cpu_x86.s
new file mode 100644 (file)
index 0000000..47f0841
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build 386 amd64 amd64p32
+// +build !gccgo
+
+#include "textflag.h"
+
+// func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
+TEXT ·cpuid(SB), NOSPLIT, $0-24
+       MOVL eaxArg+0(FP), AX
+       MOVL ecxArg+4(FP), CX
+       CPUID
+       MOVL AX, eax+8(FP)
+       MOVL BX, ebx+12(FP)
+       MOVL CX, ecx+16(FP)
+       MOVL DX, edx+20(FP)
+       RET
+
+// func xgetbv() (eax, edx uint32)
+TEXT ·xgetbv(SB),NOSPLIT,$0-8
+       MOVL $0, CX
+       XGETBV
+       MOVL AX, eax+0(FP)
+       MOVL DX, edx+4(FP)
+       RET
index 75152f99b20b4c8a4ea16752bba82834122fdcc1..1e5c59d0dd2ea32766ae526c644edc9d1a4d56b0 100644 (file)
@@ -207,8 +207,6 @@ esac
        esac
        if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
        if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
-       if [ -n "$mktypes" ]; then
-               echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go";
+       if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi
        if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
-       fi
 ) | $run
index 6a23484e5b5b6d650ea6a9db1777145f4a7cf8b1..cfb61ba049794460174087666d74d69063976527 100644 (file)
@@ -192,6 +192,7 @@ struct ltchars {
 #include <linux/if_packet.h>
 #include <linux/if_addr.h>
 #include <linux/falloc.h>
+#include <linux/fanotify.h>
 #include <linux/filter.h>
 #include <linux/fs.h>
 #include <linux/kexec.h>
@@ -501,6 +502,7 @@ ccflags="$@"
                $2 !~ "WMESGLEN" &&
                $2 ~ /^W[A-Z0-9]+$/ ||
                $2 ~/^PPPIOC/ ||
+               $2 ~ /^FAN_|FANOTIFY_/ ||
                $2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
                $2 ~ /^__WCOREFLAG$/ {next}
                $2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
index e06e4253ea3c3a7f03f49eb0662806808cb4e4c5..e4af9424e97886239f52a5035fbe64c3402c4792 100644 (file)
@@ -153,6 +153,11 @@ func main() {
                        }
                        funct, inps, outps, sysname := f[2], f[3], f[4], f[5]
 
+                       // ClockGettime doesn't have a syscall number on Darwin, only generate libc wrappers.
+                       if goos == "darwin" && !libc && funct == "ClockGettime" {
+                               continue
+                       }
+
                        // Split argument lists on comma.
                        in := parseParamList(inps)
                        out := parseParamList(outps)
@@ -228,7 +233,7 @@ func main() {
                                        } else {
                                                args = append(args, fmt.Sprintf("uintptr(%s)", p.Name))
                                        }
-                               } else if p.Type == "int64" && endianness != "" {
+                               } else if (p.Type == "int64" || p.Type == "uint64") && endianness != "" {
                                        if len(args)%2 == 1 && *arm {
                                                // arm abi specifies 64-bit argument uses
                                                // (even, odd) pair
index 5f9ae233a7a62af88a77d9d0142aa78f546394e2..26e8b36cfc14a8f1fde9ad98dce9ec1126730411 100644 (file)
@@ -25,8 +25,8 @@ func cmsgAlignOf(salen int) int {
                if SizeofPtr == 8 {
                        salign = 4
                }
-       case "openbsd":
-               // OpenBSD armv7 requires 64-bit alignment.
+       case "netbsd", "openbsd":
+               // NetBSD and OpenBSD armv7 require 64-bit alignment.
                if runtime.GOARCH == "arm" {
                        salign = 8
                }
index a76826f443616dfc008d50696dd14a98fbb113dd..fd83d87509f384cd0664ce958998a98c02b2867a 100644 (file)
@@ -545,3 +545,5 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
 //sys  gettimeofday(tv *Timeval, tzp *Timezone) (err error)
 //sysnb        Time(t *Time_t) (tt Time_t, err error)
 //sys  Utime(path string, buf *Utimbuf) (err error)
+
+//sys  Getsystemcfg(label int) (n uint64)
index a2e3688822262513982f64b9654468778514f649..21200918927f54a8da5bb74c5bd91ec98373aacb 100644 (file)
@@ -144,6 +144,23 @@ func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (
 
 //sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
 
+func SysctlClockinfo(name string) (*Clockinfo, error) {
+       mib, err := sysctlmib(name)
+       if err != nil {
+               return nil, err
+       }
+
+       n := uintptr(SizeofClockinfo)
+       var ci Clockinfo
+       if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
+               return nil, err
+       }
+       if n != SizeofClockinfo {
+               return nil, EIO
+       }
+       return &ci, nil
+}
+
 //sysnb pipe() (r int, w int, err error)
 
 func Pipe(p []int) (err error) {
index 4bb86aa0fe5123ba07ae6ac239ad0c9db3b209b0..7e429ab2f9855943305a7f0003fa47c34f2937dc 100644 (file)
@@ -39,6 +39,20 @@ func Creat(path string, mode uint32) (fd int, err error) {
        return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode)
 }
 
+//sys  FanotifyInit(flags uint, event_f_flags uint) (fd int, err error)
+//sys  fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error)
+
+func FanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname string) (err error) {
+       if pathname == "" {
+               return fanotifyMark(fd, flags, mask, dirFd, nil)
+       }
+       p, err := BytePtrFromString(pathname)
+       if err != nil {
+               return err
+       }
+       return fanotifyMark(fd, flags, mask, dirFd, p)
+}
+
 //sys  fchmodat(dirfd int, path string, mode uint32) (err error)
 
 func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) {
@@ -990,10 +1004,28 @@ func GetsockoptString(fd, level, opt int) (string, error) {
        return string(buf[:vallen-1]), nil
 }
 
+func GetsockoptTpacketStats(fd, level, opt int) (*TpacketStats, error) {
+       var value TpacketStats
+       vallen := _Socklen(SizeofTpacketStats)
+       err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+       return &value, err
+}
+
+func GetsockoptTpacketStatsV3(fd, level, opt int) (*TpacketStatsV3, error) {
+       var value TpacketStatsV3
+       vallen := _Socklen(SizeofTpacketStatsV3)
+       err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
+       return &value, err
+}
+
 func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
        return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
 }
 
+func SetsockoptPacketMreq(fd, level, opt int, mreq *PacketMreq) error {
+       return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
+}
+
 // SetsockoptSockFprog attaches a classic BPF or an extended BPF program to a
 // socket to filter incoming packets.  See 'man 7 socket' for usage information.
 func SetsockoptSockFprog(fd, level, opt int, fprog *SockFprog) error {
@@ -1008,6 +1040,14 @@ func SetsockoptCanRawFilter(fd, level, opt int, filter []CanFilter) error {
        return setsockopt(fd, level, opt, p, uintptr(len(filter)*SizeofCanFilter))
 }
 
+func SetsockoptTpacketReq(fd, level, opt int, tp *TpacketReq) error {
+       return setsockopt(fd, level, opt, unsafe.Pointer(tp), unsafe.Sizeof(*tp))
+}
+
+func SetsockoptTpacketReq3(fd, level, opt int, tp *TpacketReq3) error {
+       return setsockopt(fd, level, opt, unsafe.Pointer(tp), unsafe.Sizeof(*tp))
+}
+
 // Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html)
 
 // KeyctlInt calls keyctl commands in which each argument is an int.
index cda3559419c027b47a60037e510a9d3149b6a08c..3a3c37b4c8b6d8b1b4ac896c9d0b54e2bb59d84d 100644 (file)
@@ -19,12 +19,18 @@ func setTimeval(sec, usec int64) Timeval {
        return Timeval{Sec: int32(sec), Usec: int32(usec)}
 }
 
+//sysnb        pipe(p *[2]_C_int) (err error)
+
 func Pipe(p []int) (err error) {
        if len(p) != 2 {
                return EINVAL
        }
        var pp [2]_C_int
+       // Try pipe2 first for Android O, then try pipe for kernel 2.6.23.
        err = pipe2(&pp, 0)
+       if err == ENOSYS {
+               err = pipe(&pp)
+       }
        p[0] = int(pp[0])
        p[1] = int(pp[1])
        return
index 6d567224017fd302782887ab7f0a628b92c8702f..cb20b15d5d2bfb424881c6ef3b06ee191efe82ed 100644 (file)
@@ -208,3 +208,16 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
        }
        return ppoll(&fds[0], len(fds), ts, nil)
 }
+
+//sys  kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error)
+
+func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error {
+       cmdlineLen := len(cmdline)
+       if cmdlineLen > 0 {
+               // Account for the additional NULL byte added by
+               // BytePtrFromString in kexecFileLoad. The kexec_file_load
+               // syscall expects a NULL-terminated string.
+               cmdlineLen++
+       }
+       return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
+}
index f23ca451c7d22ff29f5c893b6a166e645d0014db..6230f64052003973785d3b622d28f0b105edb502 100644 (file)
@@ -211,3 +211,16 @@ func Poll(fds []PollFd, timeout int) (n int, err error) {
 func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
        return Renameat2(olddirfd, oldpath, newdirfd, newpath, 0)
 }
+
+//sys  kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error)
+
+func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error {
+       cmdlineLen := len(cmdline)
+       if cmdlineLen > 0 {
+               // Account for the additional NULL byte added by
+               // BytePtrFromString in kexecFileLoad. The kexec_file_load
+               // syscall expects a NULL-terminated string.
+               cmdlineLen++
+       }
+       return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
+}
index 687999549c80048ce621bf1043a92cef8cdeac5d..c8648ec02678713de430345ed3f10552a42566a0 100644 (file)
@@ -43,6 +43,23 @@ func nametomib(name string) (mib []_C_int, err error) {
        return nil, EINVAL
 }
 
+func SysctlClockinfo(name string) (*Clockinfo, error) {
+       mib, err := sysctlmib(name)
+       if err != nil {
+               return nil, err
+       }
+
+       n := uintptr(SizeofClockinfo)
+       var ci Clockinfo
+       if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
+               return nil, err
+       }
+       if n != SizeofClockinfo {
+               return nil, EIO
+       }
+       return &ci, nil
+}
+
 func SysctlUvmexp(name string) (*Uvmexp, error) {
        mib, err := sysctlmib(name)
        if err != nil {
index 33583a22b67c42b478ed31295c8715285dfbf44e..0ed1d58d575f13bd9c130cf36c62c44578f8fafd 100644 (file)
@@ -28,6 +28,11 @@ var (
        errENOENT error = syscall.ENOENT
 )
 
+var (
+       signalNameMapOnce sync.Once
+       signalNameMap     map[string]syscall.Signal
+)
+
 // errnoErr returns common boxed Errno values, to prevent
 // allocations at runtime.
 func errnoErr(e syscall.Errno) error {
@@ -66,6 +71,19 @@ func SignalName(s syscall.Signal) string {
        return ""
 }
 
+// SignalNum returns the syscall.Signal for signal named s,
+// or 0 if a signal with such name is not found.
+// The signal name should start with "SIG".
+func SignalNum(s string) syscall.Signal {
+       signalNameMapOnce.Do(func() {
+               signalNameMap = make(map[string]syscall.Signal)
+               for _, signal := range signalList {
+                       signalNameMap[signal.name] = signal.num
+               }
+       })
+       return signalNameMap[s]
+}
+
 // clen returns the index of the first NULL byte in n or len(n) if n contains no NULL byte.
 func clen(n []byte) int {
        i := bytes.IndexByte(n, 0)
@@ -276,6 +294,13 @@ func GetsockoptTimeval(fd, level, opt int) (*Timeval, error) {
        return &tv, err
 }
 
+func GetsockoptUint64(fd, level, opt int) (value uint64, err error) {
+       var n uint64
+       vallen := _Socklen(8)
+       err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
+       return n, err
+}
+
 func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
        var rsa RawSockaddrAny
        var len _Socklen = SizeofSockaddrAny
@@ -333,6 +358,10 @@ func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) {
        return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv))
 }
 
+func SetsockoptUint64(fd, level, opt int, value uint64) (err error) {
+       return setsockopt(fd, level, opt, unsafe.Pointer(&value), 8)
+}
+
 func Socket(domain, typ, proto int) (fd int, err error) {
        if domain == AF_INET6 && SocketDisableIPv6 {
                return -1, EAFNOSUPPORT
@@ -377,3 +406,22 @@ func SetNonblock(fd int, nonblocking bool) (err error) {
 func Exec(argv0 string, argv []string, envv []string) error {
        return syscall.Exec(argv0, argv, envv)
 }
+
+// Lutimes sets the access and modification times tv on path. If path refers to
+// a symlink, it is not dereferenced and the timestamps are set on the symlink.
+// If tv is nil, the access and modification times are set to the current time.
+// Otherwise tv must contain exactly 2 elements, with access time as the first
+// element and modification time as the second element.
+func Lutimes(path string, tv []Timeval) error {
+       if tv == nil {
+               return UtimesNanoAt(AT_FDCWD, path, nil, AT_SYMLINK_NOFOLLOW)
+       }
+       if len(tv) != 2 {
+               return EINVAL
+       }
+       ts := []Timespec{
+               NsecToTimespec(TimevalToNsec(tv[0])),
+               NsecToTimespec(TimevalToNsec(tv[1])),
+       }
+       return UtimesNanoAt(AT_FDCWD, path, ts, AT_SYMLINK_NOFOLLOW)
+}
index 9fd2aaa6a224decf7f702e07574cee0ac30527e4..155c2e692b45eb9f4416eaa6fe5ad50c4ea655a1 100644 (file)
@@ -275,3 +275,9 @@ const (
 // uname
 
 type Utsname C.struct_utsname
+
+// Clockinfo
+
+const SizeofClockinfo = C.sizeof_struct_clockinfo
+
+type Clockinfo C.struct_clockinfo
index 4e5e57f9a61a09dce8bd3ea7501038aefc870bab..8aafbe4469bfaf4e26df54c4550349490a70c342 100644 (file)
@@ -274,3 +274,9 @@ type Utsname C.struct_utsname
 const SizeofUvmexp = C.sizeof_struct_uvmexp
 
 type Uvmexp C.struct_uvmexp
+
+// Clockinfo
+
+const SizeofClockinfo = C.sizeof_struct_clockinfo
+
+type Clockinfo C.struct_clockinfo
index cb89df8f543ebd5d78d6181158f5fcf3d9af0093..9e99d67cb8a38034cd54cc9fb35adefc7e00f15c 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x80041270
        BLKBSZSET                            = 0x40041271
@@ -486,6 +487,50 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
@@ -493,6 +538,7 @@ const (
        FFDLY                                = 0x8000
        FLUSHO                               = 0x1000
        FP_XSTATE_MAGIC2                     = 0x46505845
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -514,7 +560,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1134,7 +1180,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1398,6 +1444,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2232,6 +2284,7 @@ const (
        TUNGETVNETBE                         = 0x800454df
        TUNGETVNETHDRSZ                      = 0x800454d7
        TUNGETVNETLE                         = 0x800454dd
+       TUNSETCARRIER                        = 0x400454e2
        TUNSETDEBUG                          = 0x400454c9
        TUNSETFILTEREBPF                     = 0x800454e1
        TUNSETGROUP                          = 0x400454ce
index 73c9b88ca78ee352d7f71cdbf0bda00e56ca4953..e3091f1e30b640b4d206cd2f91ac0aefe745a9d3 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x80081270
        BLKBSZSET                            = 0x40081271
@@ -486,6 +487,50 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
@@ -493,6 +538,7 @@ const (
        FFDLY                                = 0x8000
        FLUSHO                               = 0x1000
        FP_XSTATE_MAGIC2                     = 0x46505845
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -514,7 +560,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1134,7 +1180,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1398,6 +1444,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2233,6 +2285,7 @@ const (
        TUNGETVNETBE                         = 0x800454df
        TUNGETVNETHDRSZ                      = 0x800454d7
        TUNGETVNETLE                         = 0x800454dd
+       TUNSETCARRIER                        = 0x400454e2
        TUNSETDEBUG                          = 0x400454c9
        TUNSETFILTEREBPF                     = 0x800454e1
        TUNSETGROUP                          = 0x400454ce
index f1ef82f57edd79531261faa55e56a2951f73b58e..a75dfebcc48ccf49767b4a57d73d334e9166611c 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x80041270
        BLKBSZSET                            = 0x40041271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x8000
        FFDLY                                = 0x8000
        FLUSHO                               = 0x1000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1132,7 +1178,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1396,6 +1442,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2239,6 +2291,7 @@ const (
        TUNGETVNETBE                         = 0x800454df
        TUNGETVNETHDRSZ                      = 0x800454d7
        TUNGETVNETLE                         = 0x800454dd
+       TUNSETCARRIER                        = 0x400454e2
        TUNSETDEBUG                          = 0x400454c9
        TUNSETFILTEREBPF                     = 0x800454e1
        TUNSETGROUP                          = 0x400454ce
index cf17c99069440a25efc4726b92f7c2d733fb315e..393ad7c91b28f7a2ef0a3120b88ed5340aa5052b 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x80081270
        BLKBSZSET                            = 0x40081271
@@ -488,6 +489,50 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
@@ -495,6 +540,7 @@ const (
        FFDLY                                = 0x8000
        FLUSHO                               = 0x1000
        FPSIMD_MAGIC                         = 0x46508001
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -516,7 +562,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1135,7 +1181,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1399,6 +1445,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2224,6 +2276,7 @@ const (
        TUNGETVNETBE                         = 0x800454df
        TUNGETVNETHDRSZ                      = 0x800454d7
        TUNGETVNETLE                         = 0x800454dd
+       TUNSETCARRIER                        = 0x400454e2
        TUNSETDEBUG                          = 0x400454c9
        TUNSETFILTEREBPF                     = 0x800454e1
        TUNSETGROUP                          = 0x400454ce
index 380913c4fce1400ab0a81a1496c93bda132f2f84..ba1beb90935e0ac8cd2226408290181ad177ea75 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x40041270
        BLKBSZSET                            = 0x80041271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x8000
        FFDLY                                = 0x8000
        FLUSHO                               = 0x2000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1132,7 +1178,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1396,6 +1442,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2234,6 +2286,7 @@ const (
        TUNGETVNETBE                         = 0x400454df
        TUNGETVNETHDRSZ                      = 0x400454d7
        TUNGETVNETLE                         = 0x400454dd
+       TUNSETCARRIER                        = 0x800454e2
        TUNSETDEBUG                          = 0x800454c9
        TUNSETFILTEREBPF                     = 0x400454e1
        TUNSETGROUP                          = 0x800454ce
index fb82529ac93ca18d08a6cea1cc710fb809302311..efba3e5c9df07ab2b73c4ac8fef9c94dea4764cf 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x40081270
        BLKBSZSET                            = 0x80081271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x8000
        FFDLY                                = 0x8000
        FLUSHO                               = 0x2000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1132,7 +1178,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1396,6 +1442,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2234,6 +2286,7 @@ const (
        TUNGETVNETBE                         = 0x400454df
        TUNGETVNETHDRSZ                      = 0x400454d7
        TUNGETVNETLE                         = 0x400454dd
+       TUNSETCARRIER                        = 0x800454e2
        TUNSETDEBUG                          = 0x800454c9
        TUNSETFILTEREBPF                     = 0x400454e1
        TUNSETGROUP                          = 0x800454ce
index 677d9045624b0ac287d13b40c585cdb0b31022f6..d3f6e9065249914d3265d92f7eda8f7b56b5326e 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x40081270
        BLKBSZSET                            = 0x80081271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x8000
        FFDLY                                = 0x8000
        FLUSHO                               = 0x2000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1132,7 +1178,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1396,6 +1442,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2234,6 +2286,7 @@ const (
        TUNGETVNETBE                         = 0x400454df
        TUNGETVNETHDRSZ                      = 0x400454d7
        TUNGETVNETLE                         = 0x400454dd
+       TUNSETCARRIER                        = 0x800454e2
        TUNSETDEBUG                          = 0x800454c9
        TUNSETFILTEREBPF                     = 0x400454e1
        TUNSETGROUP                          = 0x800454ce
index 7ddd09d7824e904ce0f6c12e07be32dc43a80ea4..7275cd876b317fafe03612e2e2c0e11b2889f4a1 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x40041270
        BLKBSZSET                            = 0x80041271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x8000
        FFDLY                                = 0x8000
        FLUSHO                               = 0x2000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1132,7 +1178,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1396,6 +1442,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2234,6 +2286,7 @@ const (
        TUNGETVNETBE                         = 0x400454df
        TUNGETVNETHDRSZ                      = 0x400454d7
        TUNGETVNETLE                         = 0x400454dd
+       TUNSETCARRIER                        = 0x800454e2
        TUNSETDEBUG                          = 0x800454c9
        TUNSETFILTEREBPF                     = 0x400454e1
        TUNSETGROUP                          = 0x800454ce
index ebaca417b461308438f18904a1b6e08881ada125..7586a134ef754cbf99e3c62ed76d1f87663fdba1 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x40081270
        BLKBSZSET                            = 0x80081271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x4000
        FFDLY                                = 0x4000
        FLUSHO                               = 0x800000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1131,7 +1177,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1398,6 +1444,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2294,6 +2346,7 @@ const (
        TUNGETVNETBE                         = 0x400454df
        TUNGETVNETHDRSZ                      = 0x400454d7
        TUNGETVNETLE                         = 0x400454dd
+       TUNSETCARRIER                        = 0x800454e2
        TUNSETDEBUG                          = 0x800454c9
        TUNSETFILTEREBPF                     = 0x400454e1
        TUNSETGROUP                          = 0x800454ce
index 02938cb6ed45744f2ee4310d321c7b55795b8b7a..b861ec78347240a87e085ec5c6383bf944284b73 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x40081270
        BLKBSZSET                            = 0x80081271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x4000
        FFDLY                                = 0x4000
        FLUSHO                               = 0x800000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1131,7 +1177,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1398,6 +1444,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2294,6 +2346,7 @@ const (
        TUNGETVNETBE                         = 0x400454df
        TUNGETVNETHDRSZ                      = 0x400454d7
        TUNGETVNETLE                         = 0x400454dd
+       TUNSETCARRIER                        = 0x800454e2
        TUNSETDEBUG                          = 0x800454c9
        TUNSETFILTEREBPF                     = 0x400454e1
        TUNSETGROUP                          = 0x800454ce
index 5aea4b9093ade4e8ecd2cdbcf93929e664d0b560..a321ec23f466233328d25bd9e271137a1c9c642f 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x80081270
        BLKBSZSET                            = 0x40081271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x8000
        FFDLY                                = 0x8000
        FLUSHO                               = 0x1000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1132,7 +1178,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1396,6 +1442,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2220,6 +2272,7 @@ const (
        TUNGETVNETBE                         = 0x800454df
        TUNGETVNETHDRSZ                      = 0x800454d7
        TUNGETVNETLE                         = 0x800454dd
+       TUNSETCARRIER                        = 0x400454e2
        TUNSETDEBUG                          = 0x400454c9
        TUNSETFILTEREBPF                     = 0x800454e1
        TUNSETGROUP                          = 0x400454ce
index 7f7c2e3e2fe1b9a06a03ee567426a858c9f06017..f6c99164ffcca243b5c8009ca865e48f8650662a 100644 (file)
@@ -174,6 +174,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x80081270
        BLKBSZSET                            = 0x40081271
@@ -486,12 +487,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x8000
        FFDLY                                = 0x8000
        FLUSHO                               = 0x1000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -513,7 +559,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1132,7 +1178,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1396,6 +1442,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2293,6 +2345,7 @@ const (
        TUNGETVNETBE                         = 0x800454df
        TUNGETVNETHDRSZ                      = 0x800454d7
        TUNGETVNETLE                         = 0x800454dd
+       TUNSETCARRIER                        = 0x400454e2
        TUNSETDEBUG                          = 0x400454c9
        TUNSETFILTEREBPF                     = 0x800454e1
        TUNSETGROUP                          = 0x400454ce
index 968e21fd680b838f799e11d633ad38050b5db957..c1e95e29cbcafc1e1c53be395549f056348e30a9 100644 (file)
@@ -177,6 +177,7 @@ const (
        B9600                                = 0xd
        BALLOON_KVM_MAGIC                    = 0x13661366
        BDEVFS_MAGIC                         = 0x62646576
+       BINDERFS_SUPER_MAGIC                 = 0x6c6f6f70
        BINFMTFS_MAGIC                       = 0x42494e4d
        BLKBSZGET                            = 0x40081270
        BLKBSZSET                            = 0x80081271
@@ -490,12 +491,57 @@ const (
        FALLOC_FL_PUNCH_HOLE                 = 0x2
        FALLOC_FL_UNSHARE_RANGE              = 0x40
        FALLOC_FL_ZERO_RANGE                 = 0x10
+       FANOTIFY_METADATA_VERSION            = 0x3
+       FAN_ACCESS                           = 0x1
+       FAN_ACCESS_PERM                      = 0x20000
+       FAN_ALLOW                            = 0x1
+       FAN_ALL_CLASS_BITS                   = 0xc
+       FAN_ALL_EVENTS                       = 0x3b
+       FAN_ALL_INIT_FLAGS                   = 0x3f
+       FAN_ALL_MARK_FLAGS                   = 0xff
+       FAN_ALL_OUTGOING_EVENTS              = 0x3403b
+       FAN_ALL_PERM_EVENTS                  = 0x30000
+       FAN_AUDIT                            = 0x10
+       FAN_CLASS_CONTENT                    = 0x4
+       FAN_CLASS_NOTIF                      = 0x0
+       FAN_CLASS_PRE_CONTENT                = 0x8
+       FAN_CLOEXEC                          = 0x1
+       FAN_CLOSE                            = 0x18
+       FAN_CLOSE_NOWRITE                    = 0x10
+       FAN_CLOSE_WRITE                      = 0x8
+       FAN_DENY                             = 0x2
+       FAN_ENABLE_AUDIT                     = 0x40
+       FAN_EVENT_METADATA_LEN               = 0x18
+       FAN_EVENT_ON_CHILD                   = 0x8000000
+       FAN_MARK_ADD                         = 0x1
+       FAN_MARK_DONT_FOLLOW                 = 0x4
+       FAN_MARK_FILESYSTEM                  = 0x100
+       FAN_MARK_FLUSH                       = 0x80
+       FAN_MARK_IGNORED_MASK                = 0x20
+       FAN_MARK_IGNORED_SURV_MODIFY         = 0x40
+       FAN_MARK_INODE                       = 0x0
+       FAN_MARK_MOUNT                       = 0x10
+       FAN_MARK_ONLYDIR                     = 0x8
+       FAN_MARK_REMOVE                      = 0x2
+       FAN_MODIFY                           = 0x2
+       FAN_NOFD                             = -0x1
+       FAN_NONBLOCK                         = 0x2
+       FAN_ONDIR                            = 0x40000000
+       FAN_OPEN                             = 0x20
+       FAN_OPEN_EXEC                        = 0x1000
+       FAN_OPEN_EXEC_PERM                   = 0x40000
+       FAN_OPEN_PERM                        = 0x10000
+       FAN_Q_OVERFLOW                       = 0x4000
+       FAN_REPORT_TID                       = 0x100
+       FAN_UNLIMITED_MARKS                  = 0x20
+       FAN_UNLIMITED_QUEUE                  = 0x10
        FD_CLOEXEC                           = 0x1
        FD_SETSIZE                           = 0x400
        FF0                                  = 0x0
        FF1                                  = 0x8000
        FFDLY                                = 0x8000
        FLUSHO                               = 0x1000
+       FS_ENCRYPTION_MODE_ADIANTUM          = 0x9
        FS_ENCRYPTION_MODE_AES_128_CBC       = 0x5
        FS_ENCRYPTION_MODE_AES_128_CTS       = 0x6
        FS_ENCRYPTION_MODE_AES_256_CBC       = 0x3
@@ -517,7 +563,7 @@ const (
        FS_POLICY_FLAGS_PAD_4                = 0x0
        FS_POLICY_FLAGS_PAD_8                = 0x1
        FS_POLICY_FLAGS_PAD_MASK             = 0x3
-       FS_POLICY_FLAGS_VALID                = 0x3
+       FS_POLICY_FLAGS_VALID                = 0x7
        FUTEXFS_SUPER_MAGIC                  = 0xbad1dea
        F_ADD_SEALS                          = 0x409
        F_DUPFD                              = 0x0
@@ -1136,7 +1182,7 @@ const (
        NETLINK_UNUSED                       = 0x1
        NETLINK_USERSOCK                     = 0x2
        NETLINK_XFRM                         = 0x6
-       NETNSA_MAX                           = 0x3
+       NETNSA_MAX                           = 0x5
        NETNSA_NSID_NOT_ASSIGNED             = -0x1
        NFNETLINK_V0                         = 0x0
        NFNLGRP_ACCT_QUOTA                   = 0x8
@@ -1400,6 +1446,12 @@ const (
        PR_MCE_KILL_SET                      = 0x1
        PR_MPX_DISABLE_MANAGEMENT            = 0x2c
        PR_MPX_ENABLE_MANAGEMENT             = 0x2b
+       PR_PAC_APDAKEY                       = 0x4
+       PR_PAC_APDBKEY                       = 0x8
+       PR_PAC_APGAKEY                       = 0x10
+       PR_PAC_APIAKEY                       = 0x1
+       PR_PAC_APIBKEY                       = 0x2
+       PR_PAC_RESET_KEYS                    = 0x36
        PR_SET_CHILD_SUBREAPER               = 0x24
        PR_SET_DUMPABLE                      = 0x4
        PR_SET_ENDIAN                        = 0x14
@@ -2282,6 +2334,7 @@ const (
        TUNGETVNETBE                         = 0x400454df
        TUNGETVNETHDRSZ                      = 0x400454d7
        TUNGETVNETLE                         = 0x400454dd
+       TUNSETCARRIER                        = 0x800454e2
        TUNSETDEBUG                          = 0x800454c9
        TUNSETFILTEREBPF                     = 0x400454e1
        TUNSETGROUP                          = 0x800454ce
index e645a05cbeb462b796922db5716eb93646dc3880..52802bfc17a6cf391697a64f3961d3c4b462d767 100644 (file)
@@ -1367,6 +1367,14 @@ func Utime(path string, buf *Utimbuf) (err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func Getsystemcfg(label int) (n uint64) {
+       r0, _ := callgetsystemcfg(label)
+       n = uint64(r0)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func Getrlimit(resource int, rlim *Rlimit) (err error) {
        _, e1 := callgetrlimit(resource, uintptr(unsafe.Pointer(rlim)))
        if e1 != 0 {
index 0b8eb721022760acacab5337f09c65f7ef44e3f6..a2b24e4a430f123159cc857a6e3e2681b2d52bd5 100644 (file)
@@ -120,6 +120,7 @@ import (
 //go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_time time "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_utime utime "libc.a/shr_64.o"
+//go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_getrlimit getrlimit "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_setrlimit setrlimit "libc.a/shr_64.o"
 //go:cgo_import_dynamic libc_lseek lseek "libc.a/shr_64.o"
@@ -235,6 +236,7 @@ import (
 //go:linkname libc_gettimeofday libc_gettimeofday
 //go:linkname libc_time libc_time
 //go:linkname libc_utime libc_utime
+//go:linkname libc_getsystemcfg libc_getsystemcfg
 //go:linkname libc_getrlimit libc_getrlimit
 //go:linkname libc_setrlimit libc_setrlimit
 //go:linkname libc_lseek libc_lseek
@@ -353,6 +355,7 @@ var (
        libc_gettimeofday,
        libc_time,
        libc_utime,
+       libc_getsystemcfg,
        libc_getrlimit,
        libc_setrlimit,
        libc_lseek,
@@ -1135,6 +1138,13 @@ func callutime(_p0 uintptr, buf uintptr) (r1 uintptr, e1 Errno) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func callgetsystemcfg(label int) (r1 uintptr, e1 Errno) {
+       r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsystemcfg)), 1, uintptr(label), 0, 0, 0, 0, 0)
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func callgetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) {
        r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getrlimit)), 2, uintptr(resource), rlim, 0, 0, 0, 0)
        return
index e88a442787d31e283aaf2bde72cec2ab40cd796b..5491c89e96826726123593563c7f16fbf366aaa2 100644 (file)
@@ -118,6 +118,7 @@ int poll(uintptr_t, int, int);
 int gettimeofday(uintptr_t, uintptr_t);
 int time(uintptr_t);
 int utime(uintptr_t, uintptr_t);
+unsigned long long getsystemcfg(int);
 int getrlimit(int, uintptr_t);
 int setrlimit(int, uintptr_t);
 long long lseek(int, long long, int);
@@ -1011,6 +1012,14 @@ func callutime(_p0 uintptr, buf uintptr) (r1 uintptr, e1 Errno) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func callgetsystemcfg(label int) (r1 uintptr, e1 Errno) {
+       r1 = uintptr(C.getsystemcfg(C.int(label)))
+       e1 = syscall.GetErrno()
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func callgetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) {
        r1 = uintptr(C.getrlimit(C.int(resource), C.uintptr_t(rlim)))
        e1 = syscall.GetErrno()
index c8b451000b09bdaf300b1a772e80f9aa033f07f5..9855afa76793870afcfc0c924c8b29b377e199df 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(mask>>32), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 2aac3184bc0da9bb4f8e2eeca515b018ec4cf6e4..773e251185281ffaa586608db926a58018ab4eba 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 13c06c2815808bb62093d7a78ed56c7cd5d2b628..ccea621d4881824e90e4d58b71ffa419b9e0fdcc 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(mask>>32), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
@@ -1658,6 +1679,16 @@ func faccessat(dirfd int, path string, mode uint32) (err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func pipe(p *[2]_C_int) (err error) {
+       _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func pipe2(p *[2]_C_int, flags int) (err error) {
        _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
        if e1 != 0 {
index 737fa8d1812acd5960fcec3750daf586a62696f5..712c7a3265be7f2568bafa0c6b968e32d609dc39 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
@@ -2206,3 +2227,18 @@ func pipe2(p *[2]_C_int, flags int) (err error) {
        }
        return
 }
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(cmdline)
+       if err != nil {
+               return
+       }
+       _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
index 0a85f3f8db3331af60f9c1d3ad2ebcf12bc0dbe6..68b325100b4b6e868509d1d4909ee483297e666a 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask>>32), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index ec7007e781ded90bf4f8eec945e0fade21c30328..a8be4076cf6d42dd4632e2710a6eb181d63eb8bd 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index c5bb25d9643aeeece89a0b6cd73dc31da547aa7a..1351028adc22feb80af9ab236bfca3d42d73c1b2 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 26ada0478f9600be5d7212be96a5c6217aaac545..327b4f97a84f03fe23d57b7bfffd180449c5a985 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(mask>>32), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 2da9cb700a7f5289d6dd8026764bd78ac18c5dd1..c145bd3ceca236426828228d036a676da6daaa4c 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 772733d83ffbc78c5c460b19179bf35906293f37..cd8179c7a5efed5e5f0d6549890c0ad53be34288 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 996eba517ac3d9d904090ea86189d74c6781d29c..2e90cf0f27c7c1469b17ce8bd8d6c4d16562bad0 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
@@ -2186,3 +2207,18 @@ func pipe2(p *[2]_C_int, flags int) (err error) {
        }
        return
 }
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(cmdline)
+       if err != nil {
+               return
+       }
+       _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
index cb9072a33a480390f9304ab4f3dd38dda83ff9f3..fe9c7e12b09fd80596c459f96ff2a7481cfcec37 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 5e48a1001b9f0bc0668758c6228dba1c93c2d129..d4a2100b09f3d7c7039ee29f3cac707d5a483213 100644 (file)
@@ -14,6 +14,27 @@ var _ syscall.Errno
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
+func FanotifyInit(flags uint, event_f_flags uint) (fd int, err error) {
+       r0, _, e1 := Syscall(SYS_FANOTIFY_INIT, uintptr(flags), uintptr(event_f_flags), 0)
+       fd = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
+       _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
 func fchmodat(dirfd int, path string, mode uint32) (err error) {
        var _p0 *byte
        _p0, err = BytePtrFromString(path)
index 3206967896afd8c389adba90acb09d3f243fbc6d..b81d508a730facc48b8a8111a766dcf1f37706a4 100644 (file)
@@ -285,4 +285,5 @@ const (
        SYS_STATX                  = 291
        SYS_IO_PGETEVENTS          = 292
        SYS_RSEQ                   = 293
+       SYS_KEXEC_FILE_LOAD        = 294
 )
index 473c74613f64fed3a550a7a068ba2128ab90b8f9..2c8c46a2fc15b0f7eb17b81091fe4f62a00f5b30 100644 (file)
@@ -284,4 +284,5 @@ const (
        SYS_STATX                  = 291
        SYS_IO_PGETEVENTS          = 292
        SYS_RSEQ                   = 293
+       SYS_KEXEC_FILE_LOAD        = 294
 )
index 93480fcb168386765fc0d60e4331912d76f244be..6ed306370a5e5cd15add61219fbe6e69a6259f47 100644 (file)
@@ -253,6 +253,7 @@ const (
        SYS_TIMER_GETOVERRUN       = 264
        SYS_TIMER_DELETE           = 265
        SYS_TIMER_CREATE           = 266
+       SYS_VSERVER                = 267
        SYS_IO_SETUP               = 268
        SYS_IO_DESTROY             = 269
        SYS_IO_SUBMIT              = 270
index 2aeb52a886decc2988fe602f599012cdd689b6f1..cefe2f8eaeb107949d83213be254dbb14e20fa3e 100644 (file)
@@ -487,3 +487,13 @@ type Utsname struct {
        Version  [256]byte
        Machine  [256]byte
 }
+
+const SizeofClockinfo = 0x14
+
+type Clockinfo struct {
+       Hz      int32
+       Tick    int32
+       Tickadj int32
+       Stathz  int32
+       Profhz  int32
+}
index 0d0d9f2ccb7abd5e6f15af9bd3a205629a5a7733..c6bb883c3962dcc7534609de9a2657a05fb931e1 100644 (file)
@@ -497,3 +497,13 @@ type Utsname struct {
        Version  [256]byte
        Machine  [256]byte
 }
+
+const SizeofClockinfo = 0x14
+
+type Clockinfo struct {
+       Hz      int32
+       Tick    int32
+       Tickadj int32
+       Stathz  int32
+       Profhz  int32
+}
index 04e344b78d88329dcbf0f15b0c2dd3050549bde7..94c23bc2d4ae831bbeaabe0f9d1b15ab6ba8a164 100644 (file)
@@ -488,3 +488,13 @@ type Utsname struct {
        Version  [256]byte
        Machine  [256]byte
 }
+
+const SizeofClockinfo = 0x14
+
+type Clockinfo struct {
+       Hz      int32
+       Tick    int32
+       Tickadj int32
+       Stathz  int32
+       Profhz  int32
+}
index 9fec185c180f0b51b0b59f26ea00084412f3e16b..c82a930cdc59b5eefca5eddabc3d65e4d1c2881a 100644 (file)
@@ -497,3 +497,13 @@ type Utsname struct {
        Version  [256]byte
        Machine  [256]byte
 }
+
+const SizeofClockinfo = 0x14
+
+type Clockinfo struct {
+       Hz      int32
+       Tick    int32
+       Tickadj int32
+       Stathz  int32
+       Profhz  int32
+}
index 3e9c18e6814bb287be8514c67146d4b35c419001..6dfe56be769abf3283f8c8135aef3702f4c4322d 100644 (file)
@@ -575,6 +575,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -640,6 +641,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x8
@@ -961,7 +973,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1064,6 +1077,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1085,21 +1099,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1112,6 +1143,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1416,6 +1448,9 @@ const (
        SizeofTpacketHdr  = 0x18
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2031,3 +2066,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 14365ff6cf3046d4f0e0c8066d54e80009e6917c..9f8cbf4cb33f015e78b3034ceb2045bdfb60b9ef 100644 (file)
@@ -576,6 +576,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -641,6 +642,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -972,7 +984,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1075,6 +1088,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1096,21 +1110,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1123,6 +1154,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1428,6 +1460,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2044,3 +2079,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 80ad473c614ed0de712dfffd506f5e7f506ea8d8..cbbf19a44713892a11da358411c0fe2ae1f53b54 100644 (file)
@@ -579,6 +579,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -644,6 +645,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x8
@@ -950,7 +962,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1053,6 +1066,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1074,21 +1088,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1101,6 +1132,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1406,6 +1438,9 @@ const (
        SizeofTpacketHdr  = 0x18
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2022,3 +2057,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 20e78cc1f6d1819dc99c19b73af8b039f7d74072..be21189dbd786169372d981884c2130f5ca33181 100644 (file)
@@ -577,6 +577,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -642,6 +643,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -951,7 +963,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1054,6 +1067,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1075,21 +1089,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1102,6 +1133,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1407,6 +1439,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2023,3 +2058,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index bdeb0cb24f69167b6a3ca7ddece54ac75641c4aa..d599ca2759c39ae2e9b62c4352c69a60758f9041 100644 (file)
@@ -578,6 +578,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -643,6 +644,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x8
@@ -955,7 +967,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1058,6 +1071,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1079,21 +1093,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1106,6 +1137,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1412,6 +1444,9 @@ const (
        SizeofTpacketHdr  = 0x18
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2028,3 +2063,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 2d3f5911290b3959804fd9563d9597be6a308f47..011be86baef9a20d411237d68e2550289a8bfdd0 100644 (file)
@@ -577,6 +577,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -642,6 +643,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -953,7 +965,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1056,6 +1069,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1077,21 +1091,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1104,6 +1135,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1409,6 +1441,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2025,3 +2060,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 5fb57ff2a386cbdd67c3108cea3449c77bc08439..8163445163e8285b00aef6ad31e77040c8cb2351 100644 (file)
@@ -577,6 +577,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -642,6 +643,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -953,7 +965,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1056,6 +1069,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1077,21 +1091,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1104,6 +1135,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1409,6 +1441,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2025,3 +2060,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index b46b26f6ce1c686b6e31f507dc36cfd34b4c59f0..4ecf7a8c77c81dbfda438bbcf9117ebbd9a9e4c1 100644 (file)
@@ -578,6 +578,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -643,6 +644,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x8
@@ -955,7 +967,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1058,6 +1071,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1079,21 +1093,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1106,6 +1137,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1412,6 +1444,9 @@ const (
        SizeofTpacketHdr  = 0x18
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2028,3 +2063,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index e14e3c90abf0014d930410597b1314d4af1104d1..ea817bafbae022a992eed6360a5f2e33793a3508 100644 (file)
@@ -578,6 +578,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -643,6 +644,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -961,7 +973,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1064,6 +1077,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1085,21 +1099,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1112,6 +1143,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1417,6 +1449,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2033,3 +2068,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 2332e8fd126a611365988c3342afae872748d309..192ea3b105dd051185acd6a3212b00279cf679a0 100644 (file)
@@ -578,6 +578,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -643,6 +644,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -961,7 +973,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1064,6 +1077,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1085,21 +1099,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1112,6 +1143,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1417,6 +1449,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2033,3 +2068,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index efec4f8193ba8bfc034ab66ebaf212998fa52cfc..673e5e7919c14d11a271f3ab8d72b2e248278eb8 100644 (file)
@@ -577,6 +577,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -642,6 +643,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -978,7 +990,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1081,6 +1094,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1102,21 +1116,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1129,6 +1160,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1434,6 +1466,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2050,3 +2085,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 71cc23f2e13c92e774057ca1b070b2c2635a7060..faafcddfcc6b6278fa0ab93d773c9fbc1a704162 100644 (file)
@@ -576,6 +576,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -641,6 +642,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -974,7 +986,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1077,6 +1090,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1098,21 +1112,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1125,6 +1156,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1431,6 +1463,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2047,3 +2082,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 48805ba1952880a617207972e66108454335b21b..392dd7375cc2a421c259009eb60bf2e7c966a9ff 100644 (file)
@@ -580,6 +580,7 @@ const (
        SizeofIfAddrmsg      = 0x8
        SizeofRtMsg          = 0xc
        SizeofRtNexthop      = 0x8
+       SizeofNdUseroptmsg   = 0x10
 )
 
 type NlMsghdr struct {
@@ -645,6 +646,17 @@ type RtNexthop struct {
        Ifindex int32
 }
 
+type NdUseroptmsg struct {
+       Family    uint8
+       Pad1      uint8
+       Opts_len  uint16
+       Ifindex   int32
+       Icmp_type uint8
+       Icmp_code uint8
+       Pad2      uint16
+       Pad3      uint32
+}
+
 const (
        SizeofSockFilter = 0x8
        SizeofSockFprog  = 0x10
@@ -956,7 +968,8 @@ type PerfEventAttr struct {
        Clockid            int32
        Sample_regs_intr   uint64
        Aux_watermark      uint32
-       _                  uint32
+       Sample_max_stack   uint16
+       _                  uint16
 }
 
 type PerfEventMmapPage struct {
@@ -1059,6 +1072,7 @@ const (
        PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
        PERF_COUNT_SW_EMULATION_FAULTS = 0x8
        PERF_COUNT_SW_DUMMY            = 0x9
+       PERF_COUNT_SW_BPF_OUTPUT       = 0xa
 
        PERF_SAMPLE_IP           = 0x1
        PERF_SAMPLE_TID          = 0x2
@@ -1080,21 +1094,38 @@ const (
        PERF_SAMPLE_BRANCH_ANY_CALL   = 0x10
        PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
        PERF_SAMPLE_BRANCH_IND_CALL   = 0x40
+       PERF_SAMPLE_BRANCH_ABORT_TX   = 0x80
+       PERF_SAMPLE_BRANCH_IN_TX      = 0x100
+       PERF_SAMPLE_BRANCH_NO_TX      = 0x200
+       PERF_SAMPLE_BRANCH_COND       = 0x400
+       PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+       PERF_SAMPLE_BRANCH_IND_JUMP   = 0x1000
+       PERF_SAMPLE_BRANCH_CALL       = 0x2000
+       PERF_SAMPLE_BRANCH_NO_FLAGS   = 0x4000
+       PERF_SAMPLE_BRANCH_NO_CYCLES  = 0x8000
+       PERF_SAMPLE_BRANCH_TYPE_SAVE  = 0x10000
 
        PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
        PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
        PERF_FORMAT_ID                 = 0x4
        PERF_FORMAT_GROUP              = 0x8
 
-       PERF_RECORD_MMAP       = 0x1
-       PERF_RECORD_LOST       = 0x2
-       PERF_RECORD_COMM       = 0x3
-       PERF_RECORD_EXIT       = 0x4
-       PERF_RECORD_THROTTLE   = 0x5
-       PERF_RECORD_UNTHROTTLE = 0x6
-       PERF_RECORD_FORK       = 0x7
-       PERF_RECORD_READ       = 0x8
-       PERF_RECORD_SAMPLE     = 0x9
+       PERF_RECORD_MMAP            = 0x1
+       PERF_RECORD_LOST            = 0x2
+       PERF_RECORD_COMM            = 0x3
+       PERF_RECORD_EXIT            = 0x4
+       PERF_RECORD_THROTTLE        = 0x5
+       PERF_RECORD_UNTHROTTLE      = 0x6
+       PERF_RECORD_FORK            = 0x7
+       PERF_RECORD_READ            = 0x8
+       PERF_RECORD_SAMPLE          = 0x9
+       PERF_RECORD_MMAP2           = 0xa
+       PERF_RECORD_AUX             = 0xb
+       PERF_RECORD_ITRACE_START    = 0xc
+       PERF_RECORD_LOST_SAMPLES    = 0xd
+       PERF_RECORD_SWITCH          = 0xe
+       PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+       PERF_RECORD_NAMESPACES      = 0x10
 
        PERF_CONTEXT_HV     = -0x20
        PERF_CONTEXT_KERNEL = -0x80
@@ -1107,6 +1138,7 @@ const (
        PERF_FLAG_FD_NO_GROUP = 0x1
        PERF_FLAG_FD_OUTPUT   = 0x2
        PERF_FLAG_PID_CGROUP  = 0x4
+       PERF_FLAG_FD_CLOEXEC  = 0x8
 )
 
 const (
@@ -1412,6 +1444,9 @@ const (
        SizeofTpacketHdr  = 0x20
        SizeofTpacket2Hdr = 0x20
        SizeofTpacket3Hdr = 0x30
+
+       SizeofTpacketStats   = 0x8
+       SizeofTpacketStatsV3 = 0xc
 )
 
 const (
@@ -2028,3 +2063,18 @@ type SockExtendedErr struct {
        Info   uint32
        Data   uint32
 }
+
+type FanotifyEventMetadata struct {
+       Event_len    uint32
+       Vers         uint8
+       Reserved     uint8
+       Metadata_len uint16
+       Mask         uint64
+       Fd           int32
+       Pid          int32
+}
+
+type FanotifyResponse struct {
+       Fd       int32
+       Response uint32
+}
index 8b37d83992b6fdd495a4556d413e9283be818d64..900fb44622f36050ff0acd7f6b9109ed01353b9a 100644 (file)
@@ -558,3 +558,13 @@ type Uvmexp struct {
        Fpswtch            int32
        Kmapent            int32
 }
+
+const SizeofClockinfo = 0x14
+
+type Clockinfo struct {
+       Hz      int32
+       Tick    int32
+       Tickadj int32
+       Stathz  int32
+       Profhz  int32
+}
index 6efea463559f8913967ff8a8ac1af81d2cacabd9..028fa78d74afc76101c31580a541dfa73918897d 100644 (file)
@@ -558,3 +558,13 @@ type Uvmexp struct {
        Fpswtch            int32
        Kmapent            int32
 }
+
+const SizeofClockinfo = 0x14
+
+type Clockinfo struct {
+       Hz      int32
+       Tick    int32
+       Tickadj int32
+       Stathz  int32
+       Profhz  int32
+}
index 510efc3eaac69f9ff4f45c6979fb684d99753b07..b45d5eedffe91c69b5127c2de2faca4a3b520499 100644 (file)
@@ -559,3 +559,13 @@ type Uvmexp struct {
        Fpswtch            int32
        Kmapent            int32
 }
+
+const SizeofClockinfo = 0x14
+
+type Clockinfo struct {
+       Hz      int32
+       Tick    int32
+       Tickadj int32
+       Stathz  int32
+       Profhz  int32
+}
index e92c05b213c8f63d960bd9c1ceedb20bb798e15b..ba67658db1d13909c4ab063bcc0fb7c1dff53be6 100644 (file)
@@ -359,11 +359,11 @@ func loadLibraryEx(name string, system bool) (*DLL, error) {
                        // trying to load "foo.dll" out of the system
                        // folder, but LoadLibraryEx doesn't support
                        // that yet on their system, so emulate it.
-                       windir, _ := Getenv("WINDIR") // old var; apparently works on XP
-                       if windir == "" {
-                               return nil, errString("%WINDIR% not defined")
+                       systemdir, err := GetSystemDirectory()
+                       if err != nil {
+                               return nil, err
                        }
-                       loadDLL = windir + "\\System32\\" + name
+                       loadDLL = systemdir + "\\" + name
                }
        }
        h, err := LoadLibraryEx(loadDLL, 0, flags)
index 9f946da6fe5e216f5efb0fd9b7eb36de3c1057e2..da06406c44e1efe2221a5612e86b4b343ab723e6 100644 (file)
@@ -169,6 +169,7 @@ const (
 //sys  GetLengthSid(sid *SID) (len uint32) = advapi32.GetLengthSid
 //sys  CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) = advapi32.CopySid
 //sys  AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) = advapi32.AllocateAndInitializeSid
+//sys  createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) = advapi32.CreateWellKnownSid
 //sys  FreeSid(sid *SID) (err error) [failretval!=0] = advapi32.FreeSid
 //sys  EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) = advapi32.EqualSid
 
@@ -286,6 +287,158 @@ func (sid *SID) LookupAccount(system string) (account, domain string, accType ui
        }
 }
 
+// Various types of pre-specified sids that can be synthesized at runtime.
+type WELL_KNOWN_SID_TYPE uint32
+
+const (
+       WinNullSid                                    = 0
+       WinWorldSid                                   = 1
+       WinLocalSid                                   = 2
+       WinCreatorOwnerSid                            = 3
+       WinCreatorGroupSid                            = 4
+       WinCreatorOwnerServerSid                      = 5
+       WinCreatorGroupServerSid                      = 6
+       WinNtAuthoritySid                             = 7
+       WinDialupSid                                  = 8
+       WinNetworkSid                                 = 9
+       WinBatchSid                                   = 10
+       WinInteractiveSid                             = 11
+       WinServiceSid                                 = 12
+       WinAnonymousSid                               = 13
+       WinProxySid                                   = 14
+       WinEnterpriseControllersSid                   = 15
+       WinSelfSid                                    = 16
+       WinAuthenticatedUserSid                       = 17
+       WinRestrictedCodeSid                          = 18
+       WinTerminalServerSid                          = 19
+       WinRemoteLogonIdSid                           = 20
+       WinLogonIdsSid                                = 21
+       WinLocalSystemSid                             = 22
+       WinLocalServiceSid                            = 23
+       WinNetworkServiceSid                          = 24
+       WinBuiltinDomainSid                           = 25
+       WinBuiltinAdministratorsSid                   = 26
+       WinBuiltinUsersSid                            = 27
+       WinBuiltinGuestsSid                           = 28
+       WinBuiltinPowerUsersSid                       = 29
+       WinBuiltinAccountOperatorsSid                 = 30
+       WinBuiltinSystemOperatorsSid                  = 31
+       WinBuiltinPrintOperatorsSid                   = 32
+       WinBuiltinBackupOperatorsSid                  = 33
+       WinBuiltinReplicatorSid                       = 34
+       WinBuiltinPreWindows2000CompatibleAccessSid   = 35
+       WinBuiltinRemoteDesktopUsersSid               = 36
+       WinBuiltinNetworkConfigurationOperatorsSid    = 37
+       WinAccountAdministratorSid                    = 38
+       WinAccountGuestSid                            = 39
+       WinAccountKrbtgtSid                           = 40
+       WinAccountDomainAdminsSid                     = 41
+       WinAccountDomainUsersSid                      = 42
+       WinAccountDomainGuestsSid                     = 43
+       WinAccountComputersSid                        = 44
+       WinAccountControllersSid                      = 45
+       WinAccountCertAdminsSid                       = 46
+       WinAccountSchemaAdminsSid                     = 47
+       WinAccountEnterpriseAdminsSid                 = 48
+       WinAccountPolicyAdminsSid                     = 49
+       WinAccountRasAndIasServersSid                 = 50
+       WinNTLMAuthenticationSid                      = 51
+       WinDigestAuthenticationSid                    = 52
+       WinSChannelAuthenticationSid                  = 53
+       WinThisOrganizationSid                        = 54
+       WinOtherOrganizationSid                       = 55
+       WinBuiltinIncomingForestTrustBuildersSid      = 56
+       WinBuiltinPerfMonitoringUsersSid              = 57
+       WinBuiltinPerfLoggingUsersSid                 = 58
+       WinBuiltinAuthorizationAccessSid              = 59
+       WinBuiltinTerminalServerLicenseServersSid     = 60
+       WinBuiltinDCOMUsersSid                        = 61
+       WinBuiltinIUsersSid                           = 62
+       WinIUserSid                                   = 63
+       WinBuiltinCryptoOperatorsSid                  = 64
+       WinUntrustedLabelSid                          = 65
+       WinLowLabelSid                                = 66
+       WinMediumLabelSid                             = 67
+       WinHighLabelSid                               = 68
+       WinSystemLabelSid                             = 69
+       WinWriteRestrictedCodeSid                     = 70
+       WinCreatorOwnerRightsSid                      = 71
+       WinCacheablePrincipalsGroupSid                = 72
+       WinNonCacheablePrincipalsGroupSid             = 73
+       WinEnterpriseReadonlyControllersSid           = 74
+       WinAccountReadonlyControllersSid              = 75
+       WinBuiltinEventLogReadersGroup                = 76
+       WinNewEnterpriseReadonlyControllersSid        = 77
+       WinBuiltinCertSvcDComAccessGroup              = 78
+       WinMediumPlusLabelSid                         = 79
+       WinLocalLogonSid                              = 80
+       WinConsoleLogonSid                            = 81
+       WinThisOrganizationCertificateSid             = 82
+       WinApplicationPackageAuthoritySid             = 83
+       WinBuiltinAnyPackageSid                       = 84
+       WinCapabilityInternetClientSid                = 85
+       WinCapabilityInternetClientServerSid          = 86
+       WinCapabilityPrivateNetworkClientServerSid    = 87
+       WinCapabilityPicturesLibrarySid               = 88
+       WinCapabilityVideosLibrarySid                 = 89
+       WinCapabilityMusicLibrarySid                  = 90
+       WinCapabilityDocumentsLibrarySid              = 91
+       WinCapabilitySharedUserCertificatesSid        = 92
+       WinCapabilityEnterpriseAuthenticationSid      = 93
+       WinCapabilityRemovableStorageSid              = 94
+       WinBuiltinRDSRemoteAccessServersSid           = 95
+       WinBuiltinRDSEndpointServersSid               = 96
+       WinBuiltinRDSManagementServersSid             = 97
+       WinUserModeDriversSid                         = 98
+       WinBuiltinHyperVAdminsSid                     = 99
+       WinAccountCloneableControllersSid             = 100
+       WinBuiltinAccessControlAssistanceOperatorsSid = 101
+       WinBuiltinRemoteManagementUsersSid            = 102
+       WinAuthenticationAuthorityAssertedSid         = 103
+       WinAuthenticationServiceAssertedSid           = 104
+       WinLocalAccountSid                            = 105
+       WinLocalAccountAndAdministratorSid            = 106
+       WinAccountProtectedUsersSid                   = 107
+       WinCapabilityAppointmentsSid                  = 108
+       WinCapabilityContactsSid                      = 109
+       WinAccountDefaultSystemManagedSid             = 110
+       WinBuiltinDefaultSystemManagedGroupSid        = 111
+       WinBuiltinStorageReplicaAdminsSid             = 112
+       WinAccountKeyAdminsSid                        = 113
+       WinAccountEnterpriseKeyAdminsSid              = 114
+       WinAuthenticationKeyTrustSid                  = 115
+       WinAuthenticationKeyPropertyMFASid            = 116
+       WinAuthenticationKeyPropertyAttestationSid    = 117
+       WinAuthenticationFreshKeyAuthSid              = 118
+       WinBuiltinDeviceOwnersSid                     = 119
+)
+
+// Creates a sid for a well-known predefined alias, generally using the constants of the form
+// Win*Sid, for the local machine.
+func CreateWellKnownSid(sidType WELL_KNOWN_SID_TYPE) (*SID, error) {
+       return CreateWellKnownDomainSid(sidType, nil)
+}
+
+// Creates a sid for a well-known predefined alias, generally using the constants of the form
+// Win*Sid, for the domain specified by the domainSid parameter.
+func CreateWellKnownDomainSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID) (*SID, error) {
+       n := uint32(50)
+       for {
+               b := make([]byte, n)
+               sid := (*SID)(unsafe.Pointer(&b[0]))
+               err := createWellKnownSid(sidType, domainSid, sid, &n)
+               if err == nil {
+                       return sid, nil
+               }
+               if err != ERROR_INSUFFICIENT_BUFFER {
+                       return nil, err
+               }
+               if n <= uint32(len(b)) {
+                       return nil, err
+               }
+       }
+}
+
 const (
        // do not reorder
        TOKEN_ASSIGN_PRIMARY = 1 << iota
@@ -372,6 +525,7 @@ type Tokengroups struct {
 //sys  OpenProcessToken(h Handle, access uint32, token *Token) (err error) = advapi32.OpenProcessToken
 //sys  GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) = advapi32.GetTokenInformation
 //sys  GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) = userenv.GetUserProfileDirectoryW
+//sys  getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) = kernel32.GetSystemDirectoryW
 
 // An access token contains the security information for a logon session.
 // The system creates an access token when a user logs on, and every
@@ -468,6 +622,23 @@ func (t Token) GetUserProfileDirectory() (string, error) {
        }
 }
 
+// GetSystemDirectory retrieves path to current location of the system
+// directory, which is typically, though not always, C:\Windows\System32.
+func GetSystemDirectory() (string, error) {
+       n := uint32(MAX_PATH)
+       for {
+               b := make([]uint16, n)
+               l, e := getSystemDirectory(&b[0], n)
+               if e != nil {
+                       return "", e
+               }
+               if l <= n {
+                       return UTF16ToString(b[:l]), nil
+               }
+               n = l
+       }
+}
+
 // IsMember reports whether the access token t is a member of the provided SID.
 func (t Token) IsMember(sid *SID) (bool, error) {
        var b int32
index cda26b54b3912ec33c55fdf3d4edb3641b077805..38b147d5fe32bd2714bc6f809fb899d678c93ce2 100644 (file)
@@ -80,6 +80,7 @@ type ChangeRequest struct {
        EventType     uint32
        EventData     uintptr
        CurrentStatus Status
+       Context       uintptr
 }
 
 // Handler is the interface that must be implemented to build Windows service.
@@ -114,19 +115,18 @@ var (
 )
 
 func init() {
-       k := syscall.MustLoadDLL("kernel32.dll")
-       cSetEvent = k.MustFindProc("SetEvent").Addr()
-       cWaitForSingleObject = k.MustFindProc("WaitForSingleObject").Addr()
-       a := syscall.MustLoadDLL("advapi32.dll")
-       cRegisterServiceCtrlHandlerExW = a.MustFindProc("RegisterServiceCtrlHandlerExW").Addr()
+       k := windows.NewLazySystemDLL("kernel32.dll")
+       cSetEvent = k.NewProc("SetEvent").Addr()
+       cWaitForSingleObject = k.NewProc("WaitForSingleObject").Addr()
+       a := windows.NewLazySystemDLL("advapi32.dll")
+       cRegisterServiceCtrlHandlerExW = a.NewProc("RegisterServiceCtrlHandlerExW").Addr()
 }
 
-// The HandlerEx prototype also has a context pointer but since we don't use
-// it at start-up time we don't have to pass it over either.
 type ctlEvent struct {
        cmd       Cmd
        eventType uint32
        eventData uintptr
+       context   uintptr
        errno     uint32
 }
 
@@ -238,13 +238,12 @@ func (s *service) run() {
                exitFromHandler <- exitCode{ss, errno}
        }()
 
-       status := Status{State: Stopped}
        ec := exitCode{isSvcSpecific: true, errno: 0}
+       outcr := ChangeRequest{
+               CurrentStatus: Status{State: Stopped},
+       }
        var outch chan ChangeRequest
        inch := s.c
-       var cmd Cmd
-       var evtype uint32
-       var evdata uintptr
 loop:
        for {
                select {
@@ -255,10 +254,11 @@ loop:
                        }
                        inch = nil
                        outch = cmdsToHandler
-                       cmd = r.cmd
-                       evtype = r.eventType
-                       evdata = r.eventData
-               case outch <- ChangeRequest{cmd, evtype, evdata, status}:
+                       outcr.Cmd = r.cmd
+                       outcr.EventType = r.eventType
+                       outcr.EventData = r.eventData
+                       outcr.Context = r.context
+               case outch <- outcr:
                        inch = s.c
                        outch = nil
                case c := <-changesFromHandler:
@@ -271,7 +271,7 @@ loop:
                                }
                                break loop
                        }
-                       status = c
+                       outcr.CurrentStatus = c
                case ec = <-exitFromHandler:
                        break loop
                }
@@ -315,8 +315,8 @@ func Run(name string, handler Handler) error {
                return err
        }
 
-       ctlHandler := func(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
-               e := ctlEvent{cmd: Cmd(ctl), eventType: evtype, eventData: evdata}
+       ctlHandler := func(ctl, evtype, evdata, context uintptr) uintptr {
+               e := ctlEvent{cmd: Cmd(ctl), eventType: uint32(evtype), eventData: evdata, context: context}
                // We assume that this callback function is running on
                // the same thread as Run. Nowhere in MS documentation
                // I could find statement to guarantee that. So putting
index 2c82a9d91d7f2035076bfce40d5466c4883f0b24..c8a583d7375dd20f9e361c6962f2f343da57649c 100644 (file)
@@ -22,7 +22,8 @@ TEXT ·servicemain(SB),7,$0
        MOVL    AX, (SP)
        MOVL    $·servicectlhandler(SB), AX
        MOVL    AX, 4(SP)
-       MOVL    $0, 8(SP)
+       // Set context to 123456 to test issue #25660.
+       MOVL    $123456, 8(SP)
        MOVL    ·cRegisterServiceCtrlHandlerExW(SB), AX
        MOVL    SP, BP
        CALL    AX
index bde25e9c48580ae659bb4d2ee88e967163ecb35f..2f7609c5b6465dd96ef82da3b720dc9c37e4724b 100644 (file)
@@ -14,6 +14,8 @@ TEXT ·servicemain(SB),7,$0
        MOVQ    ·sName(SB), CX
        MOVQ    $·servicectlhandler(SB), DX
        // BUG(pastarmovj): Figure out a way to pass in context in R8.
+       // Set context to 123456 to test issue #25660.
+       MOVQ    $123456, R8
        MOVQ    ·cRegisterServiceCtrlHandlerExW(SB), AX
        CALL    AX
        CMPQ    AX, $0
index f72fa55f3ef3b030cbbf3a36daa61962b3db8dc1..7aff0d02252549beaac0c184324c604c77f22f94 100644 (file)
@@ -137,6 +137,7 @@ func NewCallbackCDecl(fn interface{}) uintptr {
 //sys  CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) [failretval==InvalidHandle] = CreateFileW
 //sys  ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error)
 //sys  WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error)
+//sys  GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error)
 //sys  SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) [failretval==0xffffffff]
 //sys  CloseHandle(handle Handle) (err error)
 //sys  GetStdHandle(stdhandle uint32) (handle Handle, err error) [failretval==InvalidHandle]
index 141ca81bd74d9f0fb95bd30827901178d1dc7389..bbf19f0dcd9b5364db1d0ddaf022897bcc149251 100644 (file)
@@ -126,9 +126,19 @@ const (
        OPEN_ALWAYS       = 4
        TRUNCATE_EXISTING = 5
 
-       FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
-       FILE_FLAG_BACKUP_SEMANTICS   = 0x02000000
-       FILE_FLAG_OVERLAPPED         = 0x40000000
+       FILE_FLAG_OPEN_REQUIRING_OPLOCK = 0x00040000
+       FILE_FLAG_FIRST_PIPE_INSTANCE   = 0x00080000
+       FILE_FLAG_OPEN_NO_RECALL        = 0x00100000
+       FILE_FLAG_OPEN_REPARSE_POINT    = 0x00200000
+       FILE_FLAG_SESSION_AWARE         = 0x00800000
+       FILE_FLAG_POSIX_SEMANTICS       = 0x01000000
+       FILE_FLAG_BACKUP_SEMANTICS      = 0x02000000
+       FILE_FLAG_DELETE_ON_CLOSE       = 0x04000000
+       FILE_FLAG_SEQUENTIAL_SCAN       = 0x08000000
+       FILE_FLAG_RANDOM_ACCESS         = 0x10000000
+       FILE_FLAG_NO_BUFFERING          = 0x20000000
+       FILE_FLAG_OVERLAPPED            = 0x40000000
+       FILE_FLAG_WRITE_THROUGH         = 0x80000000
 
        HANDLE_FLAG_INHERIT    = 0x00000001
        STARTF_USESTDHANDLES   = 0x00000100
index e4b54e2d92948904419bfcf1cef355d6fed1b9a7..eb9f06296e42ea70f79edc5b94ae8cde56e1684c 100644 (file)
@@ -77,6 +77,7 @@ var (
        procCreateFileW                        = modkernel32.NewProc("CreateFileW")
        procReadFile                           = modkernel32.NewProc("ReadFile")
        procWriteFile                          = modkernel32.NewProc("WriteFile")
+       procGetOverlappedResult                = modkernel32.NewProc("GetOverlappedResult")
        procSetFilePointer                     = modkernel32.NewProc("SetFilePointer")
        procCloseHandle                        = modkernel32.NewProc("CloseHandle")
        procGetStdHandle                       = modkernel32.NewProc("GetStdHandle")
@@ -246,12 +247,14 @@ var (
        procGetLengthSid                       = modadvapi32.NewProc("GetLengthSid")
        procCopySid                            = modadvapi32.NewProc("CopySid")
        procAllocateAndInitializeSid           = modadvapi32.NewProc("AllocateAndInitializeSid")
+       procCreateWellKnownSid                 = modadvapi32.NewProc("CreateWellKnownSid")
        procFreeSid                            = modadvapi32.NewProc("FreeSid")
        procEqualSid                           = modadvapi32.NewProc("EqualSid")
        procCheckTokenMembership               = modadvapi32.NewProc("CheckTokenMembership")
        procOpenProcessToken                   = modadvapi32.NewProc("OpenProcessToken")
        procGetTokenInformation                = modadvapi32.NewProc("GetTokenInformation")
        procGetUserProfileDirectoryW           = moduserenv.NewProc("GetUserProfileDirectoryW")
+       procGetSystemDirectoryW                = modkernel32.NewProc("GetSystemDirectoryW")
 )
 
 func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
@@ -652,6 +655,24 @@ func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped)
        return
 }
 
+func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
+       var _p0 uint32
+       if wait {
+               _p0 = 1
+       } else {
+               _p0 = 0
+       }
+       r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
+       if r1 == 0 {
+               if e1 != 0 {
+                       err = errnoErr(e1)
+               } else {
+                       err = syscall.EINVAL
+               }
+       }
+       return
+}
+
 func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
        r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
        newlowoffset = uint32(r0)
@@ -2653,6 +2674,18 @@ func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, s
        return
 }
 
+func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
+       r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
+       if r1 == 0 {
+               if e1 != 0 {
+                       err = errnoErr(e1)
+               } else {
+                       err = syscall.EINVAL
+               }
+       }
+       return
+}
+
 func FreeSid(sid *SID) (err error) {
        r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
        if r1 != 0 {
@@ -2718,3 +2751,16 @@ func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
        }
        return
 }
+
+func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
+       r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
+       len = uint32(r0)
+       if len == 0 {
+               if e1 != 0 {
+                       err = errnoErr(e1)
+               } else {
+                       err = syscall.EINVAL
+               }
+       }
+       return
+}
index b097527e1a9bcd2e8f6bd266eb4e692cd08553b7..c8ea49ccc623d83eac7c65517dc5165b13c5cc6d 100644 (file)
@@ -1,15 +1,17 @@
 sudo: false
 language: go
 go:
-  - 1.5.x
   - 1.6.x
   - 1.7.x
   - 1.8.x
   - 1.9.x
+  - 1.10.x
+  - 1.11.x
 
-script: 
+script:
   - go get golang.org/x/tools/cmd/cover
   - go get github.com/smartystreets/goconvey
   - mkdir -p $HOME/gopath/src/gopkg.in
   - ln -s $HOME/gopath/src/github.com/go-ini/ini $HOME/gopath/src/gopkg.in/ini.v1
+  - cd $HOME/gopath/src/gopkg.in/ini.v1
   - go test -v -cover -race
index 1316911d2df54082b1534bfba3b4d339b8948a60..af27ff0768faeb36d27299048f016e153b849c8d 100644 (file)
@@ -12,4 +12,4 @@ vet:
        go vet
 
 coverage:
-       go test -coverprofile=c.out && go tool cover -html=c.out && rm c.out
\ No newline at end of file
+       go test -coverprofile=c.out && go tool cover -html=c.out && rm c.out
index f4ff27cd30c926ca4b5fcf45a3e27ee754eb8e8d..ae4dfc3a5a8220fa51beb9c90b9b7669dde4a731 100644 (file)
@@ -1,15 +1,13 @@
-INI [![Build Status](https://travis-ci.org/go-ini/ini.svg?branch=master)](https://travis-ci.org/go-ini/ini) [![Sourcegraph](https://sourcegraph.com/github.com/go-ini/ini/-/badge.svg)](https://sourcegraph.com/github.com/go-ini/ini?badge)
+INI [![Build Status](https://travis-ci.org/go-ini/ini.svg?branch=master)](https://travis-ci.org/go-ini/ini) [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg)](https://sourcegraph.com/github.com/go-ini/ini)
 ===
 
 ![](https://avatars0.githubusercontent.com/u/10216035?v=3&s=200)
 
 Package ini provides INI file read and write functionality in Go.
 
-[简体中文](README_ZH.md)
+## Features
 
-## Feature
-
-- Load multiple data sources(`[]byte`, file and `io.ReadCloser`) with overwrites.
+- Load from multiple data sources(`[]byte`, file and `io.ReadCloser`) with overwrites.
 - Read with recursion values.
 - Read with parent-child sections.
 - Read with auto-increment key names.
@@ -22,741 +20,26 @@ Package ini provides INI file read and write functionality in Go.
 
 ## Installation
 
-To use a tagged revision:
-
-       go get gopkg.in/ini.v1
-
-To use with latest changes:
-
-       go get github.com/go-ini/ini
-
-Please add `-u` flag to update in the future.
-
-### Testing
-
-If you want to test on your machine, please apply `-t` flag:
-
-       go get -t gopkg.in/ini.v1
-
-Please add `-u` flag to update in the future.
-
-## Getting Started
-
-### Loading from data sources
-
-A **Data Source** is either raw data in type `[]byte`, a file name with type `string` or `io.ReadCloser`. You can load **as many data sources as you want**. Passing other types will simply return an error.
-
-```go
-cfg, err := ini.Load([]byte("raw data"), "filename", ioutil.NopCloser(bytes.NewReader([]byte("some other data"))))
-```
-
-Or start with an empty object:
-
-```go
-cfg := ini.Empty()
-```
-
-When you cannot decide how many data sources to load at the beginning, you will still be able to **Append()** them later.
-
-```go
-err := cfg.Append("other file", []byte("other raw data"))
-```
-
-If you have a list of files with possibilities that some of them may not available at the time, and you don't know exactly which ones, you can use `LooseLoad` to ignore nonexistent files without returning error.
-
-```go
-cfg, err := ini.LooseLoad("filename", "filename_404")
-```
-
-The cool thing is, whenever the file is available to load while you're calling `Reload` method, it will be counted as usual.
-
-#### Ignore cases of key name
-
-When you do not care about cases of section and key names, you can use `InsensitiveLoad` to force all names to be lowercased while parsing.
-
-```go
-cfg, err := ini.InsensitiveLoad("filename")
-//...
-
-// sec1 and sec2 are the exactly same section object
-sec1, err := cfg.GetSection("Section")
-sec2, err := cfg.GetSection("SecTIOn")
-
-// key1 and key2 are the exactly same key object
-key1, err := sec1.GetKey("Key")
-key2, err := sec2.GetKey("KeY")
-```
-
-#### MySQL-like boolean key 
-
-MySQL's configuration allows a key without value as follows:
-
-```ini
-[mysqld]
-...
-skip-host-cache
-skip-name-resolve
-```
-
-By default, this is considered as missing value. But if you know you're going to deal with those cases, you can assign advanced load options:
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{AllowBooleanKeys: true}, "my.cnf"))
-```
-
-The value of those keys are always `true`, and when you save to a file, it will keep in the same foramt as you read.
-
-To generate such keys in your program, you could use `NewBooleanKey`:
-
-```go
-key, err := sec.NewBooleanKey("skip-host-cache")
-```
-
-#### Comment
-
-Take care that following format will be treated as comment:
-
-1. Line begins with `#` or `;`
-2. Words after `#` or `;`
-3. Words after section name (i.e words after `[some section name]`)
-
-If you want to save a value with `#` or `;`, please quote them with ``` ` ``` or ``` """ ```.
-
-Alternatively, you can use following `LoadOptions` to completely ignore inline comments:
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: true}, "app.ini"))
-```
-
-### Working with sections
-
-To get a section, you would need to:
-
-```go
-section, err := cfg.GetSection("section name")
-```
-
-For a shortcut for default section, just give an empty string as name:
-
-```go
-section, err := cfg.GetSection("")
-```
-
-When you're pretty sure the section exists, following code could make your life easier:
-
-```go
-section := cfg.Section("section name")
-```
-
-What happens when the section somehow does not exist? Don't panic, it automatically creates and returns a new section to you.
-
-To create a new section:
-
-```go
-err := cfg.NewSection("new section")
-```
-
-To get a list of sections or section names:
-
-```go
-sections := cfg.Sections()
-names := cfg.SectionStrings()
-```
-
-### Working with keys
-
-To get a key under a section:
-
-```go
-key, err := cfg.Section("").GetKey("key name")
-```
-
-Same rule applies to key operations:
-
-```go
-key := cfg.Section("").Key("key name")
-```
-
-To check if a key exists:
-
-```go
-yes := cfg.Section("").HasKey("key name")
-```
-
-To create a new key:
-
-```go
-err := cfg.Section("").NewKey("name", "value")
-```
-
-To get a list of keys or key names:
-
-```go
-keys := cfg.Section("").Keys()
-names := cfg.Section("").KeyStrings()
-```
-
-To get a clone hash of keys and corresponding values:
-
-```go
-hash := cfg.Section("").KeysHash()
-```
-
-### Working with values
-
-To get a string value:
-
-```go
-val := cfg.Section("").Key("key name").String()
-```
-
-To validate key value on the fly:
-
-```go
-val := cfg.Section("").Key("key name").Validate(func(in string) string {
-       if len(in) == 0 {
-               return "default"
-       }
-       return in
-})
-```
-
-If you do not want any auto-transformation (such as recursive read) for the values, you can get raw value directly (this way you get much better performance):
-
-```go
-val := cfg.Section("").Key("key name").Value()
-```
-
-To check if raw value exists:
-
-```go
-yes := cfg.Section("").HasValue("test value")
-```
-
-To get value with types:
-
-```go
-// For boolean values:
-// true when value is: 1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On
-// false when value is: 0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off
-v, err = cfg.Section("").Key("BOOL").Bool()
-v, err = cfg.Section("").Key("FLOAT64").Float64()
-v, err = cfg.Section("").Key("INT").Int()
-v, err = cfg.Section("").Key("INT64").Int64()
-v, err = cfg.Section("").Key("UINT").Uint()
-v, err = cfg.Section("").Key("UINT64").Uint64()
-v, err = cfg.Section("").Key("TIME").TimeFormat(time.RFC3339)
-v, err = cfg.Section("").Key("TIME").Time() // RFC3339
-
-v = cfg.Section("").Key("BOOL").MustBool()
-v = cfg.Section("").Key("FLOAT64").MustFloat64()
-v = cfg.Section("").Key("INT").MustInt()
-v = cfg.Section("").Key("INT64").MustInt64()
-v = cfg.Section("").Key("UINT").MustUint()
-v = cfg.Section("").Key("UINT64").MustUint64()
-v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339)
-v = cfg.Section("").Key("TIME").MustTime() // RFC3339
-
-// Methods start with Must also accept one argument for default value
-// when key not found or fail to parse value to given type.
-// Except method MustString, which you have to pass a default value.
-
-v = cfg.Section("").Key("String").MustString("default")
-v = cfg.Section("").Key("BOOL").MustBool(true)
-v = cfg.Section("").Key("FLOAT64").MustFloat64(1.25)
-v = cfg.Section("").Key("INT").MustInt(10)
-v = cfg.Section("").Key("INT64").MustInt64(99)
-v = cfg.Section("").Key("UINT").MustUint(3)
-v = cfg.Section("").Key("UINT64").MustUint64(6)
-v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339, time.Now())
-v = cfg.Section("").Key("TIME").MustTime(time.Now()) // RFC3339
-```
-
-What if my value is three-line long?
-
-```ini
-[advance]
-ADDRESS = """404 road,
-NotFound, State, 5000
-Earth"""
-```
-
-Not a problem!
-
-```go
-cfg.Section("advance").Key("ADDRESS").String()
-
-/* --- start ---
-404 road,
-NotFound, State, 5000
-Earth
-------  end  --- */
-```
-
-That's cool, how about continuation lines?
-
-```ini
-[advance]
-two_lines = how about \
-       continuation lines?
-lots_of_lines = 1 \
-       2 \
-       3 \
-       4
-```
-
-Piece of cake!
-
-```go
-cfg.Section("advance").Key("two_lines").String() // how about continuation lines?
-cfg.Section("advance").Key("lots_of_lines").String() // 1 2 3 4
-```
-
-Well, I hate continuation lines, how do I disable that?
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{
-       IgnoreContinuation: true,
-}, "filename")
-```
-
-Holy crap! 
-
-Note that single quotes around values will be stripped:
-
-```ini
-foo = "some value" // foo: some value
-bar = 'some value' // bar: some value
-```
-
-Sometimes you downloaded file from [Crowdin](https://crowdin.com/) has values like the following (value is surrounded by double quotes and quotes in the value are escaped):
-
-```ini
-create_repo="created repository <a href=\"%s\">%s</a>"
-```
-
-How do you transform this to regular format automatically?
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{UnescapeValueDoubleQuotes: true}, "en-US.ini"))
-cfg.Section("<name of your section>").Key("create_repo").String() 
-// You got: created repository <a href="%s">%s</a>
-```
-
-That's all? Hmm, no.
-
-#### Helper methods of working with values
-
-To get value with given candidates:
-
-```go
-v = cfg.Section("").Key("STRING").In("default", []string{"str", "arr", "types"})
-v = cfg.Section("").Key("FLOAT64").InFloat64(1.1, []float64{1.25, 2.5, 3.75})
-v = cfg.Section("").Key("INT").InInt(5, []int{10, 20, 30})
-v = cfg.Section("").Key("INT64").InInt64(10, []int64{10, 20, 30})
-v = cfg.Section("").Key("UINT").InUint(4, []int{3, 6, 9})
-v = cfg.Section("").Key("UINT64").InUint64(8, []int64{3, 6, 9})
-v = cfg.Section("").Key("TIME").InTimeFormat(time.RFC3339, time.Now(), []time.Time{time1, time2, time3})
-v = cfg.Section("").Key("TIME").InTime(time.Now(), []time.Time{time1, time2, time3}) // RFC3339
-```
-
-Default value will be presented if value of key is not in candidates you given, and default value does not need be one of candidates.
-
-To validate value in a given range:
-
-```go
-vals = cfg.Section("").Key("FLOAT64").RangeFloat64(0.0, 1.1, 2.2)
-vals = cfg.Section("").Key("INT").RangeInt(0, 10, 20)
-vals = cfg.Section("").Key("INT64").RangeInt64(0, 10, 20)
-vals = cfg.Section("").Key("UINT").RangeUint(0, 3, 9)
-vals = cfg.Section("").Key("UINT64").RangeUint64(0, 3, 9)
-vals = cfg.Section("").Key("TIME").RangeTimeFormat(time.RFC3339, time.Now(), minTime, maxTime)
-vals = cfg.Section("").Key("TIME").RangeTime(time.Now(), minTime, maxTime) // RFC3339
-```
-
-##### Auto-split values into a slice
-
-To use zero value of type for invalid inputs:
-
-```go
-// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4]
-// Input: how, 2.2, are, you -> [0.0 2.2 0.0 0.0]
-vals = cfg.Section("").Key("STRINGS").Strings(",")
-vals = cfg.Section("").Key("FLOAT64S").Float64s(",")
-vals = cfg.Section("").Key("INTS").Ints(",")
-vals = cfg.Section("").Key("INT64S").Int64s(",")
-vals = cfg.Section("").Key("UINTS").Uints(",")
-vals = cfg.Section("").Key("UINT64S").Uint64s(",")
-vals = cfg.Section("").Key("TIMES").Times(",")
-```
-
-To exclude invalid values out of result slice:
-
-```go
-// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4]
-// Input: how, 2.2, are, you -> [2.2]
-vals = cfg.Section("").Key("FLOAT64S").ValidFloat64s(",")
-vals = cfg.Section("").Key("INTS").ValidInts(",")
-vals = cfg.Section("").Key("INT64S").ValidInt64s(",")
-vals = cfg.Section("").Key("UINTS").ValidUints(",")
-vals = cfg.Section("").Key("UINT64S").ValidUint64s(",")
-vals = cfg.Section("").Key("TIMES").ValidTimes(",")
-```
-
-Or to return nothing but error when have invalid inputs:
-
-```go
-// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4]
-// Input: how, 2.2, are, you -> error
-vals = cfg.Section("").Key("FLOAT64S").StrictFloat64s(",")
-vals = cfg.Section("").Key("INTS").StrictInts(",")
-vals = cfg.Section("").Key("INT64S").StrictInt64s(",")
-vals = cfg.Section("").Key("UINTS").StrictUints(",")
-vals = cfg.Section("").Key("UINT64S").StrictUint64s(",")
-vals = cfg.Section("").Key("TIMES").StrictTimes(",")
-```
-
-### Save your configuration
-
-Finally, it's time to save your configuration to somewhere.
-
-A typical way to save configuration is writing it to a file:
-
-```go
-// ...
-err = cfg.SaveTo("my.ini")
-err = cfg.SaveToIndent("my.ini", "\t")
-```
-
-Another way to save is writing to a `io.Writer` interface:
-
-```go
-// ...
-cfg.WriteTo(writer)
-cfg.WriteToIndent(writer, "\t")
-```
-
-By default, spaces are used to align "=" sign between key and values, to disable that:
-
-```go
-ini.PrettyFormat = false
-``` 
-
-## Advanced Usage
-
-### Recursive Values
-
-For all value of keys, there is a special syntax `%(<name>)s`, where `<name>` is the key name in same section or default section, and `%(<name>)s` will be replaced by corresponding value(empty string if key not found). You can use this syntax at most 99 level of recursions.
-
-```ini
-NAME = ini
-
-[author]
-NAME = Unknwon
-GITHUB = https://github.com/%(NAME)s
-
-[package]
-FULL_NAME = github.com/go-ini/%(NAME)s
-```
-
-```go
-cfg.Section("author").Key("GITHUB").String()           // https://github.com/Unknwon
-cfg.Section("package").Key("FULL_NAME").String()       // github.com/go-ini/ini
-```
-
-### Parent-child Sections
-
-You can use `.` in section name to indicate parent-child relationship between two or more sections. If the key not found in the child section, library will try again on its parent section until there is no parent section.
-
-```ini
-NAME = ini
-VERSION = v1
-IMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s
-
-[package]
-CLONE_URL = https://%(IMPORT_PATH)s
-
-[package.sub]
-```
-
-```go
-cfg.Section("package.sub").Key("CLONE_URL").String()   // https://gopkg.in/ini.v1
-```
-
-#### Retrieve parent keys available to a child section
-
-```go
-cfg.Section("package.sub").ParentKeys() // ["CLONE_URL"]
-```
-
-### Unparseable Sections
-
-Sometimes, you have sections that do not contain key-value pairs but raw content, to handle such case, you can use `LoadOptions.UnparsableSections`:
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{UnparseableSections: []string{"COMMENTS"}}, `[COMMENTS]
-<1><L.Slide#2> This slide has the fuel listed in the wrong units <e.1>`))
-
-body := cfg.Section("COMMENTS").Body()
-
-/* --- start ---
-<1><L.Slide#2> This slide has the fuel listed in the wrong units <e.1>
-------  end  --- */
-```
-
-### Auto-increment Key Names
-
-If key name is `-` in data source, then it would be seen as special syntax for auto-increment key name start from 1, and every section is independent on counter.
-
-```ini
-[features]
--: Support read/write comments of keys and sections
--: Support auto-increment of key names
--: Support load multiple files to overwrite key values
-```
-
-```go
-cfg.Section("features").KeyStrings()   // []{"#1", "#2", "#3"}
-```
+The minimum requirement of Go is **1.6**.
 
-### Map To Struct
-
-Want more objective way to play with INI? Cool.
-
-```ini
-Name = Unknwon
-age = 21
-Male = true
-Born = 1993-01-01T20:17:05Z
-
-[Note]
-Content = Hi is a good man!
-Cities = HangZhou, Boston
-```
-
-```go
-type Note struct {
-       Content string
-       Cities  []string
-}
-
-type Person struct {
-       Name string
-       Age  int `ini:"age"`
-       Male bool
-       Born time.Time
-       Note
-       Created time.Time `ini:"-"`
-}
-
-func main() {
-       cfg, err := ini.Load("path/to/ini")
-       // ...
-       p := new(Person)
-       err = cfg.MapTo(p)
-       // ...
-
-       // Things can be simpler.
-       err = ini.MapTo(p, "path/to/ini")
-       // ...
-
-       // Just map a section? Fine.
-       n := new(Note)
-       err = cfg.Section("Note").MapTo(n)
-       // ...
-}
-```
-
-Can I have default value for field? Absolutely.
-
-Assign it before you map to struct. It will keep the value as it is if the key is not presented or got wrong type.
-
-```go
-// ...
-p := &Person{
-       Name: "Joe",
-}
-// ...
-```
-
-It's really cool, but what's the point if you can't give me my file back from struct?
-
-### Reflect From Struct
-
-Why not?
-
-```go
-type Embeded struct {
-       Dates  []time.Time `delim:"|" comment:"Time data"`
-       Places []string    `ini:"places,omitempty"`
-       None   []int       `ini:",omitempty"`
-}
-
-type Author struct {
-       Name      string `ini:"NAME"`
-       Male      bool
-       Age       int `comment:"Author's age"`
-       GPA       float64
-       NeverMind string `ini:"-"`
-       *Embeded `comment:"Embeded section"`
-}
-
-func main() {
-       a := &Author{"Unknwon", true, 21, 2.8, "",
-               &Embeded{
-                       []time.Time{time.Now(), time.Now()},
-                       []string{"HangZhou", "Boston"},
-                       []int{},
-               }}
-       cfg := ini.Empty()
-       err = ini.ReflectFrom(cfg, a)
-       // ...
-}
-```
-
-So, what do I get?
-
-```ini
-NAME = Unknwon
-Male = true
-; Author's age
-Age = 21
-GPA = 2.8
-
-; Embeded section
-[Embeded]
-; Time data
-Dates = 2015-08-07T22:14:22+08:00|2015-08-07T22:14:22+08:00
-places = HangZhou,Boston
-```
-
-#### Name Mapper
-
-To save your time and make your code cleaner, this library supports [`NameMapper`](https://gowalker.org/gopkg.in/ini.v1#NameMapper) between struct field and actual section and key name.
-
-There are 2 built-in name mappers:
-
-- `AllCapsUnderscore`: it converts to format `ALL_CAPS_UNDERSCORE` then match section or key.
-- `TitleUnderscore`: it converts to format `title_underscore` then match section or key.
-
-To use them:
-
-```go
-type Info struct {
-       PackageName string
-}
-
-func main() {
-       err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("package_name=ini"))
-       // ...
-
-       cfg, err := ini.Load([]byte("PACKAGE_NAME=ini"))
-       // ...
-       info := new(Info)
-       cfg.NameMapper = ini.AllCapsUnderscore
-       err = cfg.MapTo(info)
-       // ...
-}
-```
-
-Same rules of name mapper apply to `ini.ReflectFromWithMapper` function.
-
-#### Value Mapper
-
-To expand values (e.g. from environment variables), you can use the `ValueMapper` to transform values:
-
-```go
-type Env struct {
-       Foo string `ini:"foo"`
-}
-
-func main() {
-       cfg, err := ini.Load([]byte("[env]\nfoo = ${MY_VAR}\n")
-       cfg.ValueMapper = os.ExpandEnv
-       // ...
-       env := &Env{}
-       err = cfg.Section("env").MapTo(env)
-}
-```
-
-This would set the value of `env.Foo` to the value of the environment variable `MY_VAR`.
-
-#### Other Notes On Map/Reflect
-
-Any embedded struct is treated as a section by default, and there is no automatic parent-child relations in map/reflect feature:
-
-```go
-type Child struct {
-       Age string
-}
-
-type Parent struct {
-       Name string
-       Child
-}
-
-type Config struct {
-       City string
-       Parent
-}
-```
-
-Example configuration:
-
-```ini
-City = Boston
-
-[Parent]
-Name = Unknwon
+To use a tagged revision:
 
-[Child]
-Age = 21
+```sh
+$ go get gopkg.in/ini.v1
 ```
 
-What if, yes, I'm paranoid, I want embedded struct to be in the same section. Well, all roads lead to Rome.
-
-```go
-type Child struct {
-       Age string
-}
-
-type Parent struct {
-       Name string
-       Child `ini:"Parent"`
-}
+To use with latest changes:
 
-type Config struct {
-       City string
-       Parent
-}
+```sh
+$ go get github.com/go-ini/ini
 ```
 
-Example configuration:
-
-```ini
-City = Boston
-
-[Parent]
-Name = Unknwon
-Age = 21
-```
+Please add `-u` flag to update in the future.
 
 ## Getting Help
 
+- [Getting Started](https://ini.unknwon.io/docs/intro/getting_started)
 - [API Documentation](https://gowalker.org/gopkg.in/ini.v1)
-- [File An Issue](https://github.com/go-ini/ini/issues/new)
-
-## FAQs
-
-### What does `BlockMode` field do?
-
-By default, library lets you read and write values so we need a locker to make sure your data is safe. But in cases that you are very sure about only reading data through the library, you can set `cfg.BlockMode = false` to speed up read operations about **50-70%** faster.
-
-### Why another INI library?
-
-Many people are using my another INI library [goconfig](https://github.com/Unknwon/goconfig), so the reason for this one is I would like to make more Go style code. Also when you set `cfg.BlockMode = false`, this one is about **10-30%** faster.
-
-To make those changes I have to confirm API broken, so it's safer to keep it in another place and start using `gopkg.in` to version my package at this time.(PS: shorter import path)
 
 ## License
 
diff --git a/vendor/gopkg.in/ini.v1/README_ZH.md b/vendor/gopkg.in/ini.v1/README_ZH.md
deleted file mode 100644 (file)
index 69aefef..0000000
+++ /dev/null
@@ -1,750 +0,0 @@
-本包提供了 Go 语言中读写 INI 文件的功能。
-
-## 功能特性
-
-- 支持覆盖加载多个数据源(`[]byte`、文件和 `io.ReadCloser`)
-- 支持递归读取键值
-- 支持读取父子分区
-- 支持读取自增键名
-- 支持读取多行的键值
-- 支持大量辅助方法
-- 支持在读取时直接转换为 Go 语言类型
-- 支持读取和 **写入** 分区和键的注释
-- 轻松操作分区、键值和注释
-- 在保存文件时分区和键值会保持原有的顺序
-
-## 下载安装
-
-使用一个特定版本:
-
-    go get gopkg.in/ini.v1
-
-使用最新版:
-
-       go get github.com/go-ini/ini
-
-如需更新请添加 `-u` 选项。
-
-### 测试安装
-
-如果您想要在自己的机器上运行测试,请使用 `-t` 标记:
-
-       go get -t gopkg.in/ini.v1
-
-如需更新请添加 `-u` 选项。
-
-## 开始使用
-
-### 从数据源加载
-
-一个 **数据源** 可以是 `[]byte` 类型的原始数据,`string` 类型的文件路径或 `io.ReadCloser`。您可以加载 **任意多个** 数据源。如果您传递其它类型的数据源,则会直接返回错误。
-
-```go
-cfg, err := ini.Load([]byte("raw data"), "filename", ioutil.NopCloser(bytes.NewReader([]byte("some other data"))))
-```
-
-或者从一个空白的文件开始:
-
-```go
-cfg := ini.Empty()
-```
-
-当您在一开始无法决定需要加载哪些数据源时,仍可以使用 **Append()** 在需要的时候加载它们。
-
-```go
-err := cfg.Append("other file", []byte("other raw data"))
-```
-
-当您想要加载一系列文件,但是不能够确定其中哪些文件是不存在的,可以通过调用函数 `LooseLoad` 来忽略它们(`Load` 会因为文件不存在而返回错误):
-
-```go
-cfg, err := ini.LooseLoad("filename", "filename_404")
-```
-
-更牛逼的是,当那些之前不存在的文件在重新调用 `Reload` 方法的时候突然出现了,那么它们会被正常加载。
-
-#### 忽略键名的大小写
-
-有时候分区和键的名称大小写混合非常烦人,这个时候就可以通过 `InsensitiveLoad` 将所有分区和键名在读取里强制转换为小写:
-
-```go
-cfg, err := ini.InsensitiveLoad("filename")
-//...
-
-// sec1 和 sec2 指向同一个分区对象
-sec1, err := cfg.GetSection("Section")
-sec2, err := cfg.GetSection("SecTIOn")
-
-// key1 和 key2 指向同一个键对象
-key1, err := sec1.GetKey("Key")
-key2, err := sec2.GetKey("KeY")
-```
-
-#### 类似 MySQL 配置中的布尔值键
-
-MySQL 的配置文件中会出现没有具体值的布尔类型的键:
-
-```ini
-[mysqld]
-...
-skip-host-cache
-skip-name-resolve
-```
-
-默认情况下这被认为是缺失值而无法完成解析,但可以通过高级的加载选项对它们进行处理:
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{AllowBooleanKeys: true}, "my.cnf"))
-```
-
-这些键的值永远为 `true`,且在保存到文件时也只会输出键名。
-
-如果您想要通过程序来生成此类键,则可以使用 `NewBooleanKey`:
-
-```go
-key, err := sec.NewBooleanKey("skip-host-cache")
-```
-
-#### 关于注释
-
-下述几种情况的内容将被视为注释:
-
-1. 所有以 `#` 或 `;` 开头的行
-2. 所有在 `#` 或 `;` 之后的内容
-3. 分区标签后的文字 (即 `[分区名]` 之后的内容)
-
-如果你希望使用包含 `#` 或 `;` 的值,请使用 ``` ` ``` 或 ``` """ ``` 进行包覆。
-
-除此之外,您还可以通过 `LoadOptions` 完全忽略行内注释:
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{IgnoreInlineComment: true}, "app.ini"))
-```
-
-### 操作分区(Section)
-
-获取指定分区:
-
-```go
-section, err := cfg.GetSection("section name")
-```
-
-如果您想要获取默认分区,则可以用空字符串代替分区名:
-
-```go
-section, err := cfg.GetSection("")
-```
-
-当您非常确定某个分区是存在的,可以使用以下简便方法:
-
-```go
-section := cfg.Section("section name")
-```
-
-如果不小心判断错了,要获取的分区其实是不存在的,那会发生什么呢?没事的,它会自动创建并返回一个对应的分区对象给您。
-
-创建一个分区:
-
-```go
-err := cfg.NewSection("new section")
-```
-
-获取所有分区对象或名称:
-
-```go
-sections := cfg.Sections()
-names := cfg.SectionStrings()
-```
-
-### 操作键(Key)
-
-获取某个分区下的键:
-
-```go
-key, err := cfg.Section("").GetKey("key name")
-```
-
-和分区一样,您也可以直接获取键而忽略错误处理:
-
-```go
-key := cfg.Section("").Key("key name")
-```
-
-判断某个键是否存在:
-
-```go
-yes := cfg.Section("").HasKey("key name")
-```
-
-创建一个新的键:
-
-```go
-err := cfg.Section("").NewKey("name", "value")
-```
-
-获取分区下的所有键或键名:
-
-```go
-keys := cfg.Section("").Keys()
-names := cfg.Section("").KeyStrings()
-```
-
-获取分区下的所有键值对的克隆:
-
-```go
-hash := cfg.Section("").KeysHash()
-```
-
-### 操作键值(Value)
-
-获取一个类型为字符串(string)的值:
-
-```go
-val := cfg.Section("").Key("key name").String()
-```
-
-获取值的同时通过自定义函数进行处理验证:
-
-```go
-val := cfg.Section("").Key("key name").Validate(func(in string) string {
-       if len(in) == 0 {
-               return "default"
-       }
-       return in
-})
-```
-
-如果您不需要任何对值的自动转变功能(例如递归读取),可以直接获取原值(这种方式性能最佳):
-
-```go
-val := cfg.Section("").Key("key name").Value()
-```
-
-判断某个原值是否存在:
-
-```go
-yes := cfg.Section("").HasValue("test value")
-```
-
-获取其它类型的值:
-
-```go
-// 布尔值的规则:
-// true 当值为:1, t, T, TRUE, true, True, YES, yes, Yes, y, ON, on, On
-// false 当值为:0, f, F, FALSE, false, False, NO, no, No, n, OFF, off, Off
-v, err = cfg.Section("").Key("BOOL").Bool()
-v, err = cfg.Section("").Key("FLOAT64").Float64()
-v, err = cfg.Section("").Key("INT").Int()
-v, err = cfg.Section("").Key("INT64").Int64()
-v, err = cfg.Section("").Key("UINT").Uint()
-v, err = cfg.Section("").Key("UINT64").Uint64()
-v, err = cfg.Section("").Key("TIME").TimeFormat(time.RFC3339)
-v, err = cfg.Section("").Key("TIME").Time() // RFC3339
-
-v = cfg.Section("").Key("BOOL").MustBool()
-v = cfg.Section("").Key("FLOAT64").MustFloat64()
-v = cfg.Section("").Key("INT").MustInt()
-v = cfg.Section("").Key("INT64").MustInt64()
-v = cfg.Section("").Key("UINT").MustUint()
-v = cfg.Section("").Key("UINT64").MustUint64()
-v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339)
-v = cfg.Section("").Key("TIME").MustTime() // RFC3339
-
-// 由 Must 开头的方法名允许接收一个相同类型的参数来作为默认值,
-// 当键不存在或者转换失败时,则会直接返回该默认值。
-// 但是,MustString 方法必须传递一个默认值。
-
-v = cfg.Seciont("").Key("String").MustString("default")
-v = cfg.Section("").Key("BOOL").MustBool(true)
-v = cfg.Section("").Key("FLOAT64").MustFloat64(1.25)
-v = cfg.Section("").Key("INT").MustInt(10)
-v = cfg.Section("").Key("INT64").MustInt64(99)
-v = cfg.Section("").Key("UINT").MustUint(3)
-v = cfg.Section("").Key("UINT64").MustUint64(6)
-v = cfg.Section("").Key("TIME").MustTimeFormat(time.RFC3339, time.Now())
-v = cfg.Section("").Key("TIME").MustTime(time.Now()) // RFC3339
-```
-
-如果我的值有好多行怎么办?
-
-```ini
-[advance]
-ADDRESS = """404 road,
-NotFound, State, 5000
-Earth"""
-```
-
-嗯哼?小 case!
-
-```go
-cfg.Section("advance").Key("ADDRESS").String()
-
-/* --- start ---
-404 road,
-NotFound, State, 5000
-Earth
-------  end  --- */
-```
-
-赞爆了!那要是我属于一行的内容写不下想要写到第二行怎么办?
-
-```ini
-[advance]
-two_lines = how about \
-       continuation lines?
-lots_of_lines = 1 \
-       2 \
-       3 \
-       4
-```
-
-简直是小菜一碟!
-
-```go
-cfg.Section("advance").Key("two_lines").String() // how about continuation lines?
-cfg.Section("advance").Key("lots_of_lines").String() // 1 2 3 4
-```
-
-可是我有时候觉得两行连在一起特别没劲,怎么才能不自动连接两行呢?
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{
-       IgnoreContinuation: true,
-}, "filename")
-```
-
-哇靠给力啊!
-
-需要注意的是,值两侧的单引号会被自动剔除:
-
-```ini
-foo = "some value" // foo: some value
-bar = 'some value' // bar: some value
-```
-
-有时您会获得像从 [Crowdin](https://crowdin.com/) 网站下载的文件那样具有特殊格式的值(值使用双引号括起来,内部的双引号被转义):
-
-```ini
-create_repo="创建了仓库 <a href=\"%s\">%s</a>"
-```
-
-那么,怎么自动地将这类值进行处理呢?
-
-```go
-cfg, err := ini.LoadSources(ini.LoadOptions{UnescapeValueDoubleQuotes: true}, "en-US.ini"))
-cfg.Section("<name of your section>").Key("create_repo").String() 
-// You got: 创建了仓库 <a href="%s">%s</a>
-```
-
-这就是全部了?哈哈,当然不是。
-
-#### 操作键值的辅助方法
-
-获取键值时设定候选值:
-
-```go
-v = cfg.Section("").Key("STRING").In("default", []string{"str", "arr", "types"})
-v = cfg.Section("").Key("FLOAT64").InFloat64(1.1, []float64{1.25, 2.5, 3.75})
-v = cfg.Section("").Key("INT").InInt(5, []int{10, 20, 30})
-v = cfg.Section("").Key("INT64").InInt64(10, []int64{10, 20, 30})
-v = cfg.Section("").Key("UINT").InUint(4, []int{3, 6, 9})
-v = cfg.Section("").Key("UINT64").InUint64(8, []int64{3, 6, 9})
-v = cfg.Section("").Key("TIME").InTimeFormat(time.RFC3339, time.Now(), []time.Time{time1, time2, time3})
-v = cfg.Section("").Key("TIME").InTime(time.Now(), []time.Time{time1, time2, time3}) // RFC3339
-```
-
-如果获取到的值不是候选值的任意一个,则会返回默认值,而默认值不需要是候选值中的一员。
-
-验证获取的值是否在指定范围内:
-
-```go
-vals = cfg.Section("").Key("FLOAT64").RangeFloat64(0.0, 1.1, 2.2)
-vals = cfg.Section("").Key("INT").RangeInt(0, 10, 20)
-vals = cfg.Section("").Key("INT64").RangeInt64(0, 10, 20)
-vals = cfg.Section("").Key("UINT").RangeUint(0, 3, 9)
-vals = cfg.Section("").Key("UINT64").RangeUint64(0, 3, 9)
-vals = cfg.Section("").Key("TIME").RangeTimeFormat(time.RFC3339, time.Now(), minTime, maxTime)
-vals = cfg.Section("").Key("TIME").RangeTime(time.Now(), minTime, maxTime) // RFC3339
-```
-
-##### 自动分割键值到切片(slice)
-
-当存在无效输入时,使用零值代替:
-
-```go
-// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4]
-// Input: how, 2.2, are, you -> [0.0 2.2 0.0 0.0]
-vals = cfg.Section("").Key("STRINGS").Strings(",")
-vals = cfg.Section("").Key("FLOAT64S").Float64s(",")
-vals = cfg.Section("").Key("INTS").Ints(",")
-vals = cfg.Section("").Key("INT64S").Int64s(",")
-vals = cfg.Section("").Key("UINTS").Uints(",")
-vals = cfg.Section("").Key("UINT64S").Uint64s(",")
-vals = cfg.Section("").Key("TIMES").Times(",")
-```
-
-从结果切片中剔除无效输入:
-
-```go
-// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4]
-// Input: how, 2.2, are, you -> [2.2]
-vals = cfg.Section("").Key("FLOAT64S").ValidFloat64s(",")
-vals = cfg.Section("").Key("INTS").ValidInts(",")
-vals = cfg.Section("").Key("INT64S").ValidInt64s(",")
-vals = cfg.Section("").Key("UINTS").ValidUints(",")
-vals = cfg.Section("").Key("UINT64S").ValidUint64s(",")
-vals = cfg.Section("").Key("TIMES").ValidTimes(",")
-```
-
-当存在无效输入时,直接返回错误:
-
-```go
-// Input: 1.1, 2.2, 3.3, 4.4 -> [1.1 2.2 3.3 4.4]
-// Input: how, 2.2, are, you -> error
-vals = cfg.Section("").Key("FLOAT64S").StrictFloat64s(",")
-vals = cfg.Section("").Key("INTS").StrictInts(",")
-vals = cfg.Section("").Key("INT64S").StrictInt64s(",")
-vals = cfg.Section("").Key("UINTS").StrictUints(",")
-vals = cfg.Section("").Key("UINT64S").StrictUint64s(",")
-vals = cfg.Section("").Key("TIMES").StrictTimes(",")
-```
-
-### 保存配置
-
-终于到了这个时刻,是时候保存一下配置了。
-
-比较原始的做法是输出配置到某个文件:
-
-```go
-// ...
-err = cfg.SaveTo("my.ini")
-err = cfg.SaveToIndent("my.ini", "\t")
-```
-
-另一个比较高级的做法是写入到任何实现 `io.Writer` 接口的对象中:
-
-```go
-// ...
-cfg.WriteTo(writer)
-cfg.WriteToIndent(writer, "\t")
-```
-
-默认情况下,空格将被用于对齐键值之间的等号以美化输出结果,以下代码可以禁用该功能:
-
-```go
-ini.PrettyFormat = false
-``` 
-
-## 高级用法
-
-### 递归读取键值
-
-在获取所有键值的过程中,特殊语法 `%(<name>)s` 会被应用,其中 `<name>` 可以是相同分区或者默认分区下的键名。字符串 `%(<name>)s` 会被相应的键值所替代,如果指定的键不存在,则会用空字符串替代。您可以最多使用 99 层的递归嵌套。
-
-```ini
-NAME = ini
-
-[author]
-NAME = Unknwon
-GITHUB = https://github.com/%(NAME)s
-
-[package]
-FULL_NAME = github.com/go-ini/%(NAME)s
-```
-
-```go
-cfg.Section("author").Key("GITHUB").String()           // https://github.com/Unknwon
-cfg.Section("package").Key("FULL_NAME").String()       // github.com/go-ini/ini
-```
-
-### 读取父子分区
-
-您可以在分区名称中使用 `.` 来表示两个或多个分区之间的父子关系。如果某个键在子分区中不存在,则会去它的父分区中再次寻找,直到没有父分区为止。
-
-```ini
-NAME = ini
-VERSION = v1
-IMPORT_PATH = gopkg.in/%(NAME)s.%(VERSION)s
-
-[package]
-CLONE_URL = https://%(IMPORT_PATH)s
-
-[package.sub]
-```
-
-```go
-cfg.Section("package.sub").Key("CLONE_URL").String()   // https://gopkg.in/ini.v1
-```
-
-#### 获取上级父分区下的所有键名
-
-```go
-cfg.Section("package.sub").ParentKeys() // ["CLONE_URL"]
-```
-
-### 无法解析的分区
-
-如果遇到一些比较特殊的分区,它们不包含常见的键值对,而是没有固定格式的纯文本,则可以使用 `LoadOptions.UnparsableSections` 进行处理:
-
-```go
-cfg, err := LoadSources(ini.LoadOptions{UnparseableSections: []string{"COMMENTS"}}, `[COMMENTS]
-<1><L.Slide#2> This slide has the fuel listed in the wrong units <e.1>`))
-
-body := cfg.Section("COMMENTS").Body()
-
-/* --- start ---
-<1><L.Slide#2> This slide has the fuel listed in the wrong units <e.1>
-------  end  --- */
-```
-
-### 读取自增键名
-
-如果数据源中的键名为 `-`,则认为该键使用了自增键名的特殊语法。计数器从 1 开始,并且分区之间是相互独立的。
-
-```ini
-[features]
--: Support read/write comments of keys and sections
--: Support auto-increment of key names
--: Support load multiple files to overwrite key values
-```
-
-```go
-cfg.Section("features").KeyStrings()   // []{"#1", "#2", "#3"}
-```
-
-### 映射到结构
-
-想要使用更加面向对象的方式玩转 INI 吗?好主意。
-
-```ini
-Name = Unknwon
-age = 21
-Male = true
-Born = 1993-01-01T20:17:05Z
-
-[Note]
-Content = Hi is a good man!
-Cities = HangZhou, Boston
-```
-
-```go
-type Note struct {
-       Content string
-       Cities  []string
-}
-
-type Person struct {
-       Name string
-       Age  int `ini:"age"`
-       Male bool
-       Born time.Time
-       Note
-       Created time.Time `ini:"-"`
-}
-
-func main() {
-       cfg, err := ini.Load("path/to/ini")
-       // ...
-       p := new(Person)
-       err = cfg.MapTo(p)
-       // ...
-
-       // 一切竟可以如此的简单。
-       err = ini.MapTo(p, "path/to/ini")
-       // ...
-
-       // 嗯哼?只需要映射一个分区吗?
-       n := new(Note)
-       err = cfg.Section("Note").MapTo(n)
-       // ...
-}
-```
-
-结构的字段怎么设置默认值呢?很简单,只要在映射之前对指定字段进行赋值就可以了。如果键未找到或者类型错误,该值不会发生改变。
-
-```go
-// ...
-p := &Person{
-       Name: "Joe",
-}
-// ...
-```
-
-这样玩 INI 真的好酷啊!然而,如果不能还给我原来的配置文件,有什么卵用?
-
-### 从结构反射
-
-可是,我有说不能吗?
-
-```go
-type Embeded struct {
-       Dates  []time.Time `delim:"|" comment:"Time data"`
-       Places []string    `ini:"places,omitempty"`
-       None   []int       `ini:",omitempty"`
-}
-
-type Author struct {
-       Name      string `ini:"NAME"`
-       Male      bool
-       Age       int `comment:"Author's age"`
-       GPA       float64
-       NeverMind string `ini:"-"`
-       *Embeded `comment:"Embeded section"`
-}
-
-func main() {
-       a := &Author{"Unknwon", true, 21, 2.8, "",
-               &Embeded{
-                       []time.Time{time.Now(), time.Now()},
-                       []string{"HangZhou", "Boston"},
-                       []int{},
-               }}
-       cfg := ini.Empty()
-       err = ini.ReflectFrom(cfg, a)
-       // ...
-}
-```
-
-瞧瞧,奇迹发生了。
-
-```ini
-NAME = Unknwon
-Male = true
-; Author's age
-Age = 21
-GPA = 2.8
-
-; Embeded section
-[Embeded]
-; Time data
-Dates = 2015-08-07T22:14:22+08:00|2015-08-07T22:14:22+08:00
-places = HangZhou,Boston
-```
-
-#### 名称映射器(Name Mapper)
-
-为了节省您的时间并简化代码,本库支持类型为 [`NameMapper`](https://gowalker.org/gopkg.in/ini.v1#NameMapper) 的名称映射器,该映射器负责结构字段名与分区名和键名之间的映射。
-
-目前有 2 款内置的映射器:
-
-- `AllCapsUnderscore`:该映射器将字段名转换至格式 `ALL_CAPS_UNDERSCORE` 后再去匹配分区名和键名。
-- `TitleUnderscore`:该映射器将字段名转换至格式 `title_underscore` 后再去匹配分区名和键名。
-
-使用方法:
-
-```go
-type Info struct{
-       PackageName string
-}
-
-func main() {
-       err = ini.MapToWithMapper(&Info{}, ini.TitleUnderscore, []byte("package_name=ini"))
-       // ...
-
-       cfg, err := ini.Load([]byte("PACKAGE_NAME=ini"))
-       // ...
-       info := new(Info)
-       cfg.NameMapper = ini.AllCapsUnderscore
-       err = cfg.MapTo(info)
-       // ...
-}
-```
-
-使用函数 `ini.ReflectFromWithMapper` 时也可应用相同的规则。
-
-#### 值映射器(Value Mapper)
-
-值映射器允许使用一个自定义函数自动展开值的具体内容,例如:运行时获取环境变量:
-
-```go
-type Env struct {
-       Foo string `ini:"foo"`
-}
-
-func main() {
-       cfg, err := ini.Load([]byte("[env]\nfoo = ${MY_VAR}\n")
-       cfg.ValueMapper = os.ExpandEnv
-       // ...
-       env := &Env{}
-       err = cfg.Section("env").MapTo(env)
-}
-```
-
-本例中,`env.Foo` 将会是运行时所获取到环境变量 `MY_VAR` 的值。
-
-#### 映射/反射的其它说明
-
-任何嵌入的结构都会被默认认作一个不同的分区,并且不会自动产生所谓的父子分区关联:
-
-```go
-type Child struct {
-       Age string
-}
-
-type Parent struct {
-       Name string
-       Child
-}
-
-type Config struct {
-       City string
-       Parent
-}
-```
-
-示例配置文件:
-
-```ini
-City = Boston
-
-[Parent]
-Name = Unknwon
-
-[Child]
-Age = 21
-```
-
-很好,但是,我就是要嵌入结构也在同一个分区。好吧,你爹是李刚!
-
-```go
-type Child struct {
-       Age string
-}
-
-type Parent struct {
-       Name string
-       Child `ini:"Parent"`
-}
-
-type Config struct {
-       City string
-       Parent
-}
-```
-
-示例配置文件:
-
-```ini
-City = Boston
-
-[Parent]
-Name = Unknwon
-Age = 21
-```
-
-## 获取帮助
-
-- [API 文档](https://gowalker.org/gopkg.in/ini.v1)
-- [创建工单](https://github.com/go-ini/ini/issues/new)
-
-## 常见问题
-
-### 字段 `BlockMode` 是什么?
-
-默认情况下,本库会在您进行读写操作时采用锁机制来确保数据时间。但在某些情况下,您非常确定只进行读操作。此时,您可以通过设置 `cfg.BlockMode = false` 来将读操作提升大约 **50-70%** 的性能。
-
-### 为什么要写另一个 INI 解析库?
-
-许多人都在使用我的 [goconfig](https://github.com/Unknwon/goconfig) 来完成对 INI 文件的操作,但我希望使用更加 Go 风格的代码。并且当您设置 `cfg.BlockMode = false` 时,会有大约 **10-30%** 的性能提升。
-
-为了做出这些改变,我必须对 API 进行破坏,所以新开一个仓库是最安全的做法。除此之外,本库直接使用 `gopkg.in` 来进行版本化发布。(其实真相是导入路径更短了)
index 93ac50836cc4eece5fa0213f303f7f851846a5d4..0ed0eafd029836ea5a04ed181382e55c54e1d04a 100644 (file)
@@ -45,6 +45,9 @@ type File struct {
 
 // newFile initializes File object with given data sources.
 func newFile(dataSources []dataSource, opts LoadOptions) *File {
+       if len(opts.KeyValueDelimiters) == 0 {
+               opts.KeyValueDelimiters = "=:"
+       }
        return &File{
                BlockMode:   true,
                dataSources: dataSources,
@@ -140,9 +143,14 @@ func (f *File) Section(name string) *Section {
 
 // Section returns list of Section.
 func (f *File) Sections() []*Section {
+       if f.BlockMode {
+               f.lock.RLock()
+               defer f.lock.RUnlock()
+       }
+
        sections := make([]*Section, len(f.sectionList))
-       for i := range f.sectionList {
-               sections[i] = f.Section(f.sectionList[i])
+       for i, name := range f.sectionList {
+               sections[i] = f.sections[name]
        }
        return sections
 }
@@ -222,8 +230,9 @@ func (f *File) Append(source interface{}, others ...interface{}) error {
 }
 
 func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
-       equalSign := "="
-       if PrettyFormat {
+       equalSign := DefaultFormatLeft + "=" + DefaultFormatRight
+
+       if PrettyFormat || PrettyEqual {
                equalSign = " = "
        }
 
@@ -232,13 +241,18 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
        for i, sname := range f.sectionList {
                sec := f.Section(sname)
                if len(sec.Comment) > 0 {
-                       if sec.Comment[0] != '#' && sec.Comment[0] != ';' {
-                               sec.Comment = "; " + sec.Comment
-                       } else {
-                               sec.Comment = sec.Comment[:1] + " " + strings.TrimSpace(sec.Comment[1:])
-                       }
-                       if _, err := buf.WriteString(sec.Comment + LineBreak); err != nil {
-                               return nil, err
+                       // Support multiline comments
+                       lines := strings.Split(sec.Comment, LineBreak)
+                       for i := range lines {
+                               if lines[i][0] != '#' && lines[i][0] != ';' {
+                                       lines[i] = "; " + lines[i]
+                               } else {
+                                       lines[i] = lines[i][:1] + " " + strings.TrimSpace(lines[i][1:])
+                               }
+
+                               if _, err := buf.WriteString(lines[i] + LineBreak); err != nil {
+                                       return nil, err
+                               }
                        }
                }
 
@@ -275,7 +289,7 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
                        for _, kname := range sec.keyList {
                                keyLength := len(kname)
                                // First case will surround key by ` and second by """
-                               if strings.ContainsAny(kname, "\"=:") {
+                               if strings.Contains(kname, "\"") || strings.ContainsAny(kname, f.options.KeyValueDelimiters) {
                                        keyLength += 2
                                } else if strings.Contains(kname, "`") {
                                        keyLength += 6
@@ -295,13 +309,19 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
                                if len(indent) > 0 && sname != DEFAULT_SECTION {
                                        buf.WriteString(indent)
                                }
-                               if key.Comment[0] != '#' && key.Comment[0] != ';' {
-                                       key.Comment = "; " + key.Comment
-                               } else {
-                                       key.Comment = key.Comment[:1] + " " + strings.TrimSpace(key.Comment[1:])
-                               }
-                               if _, err := buf.WriteString(key.Comment + LineBreak); err != nil {
-                                       return nil, err
+
+                               // Support multiline comments
+                               lines := strings.Split(key.Comment, LineBreak)
+                               for i := range lines {
+                                       if lines[i][0] != '#' && lines[i][0] != ';' {
+                                               lines[i] = "; " + strings.TrimSpace(lines[i])
+                                       } else {
+                                               lines[i] = lines[i][:1] + " " + strings.TrimSpace(lines[i][1:])
+                                       }
+
+                                       if _, err := buf.WriteString(lines[i] + LineBreak); err != nil {
+                                               return nil, err
+                                       }
                                }
                        }
 
@@ -312,7 +332,7 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
                        switch {
                        case key.isAutoIncrement:
                                kname = "-"
-                       case strings.ContainsAny(kname, "\"=:"):
+                       case strings.Contains(kname, "\"") || strings.ContainsAny(kname, f.options.KeyValueDelimiters):
                                kname = "`" + kname + "`"
                        case strings.Contains(kname, "`"):
                                kname = `"""` + kname + `"""`
@@ -345,6 +365,12 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
                                        return nil, err
                                }
                        }
+
+                       for _, val := range key.nestedValues {
+                               if _, err := buf.WriteString(indent + "  " + val + LineBreak); err != nil {
+                                       return nil, err
+                               }
+                       }
                }
 
                if PrettySection {
index cd7c8a135563f0401073438f82c756574d18d2cd..f827a1ef99f1b9fb62af28e4c11dc087d178252d 100644 (file)
@@ -1,3 +1,5 @@
+// +build go1.6
+
 // Copyright 2014 Unknwon
 //
 // Licensed under the Apache License, Version 2.0 (the "License"): you may
@@ -32,7 +34,7 @@ const (
 
        // Maximum allowed depth when recursively substituing variable names.
        _DEPTH_VALUES = 99
-       _VERSION      = "1.31.1"
+       _VERSION      = "1.42.0"
 )
 
 // Version returns current package version literal.
@@ -46,6 +48,10 @@ var (
        // at package init time.
        LineBreak = "\n"
 
+       // Place custom spaces when PrettyFormat and PrettyEqual are both disabled
+       DefaultFormatLeft  = ""
+       DefaultFormatRight = ""
+
        // Variable regexp pattern: %(variable)s
        varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`)
 
@@ -53,6 +59,9 @@ var (
        // or reduce all possible spaces for compact format.
        PrettyFormat = true
 
+       // Place spaces around "=" sign even when PrettyFormat is false
+       PrettyEqual = false
+
        // Explicitly write DEFAULT section header
        DefaultHeader = false
 
@@ -129,11 +138,26 @@ type LoadOptions struct {
        IgnoreContinuation bool
        // IgnoreInlineComment indicates whether to ignore comments at the end of value and treat it as part of value.
        IgnoreInlineComment bool
+       // SkipUnrecognizableLines indicates whether to skip unrecognizable lines that do not conform to key/value pairs.
+       SkipUnrecognizableLines bool
        // AllowBooleanKeys indicates whether to allow boolean type keys or treat as value is missing.
        // This type of keys are mostly used in my.cnf.
        AllowBooleanKeys bool
        // AllowShadows indicates whether to keep track of keys with same name under same section.
        AllowShadows bool
+       // AllowNestedValues indicates whether to allow AWS-like nested values.
+       // Docs: http://docs.aws.amazon.com/cli/latest/topic/config-vars.html#nested-values
+       AllowNestedValues bool
+       // AllowPythonMultilineValues indicates whether to allow Python-like multi-line values.
+       // Docs: https://docs.python.org/3/library/configparser.html#supported-ini-file-structure
+       // Relevant quote:  Values can also span multiple lines, as long as they are indented deeper
+       // than the first line of the value.
+       AllowPythonMultilineValues bool
+       // SpaceBeforeInlineComment indicates whether to allow comment symbols (\# and \;) inside value.
+       // Docs: https://docs.python.org/2/library/configparser.html
+       // Quote: Comments may appear on their own in an otherwise empty line, or may be entered in lines holding values or section names.
+       // In the latter case, they need to be preceded by a whitespace character to be recognized as a comment.
+       SpaceBeforeInlineComment bool
        // UnescapeValueDoubleQuotes indicates whether to unescape double quotes inside value to regular format
        // when value is surrounded by double quotes, e.g. key="a \"value\"" => key=a "value"
        UnescapeValueDoubleQuotes bool
@@ -141,9 +165,13 @@ type LoadOptions struct {
        // when value is NOT surrounded by any quotes.
        // Note: UNSTABLE, behavior might change to only unescape inside double quotes but may noy necessary at all.
        UnescapeValueCommentSymbols bool
-       // Some INI formats allow group blocks that store a block of raw content that doesn't otherwise
+       // UnparseableSections stores a list of blocks that are allowed with raw content which do not otherwise
        // conform to key/value pairs. Specify the names of those blocks here.
        UnparseableSections []string
+       // KeyValueDelimiters is the sequence of delimiters that are used to separate key and value. By default, it is "=:".
+       KeyValueDelimiters string
+       // PreserveSurroundedQuote indicates whether to preserve surrounded quote (single and double quotes).
+       PreserveSurroundedQuote bool
 }
 
 func LoadSources(opts LoadOptions, source interface{}, others ...interface{}) (_ *File, err error) {
@@ -184,7 +212,7 @@ func InsensitiveLoad(source interface{}, others ...interface{}) (*File, error) {
        return LoadSources(LoadOptions{Insensitive: true}, source, others...)
 }
 
-// InsensitiveLoad has exactly same functionality as Load function
+// ShadowLoad has exactly same functionality as Load function
 // except it allows have shadow keys.
 func ShadowLoad(source interface{}, others ...interface{}) (*File, error) {
        return LoadSources(LoadOptions{AllowShadows: true}, source, others...)
index d3eac4776c115dcf5eab222cb3aac35885dc341b..0fee0dc7e407de2a8b284d976fb76a1767a50dc8 100644 (file)
@@ -34,6 +34,8 @@ type Key struct {
 
        isShadow bool
        shadows  []*Key
+
+       nestedValues []string
 }
 
 // newKey simply return a key object with given values.
@@ -66,6 +68,22 @@ func (k *Key) AddShadow(val string) error {
        return k.addShadow(val)
 }
 
+func (k *Key) addNestedValue(val string) error {
+       if k.isAutoIncrement || k.isBooleanType {
+               return errors.New("cannot add nested value to auto-increment or boolean key")
+       }
+
+       k.nestedValues = append(k.nestedValues, val)
+       return nil
+}
+
+func (k *Key) AddNestedValue(val string) error {
+       if !k.s.f.options.AllowNestedValues {
+               return errors.New("nested value is not allowed")
+       }
+       return k.addNestedValue(val)
+}
+
 // ValueMapper represents a mapping function for values, e.g. os.ExpandEnv
 type ValueMapper func(string) string
 
@@ -92,6 +110,12 @@ func (k *Key) ValueWithShadows() []string {
        return vals
 }
 
+// NestedValues returns nested values stored in the key.
+// It is possible returned value is nil if no nested values stored in the key.
+func (k *Key) NestedValues() []string {
+       return k.nestedValues
+}
+
 // transformValue takes a raw value and transforms to its final string.
 func (k *Key) transformValue(val string) string {
        if k.s.f.ValueMapper != nil {
@@ -109,8 +133,7 @@ func (k *Key) transformValue(val string) string {
                }
 
                // Take off leading '%(' and trailing ')s'.
-               noption := strings.TrimLeft(vr, "%(")
-               noption = strings.TrimRight(noption, ")s")
+               noption := vr[2 : len(vr)-2]
 
                // Search in the same section.
                nk, err := k.s.GetKey(noption)
@@ -163,23 +186,24 @@ func (k *Key) Float64() (float64, error) {
 
 // Int returns int type value.
 func (k *Key) Int() (int, error) {
-       return strconv.Atoi(k.String())
+    v, err := strconv.ParseInt(k.String(), 0, 64)
+    return int(v), err
 }
 
 // Int64 returns int64 type value.
 func (k *Key) Int64() (int64, error) {
-       return strconv.ParseInt(k.String(), 10, 64)
+       return strconv.ParseInt(k.String(), 0, 64)
 }
 
 // Uint returns uint type valued.
 func (k *Key) Uint() (uint, error) {
-       u, e := strconv.ParseUint(k.String(), 10, 64)
+       u, e := strconv.ParseUint(k.String(), 0, 64)
        return uint(u), e
 }
 
 // Uint64 returns uint64 type value.
 func (k *Key) Uint64() (uint64, error) {
-       return strconv.ParseUint(k.String(), 10, 64)
+       return strconv.ParseUint(k.String(), 0, 64)
 }
 
 // Duration returns time.Duration type value.
@@ -644,7 +668,8 @@ func (k *Key) parseFloat64s(strs []string, addInvalid, returnOnInvalid bool) ([]
 func (k *Key) parseInts(strs []string, addInvalid, returnOnInvalid bool) ([]int, error) {
        vals := make([]int, 0, len(strs))
        for _, str := range strs {
-               val, err := strconv.Atoi(str)
+               valInt64, err := strconv.ParseInt(str, 0, 64)
+               val := int(valInt64)        
                if err != nil && returnOnInvalid {
                        return nil, err
                }
@@ -659,7 +684,7 @@ func (k *Key) parseInts(strs []string, addInvalid, returnOnInvalid bool) ([]int,
 func (k *Key) parseInt64s(strs []string, addInvalid, returnOnInvalid bool) ([]int64, error) {
        vals := make([]int64, 0, len(strs))
        for _, str := range strs {
-               val, err := strconv.ParseInt(str, 10, 64)
+               val, err := strconv.ParseInt(str, 0, 64)
                if err != nil && returnOnInvalid {
                        return nil, err
                }
@@ -674,7 +699,7 @@ func (k *Key) parseInt64s(strs []string, addInvalid, returnOnInvalid bool) ([]in
 func (k *Key) parseUints(strs []string, addInvalid, returnOnInvalid bool) ([]uint, error) {
        vals := make([]uint, 0, len(strs))
        for _, str := range strs {
-               val, err := strconv.ParseUint(str, 10, 0)
+               val, err := strconv.ParseUint(str, 0, 0)
                if err != nil && returnOnInvalid {
                        return nil, err
                }
@@ -689,7 +714,7 @@ func (k *Key) parseUints(strs []string, addInvalid, returnOnInvalid bool) ([]uin
 func (k *Key) parseUint64s(strs []string, addInvalid, returnOnInvalid bool) ([]uint64, error) {
        vals := make([]uint64, 0, len(strs))
        for _, str := range strs {
-               val, err := strconv.ParseUint(str, 10, 64)
+               val, err := strconv.ParseUint(str, 0, 64)
                if err != nil && returnOnInvalid {
                        return nil, err
                }
index 6bd3cd34014eb47f253cd66afd63e15ebeab1eeb..f20073d1b4cd083a76edddbadabe25c4cfdbcbe9 100644 (file)
@@ -19,11 +19,14 @@ import (
        "bytes"
        "fmt"
        "io"
+       "regexp"
        "strconv"
        "strings"
        "unicode"
 )
 
+var pythonMultiline = regexp.MustCompile("^(\\s+)([^\n]+)")
+
 type tokenType int
 
 const (
@@ -97,7 +100,7 @@ func cleanComment(in []byte) ([]byte, bool) {
        return in[i:], true
 }
 
-func readKeyName(in []byte) (string, int, error) {
+func readKeyName(delimiters string, in []byte) (string, int, error) {
        line := string(in)
 
        // Check if key name surrounded by quotes.
@@ -124,7 +127,7 @@ func readKeyName(in []byte) (string, int, error) {
                pos += startIdx
 
                // Find key-value delimiter
-               i := strings.IndexAny(line[pos+startIdx:], "=:")
+               i := strings.IndexAny(line[pos+startIdx:], delimiters)
                if i < 0 {
                        return "", -1, ErrDelimiterNotFound{line}
                }
@@ -132,7 +135,7 @@ func readKeyName(in []byte) (string, int, error) {
                return strings.TrimSpace(line[startIdx:pos]), endIdx + startIdx + 1, nil
        }
 
-       endIdx = strings.IndexAny(line, "=:")
+       endIdx = strings.IndexAny(line, delimiters)
        if endIdx < 0 {
                return "", -1, ErrDelimiterNotFound{line}
        }
@@ -194,7 +197,8 @@ func hasSurroundedQuote(in string, quote byte) bool {
 }
 
 func (p *parser) readValue(in []byte,
-       ignoreContinuation, ignoreInlineComment, unescapeValueDoubleQuotes, unescapeValueCommentSymbols bool) (string, error) {
+       parserBufferSize int,
+       ignoreContinuation, ignoreInlineComment, unescapeValueDoubleQuotes, unescapeValueCommentSymbols, allowPythonMultilines, spaceBeforeInlineComment, preserveSurroundedQuote bool) (string, error) {
 
        line := strings.TrimLeftFunc(string(in), unicode.IsSpace)
        if len(line) == 0 {
@@ -224,26 +228,39 @@ func (p *parser) readValue(in []byte,
                return line[startIdx : pos+startIdx], nil
        }
 
+       lastChar := line[len(line)-1]
        // Won't be able to reach here if value only contains whitespace
        line = strings.TrimSpace(line)
+       trimmedLastChar := line[len(line)-1]
 
        // Check continuation lines when desired
-       if !ignoreContinuation && line[len(line)-1] == '\\' {
+       if !ignoreContinuation && trimmedLastChar == '\\' {
                return p.readContinuationLines(line[:len(line)-1])
        }
 
        // Check if ignore inline comment
        if !ignoreInlineComment {
-               i := strings.IndexAny(line, "#;")
+               var i int
+               if spaceBeforeInlineComment {
+                       i = strings.Index(line, " #")
+                       if i == -1 {
+                               i = strings.Index(line, " ;")
+                       }
+
+               } else {
+                       i = strings.IndexAny(line, "#;")
+               }
+
                if i > -1 {
                        p.comment.WriteString(line[i:])
                        line = strings.TrimSpace(line[:i])
                }
+
        }
 
        // Trim single and double quotes
-       if hasSurroundedQuote(line, '\'') ||
-               hasSurroundedQuote(line, '"') {
+       if (hasSurroundedQuote(line, '\'') ||
+               hasSurroundedQuote(line, '"')) && !preserveSurroundedQuote {
                line = line[1 : len(line)-1]
        } else if len(valQuote) == 0 && unescapeValueCommentSymbols {
                if strings.Contains(line, `\;`) {
@@ -252,7 +269,42 @@ func (p *parser) readValue(in []byte,
                if strings.Contains(line, `\#`) {
                        line = strings.Replace(line, `\#`, "#", -1)
                }
+       } else if allowPythonMultilines && lastChar == '\n' {
+               parserBufferPeekResult, _ := p.buf.Peek(parserBufferSize)
+               peekBuffer := bytes.NewBuffer(parserBufferPeekResult)
+
+               val := line
+
+               for {
+                       peekData, peekErr := peekBuffer.ReadBytes('\n')
+                       if peekErr != nil {
+                               if peekErr == io.EOF {
+                                       return val, nil
+                               }
+                               return "", peekErr
+                       }
+
+                       peekMatches := pythonMultiline.FindStringSubmatch(string(peekData))
+                       if len(peekMatches) != 3 {
+                               return val, nil
+                       }
+
+                       // NOTE: Return if not a python-ini multi-line value.
+                       currentIdentSize := len(peekMatches[1])
+                       if currentIdentSize <= 0 {
+                               return val, nil
+                       }
+
+                       // NOTE: Just advance the parser reader (buffer) in-sync with the peek buffer.
+                       _, err := p.readUntil('\n')
+                       if err != nil {
+                               return "", err
+                       }
+
+                       val += fmt.Sprintf("\n%s", peekMatches[2])
+               }
        }
+
        return line, nil
 }
 
@@ -270,14 +322,48 @@ func (f *File) parse(reader io.Reader) (err error) {
        }
        section, _ := f.NewSection(name)
 
+       // This "last" is not strictly equivalent to "previous one" if current key is not the first nested key
+       var isLastValueEmpty bool
+       var lastRegularKey *Key
+
        var line []byte
        var inUnparseableSection bool
+
+       // NOTE: Iterate and increase `currentPeekSize` until
+       // the size of the parser buffer is found.
+       // TODO(unknwon): When Golang 1.10 is the lowest version supported, replace with `parserBufferSize := p.buf.Size()`.
+       parserBufferSize := 0
+       // NOTE: Peek 1kb at a time.
+       currentPeekSize := 1024
+
+       if f.options.AllowPythonMultilineValues {
+               for {
+                       peekBytes, _ := p.buf.Peek(currentPeekSize)
+                       peekBytesLength := len(peekBytes)
+
+                       if parserBufferSize >= peekBytesLength {
+                               break
+                       }
+
+                       currentPeekSize *= 2
+                       parserBufferSize = peekBytesLength
+               }
+       }
+
        for !p.isEOF {
                line, err = p.readUntil('\n')
                if err != nil {
                        return err
                }
 
+               if f.options.AllowNestedValues &&
+                       isLastValueEmpty && len(line) > 0 {
+                       if line[0] == ' ' || line[0] == '\t' {
+                               lastRegularKey.addNestedValue(string(bytes.TrimSpace(line)))
+                               continue
+                       }
+               }
+
                line = bytes.TrimLeftFunc(line, unicode.IsSpace)
                if len(line) == 0 {
                        continue
@@ -295,8 +381,7 @@ func (f *File) parse(reader io.Reader) (err error) {
                // Section
                if line[0] == '[' {
                        // Read to the next ']' (TODO: support quoted strings)
-                       // TODO(unknwon): use LastIndexByte when stop supporting Go1.4
-                       closeIdx := bytes.LastIndex(line, []byte("]"))
+                       closeIdx := bytes.LastIndexByte(line, ']')
                        if closeIdx == -1 {
                                return fmt.Errorf("unclosed section: %s", line)
                        }
@@ -335,25 +420,35 @@ func (f *File) parse(reader io.Reader) (err error) {
                        continue
                }
 
-               kname, offset, err := readKeyName(line)
+               kname, offset, err := readKeyName(f.options.KeyValueDelimiters, line)
                if err != nil {
                        // Treat as boolean key when desired, and whole line is key name.
-                       if IsErrDelimiterNotFound(err) && f.options.AllowBooleanKeys {
-                               kname, err := p.readValue(line,
-                                       f.options.IgnoreContinuation,
-                                       f.options.IgnoreInlineComment,
-                                       f.options.UnescapeValueDoubleQuotes,
-                                       f.options.UnescapeValueCommentSymbols)
-                               if err != nil {
-                                       return err
-                               }
-                               key, err := section.NewBooleanKey(kname)
-                               if err != nil {
-                                       return err
+                       if IsErrDelimiterNotFound(err) {
+                               switch {
+                               case f.options.AllowBooleanKeys:
+                                       kname, err := p.readValue(line,
+                                               parserBufferSize,
+                                               f.options.IgnoreContinuation,
+                                               f.options.IgnoreInlineComment,
+                                               f.options.UnescapeValueDoubleQuotes,
+                                               f.options.UnescapeValueCommentSymbols,
+                                               f.options.AllowPythonMultilineValues,
+                                               f.options.SpaceBeforeInlineComment,
+                                               f.options.PreserveSurroundedQuote)
+                                       if err != nil {
+                                               return err
+                                       }
+                                       key, err := section.NewBooleanKey(kname)
+                                       if err != nil {
+                                               return err
+                                       }
+                                       key.Comment = strings.TrimSpace(p.comment.String())
+                                       p.comment.Reset()
+                                       continue
+
+                               case f.options.SkipUnrecognizableLines:
+                                       continue
                                }
-                               key.Comment = strings.TrimSpace(p.comment.String())
-                               p.comment.Reset()
-                               continue
                        }
                        return err
                }
@@ -367,13 +462,18 @@ func (f *File) parse(reader io.Reader) (err error) {
                }
 
                value, err := p.readValue(line[offset:],
+                       parserBufferSize,
                        f.options.IgnoreContinuation,
                        f.options.IgnoreInlineComment,
                        f.options.UnescapeValueDoubleQuotes,
-                       f.options.UnescapeValueCommentSymbols)
+                       f.options.UnescapeValueCommentSymbols,
+                       f.options.AllowPythonMultilineValues,
+                       f.options.SpaceBeforeInlineComment,
+                       f.options.PreserveSurroundedQuote)
                if err != nil {
                        return err
                }
+               isLastValueEmpty = len(value) == 0
 
                key, err := section.NewKey(kname, value)
                if err != nil {
@@ -382,6 +482,7 @@ func (f *File) parse(reader io.Reader) (err error) {
                key.isAutoIncrement = isAutoIncr
                key.Comment = strings.TrimSpace(p.comment.String())
                p.comment.Reset()
+               lastRegularKey = key
        }
        return nil
 }
index d8a402619204e1f3fa750ffab21ae7b034772ecf..bc32c620d6ede80eabdf8091e431c038e5b18095 100644 (file)
@@ -82,6 +82,7 @@ func (s *Section) NewKey(name, val string) (*Key, error) {
                        }
                } else {
                        s.keys[name].value = val
+                       s.keysHash[name] = val
                }
                return s.keys[name], nil
        }
@@ -237,6 +238,7 @@ func (s *Section) DeleteKey(name string) {
                if k == name {
                        s.keyList = append(s.keyList[:i], s.keyList[i+1:]...)
                        delete(s.keys, name)
+                       delete(s.keysHash, name)
                        return
                }
        }
index 9719dc6985a1a635284535451962990876ee3fa4..a9dfed078ab6fad53cad77cf803f0d8555552d55 100644 (file)
@@ -180,7 +180,7 @@ func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim stri
        case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64:
                durationVal, err := key.Duration()
                // Skip zero value
-               if err == nil && int(durationVal) > 0 {
+               if err == nil && uint64(durationVal) > 0 {
                        field.Set(reflect.ValueOf(durationVal))
                        return nil
                }
index 4d427e5a745cfbad592d1551e8ef56a04c63c606..0013ea356f6dc141a7af3c83ac4c53394480fb14 100644 (file)
@@ -7,7 +7,7 @@ github.com/RoaringBitmap/roaring
 # github.com/Unknwon/cae v0.0.0-20160715032808-c6aac99ea2ca
 github.com/Unknwon/cae/zip
 github.com/Unknwon/cae
-# github.com/Unknwon/com v0.0.0-20170819223952-7677a1d7c113
+# github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755
 github.com/Unknwon/com
 # github.com/Unknwon/i18n v0.0.0-20171114194641-b64d33658966
 github.com/Unknwon/i18n
@@ -125,6 +125,8 @@ github.com/go-macaron/cache/memcache
 github.com/go-macaron/cache/redis
 # github.com/go-macaron/captcha v0.0.0-20151123225153-8aa5919789ab
 github.com/go-macaron/captcha
+# github.com/go-macaron/cors v0.0.0-20190309005821-6fd6a9bfe14e9
+github.com/go-macaron/cors
 # github.com/go-macaron/csrf v0.0.0-20180426211211-503617c6b372
 github.com/go-macaron/csrf
 # github.com/go-macaron/i18n v0.0.0-20160612092837-ef57533c3b0f
@@ -331,7 +333,7 @@ github.com/willf/bitset
 github.com/xanzy/ssh-agent
 # github.com/yohcop/openid-go v0.0.0-20160914080427-2c050d2dae53
 github.com/yohcop/openid-go
-# golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
+# golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480
 golang.org/x/crypto/acme/autocert
 golang.org/x/crypto/bcrypt
 golang.org/x/crypto/pbkdf2
@@ -363,10 +365,11 @@ golang.org/x/net/context
 # golang.org/x/oauth2 v0.0.0-20181101160152-c453e0c75759
 golang.org/x/oauth2
 golang.org/x/oauth2/internal
-# golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
+# golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e
 golang.org/x/sys/windows
 golang.org/x/sys/windows/svc
 golang.org/x/sys/unix
+golang.org/x/sys/cpu
 # golang.org/x/text v0.3.0
 golang.org/x/text/transform
 golang.org/x/text/encoding
@@ -403,7 +406,7 @@ gopkg.in/bufio.v1
 gopkg.in/editorconfig/editorconfig-core-go.v1
 # gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
 gopkg.in/gomail.v2
-# gopkg.in/ini.v1 v1.31.1
+# gopkg.in/ini.v1 v1.42.0
 gopkg.in/ini.v1
 # gopkg.in/ldap.v3 v3.0.2
 gopkg.in/ldap.v3