Repository navigation
ls: only show "+" for a real ACL, and show it before "." - #15857
18Abhinav07 wants to merge 3 commits into
Conversation
`ls -l` marked a file with "." when it had a security context and "+" only when has_acl() was true. has_acl() treated any extended attribute as an ACL, so a security.selinux or security.SMACK64 label alone made it return true; and the label check ran first, so a file with both a label and an ACL showed ".". On Linux and Android has_acl() now counts only system.posix_acl_access, system.posix_acl_default and a non-trivial system.nfs4_acl (one naming a principal other than OWNER@, GROUP@ or EVERYONE@). ls checks the ACL first, then the label. Fixes uutils#15809
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
| /// The choice behind [`alt_access_indicator`]: an ACL wins over a security | ||
| /// context, because the label is itself an extended attribute and says nothing | ||
| /// about the ACL. | ||
| fn alt_access_indicator_for(has_acl: bool, has_context: bool) -> u8 { |
There was a problem hiding this comment.
do we need a second function just for the unit test? test_ls already covers the precedence
| /// through the raw attribute so that only `setfattr` is needed. Returns false when | ||
| /// that is not possible here (no `setfattr`, or a file system without ACLs). | ||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| fn set_posix_acl(path: &str) -> bool { |
There was a problem hiding this comment.
why a raw hex blob? the other tests just use setfacl, please do the same
| let at = &scene.fixtures; | ||
| at.touch("with_xattr"); | ||
|
|
||
| match Command::new("setfattr") |
There was a problem hiding this comment.
this setfattr match block could be a small helper, it is the same pattern repeated in the file
Inline the precedence in alt_access_indicator and drop the extra function and its unit test, set ACLs with setfacl like the other tests, and share the command handling in one helper.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Thanks for the review, all three are addressed (449eccf, plus 00d3e23 for a clippy error in the SELinux test that the first push introduced):
Checked locally on Linux with |
Merging this PR will degrade performance by 5.48%2 warnings, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Fixes #15809
Problem
ls -lshows+for an ACL and.for a security context. Two things went wrong:uucore::fsxattr::has_aclreturned true for any extended attribute on Linux, so a file with only a SELinux or SMACK label (security.*) was treated as having an ACL.lschecked the label before the ACL, so a file with both showed.and the ACL was hidden.Change
has_aclon Linux and Android counts onlysystem.posix_acl_access,system.posix_acl_default, or a non-trivialsystem.nfs4_acl. A non-trivial NFSv4 ACL names a principal other thanOWNER@,GROUP@orEVERYONE@. An unreadable or absent value is not counted; unparseable content is. macOS still uses the ACL API; other platforms are unchanged.lspicks+for an ACL, else.for a security context, else a space.Behaviour change
A file whose only extended attributes are
user.*orsecurity.capabilityis no longer marked+.Tests
uucoreunit tests forhas_acland the NFSv4 parser;lsunit test for the ACL-over-context precedence.test_ls: raw POSIX ACL shown as+, other xattrs not shown as+, and an ACL plus a context case intest_ls_selinux_context_indicator.-D warnings(includingfeat_selinux),fsxattr8/8,uu_lsunit 19/19,test_ls201 passed, 1 ignored. In a Fedora container with real libselinux and a fakedis_selinux_enabled, thetest_acl*tests pass and the binary prints.,+,+for label, ACL, and both.Not verified
Overlap
#15210 also changes
has_acl. Whichever lands second will need a rebase.