mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #8217 from sudhackar/ls-fix
ls: follow symlinks for xattrs, fix #8216
This commit is contained in:
parent
86f0c617d8
commit
c674cf1839
4 changed files with 43 additions and 5 deletions
|
@ -68,6 +68,7 @@ kibi
|
||||||
kibibytes
|
kibibytes
|
||||||
libacl
|
libacl
|
||||||
lcase
|
lcase
|
||||||
|
listxattr
|
||||||
llistxattr
|
llistxattr
|
||||||
lossily
|
lossily
|
||||||
lstat
|
lstat
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub fn apply_xattrs<P: AsRef<Path>>(
|
||||||
/// `true` if the file has extended attributes (indicating an ACL), `false` otherwise.
|
/// `true` if the file has extended attributes (indicating an ACL), `false` otherwise.
|
||||||
pub fn has_acl<P: AsRef<Path>>(file: P) -> bool {
|
pub fn has_acl<P: AsRef<Path>>(file: P) -> bool {
|
||||||
// don't use exacl here, it is doing more getxattr call then needed
|
// don't use exacl here, it is doing more getxattr call then needed
|
||||||
xattr::list(file).is_ok_and(|acl| {
|
xattr::list_deref(file).is_ok_and(|acl| {
|
||||||
// if we have extra attributes, we have an acl
|
// if we have extra attributes, we have an acl
|
||||||
acl.count() > 0
|
acl.count() > 0
|
||||||
})
|
})
|
||||||
|
|
|
@ -5716,3 +5716,40 @@ fn test_unknown_format_specifier() {
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_matches(&re_custom_format);
|
.stdout_matches(&re_custom_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(unix, not(target_os = "macos")))]
|
||||||
|
#[test]
|
||||||
|
fn test_acl_display_symlink() {
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
let dir_name = "dir";
|
||||||
|
let link_name = "link";
|
||||||
|
at.mkdir(dir_name);
|
||||||
|
|
||||||
|
// calling the command directly. xattr requires some dev packages to be installed
|
||||||
|
// and it adds a complex dependency just for a test
|
||||||
|
match Command::new("setfacl")
|
||||||
|
.args(["-d", "-m", "u:bin:rwx", &at.plus_as_string(dir_name)])
|
||||||
|
.status()
|
||||||
|
.map(|status| status.code())
|
||||||
|
{
|
||||||
|
Ok(Some(0)) => {}
|
||||||
|
Ok(_) => {
|
||||||
|
println!("test skipped: setfacl failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
println!("test skipped: setfacl failed with {e}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
at.symlink_dir(dir_name, link_name);
|
||||||
|
|
||||||
|
let re_with_acl = Regex::new(r"[a-z-]*\+ .*link").unwrap();
|
||||||
|
ucmd.arg("-lLd")
|
||||||
|
.arg(link_name)
|
||||||
|
.succeeds()
|
||||||
|
.stdout_matches(&re_with_acl);
|
||||||
|
}
|
||||||
|
|
|
@ -8,13 +8,13 @@ index 99f0563bc..f7b9e7885 100755
|
||||||
LS_COLORS=ca=1; export LS_COLORS
|
LS_COLORS=ca=1; export LS_COLORS
|
||||||
-strace -e capget ls --color=always > /dev/null 2> out || fail=1
|
-strace -e capget ls --color=always > /dev/null 2> out || fail=1
|
||||||
-$EGREP 'capget\(' out || skip_ "your ls doesn't call capget"
|
-$EGREP 'capget\(' out || skip_ "your ls doesn't call capget"
|
||||||
+strace -e llistxattr ls --color=always > /dev/null 2> out || fail=1
|
+strace -e listxattr ls --color=always > /dev/null 2> out || fail=1
|
||||||
+$EGREP 'llistxattr\(' out || skip_ "your ls doesn't call llistxattr"
|
+$EGREP 'listxattr\(' out || skip_ "your ls doesn't call listxattr"
|
||||||
|
|
||||||
LS_COLORS=ca=:; export LS_COLORS
|
LS_COLORS=ca=:; export LS_COLORS
|
||||||
-strace -e capget ls --color=always > /dev/null 2> out || fail=1
|
-strace -e capget ls --color=always > /dev/null 2> out || fail=1
|
||||||
-$EGREP 'capget\(' out && fail=1
|
-$EGREP 'capget\(' out && fail=1
|
||||||
+strace -e llistxattr ls --color=always > /dev/null 2> out || fail=1
|
+strace -e listxattr ls --color=always > /dev/null 2> out || fail=1
|
||||||
+$EGREP 'llistxattr\(' out && fail=1
|
+$EGREP 'listxattr\(' out && fail=1
|
||||||
|
|
||||||
Exit $fail
|
Exit $fail
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue