Fix: resolve relative executable paths against workingDirectory in vmexec #473
+20
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the root cause for apple/container#962.
This PR fixes an issue where relative paths provided as an entrypoint or command (e.g.,
./uname) failed to execute. The root cause was that executable paths were being validated before the working directory was changed (chdir) in the guest VM executor, leading to a "failed to find target executable" error.Motivation and Context
In the current
vmexecimplementation, the file existence check occurs before applying the OCIworkingDirectory. Following the "cleaner approach" suggested by maintainers in apple/container#987, this change ensures that the executor itself handles relative path resolution internally.Key Changes:
/or starting with.workingDirectorybefore performing the binary existence check.URL.standardized.pathto ensure a clean absolute path is passed to the execution system.ls,uname) via the systemPATHby checking for the absence of slashes.This aligns the executor's behavior with industry standards seen in Docker and Podman.
Testing & Verification
Integration Tests
container run --workdir /bin --entrypoint ./uname alpine./bin/unameinside the VM and returnedLinux./bin/ls) and bare commands (ls) continue to function correctly via systemPATH.Cross-Repository Coordination
containerCLI.testProcessEntrypointRelativePathPassthroughin theapple/containerrepository (ParserTest.swift).vmexeccorrectly handles the resolution internally, keeping the OCI bundle configuration clean and logic centralized in the executor.