]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.14] syscall: preserve Windows file permissions for O_CREAT|O_TRUNC
authorIan Lance Taylor <iant@golang.org>
Wed, 20 May 2020 03:23:58 +0000 (20:23 -0700)
committerIan Lance Taylor <iant@golang.org>
Sat, 23 May 2020 21:08:37 +0000 (21:08 +0000)
commitf758dabf52d38333985e24762f9b53a29e2e7da0
treee22ee99372c1c6022a36290e73b42ff3daf34daf
parentf296b7a6f045325a230f77e9bda1470b1270f817
[release-branch.go1.14] syscall: preserve Windows file permissions for O_CREAT|O_TRUNC

On Windows, calling syscall.Open(file, O_CREAT|O_TRUNC, 0) for a file
that already exists would change the file to be read-only.
That is not how the Unix syscall.Open behaves, so avoid it on
Windows by calling CreateFile twice if necessary.

For #38225
Fixes #39158

Change-Id: I70097fca8863df427cc8a97b9376a9ffc69c6318
Reviewed-on: https://go-review.googlesource.com/c/go/+/234534
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
(cherry picked from commit 567556d78657326c99b8fa84ec2a5ee511a0941b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/234686
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
src/os/os_test.go
src/syscall/syscall_windows.go