aboutsummaryrefslogtreecommitdiff
path: root/src/os/root_windows.go
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2025-03-28 16:14:43 -0700
committerGopher Robot <gobot@golang.org>2025-03-31 15:36:10 -0700
commit6d418096b2dfe2a2e47b7aa83b46748fb301e6cb (patch)
treed7740233a1d75c56e4aef697da8241396946dc43 /src/os/root_windows.go
parentc6a1dc47297a47e6111e3a00911393c355800023 (diff)
downloadgo-6d418096b2dfe2a2e47b7aa83b46748fb301e6cb.tar.xz
os: avoid symlink races in RemoveAll on Windows
Make the openat-using version of RemoveAll use the appropriate Windows equivalent, via new portable (but internal) functions added for os.Root. We could reimplement everything in terms of os.Root, but this is a bit simpler and keeps the existing code structure. Fixes #52745 Change-Id: I0eba0286398b351f2ee9abaa60e1675173988787 Reviewed-on: https://go-review.googlesource.com/c/go/+/661575 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/os/root_windows.go')
-rw-r--r--src/os/root_windows.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/os/root_windows.go b/src/os/root_windows.go
index eb82715046..2eeb53e362 100644
--- a/src/os/root_windows.go
+++ b/src/os/root_windows.go
@@ -336,7 +336,15 @@ func mkdirat(dirfd syscall.Handle, name string, perm FileMode) error {
}
func removeat(dirfd syscall.Handle, name string) error {
- return windows.Deleteat(dirfd, name)
+ return windows.Deleteat(dirfd, name, 0)
+}
+
+func removefileat(dirfd syscall.Handle, name string) error {
+ return windows.Deleteat(dirfd, name, windows.FILE_NON_DIRECTORY_FILE)
+}
+
+func removedirat(dirfd syscall.Handle, name string) error {
+ return windows.Deleteat(dirfd, name, windows.FILE_DIRECTORY_FILE)
}
func chtimesat(dirfd syscall.Handle, name string, atime time.Time, mtime time.Time) error {