Some new upcoming changes require us to use Go 1.23. However, if we switch to Go 1.23 some
new linter errors are showing up. This commit fixes most of the errors and adds an
exclusion for integer overflow errors.
Signed-off-by: Amit <ambarve@microsoft.com>
* Update to go 1.21
Use `atomic.Bool` stdlib instead of including our own.
Include `tools\mkwinsyscall` updates from go-winio/283 to switch to
`syscallN`.
Note: removed `// TODO` about `print`/`ln`, since the latter adds spaces
between args when printing, which is undesired.
Also update CI to run steps on windows-2022 instead of windows-2019,
similar to our hcsshim CI.
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
* PR: simplify type checking
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
---------
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Where ever possible, use `golang.org/x/sys/windows` instead of `syscall`
(which has been deprecated since go1.11).
Using `windows.LocalFree` requires using `unsafe.Pointer`, which ensures
that the Go garbage collector does not try to free memory pre-maturely
if it was previously declared as a pointer.
Since `syscall.Handle` is part of API for `vhd` package, it was left
unchanged.
For security descriptor functions, switch to using
`windows.SECURITY_DESCRIPTOR` to avoid unnecessary byte manipulation and
panics due to missing input validation and error checking.
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Run fuzzing tests in CI.
Use race detector when running tests.
Add missing `t.Helper()` calls.
Update test helpers in `pkg/bindfilter` to use `RtlGetNtVersionNumbers`
instead of reading registry, and skip tests if not running as admin.
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
* Add some basic bind filter functions
This change adds the ability to mount a a single folder or a volume
inside another folder, using the bind filter API.
While the API allows mounting multiple sources inside a single mount
point, acting as an overlay, we disable this functionality in the ApplyFileBinding
function.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Add some tests
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Move bind filter to different package
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Use string in signature and fix getFinalPath
* Properly close handle in getFinalPath()
* Use string in function signature. mksyscall generates proper code to
convert to utf16
* Enable TestRemoveFileBinding on Windows Server 2019
Windows Server 2019 only exposes 2 function in bindfltapi.dll:
* BfRemoveMapping
* BfSetupFilter
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Use windows.UTF16ToString to decode string
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Optimize bfGetMappings signature
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Skip unsupported tests on ltsc2019
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Fix typo, add testcase
* Additionally check if we can write to a read-only mount point, not
just delete from it
* No need to set FILE_FLAG_OPEN_REPARSE_POINT when opening a file
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Remove extra flags
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
* Add test to account for symlinks as sources
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
---------
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>