Commit Graph

1123 Commits

Author SHA1 Message Date
Tobias Kohlbau
479acdf4ea windows: add support for CommTimeouts
CommTimeouts allows the user to set the timeout on Comm devices:

docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setcommtimeouts
docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcommtimeouts

Change-Id: I756dc93b1b01412a496c6eccab22c9ff7e5f4b83
Reviewed-on: https://go-review.googlesource.com/c/sys/+/290209
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-28 01:22:17 +00:00
Alex Brainman
b0d1d43c01 windows/svc: make IsWindowsService handle parent exit
IsWindowsService fails when parent process has exited.

This change makes IsWindowsService return false instead.

Added a test to verify the change.

Change-Id: Ibb2aa9478e8afd9e35011bbdc0985bdf8f0af9cc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/294729
TryBot-Result: Go Bot <gobot@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
2021-02-27 04:07:30 +00:00
Jason A. Donenfeld
f36f78243c windows: add definitions and functions for ProcThreadAttributeList
The bulk of the documentation for these is in:

https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute

This allows creating processes from scratch that use advanced options,
such as changing the process parent.

Fixes golang/go#44005.

Change-Id: Id5cc5400541e57710b9e888cd37ef4f925d510fe
Reviewed-on: https://go-review.googlesource.com/c/sys/+/288412
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-26 18:17:00 +00:00
Tobias Klauser
a50acf3fe0 unix: fix IoctlFileDedupeRange test
The test introduced in CL 284352 breaks on several builders, either
with IoctlFileDedupeRange returning ENOTTY (as already seen for android
in the TryBot run) or returning EINVAL in the FileDedupeRange.Status
field. Both seem to indicate that the underlying filesystem doesn't
support deduplication, so skip the test in these cases.

Also rename the test to indicate the func it is testing.

Change-Id: I29553a5fc95f98335cb233f05d4c2dfb5640dc4c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/295911
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-02-25 13:49:36 +00:00
Tobias Klauser
4ada9433c6 unix: test nonblocking and close-on-exec behavior of Pipe2
Following TestNonblockingPipe in package runtime.

Change-Id: Ifacec3ea6ce372a891273e3ec9fa4194f7d17619
Reviewed-on: https://go-review.googlesource.com/c/sys/+/295869
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-25 09:19:47 +00:00
Tobias Klauser
2738c018e2 unix: fix Pipe2 on dragonfly
The pipe2 on dragonfly still expects an fds array as an argument, but
does not use it to return the file descriptors. Just pass the argument
but ignore its value. This way the flags argument will be respected
correctly.

Change-Id: Id340653040999f31074eae01e9be4ea2088abae5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/295870
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-25 09:19:36 +00:00
Lluís Batlle i Rossell
8e9945a547 unix: fix and test the FIDEDUPERANGE Linux ioctl
The previous implementation didn't match the ioctl spec.

Fixes golang/go#43678

Change-Id: Ia1c292c2dbd4913fb1d7e8331d9f18e23169d64a
GitHub-Last-Rev: 5331c424ef
GitHub-Pull-Request: golang/sys#97
Reviewed-on: https://go-review.googlesource.com/c/sys/+/284352
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
2021-02-25 08:00:10 +00:00
Jason A. Donenfeld
683adc9d29 windows: do not overflow key memory in GetQueuedCompletionStatus
The third argument to GetQueuedCompletionStatus is a pointer to a
uintptr, not a uint32. Users of this functions have therefore been
corrupting their memory every time they used it. Either that memory
corruption was silent (dangerous), or their programs didn't work so they
chose a different API to use.

Updates golang/go#44538.

Change-Id: Ie1f66de11001cf9c8195afaa61f003a86f821a95
Reviewed-on: https://go-review.googlesource.com/c/sys/+/295174
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-02-25 01:42:09 +00:00
billofarrell
5640770f5e unix: add support for zos/s390x
This adds sys/unix support for zos/s390x.
These changes should not affect other platforms.

Fixes golang/go#43230

Change-Id: If1c1d9df134fbc44f95ca1b214e836508696da93
Reviewed-on: https://go-review.googlesource.com/c/sys/+/275992
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-24 23:11:01 +00:00
Jason A. Donenfeld
eede4237b3 windows: add WSASocket
Simple function to complement the other ws2 functions we have:
https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw

Change-Id: Idf6b17360d84a8529e48ab94561c4ac7bee1d847
Reviewed-on: https://go-review.googlesource.com/c/sys/+/295175
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-23 21:21:15 +00:00
Tobias Klauser
7937bea010 unix: add Xucred, GetsockoptXucred on freebsd
Follow CL 292330 which added these on darwin.

Generated on FreeBSD 13.0BETA3

For golang/go#41659

Change-Id: I30eeef43c4f61a9449f3fe8b5cc0033f46dfe822
Reviewed-on: https://go-review.googlesource.com/c/sys/+/294989
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-23 09:59:34 +00:00
Tom Thorogood
b80eb88b80 unix: add HIDRAW ioctls
This change adds (most) of the ioctl API for the Linux HIDRAW interface.
Reading and writing non-numbered HID reports is done using the read and
write system calls respectively.

Some of the HIDIOC* request numbers are exported directly while others
are kept unexported. This is because some of the #defines require a len
attribute that doesn't have a specific well defined value.

Wrapper types are added for most of the request numbers as is standard.
No wrapper is added for HIDIOCGRDESCSIZE as it would just be
IoctlGetUint32.

The HIDIOC[GS]FEATURE, HIDIOC[GS]INPUT and HIDIOC[GS]OUTPUT request
numbers, which are required for numbered HID reports, are entirely
ommitted as the len attribute has to be a runtime variable. These could
be added later by doing something like
 `HIDIOCGFEATURE(0) | (len << _IOC_SIZESHIFT)`,
with care taken that len doesn't overflow _IOC_XSIZEMASK.

Outdated documentation for the HIDRAW interface is available at:
https://www.kernel.org/doc/Documentation/hid/hidraw.txt.

Change-Id: I2ae5060f0f46150f6fb52959c2e55f50927c1f69
Reviewed-on: https://go-review.googlesource.com/c/sys/+/289169
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-02-23 08:53:22 +00:00
Tobias Klauser
d8cc79f4ae unix: drop pre-1.10 compatibility in TestSCMCredentials
The last pre-1.10 release - Go 1.9 - was release 2017-08-24 and is no
longer supported since Go 1.11 was released 2018-08-24.

This effectively reverts https://golang.org/cl/80275

Updates golang/go#22899

Change-Id: Id7ab3f6b6d6430977db9345def383d875396e1e7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/292969
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-23 08:51:55 +00:00
Russ Cox
9a76102bfb all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I01667f826428426a39c84717d02efa25fa44553c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/294490
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2021-02-20 05:07:31 +00:00
Bryan C. Mills
57ea560cfc windows: comment on fields omitted from the win32finddata1 struct
Updates golang/go#42637

Change-Id: I2e8c95af3cf2172c55bda6a15a749afcc6c45581
Reviewed-on: https://go-review.googlesource.com/c/sys/+/284172
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-02-19 17:28:41 +00:00
Boshi LIAN
3351caf150 windows: add CertFindCertificateInStore, CertFindChainInStore and CryptAcquireCertificatePrivateKey
add cert loading related syscall
CertFindCertificateInStore [1]
CertFindChainInStore [2]
CryptAcquireCertificatePrivateKey [3]

[1] https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certfindcertificateinstore
[2] https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certfindchaininstore
[3] https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecertificateprivatekey

Change-Id: I179bffd06d714d729f3afd83687336edecae6b37
GitHub-Last-Rev: 58a8c666c8
GitHub-Pull-Request: golang/sys#94
Reviewed-on: https://go-review.googlesource.com/c/sys/+/281012
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
2021-02-19 17:27:56 +00:00
Tobias Klauser
8ebf48af03 unix: check gid in TestGetsockoptXucred
macOS (and the BSDs) report all groups in Xucred, the first one being
the GID.

Also use Socketpair/Close from golang.org/x/sys/unix instead of package
syscall.

Change-Id: I9319ff2b5258f66afc24e3e80c704d816e995dbf
Reviewed-on: https://go-review.googlesource.com/c/sys/+/293569
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-18 15:57:24 +00:00
Jason A. Donenfeld
beda7e5e15 windows: port to ARM64
This also fixes up some spaces->tabs issues and moves build tags from
the file contents to the file name.

Updates golang/go#36439.

Change-Id: Iafa03e26575603a802832e587bb18ebd16fd176b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/289449
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-02-18 14:52:45 +00:00
Tobias Klauser
9555bcde0c unix: add Pipe2 on netbsd
Re-submit after CL 283593 broke the dragonfly builders.

Change-Id: Ifdeb7642be32f5d3d3862aacdff90a0da4886365
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283599
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-18 08:51:08 +00:00
Tobias Klauser
e8e29180ff unix: fix Pipe2 on dragonfly
Also move TestPipe2 into a separate file, enabling it for all platforms
where Pipe2 is available.

Change-Id: I9c554a53fc9d7610aaa732c0ceba864963fad542
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283598
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2021-02-18 08:40:38 +00:00
Tobias Klauser
b926d437f3 unix/linux: update Dockerfile to Kernel 5.11, glibc 2.33, Go 1.16
The FS_POLICY_FLAGS_VALID const is kernel-internal and was removed from
the UAPI headers in
3ceb6543e9

Change-Id: I21b1efe895fbd7f640a7604805cf7ce39c5a43f4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/291637
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-02-17 10:54:51 +00:00
Tobias Klauser
ed5674b6da unix/linux: adjust comment regarding riscv64 support
The riscv64 port is supported since Go 1.14, adjust the comment in
mkall.go accordingly.

Change-Id: I4b3f218abe9c864c855e89f132e67e9d86754a53
Reviewed-on: https://go-review.googlesource.com/c/sys/+/288333
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-17 09:06:53 +00:00
Tobias Klauser
21e18009e2 unix: add Sysconf on solaris
This wraps sysconf(3) on solaris.

Change-Id: Ie5dd32bfa98bf900cadce6f20cefd553fdf80e29
Reviewed-on: https://go-review.googlesource.com/c/sys/+/286593
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-17 09:05:18 +00:00
Tobias Klauser
1d4d2d3355 unix: small fixes for TestPipe
Check error returned by Pipe, use %v to format error values and strip
trailing newlines from Errorf messages. Also move TestPipe above the
test helper functions.

Change-Id: Id431c8ffbcf525347cb4c138df69f92cc730f54a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283592
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-17 09:00:31 +00:00
Tobias Klauser
73548a7a48 unix: consistently use tabs in //sys and //sysnb lines
There is some inconsistent use of tabs and spaces in the //sys and
//sysnb lines. However, the large majority is using tabs, so use these
consistently.

Also change the regexp in mksyscall*.go to only accept tabs going
forward.

Change-Id: I78944e88b5fec11c1bd1d103cea894bc5109da56
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283596
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-17 08:59:31 +00:00
Brad Fitzpatrick
f992740a1b unix: add Xucred, GetsockoptXucred on darwin
Test adapted from CL 134535 from Tyler Julian (@APTy).

For posterity, the auto-generated parts were updated with:

    GOARCH_TARGET=amd64 go tool cgo -godefs types_darwin.go | GOOS=darwin GOARCH_TARGET=amd64 go run mkpost.go > ztypes_darwin_amd64.go
    GOARCH_TARGET=arm64 go tool cgo -godefs types_darwin.go | GOOS=darwin GOARCH_TARGET=arm64 go run mkpost.go > ztypes_darwin_arm64.go
    GOOS=darwin GOARCH=amd64 ./mkerrors.sh -m64 > zerrors_darwin_amd64.go ; gofmt -w zerrors_darwin_amd64.go
    GOOS=darwin GOARCH=arm64 ./mkerrors.sh -m64 > zerrors_darwin_arm64.go ; gofmt -w zerrors_darwin_arm64.go
    perl -i -npe 's,( cgo -godefs(?: -- -m64)? )/.+/(\S+.go),$$1$$2,' zerrors_darwin_amd64.go zerrors_darwin_arm64.go ztypes_darwin_amd64.go ztypes_darwin_arm64.go

Fixes golang/go#27613

Change-Id: Ie41b3da840cb9c8c140c57ecfb78e7abc4f70bea
Reviewed-on: https://go-review.googlesource.com/c/sys/+/292330
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-02-16 22:45:49 +00:00
Brad Fitzpatrick
f7da38b97c unix: re-generate darwin output on Big Sur (11.2.1)
For posterity, I ran:

    GOARCH_TARGET=amd64 go tool cgo -godefs types_darwin.go | GOOS=darwin GOARCH_TARGET=amd64 go run mkpost.go > ztypes_darwin_amd64.go
    GOARCH_TARGET=arm64 go tool cgo -godefs types_darwin.go | GOOS=darwin GOARCH_TARGET=arm64 go run mkpost.go > ztypes_darwin_arm64.go
    GOOS=darwin GOARCH=amd64 ./mkerrors.sh -m64 > zerrors_darwin_amd64.go ; gofmt -w zerrors_darwin_amd64.go
    GOOS=darwin GOARCH=arm64 ./mkerrors.sh -m64 > zerrors_darwin_arm64.go ; gofmt -w zerrors_darwin_arm64.go
    perl -i -npe 's,( cgo -godefs(?: -- -m64)? )/.+/(\S+.go),$$1$$2,' zerrors_darwin_amd64.go zerrors_darwin_arm64.go ztypes_darwin_amd64.go ztypes_darwin_arm64.go

Change-Id: I17e8fc3bd66f4766d0f5f731151f0b85758c01b0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/292329
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-02-16 16:36:48 +00:00
Brad Fitzpatrick
c4c1ae6d18 unix: fix typo in test
Change-Id: I80b28a28a9e6133a7c8a9340ce5914498ff6bf0f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/292331
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2021-02-16 15:53:14 +00:00
Jason A. Donenfeld
22da62e12c windows: correct struct name and bool type
This fixes the name of a struct to match Microsoft's documentation.

It also reverts a change I made in the last patchset of CL 285714. The
idea there was that a Go bool would suffice for a win32 BOOL, because of
little endian. But in fact, a value of 0xff000000 would be treated as
false by Go but true by C, which is a problem. So this changes to using
a vanilla int32 type, which matches the C "int" used in the Microsoft
headers.

Change-Id: Id7cd306e916b3754e8dfe32bf11ec30cad3a13b4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/285717
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-01-24 15:45:48 +00:00
Jason A. Donenfeld
1d476976d1 windows: add support for DPAPI
DPAPI allows machine or user-based blob encryption, using APIs from
crypt32:

https://docs.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptunprotectdata
https://docs.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptprotectdata

Change-Id: I57fb4f1877a5fb7629809e79111cbfa02b11cca3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/285716
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-01-23 23:11:50 +00:00
Jason A. Donenfeld
07034700bc windows: add WinVerifyTrustEx function
This commit adds the function and the required structs for it.  This is
the same as the WinVerifyTrust function but has the more correct
signature.

https://docs.microsoft.com/en-us/windows/win32/api/wintrust/nf-wintrust-winverifytrustex

Change-Id: I43ae20302ba85a6ae1fc32ad4c34b59bee0a6a35
Reviewed-on: https://go-review.googlesource.com/c/sys/+/285715
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-01-23 23:11:35 +00:00
Jason A. Donenfeld
4df39788e6 windows: add missing crypt/cert API functions for examining certificate objects
This adds these functions and the various enums and constants required
to use them:
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptdecodeobject
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptqueryobject
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certgetnamestringw
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certfindextension

We also use this opportunity to clean up formatting of the previous
crypt APIs added: a few lines slipped in that used "//sys   ", with
spaces, instead of "//sys\t" with a tab. This fixes that up for
consistency.

Change-Id: I925d3d29b5255f70ee2368e8906c45b8b22115ce
Reviewed-on: https://go-review.googlesource.com/c/sys/+/285714
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
2021-01-23 23:10:56 +00:00
Tobias Klauser
9b0068b266 execabs: disable tests on ios and js/wasm
TestCommand and TestLookPath fail on the js/wasm builder and likely
fail on ios as well.

Like the tests in internal/execabs, skip them for these platforms.

This fixes the js/wasm builder after CL 284753.

For golang/go#11811

Change-Id: I1038128bd4c7bd410ac1357dedda5e3eef5c7bbb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/285712
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-01-23 11:12:55 +00:00
Jason A. Donenfeld
a8b976e07c windows: add Find*ChangeNotification APIs for file and directory monitoring
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstchangenotificationw
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findnextchangenotification
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findclosechangenotification

Change-Id: If7abfd63cd7a60e7f95ffad9aca2b7b7b74c94f0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/285713
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-01-22 23:57:52 +00:00
Jason A. Donenfeld
04d7465088 windows: correct signature of recently added GetWindowThreadProcessId
This function returns 0 and sets last error on failure. While this isn't
said explicitly on MSDN, there's no PID 0, and trivial reverse
engineering shows that this is the case. For example:

.text:00000001800035ED loc_1800035ED:                          ; CODE XREF: GetWindowThreadProcessId+23↑j
.text:00000001800035ED                                         ; GetWindowThreadProcessId+3D↑j ...
.text:00000001800035ED                 mov     ecx, 578h       ; LastError
.text:00000001800035F2                 call    cs:__imp_RtlSetLastWin32Error
.text:00000001800035F9                 nop     dword ptr [rax+rax+00h]
.text:00000001800035FE
.text:00000001800035FE loc_1800035FE:                          ; CODE XREF: GetWindowThreadProcessId+65↑j
.text:00000001800035FE                 xor     eax, eax
.text:0000000180003600                 jmp     short loc_1800035AA

This function was also just added by a user who is likely its only
consumer, so this error is not too late to fix.

Change-Id: I5dd24e78c006686bb8f1288ad0fe63cd67df56a6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/285272
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-01-22 09:31:01 +00:00
Roland Shoemaker
b64e53b001 execabs: create execabs package
This package provides an alternative to os/exec that guarantees
never to satisfy a PATH lookup using an executable in the current
directory.

Change-Id: Id978f8039fe21687059c788836c79ae8e0930e92
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949732
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-on: https://go-review.googlesource.com/c/sys/+/284753
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-01-19 21:28:57 +00:00
Tobias Klauser
4bcb84eeeb Revert "unix: add Pipe2 on netbsd"
This reverts CL 283593.

Reason for revert: breaks DragonflyBSD builders and was submitted during code freeze.

Change-Id: I784f58ae56f7259d5176921d7a61070e0ac7cb52
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283597
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-01-13 18:17:07 +00:00
Tobias Klauser
ba0562f347 unix: re-generate linux consts after CL 283413
ETHTOOL_RX_FLOW_SPEC_RING_VF_OFF was removed from linux/types.go and
mkerrors.sh will catch it instead.

Change-Id: I76e063cbfee4411e5ea9f2e0e5359e169d56b195
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283595
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-01-13 13:13:15 +00:00
Tobias Klauser
3196cb8d8e unix: add Pipe2 on netbsd
Also move TestPipe2 into a separate file, enabling it for all platforms
where Pipe2 is available.

Change-Id: I1a31e9563f5f60ef0e994abc1db57b7f1c58fe88
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283593
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-01-13 11:20:37 +00:00
Matt Layher
eaf3bda374 unix: add ethtool constants for Linux
The ethtool generic netlink interface also uses these constants
in addition to the ones I previously added.

For more information about this interface, see:
https://www.kernel.org/doc/html/latest/networking/ethtool-netlink.html.

Change-Id: I8861e5faa23bfc0179725314fc5a528486e328b2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283413
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-01-13 00:00:19 +00:00
Alex Brainman
59c308dcf3 windows: use HWND type in MessageBox, GetShellWindow and GetWindowThreadProcessId
This matches usual win32api conventions. While we're at it, we
group together user32.dll functions together.

This CL was based on CL 282634 with all but MessageBox, GetShellWindow
and GetWindowThreadProcessId changes removed to prevent compatibility
break.

Change-Id: I7e17c581723c41580a49c5612cabc7a5c13c0f15
Reviewed-on: https://go-review.googlesource.com/c/sys/+/282972
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Alex Brainman <alex.brainman@gmail.com>
2021-01-12 09:13:31 +00:00
Tobias Klauser
489259a850 unix: add Pipe2 for solaris
We already implement Pipe2 for illumos and it seems solaris provides the
pipe2 syscall as well, see
https://docs.oracle.com/cd/E88353_01/html/E37841/pipe2-2.html.

Fixes golang/go#40613

Change-Id: I135cb1e78e6c67567d30d7eed266d00ef8fd6c3a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283032
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-01-12 08:05:10 +00:00
Matt Layher
789bb1bd40 unix: add ethtool generic netlink constants for Linux
For more information about this interface, see:
https://www.kernel.org/doc/html/latest/networking/ethtool-netlink.html.

Change-Id: I4fe37e7dce3c52d72286bee047de2b49fe559b13
Reviewed-on: https://go-review.googlesource.com/c/sys/+/282812
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
2021-01-10 05:19:26 +00:00
Alex Brainman
0df2131ae3 windows: add GetShellWindow and GetWindowThreadProcessId
I am trying to implement

https://devblogs.microsoft.com/oldnewthing/20190425-00/?p=102443

so I need these functions.

Change-Id: Id5082e4cc450569ffd021f4a300d56de325e4952
Reviewed-on: https://go-review.googlesource.com/c/sys/+/280717
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-01-08 17:29:13 +00:00
Artyom Pervukhin
16f7687f50 unix: don't call testing.T.Fatalf in a background goroutine
> Those methods [...] must be called only from the goroutine running the
> Test function.

For golang/go#43498

Change-Id: I847067936ade613a21b059c90219bd285425f0aa
Reviewed-on: https://go-review.googlesource.com/c/sys/+/280622
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2021-01-05 21:07:32 +00:00
Keith Randall
6f8348627a unix: fix darwin pipe implementation
The raw syscall returned the two pipes whereas the libc call
takes a pointer to a location to write the two pipes.
When we switched over from raw syscalls to libc calls, this
change in behavior was missed.

Fixes golang/go#43498

Change-Id: Icee2204dcb8be8fc94be0df106e1ff061cafa446
Reviewed-on: https://go-review.googlesource.com/c/sys/+/281432
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-01-04 20:47:34 +00:00
Boshi LIAN
2d18734c60 windows: add PFXImportCertStore and CertDuplicateCertificateContext
add 2 new cert related dll call
PFXImportCertStore [1]
CertDuplicateCertificateContext [2]

also, add missing flags for CertCloseStore [3]

[1] https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-pfximportcertstore
[2] https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certduplicatecertificatecontext
[3] https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certclosestore

Change-Id: Ia44100ddb2cac1c2a817932c859926e8183dcda0
GitHub-Last-Rev: f3cd41859d
GitHub-Pull-Request: golang/sys#93
Reviewed-on: https://go-review.googlesource.com/c/sys/+/273907
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-31 18:44:35 +00:00
Tobias Klauser
0d417f6369 unix: don't use ptrace on ios
Follow CL 279481 which did the same for package syscall.

For golang/go#43302.

Change-Id: I9fa7bec5712cf43fd7485225d4c21665c151defc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/279393
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-12-23 07:45:33 +00:00
Tobias Klauser
bc327ba9c2 unix/linux: update Dockerfile to Go 1.16beta1
Change-Id: Iee6d0bdbbb4f36adb8e963e482c0d62c7a3fb147
Reviewed-on: https://go-review.googlesource.com/c/sys/+/279113
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-21 09:36:33 +00:00
Tobias Klauser
7d0127a747 unix: add SizeofIovec on aix, dragonfly, *bsd and solaris
Change-Id: Ib981ad3f745a2566d0a12eba5e54c7da53b69d6e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/279112
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2020-12-18 08:43:10 +00:00