-
Notifications
You must be signed in to change notification settings - Fork 13.4k
bootstrap: Fix file permissions when dereferencing symlinks #142026
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Makes sense, thanks! @bors r+ rollup |
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jun 5, 2025
bootstrap: Fix file permissions when dereferencing symlinks ## Problem When copying files in the bootstrap process with `dereference_symlinks = true`, we're incorrectly using the symlink's metadata to set permissions on the copied regular file, which results in the following error: ``` Warning: Failed to set file times for "/build/nix-build-rustc-1.86.0.drv-0/rustc-1.86.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-strip" (permissions: Permissions(FilePermissions { mode: 0o100000 (----------) })) error: Permission denied (os error 13) ``` Verbose Logs confirming the error: ``` TRACE: Found llvm-strip copy operation Source: /n/nix/tech/store/n34yzv2n50p6lbjmx089vjym121wbl4j-llvm-19.1.7/bin/llvm-strip Destination: /build/nix-build-rustc-1.86.0.drv-0/rustc-1.86.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-strip Source is_symlink (via symlink_metadata): true Source symlink_metadata permissions: 120000 Source symlink_metadata file_type: FileType { is_file: false, is_dir: false, is_symlink: true, .. } Source is symlink pointing to: llvm-objcopy Source raw mode: 120000 Source filetype: 120000 Setting permissions: Permissions(FilePermissions { mode: 0o120000 (l---------) }) Permission mode to set: 120000 Raw permission bits: 120000 File type bits being set: 120000 Permission bits being set: 0 WARNING: Attempting to set symlink file type (120000) on regular file! WARNING: Setting zero permission bits will make file inaccessible! Destination permissions after set_permissions: 100000 ``` ## Solution After canonicalizing a symlink path, fetch the metadata of the target file instead of continuing to use the symlink's metadata. This ensures: - Correct file type detection - Proper permission bits for the target file - Maintains existing behavior for non-symlink cases ## Testing Verified fix resolves permission errors: ``` rustc> llvm-strip: Original metadata mode: 120000, is_symlink: true rustc> llvm-strip: Target metadata mode after fix: 100555 rustc> llvm-strip: Final permissions mode: 100555 ```
This was referenced Jun 5, 2025
bors
added a commit
that referenced
this pull request
Jun 5, 2025
Rollup of 7 pull requests Successful merges: - #141709 (jsondocck: Refactor directive handling) - #141974 (`tests/ui`: A New Order [4/N]) - #141989 (rustdoc-json-type: Depend on `serde` and `serde_derive` seperately) - #142015 (Report the actual item that evaluation failed for) - #142026 (bootstrap: Fix file permissions when dereferencing symlinks) - #142032 (Fix parsing of frontmatters with inner hyphens) - #142036 (Update the `compiler-builtins` subtree) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
Jun 5, 2025
Rollup merge of #142026 - smpdt:master, r=Kobzol bootstrap: Fix file permissions when dereferencing symlinks ## Problem When copying files in the bootstrap process with `dereference_symlinks = true`, we're incorrectly using the symlink's metadata to set permissions on the copied regular file, which results in the following error: ``` Warning: Failed to set file times for "/build/nix-build-rustc-1.86.0.drv-0/rustc-1.86.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-strip" (permissions: Permissions(FilePermissions { mode: 0o100000 (----------) })) error: Permission denied (os error 13) ``` Verbose Logs confirming the error: ``` TRACE: Found llvm-strip copy operation Source: /n/nix/tech/store/n34yzv2n50p6lbjmx089vjym121wbl4j-llvm-19.1.7/bin/llvm-strip Destination: /build/nix-build-rustc-1.86.0.drv-0/rustc-1.86.0-src/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-strip Source is_symlink (via symlink_metadata): true Source symlink_metadata permissions: 120000 Source symlink_metadata file_type: FileType { is_file: false, is_dir: false, is_symlink: true, .. } Source is symlink pointing to: llvm-objcopy Source raw mode: 120000 Source filetype: 120000 Setting permissions: Permissions(FilePermissions { mode: 0o120000 (l---------) }) Permission mode to set: 120000 Raw permission bits: 120000 File type bits being set: 120000 Permission bits being set: 0 WARNING: Attempting to set symlink file type (120000) on regular file! WARNING: Setting zero permission bits will make file inaccessible! Destination permissions after set_permissions: 100000 ``` ## Solution After canonicalizing a symlink path, fetch the metadata of the target file instead of continuing to use the symlink's metadata. This ensures: - Correct file type detection - Proper permission bits for the target file - Maintains existing behavior for non-symlink cases ## Testing Verified fix resolves permission errors: ``` rustc> llvm-strip: Original metadata mode: 120000, is_symlink: true rustc> llvm-strip: Target metadata mode after fix: 100555 rustc> llvm-strip: Final permissions mode: 100555 ```
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Jun 6, 2025
Rollup of 7 pull requests Successful merges: - rust-lang/rust#141709 (jsondocck: Refactor directive handling) - rust-lang/rust#141974 (`tests/ui`: A New Order [4/N]) - rust-lang/rust#141989 (rustdoc-json-type: Depend on `serde` and `serde_derive` seperately) - rust-lang/rust#142015 (Report the actual item that evaluation failed for) - rust-lang/rust#142026 (bootstrap: Fix file permissions when dereferencing symlinks) - rust-lang/rust#142032 (Fix parsing of frontmatters with inner hyphens) - rust-lang/rust#142036 (Update the `compiler-builtins` subtree) r? `@ghost` `@rustbot` modify labels: rollup
github-actions bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Jun 9, 2025
Rollup of 7 pull requests Successful merges: - rust-lang/rust#141709 (jsondocck: Refactor directive handling) - rust-lang/rust#141974 (`tests/ui`: A New Order [4/N]) - rust-lang/rust#141989 (rustdoc-json-type: Depend on `serde` and `serde_derive` seperately) - rust-lang/rust#142015 (Report the actual item that evaluation failed for) - rust-lang/rust#142026 (bootstrap: Fix file permissions when dereferencing symlinks) - rust-lang/rust#142032 (Fix parsing of frontmatters with inner hyphens) - rust-lang/rust#142036 (Update the `compiler-builtins` subtree) r? `@ghost` `@rustbot` modify labels: rollup
tgross35
pushed a commit
to tgross35/compiler-builtins
that referenced
this pull request
Jun 9, 2025
Rollup of 7 pull requests Successful merges: - rust-lang/rust#141709 (jsondocck: Refactor directive handling) - rust-lang/rust#141974 (`tests/ui`: A New Order [4/N]) - rust-lang/rust#141989 (rustdoc-json-type: Depend on `serde` and `serde_derive` seperately) - rust-lang/rust#142015 (Report the actual item that evaluation failed for) - rust-lang/rust#142026 (bootstrap: Fix file permissions when dereferencing symlinks) - rust-lang/rust#142032 (Fix parsing of frontmatters with inner hyphens) - rust-lang/rust#142036 (Update the `compiler-builtins` subtree) r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-bootstrap
Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
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.
Problem
When copying files in the bootstrap process with
dereference_symlinks = true
, we're incorrectly using the symlink's metadata to set permissions on the copied regular file, which results in the following error:Verbose Logs confirming the error:
Solution
After canonicalizing a symlink path, fetch the metadata of the target file instead of continuing to use the symlink's metadata. This ensures:
Testing
Verified fix resolves permission errors: