mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
ls: Don't call the capabilites features of the system when passed an empty ca=
in LS_COLORS In parallel, in the GNU test, adjust the GNU tests as we don't use libcap but xattr instead.
This commit is contained in:
parent
9a97c18877
commit
ffc6eb094a
3 changed files with 40 additions and 11 deletions
|
@ -10,6 +10,7 @@ bytewise
|
||||||
canonicalization
|
canonicalization
|
||||||
canonicalize
|
canonicalize
|
||||||
canonicalizing
|
canonicalizing
|
||||||
|
capget
|
||||||
codepoint
|
codepoint
|
||||||
codepoints
|
codepoints
|
||||||
codegen
|
codegen
|
||||||
|
@ -65,6 +66,7 @@ kibi
|
||||||
kibibytes
|
kibibytes
|
||||||
libacl
|
libacl
|
||||||
lcase
|
lcase
|
||||||
|
llistxattr
|
||||||
lossily
|
lossily
|
||||||
lstat
|
lstat
|
||||||
mebi
|
mebi
|
||||||
|
@ -108,6 +110,7 @@ seedable
|
||||||
semver
|
semver
|
||||||
semiprime
|
semiprime
|
||||||
semiprimes
|
semiprimes
|
||||||
|
setcap
|
||||||
setfacl
|
setfacl
|
||||||
shortcode
|
shortcode
|
||||||
shortcodes
|
shortcodes
|
||||||
|
|
|
@ -156,19 +156,23 @@ pub(crate) fn color_name(
|
||||||
target_symlink: Option<&PathData>,
|
target_symlink: Option<&PathData>,
|
||||||
wrap: bool,
|
wrap: bool,
|
||||||
) -> String {
|
) -> String {
|
||||||
#[cfg(any(not(unix), target_os = "android", target_os = "macos"))]
|
|
||||||
let has_capabilities = false;
|
|
||||||
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
|
|
||||||
// Check if the file has capabilities
|
// Check if the file has capabilities
|
||||||
let has_capabilities = uucore::fsxattr::has_acl(path.p_buf.as_path());
|
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
|
||||||
|
{
|
||||||
|
// Skip checking capabilities if LS_COLORS=ca=:
|
||||||
|
let capabilities = style_manager
|
||||||
|
.colors
|
||||||
|
.style_for_indicator(Indicator::Capabilities);
|
||||||
|
|
||||||
|
let has_capabilities = if capabilities.is_none() {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
uucore::fsxattr::has_acl(path.p_buf.as_path())
|
||||||
|
};
|
||||||
|
|
||||||
// If the file has capabilities, use a specific style for `ca` (capabilities)
|
// If the file has capabilities, use a specific style for `ca` (capabilities)
|
||||||
if has_capabilities {
|
if has_capabilities {
|
||||||
if let Some(style) = style_manager
|
return style_manager.apply_style(capabilities, name, wrap);
|
||||||
.colors
|
|
||||||
.style_for_indicator(Indicator::Capabilities)
|
|
||||||
{
|
|
||||||
return style_manager.apply_style(Some(style), name, wrap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
util/gnu-patches/tests_ls_no_cap.patch
Normal file
22
util/gnu-patches/tests_ls_no_cap.patch
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
diff --git a/tests/ls/no-cap.sh b/tests/ls/no-cap.sh
|
||||||
|
index 3d84c74ff..d1f60e70a 100755
|
||||||
|
--- a/tests/ls/no-cap.sh
|
||||||
|
+++ b/tests/ls/no-cap.sh
|
||||||
|
@@ -21,13 +21,13 @@ print_ver_ ls
|
||||||
|
require_strace_ capget
|
||||||
|
|
||||||
|
LS_COLORS=ca=1; export LS_COLORS
|
||||||
|
-strace -e capget ls --color=always > /dev/null 2> out || fail=1
|
||||||
|
-$EGREP 'capget\(' out || skip_ "your ls doesn't call capget"
|
||||||
|
+strace -e llistxattr ls --color=always > /dev/null 2> out || fail=1
|
||||||
|
+$EGREP 'llistxattr\(' out || skip_ "your ls doesn't call llistxattr"
|
||||||
|
|
||||||
|
rm -f out
|
||||||
|
|
||||||
|
LS_COLORS=ca=:; export LS_COLORS
|
||||||
|
-strace -e capget ls --color=always > /dev/null 2> out || fail=1
|
||||||
|
-$EGREP 'capget\(' out && fail=1
|
||||||
|
+strace -e llistxattr ls --color=always > /dev/null 2> out || fail=1
|
||||||
|
+$EGREP 'llistxattr\(' out && fail=1
|
||||||
|
|
||||||
|
Exit $fail
|
Loading…
Add table
Add a link
Reference in a new issue