Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os: opening an existing file with O_CREATE|O_TRUNC and permission 0 changes file to be read-only on Windows [1.14 backport] #39158

Closed
gopherbot opened this issue May 20, 2020 · 2 comments

Comments

@gopherbot
Copy link

@gopherbot gopherbot commented May 20, 2020

@ianlancetaylor requested issue #38225 to be considered for backport to the next 1.14 minor release.

@gopherbot Please open a backport to 1.14. This is a regression that was introduced in 1.14.

@gopherbot
Copy link
Author

@gopherbot gopherbot commented May 20, 2020

Change https://golang.org/cl/234686 mentions this issue: [release-branch.go1.14] syscall: preserve Windows file permissions for O_CREAT|O_TRUNC

@gopherbot
Copy link
Author

@gopherbot gopherbot commented May 23, 2020

Closed by merging f758dab to release-branch.go1.14.

@gopherbot gopherbot closed this May 23, 2020
gopherbot pushed a commit that referenced this issue May 23, 2020
…r 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 567556d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/234686
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.