Merge ~kajiya/+git/google-guest-agent:kajiya/master into ~ubuntu-core-dev/+git/google-guest-agent:ubuntu/master

Proposed by Chloé Smith
Status: Merged
Merged at revision: 315ed9a555225dc8f8a4ea4400884b64e8fedb2f
Proposed branch: ~kajiya/+git/google-guest-agent:kajiya/master
Merge into: ~ubuntu-core-dev/+git/google-guest-agent:ubuntu/master
Diff against target: 44407 lines (+39733/-1274)
215 files modified
.gitignore (+11/-1)
OWNERS (+2/-2)
THIRD_PARTY_LICENSES/cloud.google.com/go/internal/LICENSE (+2/-1)
THIRD_PARTY_LICENSES/github.com/GoogleCloudPlatform/guest-agent/LICENSE (+2/-2)
THIRD_PARTY_LICENSES/github.com/Microsoft/go-winio/LICENSE (+22/-0)
THIRD_PARTY_LICENSES/golang.org/x/xerrors/LICENSE (+27/-0)
THIRD_PARTY_LICENSES/software.sslmate.com/src/go-pkcs12/LICENSE (+1/-1)
debian/changelog (+8/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/.gitattributes (+1/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/.gitignore (+10/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/.golangci.yml (+149/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/CODEOWNERS (+1/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/LICENSE (+22/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/README.md (+89/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/SECURITY.md (+41/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/backup.go (+290/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/doc.go (+22/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/ea.go (+137/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/file.go (+331/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/fileinfo.go (+92/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/hvsock.go (+575/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/doc.go (+2/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/fs.go (+202/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/security.go (+12/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/zsyscall_windows.go (+64/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/rawaddr.go (+20/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/socket.go (+179/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/zsyscall_windows.go (+72/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/internal/stringbuffer/wstring.go (+132/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/pipe.go (+525/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go (+232/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_nonwindows.go (+16/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_windows.go (+13/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/variant_string.go (+27/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/privilege.go (+197/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/reparse.go (+131/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/sd.go (+144/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/syscall.go (+5/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/tools.go (+5/-0)
debian/extra/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go (+419/-0)
debian/extra/vendor/golang.org/x/crypto/blowfish/block.go (+159/-0)
debian/extra/vendor/golang.org/x/crypto/blowfish/cipher.go (+99/-0)
debian/extra/vendor/golang.org/x/crypto/blowfish/const.go (+199/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/curve25519.go (+59/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/curve25519_compat.go (+105/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/curve25519_go120.go (+46/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/README (+7/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/fe.go (+416/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.go (+16/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64.s (+379/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/fe_amd64_noasm.go (+12/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.go (+16/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64.s (+43/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/fe_arm64_noasm.go (+12/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/fe_generic.go (+264/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/sync.checkpoint (+1/-0)
debian/extra/vendor/golang.org/x/crypto/curve25519/internal/field/sync.sh (+19/-0)
debian/extra/vendor/golang.org/x/crypto/ed25519/ed25519.go (+71/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/buffer.go (+97/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/certs.go (+589/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/channel.go (+633/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/cipher.go (+789/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/client.go (+282/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/client_auth.go (+725/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/common.go (+446/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/connection.go (+143/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/doc.go (+22/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/handshake.go (+735/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/internal/bcrypt_pbkdf/bcrypt_pbkdf.go (+93/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/kex.go (+774/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/keys.go (+1447/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/mac.go (+68/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/messages.go (+877/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/mux.go (+351/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/server.go (+755/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/session.go (+647/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/ssh_gss.go (+139/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/streamlocal.go (+116/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/tcpip.go (+474/-0)
debian/extra/vendor/golang.org/x/crypto/ssh/transport.go (+358/-0)
debian/extra/vendor/golang.org/x/mod/LICENSE (+27/-0)
debian/extra/vendor/golang.org/x/mod/PATENTS (+22/-0)
debian/extra/vendor/golang.org/x/mod/semver/semver.go (+401/-0)
debian/extra/vendor/golang.org/x/sys/execabs/execabs.go (+102/-0)
debian/extra/vendor/golang.org/x/sys/execabs/execabs_go118.go (+18/-0)
debian/extra/vendor/golang.org/x/sys/execabs/execabs_go119.go (+21/-0)
debian/extra/vendor/golang.org/x/tools/LICENSE (+27/-0)
debian/extra/vendor/golang.org/x/tools/PATENTS (+22/-0)
debian/extra/vendor/golang.org/x/tools/cmd/stringer/stringer.go (+657/-0)
debian/extra/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go (+187/-0)
debian/extra/vendor/golang.org/x/tools/go/gcexportdata/importer.go (+75/-0)
debian/extra/vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go (+49/-0)
debian/extra/vendor/golang.org/x/tools/go/packages/doc.go (+220/-0)
debian/extra/vendor/golang.org/x/tools/go/packages/external.go (+101/-0)
debian/extra/vendor/golang.org/x/tools/go/packages/golist.go (+1173/-0)
debian/extra/vendor/golang.org/x/tools/go/packages/golist_overlay.go (+575/-0)
debian/extra/vendor/golang.org/x/tools/go/packages/loadmode_string.go (+57/-0)
debian/extra/vendor/golang.org/x/tools/go/packages/packages.go (+1326/-0)
debian/extra/vendor/golang.org/x/tools/go/packages/visit.go (+59/-0)
debian/extra/vendor/golang.org/x/tools/internal/event/core/event.go (+85/-0)
debian/extra/vendor/golang.org/x/tools/internal/event/core/export.go (+70/-0)
debian/extra/vendor/golang.org/x/tools/internal/event/core/fast.go (+77/-0)
debian/extra/vendor/golang.org/x/tools/internal/event/doc.go (+7/-0)
debian/extra/vendor/golang.org/x/tools/internal/event/event.go (+127/-0)
debian/extra/vendor/golang.org/x/tools/internal/event/keys/keys.go (+564/-0)
debian/extra/vendor/golang.org/x/tools/internal/event/keys/standard.go (+22/-0)
debian/extra/vendor/golang.org/x/tools/internal/event/label/label.go (+215/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/bexport.go (+852/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/bimport.go (+1053/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/exportdata.go (+99/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/gcimporter.go (+265/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/iexport.go (+1180/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/iimport.go (+976/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/newInterface10.go (+22/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/newInterface11.go (+14/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/support_go117.go (+16/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/support_go118.go (+37/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/unified_no.go (+10/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/unified_yes.go (+10/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/ureader_no.go (+19/-0)
debian/extra/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go (+738/-0)
debian/extra/vendor/golang.org/x/tools/internal/gocommand/invoke.go (+356/-0)
debian/extra/vendor/golang.org/x/tools/internal/gocommand/vendor.go (+109/-0)
debian/extra/vendor/golang.org/x/tools/internal/gocommand/version.go (+81/-0)
debian/extra/vendor/golang.org/x/tools/internal/packagesinternal/packages.go (+30/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/codes.go (+77/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/decoder.go (+517/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/doc.go (+32/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/encoder.go (+383/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/flags.go (+9/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/frames_go1.go (+21/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/frames_go17.go (+28/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/reloc.go (+42/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/support.go (+17/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/sync.go (+113/-0)
debian/extra/vendor/golang.org/x/tools/internal/pkgbits/syncmarker_string.go (+89/-0)
debian/extra/vendor/golang.org/x/tools/internal/tokeninternal/tokeninternal.go (+59/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/common.go (+179/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/coretype.go (+122/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/enabled_go117.go (+12/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/enabled_go118.go (+15/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/normalize.go (+218/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/termlist.go (+163/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go (+197/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go (+151/-0)
debian/extra/vendor/golang.org/x/tools/internal/typeparams/typeterm.go (+170/-0)
debian/extra/vendor/golang.org/x/tools/internal/typesinternal/errorcode.go (+1560/-0)
debian/extra/vendor/golang.org/x/tools/internal/typesinternal/errorcode_string.go (+179/-0)
debian/extra/vendor/golang.org/x/tools/internal/typesinternal/types.go (+52/-0)
debian/extra/vendor/golang.org/x/tools/internal/typesinternal/types_118.go (+19/-0)
debian/extra/vendor/modules.txt (+34/-0)
debian/source/include-binaries (+8/-0)
dev/null (+0/-93)
gce_workload_cert_refresh/main.go (+169/-152)
gce_workload_cert_refresh/main_test.go (+495/-0)
go.mod (+5/-2)
go.sum (+9/-0)
google_authorized_keys/main.go (+14/-49)
google_authorized_keys/main_test.go (+103/-44)
google_guest_agent/addresses.go (+21/-245)
google_guest_agent/agentcrypto/mtls_mds.go (+1/-1)
google_guest_agent/agentcrypto/mtls_mds_linux.go (+35/-14)
google_guest_agent/agentcrypto/mtls_mds_linux_test.go (+21/-4)
google_guest_agent/agentcrypto/mtls_mds_windows.go (+25/-0)
google_guest_agent/cfg/cfg.go (+30/-8)
google_guest_agent/cfg/cfg_test.go (+3/-1)
google_guest_agent/command/Readme.md (+24/-0)
google_guest_agent/command/command.go (+146/-0)
google_guest_agent/command/command_linux.go (+140/-0)
google_guest_agent/command/command_monitor.go (+228/-0)
google_guest_agent/command/command_test.go (+209/-0)
google_guest_agent/command/command_windows.go (+104/-0)
google_guest_agent/command/command_windows_test.go (+73/-0)
google_guest_agent/diagnostics.go (+2/-1)
google_guest_agent/events/events.go (+308/-138)
google_guest_agent/events/events_test.go (+372/-107)
google_guest_agent/events/metadata/metadata.go (+0/-6)
google_guest_agent/events/metadata/metadata_test.go (+4/-0)
google_guest_agent/fakes/fake_mds.go (+5/-0)
google_guest_agent/instance_setup.go (+18/-7)
google_guest_agent/main.go (+22/-20)
google_guest_agent/network/manager/common.go (+90/-0)
google_guest_agent/network/manager/dhclient_linux.go (+292/-0)
google_guest_agent/network/manager/dhclient_linux_test.go (+511/-0)
google_guest_agent/network/manager/manager.go (+362/-0)
google_guest_agent/network/manager/manager_test.go (+353/-0)
google_guest_agent/network/manager/systemd_networkd_linux.go (+295/-0)
google_guest_agent/network/manager/systemd_networkd_linux_test.go (+549/-0)
google_guest_agent/non_windows_accounts.go (+3/-1)
google_guest_agent/oslogin.go (+91/-0)
google_guest_agent/ps/ps.go (+37/-0)
google_guest_agent/ps/ps_linux.go (+121/-0)
google_guest_agent/ps/ps_linux_test.go (+157/-0)
google_guest_agent/ps/ps_windows.go (+21/-0)
google_guest_agent/run/run.go (+51/-4)
google_guest_agent/scheduler/logger.go (+2/-2)
google_guest_agent/scheduler/scheduler.go (+1/-0)
google_guest_agent/scheduler/scheduler_test.go (+8/-8)
google_guest_agent/snapshot_listener.go (+7/-5)
google_guest_agent/sshca/sshca.go (+9/-11)
google_guest_agent/windows_accounts.go (+2/-1)
google_guest_agent/windows_accounts_test.go (+49/-42)
google_metadata_script_runner/main.go (+63/-78)
google_metadata_script_runner/main_test.go (+78/-11)
metadata/metadata.go (+16/-0)
metadata/metadata_test.go (+30/-0)
packaging/genlicense.sh (+24/-0)
retry/retry.go (+107/-0)
retry/retry_test.go (+193/-0)
utils/file.go (+80/-0)
utils/file_test.go (+87/-0)
utils/serial_port_logger.go (+35/-0)
utils/ssh.go (+19/-108)
utils/ssh_test.go (+32/-104)
utils/test.go (+38/-0)
Reviewer Review Type Date Requested Status
Utkarsh Gupta Approve
Review via email: mp+460884@code.launchpad.net

Commit message

Update upstream source from upstream tags/20240213.00

Also:
* Update the vendored dependencies
* Added a new d/source/include-binaries file to list ../s2a-go/.. DER-encoded
  cert files
* (LP: #2054484)

To post a comment you must log in.
Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

Sponsored your upload with one tiny additional change -
https://git.launchpad.net/~ubuntu-core-dev/+git/google-guest-agent/commit/?id=bab3df1dc0511d52d8b9edccb0ff107f70af9255

But all good otherwise!

$ dput ubuntu ../google-guest-agent_20240213.00-0ubuntu1_source.changes
Uploading google-guest-agent using ftp to ubuntu (host: upload.ubuntu.com; directory: /ubuntu)
running supported-distribution: check whether the target distribution is currently supported (using distro-info)
{'allowed': ['release', 'proposed', 'backports', 'security'], 'known': ['release', 'proposed', 'updates', 'backports', 'security']}
running required-fields: check whether a field is present and non-empty in the changes file
running checksum: verify checksums before uploading
running suite-mismatch: check the target distribution for common errors
running check-debs: makes sure the upload contains a binary package
running gpg: check GnuPG signatures before the upload
Uploading google-guest-agent_20240213.00-0ubuntu1.dsc
Uploading google-guest-agent_20240213.00.orig.tar.gz
Uploading google-guest-agent_20240213.00-0ubuntu1.debian.tar.xz
Uploading google-guest-agent_20240213.00-0ubuntu1_source.buildinfo
Uploading google-guest-agent_20240213.00-0ubuntu1_source.changes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/.gitignore b/.gitignore
2index 2ceee21..85eb02e 100644
3--- a/.gitignore
4+++ b/.gitignore
5@@ -1,5 +1,15 @@
6-# ignore all built binaries
7+# Ignore all built binaries.
8 **/gce_workload_cert_refresh
9+**/gce_workload_cert_refresh.exe
10 **/google_authorized_keys
11+**/google_authorized_keys.exe
12 **/google_guest_agent
13+**/google_guest_agent.exe
14 **/google_metadata_script_runner
15+**/google_metadata_script_runner.exe
16+
17+# Don't ignore new content to directories.
18+!**/gce_workload_cert_refresh/
19+!**/google_authorized_keys/
20+!**/google_guest_agent/
21+!**/google_metadata_script_runner/
22\ No newline at end of file
23diff --git a/OWNERS b/OWNERS
24index edde10e..59fca61 100644
25--- a/OWNERS
26+++ b/OWNERS
27@@ -3,14 +3,14 @@
28
29 approvers:
30 - a-crate
31+ - ajorg
32 - bkatyl
33 - chaitanyakulkarni28
34 - dorileo
35 - drewhli
36 - elicriffield
37+ - gaughen
38 - jjerger
39 - karnvadaliya
40 - koln67
41- - quintonamore
42- - vorakl
43 - zmarano
44diff --git a/THIRD_PARTY_LICENSES/cloud.google.com/go/LICENSE b/THIRD_PARTY_LICENSES/cloud.google.com/go/iam/LICENSE
45similarity index 100%
46rename from THIRD_PARTY_LICENSES/cloud.google.com/go/LICENSE
47rename to THIRD_PARTY_LICENSES/cloud.google.com/go/iam/LICENSE
48diff --git a/THIRD_PARTY_LICENSES/github.com/GoogleCloudPlatform/guest-agent/google_guest_agent/LICENSE b/THIRD_PARTY_LICENSES/cloud.google.com/go/internal/LICENSE
49similarity index 100%
50rename from THIRD_PARTY_LICENSES/github.com/GoogleCloudPlatform/guest-agent/google_guest_agent/LICENSE
51rename to THIRD_PARTY_LICENSES/cloud.google.com/go/internal/LICENSE
52index 65fb971..d645695 100644
53--- a/THIRD_PARTY_LICENSES/github.com/GoogleCloudPlatform/guest-agent/google_guest_agent/LICENSE
54+++ b/THIRD_PARTY_LICENSES/cloud.google.com/go/internal/LICENSE
55@@ -1,3 +1,4 @@
56+
57 Apache License
58 Version 2.0, January 2004
59 http://www.apache.org/licenses/
60@@ -186,7 +187,7 @@
61 same "printed page" as the copyright notice for easier
62 identification within third-party archives.
63
64- Copyright 2020 Google Inc.
65+ Copyright [yyyy] [name of copyright owner]
66
67 Licensed under the Apache License, Version 2.0 (the "License");
68 you may not use this file except in compliance with the License.
69diff --git a/THIRD_PARTY_LICENSES/github.com/GoogleCloudPlatform/guest-agent/LICENSE b/THIRD_PARTY_LICENSES/github.com/GoogleCloudPlatform/guest-agent/LICENSE
70index 65fb971..f49a4e1 100644
71--- a/THIRD_PARTY_LICENSES/github.com/GoogleCloudPlatform/guest-agent/LICENSE
72+++ b/THIRD_PARTY_LICENSES/github.com/GoogleCloudPlatform/guest-agent/LICENSE
73@@ -186,7 +186,7 @@
74 same "printed page" as the copyright notice for easier
75 identification within third-party archives.
76
77- Copyright 2020 Google Inc.
78+ Copyright [yyyy] [name of copyright owner]
79
80 Licensed under the Apache License, Version 2.0 (the "License");
81 you may not use this file except in compliance with the License.
82@@ -198,4 +198,4 @@
83 distributed under the License is distributed on an "AS IS" BASIS,
84 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
85 See the License for the specific language governing permissions and
86- limitations under the License.
87+ limitations under the License.
88\ No newline at end of file
89diff --git a/THIRD_PARTY_LICENSES/github.com/Microsoft/go-winio/LICENSE b/THIRD_PARTY_LICENSES/github.com/Microsoft/go-winio/LICENSE
90new file mode 100644
91index 0000000..b8b569d
92--- /dev/null
93+++ b/THIRD_PARTY_LICENSES/github.com/Microsoft/go-winio/LICENSE
94@@ -0,0 +1,22 @@
95+The MIT License (MIT)
96+
97+Copyright (c) 2015 Microsoft
98+
99+Permission is hereby granted, free of charge, to any person obtaining a copy
100+of this software and associated documentation files (the "Software"), to deal
101+in the Software without restriction, including without limitation the rights
102+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
103+copies of the Software, and to permit persons to whom the Software is
104+furnished to do so, subject to the following conditions:
105+
106+The above copyright notice and this permission notice shall be included in all
107+copies or substantial portions of the Software.
108+
109+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
110+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
111+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
112+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
113+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
114+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
115+SOFTWARE.
116+
117diff --git a/THIRD_PARTY_LICENSES/golang.org/x/xerrors/LICENSE b/THIRD_PARTY_LICENSES/golang.org/x/xerrors/LICENSE
118new file mode 100644
119index 0000000..e4a47e1
120--- /dev/null
121+++ b/THIRD_PARTY_LICENSES/golang.org/x/xerrors/LICENSE
122@@ -0,0 +1,27 @@
123+Copyright (c) 2019 The Go Authors. All rights reserved.
124+
125+Redistribution and use in source and binary forms, with or without
126+modification, are permitted provided that the following conditions are
127+met:
128+
129+ * Redistributions of source code must retain the above copyright
130+notice, this list of conditions and the following disclaimer.
131+ * Redistributions in binary form must reproduce the above
132+copyright notice, this list of conditions and the following disclaimer
133+in the documentation and/or other materials provided with the
134+distribution.
135+ * Neither the name of Google Inc. nor the names of its
136+contributors may be used to endorse or promote products derived from
137+this software without specific prior written permission.
138+
139+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
140+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
141+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
142+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
143+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
144+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
145+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
146+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
147+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
148+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
149+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
150diff --git a/THIRD_PARTY_LICENSES/google.golang.org/genproto/LICENSE b/THIRD_PARTY_LICENSES/google.golang.org/genproto/LICENSE
151deleted file mode 100644
152index d645695..0000000
153--- a/THIRD_PARTY_LICENSES/google.golang.org/genproto/LICENSE
154+++ /dev/null
155@@ -1,202 +0,0 @@
156-
157- Apache License
158- Version 2.0, January 2004
159- http://www.apache.org/licenses/
160-
161- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
162-
163- 1. Definitions.
164-
165- "License" shall mean the terms and conditions for use, reproduction,
166- and distribution as defined by Sections 1 through 9 of this document.
167-
168- "Licensor" shall mean the copyright owner or entity authorized by
169- the copyright owner that is granting the License.
170-
171- "Legal Entity" shall mean the union of the acting entity and all
172- other entities that control, are controlled by, or are under common
173- control with that entity. For the purposes of this definition,
174- "control" means (i) the power, direct or indirect, to cause the
175- direction or management of such entity, whether by contract or
176- otherwise, or (ii) ownership of fifty percent (50%) or more of the
177- outstanding shares, or (iii) beneficial ownership of such entity.
178-
179- "You" (or "Your") shall mean an individual or Legal Entity
180- exercising permissions granted by this License.
181-
182- "Source" form shall mean the preferred form for making modifications,
183- including but not limited to software source code, documentation
184- source, and configuration files.
185-
186- "Object" form shall mean any form resulting from mechanical
187- transformation or translation of a Source form, including but
188- not limited to compiled object code, generated documentation,
189- and conversions to other media types.
190-
191- "Work" shall mean the work of authorship, whether in Source or
192- Object form, made available under the License, as indicated by a
193- copyright notice that is included in or attached to the work
194- (an example is provided in the Appendix below).
195-
196- "Derivative Works" shall mean any work, whether in Source or Object
197- form, that is based on (or derived from) the Work and for which the
198- editorial revisions, annotations, elaborations, or other modifications
199- represent, as a whole, an original work of authorship. For the purposes
200- of this License, Derivative Works shall not include works that remain
201- separable from, or merely link (or bind by name) to the interfaces of,
202- the Work and Derivative Works thereof.
203-
204- "Contribution" shall mean any work of authorship, including
205- the original version of the Work and any modifications or additions
206- to that Work or Derivative Works thereof, that is intentionally
207- submitted to Licensor for inclusion in the Work by the copyright owner
208- or by an individual or Legal Entity authorized to submit on behalf of
209- the copyright owner. For the purposes of this definition, "submitted"
210- means any form of electronic, verbal, or written communication sent
211- to the Licensor or its representatives, including but not limited to
212- communication on electronic mailing lists, source code control systems,
213- and issue tracking systems that are managed by, or on behalf of, the
214- Licensor for the purpose of discussing and improving the Work, but
215- excluding communication that is conspicuously marked or otherwise
216- designated in writing by the copyright owner as "Not a Contribution."
217-
218- "Contributor" shall mean Licensor and any individual or Legal Entity
219- on behalf of whom a Contribution has been received by Licensor and
220- subsequently incorporated within the Work.
221-
222- 2. Grant of Copyright License. Subject to the terms and conditions of
223- this License, each Contributor hereby grants to You a perpetual,
224- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
225- copyright license to reproduce, prepare Derivative Works of,
226- publicly display, publicly perform, sublicense, and distribute the
227- Work and such Derivative Works in Source or Object form.
228-
229- 3. Grant of Patent License. Subject to the terms and conditions of
230- this License, each Contributor hereby grants to You a perpetual,
231- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
232- (except as stated in this section) patent license to make, have made,
233- use, offer to sell, sell, import, and otherwise transfer the Work,
234- where such license applies only to those patent claims licensable
235- by such Contributor that are necessarily infringed by their
236- Contribution(s) alone or by combination of their Contribution(s)
237- with the Work to which such Contribution(s) was submitted. If You
238- institute patent litigation against any entity (including a
239- cross-claim or counterclaim in a lawsuit) alleging that the Work
240- or a Contribution incorporated within the Work constitutes direct
241- or contributory patent infringement, then any patent licenses
242- granted to You under this License for that Work shall terminate
243- as of the date such litigation is filed.
244-
245- 4. Redistribution. You may reproduce and distribute copies of the
246- Work or Derivative Works thereof in any medium, with or without
247- modifications, and in Source or Object form, provided that You
248- meet the following conditions:
249-
250- (a) You must give any other recipients of the Work or
251- Derivative Works a copy of this License; and
252-
253- (b) You must cause any modified files to carry prominent notices
254- stating that You changed the files; and
255-
256- (c) You must retain, in the Source form of any Derivative Works
257- that You distribute, all copyright, patent, trademark, and
258- attribution notices from the Source form of the Work,
259- excluding those notices that do not pertain to any part of
260- the Derivative Works; and
261-
262- (d) If the Work includes a "NOTICE" text file as part of its
263- distribution, then any Derivative Works that You distribute must
264- include a readable copy of the attribution notices contained
265- within such NOTICE file, excluding those notices that do not
266- pertain to any part of the Derivative Works, in at least one
267- of the following places: within a NOTICE text file distributed
268- as part of the Derivative Works; within the Source form or
269- documentation, if provided along with the Derivative Works; or,
270- within a display generated by the Derivative Works, if and
271- wherever such third-party notices normally appear. The contents
272- of the NOTICE file are for informational purposes only and
273- do not modify the License. You may add Your own attribution
274- notices within Derivative Works that You distribute, alongside
275- or as an addendum to the NOTICE text from the Work, provided
276- that such additional attribution notices cannot be construed
277- as modifying the License.
278-
279- You may add Your own copyright statement to Your modifications and
280- may provide additional or different license terms and conditions
281- for use, reproduction, or distribution of Your modifications, or
282- for any such Derivative Works as a whole, provided Your use,
283- reproduction, and distribution of the Work otherwise complies with
284- the conditions stated in this License.
285-
286- 5. Submission of Contributions. Unless You explicitly state otherwise,
287- any Contribution intentionally submitted for inclusion in the Work
288- by You to the Licensor shall be under the terms and conditions of
289- this License, without any additional terms or conditions.
290- Notwithstanding the above, nothing herein shall supersede or modify
291- the terms of any separate license agreement you may have executed
292- with Licensor regarding such Contributions.
293-
294- 6. Trademarks. This License does not grant permission to use the trade
295- names, trademarks, service marks, or product names of the Licensor,
296- except as required for reasonable and customary use in describing the
297- origin of the Work and reproducing the content of the NOTICE file.
298-
299- 7. Disclaimer of Warranty. Unless required by applicable law or
300- agreed to in writing, Licensor provides the Work (and each
301- Contributor provides its Contributions) on an "AS IS" BASIS,
302- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
303- implied, including, without limitation, any warranties or conditions
304- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
305- PARTICULAR PURPOSE. You are solely responsible for determining the
306- appropriateness of using or redistributing the Work and assume any
307- risks associated with Your exercise of permissions under this License.
308-
309- 8. Limitation of Liability. In no event and under no legal theory,
310- whether in tort (including negligence), contract, or otherwise,
311- unless required by applicable law (such as deliberate and grossly
312- negligent acts) or agreed to in writing, shall any Contributor be
313- liable to You for damages, including any direct, indirect, special,
314- incidental, or consequential damages of any character arising as a
315- result of this License or out of the use or inability to use the
316- Work (including but not limited to damages for loss of goodwill,
317- work stoppage, computer failure or malfunction, or any and all
318- other commercial damages or losses), even if such Contributor
319- has been advised of the possibility of such damages.
320-
321- 9. Accepting Warranty or Additional Liability. While redistributing
322- the Work or Derivative Works thereof, You may choose to offer,
323- and charge a fee for, acceptance of support, warranty, indemnity,
324- or other liability obligations and/or rights consistent with this
325- License. However, in accepting such obligations, You may act only
326- on Your own behalf and on Your sole responsibility, not on behalf
327- of any other Contributor, and only if You agree to indemnify,
328- defend, and hold each Contributor harmless for any liability
329- incurred by, or claims asserted against, such Contributor by reason
330- of your accepting any such warranty or additional liability.
331-
332- END OF TERMS AND CONDITIONS
333-
334- APPENDIX: How to apply the Apache License to your work.
335-
336- To apply the Apache License to your work, attach the following
337- boilerplate notice, with the fields enclosed by brackets "[]"
338- replaced with your own identifying information. (Don't include
339- the brackets!) The text should be enclosed in the appropriate
340- comment syntax for the file format. We also recommend that a
341- file or class name and description of purpose be included on the
342- same "printed page" as the copyright notice for easier
343- identification within third-party archives.
344-
345- Copyright [yyyy] [name of copyright owner]
346-
347- Licensed under the Apache License, Version 2.0 (the "License");
348- you may not use this file except in compliance with the License.
349- You may obtain a copy of the License at
350-
351- http://www.apache.org/licenses/LICENSE-2.0
352-
353- Unless required by applicable law or agreed to in writing, software
354- distributed under the License is distributed on an "AS IS" BASIS,
355- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
356- See the License for the specific language governing permissions and
357- limitations under the License.
358diff --git a/THIRD_PARTY_LICENSES/software.sslmate.com/src/go-pkcs12/LICENSE b/THIRD_PARTY_LICENSES/software.sslmate.com/src/go-pkcs12/LICENSE
359index 6ac6b11..bcecd3d 100644
360--- a/THIRD_PARTY_LICENSES/software.sslmate.com/src/go-pkcs12/LICENSE
361+++ b/THIRD_PARTY_LICENSES/software.sslmate.com/src/go-pkcs12/LICENSE
362@@ -25,4 +25,4 @@ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
363 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
364 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
365 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
366-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
367\ No newline at end of file
368+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
369diff --git a/debian/changelog b/debian/changelog
370index b70ed12..e017e42 100644
371--- a/debian/changelog
372+++ b/debian/changelog
373@@ -1,3 +1,11 @@
374+google-guest-agent (20240213.00-0ubuntu1) noble; urgency=medium
375+
376+ * Update code to new upstream version/tag 20240213.00 (LP: #2054484)
377+ * d/extra/vendor: Update the vendored dependencies
378+ * New d/source/include-binaries file
379+
380+ -- Chloé 'kajiya' Smith <chloe.smith@canonical.com> Wed, 21 Feb 2024 00:25:47 +0000
381+
382 google-guest-agent (20231004.02-0ubuntu3) noble; urgency=medium
383
384 * d/control: Fix dependency version of `google-compute-engine-oslogin`
385diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/.gitattributes b/debian/extra/vendor/github.com/Microsoft/go-winio/.gitattributes
386new file mode 100644
387index 0000000..94f480d
388--- /dev/null
389+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/.gitattributes
390@@ -0,0 +1 @@
391+* text=auto eol=lf
392\ No newline at end of file
393diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/.gitignore b/debian/extra/vendor/github.com/Microsoft/go-winio/.gitignore
394new file mode 100644
395index 0000000..815e206
396--- /dev/null
397+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/.gitignore
398@@ -0,0 +1,10 @@
399+.vscode/
400+
401+*.exe
402+
403+# testing
404+testdata
405+
406+# go workspaces
407+go.work
408+go.work.sum
409diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/.golangci.yml b/debian/extra/vendor/github.com/Microsoft/go-winio/.golangci.yml
410new file mode 100644
411index 0000000..7b503d2
412--- /dev/null
413+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/.golangci.yml
414@@ -0,0 +1,149 @@
415+run:
416+ skip-dirs:
417+ - pkg/etw/sample
418+
419+linters:
420+ enable:
421+ # style
422+ - containedctx # struct contains a context
423+ - dupl # duplicate code
424+ - errname # erorrs are named correctly
425+ - nolintlint # "//nolint" directives are properly explained
426+ - revive # golint replacement
427+ - unconvert # unnecessary conversions
428+ - wastedassign
429+
430+ # bugs, performance, unused, etc ...
431+ - contextcheck # function uses a non-inherited context
432+ - errorlint # errors not wrapped for 1.13
433+ - exhaustive # check exhaustiveness of enum switch statements
434+ - gofmt # files are gofmt'ed
435+ - gosec # security
436+ - nilerr # returns nil even with non-nil error
437+ - unparam # unused function params
438+
439+issues:
440+ exclude-rules:
441+ # err is very often shadowed in nested scopes
442+ - linters:
443+ - govet
444+ text: '^shadow: declaration of "err" shadows declaration'
445+
446+ # ignore long lines for skip autogen directives
447+ - linters:
448+ - revive
449+ text: "^line-length-limit: "
450+ source: "^//(go:generate|sys) "
451+
452+ #TODO: remove after upgrading to go1.18
453+ # ignore comment spacing for nolint and sys directives
454+ - linters:
455+ - revive
456+ text: "^comment-spacings: no space between comment delimiter and comment text"
457+ source: "//(cspell:|nolint:|sys |todo)"
458+
459+ # not on go 1.18 yet, so no any
460+ - linters:
461+ - revive
462+ text: "^use-any: since GO 1.18 'interface{}' can be replaced by 'any'"
463+
464+ # allow unjustified ignores of error checks in defer statements
465+ - linters:
466+ - nolintlint
467+ text: "^directive `//nolint:errcheck` should provide explanation"
468+ source: '^\s*defer '
469+
470+ # allow unjustified ignores of error lints for io.EOF
471+ - linters:
472+ - nolintlint
473+ text: "^directive `//nolint:errorlint` should provide explanation"
474+ source: '[=|!]= io.EOF'
475+
476+
477+linters-settings:
478+ exhaustive:
479+ default-signifies-exhaustive: true
480+ govet:
481+ enable-all: true
482+ disable:
483+ # struct order is often for Win32 compat
484+ # also, ignore pointer bytes/GC issues for now until performance becomes an issue
485+ - fieldalignment
486+ check-shadowing: true
487+ nolintlint:
488+ allow-leading-space: false
489+ require-explanation: true
490+ require-specific: true
491+ revive:
492+ # revive is more configurable than static check, so likely the preferred alternative to static-check
493+ # (once the perf issue is solved: https://github.com/golangci/golangci-lint/issues/2997)
494+ enable-all-rules:
495+ true
496+ # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
497+ rules:
498+ # rules with required arguments
499+ - name: argument-limit
500+ disabled: true
501+ - name: banned-characters
502+ disabled: true
503+ - name: cognitive-complexity
504+ disabled: true
505+ - name: cyclomatic
506+ disabled: true
507+ - name: file-header
508+ disabled: true
509+ - name: function-length
510+ disabled: true
511+ - name: function-result-limit
512+ disabled: true
513+ - name: max-public-structs
514+ disabled: true
515+ # geneally annoying rules
516+ - name: add-constant # complains about any and all strings and integers
517+ disabled: true
518+ - name: confusing-naming # we frequently use "Foo()" and "foo()" together
519+ disabled: true
520+ - name: flag-parameter # excessive, and a common idiom we use
521+ disabled: true
522+ - name: unhandled-error # warns over common fmt.Print* and io.Close; rely on errcheck instead
523+ disabled: true
524+ # general config
525+ - name: line-length-limit
526+ arguments:
527+ - 140
528+ - name: var-naming
529+ arguments:
530+ - []
531+ - - CID
532+ - CRI
533+ - CTRD
534+ - DACL
535+ - DLL
536+ - DOS
537+ - ETW
538+ - FSCTL
539+ - GCS
540+ - GMSA
541+ - HCS
542+ - HV
543+ - IO
544+ - LCOW
545+ - LDAP
546+ - LPAC
547+ - LTSC
548+ - MMIO
549+ - NT
550+ - OCI
551+ - PMEM
552+ - PWSH
553+ - RX
554+ - SACl
555+ - SID
556+ - SMB
557+ - TX
558+ - VHD
559+ - VHDX
560+ - VMID
561+ - VPCI
562+ - WCOW
563+ - WIM
564diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/CODEOWNERS b/debian/extra/vendor/github.com/Microsoft/go-winio/CODEOWNERS
565new file mode 100644
566index 0000000..ae1b494
567--- /dev/null
568+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/CODEOWNERS
569@@ -0,0 +1 @@
570+ * @microsoft/containerplat
571diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/LICENSE b/debian/extra/vendor/github.com/Microsoft/go-winio/LICENSE
572new file mode 100644
573index 0000000..b8b569d
574--- /dev/null
575+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/LICENSE
576@@ -0,0 +1,22 @@
577+The MIT License (MIT)
578+
579+Copyright (c) 2015 Microsoft
580+
581+Permission is hereby granted, free of charge, to any person obtaining a copy
582+of this software and associated documentation files (the "Software"), to deal
583+in the Software without restriction, including without limitation the rights
584+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
585+copies of the Software, and to permit persons to whom the Software is
586+furnished to do so, subject to the following conditions:
587+
588+The above copyright notice and this permission notice shall be included in all
589+copies or substantial portions of the Software.
590+
591+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
592+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
593+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
594+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
595+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
596+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
597+SOFTWARE.
598+
599diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/README.md b/debian/extra/vendor/github.com/Microsoft/go-winio/README.md
600new file mode 100644
601index 0000000..7474b4f
602--- /dev/null
603+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/README.md
604@@ -0,0 +1,89 @@
605+# go-winio [![Build Status](https://github.com/microsoft/go-winio/actions/workflows/ci.yml/badge.svg)](https://github.com/microsoft/go-winio/actions/workflows/ci.yml)
606+
607+This repository contains utilities for efficiently performing Win32 IO operations in
608+Go. Currently, this is focused on accessing named pipes and other file handles, and
609+for using named pipes as a net transport.
610+
611+This code relies on IO completion ports to avoid blocking IO on system threads, allowing Go
612+to reuse the thread to schedule another goroutine. This limits support to Windows Vista and
613+newer operating systems. This is similar to the implementation of network sockets in Go's net
614+package.
615+
616+Please see the LICENSE file for licensing information.
617+
618+## Contributing
619+
620+This project welcomes contributions and suggestions.
621+Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that
622+you have the right to, and actually do, grant us the rights to use your contribution.
623+For details, visit [Microsoft CLA](https://cla.microsoft.com).
624+
625+When you submit a pull request, a CLA-bot will automatically determine whether you need to
626+provide a CLA and decorate the PR appropriately (e.g., label, comment).
627+Simply follow the instructions provided by the bot.
628+You will only need to do this once across all repos using our CLA.
629+
630+Additionally, the pull request pipeline requires the following steps to be performed before
631+mergining.
632+
633+### Code Sign-Off
634+
635+We require that contributors sign their commits using [`git commit --signoff`][git-commit-s]
636+to certify they either authored the work themselves or otherwise have permission to use it in this project.
637+
638+A range of commits can be signed off using [`git rebase --signoff`][git-rebase-s].
639+
640+Please see [the developer certificate](https://developercertificate.org) for more info,
641+as well as to make sure that you can attest to the rules listed.
642+Our CI uses the DCO Github app to ensure that all commits in a given PR are signed-off.
643+
644+### Linting
645+
646+Code must pass a linting stage, which uses [`golangci-lint`][lint].
647+The linting settings are stored in [`.golangci.yaml`](./.golangci.yaml), and can be run
648+automatically with VSCode by adding the following to your workspace or folder settings:
649+
650+```json
651+ "go.lintTool": "golangci-lint",
652+ "go.lintOnSave": "package",
653+```
654+
655+Additional editor [integrations options are also available][lint-ide].
656+
657+Alternatively, `golangci-lint` can be [installed locally][lint-install] and run from the repo root:
658+
659+```shell
660+# use . or specify a path to only lint a package
661+# to show all lint errors, use flags "--max-issues-per-linter=0 --max-same-issues=0"
662+> golangci-lint run ./...
663+```
664+
665+### Go Generate
666+
667+The pipeline checks that auto-generated code, via `go generate`, are up to date.
668+
669+This can be done for the entire repo:
670+
671+```shell
672+> go generate ./...
673+```
674+
675+## Code of Conduct
676+
677+This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
678+For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
679+contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
680+
681+## Special Thanks
682+
683+Thanks to [natefinch][natefinch] for the inspiration for this library.
684+See [npipe](https://github.com/natefinch/npipe) for another named pipe implementation.
685+
686+[lint]: https://golangci-lint.run/
687+[lint-ide]: https://golangci-lint.run/usage/integrations/#editor-integration
688+[lint-install]: https://golangci-lint.run/usage/install/#local-installation
689+
690+[git-commit-s]: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--s
691+[git-rebase-s]: https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---signoff
692+
693+[natefinch]: https://github.com/natefinch
694diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/SECURITY.md b/debian/extra/vendor/github.com/Microsoft/go-winio/SECURITY.md
695new file mode 100644
696index 0000000..869fdfe
697--- /dev/null
698+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/SECURITY.md
699@@ -0,0 +1,41 @@
700+<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
701+
702+## Security
703+
704+Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
705+
706+If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
707+
708+## Reporting Security Issues
709+
710+**Please do not report security vulnerabilities through public GitHub issues.**
711+
712+Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
713+
714+If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
715+
716+You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
717+
718+Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
719+
720+ * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
721+ * Full paths of source file(s) related to the manifestation of the issue
722+ * The location of the affected source code (tag/branch/commit or direct URL)
723+ * Any special configuration required to reproduce the issue
724+ * Step-by-step instructions to reproduce the issue
725+ * Proof-of-concept or exploit code (if possible)
726+ * Impact of the issue, including how an attacker might exploit the issue
727+
728+This information will help us triage your report more quickly.
729+
730+If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
731+
732+## Preferred Languages
733+
734+We prefer all communications to be in English.
735+
736+## Policy
737+
738+Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
739+
740+<!-- END MICROSOFT SECURITY.MD BLOCK -->
741diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/backup.go b/debian/extra/vendor/github.com/Microsoft/go-winio/backup.go
742new file mode 100644
743index 0000000..09621c8
744--- /dev/null
745+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/backup.go
746@@ -0,0 +1,290 @@
747+//go:build windows
748+// +build windows
749+
750+package winio
751+
752+import (
753+ "encoding/binary"
754+ "errors"
755+ "fmt"
756+ "io"
757+ "os"
758+ "runtime"
759+ "syscall"
760+ "unicode/utf16"
761+
762+ "golang.org/x/sys/windows"
763+)
764+
765+//sys backupRead(h syscall.Handle, b []byte, bytesRead *uint32, abort bool, processSecurity bool, context *uintptr) (err error) = BackupRead
766+//sys backupWrite(h syscall.Handle, b []byte, bytesWritten *uint32, abort bool, processSecurity bool, context *uintptr) (err error) = BackupWrite
767+
768+const (
769+ BackupData = uint32(iota + 1)
770+ BackupEaData
771+ BackupSecurity
772+ BackupAlternateData
773+ BackupLink
774+ BackupPropertyData
775+ BackupObjectId //revive:disable-line:var-naming ID, not Id
776+ BackupReparseData
777+ BackupSparseBlock
778+ BackupTxfsData
779+)
780+
781+const (
782+ StreamSparseAttributes = uint32(8)
783+)
784+
785+//nolint:revive // var-naming: ALL_CAPS
786+const (
787+ WRITE_DAC = windows.WRITE_DAC
788+ WRITE_OWNER = windows.WRITE_OWNER
789+ ACCESS_SYSTEM_SECURITY = windows.ACCESS_SYSTEM_SECURITY
790+)
791+
792+// BackupHeader represents a backup stream of a file.
793+type BackupHeader struct {
794+ //revive:disable-next-line:var-naming ID, not Id
795+ Id uint32 // The backup stream ID
796+ Attributes uint32 // Stream attributes
797+ Size int64 // The size of the stream in bytes
798+ Name string // The name of the stream (for BackupAlternateData only).
799+ Offset int64 // The offset of the stream in the file (for BackupSparseBlock only).
800+}
801+
802+type win32StreamID struct {
803+ StreamID uint32
804+ Attributes uint32
805+ Size uint64
806+ NameSize uint32
807+}
808+
809+// BackupStreamReader reads from a stream produced by the BackupRead Win32 API and produces a series
810+// of BackupHeader values.
811+type BackupStreamReader struct {
812+ r io.Reader
813+ bytesLeft int64
814+}
815+
816+// NewBackupStreamReader produces a BackupStreamReader from any io.Reader.
817+func NewBackupStreamReader(r io.Reader) *BackupStreamReader {
818+ return &BackupStreamReader{r, 0}
819+}
820+
821+// Next returns the next backup stream and prepares for calls to Read(). It skips the remainder of the current stream if
822+// it was not completely read.
823+func (r *BackupStreamReader) Next() (*BackupHeader, error) {
824+ if r.bytesLeft > 0 { //nolint:nestif // todo: flatten this
825+ if s, ok := r.r.(io.Seeker); ok {
826+ // Make sure Seek on io.SeekCurrent sometimes succeeds
827+ // before trying the actual seek.
828+ if _, err := s.Seek(0, io.SeekCurrent); err == nil {
829+ if _, err = s.Seek(r.bytesLeft, io.SeekCurrent); err != nil {
830+ return nil, err
831+ }
832+ r.bytesLeft = 0
833+ }
834+ }
835+ if _, err := io.Copy(io.Discard, r); err != nil {
836+ return nil, err
837+ }
838+ }
839+ var wsi win32StreamID
840+ if err := binary.Read(r.r, binary.LittleEndian, &wsi); err != nil {
841+ return nil, err
842+ }
843+ hdr := &BackupHeader{
844+ Id: wsi.StreamID,
845+ Attributes: wsi.Attributes,
846+ Size: int64(wsi.Size),
847+ }
848+ if wsi.NameSize != 0 {
849+ name := make([]uint16, int(wsi.NameSize/2))
850+ if err := binary.Read(r.r, binary.LittleEndian, name); err != nil {
851+ return nil, err
852+ }
853+ hdr.Name = syscall.UTF16ToString(name)
854+ }
855+ if wsi.StreamID == BackupSparseBlock {
856+ if err := binary.Read(r.r, binary.LittleEndian, &hdr.Offset); err != nil {
857+ return nil, err
858+ }
859+ hdr.Size -= 8
860+ }
861+ r.bytesLeft = hdr.Size
862+ return hdr, nil
863+}
864+
865+// Read reads from the current backup stream.
866+func (r *BackupStreamReader) Read(b []byte) (int, error) {
867+ if r.bytesLeft == 0 {
868+ return 0, io.EOF
869+ }
870+ if int64(len(b)) > r.bytesLeft {
871+ b = b[:r.bytesLeft]
872+ }
873+ n, err := r.r.Read(b)
874+ r.bytesLeft -= int64(n)
875+ if err == io.EOF {
876+ err = io.ErrUnexpectedEOF
877+ } else if r.bytesLeft == 0 && err == nil {
878+ err = io.EOF
879+ }
880+ return n, err
881+}
882+
883+// BackupStreamWriter writes a stream compatible with the BackupWrite Win32 API.
884+type BackupStreamWriter struct {
885+ w io.Writer
886+ bytesLeft int64
887+}
888+
889+// NewBackupStreamWriter produces a BackupStreamWriter on top of an io.Writer.
890+func NewBackupStreamWriter(w io.Writer) *BackupStreamWriter {
891+ return &BackupStreamWriter{w, 0}
892+}
893+
894+// WriteHeader writes the next backup stream header and prepares for calls to Write().
895+func (w *BackupStreamWriter) WriteHeader(hdr *BackupHeader) error {
896+ if w.bytesLeft != 0 {
897+ return fmt.Errorf("missing %d bytes", w.bytesLeft)
898+ }
899+ name := utf16.Encode([]rune(hdr.Name))
900+ wsi := win32StreamID{
901+ StreamID: hdr.Id,
902+ Attributes: hdr.Attributes,
903+ Size: uint64(hdr.Size),
904+ NameSize: uint32(len(name) * 2),
905+ }
906+ if hdr.Id == BackupSparseBlock {
907+ // Include space for the int64 block offset
908+ wsi.Size += 8
909+ }
910+ if err := binary.Write(w.w, binary.LittleEndian, &wsi); err != nil {
911+ return err
912+ }
913+ if len(name) != 0 {
914+ if err := binary.Write(w.w, binary.LittleEndian, name); err != nil {
915+ return err
916+ }
917+ }
918+ if hdr.Id == BackupSparseBlock {
919+ if err := binary.Write(w.w, binary.LittleEndian, hdr.Offset); err != nil {
920+ return err
921+ }
922+ }
923+ w.bytesLeft = hdr.Size
924+ return nil
925+}
926+
927+// Write writes to the current backup stream.
928+func (w *BackupStreamWriter) Write(b []byte) (int, error) {
929+ if w.bytesLeft < int64(len(b)) {
930+ return 0, fmt.Errorf("too many bytes by %d", int64(len(b))-w.bytesLeft)
931+ }
932+ n, err := w.w.Write(b)
933+ w.bytesLeft -= int64(n)
934+ return n, err
935+}
936+
937+// BackupFileReader provides an io.ReadCloser interface on top of the BackupRead Win32 API.
938+type BackupFileReader struct {
939+ f *os.File
940+ includeSecurity bool
941+ ctx uintptr
942+}
943+
944+// NewBackupFileReader returns a new BackupFileReader from a file handle. If includeSecurity is true,
945+// Read will attempt to read the security descriptor of the file.
946+func NewBackupFileReader(f *os.File, includeSecurity bool) *BackupFileReader {
947+ r := &BackupFileReader{f, includeSecurity, 0}
948+ return r
949+}
950+
951+// Read reads a backup stream from the file by calling the Win32 API BackupRead().
952+func (r *BackupFileReader) Read(b []byte) (int, error) {
953+ var bytesRead uint32
954+ err := backupRead(syscall.Handle(r.f.Fd()), b, &bytesRead, false, r.includeSecurity, &r.ctx)
955+ if err != nil {
956+ return 0, &os.PathError{Op: "BackupRead", Path: r.f.Name(), Err: err}
957+ }
958+ runtime.KeepAlive(r.f)
959+ if bytesRead == 0 {
960+ return 0, io.EOF
961+ }
962+ return int(bytesRead), nil
963+}
964+
965+// Close frees Win32 resources associated with the BackupFileReader. It does not close
966+// the underlying file.
967+func (r *BackupFileReader) Close() error {
968+ if r.ctx != 0 {
969+ _ = backupRead(syscall.Handle(r.f.Fd()), nil, nil, true, false, &r.ctx)
970+ runtime.KeepAlive(r.f)
971+ r.ctx = 0
972+ }
973+ return nil
974+}
975+
976+// BackupFileWriter provides an io.WriteCloser interface on top of the BackupWrite Win32 API.
977+type BackupFileWriter struct {
978+ f *os.File
979+ includeSecurity bool
980+ ctx uintptr
981+}
982+
983+// NewBackupFileWriter returns a new BackupFileWriter from a file handle. If includeSecurity is true,
984+// Write() will attempt to restore the security descriptor from the stream.
985+func NewBackupFileWriter(f *os.File, includeSecurity bool) *BackupFileWriter {
986+ w := &BackupFileWriter{f, includeSecurity, 0}
987+ return w
988+}
989+
990+// Write restores a portion of the file using the provided backup stream.
991+func (w *BackupFileWriter) Write(b []byte) (int, error) {
992+ var bytesWritten uint32
993+ err := backupWrite(syscall.Handle(w.f.Fd()), b, &bytesWritten, false, w.includeSecurity, &w.ctx)
994+ if err != nil {
995+ return 0, &os.PathError{Op: "BackupWrite", Path: w.f.Name(), Err: err}
996+ }
997+ runtime.KeepAlive(w.f)
998+ if int(bytesWritten) != len(b) {
999+ return int(bytesWritten), errors.New("not all bytes could be written")
1000+ }
1001+ return len(b), nil
1002+}
1003+
1004+// Close frees Win32 resources associated with the BackupFileWriter. It does not
1005+// close the underlying file.
1006+func (w *BackupFileWriter) Close() error {
1007+ if w.ctx != 0 {
1008+ _ = backupWrite(syscall.Handle(w.f.Fd()), nil, nil, true, false, &w.ctx)
1009+ runtime.KeepAlive(w.f)
1010+ w.ctx = 0
1011+ }
1012+ return nil
1013+}
1014+
1015+// OpenForBackup opens a file or directory, potentially skipping access checks if the backup
1016+// or restore privileges have been acquired.
1017+//
1018+// If the file opened was a directory, it cannot be used with Readdir().
1019+func OpenForBackup(path string, access uint32, share uint32, createmode uint32) (*os.File, error) {
1020+ winPath, err := syscall.UTF16FromString(path)
1021+ if err != nil {
1022+ return nil, err
1023+ }
1024+ h, err := syscall.CreateFile(&winPath[0],
1025+ access,
1026+ share,
1027+ nil,
1028+ createmode,
1029+ syscall.FILE_FLAG_BACKUP_SEMANTICS|syscall.FILE_FLAG_OPEN_REPARSE_POINT,
1030+ 0)
1031+ if err != nil {
1032+ err = &os.PathError{Op: "open", Path: path, Err: err}
1033+ return nil, err
1034+ }
1035+ return os.NewFile(uintptr(h), path), nil
1036+}
1037diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/doc.go b/debian/extra/vendor/github.com/Microsoft/go-winio/doc.go
1038new file mode 100644
1039index 0000000..1f5bfe2
1040--- /dev/null
1041+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/doc.go
1042@@ -0,0 +1,22 @@
1043+// This package provides utilities for efficiently performing Win32 IO operations in Go.
1044+// Currently, this package is provides support for genreal IO and management of
1045+// - named pipes
1046+// - files
1047+// - [Hyper-V sockets]
1048+//
1049+// This code is similar to Go's [net] package, and uses IO completion ports to avoid
1050+// blocking IO on system threads, allowing Go to reuse the thread to schedule other goroutines.
1051+//
1052+// This limits support to Windows Vista and newer operating systems.
1053+//
1054+// Additionally, this package provides support for:
1055+// - creating and managing GUIDs
1056+// - writing to [ETW]
1057+// - opening and manageing VHDs
1058+// - parsing [Windows Image files]
1059+// - auto-generating Win32 API code
1060+//
1061+// [Hyper-V sockets]: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/make-integration-service
1062+// [ETW]: https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/event-tracing-for-windows--etw-
1063+// [Windows Image files]: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/work-with-windows-images
1064+package winio
1065diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/ea.go b/debian/extra/vendor/github.com/Microsoft/go-winio/ea.go
1066new file mode 100644
1067index 0000000..e104dbd
1068--- /dev/null
1069+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/ea.go
1070@@ -0,0 +1,137 @@
1071+package winio
1072+
1073+import (
1074+ "bytes"
1075+ "encoding/binary"
1076+ "errors"
1077+)
1078+
1079+type fileFullEaInformation struct {
1080+ NextEntryOffset uint32
1081+ Flags uint8
1082+ NameLength uint8
1083+ ValueLength uint16
1084+}
1085+
1086+var (
1087+ fileFullEaInformationSize = binary.Size(&fileFullEaInformation{})
1088+
1089+ errInvalidEaBuffer = errors.New("invalid extended attribute buffer")
1090+ errEaNameTooLarge = errors.New("extended attribute name too large")
1091+ errEaValueTooLarge = errors.New("extended attribute value too large")
1092+)
1093+
1094+// ExtendedAttribute represents a single Windows EA.
1095+type ExtendedAttribute struct {
1096+ Name string
1097+ Value []byte
1098+ Flags uint8
1099+}
1100+
1101+func parseEa(b []byte) (ea ExtendedAttribute, nb []byte, err error) {
1102+ var info fileFullEaInformation
1103+ err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &info)
1104+ if err != nil {
1105+ err = errInvalidEaBuffer
1106+ return ea, nb, err
1107+ }
1108+
1109+ nameOffset := fileFullEaInformationSize
1110+ nameLen := int(info.NameLength)
1111+ valueOffset := nameOffset + int(info.NameLength) + 1
1112+ valueLen := int(info.ValueLength)
1113+ nextOffset := int(info.NextEntryOffset)
1114+ if valueLen+valueOffset > len(b) || nextOffset < 0 || nextOffset > len(b) {
1115+ err = errInvalidEaBuffer
1116+ return ea, nb, err
1117+ }
1118+
1119+ ea.Name = string(b[nameOffset : nameOffset+nameLen])
1120+ ea.Value = b[valueOffset : valueOffset+valueLen]
1121+ ea.Flags = info.Flags
1122+ if info.NextEntryOffset != 0 {
1123+ nb = b[info.NextEntryOffset:]
1124+ }
1125+ return ea, nb, err
1126+}
1127+
1128+// DecodeExtendedAttributes decodes a list of EAs from a FILE_FULL_EA_INFORMATION
1129+// buffer retrieved from BackupRead, ZwQueryEaFile, etc.
1130+func DecodeExtendedAttributes(b []byte) (eas []ExtendedAttribute, err error) {
1131+ for len(b) != 0 {
1132+ ea, nb, err := parseEa(b)
1133+ if err != nil {
1134+ return nil, err
1135+ }
1136+
1137+ eas = append(eas, ea)
1138+ b = nb
1139+ }
1140+ return eas, err
1141+}
1142+
1143+func writeEa(buf *bytes.Buffer, ea *ExtendedAttribute, last bool) error {
1144+ if int(uint8(len(ea.Name))) != len(ea.Name) {
1145+ return errEaNameTooLarge
1146+ }
1147+ if int(uint16(len(ea.Value))) != len(ea.Value) {
1148+ return errEaValueTooLarge
1149+ }
1150+ entrySize := uint32(fileFullEaInformationSize + len(ea.Name) + 1 + len(ea.Value))
1151+ withPadding := (entrySize + 3) &^ 3
1152+ nextOffset := uint32(0)
1153+ if !last {
1154+ nextOffset = withPadding
1155+ }
1156+ info := fileFullEaInformation{
1157+ NextEntryOffset: nextOffset,
1158+ Flags: ea.Flags,
1159+ NameLength: uint8(len(ea.Name)),
1160+ ValueLength: uint16(len(ea.Value)),
1161+ }
1162+
1163+ err := binary.Write(buf, binary.LittleEndian, &info)
1164+ if err != nil {
1165+ return err
1166+ }
1167+
1168+ _, err = buf.Write([]byte(ea.Name))
1169+ if err != nil {
1170+ return err
1171+ }
1172+
1173+ err = buf.WriteByte(0)
1174+ if err != nil {
1175+ return err
1176+ }
1177+
1178+ _, err = buf.Write(ea.Value)
1179+ if err != nil {
1180+ return err
1181+ }
1182+
1183+ _, err = buf.Write([]byte{0, 0, 0}[0 : withPadding-entrySize])
1184+ if err != nil {
1185+ return err
1186+ }
1187+
1188+ return nil
1189+}
1190+
1191+// EncodeExtendedAttributes encodes a list of EAs into a FILE_FULL_EA_INFORMATION
1192+// buffer for use with BackupWrite, ZwSetEaFile, etc.
1193+func EncodeExtendedAttributes(eas []ExtendedAttribute) ([]byte, error) {
1194+ var buf bytes.Buffer
1195+ for i := range eas {
1196+ last := false
1197+ if i == len(eas)-1 {
1198+ last = true
1199+ }
1200+
1201+ err := writeEa(&buf, &eas[i], last)
1202+ if err != nil {
1203+ return nil, err
1204+ }
1205+ }
1206+ return buf.Bytes(), nil
1207+}
1208diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/file.go b/debian/extra/vendor/github.com/Microsoft/go-winio/file.go
1209new file mode 100644
1210index 0000000..175a99d
1211--- /dev/null
1212+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/file.go
1213@@ -0,0 +1,331 @@
1214+//go:build windows
1215+// +build windows
1216+
1217+package winio
1218+
1219+import (
1220+ "errors"
1221+ "io"
1222+ "runtime"
1223+ "sync"
1224+ "sync/atomic"
1225+ "syscall"
1226+ "time"
1227+
1228+ "golang.org/x/sys/windows"
1229+)
1230+
1231+//sys cancelIoEx(file syscall.Handle, o *syscall.Overlapped) (err error) = CancelIoEx
1232+//sys createIoCompletionPort(file syscall.Handle, port syscall.Handle, key uintptr, threadCount uint32) (newport syscall.Handle, err error) = CreateIoCompletionPort
1233+//sys getQueuedCompletionStatus(port syscall.Handle, bytes *uint32, key *uintptr, o **ioOperation, timeout uint32) (err error) = GetQueuedCompletionStatus
1234+//sys setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) = SetFileCompletionNotificationModes
1235+//sys wsaGetOverlappedResult(h syscall.Handle, o *syscall.Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) = ws2_32.WSAGetOverlappedResult
1236+
1237+type atomicBool int32
1238+
1239+func (b *atomicBool) isSet() bool { return atomic.LoadInt32((*int32)(b)) != 0 }
1240+func (b *atomicBool) setFalse() { atomic.StoreInt32((*int32)(b), 0) }
1241+func (b *atomicBool) setTrue() { atomic.StoreInt32((*int32)(b), 1) }
1242+
1243+//revive:disable-next-line:predeclared Keep "new" to maintain consistency with "atomic" pkg
1244+func (b *atomicBool) swap(new bool) bool {
1245+ var newInt int32
1246+ if new {
1247+ newInt = 1
1248+ }
1249+ return atomic.SwapInt32((*int32)(b), newInt) == 1
1250+}
1251+
1252+var (
1253+ ErrFileClosed = errors.New("file has already been closed")
1254+ ErrTimeout = &timeoutError{}
1255+)
1256+
1257+type timeoutError struct{}
1258+
1259+func (*timeoutError) Error() string { return "i/o timeout" }
1260+func (*timeoutError) Timeout() bool { return true }
1261+func (*timeoutError) Temporary() bool { return true }
1262+
1263+type timeoutChan chan struct{}
1264+
1265+var ioInitOnce sync.Once
1266+var ioCompletionPort syscall.Handle
1267+
1268+// ioResult contains the result of an asynchronous IO operation.
1269+type ioResult struct {
1270+ bytes uint32
1271+ err error
1272+}
1273+
1274+// ioOperation represents an outstanding asynchronous Win32 IO.
1275+type ioOperation struct {
1276+ o syscall.Overlapped
1277+ ch chan ioResult
1278+}
1279+
1280+func initIO() {
1281+ h, err := createIoCompletionPort(syscall.InvalidHandle, 0, 0, 0xffffffff)
1282+ if err != nil {
1283+ panic(err)
1284+ }
1285+ ioCompletionPort = h
1286+ go ioCompletionProcessor(h)
1287+}
1288+
1289+// win32File implements Reader, Writer, and Closer on a Win32 handle without blocking in a syscall.
1290+// It takes ownership of this handle and will close it if it is garbage collected.
1291+type win32File struct {
1292+ handle syscall.Handle
1293+ wg sync.WaitGroup
1294+ wgLock sync.RWMutex
1295+ closing atomicBool
1296+ socket bool
1297+ readDeadline deadlineHandler
1298+ writeDeadline deadlineHandler
1299+}
1300+
1301+type deadlineHandler struct {
1302+ setLock sync.Mutex
1303+ channel timeoutChan
1304+ channelLock sync.RWMutex
1305+ timer *time.Timer
1306+ timedout atomicBool
1307+}
1308+
1309+// makeWin32File makes a new win32File from an existing file handle.
1310+func makeWin32File(h syscall.Handle) (*win32File, error) {
1311+ f := &win32File{handle: h}
1312+ ioInitOnce.Do(initIO)
1313+ _, err := createIoCompletionPort(h, ioCompletionPort, 0, 0xffffffff)
1314+ if err != nil {
1315+ return nil, err
1316+ }
1317+ err = setFileCompletionNotificationModes(h, windows.FILE_SKIP_COMPLETION_PORT_ON_SUCCESS|windows.FILE_SKIP_SET_EVENT_ON_HANDLE)
1318+ if err != nil {
1319+ return nil, err
1320+ }
1321+ f.readDeadline.channel = make(timeoutChan)
1322+ f.writeDeadline.channel = make(timeoutChan)
1323+ return f, nil
1324+}
1325+
1326+func MakeOpenFile(h syscall.Handle) (io.ReadWriteCloser, error) {
1327+ // If we return the result of makeWin32File directly, it can result in an
1328+ // interface-wrapped nil, rather than a nil interface value.
1329+ f, err := makeWin32File(h)
1330+ if err != nil {
1331+ return nil, err
1332+ }
1333+ return f, nil
1334+}
1335+
1336+// closeHandle closes the resources associated with a Win32 handle.
1337+func (f *win32File) closeHandle() {
1338+ f.wgLock.Lock()
1339+ // Atomically set that we are closing, releasing the resources only once.
1340+ if !f.closing.swap(true) {
1341+ f.wgLock.Unlock()
1342+ // cancel all IO and wait for it to complete
1343+ _ = cancelIoEx(f.handle, nil)
1344+ f.wg.Wait()
1345+ // at this point, no new IO can start
1346+ syscall.Close(f.handle)
1347+ f.handle = 0
1348+ } else {
1349+ f.wgLock.Unlock()
1350+ }
1351+}
1352+
1353+// Close closes a win32File.
1354+func (f *win32File) Close() error {
1355+ f.closeHandle()
1356+ return nil
1357+}
1358+
1359+// IsClosed checks if the file has been closed.
1360+func (f *win32File) IsClosed() bool {
1361+ return f.closing.isSet()
1362+}
1363+
1364+// prepareIO prepares for a new IO operation.
1365+// The caller must call f.wg.Done() when the IO is finished, prior to Close() returning.
1366+func (f *win32File) prepareIO() (*ioOperation, error) {
1367+ f.wgLock.RLock()
1368+ if f.closing.isSet() {
1369+ f.wgLock.RUnlock()
1370+ return nil, ErrFileClosed
1371+ }
1372+ f.wg.Add(1)
1373+ f.wgLock.RUnlock()
1374+ c := &ioOperation{}
1375+ c.ch = make(chan ioResult)
1376+ return c, nil
1377+}
1378+
1379+// ioCompletionProcessor processes completed async IOs forever.
1380+func ioCompletionProcessor(h syscall.Handle) {
1381+ for {
1382+ var bytes uint32
1383+ var key uintptr
1384+ var op *ioOperation
1385+ err := getQueuedCompletionStatus(h, &bytes, &key, &op, syscall.INFINITE)
1386+ if op == nil {
1387+ panic(err)
1388+ }
1389+ op.ch <- ioResult{bytes, err}
1390+ }
1391+}
1392+
1393+// todo: helsaawy - create an asyncIO version that takes a context
1394+
1395+// asyncIO processes the return value from ReadFile or WriteFile, blocking until
1396+// the operation has actually completed.
1397+func (f *win32File) asyncIO(c *ioOperation, d *deadlineHandler, bytes uint32, err error) (int, error) {
1398+ if err != syscall.ERROR_IO_PENDING { //nolint:errorlint // err is Errno
1399+ return int(bytes), err
1400+ }
1401+
1402+ if f.closing.isSet() {
1403+ _ = cancelIoEx(f.handle, &c.o)
1404+ }
1405+
1406+ var timeout timeoutChan
1407+ if d != nil {
1408+ d.channelLock.Lock()
1409+ timeout = d.channel
1410+ d.channelLock.Unlock()
1411+ }
1412+
1413+ var r ioResult
1414+ select {
1415+ case r = <-c.ch:
1416+ err = r.err
1417+ if err == syscall.ERROR_OPERATION_ABORTED { //nolint:errorlint // err is Errno
1418+ if f.closing.isSet() {
1419+ err = ErrFileClosed
1420+ }
1421+ } else if err != nil && f.socket {
1422+ // err is from Win32. Query the overlapped structure to get the winsock error.
1423+ var bytes, flags uint32
1424+ err = wsaGetOverlappedResult(f.handle, &c.o, &bytes, false, &flags)
1425+ }
1426+ case <-timeout:
1427+ _ = cancelIoEx(f.handle, &c.o)
1428+ r = <-c.ch
1429+ err = r.err
1430+ if err == syscall.ERROR_OPERATION_ABORTED { //nolint:errorlint // err is Errno
1431+ err = ErrTimeout
1432+ }
1433+ }
1434+
1435+ // runtime.KeepAlive is needed, as c is passed via native
1436+ // code to ioCompletionProcessor, c must remain alive
1437+ // until the channel read is complete.
1438+ // todo: (de)allocate *ioOperation via win32 heap functions, instead of needing to KeepAlive?
1439+ runtime.KeepAlive(c)
1440+ return int(r.bytes), err
1441+}
1442+
1443+// Read reads from a file handle.
1444+func (f *win32File) Read(b []byte) (int, error) {
1445+ c, err := f.prepareIO()
1446+ if err != nil {
1447+ return 0, err
1448+ }
1449+ defer f.wg.Done()
1450+
1451+ if f.readDeadline.timedout.isSet() {
1452+ return 0, ErrTimeout
1453+ }
1454+
1455+ var bytes uint32
1456+ err = syscall.ReadFile(f.handle, b, &bytes, &c.o)
1457+ n, err := f.asyncIO(c, &f.readDeadline, bytes, err)
1458+ runtime.KeepAlive(b)
1459+
1460+ // Handle EOF conditions.
1461+ if err == nil && n == 0 && len(b) != 0 {
1462+ return 0, io.EOF
1463+ } else if err == syscall.ERROR_BROKEN_PIPE { //nolint:errorlint // err is Errno
1464+ return 0, io.EOF
1465+ } else {
1466+ return n, err
1467+ }
1468+}
1469+
1470+// Write writes to a file handle.
1471+func (f *win32File) Write(b []byte) (int, error) {
1472+ c, err := f.prepareIO()
1473+ if err != nil {
1474+ return 0, err
1475+ }
1476+ defer f.wg.Done()
1477+
1478+ if f.writeDeadline.timedout.isSet() {
1479+ return 0, ErrTimeout
1480+ }
1481+
1482+ var bytes uint32
1483+ err = syscall.WriteFile(f.handle, b, &bytes, &c.o)
1484+ n, err := f.asyncIO(c, &f.writeDeadline, bytes, err)
1485+ runtime.KeepAlive(b)
1486+ return n, err
1487+}
1488+
1489+func (f *win32File) SetReadDeadline(deadline time.Time) error {
1490+ return f.readDeadline.set(deadline)
1491+}
1492+
1493+func (f *win32File) SetWriteDeadline(deadline time.Time) error {
1494+ return f.writeDeadline.set(deadline)
1495+}
1496+
1497+func (f *win32File) Flush() error {
1498+ return syscall.FlushFileBuffers(f.handle)
1499+}
1500+
1501+func (f *win32File) Fd() uintptr {
1502+ return uintptr(f.handle)
1503+}
1504+
1505+func (d *deadlineHandler) set(deadline time.Time) error {
1506+ d.setLock.Lock()
1507+ defer d.setLock.Unlock()
1508+
1509+ if d.timer != nil {
1510+ if !d.timer.Stop() {
1511+ <-d.channel
1512+ }
1513+ d.timer = nil
1514+ }
1515+ d.timedout.setFalse()
1516+
1517+ select {
1518+ case <-d.channel:
1519+ d.channelLock.Lock()
1520+ d.channel = make(chan struct{})
1521+ d.channelLock.Unlock()
1522+ default:
1523+ }
1524+
1525+ if deadline.IsZero() {
1526+ return nil
1527+ }
1528+
1529+ timeoutIO := func() {
1530+ d.timedout.setTrue()
1531+ close(d.channel)
1532+ }
1533+
1534+ now := time.Now()
1535+ duration := deadline.Sub(now)
1536+ if deadline.After(now) {
1537+ // Deadline is in the future, set a timer to wait
1538+ d.timer = time.AfterFunc(duration, timeoutIO)
1539+ } else {
1540+ // Deadline is in the past. Cancel all pending IO now.
1541+ timeoutIO()
1542+ }
1543+ return nil
1544+}
1545diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/fileinfo.go b/debian/extra/vendor/github.com/Microsoft/go-winio/fileinfo.go
1546new file mode 100644
1547index 0000000..702950e
1548--- /dev/null
1549+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/fileinfo.go
1550@@ -0,0 +1,92 @@
1551+//go:build windows
1552+// +build windows
1553+
1554+package winio
1555+
1556+import (
1557+ "os"
1558+ "runtime"
1559+ "unsafe"
1560+
1561+ "golang.org/x/sys/windows"
1562+)
1563+
1564+// FileBasicInfo contains file access time and file attributes information.
1565+type FileBasicInfo struct {
1566+ CreationTime, LastAccessTime, LastWriteTime, ChangeTime windows.Filetime
1567+ FileAttributes uint32
1568+ _ uint32 // padding
1569+}
1570+
1571+// GetFileBasicInfo retrieves times and attributes for a file.
1572+func GetFileBasicInfo(f *os.File) (*FileBasicInfo, error) {
1573+ bi := &FileBasicInfo{}
1574+ if err := windows.GetFileInformationByHandleEx(
1575+ windows.Handle(f.Fd()),
1576+ windows.FileBasicInfo,
1577+ (*byte)(unsafe.Pointer(bi)),
1578+ uint32(unsafe.Sizeof(*bi)),
1579+ ); err != nil {
1580+ return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err}
1581+ }
1582+ runtime.KeepAlive(f)
1583+ return bi, nil
1584+}
1585+
1586+// SetFileBasicInfo sets times and attributes for a file.
1587+func SetFileBasicInfo(f *os.File, bi *FileBasicInfo) error {
1588+ if err := windows.SetFileInformationByHandle(
1589+ windows.Handle(f.Fd()),
1590+ windows.FileBasicInfo,
1591+ (*byte)(unsafe.Pointer(bi)),
1592+ uint32(unsafe.Sizeof(*bi)),
1593+ ); err != nil {
1594+ return &os.PathError{Op: "SetFileInformationByHandle", Path: f.Name(), Err: err}
1595+ }
1596+ runtime.KeepAlive(f)
1597+ return nil
1598+}
1599+
1600+// FileStandardInfo contains extended information for the file.
1601+// FILE_STANDARD_INFO in WinBase.h
1602+// https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_standard_info
1603+type FileStandardInfo struct {
1604+ AllocationSize, EndOfFile int64
1605+ NumberOfLinks uint32
1606+ DeletePending, Directory bool
1607+}
1608+
1609+// GetFileStandardInfo retrieves ended information for the file.
1610+func GetFileStandardInfo(f *os.File) (*FileStandardInfo, error) {
1611+ si := &FileStandardInfo{}
1612+ if err := windows.GetFileInformationByHandleEx(windows.Handle(f.Fd()),
1613+ windows.FileStandardInfo,
1614+ (*byte)(unsafe.Pointer(si)),
1615+ uint32(unsafe.Sizeof(*si))); err != nil {
1616+ return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err}
1617+ }
1618+ runtime.KeepAlive(f)
1619+ return si, nil
1620+}
1621+
1622+// FileIDInfo contains the volume serial number and file ID for a file. This pair should be
1623+// unique on a system.
1624+type FileIDInfo struct {
1625+ VolumeSerialNumber uint64
1626+ FileID [16]byte
1627+}
1628+
1629+// GetFileID retrieves the unique (volume, file ID) pair for a file.
1630+func GetFileID(f *os.File) (*FileIDInfo, error) {
1631+ fileID := &FileIDInfo{}
1632+ if err := windows.GetFileInformationByHandleEx(
1633+ windows.Handle(f.Fd()),
1634+ windows.FileIdInfo,
1635+ (*byte)(unsafe.Pointer(fileID)),
1636+ uint32(unsafe.Sizeof(*fileID)),
1637+ ); err != nil {
1638+ return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err}
1639+ }
1640+ runtime.KeepAlive(f)
1641+ return fileID, nil
1642+}
1643diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/hvsock.go b/debian/extra/vendor/github.com/Microsoft/go-winio/hvsock.go
1644new file mode 100644
1645index 0000000..c881916
1646--- /dev/null
1647+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/hvsock.go
1648@@ -0,0 +1,575 @@
1649+//go:build windows
1650+// +build windows
1651+
1652+package winio
1653+
1654+import (
1655+ "context"
1656+ "errors"
1657+ "fmt"
1658+ "io"
1659+ "net"
1660+ "os"
1661+ "syscall"
1662+ "time"
1663+ "unsafe"
1664+
1665+ "golang.org/x/sys/windows"
1666+
1667+ "github.com/Microsoft/go-winio/internal/socket"
1668+ "github.com/Microsoft/go-winio/pkg/guid"
1669+)
1670+
1671+const afHVSock = 34 // AF_HYPERV
1672+
1673+// Well known Service and VM IDs
1674+// https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/make-integration-service#vmid-wildcards
1675+
1676+// HvsockGUIDWildcard is the wildcard VmId for accepting connections from all partitions.
1677+func HvsockGUIDWildcard() guid.GUID { // 00000000-0000-0000-0000-000000000000
1678+ return guid.GUID{}
1679+}
1680+
1681+// HvsockGUIDBroadcast is the wildcard VmId for broadcasting sends to all partitions.
1682+func HvsockGUIDBroadcast() guid.GUID { // ffffffff-ffff-ffff-ffff-ffffffffffff
1683+ return guid.GUID{
1684+ Data1: 0xffffffff,
1685+ Data2: 0xffff,
1686+ Data3: 0xffff,
1687+ Data4: [8]uint8{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
1688+ }
1689+}
1690+
1691+// HvsockGUIDLoopback is the Loopback VmId for accepting connections to the same partition as the connector.
1692+func HvsockGUIDLoopback() guid.GUID { // e0e16197-dd56-4a10-9195-5ee7a155a838
1693+ return guid.GUID{
1694+ Data1: 0xe0e16197,
1695+ Data2: 0xdd56,
1696+ Data3: 0x4a10,
1697+ Data4: [8]uint8{0x91, 0x95, 0x5e, 0xe7, 0xa1, 0x55, 0xa8, 0x38},
1698+ }
1699+}
1700+
1701+// HvsockGUIDSiloHost is the address of a silo's host partition:
1702+// - The silo host of a hosted silo is the utility VM.
1703+// - The silo host of a silo on a physical host is the physical host.
1704+func HvsockGUIDSiloHost() guid.GUID { // 36bd0c5c-7276-4223-88ba-7d03b654c568
1705+ return guid.GUID{
1706+ Data1: 0x36bd0c5c,
1707+ Data2: 0x7276,
1708+ Data3: 0x4223,
1709+ Data4: [8]byte{0x88, 0xba, 0x7d, 0x03, 0xb6, 0x54, 0xc5, 0x68},
1710+ }
1711+}
1712+
1713+// HvsockGUIDChildren is the wildcard VmId for accepting connections from the connector's child partitions.
1714+func HvsockGUIDChildren() guid.GUID { // 90db8b89-0d35-4f79-8ce9-49ea0ac8b7cd
1715+ return guid.GUID{
1716+ Data1: 0x90db8b89,
1717+ Data2: 0xd35,
1718+ Data3: 0x4f79,
1719+ Data4: [8]uint8{0x8c, 0xe9, 0x49, 0xea, 0xa, 0xc8, 0xb7, 0xcd},
1720+ }
1721+}
1722+
1723+// HvsockGUIDParent is the wildcard VmId for accepting connections from the connector's parent partition.
1724+// Listening on this VmId accepts connection from:
1725+// - Inside silos: silo host partition.
1726+// - Inside hosted silo: host of the VM.
1727+// - Inside VM: VM host.
1728+// - Physical host: Not supported.
1729+func HvsockGUIDParent() guid.GUID { // a42e7cda-d03f-480c-9cc2-a4de20abb878
1730+ return guid.GUID{
1731+ Data1: 0xa42e7cda,
1732+ Data2: 0xd03f,
1733+ Data3: 0x480c,
1734+ Data4: [8]uint8{0x9c, 0xc2, 0xa4, 0xde, 0x20, 0xab, 0xb8, 0x78},
1735+ }
1736+}
1737+
1738+// hvsockVsockServiceTemplate is the Service GUID used for the VSOCK protocol.
1739+func hvsockVsockServiceTemplate() guid.GUID { // 00000000-facb-11e6-bd58-64006a7986d3
1740+ return guid.GUID{
1741+ Data2: 0xfacb,
1742+ Data3: 0x11e6,
1743+ Data4: [8]uint8{0xbd, 0x58, 0x64, 0x00, 0x6a, 0x79, 0x86, 0xd3},
1744+ }
1745+}
1746+
1747+// An HvsockAddr is an address for a AF_HYPERV socket.
1748+type HvsockAddr struct {
1749+ VMID guid.GUID
1750+ ServiceID guid.GUID
1751+}
1752+
1753+type rawHvsockAddr struct {
1754+ Family uint16
1755+ _ uint16
1756+ VMID guid.GUID
1757+ ServiceID guid.GUID
1758+}
1759+
1760+var _ socket.RawSockaddr = &rawHvsockAddr{}
1761+
1762+// Network returns the address's network name, "hvsock".
1763+func (*HvsockAddr) Network() string {
1764+ return "hvsock"
1765+}
1766+
1767+func (addr *HvsockAddr) String() string {
1768+ return fmt.Sprintf("%s:%s", &addr.VMID, &addr.ServiceID)
1769+}
1770+
1771+// VsockServiceID returns an hvsock service ID corresponding to the specified AF_VSOCK port.
1772+func VsockServiceID(port uint32) guid.GUID {
1773+ g := hvsockVsockServiceTemplate() // make a copy
1774+ g.Data1 = port
1775+ return g
1776+}
1777+
1778+func (addr *HvsockAddr) raw() rawHvsockAddr {
1779+ return rawHvsockAddr{
1780+ Family: afHVSock,
1781+ VMID: addr.VMID,
1782+ ServiceID: addr.ServiceID,
1783+ }
1784+}
1785+
1786+func (addr *HvsockAddr) fromRaw(raw *rawHvsockAddr) {
1787+ addr.VMID = raw.VMID
1788+ addr.ServiceID = raw.ServiceID
1789+}
1790+
1791+// Sockaddr returns a pointer to and the size of this struct.
1792+//
1793+// Implements the [socket.RawSockaddr] interface, and allows use in
1794+// [socket.Bind] and [socket.ConnectEx].
1795+func (r *rawHvsockAddr) Sockaddr() (unsafe.Pointer, int32, error) {
1796+ return unsafe.Pointer(r), int32(unsafe.Sizeof(rawHvsockAddr{})), nil
1797+}
1798+
1799+// Sockaddr interface allows use with `sockets.Bind()` and `.ConnectEx()`.
1800+func (r *rawHvsockAddr) FromBytes(b []byte) error {
1801+ n := int(unsafe.Sizeof(rawHvsockAddr{}))
1802+
1803+ if len(b) < n {
1804+ return fmt.Errorf("got %d, want %d: %w", len(b), n, socket.ErrBufferSize)
1805+ }
1806+
1807+ copy(unsafe.Slice((*byte)(unsafe.Pointer(r)), n), b[:n])
1808+ if r.Family != afHVSock {
1809+ return fmt.Errorf("got %d, want %d: %w", r.Family, afHVSock, socket.ErrAddrFamily)
1810+ }
1811+
1812+ return nil
1813+}
1814+
1815+// HvsockListener is a socket listener for the AF_HYPERV address family.
1816+type HvsockListener struct {
1817+ sock *win32File
1818+ addr HvsockAddr
1819+}
1820+
1821+var _ net.Listener = &HvsockListener{}
1822+
1823+// HvsockConn is a connected socket of the AF_HYPERV address family.
1824+type HvsockConn struct {
1825+ sock *win32File
1826+ local, remote HvsockAddr
1827+}
1828+
1829+var _ net.Conn = &HvsockConn{}
1830+
1831+func newHVSocket() (*win32File, error) {
1832+ fd, err := syscall.Socket(afHVSock, syscall.SOCK_STREAM, 1)
1833+ if err != nil {
1834+ return nil, os.NewSyscallError("socket", err)
1835+ }
1836+ f, err := makeWin32File(fd)
1837+ if err != nil {
1838+ syscall.Close(fd)
1839+ return nil, err
1840+ }
1841+ f.socket = true
1842+ return f, nil
1843+}
1844+
1845+// ListenHvsock listens for connections on the specified hvsock address.
1846+func ListenHvsock(addr *HvsockAddr) (_ *HvsockListener, err error) {
1847+ l := &HvsockListener{addr: *addr}
1848+ sock, err := newHVSocket()
1849+ if err != nil {
1850+ return nil, l.opErr("listen", err)
1851+ }
1852+ sa := addr.raw()
1853+ err = socket.Bind(windows.Handle(sock.handle), &sa)
1854+ if err != nil {
1855+ return nil, l.opErr("listen", os.NewSyscallError("socket", err))
1856+ }
1857+ err = syscall.Listen(sock.handle, 16)
1858+ if err != nil {
1859+ return nil, l.opErr("listen", os.NewSyscallError("listen", err))
1860+ }
1861+ return &HvsockListener{sock: sock, addr: *addr}, nil
1862+}
1863+
1864+func (l *HvsockListener) opErr(op string, err error) error {
1865+ return &net.OpError{Op: op, Net: "hvsock", Addr: &l.addr, Err: err}
1866+}
1867+
1868+// Addr returns the listener's network address.
1869+func (l *HvsockListener) Addr() net.Addr {
1870+ return &l.addr
1871+}
1872+
1873+// Accept waits for the next connection and returns it.
1874+func (l *HvsockListener) Accept() (_ net.Conn, err error) {
1875+ sock, err := newHVSocket()
1876+ if err != nil {
1877+ return nil, l.opErr("accept", err)
1878+ }
1879+ defer func() {
1880+ if sock != nil {
1881+ sock.Close()
1882+ }
1883+ }()
1884+ c, err := l.sock.prepareIO()
1885+ if err != nil {
1886+ return nil, l.opErr("accept", err)
1887+ }
1888+ defer l.sock.wg.Done()
1889+
1890+ // AcceptEx, per documentation, requires an extra 16 bytes per address.
1891+ //
1892+ // https://docs.microsoft.com/en-us/windows/win32/api/mswsock/nf-mswsock-acceptex
1893+ const addrlen = uint32(16 + unsafe.Sizeof(rawHvsockAddr{}))
1894+ var addrbuf [addrlen * 2]byte
1895+
1896+ var bytes uint32
1897+ err = syscall.AcceptEx(l.sock.handle, sock.handle, &addrbuf[0], 0 /* rxdatalen */, addrlen, addrlen, &bytes, &c.o)
1898+ if _, err = l.sock.asyncIO(c, nil, bytes, err); err != nil {
1899+ return nil, l.opErr("accept", os.NewSyscallError("acceptex", err))
1900+ }
1901+
1902+ conn := &HvsockConn{
1903+ sock: sock,
1904+ }
1905+ // The local address returned in the AcceptEx buffer is the same as the Listener socket's
1906+ // address. However, the service GUID reported by GetSockName is different from the Listeners
1907+ // socket, and is sometimes the same as the local address of the socket that dialed the
1908+ // address, with the service GUID.Data1 incremented, but othertimes is different.
1909+ // todo: does the local address matter? is the listener's address or the actual address appropriate?
1910+ conn.local.fromRaw((*rawHvsockAddr)(unsafe.Pointer(&addrbuf[0])))
1911+ conn.remote.fromRaw((*rawHvsockAddr)(unsafe.Pointer(&addrbuf[addrlen])))
1912+
1913+ // initialize the accepted socket and update its properties with those of the listening socket
1914+ if err = windows.Setsockopt(windows.Handle(sock.handle),
1915+ windows.SOL_SOCKET, windows.SO_UPDATE_ACCEPT_CONTEXT,
1916+ (*byte)(unsafe.Pointer(&l.sock.handle)), int32(unsafe.Sizeof(l.sock.handle))); err != nil {
1917+ return nil, conn.opErr("accept", os.NewSyscallError("setsockopt", err))
1918+ }
1919+
1920+ sock = nil
1921+ return conn, nil
1922+}
1923+
1924+// Close closes the listener, causing any pending Accept calls to fail.
1925+func (l *HvsockListener) Close() error {
1926+ return l.sock.Close()
1927+}
1928+
1929+// HvsockDialer configures and dials a Hyper-V Socket (ie, [HvsockConn]).
1930+type HvsockDialer struct {
1931+ // Deadline is the time the Dial operation must connect before erroring.
1932+ Deadline time.Time
1933+
1934+ // Retries is the number of additional connects to try if the connection times out, is refused,
1935+ // or the host is unreachable
1936+ Retries uint
1937+
1938+ // RetryWait is the time to wait after a connection error to retry
1939+ RetryWait time.Duration
1940+
1941+ rt *time.Timer // redial wait timer
1942+}
1943+
1944+// Dial the Hyper-V socket at addr.
1945+//
1946+// See [HvsockDialer.Dial] for more information.
1947+func Dial(ctx context.Context, addr *HvsockAddr) (conn *HvsockConn, err error) {
1948+ return (&HvsockDialer{}).Dial(ctx, addr)
1949+}
1950+
1951+// Dial attempts to connect to the Hyper-V socket at addr, and returns a connection if successful.
1952+// Will attempt (HvsockDialer).Retries if dialing fails, waiting (HvsockDialer).RetryWait between
1953+// retries.
1954+//
1955+// Dialing can be cancelled either by providing (HvsockDialer).Deadline, or cancelling ctx.
1956+func (d *HvsockDialer) Dial(ctx context.Context, addr *HvsockAddr) (conn *HvsockConn, err error) {
1957+ op := "dial"
1958+ // create the conn early to use opErr()
1959+ conn = &HvsockConn{
1960+ remote: *addr,
1961+ }
1962+
1963+ if !d.Deadline.IsZero() {
1964+ var cancel context.CancelFunc
1965+ ctx, cancel = context.WithDeadline(ctx, d.Deadline)
1966+ defer cancel()
1967+ }
1968+
1969+ // preemptive timeout/cancellation check
1970+ if err = ctx.Err(); err != nil {
1971+ return nil, conn.opErr(op, err)
1972+ }
1973+
1974+ sock, err := newHVSocket()
1975+ if err != nil {
1976+ return nil, conn.opErr(op, err)
1977+ }
1978+ defer func() {
1979+ if sock != nil {
1980+ sock.Close()
1981+ }
1982+ }()
1983+
1984+ sa := addr.raw()
1985+ err = socket.Bind(windows.Handle(sock.handle), &sa)
1986+ if err != nil {
1987+ return nil, conn.opErr(op, os.NewSyscallError("bind", err))
1988+ }
1989+
1990+ c, err := sock.prepareIO()
1991+ if err != nil {
1992+ return nil, conn.opErr(op, err)
1993+ }
1994+ defer sock.wg.Done()
1995+ var bytes uint32
1996+ for i := uint(0); i <= d.Retries; i++ {
1997+ err = socket.ConnectEx(
1998+ windows.Handle(sock.handle),
1999+ &sa,
2000+ nil, // sendBuf
2001+ 0, // sendDataLen
2002+ &bytes,
2003+ (*windows.Overlapped)(unsafe.Pointer(&c.o)))
2004+ _, err = sock.asyncIO(c, nil, bytes, err)
2005+ if i < d.Retries && canRedial(err) {
2006+ if err = d.redialWait(ctx); err == nil {
2007+ continue
2008+ }
2009+ }
2010+ break
2011+ }
2012+ if err != nil {
2013+ return nil, conn.opErr(op, os.NewSyscallError("connectex", err))
2014+ }
2015+
2016+ // update the connection properties, so shutdown can be used
2017+ if err = windows.Setsockopt(
2018+ windows.Handle(sock.handle),
2019+ windows.SOL_SOCKET,
2020+ windows.SO_UPDATE_CONNECT_CONTEXT,
2021+ nil, // optvalue
2022+ 0, // optlen
2023+ ); err != nil {
2024+ return nil, conn.opErr(op, os.NewSyscallError("setsockopt", err))
2025+ }
2026+
2027+ // get the local name
2028+ var sal rawHvsockAddr
2029+ err = socket.GetSockName(windows.Handle(sock.handle), &sal)
2030+ if err != nil {
2031+ return nil, conn.opErr(op, os.NewSyscallError("getsockname", err))
2032+ }
2033+ conn.local.fromRaw(&sal)
2034+
2035+ // one last check for timeout, since asyncIO doesn't check the context
2036+ if err = ctx.Err(); err != nil {
2037+ return nil, conn.opErr(op, err)
2038+ }
2039+
2040+ conn.sock = sock
2041+ sock = nil
2042+
2043+ return conn, nil
2044+}
2045+
2046+// redialWait waits before attempting to redial, resetting the timer as appropriate.
2047+func (d *HvsockDialer) redialWait(ctx context.Context) (err error) {
2048+ if d.RetryWait == 0 {
2049+ return nil
2050+ }
2051+
2052+ if d.rt == nil {
2053+ d.rt = time.NewTimer(d.RetryWait)
2054+ } else {
2055+ // should already be stopped and drained
2056+ d.rt.Reset(d.RetryWait)
2057+ }
2058+
2059+ select {
2060+ case <-ctx.Done():
2061+ case <-d.rt.C:
2062+ return nil
2063+ }
2064+
2065+ // stop and drain the timer
2066+ if !d.rt.Stop() {
2067+ <-d.rt.C
2068+ }
2069+ return ctx.Err()
2070+}
2071+
2072+// assumes error is a plain, unwrapped syscall.Errno provided by direct syscall.
2073+func canRedial(err error) bool {
2074+ //nolint:errorlint // guaranteed to be an Errno
2075+ switch err {
2076+ case windows.WSAECONNREFUSED, windows.WSAENETUNREACH, windows.WSAETIMEDOUT,
2077+ windows.ERROR_CONNECTION_REFUSED, windows.ERROR_CONNECTION_UNAVAIL:
2078+ return true
2079+ default:
2080+ return false
2081+ }
2082+}
2083+
2084+func (conn *HvsockConn) opErr(op string, err error) error {
2085+ // translate from "file closed" to "socket closed"
2086+ if errors.Is(err, ErrFileClosed) {
2087+ err = socket.ErrSocketClosed
2088+ }
2089+ return &net.OpError{Op: op, Net: "hvsock", Source: &conn.local, Addr: &conn.remote, Err: err}
2090+}
2091+
2092+func (conn *HvsockConn) Read(b []byte) (int, error) {
2093+ c, err := conn.sock.prepareIO()
2094+ if err != nil {
2095+ return 0, conn.opErr("read", err)
2096+ }
2097+ defer conn.sock.wg.Done()
2098+ buf := syscall.WSABuf{Buf: &b[0], Len: uint32(len(b))}
2099+ var flags, bytes uint32
2100+ err = syscall.WSARecv(conn.sock.handle, &buf, 1, &bytes, &flags, &c.o, nil)
2101+ n, err := conn.sock.asyncIO(c, &conn.sock.readDeadline, bytes, err)
2102+ if err != nil {
2103+ var eno windows.Errno
2104+ if errors.As(err, &eno) {
2105+ err = os.NewSyscallError("wsarecv", eno)
2106+ }
2107+ return 0, conn.opErr("read", err)
2108+ } else if n == 0 {
2109+ err = io.EOF
2110+ }
2111+ return n, err
2112+}
2113+
2114+func (conn *HvsockConn) Write(b []byte) (int, error) {
2115+ t := 0
2116+ for len(b) != 0 {
2117+ n, err := conn.write(b)
2118+ if err != nil {
2119+ return t + n, err
2120+ }
2121+ t += n
2122+ b = b[n:]
2123+ }
2124+ return t, nil
2125+}
2126+
2127+func (conn *HvsockConn) write(b []byte) (int, error) {
2128+ c, err := conn.sock.prepareIO()
2129+ if err != nil {
2130+ return 0, conn.opErr("write", err)
2131+ }
2132+ defer conn.sock.wg.Done()
2133+ buf := syscall.WSABuf{Buf: &b[0], Len: uint32(len(b))}
2134+ var bytes uint32
2135+ err = syscall.WSASend(conn.sock.handle, &buf, 1, &bytes, 0, &c.o, nil)
2136+ n, err := conn.sock.asyncIO(c, &conn.sock.writeDeadline, bytes, err)
2137+ if err != nil {
2138+ var eno windows.Errno
2139+ if errors.As(err, &eno) {
2140+ err = os.NewSyscallError("wsasend", eno)
2141+ }
2142+ return 0, conn.opErr("write", err)
2143+ }
2144+ return n, err
2145+}
2146+
2147+// Close closes the socket connection, failing any pending read or write calls.
2148+func (conn *HvsockConn) Close() error {
2149+ return conn.sock.Close()
2150+}
2151+
2152+func (conn *HvsockConn) IsClosed() bool {
2153+ return conn.sock.IsClosed()
2154+}
2155+
2156+// shutdown disables sending or receiving on a socket.
2157+func (conn *HvsockConn) shutdown(how int) error {
2158+ if conn.IsClosed() {
2159+ return socket.ErrSocketClosed
2160+ }
2161+
2162+ err := syscall.Shutdown(conn.sock.handle, how)
2163+ if err != nil {
2164+ // If the connection was closed, shutdowns fail with "not connected"
2165+ if errors.Is(err, windows.WSAENOTCONN) ||
2166+ errors.Is(err, windows.WSAESHUTDOWN) {
2167+ err = socket.ErrSocketClosed
2168+ }
2169+ return os.NewSyscallError("shutdown", err)
2170+ }
2171+ return nil
2172+}
2173+
2174+// CloseRead shuts down the read end of the socket, preventing future read operations.
2175+func (conn *HvsockConn) CloseRead() error {
2176+ err := conn.shutdown(syscall.SHUT_RD)
2177+ if err != nil {
2178+ return conn.opErr("closeread", err)
2179+ }
2180+ return nil
2181+}
2182+
2183+// CloseWrite shuts down the write end of the socket, preventing future write operations and
2184+// notifying the other endpoint that no more data will be written.
2185+func (conn *HvsockConn) CloseWrite() error {
2186+ err := conn.shutdown(syscall.SHUT_WR)
2187+ if err != nil {
2188+ return conn.opErr("closewrite", err)
2189+ }
2190+ return nil
2191+}
2192+
2193+// LocalAddr returns the local address of the connection.
2194+func (conn *HvsockConn) LocalAddr() net.Addr {
2195+ return &conn.local
2196+}
2197+
2198+// RemoteAddr returns the remote address of the connection.
2199+func (conn *HvsockConn) RemoteAddr() net.Addr {
2200+ return &conn.remote
2201+}
2202+
2203+// SetDeadline implements the net.Conn SetDeadline method.
2204+func (conn *HvsockConn) SetDeadline(t time.Time) error {
2205+ // todo: implement `SetDeadline` for `win32File`
2206+ if err := conn.SetReadDeadline(t); err != nil {
2207+ return fmt.Errorf("set read deadline: %w", err)
2208+ }
2209+ if err := conn.SetWriteDeadline(t); err != nil {
2210+ return fmt.Errorf("set write deadline: %w", err)
2211+ }
2212+ return nil
2213+}
2214+
2215+// SetReadDeadline implements the net.Conn SetReadDeadline method.
2216+func (conn *HvsockConn) SetReadDeadline(t time.Time) error {
2217+ return conn.sock.SetReadDeadline(t)
2218+}
2219+
2220+// SetWriteDeadline implements the net.Conn SetWriteDeadline method.
2221+func (conn *HvsockConn) SetWriteDeadline(t time.Time) error {
2222+ return conn.sock.SetWriteDeadline(t)
2223+}
2224diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/doc.go b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/doc.go
2225new file mode 100644
2226index 0000000..1f65388
2227--- /dev/null
2228+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/doc.go
2229@@ -0,0 +1,2 @@
2230+// This package contains Win32 filesystem functionality.
2231+package fs
2232diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/fs.go b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/fs.go
2233new file mode 100644
2234index 0000000..509b3ec
2235--- /dev/null
2236+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/fs.go
2237@@ -0,0 +1,202 @@
2238+//go:build windows
2239+
2240+package fs
2241+
2242+import (
2243+ "golang.org/x/sys/windows"
2244+
2245+ "github.com/Microsoft/go-winio/internal/stringbuffer"
2246+)
2247+
2248+//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go fs.go
2249+
2250+// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew
2251+//sys CreateFile(name string, access AccessMask, mode FileShareMode, sa *syscall.SecurityAttributes, createmode FileCreationDisposition, attrs FileFlagOrAttribute, templatefile windows.Handle) (handle windows.Handle, err error) [failretval==windows.InvalidHandle] = CreateFileW
2252+
2253+const NullHandle windows.Handle = 0
2254+
2255+// AccessMask defines standard, specific, and generic rights.
2256+//
2257+// Bitmask:
2258+// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
2259+// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
2260+// +---------------+---------------+-------------------------------+
2261+// |G|G|G|G|Resvd|A| StandardRights| SpecificRights |
2262+// |R|W|E|A| |S| | |
2263+// +-+-------------+---------------+-------------------------------+
2264+//
2265+// GR Generic Read
2266+// GW Generic Write
2267+// GE Generic Exectue
2268+// GA Generic All
2269+// Resvd Reserved
2270+// AS Access Security System
2271+//
2272+// https://learn.microsoft.com/en-us/windows/win32/secauthz/access-mask
2273+//
2274+// https://learn.microsoft.com/en-us/windows/win32/secauthz/generic-access-rights
2275+//
2276+// https://learn.microsoft.com/en-us/windows/win32/fileio/file-access-rights-constants
2277+type AccessMask = windows.ACCESS_MASK
2278+
2279+//nolint:revive // SNAKE_CASE is not idiomatic in Go, but aligned with Win32 API.
2280+const (
2281+ // Not actually any.
2282+ //
2283+ // For CreateFile: "query certain metadata such as file, directory, or device attributes without accessing that file or device"
2284+ // https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew#parameters
2285+ FILE_ANY_ACCESS AccessMask = 0
2286+
2287+ // Specific Object Access
2288+ // from ntioapi.h
2289+
2290+ FILE_READ_DATA AccessMask = (0x0001) // file & pipe
2291+ FILE_LIST_DIRECTORY AccessMask = (0x0001) // directory
2292+
2293+ FILE_WRITE_DATA AccessMask = (0x0002) // file & pipe
2294+ FILE_ADD_FILE AccessMask = (0x0002) // directory
2295+
2296+ FILE_APPEND_DATA AccessMask = (0x0004) // file
2297+ FILE_ADD_SUBDIRECTORY AccessMask = (0x0004) // directory
2298+ FILE_CREATE_PIPE_INSTANCE AccessMask = (0x0004) // named pipe
2299+
2300+ FILE_READ_EA AccessMask = (0x0008) // file & directory
2301+ FILE_READ_PROPERTIES AccessMask = FILE_READ_EA
2302+
2303+ FILE_WRITE_EA AccessMask = (0x0010) // file & directory
2304+ FILE_WRITE_PROPERTIES AccessMask = FILE_WRITE_EA
2305+
2306+ FILE_EXECUTE AccessMask = (0x0020) // file
2307+ FILE_TRAVERSE AccessMask = (0x0020) // directory
2308+
2309+ FILE_DELETE_CHILD AccessMask = (0x0040) // directory
2310+
2311+ FILE_READ_ATTRIBUTES AccessMask = (0x0080) // all
2312+
2313+ FILE_WRITE_ATTRIBUTES AccessMask = (0x0100) // all
2314+
2315+ FILE_ALL_ACCESS AccessMask = (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
2316+ FILE_GENERIC_READ AccessMask = (STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE)
2317+ FILE_GENERIC_WRITE AccessMask = (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE)
2318+ FILE_GENERIC_EXECUTE AccessMask = (STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE)
2319+
2320+ SPECIFIC_RIGHTS_ALL AccessMask = 0x0000FFFF
2321+
2322+ // Standard Access
2323+ // from ntseapi.h
2324+
2325+ DELETE AccessMask = 0x0001_0000
2326+ READ_CONTROL AccessMask = 0x0002_0000
2327+ WRITE_DAC AccessMask = 0x0004_0000
2328+ WRITE_OWNER AccessMask = 0x0008_0000
2329+ SYNCHRONIZE AccessMask = 0x0010_0000
2330+
2331+ STANDARD_RIGHTS_REQUIRED AccessMask = 0x000F_0000
2332+
2333+ STANDARD_RIGHTS_READ AccessMask = READ_CONTROL
2334+ STANDARD_RIGHTS_WRITE AccessMask = READ_CONTROL
2335+ STANDARD_RIGHTS_EXECUTE AccessMask = READ_CONTROL
2336+
2337+ STANDARD_RIGHTS_ALL AccessMask = 0x001F_0000
2338+)
2339+
2340+type FileShareMode uint32
2341+
2342+//nolint:revive // SNAKE_CASE is not idiomatic in Go, but aligned with Win32 API.
2343+const (
2344+ FILE_SHARE_NONE FileShareMode = 0x00
2345+ FILE_SHARE_READ FileShareMode = 0x01
2346+ FILE_SHARE_WRITE FileShareMode = 0x02
2347+ FILE_SHARE_DELETE FileShareMode = 0x04
2348+ FILE_SHARE_VALID_FLAGS FileShareMode = 0x07
2349+)
2350+
2351+type FileCreationDisposition uint32
2352+
2353+//nolint:revive // SNAKE_CASE is not idiomatic in Go, but aligned with Win32 API.
2354+const (
2355+ // from winbase.h
2356+
2357+ CREATE_NEW FileCreationDisposition = 0x01
2358+ CREATE_ALWAYS FileCreationDisposition = 0x02
2359+ OPEN_EXISTING FileCreationDisposition = 0x03
2360+ OPEN_ALWAYS FileCreationDisposition = 0x04
2361+ TRUNCATE_EXISTING FileCreationDisposition = 0x05
2362+)
2363+
2364+// CreateFile and co. take flags or attributes together as one parameter.
2365+// Define alias until we can use generics to allow both
2366+
2367+// https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants
2368+type FileFlagOrAttribute uint32
2369+
2370+//nolint:revive // SNAKE_CASE is not idiomatic in Go, but aligned with Win32 API.
2371+const ( // from winnt.h
2372+ FILE_FLAG_WRITE_THROUGH FileFlagOrAttribute = 0x8000_0000
2373+ FILE_FLAG_OVERLAPPED FileFlagOrAttribute = 0x4000_0000
2374+ FILE_FLAG_NO_BUFFERING FileFlagOrAttribute = 0x2000_0000
2375+ FILE_FLAG_RANDOM_ACCESS FileFlagOrAttribute = 0x1000_0000
2376+ FILE_FLAG_SEQUENTIAL_SCAN FileFlagOrAttribute = 0x0800_0000
2377+ FILE_FLAG_DELETE_ON_CLOSE FileFlagOrAttribute = 0x0400_0000
2378+ FILE_FLAG_BACKUP_SEMANTICS FileFlagOrAttribute = 0x0200_0000
2379+ FILE_FLAG_POSIX_SEMANTICS FileFlagOrAttribute = 0x0100_0000
2380+ FILE_FLAG_OPEN_REPARSE_POINT FileFlagOrAttribute = 0x0020_0000
2381+ FILE_FLAG_OPEN_NO_RECALL FileFlagOrAttribute = 0x0010_0000
2382+ FILE_FLAG_FIRST_PIPE_INSTANCE FileFlagOrAttribute = 0x0008_0000
2383+)
2384+
2385+type FileSQSFlag = FileFlagOrAttribute
2386+
2387+//nolint:revive // SNAKE_CASE is not idiomatic in Go, but aligned with Win32 API.
2388+const ( // from winbase.h
2389+ SECURITY_ANONYMOUS FileSQSFlag = FileSQSFlag(SecurityAnonymous << 16)
2390+ SECURITY_IDENTIFICATION FileSQSFlag = FileSQSFlag(SecurityIdentification << 16)
2391+ SECURITY_IMPERSONATION FileSQSFlag = FileSQSFlag(SecurityImpersonation << 16)
2392+ SECURITY_DELEGATION FileSQSFlag = FileSQSFlag(SecurityDelegation << 16)
2393+
2394+ SECURITY_SQOS_PRESENT FileSQSFlag = 0x00100000
2395+ SECURITY_VALID_SQOS_FLAGS FileSQSFlag = 0x001F0000
2396+)
2397+
2398+// GetFinalPathNameByHandle flags
2399+//
2400+// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew#parameters
2401+type GetFinalPathFlag uint32
2402+
2403+//nolint:revive // SNAKE_CASE is not idiomatic in Go, but aligned with Win32 API.
2404+const (
2405+ GetFinalPathDefaultFlag GetFinalPathFlag = 0x0
2406+
2407+ FILE_NAME_NORMALIZED GetFinalPathFlag = 0x0
2408+ FILE_NAME_OPENED GetFinalPathFlag = 0x8
2409+
2410+ VOLUME_NAME_DOS GetFinalPathFlag = 0x0
2411+ VOLUME_NAME_GUID GetFinalPathFlag = 0x1
2412+ VOLUME_NAME_NT GetFinalPathFlag = 0x2
2413+ VOLUME_NAME_NONE GetFinalPathFlag = 0x4
2414+)
2415+
2416+// getFinalPathNameByHandle facilitates calling the Windows API GetFinalPathNameByHandle
2417+// with the given handle and flags. It transparently takes care of creating a buffer of the
2418+// correct size for the call.
2419+//
2420+// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew
2421+func GetFinalPathNameByHandle(h windows.Handle, flags GetFinalPathFlag) (string, error) {
2422+ b := stringbuffer.NewWString()
2423+ //TODO: can loop infinitely if Win32 keeps returning the same (or a larger) n?
2424+ for {
2425+ n, err := windows.GetFinalPathNameByHandle(h, b.Pointer(), b.Cap(), uint32(flags))
2426+ if err != nil {
2427+ return "", err
2428+ }
2429+ // If the buffer wasn't large enough, n will be the total size needed (including null terminator).
2430+ // Resize and try again.
2431+ if n > b.Cap() {
2432+ b.ResizeTo(n)
2433+ continue
2434+ }
2435+ // If the buffer is large enough, n will be the size not including the null terminator.
2436+ // Convert to a Go string and return.
2437+ return b.String(), nil
2438+ }
2439+}
2440diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/security.go b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/security.go
2441new file mode 100644
2442index 0000000..81760ac
2443--- /dev/null
2444+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/security.go
2445@@ -0,0 +1,12 @@
2446+package fs
2447+
2448+// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ne-winnt-security_impersonation_level
2449+type SecurityImpersonationLevel int32 // C default enums underlying type is `int`, which is Go `int32`
2450+
2451+// Impersonation levels
2452+const (
2453+ SecurityAnonymous SecurityImpersonationLevel = 0
2454+ SecurityIdentification SecurityImpersonationLevel = 1
2455+ SecurityImpersonation SecurityImpersonationLevel = 2
2456+ SecurityDelegation SecurityImpersonationLevel = 3
2457+)
2458diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/zsyscall_windows.go b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/zsyscall_windows.go
2459new file mode 100644
2460index 0000000..e2f7bb2
2461--- /dev/null
2462+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/fs/zsyscall_windows.go
2463@@ -0,0 +1,64 @@
2464+//go:build windows
2465+
2466+// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT.
2467+
2468+package fs
2469+
2470+import (
2471+ "syscall"
2472+ "unsafe"
2473+
2474+ "golang.org/x/sys/windows"
2475+)
2476+
2477+var _ unsafe.Pointer
2478+
2479+// Do the interface allocations only once for common
2480+// Errno values.
2481+const (
2482+ errnoERROR_IO_PENDING = 997
2483+)
2484+
2485+var (
2486+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
2487+ errERROR_EINVAL error = syscall.EINVAL
2488+)
2489+
2490+// errnoErr returns common boxed Errno values, to prevent
2491+// allocations at runtime.
2492+func errnoErr(e syscall.Errno) error {
2493+ switch e {
2494+ case 0:
2495+ return errERROR_EINVAL
2496+ case errnoERROR_IO_PENDING:
2497+ return errERROR_IO_PENDING
2498+ }
2499+ // TODO: add more here, after collecting data on the common
2500+ // error values see on Windows. (perhaps when running
2501+ // all.bat?)
2502+ return e
2503+}
2504+
2505+var (
2506+ modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
2507+
2508+ procCreateFileW = modkernel32.NewProc("CreateFileW")
2509+)
2510+
2511+func CreateFile(name string, access AccessMask, mode FileShareMode, sa *syscall.SecurityAttributes, createmode FileCreationDisposition, attrs FileFlagOrAttribute, templatefile windows.Handle) (handle windows.Handle, err error) {
2512+ var _p0 *uint16
2513+ _p0, err = syscall.UTF16PtrFromString(name)
2514+ if err != nil {
2515+ return
2516+ }
2517+ return _CreateFile(_p0, access, mode, sa, createmode, attrs, templatefile)
2518+}
2519+
2520+func _CreateFile(name *uint16, access AccessMask, mode FileShareMode, sa *syscall.SecurityAttributes, createmode FileCreationDisposition, attrs FileFlagOrAttribute, templatefile windows.Handle) (handle windows.Handle, err error) {
2521+ r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0)
2522+ handle = windows.Handle(r0)
2523+ if handle == windows.InvalidHandle {
2524+ err = errnoErr(e1)
2525+ }
2526+ return
2527+}
2528diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/rawaddr.go b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/rawaddr.go
2529new file mode 100644
2530index 0000000..7e82f9a
2531--- /dev/null
2532+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/rawaddr.go
2533@@ -0,0 +1,20 @@
2534+package socket
2535+
2536+import (
2537+ "unsafe"
2538+)
2539+
2540+// RawSockaddr allows structs to be used with [Bind] and [ConnectEx]. The
2541+// struct must meet the Win32 sockaddr requirements specified here:
2542+// https://docs.microsoft.com/en-us/windows/win32/winsock/sockaddr-2
2543+//
2544+// Specifically, the struct size must be least larger than an int16 (unsigned short)
2545+// for the address family.
2546+type RawSockaddr interface {
2547+ // Sockaddr returns a pointer to the RawSockaddr and its struct size, allowing
2548+ // for the RawSockaddr's data to be overwritten by syscalls (if necessary).
2549+ //
2550+ // It is the callers responsibility to validate that the values are valid; invalid
2551+ // pointers or size can cause a panic.
2552+ Sockaddr() (unsafe.Pointer, int32, error)
2553+}
2554diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/socket.go b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/socket.go
2555new file mode 100644
2556index 0000000..aeb7b72
2557--- /dev/null
2558+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/socket.go
2559@@ -0,0 +1,179 @@
2560+//go:build windows
2561+
2562+package socket
2563+
2564+import (
2565+ "errors"
2566+ "fmt"
2567+ "net"
2568+ "sync"
2569+ "syscall"
2570+ "unsafe"
2571+
2572+ "github.com/Microsoft/go-winio/pkg/guid"
2573+ "golang.org/x/sys/windows"
2574+)
2575+
2576+//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go socket.go
2577+
2578+//sys getsockname(s windows.Handle, name unsafe.Pointer, namelen *int32) (err error) [failretval==socketError] = ws2_32.getsockname
2579+//sys getpeername(s windows.Handle, name unsafe.Pointer, namelen *int32) (err error) [failretval==socketError] = ws2_32.getpeername
2580+//sys bind(s windows.Handle, name unsafe.Pointer, namelen int32) (err error) [failretval==socketError] = ws2_32.bind
2581+
2582+const socketError = uintptr(^uint32(0))
2583+
2584+var (
2585+ // todo(helsaawy): create custom error types to store the desired vs actual size and addr family?
2586+
2587+ ErrBufferSize = errors.New("buffer size")
2588+ ErrAddrFamily = errors.New("address family")
2589+ ErrInvalidPointer = errors.New("invalid pointer")
2590+ ErrSocketClosed = fmt.Errorf("socket closed: %w", net.ErrClosed)
2591+)
2592+
2593+// todo(helsaawy): replace these with generics, ie: GetSockName[S RawSockaddr](s windows.Handle) (S, error)
2594+
2595+// GetSockName writes the local address of socket s to the [RawSockaddr] rsa.
2596+// If rsa is not large enough, the [windows.WSAEFAULT] is returned.
2597+func GetSockName(s windows.Handle, rsa RawSockaddr) error {
2598+ ptr, l, err := rsa.Sockaddr()
2599+ if err != nil {
2600+ return fmt.Errorf("could not retrieve socket pointer and size: %w", err)
2601+ }
2602+
2603+ // although getsockname returns WSAEFAULT if the buffer is too small, it does not set
2604+ // &l to the correct size, so--apart from doubling the buffer repeatedly--there is no remedy
2605+ return getsockname(s, ptr, &l)
2606+}
2607+
2608+// GetPeerName returns the remote address the socket is connected to.
2609+//
2610+// See [GetSockName] for more information.
2611+func GetPeerName(s windows.Handle, rsa RawSockaddr) error {
2612+ ptr, l, err := rsa.Sockaddr()
2613+ if err != nil {
2614+ return fmt.Errorf("could not retrieve socket pointer and size: %w", err)
2615+ }
2616+
2617+ return getpeername(s, ptr, &l)
2618+}
2619+
2620+func Bind(s windows.Handle, rsa RawSockaddr) (err error) {
2621+ ptr, l, err := rsa.Sockaddr()
2622+ if err != nil {
2623+ return fmt.Errorf("could not retrieve socket pointer and size: %w", err)
2624+ }
2625+
2626+ return bind(s, ptr, l)
2627+}
2628+
2629+// "golang.org/x/sys/windows".ConnectEx and .Bind only accept internal implementations of the
2630+// their sockaddr interface, so they cannot be used with HvsockAddr
2631+// Replicate functionality here from
2632+// https://cs.opensource.google/go/x/sys/+/master:windows/syscall_windows.go
2633+
2634+// The function pointers to `AcceptEx`, `ConnectEx` and `GetAcceptExSockaddrs` must be loaded at
2635+// runtime via a WSAIoctl call:
2636+// https://docs.microsoft.com/en-us/windows/win32/api/Mswsock/nc-mswsock-lpfn_connectex#remarks
2637+
2638+type runtimeFunc struct {
2639+ id guid.GUID
2640+ once sync.Once
2641+ addr uintptr
2642+ err error
2643+}
2644+
2645+func (f *runtimeFunc) Load() error {
2646+ f.once.Do(func() {
2647+ var s windows.Handle
2648+ s, f.err = windows.Socket(windows.AF_INET, windows.SOCK_STREAM, windows.IPPROTO_TCP)
2649+ if f.err != nil {
2650+ return
2651+ }
2652+ defer windows.CloseHandle(s) //nolint:errcheck
2653+
2654+ var n uint32
2655+ f.err = windows.WSAIoctl(s,
2656+ windows.SIO_GET_EXTENSION_FUNCTION_POINTER,
2657+ (*byte)(unsafe.Pointer(&f.id)),
2658+ uint32(unsafe.Sizeof(f.id)),
2659+ (*byte)(unsafe.Pointer(&f.addr)),
2660+ uint32(unsafe.Sizeof(f.addr)),
2661+ &n,
2662+ nil, // overlapped
2663+ 0, // completionRoutine
2664+ )
2665+ })
2666+ return f.err
2667+}
2668+
2669+var (
2670+ // todo: add `AcceptEx` and `GetAcceptExSockaddrs`
2671+ WSAID_CONNECTEX = guid.GUID{ //revive:disable-line:var-naming ALL_CAPS
2672+ Data1: 0x25a207b9,
2673+ Data2: 0xddf3,
2674+ Data3: 0x4660,
2675+ Data4: [8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e},
2676+ }
2677+
2678+ connectExFunc = runtimeFunc{id: WSAID_CONNECTEX}
2679+)
2680+
2681+func ConnectEx(
2682+ fd windows.Handle,
2683+ rsa RawSockaddr,
2684+ sendBuf *byte,
2685+ sendDataLen uint32,
2686+ bytesSent *uint32,
2687+ overlapped *windows.Overlapped,
2688+) error {
2689+ if err := connectExFunc.Load(); err != nil {
2690+ return fmt.Errorf("failed to load ConnectEx function pointer: %w", err)
2691+ }
2692+ ptr, n, err := rsa.Sockaddr()
2693+ if err != nil {
2694+ return err
2695+ }
2696+ return connectEx(fd, ptr, n, sendBuf, sendDataLen, bytesSent, overlapped)
2697+}
2698+
2699+// BOOL LpfnConnectex(
2700+// [in] SOCKET s,
2701+// [in] const sockaddr *name,
2702+// [in] int namelen,
2703+// [in, optional] PVOID lpSendBuffer,
2704+// [in] DWORD dwSendDataLength,
2705+// [out] LPDWORD lpdwBytesSent,
2706+// [in] LPOVERLAPPED lpOverlapped
2707+// )
2708+
2709+func connectEx(
2710+ s windows.Handle,
2711+ name unsafe.Pointer,
2712+ namelen int32,
2713+ sendBuf *byte,
2714+ sendDataLen uint32,
2715+ bytesSent *uint32,
2716+ overlapped *windows.Overlapped,
2717+) (err error) {
2718+ // todo: after upgrading to 1.18, switch from syscall.Syscall9 to syscall.SyscallN
2719+ r1, _, e1 := syscall.Syscall9(connectExFunc.addr,
2720+ 7,
2721+ uintptr(s),
2722+ uintptr(name),
2723+ uintptr(namelen),
2724+ uintptr(unsafe.Pointer(sendBuf)),
2725+ uintptr(sendDataLen),
2726+ uintptr(unsafe.Pointer(bytesSent)),
2727+ uintptr(unsafe.Pointer(overlapped)),
2728+ 0,
2729+ 0)
2730+ if r1 == 0 {
2731+ if e1 != 0 {
2732+ err = error(e1)
2733+ } else {
2734+ err = syscall.EINVAL
2735+ }
2736+ }
2737+ return err
2738+}
2739diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/zsyscall_windows.go b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/zsyscall_windows.go
2740new file mode 100644
2741index 0000000..6d2e1a9
2742--- /dev/null
2743+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/socket/zsyscall_windows.go
2744@@ -0,0 +1,72 @@
2745+//go:build windows
2746+
2747+// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT.
2748+
2749+package socket
2750+
2751+import (
2752+ "syscall"
2753+ "unsafe"
2754+
2755+ "golang.org/x/sys/windows"
2756+)
2757+
2758+var _ unsafe.Pointer
2759+
2760+// Do the interface allocations only once for common
2761+// Errno values.
2762+const (
2763+ errnoERROR_IO_PENDING = 997
2764+)
2765+
2766+var (
2767+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
2768+ errERROR_EINVAL error = syscall.EINVAL
2769+)
2770+
2771+// errnoErr returns common boxed Errno values, to prevent
2772+// allocations at runtime.
2773+func errnoErr(e syscall.Errno) error {
2774+ switch e {
2775+ case 0:
2776+ return errERROR_EINVAL
2777+ case errnoERROR_IO_PENDING:
2778+ return errERROR_IO_PENDING
2779+ }
2780+ // TODO: add more here, after collecting data on the common
2781+ // error values see on Windows. (perhaps when running
2782+ // all.bat?)
2783+ return e
2784+}
2785+
2786+var (
2787+ modws2_32 = windows.NewLazySystemDLL("ws2_32.dll")
2788+
2789+ procbind = modws2_32.NewProc("bind")
2790+ procgetpeername = modws2_32.NewProc("getpeername")
2791+ procgetsockname = modws2_32.NewProc("getsockname")
2792+)
2793+
2794+func bind(s windows.Handle, name unsafe.Pointer, namelen int32) (err error) {
2795+ r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
2796+ if r1 == socketError {
2797+ err = errnoErr(e1)
2798+ }
2799+ return
2800+}
2801+
2802+func getpeername(s windows.Handle, name unsafe.Pointer, namelen *int32) (err error) {
2803+ r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(name), uintptr(unsafe.Pointer(namelen)))
2804+ if r1 == socketError {
2805+ err = errnoErr(e1)
2806+ }
2807+ return
2808+}
2809+
2810+func getsockname(s windows.Handle, name unsafe.Pointer, namelen *int32) (err error) {
2811+ r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(name), uintptr(unsafe.Pointer(namelen)))
2812+ if r1 == socketError {
2813+ err = errnoErr(e1)
2814+ }
2815+ return
2816+}
2817diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/internal/stringbuffer/wstring.go b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/stringbuffer/wstring.go
2818new file mode 100644
2819index 0000000..7ad5057
2820--- /dev/null
2821+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/internal/stringbuffer/wstring.go
2822@@ -0,0 +1,132 @@
2823+package stringbuffer
2824+
2825+import (
2826+ "sync"
2827+ "unicode/utf16"
2828+)
2829+
2830+// TODO: worth exporting and using in mkwinsyscall?
2831+
2832+// Uint16BufferSize is the buffer size in the pool, chosen somewhat arbitrarily to accommodate
2833+// large path strings:
2834+// MAX_PATH (260) + size of volume GUID prefix (49) + null terminator = 310.
2835+const MinWStringCap = 310
2836+
2837+// use *[]uint16 since []uint16 creates an extra allocation where the slice header
2838+// is copied to heap and then referenced via pointer in the interface header that sync.Pool
2839+// stores.
2840+var pathPool = sync.Pool{ // if go1.18+ adds Pool[T], use that to store []uint16 directly
2841+ New: func() interface{} {
2842+ b := make([]uint16, MinWStringCap)
2843+ return &b
2844+ },
2845+}
2846+
2847+func newBuffer() []uint16 { return *(pathPool.Get().(*[]uint16)) }
2848+
2849+// freeBuffer copies the slice header data, and puts a pointer to that in the pool.
2850+// This avoids taking a pointer to the slice header in WString, which can be set to nil.
2851+func freeBuffer(b []uint16) { pathPool.Put(&b) }
2852+
2853+// WString is a wide string buffer ([]uint16) meant for storing UTF-16 encoded strings
2854+// for interacting with Win32 APIs.
2855+// Sizes are specified as uint32 and not int.
2856+//
2857+// It is not thread safe.
2858+type WString struct {
2859+ // type-def allows casting to []uint16 directly, use struct to prevent that and allow adding fields in the future.
2860+
2861+ // raw buffer
2862+ b []uint16
2863+}
2864+
2865+// NewWString returns a [WString] allocated from a shared pool with an
2866+// initial capacity of at least [MinWStringCap].
2867+// Since the buffer may have been previously used, its contents are not guaranteed to be empty.
2868+//
2869+// The buffer should be freed via [WString.Free]
2870+func NewWString() *WString {
2871+ return &WString{
2872+ b: newBuffer(),
2873+ }
2874+}
2875+
2876+func (b *WString) Free() {
2877+ if b.empty() {
2878+ return
2879+ }
2880+ freeBuffer(b.b)
2881+ b.b = nil
2882+}
2883+
2884+// ResizeTo grows the buffer to at least c and returns the new capacity, freeing the
2885+// previous buffer back into pool.
2886+func (b *WString) ResizeTo(c uint32) uint32 {
2887+ // allready sufficient (or n is 0)
2888+ if c <= b.Cap() {
2889+ return b.Cap()
2890+ }
2891+
2892+ if c <= MinWStringCap {
2893+ c = MinWStringCap
2894+ }
2895+ // allocate at-least double buffer size, as is done in [bytes.Buffer] and other places
2896+ if c <= 2*b.Cap() {
2897+ c = 2 * b.Cap()
2898+ }
2899+
2900+ b2 := make([]uint16, c)
2901+ if !b.empty() {
2902+ copy(b2, b.b)
2903+ freeBuffer(b.b)
2904+ }
2905+ b.b = b2
2906+ return c
2907+}
2908+
2909+// Buffer returns the underlying []uint16 buffer.
2910+func (b *WString) Buffer() []uint16 {
2911+ if b.empty() {
2912+ return nil
2913+ }
2914+ return b.b
2915+}
2916+
2917+// Pointer returns a pointer to the first uint16 in the buffer.
2918+// If the [WString.Free] has already been called, the pointer will be nil.
2919+func (b *WString) Pointer() *uint16 {
2920+ if b.empty() {
2921+ return nil
2922+ }
2923+ return &b.b[0]
2924+}
2925+
2926+// String returns the returns the UTF-8 encoding of the UTF-16 string in the buffer.
2927+//
2928+// It assumes that the data is null-terminated.
2929+func (b *WString) String() string {
2930+ // Using [windows.UTF16ToString] would require importing "golang.org/x/sys/windows"
2931+ // and would make this code Windows-only, which makes no sense.
2932+ // So copy UTF16ToString code into here.
2933+ // If other windows-specific code is added, switch to [windows.UTF16ToString]
2934+
2935+ s := b.b
2936+ for i, v := range s {
2937+ if v == 0 {
2938+ s = s[:i]
2939+ break
2940+ }
2941+ }
2942+ return string(utf16.Decode(s))
2943+}
2944+
2945+// Cap returns the underlying buffer capacity.
2946+func (b *WString) Cap() uint32 {
2947+ if b.empty() {
2948+ return 0
2949+ }
2950+ return b.cap()
2951+}
2952+
2953+func (b *WString) cap() uint32 { return uint32(cap(b.b)) }
2954+func (b *WString) empty() bool { return b == nil || b.cap() == 0 }
2955diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/pipe.go b/debian/extra/vendor/github.com/Microsoft/go-winio/pipe.go
2956new file mode 100644
2957index 0000000..25cc811
2958--- /dev/null
2959+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/pipe.go
2960@@ -0,0 +1,525 @@
2961+//go:build windows
2962+// +build windows
2963+
2964+package winio
2965+
2966+import (
2967+ "context"
2968+ "errors"
2969+ "fmt"
2970+ "io"
2971+ "net"
2972+ "os"
2973+ "runtime"
2974+ "syscall"
2975+ "time"
2976+ "unsafe"
2977+
2978+ "golang.org/x/sys/windows"
2979+
2980+ "github.com/Microsoft/go-winio/internal/fs"
2981+)
2982+
2983+//sys connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) = ConnectNamedPipe
2984+//sys createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateNamedPipeW
2985+//sys getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) = GetNamedPipeInfo
2986+//sys getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
2987+//sys localAlloc(uFlags uint32, length uint32) (ptr uintptr) = LocalAlloc
2988+//sys ntCreateNamedPipeFile(pipe *syscall.Handle, access uint32, oa *objectAttributes, iosb *ioStatusBlock, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (status ntStatus) = ntdll.NtCreateNamedPipeFile
2989+//sys rtlNtStatusToDosError(status ntStatus) (winerr error) = ntdll.RtlNtStatusToDosErrorNoTeb
2990+//sys rtlDosPathNameToNtPathName(name *uint16, ntName *unicodeString, filePart uintptr, reserved uintptr) (status ntStatus) = ntdll.RtlDosPathNameToNtPathName_U
2991+//sys rtlDefaultNpAcl(dacl *uintptr) (status ntStatus) = ntdll.RtlDefaultNpAcl
2992+
2993+type ioStatusBlock struct {
2994+ Status, Information uintptr
2995+}
2996+
2997+type objectAttributes struct {
2998+ Length uintptr
2999+ RootDirectory uintptr
3000+ ObjectName *unicodeString
3001+ Attributes uintptr
3002+ SecurityDescriptor *securityDescriptor
3003+ SecurityQoS uintptr
3004+}
3005+
3006+type unicodeString struct {
3007+ Length uint16
3008+ MaximumLength uint16
3009+ Buffer uintptr
3010+}
3011+
3012+type securityDescriptor struct {
3013+ Revision byte
3014+ Sbz1 byte
3015+ Control uint16
3016+ Owner uintptr
3017+ Group uintptr
3018+ Sacl uintptr //revive:disable-line:var-naming SACL, not Sacl
3019+ Dacl uintptr //revive:disable-line:var-naming DACL, not Dacl
3020+}
3021+
3022+type ntStatus int32
3023+
3024+func (status ntStatus) Err() error {
3025+ if status >= 0 {
3026+ return nil
3027+ }
3028+ return rtlNtStatusToDosError(status)
3029+}
3030+
3031+var (
3032+ // ErrPipeListenerClosed is returned for pipe operations on listeners that have been closed.
3033+ ErrPipeListenerClosed = net.ErrClosed
3034+
3035+ errPipeWriteClosed = errors.New("pipe has been closed for write")
3036+)
3037+
3038+type win32Pipe struct {
3039+ *win32File
3040+ path string
3041+}
3042+
3043+type win32MessageBytePipe struct {
3044+ win32Pipe
3045+ writeClosed bool
3046+ readEOF bool
3047+}
3048+
3049+type pipeAddress string
3050+
3051+func (f *win32Pipe) LocalAddr() net.Addr {
3052+ return pipeAddress(f.path)
3053+}
3054+
3055+func (f *win32Pipe) RemoteAddr() net.Addr {
3056+ return pipeAddress(f.path)
3057+}
3058+
3059+func (f *win32Pipe) SetDeadline(t time.Time) error {
3060+ if err := f.SetReadDeadline(t); err != nil {
3061+ return err
3062+ }
3063+ return f.SetWriteDeadline(t)
3064+}
3065+
3066+// CloseWrite closes the write side of a message pipe in byte mode.
3067+func (f *win32MessageBytePipe) CloseWrite() error {
3068+ if f.writeClosed {
3069+ return errPipeWriteClosed
3070+ }
3071+ err := f.win32File.Flush()
3072+ if err != nil {
3073+ return err
3074+ }
3075+ _, err = f.win32File.Write(nil)
3076+ if err != nil {
3077+ return err
3078+ }
3079+ f.writeClosed = true
3080+ return nil
3081+}
3082+
3083+// Write writes bytes to a message pipe in byte mode. Zero-byte writes are ignored, since
3084+// they are used to implement CloseWrite().
3085+func (f *win32MessageBytePipe) Write(b []byte) (int, error) {
3086+ if f.writeClosed {
3087+ return 0, errPipeWriteClosed
3088+ }
3089+ if len(b) == 0 {
3090+ return 0, nil
3091+ }
3092+ return f.win32File.Write(b)
3093+}
3094+
3095+// Read reads bytes from a message pipe in byte mode. A read of a zero-byte message on a message
3096+// mode pipe will return io.EOF, as will all subsequent reads.
3097+func (f *win32MessageBytePipe) Read(b []byte) (int, error) {
3098+ if f.readEOF {
3099+ return 0, io.EOF
3100+ }
3101+ n, err := f.win32File.Read(b)
3102+ if err == io.EOF { //nolint:errorlint
3103+ // If this was the result of a zero-byte read, then
3104+ // it is possible that the read was due to a zero-size
3105+ // message. Since we are simulating CloseWrite with a
3106+ // zero-byte message, ensure that all future Read() calls
3107+ // also return EOF.
3108+ f.readEOF = true
3109+ } else if err == syscall.ERROR_MORE_DATA { //nolint:errorlint // err is Errno
3110+ // ERROR_MORE_DATA indicates that the pipe's read mode is message mode
3111+ // and the message still has more bytes. Treat this as a success, since
3112+ // this package presents all named pipes as byte streams.
3113+ err = nil
3114+ }
3115+ return n, err
3116+}
3117+
3118+func (pipeAddress) Network() string {
3119+ return "pipe"
3120+}
3121+
3122+func (s pipeAddress) String() string {
3123+ return string(s)
3124+}
3125+
3126+// tryDialPipe attempts to dial the pipe at `path` until `ctx` cancellation or timeout.
3127+func tryDialPipe(ctx context.Context, path *string, access fs.AccessMask) (syscall.Handle, error) {
3128+ for {
3129+ select {
3130+ case <-ctx.Done():
3131+ return syscall.Handle(0), ctx.Err()
3132+ default:
3133+ wh, err := fs.CreateFile(*path,
3134+ access,
3135+ 0, // mode
3136+ nil, // security attributes
3137+ fs.OPEN_EXISTING,
3138+ fs.FILE_FLAG_OVERLAPPED|fs.SECURITY_SQOS_PRESENT|fs.SECURITY_ANONYMOUS,
3139+ 0, // template file handle
3140+ )
3141+ h := syscall.Handle(wh)
3142+ if err == nil {
3143+ return h, nil
3144+ }
3145+ if err != windows.ERROR_PIPE_BUSY { //nolint:errorlint // err is Errno
3146+ return h, &os.PathError{Err: err, Op: "open", Path: *path}
3147+ }
3148+ // Wait 10 msec and try again. This is a rather simplistic
3149+ // view, as we always try each 10 milliseconds.
3150+ time.Sleep(10 * time.Millisecond)
3151+ }
3152+ }
3153+}
3154+
3155+// DialPipe connects to a named pipe by path, timing out if the connection
3156+// takes longer than the specified duration. If timeout is nil, then we use
3157+// a default timeout of 2 seconds. (We do not use WaitNamedPipe.)
3158+func DialPipe(path string, timeout *time.Duration) (net.Conn, error) {
3159+ var absTimeout time.Time
3160+ if timeout != nil {
3161+ absTimeout = time.Now().Add(*timeout)
3162+ } else {
3163+ absTimeout = time.Now().Add(2 * time.Second)
3164+ }
3165+ ctx, cancel := context.WithDeadline(context.Background(), absTimeout)
3166+ defer cancel()
3167+ conn, err := DialPipeContext(ctx, path)
3168+ if errors.Is(err, context.DeadlineExceeded) {
3169+ return nil, ErrTimeout
3170+ }
3171+ return conn, err
3172+}
3173+
3174+// DialPipeContext attempts to connect to a named pipe by `path` until `ctx`
3175+// cancellation or timeout.
3176+func DialPipeContext(ctx context.Context, path string) (net.Conn, error) {
3177+ return DialPipeAccess(ctx, path, syscall.GENERIC_READ|syscall.GENERIC_WRITE)
3178+}
3179+
3180+// DialPipeAccess attempts to connect to a named pipe by `path` with `access` until `ctx`
3181+// cancellation or timeout.
3182+func DialPipeAccess(ctx context.Context, path string, access uint32) (net.Conn, error) {
3183+ var err error
3184+ var h syscall.Handle
3185+ h, err = tryDialPipe(ctx, &path, fs.AccessMask(access))
3186+ if err != nil {
3187+ return nil, err
3188+ }
3189+
3190+ var flags uint32
3191+ err = getNamedPipeInfo(h, &flags, nil, nil, nil)
3192+ if err != nil {
3193+ return nil, err
3194+ }
3195+
3196+ f, err := makeWin32File(h)
3197+ if err != nil {
3198+ syscall.Close(h)
3199+ return nil, err
3200+ }
3201+
3202+ // If the pipe is in message mode, return a message byte pipe, which
3203+ // supports CloseWrite().
3204+ if flags&windows.PIPE_TYPE_MESSAGE != 0 {
3205+ return &win32MessageBytePipe{
3206+ win32Pipe: win32Pipe{win32File: f, path: path},
3207+ }, nil
3208+ }
3209+ return &win32Pipe{win32File: f, path: path}, nil
3210+}
3211+
3212+type acceptResponse struct {
3213+ f *win32File
3214+ err error
3215+}
3216+
3217+type win32PipeListener struct {
3218+ firstHandle syscall.Handle
3219+ path string
3220+ config PipeConfig
3221+ acceptCh chan (chan acceptResponse)
3222+ closeCh chan int
3223+ doneCh chan int
3224+}
3225+
3226+func makeServerPipeHandle(path string, sd []byte, c *PipeConfig, first bool) (syscall.Handle, error) {
3227+ path16, err := syscall.UTF16FromString(path)
3228+ if err != nil {
3229+ return 0, &os.PathError{Op: "open", Path: path, Err: err}
3230+ }
3231+
3232+ var oa objectAttributes
3233+ oa.Length = unsafe.Sizeof(oa)
3234+
3235+ var ntPath unicodeString
3236+ if err := rtlDosPathNameToNtPathName(&path16[0],
3237+ &ntPath,
3238+ 0,
3239+ 0,
3240+ ).Err(); err != nil {
3241+ return 0, &os.PathError{Op: "open", Path: path, Err: err}
3242+ }
3243+ defer localFree(ntPath.Buffer)
3244+ oa.ObjectName = &ntPath
3245+ oa.Attributes = windows.OBJ_CASE_INSENSITIVE
3246+
3247+ // The security descriptor is only needed for the first pipe.
3248+ if first {
3249+ if sd != nil {
3250+ l := uint32(len(sd))
3251+ sdb := localAlloc(0, l)
3252+ defer localFree(sdb)
3253+ copy((*[0xffff]byte)(unsafe.Pointer(sdb))[:], sd)
3254+ oa.SecurityDescriptor = (*securityDescriptor)(unsafe.Pointer(sdb))
3255+ } else {
3256+ // Construct the default named pipe security descriptor.
3257+ var dacl uintptr
3258+ if err := rtlDefaultNpAcl(&dacl).Err(); err != nil {
3259+ return 0, fmt.Errorf("getting default named pipe ACL: %w", err)
3260+ }
3261+ defer localFree(dacl)
3262+
3263+ sdb := &securityDescriptor{
3264+ Revision: 1,
3265+ Control: windows.SE_DACL_PRESENT,
3266+ Dacl: dacl,
3267+ }
3268+ oa.SecurityDescriptor = sdb
3269+ }
3270+ }
3271+
3272+ typ := uint32(windows.FILE_PIPE_REJECT_REMOTE_CLIENTS)
3273+ if c.MessageMode {
3274+ typ |= windows.FILE_PIPE_MESSAGE_TYPE
3275+ }
3276+
3277+ disposition := uint32(windows.FILE_OPEN)
3278+ access := uint32(syscall.GENERIC_READ | syscall.GENERIC_WRITE | syscall.SYNCHRONIZE)
3279+ if first {
3280+ disposition = windows.FILE_CREATE
3281+ // By not asking for read or write access, the named pipe file system
3282+ // will put this pipe into an initially disconnected state, blocking
3283+ // client connections until the next call with first == false.
3284+ access = syscall.SYNCHRONIZE
3285+ }
3286+
3287+ timeout := int64(-50 * 10000) // 50ms
3288+
3289+ var (
3290+ h syscall.Handle
3291+ iosb ioStatusBlock
3292+ )
3293+ err = ntCreateNamedPipeFile(&h,
3294+ access,
3295+ &oa,
3296+ &iosb,
3297+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE,
3298+ disposition,
3299+ 0,
3300+ typ,
3301+ 0,
3302+ 0,
3303+ 0xffffffff,
3304+ uint32(c.InputBufferSize),
3305+ uint32(c.OutputBufferSize),
3306+ &timeout).Err()
3307+ if err != nil {
3308+ return 0, &os.PathError{Op: "open", Path: path, Err: err}
3309+ }
3310+
3311+ runtime.KeepAlive(ntPath)
3312+ return h, nil
3313+}
3314+
3315+func (l *win32PipeListener) makeServerPipe() (*win32File, error) {
3316+ h, err := makeServerPipeHandle(l.path, nil, &l.config, false)
3317+ if err != nil {
3318+ return nil, err
3319+ }
3320+ f, err := makeWin32File(h)
3321+ if err != nil {
3322+ syscall.Close(h)
3323+ return nil, err
3324+ }
3325+ return f, nil
3326+}
3327+
3328+func (l *win32PipeListener) makeConnectedServerPipe() (*win32File, error) {
3329+ p, err := l.makeServerPipe()
3330+ if err != nil {
3331+ return nil, err
3332+ }
3333+
3334+ // Wait for the client to connect.
3335+ ch := make(chan error)
3336+ go func(p *win32File) {
3337+ ch <- connectPipe(p)
3338+ }(p)
3339+
3340+ select {
3341+ case err = <-ch:
3342+ if err != nil {
3343+ p.Close()
3344+ p = nil
3345+ }
3346+ case <-l.closeCh:
3347+ // Abort the connect request by closing the handle.
3348+ p.Close()
3349+ p = nil
3350+ err = <-ch
3351+ if err == nil || err == ErrFileClosed { //nolint:errorlint // err is Errno
3352+ err = ErrPipeListenerClosed
3353+ }
3354+ }
3355+ return p, err
3356+}
3357+
3358+func (l *win32PipeListener) listenerRoutine() {
3359+ closed := false
3360+ for !closed {
3361+ select {
3362+ case <-l.closeCh:
3363+ closed = true
3364+ case responseCh := <-l.acceptCh:
3365+ var (
3366+ p *win32File
3367+ err error
3368+ )
3369+ for {
3370+ p, err = l.makeConnectedServerPipe()
3371+ // If the connection was immediately closed by the client, try
3372+ // again.
3373+ if err != windows.ERROR_NO_DATA { //nolint:errorlint // err is Errno
3374+ break
3375+ }
3376+ }
3377+ responseCh <- acceptResponse{p, err}
3378+ closed = err == ErrPipeListenerClosed //nolint:errorlint // err is Errno
3379+ }
3380+ }
3381+ syscall.Close(l.firstHandle)
3382+ l.firstHandle = 0
3383+ // Notify Close() and Accept() callers that the handle has been closed.
3384+ close(l.doneCh)
3385+}
3386+
3387+// PipeConfig contain configuration for the pipe listener.
3388+type PipeConfig struct {
3389+ // SecurityDescriptor contains a Windows security descriptor in SDDL format.
3390+ SecurityDescriptor string
3391+
3392+ // MessageMode determines whether the pipe is in byte or message mode. In either
3393+ // case the pipe is read in byte mode by default. The only practical difference in
3394+ // this implementation is that CloseWrite() is only supported for message mode pipes;
3395+ // CloseWrite() is implemented as a zero-byte write, but zero-byte writes are only
3396+ // transferred to the reader (and returned as io.EOF in this implementation)
3397+ // when the pipe is in message mode.
3398+ MessageMode bool
3399+
3400+ // InputBufferSize specifies the size of the input buffer, in bytes.
3401+ InputBufferSize int32
3402+
3403+ // OutputBufferSize specifies the size of the output buffer, in bytes.
3404+ OutputBufferSize int32
3405+}
3406+
3407+// ListenPipe creates a listener on a Windows named pipe path, e.g. \\.\pipe\mypipe.
3408+// The pipe must not already exist.
3409+func ListenPipe(path string, c *PipeConfig) (net.Listener, error) {
3410+ var (
3411+ sd []byte
3412+ err error
3413+ )
3414+ if c == nil {
3415+ c = &PipeConfig{}
3416+ }
3417+ if c.SecurityDescriptor != "" {
3418+ sd, err = SddlToSecurityDescriptor(c.SecurityDescriptor)
3419+ if err != nil {
3420+ return nil, err
3421+ }
3422+ }
3423+ h, err := makeServerPipeHandle(path, sd, c, true)
3424+ if err != nil {
3425+ return nil, err
3426+ }
3427+ l := &win32PipeListener{
3428+ firstHandle: h,
3429+ path: path,
3430+ config: *c,
3431+ acceptCh: make(chan (chan acceptResponse)),
3432+ closeCh: make(chan int),
3433+ doneCh: make(chan int),
3434+ }
3435+ go l.listenerRoutine()
3436+ return l, nil
3437+}
3438+
3439+func connectPipe(p *win32File) error {
3440+ c, err := p.prepareIO()
3441+ if err != nil {
3442+ return err
3443+ }
3444+ defer p.wg.Done()
3445+
3446+ err = connectNamedPipe(p.handle, &c.o)
3447+ _, err = p.asyncIO(c, nil, 0, err)
3448+ if err != nil && err != windows.ERROR_PIPE_CONNECTED { //nolint:errorlint // err is Errno
3449+ return err
3450+ }
3451+ return nil
3452+}
3453+
3454+func (l *win32PipeListener) Accept() (net.Conn, error) {
3455+ ch := make(chan acceptResponse)
3456+ select {
3457+ case l.acceptCh <- ch:
3458+ response := <-ch
3459+ err := response.err
3460+ if err != nil {
3461+ return nil, err
3462+ }
3463+ if l.config.MessageMode {
3464+ return &win32MessageBytePipe{
3465+ win32Pipe: win32Pipe{win32File: response.f, path: l.path},
3466+ }, nil
3467+ }
3468+ return &win32Pipe{win32File: response.f, path: l.path}, nil
3469+ case <-l.doneCh:
3470+ return nil, ErrPipeListenerClosed
3471+ }
3472+}
3473+
3474+func (l *win32PipeListener) Close() error {
3475+ select {
3476+ case l.closeCh <- 1:
3477+ <-l.doneCh
3478+ case <-l.doneCh:
3479+ }
3480+ return nil
3481+}
3482+
3483+func (l *win32PipeListener) Addr() net.Addr {
3484+ return pipeAddress(l.path)
3485+}
3486diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go b/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go
3487new file mode 100644
3488index 0000000..48ce4e9
3489--- /dev/null
3490+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid.go
3491@@ -0,0 +1,232 @@
3492+// Package guid provides a GUID type. The backing structure for a GUID is
3493+// identical to that used by the golang.org/x/sys/windows GUID type.
3494+// There are two main binary encodings used for a GUID, the big-endian encoding,
3495+// and the Windows (mixed-endian) encoding. See here for details:
3496+// https://en.wikipedia.org/wiki/Universally_unique_identifier#Encoding
3497+package guid
3498+
3499+import (
3500+ "crypto/rand"
3501+ "crypto/sha1" //nolint:gosec // not used for secure application
3502+ "encoding"
3503+ "encoding/binary"
3504+ "fmt"
3505+ "strconv"
3506+)
3507+
3508+//go:generate go run golang.org/x/tools/cmd/stringer -type=Variant -trimprefix=Variant -linecomment
3509+
3510+// Variant specifies which GUID variant (or "type") of the GUID. It determines
3511+// how the entirety of the rest of the GUID is interpreted.
3512+type Variant uint8
3513+
3514+// The variants specified by RFC 4122 section 4.1.1.
3515+const (
3516+ // VariantUnknown specifies a GUID variant which does not conform to one of
3517+ // the variant encodings specified in RFC 4122.
3518+ VariantUnknown Variant = iota
3519+ VariantNCS
3520+ VariantRFC4122 // RFC 4122
3521+ VariantMicrosoft
3522+ VariantFuture
3523+)
3524+
3525+// Version specifies how the bits in the GUID were generated. For instance, a
3526+// version 4 GUID is randomly generated, and a version 5 is generated from the
3527+// hash of an input string.
3528+type Version uint8
3529+
3530+func (v Version) String() string {
3531+ return strconv.FormatUint(uint64(v), 10)
3532+}
3533+
3534+var _ = (encoding.TextMarshaler)(GUID{})
3535+var _ = (encoding.TextUnmarshaler)(&GUID{})
3536+
3537+// NewV4 returns a new version 4 (pseudorandom) GUID, as defined by RFC 4122.
3538+func NewV4() (GUID, error) {
3539+ var b [16]byte
3540+ if _, err := rand.Read(b[:]); err != nil {
3541+ return GUID{}, err
3542+ }
3543+
3544+ g := FromArray(b)
3545+ g.setVersion(4) // Version 4 means randomly generated.
3546+ g.setVariant(VariantRFC4122)
3547+
3548+ return g, nil
3549+}
3550+
3551+// NewV5 returns a new version 5 (generated from a string via SHA-1 hashing)
3552+// GUID, as defined by RFC 4122. The RFC is unclear on the encoding of the name,
3553+// and the sample code treats it as a series of bytes, so we do the same here.
3554+//
3555+// Some implementations, such as those found on Windows, treat the name as a
3556+// big-endian UTF16 stream of bytes. If that is desired, the string can be
3557+// encoded as such before being passed to this function.
3558+func NewV5(namespace GUID, name []byte) (GUID, error) {
3559+ b := sha1.New() //nolint:gosec // not used for secure application
3560+ namespaceBytes := namespace.ToArray()
3561+ b.Write(namespaceBytes[:])
3562+ b.Write(name)
3563+
3564+ a := [16]byte{}
3565+ copy(a[:], b.Sum(nil))
3566+
3567+ g := FromArray(a)
3568+ g.setVersion(5) // Version 5 means generated from a string.
3569+ g.setVariant(VariantRFC4122)
3570+
3571+ return g, nil
3572+}
3573+
3574+func fromArray(b [16]byte, order binary.ByteOrder) GUID {
3575+ var g GUID
3576+ g.Data1 = order.Uint32(b[0:4])
3577+ g.Data2 = order.Uint16(b[4:6])
3578+ g.Data3 = order.Uint16(b[6:8])
3579+ copy(g.Data4[:], b[8:16])
3580+ return g
3581+}
3582+
3583+func (g GUID) toArray(order binary.ByteOrder) [16]byte {
3584+ b := [16]byte{}
3585+ order.PutUint32(b[0:4], g.Data1)
3586+ order.PutUint16(b[4:6], g.Data2)
3587+ order.PutUint16(b[6:8], g.Data3)
3588+ copy(b[8:16], g.Data4[:])
3589+ return b
3590+}
3591+
3592+// FromArray constructs a GUID from a big-endian encoding array of 16 bytes.
3593+func FromArray(b [16]byte) GUID {
3594+ return fromArray(b, binary.BigEndian)
3595+}
3596+
3597+// ToArray returns an array of 16 bytes representing the GUID in big-endian
3598+// encoding.
3599+func (g GUID) ToArray() [16]byte {
3600+ return g.toArray(binary.BigEndian)
3601+}
3602+
3603+// FromWindowsArray constructs a GUID from a Windows encoding array of bytes.
3604+func FromWindowsArray(b [16]byte) GUID {
3605+ return fromArray(b, binary.LittleEndian)
3606+}
3607+
3608+// ToWindowsArray returns an array of 16 bytes representing the GUID in Windows
3609+// encoding.
3610+func (g GUID) ToWindowsArray() [16]byte {
3611+ return g.toArray(binary.LittleEndian)
3612+}
3613+
3614+func (g GUID) String() string {
3615+ return fmt.Sprintf(
3616+ "%08x-%04x-%04x-%04x-%012x",
3617+ g.Data1,
3618+ g.Data2,
3619+ g.Data3,
3620+ g.Data4[:2],
3621+ g.Data4[2:])
3622+}
3623+
3624+// FromString parses a string containing a GUID and returns the GUID. The only
3625+// format currently supported is the `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
3626+// format.
3627+func FromString(s string) (GUID, error) {
3628+ if len(s) != 36 {
3629+ return GUID{}, fmt.Errorf("invalid GUID %q", s)
3630+ }
3631+ if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
3632+ return GUID{}, fmt.Errorf("invalid GUID %q", s)
3633+ }
3634+
3635+ var g GUID
3636+
3637+ data1, err := strconv.ParseUint(s[0:8], 16, 32)
3638+ if err != nil {
3639+ return GUID{}, fmt.Errorf("invalid GUID %q", s)
3640+ }
3641+ g.Data1 = uint32(data1)
3642+
3643+ data2, err := strconv.ParseUint(s[9:13], 16, 16)
3644+ if err != nil {
3645+ return GUID{}, fmt.Errorf("invalid GUID %q", s)
3646+ }
3647+ g.Data2 = uint16(data2)
3648+
3649+ data3, err := strconv.ParseUint(s[14:18], 16, 16)
3650+ if err != nil {
3651+ return GUID{}, fmt.Errorf("invalid GUID %q", s)
3652+ }
3653+ g.Data3 = uint16(data3)
3654+
3655+ for i, x := range []int{19, 21, 24, 26, 28, 30, 32, 34} {
3656+ v, err := strconv.ParseUint(s[x:x+2], 16, 8)
3657+ if err != nil {
3658+ return GUID{}, fmt.Errorf("invalid GUID %q", s)
3659+ }
3660+ g.Data4[i] = uint8(v)
3661+ }
3662+
3663+ return g, nil
3664+}
3665+
3666+func (g *GUID) setVariant(v Variant) {
3667+ d := g.Data4[0]
3668+ switch v {
3669+ case VariantNCS:
3670+ d = (d & 0x7f)
3671+ case VariantRFC4122:
3672+ d = (d & 0x3f) | 0x80
3673+ case VariantMicrosoft:
3674+ d = (d & 0x1f) | 0xc0
3675+ case VariantFuture:
3676+ d = (d & 0x0f) | 0xe0
3677+ case VariantUnknown:
3678+ fallthrough
3679+ default:
3680+ panic(fmt.Sprintf("invalid variant: %d", v))
3681+ }
3682+ g.Data4[0] = d
3683+}
3684+
3685+// Variant returns the GUID variant, as defined in RFC 4122.
3686+func (g GUID) Variant() Variant {
3687+ b := g.Data4[0]
3688+ if b&0x80 == 0 {
3689+ return VariantNCS
3690+ } else if b&0xc0 == 0x80 {
3691+ return VariantRFC4122
3692+ } else if b&0xe0 == 0xc0 {
3693+ return VariantMicrosoft
3694+ } else if b&0xe0 == 0xe0 {
3695+ return VariantFuture
3696+ }
3697+ return VariantUnknown
3698+}
3699+
3700+func (g *GUID) setVersion(v Version) {
3701+ g.Data3 = (g.Data3 & 0x0fff) | (uint16(v) << 12)
3702+}
3703+
3704+// Version returns the GUID version, as defined in RFC 4122.
3705+func (g GUID) Version() Version {
3706+ return Version((g.Data3 & 0xF000) >> 12)
3707+}
3708+
3709+// MarshalText returns the textual representation of the GUID.
3710+func (g GUID) MarshalText() ([]byte, error) {
3711+ return []byte(g.String()), nil
3712+}
3713+
3714+// UnmarshalText takes the textual representation of a GUID, and unmarhals it
3715+// into this GUID.
3716+func (g *GUID) UnmarshalText(text []byte) error {
3717+ g2, err := FromString(string(text))
3718+ if err != nil {
3719+ return err
3720+ }
3721+ *g = g2
3722+ return nil
3723+}
3724diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_nonwindows.go b/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_nonwindows.go
3725new file mode 100644
3726index 0000000..805bd35
3727--- /dev/null
3728+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_nonwindows.go
3729@@ -0,0 +1,16 @@
3730+//go:build !windows
3731+// +build !windows
3732+
3733+package guid
3734+
3735+// GUID represents a GUID/UUID. It has the same structure as
3736+// golang.org/x/sys/windows.GUID so that it can be used with functions expecting
3737+// that type. It is defined as its own type as that is only available to builds
3738+// targeted at `windows`. The representation matches that used by native Windows
3739+// code.
3740+type GUID struct {
3741+ Data1 uint32
3742+ Data2 uint16
3743+ Data3 uint16
3744+ Data4 [8]byte
3745+}
3746diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_windows.go b/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_windows.go
3747new file mode 100644
3748index 0000000..27e45ee
3749--- /dev/null
3750+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/guid_windows.go
3751@@ -0,0 +1,13 @@
3752+//go:build windows
3753+// +build windows
3754+
3755+package guid
3756+
3757+import "golang.org/x/sys/windows"
3758+
3759+// GUID represents a GUID/UUID. It has the same structure as
3760+// golang.org/x/sys/windows.GUID so that it can be used with functions expecting
3761+// that type. It is defined as its own type so that stringification and
3762+// marshaling can be supported. The representation matches that used by native
3763+// Windows code.
3764+type GUID windows.GUID
3765diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/variant_string.go b/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/variant_string.go
3766new file mode 100644
3767index 0000000..4076d31
3768--- /dev/null
3769+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/pkg/guid/variant_string.go
3770@@ -0,0 +1,27 @@
3771+// Code generated by "stringer -type=Variant -trimprefix=Variant -linecomment"; DO NOT EDIT.
3772+
3773+package guid
3774+
3775+import "strconv"
3776+
3777+func _() {
3778+ // An "invalid array index" compiler error signifies that the constant values have changed.
3779+ // Re-run the stringer command to generate them again.
3780+ var x [1]struct{}
3781+ _ = x[VariantUnknown-0]
3782+ _ = x[VariantNCS-1]
3783+ _ = x[VariantRFC4122-2]
3784+ _ = x[VariantMicrosoft-3]
3785+ _ = x[VariantFuture-4]
3786+}
3787+
3788+const _Variant_name = "UnknownNCSRFC 4122MicrosoftFuture"
3789+
3790+var _Variant_index = [...]uint8{0, 7, 10, 18, 27, 33}
3791+
3792+func (i Variant) String() string {
3793+ if i >= Variant(len(_Variant_index)-1) {
3794+ return "Variant(" + strconv.FormatInt(int64(i), 10) + ")"
3795+ }
3796+ return _Variant_name[_Variant_index[i]:_Variant_index[i+1]]
3797+}
3798diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/privilege.go b/debian/extra/vendor/github.com/Microsoft/go-winio/privilege.go
3799new file mode 100644
3800index 0000000..0ff9dac
3801--- /dev/null
3802+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/privilege.go
3803@@ -0,0 +1,197 @@
3804+//go:build windows
3805+// +build windows
3806+
3807+package winio
3808+
3809+import (
3810+ "bytes"
3811+ "encoding/binary"
3812+ "fmt"
3813+ "runtime"
3814+ "sync"
3815+ "syscall"
3816+ "unicode/utf16"
3817+
3818+ "golang.org/x/sys/windows"
3819+)
3820+
3821+//sys adjustTokenPrivileges(token windows.Token, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) [true] = advapi32.AdjustTokenPrivileges
3822+//sys impersonateSelf(level uint32) (err error) = advapi32.ImpersonateSelf
3823+//sys revertToSelf() (err error) = advapi32.RevertToSelf
3824+//sys openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool, token *windows.Token) (err error) = advapi32.OpenThreadToken
3825+//sys getCurrentThread() (h syscall.Handle) = GetCurrentThread
3826+//sys lookupPrivilegeValue(systemName string, name string, luid *uint64) (err error) = advapi32.LookupPrivilegeValueW
3827+//sys lookupPrivilegeName(systemName string, luid *uint64, buffer *uint16, size *uint32) (err error) = advapi32.LookupPrivilegeNameW
3828+//sys lookupPrivilegeDisplayName(systemName string, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) = advapi32.LookupPrivilegeDisplayNameW
3829+
3830+const (
3831+ //revive:disable-next-line:var-naming ALL_CAPS
3832+ SE_PRIVILEGE_ENABLED = windows.SE_PRIVILEGE_ENABLED
3833+
3834+ //revive:disable-next-line:var-naming ALL_CAPS
3835+ ERROR_NOT_ALL_ASSIGNED syscall.Errno = windows.ERROR_NOT_ALL_ASSIGNED
3836+
3837+ SeBackupPrivilege = "SeBackupPrivilege"
3838+ SeRestorePrivilege = "SeRestorePrivilege"
3839+ SeSecurityPrivilege = "SeSecurityPrivilege"
3840+)
3841+
3842+var (
3843+ privNames = make(map[string]uint64)
3844+ privNameMutex sync.Mutex
3845+)
3846+
3847+// PrivilegeError represents an error enabling privileges.
3848+type PrivilegeError struct {
3849+ privileges []uint64
3850+}
3851+
3852+func (e *PrivilegeError) Error() string {
3853+ s := "Could not enable privilege "
3854+ if len(e.privileges) > 1 {
3855+ s = "Could not enable privileges "
3856+ }
3857+ for i, p := range e.privileges {
3858+ if i != 0 {
3859+ s += ", "
3860+ }
3861+ s += `"`
3862+ s += getPrivilegeName(p)
3863+ s += `"`
3864+ }
3865+ return s
3866+}
3867+
3868+// RunWithPrivilege enables a single privilege for a function call.
3869+func RunWithPrivilege(name string, fn func() error) error {
3870+ return RunWithPrivileges([]string{name}, fn)
3871+}
3872+
3873+// RunWithPrivileges enables privileges for a function call.
3874+func RunWithPrivileges(names []string, fn func() error) error {
3875+ privileges, err := mapPrivileges(names)
3876+ if err != nil {
3877+ return err
3878+ }
3879+ runtime.LockOSThread()
3880+ defer runtime.UnlockOSThread()
3881+ token, err := newThreadToken()
3882+ if err != nil {
3883+ return err
3884+ }
3885+ defer releaseThreadToken(token)
3886+ err = adjustPrivileges(token, privileges, SE_PRIVILEGE_ENABLED)
3887+ if err != nil {
3888+ return err
3889+ }
3890+ return fn()
3891+}
3892+
3893+func mapPrivileges(names []string) ([]uint64, error) {
3894+ privileges := make([]uint64, 0, len(names))
3895+ privNameMutex.Lock()
3896+ defer privNameMutex.Unlock()
3897+ for _, name := range names {
3898+ p, ok := privNames[name]
3899+ if !ok {
3900+ err := lookupPrivilegeValue("", name, &p)
3901+ if err != nil {
3902+ return nil, err
3903+ }
3904+ privNames[name] = p
3905+ }
3906+ privileges = append(privileges, p)
3907+ }
3908+ return privileges, nil
3909+}
3910+
3911+// EnableProcessPrivileges enables privileges globally for the process.
3912+func EnableProcessPrivileges(names []string) error {
3913+ return enableDisableProcessPrivilege(names, SE_PRIVILEGE_ENABLED)
3914+}
3915+
3916+// DisableProcessPrivileges disables privileges globally for the process.
3917+func DisableProcessPrivileges(names []string) error {
3918+ return enableDisableProcessPrivilege(names, 0)
3919+}
3920+
3921+func enableDisableProcessPrivilege(names []string, action uint32) error {
3922+ privileges, err := mapPrivileges(names)
3923+ if err != nil {
3924+ return err
3925+ }
3926+
3927+ p := windows.CurrentProcess()
3928+ var token windows.Token
3929+ err = windows.OpenProcessToken(p, windows.TOKEN_ADJUST_PRIVILEGES|windows.TOKEN_QUERY, &token)
3930+ if err != nil {
3931+ return err
3932+ }
3933+
3934+ defer token.Close()
3935+ return adjustPrivileges(token, privileges, action)
3936+}
3937+
3938+func adjustPrivileges(token windows.Token, privileges []uint64, action uint32) error {
3939+ var b bytes.Buffer
3940+ _ = binary.Write(&b, binary.LittleEndian, uint32(len(privileges)))
3941+ for _, p := range privileges {
3942+ _ = binary.Write(&b, binary.LittleEndian, p)
3943+ _ = binary.Write(&b, binary.LittleEndian, action)
3944+ }
3945+ prevState := make([]byte, b.Len())
3946+ reqSize := uint32(0)
3947+ success, err := adjustTokenPrivileges(token, false, &b.Bytes()[0], uint32(len(prevState)), &prevState[0], &reqSize)
3948+ if !success {
3949+ return err
3950+ }
3951+ if err == ERROR_NOT_ALL_ASSIGNED { //nolint:errorlint // err is Errno
3952+ return &PrivilegeError{privileges}
3953+ }
3954+ return nil
3955+}
3956+
3957+func getPrivilegeName(luid uint64) string {
3958+ var nameBuffer [256]uint16
3959+ bufSize := uint32(len(nameBuffer))
3960+ err := lookupPrivilegeName("", &luid, &nameBuffer[0], &bufSize)
3961+ if err != nil {
3962+ return fmt.Sprintf("<unknown privilege %d>", luid)
3963+ }
3964+
3965+ var displayNameBuffer [256]uint16
3966+ displayBufSize := uint32(len(displayNameBuffer))
3967+ var langID uint32
3968+ err = lookupPrivilegeDisplayName("", &nameBuffer[0], &displayNameBuffer[0], &displayBufSize, &langID)
3969+ if err != nil {
3970+ return fmt.Sprintf("<unknown privilege %s>", string(utf16.Decode(nameBuffer[:bufSize])))
3971+ }
3972+
3973+ return string(utf16.Decode(displayNameBuffer[:displayBufSize]))
3974+}
3975+
3976+func newThreadToken() (windows.Token, error) {
3977+ err := impersonateSelf(windows.SecurityImpersonation)
3978+ if err != nil {
3979+ return 0, err
3980+ }
3981+
3982+ var token windows.Token
3983+ err = openThreadToken(getCurrentThread(), syscall.TOKEN_ADJUST_PRIVILEGES|syscall.TOKEN_QUERY, false, &token)
3984+ if err != nil {
3985+ rerr := revertToSelf()
3986+ if rerr != nil {
3987+ panic(rerr)
3988+ }
3989+ return 0, err
3990+ }
3991+ return token, nil
3992+}
3993+
3994+func releaseThreadToken(h windows.Token) {
3995+ err := revertToSelf()
3996+ if err != nil {
3997+ panic(err)
3998+ }
3999+ h.Close()
4000+}
4001diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/reparse.go b/debian/extra/vendor/github.com/Microsoft/go-winio/reparse.go
4002new file mode 100644
4003index 0000000..67d1a10
4004--- /dev/null
4005+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/reparse.go
4006@@ -0,0 +1,131 @@
4007+//go:build windows
4008+// +build windows
4009+
4010+package winio
4011+
4012+import (
4013+ "bytes"
4014+ "encoding/binary"
4015+ "fmt"
4016+ "strings"
4017+ "unicode/utf16"
4018+ "unsafe"
4019+)
4020+
4021+const (
4022+ reparseTagMountPoint = 0xA0000003
4023+ reparseTagSymlink = 0xA000000C
4024+)
4025+
4026+type reparseDataBuffer struct {
4027+ ReparseTag uint32
4028+ ReparseDataLength uint16
4029+ Reserved uint16
4030+ SubstituteNameOffset uint16
4031+ SubstituteNameLength uint16
4032+ PrintNameOffset uint16
4033+ PrintNameLength uint16
4034+}
4035+
4036+// ReparsePoint describes a Win32 symlink or mount point.
4037+type ReparsePoint struct {
4038+ Target string
4039+ IsMountPoint bool
4040+}
4041+
4042+// UnsupportedReparsePointError is returned when trying to decode a non-symlink or
4043+// mount point reparse point.
4044+type UnsupportedReparsePointError struct {
4045+ Tag uint32
4046+}
4047+
4048+func (e *UnsupportedReparsePointError) Error() string {
4049+ return fmt.Sprintf("unsupported reparse point %x", e.Tag)
4050+}
4051+
4052+// DecodeReparsePoint decodes a Win32 REPARSE_DATA_BUFFER structure containing either a symlink
4053+// or a mount point.
4054+func DecodeReparsePoint(b []byte) (*ReparsePoint, error) {
4055+ tag := binary.LittleEndian.Uint32(b[0:4])
4056+ return DecodeReparsePointData(tag, b[8:])
4057+}
4058+
4059+func DecodeReparsePointData(tag uint32, b []byte) (*ReparsePoint, error) {
4060+ isMountPoint := false
4061+ switch tag {
4062+ case reparseTagMountPoint:
4063+ isMountPoint = true
4064+ case reparseTagSymlink:
4065+ default:
4066+ return nil, &UnsupportedReparsePointError{tag}
4067+ }
4068+ nameOffset := 8 + binary.LittleEndian.Uint16(b[4:6])
4069+ if !isMountPoint {
4070+ nameOffset += 4
4071+ }
4072+ nameLength := binary.LittleEndian.Uint16(b[6:8])
4073+ name := make([]uint16, nameLength/2)
4074+ err := binary.Read(bytes.NewReader(b[nameOffset:nameOffset+nameLength]), binary.LittleEndian, &name)
4075+ if err != nil {
4076+ return nil, err
4077+ }
4078+ return &ReparsePoint{string(utf16.Decode(name)), isMountPoint}, nil
4079+}
4080+
4081+func isDriveLetter(c byte) bool {
4082+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
4083+}
4084+
4085+// EncodeReparsePoint encodes a Win32 REPARSE_DATA_BUFFER structure describing a symlink or
4086+// mount point.
4087+func EncodeReparsePoint(rp *ReparsePoint) []byte {
4088+ // Generate an NT path and determine if this is a relative path.
4089+ var ntTarget string
4090+ relative := false
4091+ if strings.HasPrefix(rp.Target, `\\?\`) {
4092+ ntTarget = `\??\` + rp.Target[4:]
4093+ } else if strings.HasPrefix(rp.Target, `\\`) {
4094+ ntTarget = `\??\UNC\` + rp.Target[2:]
4095+ } else if len(rp.Target) >= 2 && isDriveLetter(rp.Target[0]) && rp.Target[1] == ':' {
4096+ ntTarget = `\??\` + rp.Target
4097+ } else {
4098+ ntTarget = rp.Target
4099+ relative = true
4100+ }
4101+
4102+ // The paths must be NUL-terminated even though they are counted strings.
4103+ target16 := utf16.Encode([]rune(rp.Target + "\x00"))
4104+ ntTarget16 := utf16.Encode([]rune(ntTarget + "\x00"))
4105+
4106+ size := int(unsafe.Sizeof(reparseDataBuffer{})) - 8
4107+ size += len(ntTarget16)*2 + len(target16)*2
4108+
4109+ tag := uint32(reparseTagMountPoint)
4110+ if !rp.IsMountPoint {
4111+ tag = reparseTagSymlink
4112+ size += 4 // Add room for symlink flags
4113+ }
4114+
4115+ data := reparseDataBuffer{
4116+ ReparseTag: tag,
4117+ ReparseDataLength: uint16(size),
4118+ SubstituteNameOffset: 0,
4119+ SubstituteNameLength: uint16((len(ntTarget16) - 1) * 2),
4120+ PrintNameOffset: uint16(len(ntTarget16) * 2),
4121+ PrintNameLength: uint16((len(target16) - 1) * 2),
4122+ }
4123+
4124+ var b bytes.Buffer
4125+ _ = binary.Write(&b, binary.LittleEndian, &data)
4126+ if !rp.IsMountPoint {
4127+ flags := uint32(0)
4128+ if relative {
4129+ flags |= 1
4130+ }
4131+ _ = binary.Write(&b, binary.LittleEndian, flags)
4132+ }
4133+
4134+ _ = binary.Write(&b, binary.LittleEndian, ntTarget16)
4135+ _ = binary.Write(&b, binary.LittleEndian, target16)
4136+ return b.Bytes()
4137+}
4138diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/sd.go b/debian/extra/vendor/github.com/Microsoft/go-winio/sd.go
4139new file mode 100644
4140index 0000000..5550ef6
4141--- /dev/null
4142+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/sd.go
4143@@ -0,0 +1,144 @@
4144+//go:build windows
4145+// +build windows
4146+
4147+package winio
4148+
4149+import (
4150+ "errors"
4151+ "syscall"
4152+ "unsafe"
4153+
4154+ "golang.org/x/sys/windows"
4155+)
4156+
4157+//sys lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) = advapi32.LookupAccountNameW
4158+//sys lookupAccountSid(systemName *uint16, sid *byte, name *uint16, nameSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) = advapi32.LookupAccountSidW
4159+//sys convertSidToStringSid(sid *byte, str **uint16) (err error) = advapi32.ConvertSidToStringSidW
4160+//sys convertStringSidToSid(str *uint16, sid **byte) (err error) = advapi32.ConvertStringSidToSidW
4161+//sys convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd *uintptr, size *uint32) (err error) = advapi32.ConvertStringSecurityDescriptorToSecurityDescriptorW
4162+//sys convertSecurityDescriptorToStringSecurityDescriptor(sd *byte, revision uint32, secInfo uint32, sddl **uint16, sddlSize *uint32) (err error) = advapi32.ConvertSecurityDescriptorToStringSecurityDescriptorW
4163+//sys localFree(mem uintptr) = LocalFree
4164+//sys getSecurityDescriptorLength(sd uintptr) (len uint32) = advapi32.GetSecurityDescriptorLength
4165+
4166+type AccountLookupError struct {
4167+ Name string
4168+ Err error
4169+}
4170+
4171+func (e *AccountLookupError) Error() string {
4172+ if e.Name == "" {
4173+ return "lookup account: empty account name specified"
4174+ }
4175+ var s string
4176+ switch {
4177+ case errors.Is(e.Err, windows.ERROR_INVALID_SID):
4178+ s = "the security ID structure is invalid"
4179+ case errors.Is(e.Err, windows.ERROR_NONE_MAPPED):
4180+ s = "not found"
4181+ default:
4182+ s = e.Err.Error()
4183+ }
4184+ return "lookup account " + e.Name + ": " + s
4185+}
4186+
4187+func (e *AccountLookupError) Unwrap() error { return e.Err }
4188+
4189+type SddlConversionError struct {
4190+ Sddl string
4191+ Err error
4192+}
4193+
4194+func (e *SddlConversionError) Error() string {
4195+ return "convert " + e.Sddl + ": " + e.Err.Error()
4196+}
4197+
4198+func (e *SddlConversionError) Unwrap() error { return e.Err }
4199+
4200+// LookupSidByName looks up the SID of an account by name
4201+//
4202+//revive:disable-next-line:var-naming SID, not Sid
4203+func LookupSidByName(name string) (sid string, err error) {
4204+ if name == "" {
4205+ return "", &AccountLookupError{name, windows.ERROR_NONE_MAPPED}
4206+ }
4207+
4208+ var sidSize, sidNameUse, refDomainSize uint32
4209+ err = lookupAccountName(nil, name, nil, &sidSize, nil, &refDomainSize, &sidNameUse)
4210+ if err != nil && err != syscall.ERROR_INSUFFICIENT_BUFFER { //nolint:errorlint // err is Errno
4211+ return "", &AccountLookupError{name, err}
4212+ }
4213+ sidBuffer := make([]byte, sidSize)
4214+ refDomainBuffer := make([]uint16, refDomainSize)
4215+ err = lookupAccountName(nil, name, &sidBuffer[0], &sidSize, &refDomainBuffer[0], &refDomainSize, &sidNameUse)
4216+ if err != nil {
4217+ return "", &AccountLookupError{name, err}
4218+ }
4219+ var strBuffer *uint16
4220+ err = convertSidToStringSid(&sidBuffer[0], &strBuffer)
4221+ if err != nil {
4222+ return "", &AccountLookupError{name, err}
4223+ }
4224+ sid = syscall.UTF16ToString((*[0xffff]uint16)(unsafe.Pointer(strBuffer))[:])
4225+ localFree(uintptr(unsafe.Pointer(strBuffer)))
4226+ return sid, nil
4227+}
4228+
4229+// LookupNameBySid looks up the name of an account by SID
4230+//
4231+//revive:disable-next-line:var-naming SID, not Sid
4232+func LookupNameBySid(sid string) (name string, err error) {
4233+ if sid == "" {
4234+ return "", &AccountLookupError{sid, windows.ERROR_NONE_MAPPED}
4235+ }
4236+
4237+ sidBuffer, err := windows.UTF16PtrFromString(sid)
4238+ if err != nil {
4239+ return "", &AccountLookupError{sid, err}
4240+ }
4241+
4242+ var sidPtr *byte
4243+ if err = convertStringSidToSid(sidBuffer, &sidPtr); err != nil {
4244+ return "", &AccountLookupError{sid, err}
4245+ }
4246+ defer localFree(uintptr(unsafe.Pointer(sidPtr)))
4247+
4248+ var nameSize, refDomainSize, sidNameUse uint32
4249+ err = lookupAccountSid(nil, sidPtr, nil, &nameSize, nil, &refDomainSize, &sidNameUse)
4250+ if err != nil && err != windows.ERROR_INSUFFICIENT_BUFFER { //nolint:errorlint // err is Errno
4251+ return "", &AccountLookupError{sid, err}
4252+ }
4253+
4254+ nameBuffer := make([]uint16, nameSize)
4255+ refDomainBuffer := make([]uint16, refDomainSize)
4256+ err = lookupAccountSid(nil, sidPtr, &nameBuffer[0], &nameSize, &refDomainBuffer[0], &refDomainSize, &sidNameUse)
4257+ if err != nil {
4258+ return "", &AccountLookupError{sid, err}
4259+ }
4260+
4261+ name = windows.UTF16ToString(nameBuffer)
4262+ return name, nil
4263+}
4264+
4265+func SddlToSecurityDescriptor(sddl string) ([]byte, error) {
4266+ var sdBuffer uintptr
4267+ err := convertStringSecurityDescriptorToSecurityDescriptor(sddl, 1, &sdBuffer, nil)
4268+ if err != nil {
4269+ return nil, &SddlConversionError{sddl, err}
4270+ }
4271+ defer localFree(sdBuffer)
4272+ sd := make([]byte, getSecurityDescriptorLength(sdBuffer))
4273+ copy(sd, (*[0xffff]byte)(unsafe.Pointer(sdBuffer))[:len(sd)])
4274+ return sd, nil
4275+}
4276+
4277+func SecurityDescriptorToSddl(sd []byte) (string, error) {
4278+ var sddl *uint16
4279+ // The returned string length seems to include an arbitrary number of terminating NULs.
4280+ // Don't use it.
4281+ err := convertSecurityDescriptorToStringSecurityDescriptor(&sd[0], 1, 0xff, &sddl, nil)
4282+ if err != nil {
4283+ return "", err
4284+ }
4285+ defer localFree(uintptr(unsafe.Pointer(sddl)))
4286+ return syscall.UTF16ToString((*[0xffff]uint16)(unsafe.Pointer(sddl))[:]), nil
4287+}
4288diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/syscall.go b/debian/extra/vendor/github.com/Microsoft/go-winio/syscall.go
4289new file mode 100644
4290index 0000000..a6ca111
4291--- /dev/null
4292+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/syscall.go
4293@@ -0,0 +1,5 @@
4294+//go:build windows
4295+
4296+package winio
4297+
4298+//go:generate go run github.com/Microsoft/go-winio/tools/mkwinsyscall -output zsyscall_windows.go ./*.go
4299diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/tools.go b/debian/extra/vendor/github.com/Microsoft/go-winio/tools.go
4300new file mode 100644
4301index 0000000..2aa0458
4302--- /dev/null
4303+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/tools.go
4304@@ -0,0 +1,5 @@
4305+//go:build tools
4306+
4307+package winio
4308+
4309+import _ "golang.org/x/tools/cmd/stringer"
4310diff --git a/debian/extra/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go b/debian/extra/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go
4311new file mode 100644
4312index 0000000..469b16f
4313--- /dev/null
4314+++ b/debian/extra/vendor/github.com/Microsoft/go-winio/zsyscall_windows.go
4315@@ -0,0 +1,419 @@
4316+//go:build windows
4317+
4318+// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT.
4319+
4320+package winio
4321+
4322+import (
4323+ "syscall"
4324+ "unsafe"
4325+
4326+ "golang.org/x/sys/windows"
4327+)
4328+
4329+var _ unsafe.Pointer
4330+
4331+// Do the interface allocations only once for common
4332+// Errno values.
4333+const (
4334+ errnoERROR_IO_PENDING = 997
4335+)
4336+
4337+var (
4338+ errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
4339+ errERROR_EINVAL error = syscall.EINVAL
4340+)
4341+
4342+// errnoErr returns common boxed Errno values, to prevent
4343+// allocations at runtime.
4344+func errnoErr(e syscall.Errno) error {
4345+ switch e {
4346+ case 0:
4347+ return errERROR_EINVAL
4348+ case errnoERROR_IO_PENDING:
4349+ return errERROR_IO_PENDING
4350+ }
4351+ // TODO: add more here, after collecting data on the common
4352+ // error values see on Windows. (perhaps when running
4353+ // all.bat?)
4354+ return e
4355+}
4356+
4357+var (
4358+ modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
4359+ modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
4360+ modntdll = windows.NewLazySystemDLL("ntdll.dll")
4361+ modws2_32 = windows.NewLazySystemDLL("ws2_32.dll")
4362+
4363+ procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
4364+ procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
4365+ procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
4366+ procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
4367+ procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
4368+ procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength")
4369+ procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
4370+ procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
4371+ procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
4372+ procLookupPrivilegeDisplayNameW = modadvapi32.NewProc("LookupPrivilegeDisplayNameW")
4373+ procLookupPrivilegeNameW = modadvapi32.NewProc("LookupPrivilegeNameW")
4374+ procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
4375+ procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
4376+ procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
4377+ procBackupRead = modkernel32.NewProc("BackupRead")
4378+ procBackupWrite = modkernel32.NewProc("BackupWrite")
4379+ procCancelIoEx = modkernel32.NewProc("CancelIoEx")
4380+ procConnectNamedPipe = modkernel32.NewProc("ConnectNamedPipe")
4381+ procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
4382+ procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW")
4383+ procGetCurrentThread = modkernel32.NewProc("GetCurrentThread")
4384+ procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
4385+ procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
4386+ procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
4387+ procLocalAlloc = modkernel32.NewProc("LocalAlloc")
4388+ procLocalFree = modkernel32.NewProc("LocalFree")
4389+ procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
4390+ procNtCreateNamedPipeFile = modntdll.NewProc("NtCreateNamedPipeFile")
4391+ procRtlDefaultNpAcl = modntdll.NewProc("RtlDefaultNpAcl")
4392+ procRtlDosPathNameToNtPathName_U = modntdll.NewProc("RtlDosPathNameToNtPathName_U")
4393+ procRtlNtStatusToDosErrorNoTeb = modntdll.NewProc("RtlNtStatusToDosErrorNoTeb")
4394+ procWSAGetOverlappedResult = modws2_32.NewProc("WSAGetOverlappedResult")
4395+)
4396+
4397+func adjustTokenPrivileges(token windows.Token, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) {
4398+ var _p0 uint32
4399+ if releaseAll {
4400+ _p0 = 1
4401+ }
4402+ r0, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(input)), uintptr(outputSize), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(requiredSize)))
4403+ success = r0 != 0
4404+ if true {
4405+ err = errnoErr(e1)
4406+ }
4407+ return
4408+}
4409+
4410+func convertSecurityDescriptorToStringSecurityDescriptor(sd *byte, revision uint32, secInfo uint32, sddl **uint16, sddlSize *uint32) (err error) {
4411+ r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(secInfo), uintptr(unsafe.Pointer(sddl)), uintptr(unsafe.Pointer(sddlSize)), 0)
4412+ if r1 == 0 {
4413+ err = errnoErr(e1)
4414+ }
4415+ return
4416+}
4417+
4418+func convertSidToStringSid(sid *byte, str **uint16) (err error) {
4419+ r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(str)), 0)
4420+ if r1 == 0 {
4421+ err = errnoErr(e1)
4422+ }
4423+ return
4424+}
4425+
4426+func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd *uintptr, size *uint32) (err error) {
4427+ var _p0 *uint16
4428+ _p0, err = syscall.UTF16PtrFromString(str)
4429+ if err != nil {
4430+ return
4431+ }
4432+ return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
4433+}
4434+
4435+func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd *uintptr, size *uint32) (err error) {
4436+ r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
4437+ if r1 == 0 {
4438+ err = errnoErr(e1)
4439+ }
4440+ return
4441+}
4442+
4443+func convertStringSidToSid(str *uint16, sid **byte) (err error) {
4444+ r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(sid)), 0)
4445+ if r1 == 0 {
4446+ err = errnoErr(e1)
4447+ }
4448+ return
4449+}
4450+
4451+func getSecurityDescriptorLength(sd uintptr) (len uint32) {
4452+ r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(sd), 0, 0)
4453+ len = uint32(r0)
4454+ return
4455+}
4456+
4457+func impersonateSelf(level uint32) (err error) {
4458+ r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(level), 0, 0)
4459+ if r1 == 0 {
4460+ err = errnoErr(e1)
4461+ }
4462+ return
4463+}
4464+
4465+func lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
4466+ var _p0 *uint16
4467+ _p0, err = syscall.UTF16PtrFromString(accountName)
4468+ if err != nil {
4469+ return
4470+ }
4471+ return _lookupAccountName(systemName, _p0, sid, sidSize, refDomain, refDomainSize, sidNameUse)
4472+}
4473+
4474+func _lookupAccountName(systemName *uint16, accountName *uint16, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
4475+ r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidSize)), uintptr(unsafe.Pointer(refDomain)), uintptr(unsafe.Pointer(refDomainSize)), uintptr(unsafe.Pointer(sidNameUse)), 0, 0)
4476+ if r1 == 0 {
4477+ err = errnoErr(e1)
4478+ }
4479+ return
4480+}
4481+
4482+func lookupAccountSid(systemName *uint16, sid *byte, name *uint16, nameSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
4483+ r1, _, e1 := syscall.Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameSize)), uintptr(unsafe.Pointer(refDomain)), uintptr(unsafe.Pointer(refDomainSize)), uintptr(unsafe.Pointer(sidNameUse)), 0, 0)
4484+ if r1 == 0 {
4485+ err = errnoErr(e1)
4486+ }
4487+ return
4488+}
4489+
4490+func lookupPrivilegeDisplayName(systemName string, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) {
4491+ var _p0 *uint16
4492+ _p0, err = syscall.UTF16PtrFromString(systemName)
4493+ if err != nil {
4494+ return
4495+ }
4496+ return _lookupPrivilegeDisplayName(_p0, name, buffer, size, languageId)
4497+}
4498+
4499+func _lookupPrivilegeDisplayName(systemName *uint16, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) {
4500+ r1, _, e1 := syscall.Syscall6(procLookupPrivilegeDisplayNameW.Addr(), 5, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(languageId)), 0)
4501+ if r1 == 0 {
4502+ err = errnoErr(e1)
4503+ }
4504+ return
4505+}
4506+
4507+func lookupPrivilegeName(systemName string, luid *uint64, buffer *uint16, size *uint32) (err error) {
4508+ var _p0 *uint16
4509+ _p0, err = syscall.UTF16PtrFromString(systemName)
4510+ if err != nil {
4511+ return
4512+ }
4513+ return _lookupPrivilegeName(_p0, luid, buffer, size)
4514+}
4515+
4516+func _lookupPrivilegeName(systemName *uint16, luid *uint64, buffer *uint16, size *uint32) (err error) {
4517+ r1, _, e1 := syscall.Syscall6(procLookupPrivilegeNameW.Addr(), 4, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(luid)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), 0, 0)
4518+ if r1 == 0 {
4519+ err = errnoErr(e1)
4520+ }
4521+ return
4522+}
4523+
4524+func lookupPrivilegeValue(systemName string, name string, luid *uint64) (err error) {
4525+ var _p0 *uint16
4526+ _p0, err = syscall.UTF16PtrFromString(systemName)
4527+ if err != nil {
4528+ return
4529+ }
4530+ var _p1 *uint16
4531+ _p1, err = syscall.UTF16PtrFromString(name)
4532+ if err != nil {
4533+ return
4534+ }
4535+ return _lookupPrivilegeValue(_p0, _p1, luid)
4536+}
4537+
4538+func _lookupPrivilegeValue(systemName *uint16, name *uint16, luid *uint64) (err error) {
4539+ r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
4540+ if r1 == 0 {
4541+ err = errnoErr(e1)
4542+ }
4543+ return
4544+}
4545+
4546+func openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool, token *windows.Token) (err error) {
4547+ var _p0 uint32
4548+ if openAsSelf {
4549+ _p0 = 1
4550+ }
4551+ r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(accessMask), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
4552+ if r1 == 0 {
4553+ err = errnoErr(e1)
4554+ }
4555+ return
4556+}
4557+
4558+func revertToSelf() (err error) {
4559+ r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
4560+ if r1 == 0 {
4561+ err = errnoErr(e1)
4562+ }
4563+ return
4564+}
4565+
4566+func backupRead(h syscall.Handle, b []byte, bytesRead *uint32, abort bool, processSecurity bool, context *uintptr) (err error) {
4567+ var _p0 *byte
4568+ if len(b) > 0 {
4569+ _p0 = &b[0]
4570+ }
4571+ var _p1 uint32
4572+ if abort {
4573+ _p1 = 1
4574+ }
4575+ var _p2 uint32
4576+ if processSecurity {
4577+ _p2 = 1
4578+ }
4579+ r1, _, e1 := syscall.Syscall9(procBackupRead.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesRead)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0)
4580+ if r1 == 0 {
4581+ err = errnoErr(e1)
4582+ }
4583+ return
4584+}
4585+
4586+func backupWrite(h syscall.Handle, b []byte, bytesWritten *uint32, abort bool, processSecurity bool, context *uintptr) (err error) {
4587+ var _p0 *byte
4588+ if len(b) > 0 {
4589+ _p0 = &b[0]
4590+ }
4591+ var _p1 uint32
4592+ if abort {
4593+ _p1 = 1
4594+ }
4595+ var _p2 uint32
4596+ if processSecurity {
4597+ _p2 = 1
4598+ }
4599+ r1, _, e1 := syscall.Syscall9(procBackupWrite.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesWritten)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0)
4600+ if r1 == 0 {
4601+ err = errnoErr(e1)
4602+ }
4603+ return
4604+}
4605+
4606+func cancelIoEx(file syscall.Handle, o *syscall.Overlapped) (err error) {
4607+ r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(file), uintptr(unsafe.Pointer(o)), 0)
4608+ if r1 == 0 {
4609+ err = errnoErr(e1)
4610+ }
4611+ return
4612+}
4613+
4614+func connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) {
4615+ r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(o)), 0)
4616+ if r1 == 0 {
4617+ err = errnoErr(e1)
4618+ }
4619+ return
4620+}
4621+
4622+func createIoCompletionPort(file syscall.Handle, port syscall.Handle, key uintptr, threadCount uint32) (newport syscall.Handle, err error) {
4623+ r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(file), uintptr(port), uintptr(key), uintptr(threadCount), 0, 0)
4624+ newport = syscall.Handle(r0)
4625+ if newport == 0 {
4626+ err = errnoErr(e1)
4627+ }
4628+ return
4629+}
4630+
4631+func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
4632+ var _p0 *uint16
4633+ _p0, err = syscall.UTF16PtrFromString(name)
4634+ if err != nil {
4635+ return
4636+ }
4637+ return _createNamedPipe(_p0, flags, pipeMode, maxInstances, outSize, inSize, defaultTimeout, sa)
4638+}
4639+
4640+func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
4641+ r0, _, e1 := syscall.Syscall9(procCreateNamedPipeW.Addr(), 8, uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)), 0)
4642+ handle = syscall.Handle(r0)
4643+ if handle == syscall.InvalidHandle {
4644+ err = errnoErr(e1)
4645+ }
4646+ return
4647+}
4648+
4649+func getCurrentThread() (h syscall.Handle) {
4650+ r0, _, _ := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
4651+ h = syscall.Handle(r0)
4652+ return
4653+}
4654+
4655+func getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
4656+ r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
4657+ if r1 == 0 {
4658+ err = errnoErr(e1)
4659+ }
4660+ return
4661+}
4662+
4663+func getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) {
4664+ r1, _, e1 := syscall.Syscall6(procGetNamedPipeInfo.Addr(), 5, uintptr(pipe), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(outSize)), uintptr(unsafe.Pointer(inSize)), uintptr(unsafe.Pointer(maxInstances)), 0)
4665+ if r1 == 0 {
4666+ err = errnoErr(e1)
4667+ }
4668+ return
4669+}
4670+
4671+func getQueuedCompletionStatus(port syscall.Handle, bytes *uint32, key *uintptr, o **ioOperation, timeout uint32) (err error) {
4672+ r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(port), uintptr(unsafe.Pointer(bytes)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(o)), uintptr(timeout), 0)
4673+ if r1 == 0 {
4674+ err = errnoErr(e1)
4675+ }
4676+ return
4677+}
4678+
4679+func localAlloc(uFlags uint32, length uint32) (ptr uintptr) {
4680+ r0, _, _ := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(uFlags), uintptr(length), 0)
4681+ ptr = uintptr(r0)
4682+ return
4683+}
4684+
4685+func localFree(mem uintptr) {
4686+ syscall.Syscall(procLocalFree.Addr(), 1, uintptr(mem), 0, 0)
4687+ return
4688+}
4689+
4690+func setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) {
4691+ r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(h), uintptr(flags), 0)
4692+ if r1 == 0 {
4693+ err = errnoErr(e1)
4694+ }
4695+ return
4696+}
4697+
4698+func ntCreateNamedPipeFile(pipe *syscall.Handle, access uint32, oa *objectAttributes, iosb *ioStatusBlock, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (status ntStatus) {
4699+ r0, _, _ := syscall.Syscall15(procNtCreateNamedPipeFile.Addr(), 14, uintptr(unsafe.Pointer(pipe)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(share), uintptr(disposition), uintptr(options), uintptr(typ), uintptr(readMode), uintptr(completionMode), uintptr(maxInstances), uintptr(inboundQuota), uintptr(outputQuota), uintptr(unsafe.Pointer(timeout)), 0)
4700+ status = ntStatus(r0)
4701+ return
4702+}
4703+
4704+func rtlDefaultNpAcl(dacl *uintptr) (status ntStatus) {
4705+ r0, _, _ := syscall.Syscall(procRtlDefaultNpAcl.Addr(), 1, uintptr(unsafe.Pointer(dacl)), 0, 0)
4706+ status = ntStatus(r0)
4707+ return
4708+}
4709+
4710+func rtlDosPathNameToNtPathName(name *uint16, ntName *unicodeString, filePart uintptr, reserved uintptr) (status ntStatus) {
4711+ r0, _, _ := syscall.Syscall6(procRtlDosPathNameToNtPathName_U.Addr(), 4, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(ntName)), uintptr(filePart), uintptr(reserved), 0, 0)
4712+ status = ntStatus(r0)
4713+ return
4714+}
4715+
4716+func rtlNtStatusToDosError(status ntStatus) (winerr error) {
4717+ r0, _, _ := syscall.Syscall(procRtlNtStatusToDosErrorNoTeb.Addr(), 1, uintptr(status), 0, 0)
4718+ if r0 != 0 {
4719+ winerr = syscall.Errno(r0)
4720+ }
4721+ return
4722+}
4723+
4724+func wsaGetOverlappedResult(h syscall.Handle, o *syscall.Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) {
4725+ var _p0 uint32
4726+ if wait {
4727+ _p0 = 1
4728+ }
4729+ r1, _, e1 := syscall.Syscall6(procWSAGetOverlappedResult.Addr(), 5, uintptr(h), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(bytes)), uintptr(_p0), uintptr(unsafe.Pointer(flags)), 0)
4730+ if r1 == 0 {
4731+ err = errnoErr(e1)
4732+ }
4733+ return
4734+}
4735diff --git a/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_intermediate_cert.der b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_intermediate_cert.der
4736new file mode 100644
4737index 0000000..958f3cf
4738Binary files /dev/null and b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_intermediate_cert.der differ
4739diff --git a/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_leaf_cert.der b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_leaf_cert.der
4740new file mode 100644
4741index 0000000..d281764
4742Binary files /dev/null and b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_leaf_cert.der differ
4743diff --git a/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_root_cert.der b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_root_cert.der
4744new file mode 100644
4745index 0000000..d8c3710
4746Binary files /dev/null and b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/client_root_cert.der differ
4747diff --git a/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_intermediate_cert.der b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_intermediate_cert.der
4748new file mode 100644
4749index 0000000..dae619c
4750Binary files /dev/null and b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_intermediate_cert.der differ
4751diff --git a/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_leaf_cert.der b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_leaf_cert.der
4752new file mode 100644
4753index 0000000..ce7f8d3
4754Binary files /dev/null and b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_leaf_cert.der differ
4755diff --git a/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_root_cert.der b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_root_cert.der
4756new file mode 100644
4757index 0000000..04b0d73
4758Binary files /dev/null and b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/certverifier/testdata/server_root_cert.der differ
4759diff --git a/debian/extra/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_cert.der b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_cert.der
4760new file mode 100644
4761index 0000000..d8c3710
4762Binary files /dev/null and b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/client_cert.der differ
4763diff --git a/debian/extra/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_cert.der b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_cert.der
4764new file mode 100644
4765index 0000000..04b0d73
4766Binary files /dev/null and b/debian/extra/vendor/github.com/google/s2a-go/internal/v2/remotesigner/testdata/server_cert.der differ
4767diff --git a/debian/extra/vendor/golang.org/x/crypto/blowfish/block.go b/debian/extra/vendor/golang.org/x/crypto/blowfish/block.go
4768new file mode 100644
4769index 0000000..9d80f19
4770--- /dev/null
4771+++ b/debian/extra/vendor/golang.org/x/crypto/blowfish/block.go
4772@@ -0,0 +1,159 @@
4773+// Copyright 2010 The Go Authors. All rights reserved.
4774+// Use of this source code is governed by a BSD-style
4775+// license that can be found in the LICENSE file.
4776+
4777+package blowfish
4778+
4779+// getNextWord returns the next big-endian uint32 value from the byte slice
4780+// at the given position in a circular manner, updating the position.
4781+func getNextWord(b []byte, pos *int) uint32 {
4782+ var w uint32
4783+ j := *pos
4784+ for i := 0; i < 4; i++ {
4785+ w = w<<8 | uint32(b[j])
4786+ j++
4787+ if j >= len(b) {
4788+ j = 0
4789+ }
4790+ }
4791+ *pos = j
4792+ return w
4793+}
4794+
4795+// ExpandKey performs a key expansion on the given *Cipher. Specifically, it
4796+// performs the Blowfish algorithm's key schedule which sets up the *Cipher's
4797+// pi and substitution tables for calls to Encrypt. This is used, primarily,
4798+// by the bcrypt package to reuse the Blowfish key schedule during its
4799+// set up. It's unlikely that you need to use this directly.
4800+func ExpandKey(key []byte, c *Cipher) {
4801+ j := 0
4802+ for i := 0; i < 18; i++ {
4803+ // Using inlined getNextWord for performance.
4804+ var d uint32
4805+ for k := 0; k < 4; k++ {
4806+ d = d<<8 | uint32(key[j])
4807+ j++
4808+ if j >= len(key) {
4809+ j = 0
4810+ }
4811+ }
4812+ c.p[i] ^= d
4813+ }
4814+
4815+ var l, r uint32
4816+ for i := 0; i < 18; i += 2 {
4817+ l, r = encryptBlock(l, r, c)
4818+ c.p[i], c.p[i+1] = l, r
4819+ }
4820+
4821+ for i := 0; i < 256; i += 2 {
4822+ l, r = encryptBlock(l, r, c)
4823+ c.s0[i], c.s0[i+1] = l, r
4824+ }
4825+ for i := 0; i < 256; i += 2 {
4826+ l, r = encryptBlock(l, r, c)
4827+ c.s1[i], c.s1[i+1] = l, r
4828+ }
4829+ for i := 0; i < 256; i += 2 {
4830+ l, r = encryptBlock(l, r, c)
4831+ c.s2[i], c.s2[i+1] = l, r
4832+ }
4833+ for i := 0; i < 256; i += 2 {
4834+ l, r = encryptBlock(l, r, c)
4835+ c.s3[i], c.s3[i+1] = l, r
4836+ }
4837+}
4838+
4839+// This is similar to ExpandKey, but folds the salt during the key
4840+// schedule. While ExpandKey is essentially expandKeyWithSalt with an all-zero
4841+// salt passed in, reusing ExpandKey turns out to be a place of inefficiency
4842+// and specializing it here is useful.
4843+func expandKeyWithSalt(key []byte, salt []byte, c *Cipher) {
4844+ j := 0
4845+ for i := 0; i < 18; i++ {
4846+ c.p[i] ^= getNextWord(key, &j)
4847+ }
4848+
4849+ j = 0
4850+ var l, r uint32
4851+ for i := 0; i < 18; i += 2 {
4852+ l ^= getNextWord(salt, &j)
4853+ r ^= getNextWord(salt, &j)
4854+ l, r = encryptBlock(l, r, c)
4855+ c.p[i], c.p[i+1] = l, r
4856+ }
4857+
4858+ for i := 0; i < 256; i += 2 {
4859+ l ^= getNextWord(salt, &j)
4860+ r ^= getNextWord(salt, &j)
4861+ l, r = encryptBlock(l, r, c)
4862+ c.s0[i], c.s0[i+1] = l, r
4863+ }
4864+
4865+ for i := 0; i < 256; i += 2 {
4866+ l ^= getNextWord(salt, &j)
4867+ r ^= getNextWord(salt, &j)
4868+ l, r = encryptBlock(l, r, c)
4869+ c.s1[i], c.s1[i+1] = l, r
4870+ }
4871+
4872+ for i := 0; i < 256; i += 2 {
4873+ l ^= getNextWord(salt, &j)
4874+ r ^= getNextWord(salt, &j)
4875+ l, r = encryptBlock(l, r, c)
4876+ c.s2[i], c.s2[i+1] = l, r
4877+ }
4878+
4879+ for i := 0; i < 256; i += 2 {
4880+ l ^= getNextWord(salt, &j)
4881+ r ^= getNextWord(salt, &j)
4882+ l, r = encryptBlock(l, r, c)
4883+ c.s3[i], c.s3[i+1] = l, r
4884+ }
4885+}
4886+
4887+func encryptBlock(l, r uint32, c *Cipher) (uint32, uint32) {
4888+ xl, xr := l, r
4889+ xl ^= c.p[0]
4890+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[1]
4891+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[2]
4892+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[3]
4893+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[4]
4894+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[5]
4895+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[6]
4896+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[7]
4897+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[8]
4898+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[9]
4899+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[10]
4900+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[11]
4901+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[12]
4902+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[13]
4903+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[14]
4904+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[15]
4905+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[16]
4906+ xr ^= c.p[17]
4907+ return xr, xl
4908+}
4909+
4910+func decryptBlock(l, r uint32, c *Cipher) (uint32, uint32) {
4911+ xl, xr := l, r
4912+ xl ^= c.p[17]
4913+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[16]
4914+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[15]
4915+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[14]
4916+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[13]
4917+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[12]
4918+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[11]
4919+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[10]
4920+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[9]
4921+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[8]
4922+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[7]
4923+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[6]
4924+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[5]
4925+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[4]
4926+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[3]
4927+ xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[2]
4928+ xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[1]
4929+ xr ^= c.p[0]
4930+ return xr, xl
4931+}
4932diff --git a/debian/extra/vendor/golang.org/x/crypto/blowfish/cipher.go b/debian/extra/vendor/golang.org/x/crypto/blowfish/cipher.go
4933new file mode 100644
4934index 0000000..213bf20
4935--- /dev/null
4936+++ b/debian/extra/vendor/golang.org/x/crypto/blowfish/cipher.go
4937@@ -0,0 +1,99 @@
4938+// Copyright 2010 The Go Authors. All rights reserved.
4939+// Use of this source code is governed by a BSD-style
4940+// license that can be found in the LICENSE file.
4941+
4942+// Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
4943+//
4944+// Blowfish is a legacy cipher and its short block size makes it vulnerable to
4945+// birthday bound attacks (see https://sweet32.info). It should only be used
4946+// where compatibility with legacy systems, not security, is the goal.
4947+//
4948+// Deprecated: any new system should use AES (from crypto/aes, if necessary in
4949+// an AEAD mode like crypto/cipher.NewGCM) or XChaCha20-Poly1305 (from
4950+// golang.org/x/crypto/chacha20poly1305).
4951+package blowfish // import "golang.org/x/crypto/blowfish"
4952+
4953+// The code is a port of Bruce Schneier's C implementation.
4954+// See https://www.schneier.com/blowfish.html.
4955+
4956+import "strconv"
4957+
4958+// The Blowfish block size in bytes.
4959+const BlockSize = 8
4960+
4961+// A Cipher is an instance of Blowfish encryption using a particular key.
4962+type Cipher struct {
4963+ p [18]uint32
4964+ s0, s1, s2, s3 [256]uint32
4965+}
4966+
4967+type KeySizeError int
4968+
4969+func (k KeySizeError) Error() string {
4970+ return "crypto/blowfish: invalid key size " + strconv.Itoa(int(k))
4971+}
4972+
4973+// NewCipher creates and returns a Cipher.
4974+// The key argument should be the Blowfish key, from 1 to 56 bytes.
4975+func NewCipher(key []byte) (*Cipher, error) {
4976+ var result Cipher
4977+ if k := len(key); k < 1 || k > 56 {
4978+ return nil, KeySizeError(k)
4979+ }
4980+ initCipher(&result)
4981+ ExpandKey(key, &result)
4982+ return &result, nil
4983+}
4984+
4985+// NewSaltedCipher creates a returns a Cipher that folds a salt into its key
4986+// schedule. For most purposes, NewCipher, instead of NewSaltedCipher, is
4987+// sufficient and desirable. For bcrypt compatibility, the key can be over 56
4988+// bytes.
4989+func NewSaltedCipher(key, salt []byte) (*Cipher, error) {
4990+ if len(salt) == 0 {
4991+ return NewCipher(key)
4992+ }
4993+ var result Cipher
4994+ if k := len(key); k < 1 {
4995+ return nil, KeySizeError(k)
4996+ }
4997+ initCipher(&result)
4998+ expandKeyWithSalt(key, salt, &result)
4999+ return &result, nil
5000+}
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches