Commit Graph

738 Commits

Author SHA1 Message Date
Jason A. Donenfeld
7fc4e5ec14 windows: add GUID handling functions
Virtually every project that works with x/sys/window's GUIDs winds up
rolling their own version of this in one way or another. So let's add
the correct win32 wrappers for it, so that these are always generated,
parsed, and converted in the uniform correct way.

Change-Id: I35f4b4ab5fc681d3e16fc5bbaf2cb20031eb3f12
Reviewed-on: https://go-review.googlesource.com/c/sys/+/180938
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-06-06 20:33:20 +00:00
Jason A. Donenfeld
5da285871e windows: add accessor for duration since boot
In order to deal with boot time race conditions, sometimes it is
useful to determine the time since boot.

Change-Id: Ibc907b49a9b072b3ef3b6c94eec7e2e6428943ba
Reviewed-on: https://go-review.googlesource.com/c/sys/+/180899
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-06-06 16:51:38 +00:00
Takuto Ikuta
79a91cf218 windows: add constants for access rights
This CL adds access rights constants for process and thread.
https://docs.microsoft.com/en-us/windows/desktop/procthread/process-security-and-access-rights
https://docs.microsoft.com/en-us/windows/desktop/procthread/thread-security-and-access-rights

Change-Id: I478216cf60c2e082d55a63479781d8f4640c73da
Reviewed-on: https://go-review.googlesource.com/c/sys/+/180697
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-06-06 12:20:18 +00:00
Jason A. Donenfeld
4c4f7f33c9 windows: make it easier to iterate over groups and privileges
Rather than having to write grotesque things like:

    groups, _ := processToken.GetTokenGroups()
    for _, g := range (*[(1 << 28) - 1]windows.SIDAndAttributes)(unsafe.Pointer(&groups.Groups[0]))[:groups.GroupCount] {
        // ...
    }

Users can now write clean things like this:

    groups, _ := processToken.GetTokenGroups()
    for _, g := range groups.AllGroups() {
        // ...
    }

Change-Id: Ief06de6899c497175628ff51b9d6ae55a90d14f1
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178857
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-06-02 01:53:25 +00:00
Alex Brainman
afe098805b windows: delete mkerrors.go
mkerrors.go is called by 'go generate' command to generate
zerrors_windows.go

mkerrors.go executes mkerrors.bash. But mkerrors.bash requires
winerror.h to be present on the system to succeed. And winerror.h is
never present on the system. So executing mkerrors.go always fails.

zerrors_windows.go is never changes. It was changed recently once.
The change before that was in 2014.

This change removes mkerrors.go, so other commands that are part of
'go generate' execution can proceed. If someone needs to update
zerrors_windows.go, they can call mkerrors.bash directly.

Fixes golang/go#32349

Change-Id: I9b3e581e183377201e8f74c2d991d97564f36778
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179582
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Jason Donenfeld <Jason@zx2c4.com>
2019-06-02 01:07:38 +00:00
Joel Sing
4c3a928424 unix: provide linux/riscv64 assembly for syscalls
While the linux/riscv64 port is not yet upstream, most of the syscalls package
already has linux/riscv64 support and this will make testing and development
easier.

Updates golang/go#27532

Change-Id: I6e505be55fdbb2942fb6e4f34c040e7b82809630
Reviewed-on: https://go-review.googlesource.com/c/sys/+/177799
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-31 17:50:56 +00:00
Tobias Klauser
69e3a3a65b unix: fix TestFchmodat on illumos
Like linux/android, illumos doesn't support Fchmodat flags != 0.

The comment already mentions this, so update the condition as well now
that GOOS illumos is known.

Change-Id: Ic6542223129ec5fd8bb56dab3c8a042dc29ec7cc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179362
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-31 13:24:40 +00:00
Alex Brainman
46560c3f3c Revert "windows: make zsyscall_windows.go generatable on non-WSL env"
This reverts commit ad28b68e88.

Reason for revert: It completely breaks 'go generate' on windows

Update golang/go#32349

Change-Id: I4bedc6cf5130eb48c18c3208c8029433407430e4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179580
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-05-31 07:31:56 +00:00
Takuto Ikuta
ad28b68e88 windows: make zsyscall_windows.go generatable on non-WSL env
mkerrors.bash requires a Windows host, as it hard-codes paths like
/mnt/c/Program Files (x86)/Windows Kits.
But this does not allow to generate in non-WSL env.

Currently mkerrors.bash runs earlier than mksyscall_windows.go
when we run `go generate` and it fails on non-WSL env.
So zsyscall_windows.go is not generated in that case.

To fix that, I reoreder of code generation in this CL so that we can
generate zsyscall_windows.go in non-WSL env.

Also update error message in mkerrors.bash.

Change-Id: I04eccdbfe1e1ff56f8c405250f0724000d66d579
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178781
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-30 18:20:44 +00:00
Takuto Ikuta
95d888ea44 windows: add GenerateConsoleCtrlEvent function
ref:
https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent

Change-Id: Id5db1d4c7d73a142405061353f578b1be93dbbb9
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179538
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-30 18:20:36 +00:00
Visweswara R
6a60838ec2 plan9: modify mkall.sh to support zsyscall*.go files generation
Modify mkall.sh to support generation of zsyscall_plan9_{386,amd64,arm}.go
files. This does not generate any git diff as they were manually generated
with the same commands.

Fixes golang/go#29586

Change-Id: I5316fdb46f306974584eee653b439408294ea1cf
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179041
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-05-29 16:45:35 +00:00
Tobias Klauser
5219a1e1c5 cpu: add missing linkname for libc_getsystemcfg on aix/ppc64
This fixes the aix/ppc64 build after CL 179178

Change-Id: Ie8d762b533c05d6ca262030b34ae137140896d44
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179317
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2019-05-29 13:00:38 +00:00
Takuto Ikuta
cc920278c2 windows: add SetInformationJobObject functions
This CL also adds some struct for the function.
https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_jobobject_extended_limit_information
https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_jobobject_basic_limit_information
https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_jobobject_basic_ui_restrictions
https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-io_counters

Change-Id: Ie3b7570fc344a25ad2a39129b74434b8baa1eed9
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179039
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-29 11:55:39 +00:00
Takuto Ikuta
854af27f14 windows: add functions for priority class
took const value from
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-setpriorityclass
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getpriorityclass

Change-Id: I376bb8e1f5de8968177512857d60169cb7b7c776
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179038
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-29 08:50:34 +00:00
Brad Fitzpatrick
3626398d77 cpu: don't depend on the golang.org/x/sys/unix package for AIX
gccgo support can happen in a future CL.

Updates golang/go#32102

Change-Id: Ic9e8d7b3e413079d277bdba565551845a2b78121
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179178
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2019-05-28 18:36:47 +00:00
Yuval Pavel Zholkover
adf421d2ca unix: fix Signalfd function signature on linux
The kernel raw syscall takes an additional parameter specifying
the size of the Sigset_t parameter, returns a file descriptor and sets errno.

Add a uintptr maxSize parameter, adjust the return to be (newfd int, err error).
Add the _NSIG #define and a wrapper to call with maxSize set to _C__NSIG/8 as done
in glibc/musl.

Change-Id: I277db0aab5c12364533c26ea800b7f394ec83ae4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178858
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-28 01:25:30 +00:00
Takuto Ikuta
9cd6430ef9 windows: add ResumeThread function
ref:
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-resumethread

Change-Id: I114846c85bc5b8eb8dc742fdc3bdacb7b28cddaa
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179037
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-27 10:42:16 +00:00
Jason A. Donenfeld
ea4c425e90 windows: allow Windows-style printf debugging via MessageBox
I realize that at this time, x/sys/windows is most certainly not aiming
to be some sort of UI library or anything remotely close to that.
However, MessageBox is sort of the one universal Windows API that's used
even for console programs. It's *the* classic debugging helper. It's
even pretty customary for console programs to display their usage
message in a message box rather than stdout. I realize this might be
somewhat disturbing to consider if you're in the blissful Unix utopia,
but on Windows, this is just sort of how things roll. Easy access to
MessageBox() is important.

Change-Id: I16183b69e8a27a5ddaf73d1d4e106bb7b201a6f0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178899
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-27 09:26:32 +00:00
Jason A. Donenfeld
56c252d053 windows: add ShellExecute
This is the way to do things like execute a process elevated with UAC
and interact with that whole system. It turns out to be quite important
for writing Windows software.

Change-Id: I5e05dc9b89ea308d42ac86ba563fd01922fc940c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178898
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-05-27 09:25:20 +00:00
Jason A. Donenfeld
791d8a0f4d windows: allow determining if running 32-on-64bit
This is useful for determining whether or not it's going to be possible
to install device drivers, for example.

Change-Id: I628c6f3279b16832bcd6b4ca66dfa3e7334b88ff
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178897
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-05-26 05:23:59 +00:00
Jason A. Donenfeld
2219a0101f windows: add SID getter functions for the various components
These allow actual inspection of SIDs. For example, it might be
desirable to iterate through the group SIDs in order to find one set by
SERVICE_CONFIG_SERVICE_SID_INFO:

    for _, g := range groups {
        if g.Attributes != windows.SE_GROUP_ENABLED|windows.SE_GROUP_ENABLED_BY_DEFAULT|windows.SE_GROUP_OWNER {
            continue
        }
        if !g.Sid.IsValid() {
            continue
        }
        if g.Sid.IdentifierAuthority() != windows.SECURITY_NT_AUTHORITY {
            continue
        }
        if g.Sid.SubAuthorityCount() < 6 || g.Sid.SubAuthority(0) != 80 {
            continue
        }
        sid = g.Sid
        break
    }

Another usage of the APIs added would be to find if a user is in the
administrator group with either an elevated or unelevated token:

    isAdmin := false
    for _, g := range groups {
        if g.Attributes&(windows.SE_GROUP_ENABLED|windows.SE_GROUP_USE_FOR_DENY_ONLY) == 0 {
            continue
	}
        if !g.Sid.IsWellKnown(windows.WinBuiltinAdministratorsSid) {
            continue
	}
        isAdmin = true
        break
    }

Change-Id: I8f8dc8d37b71ec58fd51e21ea1f1b3aada6d66b0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/177841
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-05-26 03:56:09 +00:00
Takuto Ikuta
e44a3b55db windows: add SetErrorMode function
Change-Id: I79cd7d7e5b49b55281e63131388bc4693b7eed1e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178779
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-26 03:10:47 +00:00
Jason A. Donenfeld
dbbf3f1254 windows: add IP() accessor to SocketAddress type
This is what everybody winds up doing with this object, so we make it
somewhat nicer than copying and pasting this everywhere or using type
aliases.

Change-Id: I3e12395cadfe212a7d01ce86478de9486383729a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178577
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-24 15:25:21 +00:00
Takuto Ikuta
c3d486d151 windows: add JobObject functions
Change-Id: Ib8c3fe735ed72e3b211328c89170eb03fc64b102
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178777
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-24 15:12:52 +00:00
Tobias Klauser
abf6ff7781 unix: add MCAST_* constants on linux
This will also add two BPF_* consts which weren't added as part of
CL 174978 because they were generated before the Linux version update
in CL 175158.

Change-Id: I5dfecbecb9d94b56d01490a5f17f2250ad5b30d4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178658
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-24 12:25:48 +00:00
Tobias Klauser
0e01d883c5 unix: add RawSockaddrDatalink on aix
This is already part of package syscall, so add it to x/sys/unix as
well.

Change-Id: I2eb015dd439d37894519858f010cc45d6e3da50a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/178657
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-23 14:25:57 +00:00
Jason A. Donenfeld
8097e1b27f windows: do not query library for inline functions
The GetCurrent*Token variety of functions are actually implemented as
inline functions in the header files of the SDK. Attempting to call out
to these as library functions is an error. This commit also adds a test
to ensure that these work as expected.

Change-Id: I105f1ca1a8936114fe61bc22188200c31f240a23
Reviewed-on: https://go-review.googlesource.com/c/sys/+/177840
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-22 04:47:17 +00:00
Jason A. Donenfeld
30999d67c8 windows: add missing service constants
This adds a number of useful comments for ChangeServiceConfig2. It looks
like the MingW headers have these in two different places, awkwardly,
and whoever imported these constants missed the second half of them,
whereas the real Microsoft header files have them all together in one
place.

Change-Id: I723c4bcd86e5a1b905cb738c5c2b49805a354af4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/177842
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-22 04:46:51 +00:00
Jason A. Donenfeld
c46e0d965b windows/registry: do not generate unaligned loads
Byte slices aren't necessarily aligned, which means casting them to
integer types and dereferencing may result in an unaligned load. This
is mostly fine on Intel but isn't necessarily fine on other platforms.
Any good compiler will generate optimal code for the platform using the
pattern of this commit.

Change-Id: I6dd8debad1cb850b8562ee96ae0f366d1f822a6f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/176857
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-22 03:42:48 +00:00
Tobias Klauser
c432e742b0 unix: remove unused stringsFromByteSlice for tests on aix
stringsFromByteSlice is only used in xattr_test.go which isn't enabled
for aix.

Change-Id: I95948cbac285d8efe7f5299de85625cb7541e906
Reviewed-on: https://go-review.googlesource.com/c/sys/+/177839
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-05-20 20:13:01 +00:00
Clément Chigot
ad400b1274 unix: remove StTimespec type on AIX
On AIX, Stat_t's fields dealing with time are of type StTimespec while
all other GOOS are using Timespec.
StTimespec and Timespec are the same on ppc but not in ppc64. Therefore,
values returned by ppc64 syscalls need to be adjusted in order to
allow the use of Timespec instead of StTimespec.

Fixes golang/go#32073

Change-Id: I0c212bf1741a27c49e995bf928d4941b6d583e54
Reviewed-on: https://go-review.googlesource.com/c/sys/+/177838
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-20 16:14:52 +00:00
Jason A. Donenfeld
61b9204099 windows: add functions for dealing with elevated tokens
These are required when dealing with UAC or launching processes as
elevated administrators on behalf of other users.

Change-Id: If256c838b1f0202a8703d91496ffdbe16be3a700
Reviewed-on: https://go-review.googlesource.com/c/sys/+/176858
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-05-16 11:00:30 +00:00
Jason A. Donenfeld
cedb8e16d1 windows: add token group adjustment function
We have the useful AdjustTokenPrivileges, but we don't have the equally
as useful AdjustTokenGroups function. So this CL adds it.

Change-Id: Ic09b4688ee5ec7f1a626a21216a85b075961aad5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/176859
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-05-16 10:27:23 +00:00
Yuval Pavel Zholkover
cab07311ab unix: fix TestStatFieldNames on aix and TestUtimesNanoAt on darwin
Following CL 175157 which renames Stat_t time fields to [AMCB]tim.

Updates golang/go#31735

Change-Id: I0791c59bab307d237b315c1b919265902f7d9917
Reviewed-on: https://go-review.googlesource.com/c/sys/+/177437
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-16 01:48:33 +00:00
Yuval Pavel Zholkover
87c872767d unix: rename Stat_t time fields to [AMCB]tim
Birthtime/Birthtimespec was renamed to Btim to match the others.
Also unexport the [ACMB]tim_ext fields on freebsd 386.
Update mkpost.go to do the renames.

Ran the following on the existing ztypes_*.go files:

  #!/bin/sh
  set -e

  for f in ztypes_*.go; do
      cat $f | go run mkpost.go | gofmt > $f.tmp
      mv $f.tmp $f
  done;

  cat ztypes_freebsd_386.go | env GOOS=freebsd GOARCH=386 go run mkpost.go | gofmt > ztypes_freebsd_386.go.tmp
  mv ztypes_freebsd_386.go{.tmp,}

Fixes golang/go#31735

Change-Id: I15765d690ee8d2be6bbb37f465322bc019722e08
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175157
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-15 19:05:49 +00:00
Jason A. Donenfeld
06a5c49444 windows: add token environment functions
This brings the x/sys package into parity with the capabilities provided
indirectly in CL 176619, and adds a helper to make it useful.

Change-Id: I81f2d205bbb0c2b2c530b2bd991c1e6ff30cc94e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/176620
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-05-15 12:05:40 +00:00
Jason A. Donenfeld
f91f9b37d0 windows: add basic WTS functions for windows/svc usage
The svc package exposes svc.SessionChange, but it's impossible to do
anything with them without these structures, and without being able to
enumerate them prior to events, the events themselves aren't useful, so
we add the enumeration functions as well.

Change-Id: I14c932dfe97c6712fd4868c1b3a0e3a61a6a562c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/176623
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-05-15 10:53:50 +00:00
Jason A. Donenfeld
24a5b2278f windows: add service notification support
This lays the groundwork for service notification and tracking by adding
the required API functions. Users can make notifiers directly using it,
or later if we're feeling ambitious, we can see if we can come up with a
generalized solution in x/windows/svc.

Change-Id: I80503cc27970fbb23bf17cd8bc50eaa7787aa6bd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/176624
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-05-15 10:31:49 +00:00
Jason A. Donenfeld
3a4b5fb9f7 windows: add token manipulation functions and constants
These are extremely useful functions and core to the Windows security
API. They are so useful, in fact, that most of these were taken right
out of the Go repo's internal/syscall/windows package.

Change-Id: I13e34b830dd60f59fcae8085ae2be189d9cc9282
Reviewed-on: https://go-review.googlesource.com/c/sys/+/176625
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-14 13:59:07 +00:00
Tobias Klauser
a5b02f93d8 windows: add "generate" build tag
cmd/go supports the "generate" build tag as of CL 175983. Add it to the
files which are just used for generating errors and syscall wrappers.

Also see golang/go#31920

Change-Id: Ib26c90af0ac1fb7bae81366a46dedf028b787566
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175899
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-09 14:14:14 +00:00
Matt Layher
2d0786266e unix: add IoctlGetUint32 on Linux
Because the size of int varies on different architectures,
IoctlGetInt is unsuitable for ioctl APIs which explicitly deal with
fixed size integers, such as uint32.

Change-Id: I5a8dc397b713027c4ef9f9a91490f177ac8342e2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175982
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-08 22:02:29 +00:00
Lehner Florian
12bbe5a7a5 unix: add BPF constants on Linux
Change-Id: Ie43daa8ba56ad1e57ddbb8ddd47f83b363fe75b4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174978
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-05-08 10:04:23 +00:00
Tobias Klauser
ecd444e865 unix: export KexecFileLoad on linux/arm
CL 175158 added the generated kexecFileLoad wrapper but forgot to add
the exported KexecFileLoad and the corresponding //sys line.

Change-Id: Ic94ce83dbb1ecc3d07080b4b4dfe35934ec54d57
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175657
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-07 16:07:41 +00:00
Tobias Klauser
2953c62de4 unix: update Dockerfile to Linux 5.1
Also add KexecFileLoad on linux/arm now that is has SYS_KEXEC_FILE_LOAD.

Change-Id: I519bc2f611b511af994e1c7bbaa07f68cd615ef4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175158
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-07 05:39:17 +00:00
Jason A. Donenfeld
ca7f33d411 windows: CreateFile's templatefile parameter has always been a HANDLE
This fixes a bug in the declaration. The documentation involving this
parameter is at:
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilew

Change-Id: I650c54b3110d29921627b08d47be4fa41d60bbf4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175159
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-05-06 11:50:46 +00:00
Gernot Vormayr
a43fa875dd unix: add missing tpacket block (sub)header
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>
2019-05-02 17:53:42 +00:00
Brad Fitzpatrick
3ef323f4f1 unix: add illumos case
From CL 174457 which modified this file's vendored copy in the "go"
repo.

Updates golang/go#20603

Change-Id: Ic89b2e772120a08ac0fa3a56acb93a8ee96ba337
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174958
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-05-02 14:57:24 +00:00
Tobias Klauser
c0b26311cb unix: support generating netbsd/arm64 files in mkall.sh
CL 155738 added the generated files but didn't update mkall.sh. Do so
now.

Change-Id: I8681ef175547750bea94b06827ef5f4512dc6de3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174860
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-05-02 14:30:02 +00:00
Tobias Klauser
050d976686 unix: drop reference to mkunix.pl from comment
mkunix.pl doesn't exist in x/sys/unix, so drop the reference to it from
the _zero godoc comment.

Change-Id: I7a638a5248b72c4dffc83da1514e5d861c532127
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174858
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-02 14:15:30 +00:00
Brad Fitzpatrick
d89cdac9e8 windows: don't return EINVAL on zero Chmod mode
To match CL 174320

Updates golang/go#20858

Change-Id: Ic4e332c8a84b7d427fc7057aa5b0c2877cc9f7ea
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174321
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-29 19:08:28 +00:00