On 30/09/2024 09:26, Bernhard Voelker wrote:
On 9/30/24 7:24 AM, Paul Eggert wrote:
I installed the attached patch to fix some of the issue

There's a new test failure for a require_root_ test here:

FAIL: tests/ls/capability
=========================

That should be fixed by the attached.

thanks,
Pádraig
From 58df92259fac2a8613bbd8df03c61ef5c37dc436 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Wed, 2 Oct 2024 22:57:16 +0100
Subject: [PATCH] ls: reinstate capability checking in more cases

The recent commit v9.5-119-g4ce432ad8 restricted capability checking
to only files with XATTR_NAME_CAPS set.  If this is done then we need
to adjust tests/ls/no-cap.sh so that it doesn't always skip.  More
problematically XATTR_NAME_CAPS was only determined in long listing
mode, thus breaking capability coloring in short listing mode
as evidenced by the failing tests/ls/capability.sh test.

Note capability checking does have a large overhead, but we've
disabled capability checking by default anyway through the default
color configuration since v9.0-187-g6b5134770

So for these reasons revert to checking capabilities as before.

* src/ls.c (gobble_file): Check for capabilities in all modes
if enabled in color config.
---
 src/ls.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/ls.c b/src/ls.c
index 099893f86..8d0ae11f4 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3484,6 +3484,12 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
 
       f->stat_ok = true;
 
+      /* has_capability adds around 30% runtime to 'ls --color',
+          so call it only if really needed.  */
+      if ((type == normal || S_ISREG (f->stat.st_mode))
+          && print_with_color && is_colored (C_CAP))
+        f->has_capability = has_capability_cache (full_name, f);
+
       if (format == long_format || print_scontext)
         {
           struct aclinfo ai;
@@ -3512,14 +3518,6 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
                 error (0, ai.scontext_err, "%s", quotef (full_name));
             }
 
-          /* has_capability adds around 30% runtime to 'ls --color',
-             so call it only if really needed.  */
-          if (0 < ai.size
-              && (type == normal || S_ISREG (f->stat.st_mode))
-              && print_with_color && is_colored (C_CAP)
-              && aclinfo_has_xattr (&ai, XATTR_NAME_CAPS))
-            f->has_capability = has_capability_cache (full_name, f);
-
           f->scontext = ai.scontext;
           ai.scontext = nullptr;
           aclinfo_free (&ai);
-- 
2.46.0

Reply via email to