This adds the missing tpacket_hdr_v1 struct, which is needed to read
tpacket_block_desc (hdr member, which is a union and therfore defined as
[40]byte). This doesn't modify block_desc so existing implementations
keep working.
Caveat: Although TpacketBDTS has a usec member, this will contain nsec
in case of tpacket v2 or v3.
Change-Id: I772939fe56cf56fc09cf4acf4013b23beb6e03c7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174861
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Port mksysctl_openbsd.pl Perl script to mksysctl_openbsd.go.
mkall.sh script is modified to run mksysctl_openbsd.go. Running
mkall.sh does not generate any git diff besides the command
name in comments of generated files. Any missing build tag is
also added in generated files.
Fixesgolang/go#27779
Change-Id: I9f946d2818feb31e710029927f089904c5e272cf
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174127
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The two functions have the same levels of compatibility, but this latter
one gives us access to the process ID, which is important for things
like WFP whitelisting. The change required is fairly trivial too.
Change-Id: Ifb6b3ee3e897202b9cffa1388c53c25cbcfede61
Reviewed-on: https://go-review.googlesource.com/c/sys/+/173666
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This adds wrappers around name_to_handle_at and open_by_handle_at.
Requires root (or CAP_DAC_READ_SEARCH, rather) to run tests, which at
least some of our builders have.
bradfitz@go:~/src/golang.org/x/sys/unix$ go test -c && sudo ./unix.test -test.run=OpenBy -test.v=true
=== RUN TestOpenByHandleAt
=== RUN TestOpenByHandleAt/clone=false
=== RUN TestOpenByHandleAt/clone=true
--- PASS: TestOpenByHandleAt (0.00s)
syscall_linux_test.go:546: mountID: 22, handle: size=8, type=1, bytes="\x9e\x1e\b\x00~\x8c\xe5\x9d"
--- PASS: TestOpenByHandleAt/clone=false (0.00s)
syscall_linux_test.go:568: opened fd 3
--- PASS: TestOpenByHandleAt/clone=true (0.00s)
syscall_linux_test.go:568: opened fd 3
PASS
Fixesgolang/go#30537
Change-Id: Ia48a8faab2fee665d88a16d81a3a0c1504b129ce
Reviewed-on: https://go-review.googlesource.com/c/sys/+/173357
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The pledge code is platform specific, but in no way architecture specific.
As such, drop the +build rule that ties it to specific architectures.
While here also rename openbsd_pledge.go and openbsd_unveil.go so we can
drop the openbsd specific build tags.
Change-Id: I7d83796c8f9b46afe2a6790620205df5f7f3d738
Reviewed-on: https://go-review.googlesource.com/c/sys/+/173677
Reviewed-by: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
While the types_windows file previously had a small handful of types,
this forced application code to have an awkward mixture of artisanal
error constants and factory-ready ones. This commit adds the missing
ones and separates them into a new file, since they are quite numerous.
These also preserve the order of winerr.h, which should make it somewhat
easier to import new ones in the future.
Fixesgolang/go#31360
Change-Id: If2abc507a8884ec1641f0b17fe0c612a950d3644
Reviewed-on: https://go-review.googlesource.com/c/sys/+/170918
Reviewed-by: Jason Donenfeld <Jason@zx2c4.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
A number of IFLA_* constants have been added since the last time this
list was generated. In addition, IFLA_INFO_* is a different enum, so
we'll add the missing values for there as well.
Change-Id: Ie20b1f49a95cbc10daf0be2e5b5d719782eda68f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/171698
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
We already have all the structs and constants for async I/O, and the
various functions of x/sys/windows take the right parameters. But we're
missing the final step of any ordinary async I/O routine: getting the
result of overlapped I/O. Without this, the rest of the plumbing
supported by this module isn't actually so useful. So add this small
oversight.
Change-Id: I0ce1a71bce06bc81a83f3b0ca10ad9c4b67af726
Reviewed-on: https://go-review.googlesource.com/c/sys/+/168521
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The previous selection was a bit haphazard, and defining random
constants in an application and combining those with existing constants
in this library looks kind of weird. So instead let's add the actual set
of flags, instead of the strange prior assortment.
Change-Id: I6ca266cd80aa7a43e93e969e1dbb09c8c7bf12c7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/168520
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
OpenBSD (like NetBSD) uses sysctl with struct clockinfo to get clock
rate information from the kernel. Add type Clockinfo and the
SysctlClockinfo function to query this information.
Change-Id: I35070a82b8de23dcd7592e8654dcc5eeee143b5b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/168057
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
The security API is already quite extensive, but for some strange
reason, this essential and useful function was left out of the initial
port. So, we add it here, along with the relevant constants and a test
case.
Change-Id: I99568703565addf15603480f11b0edafdfc1718f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/167378
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The %WINDIR% variable is an odd choice and not even entirely reliable.
Since Windows 2000, there has been a specific function for determining
this information, so let's use it. It's also a useful function in its
own right for folks who want to launch system tools in a somewhat safe
way, like netsh.exe.
Updates golang/go#14959
Updates golang/go#30642
Change-Id: Ic24baf37d14f2daced0c1db2771b5a673d2c8852
Reviewed-on: https://go-review.googlesource.com/c/sys/+/165759
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
These DLLs, well advapi32.dll in particular, are vulnerable to classic
DLL directory injection attacks. The rest of x/sys/windows moved over to
the safe system loader, but apparently the svc package was forgotten.
This tidies up that oversight.
Change-Id: I330fa752cf2d49ccc5cf1bd60fb4bd612bd2b6b0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/165758
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Add GetsockoptTpacketStats and GetsockoptTpacketStatsV3 to get tpacket
statistics (for TPACKET_V2 and TPACKET_V3).
Add SetsockoptTpacketReq and SetsockoptTpacketReq3 to set up tpacket
v2/v3 ring buffers.
Change-Id: Ic2870be22be7d74141f682e515a682df28e1c814
Reviewed-on: https://go-review.googlesource.com/c/sys/+/165558
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Follow CL 165217 which did this for package syscall.
Android O seems to require Pipe to call the pipe2 system call.
But kernel version 2.6.23 only supports pipe, not pipe2.
So try pipe2 first, then fall back to pipe.
Updates golang/go#30549
Change-Id: Icf21433fa046ff137c0265fa96410229def482f7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/165297
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This teaches unix/mksyscall.go about mapping uint64 to syscall
arguments, similar to existing handling of int64.
Change-Id: I536b4b09bbf6a8e3016565a4a04d2b9d32cbc624
Reviewed-on: https://go-review.googlesource.com/c/164664
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>