Bug 131196

Summary: non-descriptive text if getfilecon fails
Product: [Fedora] Fedora Reporter: Ulrich Drepper <drepper.fsp>
Component: coreutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3CC: redhat-bugzilla
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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:
Cloudforms Team: ---

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.