-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
path/filepath: EvalSymlinks fails to follow symlink when root entry is a symlink #39818
Comments
This comment has been minimized.
This comment has been minimized.
When a symlink is at filesystem root (such can be the case on OSTree systems where /root points to /var/roothome and /home points to /var/home) EvalSymlinks fails to follow it correctly. Instead of following it in the context of the root directory, it tries to follow it in the context of the current directory. This is because when the last traversed directory is removed to concatenate the symlink target, "/home" contract to the empty string, and "var/home" is thus evaluated in the context of the current directory. This commit fixes that by detecting if the last removed directory was a root directory, and does not remove the trailing path separator in that case. Fixes golang#39818
Unfortunately, I might not be able to provide a pull request with that patch as I don't have a google account at hand to sign the CLA (and I won't create one). Please feel free to do whatever you want with the patch I provide, I do not retain any copyright on it. |
It's fine to not sign the CLA, of course, but in that case please do not send the patch as a GitHub comment. That just complicates the copyright status of the change. Thanks. |
EvalSymlinks should almost never be used; see #40180. If Terraform isn't aware of this, could you inform them? |
In any case, I'm ok to sign the CLA using any other means than using a google account. I also provided a PR with the patch, but I did that before knowing I had to sign the CLA. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I found a bug in terraform: hashicorp/terraform#25367 and tracked it down to the go runtime
Reproducer:
Reproduce by compiling this example and running it:
(you need to be root for chroot to work, it works well in a fedora-toolbox container with a user namespace root)
What did you expect to see?
filepath.EvalSymlinks
should follow symlinkhome -> var/home
inorigin
What did you see instead?
filepath.EvalSymlinks
fails to follow the symlink and errors out withlstat var: no such file or directory
The text was updated successfully, but these errors were encountered: