-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
cmd/go: go fmt aborts with operation not permitted when using mounted vmware shared folders (hgfs) #60225
Comments
cc @griesemer @mvdan |
The It would be slightly more efficient and slightly more secure to create the backup file with the correct permissions in the first place, but the code just calls |
Change https://go.dev/cl/495316 mentions this issue: |
Change https://go.dev/cl/496155 mentions this issue: |
The asynchronous call to processFile is synchronized by the call to GetExitCode. We can't safely access errBuf until then, because processFile may still be writing to it. This is diagnosed by 'go test -race cmd/gofmt', but only the darwin-amd64-race builder caught it because the other "-race" builders apparently all run as root (see #10719). Updates #60225. Change-Id: Ie66bb4e47429ece81043d6425f26953b7bb26002 Reviewed-on: https://go-review.googlesource.com/c/go/+/496155 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, version 1.20.4 is the latest release as of this writing
What operating system and processor architecture are you using (
go env
)?Rocky Linux 8.7 (amd64) in a VM, running on top of VMware Workstation 17 Pro, on Windows 10
go env:
What did you do?
Comments
The go fmt command above appears to create a temporary file in the current dir, and then apparently runs chmod on
that file. It would seem the chmod should not be needed to gain access to the file by go fmt, so I presume the
purpose of the chmod was actually to impose access restriction to the temp file by other users/processes during the
formatting operation.
In my case the file system of the working dir is a mounted vmware shared folder. This is a windows directory that
is shared with the linux VM by means of vmware tools. From the perspective of linux, the file permissions on such a
mount will always be 777 and owned by root, as demonstrated by the ineffective chown and chmod commands above. When
the go fmt command tries and fails to do a chmod on the temp file, it completely aborts the code formatting
operation.
Handling for this should be improved so that code formatting can still work when using various (less capable)
mounted file system types. It may make sense to check the permissions of the temp file, and only call chmod if the
permissions on the temp file are actually less restrictive than the permissions on source file for example. Another
option might be to attempt the chmod but not completely abort on failure, although the potential security
implications of that option should be considered.
The text was updated successfully, but these errors were encountered: