Commit Graph

1077 Commits

Author SHA1 Message Date
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
Jason A. Donenfeld
5cba982894 windows: add missing error constants from setupapi.h
While most of our constant gathering can be automated, some win32 error
constants come from unusual corners of the WDK, such as setupapi.h. We
add those constants to a new file, so that they can be referenced as
constants by Go programs.

Change-Id: I9bce7fddf7aaa00204e6048b53f14e6ba18d5f13
Reviewed-on: https://go-review.googlesource.com/c/sys/+/268358
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: Simon Rozman <simon@rozman.si>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2020-11-12 07:39:58 +00:00
Jason A. Donenfeld
35f3e6cf4a windows: cleanup mkwinsyscall argument list
CL 258038 improperly added a weird custom type to mkwinsyscall, rather
than doing the norm with wrapper functions. So, we revert the change to
mkwinsyscall and add the proper wrapper function to do the type
conversion.

Change-Id: I98134e4ce6bf4b52e1384fe84bddeedb00e18c0b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/268777
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-11-10 21:10:18 +00:00
Tobias Klauser
215b40eba5 unix/linux: update Dockerfile to Go 1.15.4
No changes in generated files.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Change-Id: Ibbb81f8ef48d43d7fb620fec57c3ac779ebf0e11
Reviewed-on: https://go-review.googlesource.com/c/sys/+/268357
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-09 16:54:25 +00:00
Jason A. Donenfeld
4d91cf3a1a windows: add missing page flag constants
We already have some of the most basic ones, but there are some notable
gaps that make coding programs that poke at page permissions a bit more
cumbersome to write.

Reference: https://docs.microsoft.com/en-us/windows/win32/memory/memory-protection-constants

Change-Id: Ib7d1ef2e2f6d92f6eec230b7785f579e4a26fbae
Reviewed-on: https://go-review.googlesource.com/c/sys/+/268137
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: Simon Rozman <simon@rozman.si>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2020-11-07 08:05:50 +00:00
Alex Brainman
db71ae6646 windows/svc/mgr: rename service in TestMyService
TestMyService uses the same service name as service in
golang.org/x/sys/windows/svc.TestExample.

https://build.golang.org sometimes schedules TestMyService and
TestExample to run at the same time. If that happens, tests fail,
because they were not designed to run in parallel.

This CL renames service in TestMyService, so it does not clash with
TestExample.

Fixes golang/go#42211

Change-Id: I928c2ebbae77de3540f5ce16948fb96eeeed836d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/267604
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-11-06 08:11:18 +00:00
Alex Brainman
1dbcb44a4e windows/svc: stop service before deletion in TestExample
TestExample normally stops and deletes test service at the end of the
test. But, if TestExample does not complete for some reason, test
service might remain running and installed.

There is some code that deletes "left over" test service before starting
the test. But that code fails, if service is running. Deletion only
works, if service is not running. This CL adds code to stop the "left
over" service so it can be deleted.

Update golang/go#42211

Change-Id: I826dd587063265c5b96076668c3704c0a7eaa3d8
Reviewed-on: https://go-review.googlesource.com/c/sys/+/267603
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-11-06 07:48:44 +00:00
Daniel Kessler
80594f20fa windows: add CertDeleteCertificateFromStore
https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-certdeletecertificatefromstore

Change-Id: I59c6e9c75de91176b064c0e16eeb6ea2fda7ffcd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/267601
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2020-11-06 07:34:44 +00:00
Lehner Florian
da207088b7 unix: update IFLA consts on linux
Update the IFLA_* consts from /usr/include/linux/if_link.h

Change-Id: I8a751f9237c78737691fb425dcbc4be6e52364d9
Reviewed-on: https://go-review.googlesource.com/c/sys/+/266977
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2020-11-01 10:28:59 +00:00
Joel Sing
201ba4db24 cpu: make x/sys/cpu build on non-linux mips64x
Update golang/go#40995

Change-Id: Icab9865e59350c11da32bf8af2d0830001e41323
Reviewed-on: https://go-review.googlesource.com/c/sys/+/265959
Trust: Joel Sing <joel@sing.id.au>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-29 08:09:32 +00:00
Meng Zhuo
3518587229 windows: add GetFinalPathNameByHandleW
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew

Fixes #41686

Change-Id: I207676364a3abc8658498bcd060c8f9694161867
Reviewed-on: https://go-review.googlesource.com/c/sys/+/264577
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-29 02:06:03 +00:00
Tobias Klauser
c5abc1b1d3 unix: revert zsysnum_darwin_*.go deletion from CL 250437
CL 250437 removed the zsysnum_darwin_*.go files containing the SYS_*
contants for macOS. This was done assuming that users should migrate
away from direct syscalls to libSystem wrappers. Let's not force users
of this package on when they want to do that and re-add the
zsysnum_darwin_*.go files and mark the consts as deprecated.

We can still remove these once macOS actively prevents use of direct
syscalls.

Fixes golang/go#41868

Change-Id: Ie5edf135154f24e3efa4811ef2253ad1353ba132
Reviewed-on: https://go-review.googlesource.com/c/sys/+/265857
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-28 21:52:40 +00:00
Bill O'Farrell
708e7fb298 cpu: add support for zos/s390x
This adds feature detection that works on the s390x running zos.
There are some differences with Linux (no hwcap, facilities vector available in-memory).
These changes should not affect other platforms.

Fixes golang/go#41984.

Change-Id: Ieabbfafd07367a346a4d279dde0f00aa3fc4321b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/262477
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Trust: Martin Möhrmann <moehrmann@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-10-28 09:49:53 +00:00
Ben Cartwright-Cox
0fcbb8f492 unix: add linux constants and types for PPS devices ioctl's
After trying to implement Pulse Per Second devices
in go, I found that the ioctl values and structs
where not in the unix package yet:

~# strace ppstest /dev/pps0 |& grep ioctl
ioctl(3, PPS_GETPARAMS, 0xbee63b18)     = 0
ioctl(3, PPS_GETCAP, 0xbee63b84)        = 0
ioctl(3, PPS_GETPARAMS, 0xbee63b18)     = 0
ioctl(3, PPS_SETPARAMS, 0xbee63b18)     = 0
ioctl(3, PPS_FETCH, 0xbee63b00)         = 0
ioctl(3, PPS_FETCH, 0xbee63b00)         = 0
ioctl(3, PPS_FETCH, 0xbee63b00)         = 0
ioctl(3, PPS_FETCH, 0xbee63b00)         = 0
ioctl(3, PPS_FETCH, 0xbee63b00)         = 0

This commit should add them.

Change-Id: If1225ab7c4c38aad5d8ae841d1fdebfa45055549
GitHub-Last-Rev: c1469112b8
GitHub-Pull-Request: golang/sys#90
Reviewed-on: https://go-review.googlesource.com/c/sys/+/265217
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2020-10-27 14:07:54 +00:00
Tobias Klauser
9d1ec526b7 unix: add anyToSockaddrGOOS on dragonfly
CL 264638 forgot to add func anyToSockaddrGOOS on dragonfly which breaks
the build.

Change-Id: I35d28a972c8c541dea8db0349b7e1440f5ec2fd7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/265377
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-10-27 13:05:17 +00:00
Tobias Klauser
e1471140ff unix: implement AF_SYSTEM/AF_SYS_CONTROL sockets on darwin
See https://developer.apple.com/documentation/kernel/sockaddr_ctl for
details.

AF_SYSTEM is darwin-specific, so the BSD-specific anyToSockaddr func
needs to call GOOS-specific funcs which return nil, EAFNOSUPPORT on all
BSD platforms but darwin.

For golang/go#41868

Change-Id: Id7794aba5988dd9511053b76be5efeb66c104a26
Reviewed-on: https://go-review.googlesource.com/c/sys/+/264638
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-10-27 09:04:13 +00:00
Tobias Klauser
119d4633e4 unix: add Ioctl{Get,Set}IfreqMTU on darwin
For golang/go#41868

Change-Id: I9fb8f5eee933488e4c63aaa757059b8cea4d9629
Reviewed-on: https://go-review.googlesource.com/c/sys/+/264637
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-10-26 17:38:27 +00:00