-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
cp: improve the selinux support #7878
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
base: main
Are you sure you want to change the base?
Conversation
GNU testsuite comparison:
|
The code currently fails due to the changes in #7845:
|
GNU testsuite comparison:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves SELinux support across the codebase by updating error messages, refactoring the SELinux error enum, and adding new command-line options for SELinux context handling. Key changes include:
- Updating expected error message substrings in SELinux-related tests.
- Refactoring the SELinux error enum (now SeLinuxError) with improved error variants and messages.
- Adding new SELinux-related command-line options in the cp utility and updating Cargo.toml dependency configurations.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/by-util/test_mknod.rs | Adjust expected error string casing for SELinux errors |
tests/by-util/test_mkfifo.rs | Adjust expected error string casing for SELinux errors |
tests/by-util/test_mkdir.rs | Update expected SELinux error message to reflect new error variant |
src/uucore/src/lib/features/selinux.rs | Refactor SELinux error enum and error mapping using thiserror |
src/uu/mkdir/src/mkdir.rs | Update error reporting when setting SELinux context in directory creation |
src/uu/cp/src/cp.rs | Add SELinux context flags and update feature flag usage for SELinux |
src/uu/cp/Cargo.toml | Update SELinux dependency configuration to include thiserror |
Comments suppressed due to low confidence (4)
tests/by-util/test_mknod.rs:189
- Ensure that the expected error message substring matches the actual output case consistently across tests. If the change to lowercase is intentional, verify that all related tests follow this convention.
.stderr_contains("Failed to");
tests/by-util/test_mkfifo.rs:162
- Ensure the expected error message substring now reflects the updated casing ('failed to') consistently with the changes in other SELinux tests.
.stderr_contains("Failed to");
tests/by-util/test_mkdir.rs:413
- The expected error message has been updated to 'Failed to set default file creation context to 'testtest':'; ensure that the test expectation is aligned with the new error message generated by the updated SELinux handling.
.stderr_contains("failed to set SELinux security context:");
src/uucore/src/lib/features/selinux.rs:26
- [nitpick] The error variant names 'ContextSetFailure' and 'ContextConversionFailure' are very similar and could be confusing; consider renaming one for clearer differentiation between failures during context conversion versus setting.
ContextConversionFailure(String, String),
Can you please rebase? The PR currently contains commits from a different PR. |
… code. + Add test for the selinux changes with context SLASHLogin Improves the coverage of tests/cp/cp-a-selinux.sh
GNU testsuite comparison:
|
tests/by-util/test_cp.rs
Outdated
"Expected '{}' not found in getfattr output:\n{}", | ||
"foo", | ||
selinux_perm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Expected '{}' not found in getfattr output:\n{}", | |
"foo", | |
selinux_perm | |
"Expected 'foo' not found in getfattr output:\n{selinux_perm}" |
tests/by-util/test_cp.rs
Outdated
"Expected '{}' not found in getfattr output:\n{}", | ||
"foo", | ||
selinux_perm_dest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Expected '{}' not found in getfattr output:\n{}", | |
"foo", | |
selinux_perm_dest | |
"Expected 'foo' not found in getfattr output:\n{selinux_perm_dest}" |
tests/by-util/test_cp.rs
Outdated
// Get the default SELinux context for the destination file path | ||
// on Debian/Ubuntu, this program is provided by the selinux-utils package | ||
// on Fedora/RHEL, this program is provided by the libselinux-devel package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Get the default SELinux context for the destination file path | |
// on Debian/Ubuntu, this program is provided by the selinux-utils package | |
// on Fedora/RHEL, this program is provided by the libselinux-devel package | |
// Get the default SELinux context for the destination file path. | |
// On Debian/Ubuntu, this program is provided by the selinux-utils package. | |
// On Fedora/RHEL, this program is provided by the libselinux-devel package. |
tests/by-util/test_cp.rs
Outdated
// Create two different files | ||
at.write(TEST_HELLO_WORLD_SOURCE, "source content"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either the comment is incorrect or the code. There is only one call of at.write()
.
tests/by-util/test_cp.rs
Outdated
} | ||
|
||
// Copy the file with preserved context | ||
// Only works at root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Only works at root | |
// Only works as root |
pub(crate) fn copy_attributes( | ||
source: &Path, | ||
dest: &Path, | ||
attributes: &Attributes, | ||
options: &Options, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for adding this unused parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
carryover from the previous work, I might be able to remove it
+ fix comments from review
GNU testsuite comparison:
|
No description provided.