Bug 131196 - non-descriptive text if getfilecon fails
non-descriptive text if getfilecon fails
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: coreutils (Show other bugs)
3
All Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-08-28 17:53 EDT by Ulrich Drepper
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

See Also:
Fixed In Version: 5.2.1-24
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-09-14 06:15:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Ulrich Drepper 2004-08-28 17:53:15 EDT
Description of problem:
If getfilecon fails (if -Z is used) ls currently prints (null) in case
of the attribute value.  While this might be OK for somebody who knows
the C library and that NULL pointer values are indicated this way, I
think it is misleading for normal users.  If the attribute is not set,
I would say printing nothing at all is better.

Version-Release number of selected component (if applicable):
coreutils-5.2.1-23

How reproducible:
always

Steps to Reproduce:
1.ls -Z /  and  ls -Zl /
2.observe entry for /proc
3.
  
Actual results:
dr-xr-xr-x  root     root     (null)                           proc


Expected results:
dr-xr-xr-x  root     root                                      proc


Additional info:

This patch implements the proposed behavior.

--- ls.c.null   2004-08-28 14:54:54.803978072 -0700
+++ ls.c        2004-08-28 14:48:30.591387264 -0700
@@ -3256,7 +3256,7 @@ print_long_format (const struct fileinfo
 #ifdef WITH_SELINUX
  
   if ( print_scontext ) {
-    sprintf (p, "%-32s ", f->scontext);
+    sprintf (p, "%-32s ", f->scontext ?: "");
     p += strlen (p);
   }
 #endif
@@ -4275,7 +4275,7 @@ print_scontext_format (const struct file
     }
   }
  
-  (void) sprintf (p, "%-32s ", f->scontext);
+  (void) sprintf (p, "%-32s ", f->scontext ?: "");
   p += strlen (p);
   
   DIRED_INDENT ();
Comment 1 Tim Waugh 2004-09-14 06:13:22 EDT
Fixed in CVS.

Note You need to log in before you can comment on or make changes to this bug.