Language server complains about
`invalid operation: operator | not defined on windows.TOKEN_ADJUST_PRIVILEGES`
in `privilege.go`. Upgrading to new golang.org/x/sys fixes issue.
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
* ETW name and options functionality
Added functionality to set the event (task) name and options (such as
event or associated event ID) for ETW events created by the hook based
on the logrus.Entry fields.
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
* PR: export and comment
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Add in a ^1.17.0 go-version for the actions/setup-go@v2 action. This
was set for our build step but not for the step that runs all of the
unit tests.
Signed-off-by: Daniel Canter <dcanter@microsoft.com>
This error used to just be a `errors.New` with the text exactly matching
the "use of closed network connection" that you'd get from the Go stdlib.
Now that that error was exported as `net.ErrClosed` in Go 1.16 we should
be able to swap to this safely, and anyone who relied on checking the
string explicitly should still be fine.
Signed-off-by: Daniel Canter <dcanter@microsoft.com>
1.13 is sufficiently old at this point and net.ErrClosed from 1.16 will be nice
to use.
This change additionally runs go fmt to bring in the new 1.17 build tag syntax
and builds the binaries in our CI with 1.17+.
Signed-off-by: Daniel Canter <dcanter@microsoft.com>
pkg/guid is not windows specific, as it can run on Linux.
Build constraints on guid_windows and guid_nonwindows are redundant with
file names, but added for consistency.
Added missing build constraints.
Added Ubuntu to test matrix, along with windows 2022.
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
This may be a theoretical situation, but the tar headers may contain
both the old and new headers, in which case we would be decoding
both.
This patch rewrites the function to try the new headers first, and
return early if found, then fall back to trying the old headers.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Corrected `HvsockConn` `CloseRead`/`Write` to check if the socket
has been closed before attempting to shutdown the socket for
reading or writing.
Additionally, `shutdown` was not respecting whether to shutdown reading
or writing, and only shutting down the socket for reading.
Added `IsClosed` function to `win32File` (and therefore `win32Pipe` and
`win32MessageBytePipe`) and `HvsockConn` to check if the socket/pipe
has been closed already.
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
* Fix 'OpenVirtualDiskParameters' BOOL fields
While reworking the vhd package I'd mistakingly replaced some of the fields
in the OpenVersion2 structure with the incorrect types. They're defined as
Windows BOOLS which is just a type alias for an int, and I'd put their type as
go bools.
As the type is already passed into some functions, to avoid a breaking change just
convert the incorrect type to a new structure with the correct definition internally.
Truthfully this turns out a bit better as supplying a bool makes more sense and is
more go friendly.
Signed-off-by: Daniel Canter <dcanter@microsoft.com>
This commit adds a new function LookupNameBySid that wraps
LookupAccountSidW and works as an inverse of the already existing
LookupSidByName. In addition to offering new functionality, this
fixes#202.
Signed-off-by: Michael Hofmann <michael.hofmann@bitgestalt.com>
Separates out Security Descriptor (SDDL), Extended Attribute (EA) and Reparse tag encoding
code into individual functions so that those functions can be reused in other code (like
CimFS layer writing)
Signed-off-by: Amit Barve <ambarve@microsoft.com>
Since Go version 1.13, the standard library has built-in support for
wrapping and unwrapping of error values. This commit bumps the minimum
version required by the module from 1.12 to 1.13, replaces all calls to
errors.Wrap/f with fmt.Errorf and removes the now unneeded dependency on
github.com/pkg/errors.
Signed-off-by: Michael Hofmann <michael.hofmann@bitgestalt.com>
TestLookupEmptyNameFails was an identical copy of TestLookupInvalidSid
in the same file. This commit changes the account name queried by the
former to an empty string which is what the name of the test case
suggests.
Signed-off-by: Michael Hofmann <michael.hofmann@bitgestalt.com>
A recent OS change altered how sparse files are represented in backup
streams. This caused backuptar to no longer work with certain files. The
specific behavior that changed is as follows:
- Empty sparse files (size = 0), previously did not have any data or
sparse block streams in the backup stream. Now, they will have a
data stream with size = 0, and no sparse block streams.
- Sparse files with a single allocated range (e.g. a normal file that
has the sparse attribute set) previously would not show as sparse in
the backup stream. Now, they will show as sparse.
The old backuptar behavior assumed that if the sparse flag was set on
the data stream, then there would always be a set of sparse blocks
following. These changes break this assumption, and so require special
handling.
It is unsupported to have a data stream, marked sparse, that contains
file content AND a series of sparse block streams following. As far as
I can tell this is not a valid case for backup streams.
This change also cleans up some code and error messages, and expands on
the test coverage for backuptar.
For more information on backup stream format see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-bkup/f67950c8-d583-469a-83dd-c4ff4cedf533
Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
This change updates the README to mention that we now require a valid
DCO on every commit via the bot. Also adds a new contributing section
that houses this info.
This change also re-orders the README into sections:
Contributing, Code of Conduct, Special Thanks
Signed-off-by: Daniel Canter <dcanter@microsoft.com>
These packages had incorrect error handling for their generated syscall
bindings. The functions they were calling returned errors directly, but
the binding was written such that the generated code was calling
GetLastError instead.
Thankfully, this did not affect the detection of whether or not an error
had occurred, it only caused the value returned in the case of an error
to be not the right error code.
Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
Even though this repo is normally used as a dependency, there are some
sample binaries and tools built out of here. This just makes sure they still build
in the CI.
Signed-off-by: Daniel Canter <dcanter@microsoft.com>