From d5450d7ee10b2a4b717c418e6990ba170cba7b92 Mon Sep 17 00:00:00 2001 From: Sudhakar Verma Date: Wed, 18 Jun 2025 18:07:46 +0530 Subject: [PATCH 1/7] ls: follow symlinks for xattrs Signed-off-by: Sudhakar Verma --- src/uucore/src/lib/features/fsxattr.rs | 2 +- tests/by-util/test_ls.rs | 34 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/uucore/src/lib/features/fsxattr.rs b/src/uucore/src/lib/features/fsxattr.rs index 1913b0669fc..1f1356ee5f6 100644 --- a/src/uucore/src/lib/features/fsxattr.rs +++ b/src/uucore/src/lib/features/fsxattr.rs @@ -79,7 +79,7 @@ pub fn apply_xattrs>( /// `true` if the file has extended attributes (indicating an ACL), `false` otherwise. pub fn has_acl>(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 }) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 58bd538e457..653ad8123e2 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -5716,3 +5716,37 @@ 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", &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); + ucmd.arg("-lLd") + .arg(link_name) + .succeeds() + .stdout_contains("drwxrwxr-x+"); +} From 3175a33e84b5e57a5cbd8601dee332bf0418eaa4 Mon Sep 17 00:00:00 2001 From: Sudhakar Verma Date: Wed, 18 Jun 2025 18:55:26 +0530 Subject: [PATCH 2/7] ls: clippy, fix ref Signed-off-by: Sudhakar Verma --- tests/by-util/test_ls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 653ad8123e2..ccb4180af87 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -5730,7 +5730,7 @@ fn test_acl_display_symlink() { // 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", &dir_name]) + .args(["-d", "-m", "u:bin:rwx", dir_name]) .status() .map(|status| status.code()) { From bae7a4960386b9a5f40e908eafeb4978045ade69 Mon Sep 17 00:00:00 2001 From: Sudhakar Verma Date: Wed, 18 Jun 2025 19:05:12 +0530 Subject: [PATCH 3/7] ls: tests, fix spell Signed-off-by: Sudhakar Verma --- tests/by-util/test_ls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index ccb4180af87..845639ad2cb 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff dired subdired tmpfs mdir COLORTERM mexe bcdef mfoo -// spell-checker:ignore (words) fakeroot setcap drwxr +// spell-checker:ignore (words) fakeroot setcap drwxr drwxrwxr #![allow( clippy::similar_names, clippy::too_many_lines, From 3d9e6a182e90e193962ab9b23a062b55cd4ffe0a Mon Sep 17 00:00:00 2001 From: Sudhakar Verma Date: Thu, 19 Jun 2025 10:15:48 +0530 Subject: [PATCH 4/7] ls: tests, fix path Signed-off-by: Sudhakar Verma --- tests/by-util/test_ls.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 845639ad2cb..417ac4c9240 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -5730,7 +5730,7 @@ fn test_acl_display_symlink() { // 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", dir_name]) + .args(["-d", "-m", "u:bin:rwx", &at.plus_as_string(dir_name)]) .status() .map(|status| status.code()) { From b3375098241760d8d6fc9192686cb97e4fb8f142 Mon Sep 17 00:00:00 2001 From: Sudhakar Verma Date: Thu, 19 Jun 2025 10:27:38 +0530 Subject: [PATCH 5/7] ls: tests, fix regex for MinRustV Signed-off-by: Sudhakar Verma --- tests/by-util/test_ls.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 417ac4c9240..042ce3fce3d 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -5744,9 +5744,12 @@ fn test_acl_display_symlink() { 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_contains("drwxrwxr-x+"); + .stdout_matches(&re_with_acl); } From 5edc3ae01009a58cf4c58d9bffc2d1865d81d6ed Mon Sep 17 00:00:00 2001 From: Sudhakar Verma Date: Thu, 19 Jun 2025 10:47:06 +0530 Subject: [PATCH 6/7] ls: gnu tests, use listxattr instead of llistxattr Signed-off-by: Sudhakar Verma --- tests/by-util/test_ls.rs | 2 +- util/gnu-patches/tests_ls_no_cap.patch | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 042ce3fce3d..a8b0aa37202 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff dired subdired tmpfs mdir COLORTERM mexe bcdef mfoo -// spell-checker:ignore (words) fakeroot setcap drwxr drwxrwxr +// spell-checker:ignore (words) fakeroot setcap drwxr #![allow( clippy::similar_names, clippy::too_many_lines, diff --git a/util/gnu-patches/tests_ls_no_cap.patch b/util/gnu-patches/tests_ls_no_cap.patch index 8e36512ae9c..c2f48ca21f3 100644 --- a/util/gnu-patches/tests_ls_no_cap.patch +++ b/util/gnu-patches/tests_ls_no_cap.patch @@ -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 From bf48ee781962f88fbacc6c152ceb8fdb0dd5fed3 Mon Sep 17 00:00:00 2001 From: Sudhakar Verma Date: Thu, 19 Jun 2025 11:04:55 +0530 Subject: [PATCH 7/7] ls: gnu tests, fix spell Signed-off-by: Sudhakar Verma --- .vscode/cspell.dictionaries/jargon.wordlist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/cspell.dictionaries/jargon.wordlist.txt b/.vscode/cspell.dictionaries/jargon.wordlist.txt index 6358f3c7682..0fb10db6865 100644 --- a/.vscode/cspell.dictionaries/jargon.wordlist.txt +++ b/.vscode/cspell.dictionaries/jargon.wordlist.txt @@ -68,6 +68,7 @@ kibi kibibytes libacl lcase +listxattr llistxattr lossily lstat