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

Safer use of filepath.EvalSymlinks() on Windows #25151

Merged

Conversation

l0rd
Copy link
Member

@l0rd l0rd commented Jan 29, 2025

The behavior of function path/filepath.EvalSymlinks() has changed in Go v1.23:

As a consequence, starting with Podman 5.3.0, when installing on Windows (WSL) using Scoop, Podman fails to start because it fails to find helper binaries. Scoop copies Podman binaries in a folder of type Junction and EvalSymlinks returns an error. The problem is described in #24557.

To address this problem, we check if a path is a Symlink before calling EvalSymlinks, and if it's not (hard links, mount points, or canonical files), we call path/filepath.Clean for consistency. In fact, path/filepath.EvalSymlinks, after evaluating a path, calls Clean, too.

Fixes #24557

Does this PR introduce a user-facing change?

Fix a bug that prevented Podman from starting when installed using Scoop on Windows.

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 29, 2025
pkg/machine/machine_windows_test.go Show resolved Hide resolved
pkg/machine/machine_windows_test.go Outdated Show resolved Hide resolved
pkg/machine/machine_windows_test.go Outdated Show resolved Hide resolved
pkg/machine/machine_windows_test.go Outdated Show resolved Hide resolved
pkg/machine/machine_windows_test.go Outdated Show resolved Hide resolved
@Luap99
Copy link
Member

Luap99 commented Jan 29, 2025

Also I don't think we run any windows/macos unit tests at all in CI. unit tests are only run on linux AFAICT so if we have platform specific test we need to fix that otherwise we are not covered.

@l0rd l0rd force-pushed the fix-evalsymlink-windows-option3 branch from 6eb49ee to f52d69d Compare January 29, 2025 12:09
The behavior of function `path/filepath.EvalSymlinks()` has
changed in Go v1.23:

- https://go-review.googlesource.com/c/go/+/565136
- https://go.dev/doc/go1.23#minor_library_changes
- https://tip.golang.org/doc/godebug

As a consequences, starting with Podman 5.3.0, when installing
on Windows (WSL) using scoop, Podman fails to start because it
fails to find helper binaries. Scoop copies Podman binaries in
a folder of type Junction and `EvalSymlinks` returns an error.
The problem is described in containers#24557.

To address this problem we are checking if a path is a `Symlink`
before calling `EvalSymlinks` and, if it's not (hardlinks, mount
points or canonical files), we are calling `path/filepath.Clean`
for consistency. In fact `path/filepath.EvalSymlinks`, after
evaluating a symlink target, calls `Clean` too.

Signed-off-by: Mario Loriedo <[email protected]>
@l0rd l0rd force-pushed the fix-evalsymlink-windows-option3 branch from f52d69d to 513b4aa Compare January 29, 2025 12:15
@l0rd
Copy link
Member Author

l0rd commented Jan 29, 2025

Also I don't think we run any windows/macos unit tests at all in CI. unit tests are only run on linux AFAICT so if we have platform specific test we need to fix that otherwise we are not covered.

I think you are right. If you don't mind, I would not fix it in this PR, though Also, Windows builds are run on Linux too (CI doesn't use winmake.ps1), and I would be interested in improving so that instead of cross-compilation, we use the PowerShell script to run the build on Windows + a new target to run unit tests.

@l0rd l0rd added the v5.4 label Jan 29, 2025
@Luap99
Copy link
Member

Luap99 commented Jan 29, 2025

If you don't mind, I would not fix it in this PR, though

Yes that is fine, I wasn't trying to stay that you should fix that right now just that we have a testing gap for platform specific unit tests.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

openshift-ci bot commented Jan 29, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: l0rd, Luap99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mheon
Copy link
Member

mheon commented Jan 29, 2025

LGTM

@mheon
Copy link
Member

mheon commented Jan 29, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 29, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit c285c72 into containers:main Jan 29, 2025
86 checks passed
@l0rd
Copy link
Member Author

l0rd commented Jan 29, 2025

/cherry-pick v5.4

@openshift-cherrypick-robot
Copy link
Collaborator

@l0rd: new pull request created: #25156

In response to this:

/cherry-pick v5.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. machine release-note v5.4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Podman 5.3.0 win-sshproxy.tid: The system cannot find the file specified. (install via scoop)
4 participants