Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/cspell.dictionaries/jargon.wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ kibi
kibibytes
libacl
lcase
listxattr
llistxattr
lossily
lstat
Expand Down
2 changes: 1 addition & 1 deletion src/uucore/src/lib/features/fsxattr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn apply_xattrs<P: AsRef<Path>>(
/// `true` if the file has extended attributes (indicating an ACL), `false` otherwise.
pub fn has_acl<P: AsRef<Path>>(file: P) -> bool {
// 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
acl.count() > 0
})
Expand Down
37 changes: 37 additions & 0 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5716,3 +5716,40 @@ fn test_unknown_format_specifier() {
.succeeds()
.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 changes: 4 additions & 4 deletions util/gnu-patches/tests_ls_no_cap.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ index 99f0563bc..f7b9e7885 100755
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"
+strace -e listxattr ls --color=always > /dev/null 2> out || fail=1
+$EGREP 'listxattr\(' out || skip_ "your ls doesn't call listxattr"

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
+strace -e listxattr ls --color=always > /dev/null 2> out || fail=1
+$EGREP 'listxattr\(' out && fail=1

Exit $fail
Loading