Commit Graph
309 Commits
Author SHA1 Message Date
Michael Hofmann e50e8e7af4 Add lookup of account names by SID
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>
2022-02-09 18:16:47 +01:00
Danny Canter 01a3671376 Merge pull request #227 from bitgestalt/use_stdlib_errors
Replace github.com/pkg/errors with stdlib errors
2021-12-02 12:27:00 -08:00
Kathryn Baldauf 568b5c2571 Merge pull request #225 from bitgestalt/fix_test_empty_name
Fix TestLookupEmptyNameFails
2021-12-01 10:50:10 -08:00
Michael Hofmann c4cf81c481 Replace github.com/pkg/errors with stdlib errors
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>
2021-12-01 11:09:15 +01:00
Michael Hofmann 05c1e887e7 Fix TestLookupEmptyNameFails
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>
2021-12-01 09:16:45 +01:00
Kathryn Baldauf 60c1574cd7 Merge pull request #169 from dcormier/dc/guid
Allow guid package to be used on non-Windows GOOS targets
2021-10-25 17:23:25 -07:00
Kevin Parsons 6c24dfa01e Merge pull request #217 from kylewo/master
Fixing corruption in callbacks introduced by x86 changes
2021-10-13 04:01:28 -07:00
Kyle Wojtaszek 4c72048b5c FIxing corruption in callbacks
Signed-off-by: Kyle Wojtaszek <kylewo@microsoft.com>
2021-10-12 14:31:04 -07:00
Kevin Parsons 7ec923885d Merge pull request #221 from kevpar/sparse
backuptar: Fix sparse file handling
2021-10-04 14:26:55 -07:00
Kevin Parsons 33a480106a backuptar: Fix sparse file handling
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>
2021-09-23 11:13:05 -07:00
Danny Canter a0fd408c2f Merge pull request #219 from dcantah/dco-readme
Update README with DCO information + re-order into sections
2021-09-09 13:06:00 -07:00
Daniel Canter 4643510f75 Update README with DCO information + re-order into sections
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>
2021-09-09 12:32:34 -07:00
Kevin Parsons 8f85a06205 Merge pull request #214 from kylewo/master
Fix corruption in x86 callback
2021-07-20 16:00:10 -07:00
Kyle W 0b148d19cf Fix corruption in x86 callback 2021-06-14 13:44:35 -07:00
Kevin Parsons 1d4efacd46 Merge pull request #210 from kevpar/syscall-err
Fix syscall error handling in vhd and pkg/security
2021-04-26 15:18:39 -07:00
Kevin Parsons 9f0ab2cc0a Fix syscall error handling in vhd and pkg/security
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>
2021-04-26 15:08:11 -07:00
Kathryn Baldauf 58dba89bef Merge pull request #209 from microsoft/revert-204-revert_fileinfo_break
Revert removal of "Implement winio.GetFileStandardInfo FileInfo" commits
2021-04-22 15:01:04 -07:00
Kathryn Baldauf 8f0d50b3b3 Revert "[Temporary] Revert Implement winio.GetFileStandardInfo FileInfo commits " 2021-04-22 10:33:11 -07:00
Kathryn Baldauf 5c2e05d719 Merge pull request #204 from katiewasnothere/revert_fileinfo_break
[Temporary] Revert Implement winio.GetFileStandardInfo FileInfo commits
2021-04-22 10:24:59 -07:00
Danny Canter a6ee88c751 Merge pull request #208 from dcantah/build-bins-ci
Build the three binaries in this repo from the ci
2021-04-21 19:01:47 -07:00
Daniel Canter 1358edb607 Build the three binaries in this repo from the ci
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>
2021-04-21 18:42:54 -07:00
Kathryn Baldauf 4ee6e51bfd Merge pull request #206 from katiewasnothere/build_badge
Add build status badge to readme
2021-04-21 17:51:31 -07:00
Kathryn Baldauf 090e4c6b27 Add build status badge to readme
Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
2021-04-21 15:43:01 -07:00
Kathryn Baldauf 3e47278dca Merge pull request #205 from katiewasnothere/gh_actions
Add CI github action for testing on push and PR
2021-04-21 15:40:41 -07:00
Kathryn Baldauf 085c1a94ab Add CI github action for testing on push and PR
Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
2021-04-21 15:35:36 -07:00
Kathryn Baldauf e5bd3f6e28 Revert "Implement winio.GetFileStandardInfo"
This reverts commit ef753e60d2.

Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
2021-04-21 12:50:05 -07:00
Kathryn Baldauf d80ed10b91 Revert "Replace local *FileInformationByHandleEx with x/sys/windows"
This reverts commit bfd546865c.

Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
2021-04-21 12:49:46 -07:00
Danny Canter e98b56db61 Merge pull request #201 from awmirantis/add-se-security-privilege
Add security privilege (needed for VHDX support for docker data root)
2021-04-14 13:34:21 -07:00
Adam Williams 4811f9fdd6 Add security privilege (needed for VHDX support for docker data root)
Signed-off-by: Adam Williams <awilliams@mirantis.com>
2021-04-05 12:16:07 -07:00
Kevin Parsons 5516f17a59 Merge pull request #200 from kevpar/fix-etw-arch
pkg/etw: Fix to build on windows/arm
2021-03-24 15:44:01 -07:00
Kevin Parsons 941861fe1a pkg/etw: Fix to build on windows/arm
We don't support actually using ETW on windows/arm, but to make things
easier for downstream dependencies, we want to still allow the package
to compile and just no-op on this architecture. We do this by returning
a nil Provider, and implementing its methods to no-op when the receiver
is nil.

Previously this was implemented by putting NewProviderWithID in
provider_unsupported.go, but when we refactored the code so that the
actual work was done in NewProviderWithOptions instead, we didn't fix up
provider_unsupported. This change fixes this by putting only
NewProviderWithOptions in provider_unsupported.go, since the other
provider creation functions call into this one.

Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
2021-03-24 15:05:25 -07:00
Danny Canter 6eac466e5f Merge pull request #185 from TBBle/GetFileStandardInfo
Implement `winio.GetFileStandardInfo`
2021-02-11 03:55:48 -08:00
Paul "TBBle" Hampson ef753e60d2 Implement winio.GetFileStandardInfo
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-02-11 22:50:55 +11:00
Paul "TBBle" Hampson bfd546865c Replace local *FileInformationByHandleEx with x/sys/windows
We also get pre-defined constants instead of carrying our own copies.

However, this changes the public API winio.FileBasicInfo from using
syscall.Filetime to using windows.Filetime, as visible in
backuptar/tar.go.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-02-11 22:50:55 +11:00
Paul "TBBle" Hampson bc48b61dc9 Make local mksyscall_windows.go forks less forked
At this point points of difference between the three local
mksyscall_windows.go implementations and
golang.org/x/sys/windows/mkwinsyscall v0.0.0-20210104204734-6f8348627aad
are:
- pkg/etw: Deduplicates imported functions due to multiple calling APIs
- pkg/security and vhd: Forced UTF-16 mode, not checking A/W suffix. I
  also removed cosmetic differences between these two implementations.

`go generate` reports no changes with these updates.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-02-11 22:50:55 +11:00
Paul "TBBle" Hampson 1390d1a07b Pull sync generated syscalls
This moves all the current users of
$GOROOT/src/syscall/mksyscall_windows.go to instead use
golang.org/x/sys/windows/mkwinsyscall, as directed by the version of the
former in Go 1.15.

It also syncs the local forks of mksyscall_windows.go with the latest
version of golang.org/x/sys/windows/mkwinsyscall/mkwinsyscall.go, so
that the local patches can be easily seen in a side-by-side comparison.
Significant changes compared to the in-tree forked versions:
* *bool parameters are read back through a temp-var, not directly like
  other pointer parameters.
* ?-suffixed function names support testing for function presence before
  calling. This replaces a local implementation of this in
  pkg/security, which was not actually used anyway. The upstream version
  correctly supports functions that don't already have an error return.
* `errnoErr(0)` is now useful, so each call of `errnoErr` doesn't need
  to be protected with a check for 0 first.
* The generated functions are now sorted. This of course produced a
  *lot* of churn in the generated files.

vhd\vhd.go was changed to generate syscalls into zvhd_windows.go, since
regeneration removes the build tag added by hand in
9d8277341f.

After all that, I also ran
```
go generate . .\pkg\etw\ .\pkg\process\ .\pkg\security\ .\vhd\
```
to update all the existing generated code.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-02-11 22:47:40 +11:00
Kathryn Baldauf 68cdd9bd9d Merge pull request #191 from uhthomas/master
Add build guards for all Windows imports
2021-02-10 17:11:08 -08:00
Thomas e09292102f Add noop mains for non windows builds 2021-02-11 00:05:48 +00:00
Thomas d4c02ad896 Add missing build constraints 2021-02-10 23:54:19 +00:00
Thomas f0d2c76ab3 Fix missing platform/architecture separation 2021-02-10 23:09:41 +00:00
Thomas eb9d8c9346 Separate platform from architecture build constraints 2021-02-10 23:05:19 +00:00
Kevin Parsons 2aa35e1d77 Merge pull request #195 from thaJeztah/better_exec
Use golang.org/x/sys/execabs instead of os/exec
2021-02-10 00:38:31 -08:00
Sebastiaan van Stijn f2a56450f4 Use golang.org/x/sys/execabs instead of os/exec
On Windows, the os/exec.{Command,CommandContext,LookPath} functions resolve command
names that have neither path separators nor file extension (e.g., "git") by first
looking in the current working directory before looking in the PATH environment
variable.
Go maintainers intended to match cmd.exe's historical behavior.

However, this is pretty much never the intended behavior and as an abundance of
precaution this patch prevents that when executing commands.

This patch was prompted by the [Go 1.15.7 security fixes](https://blog.golang.org/path-security).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-02-10 09:21:40 +01:00
Kathryn Baldauf a38e1dc8bb Merge pull request #188 from TBBle/correct-GetVolumeInformation-return-handling
Correct GetVolumeInformation return type handling
2021-02-09 18:46:35 -08:00
Kathryn Baldauf 90a22c612d Merge pull request #194 from thaJeztah/bump_deps
go.mod: sirupsen/logrus v1.7.0, golang.org/x/sys
2021-02-09 18:38:52 -08:00
Danny Canter 644af44635 Merge pull request #189 from dcantah/attach-v1
Remove error if ATTACH_VIRTUAL_DISK_PARAMETERS wasn't version 2
2021-02-09 17:46:10 -08:00
Danny Canter 69491f048a Merge pull request #196 from katiewasnothere/add_codeowners
Add codeowners file so containerplat is auto added as reviewers
2021-02-09 15:35:45 -08:00
Kathryn Baldauf ea4a03d185 Add codeowners file so containerplat is auto added as reviewers
Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
2021-02-09 15:18:39 -08:00
Sebastiaan van Stijn 6734ca5406 go.mod: sirupsen/logrus v1.7.0, golang.org/x/sys
full diff: https://github.com/sirupsen/logrus/compare/v1.4.2...v1.7.0

logrus v1.7.0 removes dependency on github.com/konsorten/go-windows-terminal-sequences

Features:

* a new buffer pool management API has been added
* a set of `<LogLevel>Fn()` functions have been added

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-02-09 11:02:59 +01:00
Kevin Parsons ac908d2e8e Merge pull request #192 from kylewo/add-provider-group
Add ability to set provider group
2021-01-27 14:52:50 -08:00