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
Tobias Klauser
f9fddec55a
unix/linux: update Dockerfile to kernel 5.10 and Go 1.15.6
...
Also include some newly added consts.
Change-Id: Iaf9fad92a4cbbf9f1e97ed544116bd93525dddde
Reviewed-on: https://go-review.googlesource.com/c/sys/+/277254
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-14 21:06:02 +00:00
Tobias Klauser
aec9a39092
unix: use Time{spec,val}.Nano in Time{spec,val}ToNsec
...
Follow what CL 188397 did in package syscall:
Call the Nano methods of Timespec and Timeval in TimespecToNsec and
TimevalToNsec respectively, instead of duplicating the implementation.
Change-Id: I50f1958c0f7bca92fc4990684f1de9c148ae5859
Reviewed-on: https://go-review.googlesource.com/c/sys/+/277253
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 >
2020-12-14 09:51:26 +00:00
Tobias Klauser
8c39875709
unix: drop references to Unix epoch in Timeval/Timespec docs
...
Follow what CL 277073 did for package syscall:
The various conversion functions just change the format of time values.
They don't use the Unix epoch. Although in practice the values are often
times since the Unix epoch, they aren't always, so referring to the
epoch can be confusing.
Updates golang/go#43010
Change-Id: Icb9953e20d7cab8e36ddfb467dc2380ee181f18b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/277252
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 >
2020-12-14 09:51:18 +00:00
Meng Zhuo
8ad439b19e
windows: remove ErrorControl value check in CreateService
...
ErrorIgnore is 0 which means we shouldn't rely on zero value checking.
Fixes golang/go#43094
Change-Id: I7af3132cfe58d73c7abab92203fb02a0ada15218
Reviewed-on: https://go-review.googlesource.com/c/sys/+/276572
Trust: Meng Zhuo <mzh@golangcn.org >
Trust: Alex Brainman <alex.brainman@gmail.com >
Trust: Jason A. Donenfeld <Jason@zx2c4.com >
Run-TryBot: Meng Zhuo <mzh@golangcn.org >
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com >
Reviewed-by: Alex Brainman <alex.brainman@gmail.com >
2020-12-11 09:08:39 +00:00
Josh Bleecher Snyder
1f0c578a6b
windows: add RegNotifyChangeKeyValue notifyFilter flags
...
Copied with permission (and CLA) from
https://git.zx2c4.com/wireguard-go/tree/tun/wintun/registry/registry_windows.go?id=5ca1218a5c16fb9b5e99b61c0b5758f66087e2e4
Change-Id: I42c1657b603f8494dadedacc8f7d719d39df9dc0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/277153
Trust: Josh Bleecher Snyder <josharian@gmail.com >
Trust: Jason A. Donenfeld <Jason@zx2c4.com >
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com >
2020-12-11 00:26:50 +00:00
Josh Bleecher Snyder
7e3030f880
windows: add RegNotifyChangeKeyValue syscall
...
Change-Id: If1a1b6ad1935bfaacb9e6a99fb9ade056169ccb2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/277152
Trust: Josh Bleecher Snyder <josharian@gmail.com >
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org >
2020-12-10 22:38:39 +00:00
Julie Qiu
d4d67f95c6
README.md: add badge to pkg.go.dev
...
Change-Id: I961972a89cfb5ae5aa71c6b8ba034d8b23b43876
Reviewed-on: https://go-review.googlesource.com/c/sys/+/275888
Trust: Julie Qiu <julie@golang.org >
Run-TryBot: Julie Qiu <julie@golang.org >
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org >
TryBot-Result: Go Bot <gobot@golang.org >
2020-12-07 22:35:42 +00:00
Jason A. Donenfeld
ed752295db
windows/svc/mgr: report exit status when querying services
...
One thing the newer notification API does not do is automatically
provide the service exit code in its notifier response. It requires
querying manually. Unfortunately, we weren't propagating this
information up from the lower level struct, so this commit copys that
information over.
Change-Id: I70c683007ce34ffab6196329acefc8443f921ebe
Reviewed-on: https://go-review.googlesource.com/c/sys/+/274577
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Alex Brainman <alex.brainman@gmail.com >
Trust: Alex Brainman <alex.brainman@gmail.com >
Trust: Jason A. Donenfeld <Jason@zx2c4.com >
2020-12-04 22:54:14 +00:00
Jason A. Donenfeld
c9906e3070
windows: add SubscribeServiceChangeNotifications for service tracking
...
Windows 8+ introduced SubscribeServiceChangeNotifications for simpler
and more reliable service event tracking. This commit adds the function
and related constants:
https://docs.microsoft.com/en-us/windows/win32/services/subscribeservicechangenotifications
Since these functions are only available on Windows 8+, and Go supports
Windows 7+, we mark them with "?" so that the caller can handle graceful
degradation.
Change-Id: Ibb9708bbe797408701c70b4b1c715381f33cb8ee
Reviewed-on: https://go-review.googlesource.com/c/sys/+/274576
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Alex Brainman <alex.brainman@gmail.com >
Trust: Alex Brainman <alex.brainman@gmail.com >
Trust: Jason A. Donenfeld <Jason@zx2c4.com >
2020-12-04 22:54:10 +00:00
Jason A. Donenfeld
9a0d5dbcff
windows/mkwinsyscall: account for non-"err" return values when processing "?"
...
The "?" code assumed that the error value was always called "err", when
in reality it might be called something different (like "ret") or even
entirely absent. This commit makes the templating robust to that. At the
same time, we move a lot of the complexity out of the actual templates
and into helper functions, so that this remains easy to read.
Change-Id: I939d56413a24f0e3e1bbf13da5adf13e9401747a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/275472
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 >
2020-12-04 22:54:03 +00:00
Tobias Klauser
69691e4674
unix: remove ineffectual //go:linkname directives
...
For golang/go#42938
Change-Id: I9d68a2436f3ce7402b3c6517a630d0272cf39071
Reviewed-on: https://go-review.googlesource.com/c/sys/+/274573
Trust: Tobias Klauser <tobias.klauser@gmail.com >
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Matthew Dempsky <mdempsky@google.com >
2020-12-02 21:35:21 +00:00
Tobias Klauser
ef89a241cc
unix: add SizeofIovec on darwin
...
Change-Id: I50909f3b731b4c0ef7f37788e8132930bb865c2b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/274452
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-01 14:50:00 +00:00
Tobias Klauser
760e229fe7
unix: test anyToSockaddr without creating actual socket
...
Test_anyToSockaddr on linux needs to create a socket with the given
domain, type and protocol in order to test anyToSockaddr. Depending on
kernel version, permission and other factors, a given combination might
not be available on the system that runs the test, as is e.g. the case
for AF_CAN/SOCK_DGRAM/CAN_J1939 on several builders after CL 272767.
The only reason to create the socket is to be able to get the socket
protocol in anyToSockaddr using GetsockoptInt(..., SO_PROTOCOL). Move
this implementation into a wrapper func which can be overriden in tests
to with a func unconditionally returning the protocol under test. This
makes the test less dependent on the system it runs on and should fix
the builders broken by CL 272767.
While at it also removed the unused SocketSpec type in
syscall_internal_bsd_test.go and remove an unnecessary error var
declaration.
Change-Id: Ie8754cf795fa96980b29ae43777f698cd86ae863
Reviewed-on: https://go-review.googlesource.com/c/sys/+/274046
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-11-30 17:19:29 +00:00
Boshi Lian
111129e158
windows: correct CertOpenStore to expect a 0 return value on failure
...
According to [1], this function returns NULL when it errors, rather than
INVALID_HANDLE_VALUE, which other Win32 functions return. Quick reversing
indicates that [1] is correct, as there's a `xor eax, eax` in the error
paths of the function just before jumping to the epilogue.
[1] https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certopenstore#return-value
Change-Id: Iafe3b9c78e92c9c5adb8d14a434e11b58f59f19b
GitHub-Last-Rev: 5fcd21d889
GitHub-Pull-Request: golang/sys#92
Reviewed-on: https://go-review.googlesource.com/c/sys/+/273446
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com >
Reviewed-by: Alex Brainman <alex.brainman@gmail.com >
Trust: Alex Brainman <alex.brainman@gmail.com >
Trust: Jason A. Donenfeld <Jason@zx2c4.com >
2020-11-30 07:27:48 +00:00
Jason A. Donenfeld
7719067198
windows: add DLL directory search path manipulation functions
...
A whole class of DLL hijacking attacks can be avoided with a dance like:
SetDllDirectory("")
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32)
For applications who want to opt into this better secure posture, this
commit adds the function definitions to do so.
Reference:
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setdlldirectorya
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-setdefaultdlldirectories
Change-Id: I9b6d4e414a80a689b31b9b43a2d5c72de4813c39
Reviewed-on: https://go-review.googlesource.com/c/sys/+/273606
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 >
2020-11-26 23:39:18 +00:00
Jason A. Donenfeld
f88b827b86
windows: add Token.IsRestricted helper
...
This adds an additional helper method to Token to determine whether or
not it's a restricted one, by using:
https://docs.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-istokenrestricted
Change-Id: I1f2d051450524c22665c4bb99f5948b375b5e199
Reviewed-on: https://go-review.googlesource.com/c/sys/+/272107
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Alex Brainman <alex.brainman@gmail.com >
Trust: Alex Brainman <alex.brainman@gmail.com >
Trust: Jason A. Donenfeld <Jason@zx2c4.com >
2020-11-26 22:47:55 +00:00
Sauci
a4b67b81d3
unix: add J1939 protocol support on socketcan interface
...
Fixes golang/go#42797
Change-Id: Ia7be73e53438dec80903c95de0e6829005741a0f
GitHub-Last-Rev: bc35835339
GitHub-Pull-Request: golang/sys#91
Reviewed-on: https://go-review.googlesource.com/c/sys/+/272767
Run-TryBot: Matt Layher <mdlayher@gmail.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com >
Reviewed-by: Matt Layher <mdlayher@gmail.com >
Trust: Tobias Klauser <tobias.klauser@gmail.com >
2020-11-26 14:47:05 +00:00
Tobias Klauser
f84b799fce
unix: add Pipe2 on dragonfly
...
The pipe2 syscall is available since DragonflyBSD 4.2, see
https://www.dragonflybsd.org/release42/
Change-Id: I94631fd64ee731e416049cac5f3d15544f1337dd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/271177
Trust: Tobias Klauser <tobias.klauser@gmail.com >
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com >
Reviewed-by: Matt Layher <mdlayher@gmail.com >
TryBot-Result: Go Bot <gobot@golang.org >
2020-11-19 10:28:17 +00:00
Matt Layher
a01c418693
unix: add Linux MPLS tunnel constants for use with rtnetlink APIs
...
Change-Id: Ic990c616c416e7bfe98e68eb74bab2810a1126ef
Reviewed-on: https://go-review.googlesource.com/c/sys/+/271137
Trust: Matt Layher <mdlayher@gmail.com >
Run-TryBot: Matt Layher <mdlayher@gmail.com >
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com >
2020-11-18 18:29:58 +00:00
Matt Layher
ade898ef86
unix: add Linux lwtunnel constants for use with rtnetlink APIs
...
Change-Id: Ibe39b315321c18916870dcfc97b083a18b91be2b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/271077
Run-TryBot: Matt Layher <mdlayher@gmail.com >
TryBot-Result: Go Bot <gobot@golang.org >
Trust: Matt Layher <mdlayher@gmail.com >
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com >
2020-11-18 18:01:33 +00:00
Jason A. Donenfeld
ba5294a509
windows/svc/mgr: fetch service sid type in Config()
...
Currently, doing s.UpdateConfig(s.Config()) will destroy the service,
because s.Config() fails to populate the SidType member, but
UpdateConfig will set the SidType, so that expression effectively zeros
out the SidType. Fix this by having Config() fetch the SidType in the
same way that it fetches the other additional fields there, such as
DelayedStartUp.
Change-Id: Idb917ef1e942020499b411b7777b995c29f0e7d2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/270897
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 >
2020-11-17 22:26:35 +00:00
Jason A. Donenfeld
d9b008d0a6
windows: add SetFileInformationByHandle
...
We already have GetFileInformationByHandle, so this adds the
corresponding SetFileInformationByHandle, which has a nearly identical
function signature to GetFileInformationByHandleEx, which is
convenient.
We also add the enum for the various classes of data.
Reference: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfileinformationbyhandle
Change-Id: I3d3e8b99e616b512df4d57c8c521e14294c93a6d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/270757
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org >
Trust: Brad Fitzpatrick <bradfitz@golang.org >
Trust: Jason A. Donenfeld <Jason@zx2c4.com >
2020-11-17 17:04:46 +00:00
Jason A. Donenfeld
cc9327a14d
windows: fix signature of GetFinalPathNameByHandle
...
The function name should be GetFinalPathNameByHandle, not
GetFinalPathNameByHandleW, and it should take types in windows, not in
syscall. This was merged so recently that I think we can just fix it up
here.
Updates golang/go#41686
Fixes CL 264577
Change-Id: Ib84df5b5a9c2df5ad4344884874afa152e9ca554
Reviewed-on: https://go-review.googlesource.com/c/sys/+/270459
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: Brad Fitzpatrick <bradfitz@golang.org >
Reviewed-by: Alex Brainman <alex.brainman@gmail.com >
2020-11-16 19:43:26 +00:00
Jason A. Donenfeld
3a5be02000
windows: add SetKernelObjectSecurity
...
Straight forward function for adjusting object DACLs if you already have
a handle to them.
https://docs.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-setkernelobjectsecurity
Change-Id: I744f7efa53ad00cf0ae134cda1257a61bd3f9c5e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/270458
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 >
2020-11-16 19:22:46 +00:00
Jason A. Donenfeld
a8a4db9169
windows: add missing return value to SetSecurityInfo
...
This was dangerously left out before, so now we add it.
Change-Id: I71640afa901aab289658644cb533086c91908289
Reviewed-on: https://go-review.googlesource.com/c/sys/+/270457
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 >
2020-11-16 19:22:36 +00:00
Tobias Klauser
c061ba923f
unix: define isBigEndian for all GOARCHes supported by gccgo
...
For golang/go#18031
For golang/go#37443
Change-Id: I49dabb362592bb61532a0c4f193919c3f2036af3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/270317
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 >
2020-11-16 16:16:45 +00:00
Jason A. Donenfeld
12cec1faf1
windows: add IsWow64Process2 for detecting x86 on arm
...
The original IsWow64Process returns false on arm, always, and so
IsWow64Process2 was added to account for this scenario. This isn't
available on older versions of Windows, so we mark it as such using the
new '?' notation. Finally, we add a test to make sure this all works and
does the expected thing on different versions of Windows.
Change-Id: Ic0412578cfb3f4cf6c9dc92a0028abc579bf6c85
Reviewed-on: https://go-review.googlesource.com/c/sys/+/269077
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 >
2020-11-13 23:30:24 +00:00
Jason A. Donenfeld
cec591ef54
windows: add potentially absent function marker to mkwinsyscall
...
Some functions that x/sys/windows will eventually have won't be
available on older versions of Windows, and in general we can expect
Microsoft to continue to add functions to newer builds of Windows
10. Therefore, we introduces a new notation for marking functions that
might not exist, letting the caller handle the situation without a
panic.
Change-Id: Ia66bf4aab601357198872c5cd29b6ca7c3bc6969
Reviewed-on: https://go-review.googlesource.com/c/sys/+/269938
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: Brad Fitzpatrick <bradfitz@golang.org >
Trust: Jason A. Donenfeld <Jason@zx2c4.com >
2020-11-13 23:29:40 +00:00
Jason A. Donenfeld
83cfaa298f
windows: add DLLError.Unwrap function
...
Because we're expecting for future functions to be unavailable, we
should add an Unwrap() function to the DLLError struct, so that people
can test for this situation easily via:
if errors.Is(err, windows.ERROR_PROC_NOT_FOUND) { ... }
DLLError already was wrapping the underlying Errno error, but never got
the Go 1.13 helper method.
Update golang/go#42584
Change-Id: Ib916ddd55a2de29f988edaaf82f2ae0ce1b18e3b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/269937
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 >
2020-11-13 22:15:40 +00:00
Tamir Duberstein
0a15ea8d9b
*: use more precise build tags
...
s/!gccgo/gc/ in files which use gc-syntax assembly.
Change-Id: Iafc006cd60ad0e429cff182a05c790d80c380802
Reviewed-on: https://go-review.googlesource.com/c/sys/+/269717
Run-TryBot: Ian Lance Taylor <iant@golang.org >
TryBot-Result: Go Bot <gobot@golang.org >
Reviewed-by: Ian Lance Taylor <iant@golang.org >
Trust: Than McIntosh <thanm@google.com >
2020-11-13 13:57:34 +00:00