65faf8
diff -urNp coreutils-8.21-orig/init.cfg coreutils-8.21/init.cfg
65faf8
--- coreutils-8.21-orig/init.cfg	2013-01-31 01:46:24.000000000 +0100
65faf8
+++ coreutils-8.21/init.cfg	2013-02-15 14:31:58.957469955 +0100
65faf8
@@ -308,8 +308,8 @@ require_selinux_()
65faf8
   # Independent of whether SELinux is enabled system-wide,
65faf8
   # the current file system may lack SELinux support.
65faf8
   # Also the current build may have SELinux support disabled.
65faf8
-  case $(ls -Zd .) in
65faf8
-    '? .'|'unlabeled .')
65faf8
+  case $(ls -Zd . | cut -f4 -d" ") in
65faf8
+    '?'|'unlabeled')
65faf8
       test -z "$CONFIG_HEADER" \
65faf8
         && framework_failure_ 'CONFIG_HEADER not defined'
65faf8
       grep '^#define HAVE_SELINUX_SELINUX_H 1' "$CONFIG_HEADER" > /dev/null \
65faf8
diff -urNp coreutils-8.21-orig/man/chcon.x coreutils-8.21/man/chcon.x
65faf8
--- coreutils-8.21-orig/man/chcon.x	2011-08-23 15:44:01.000000000 +0200
65faf8
+++ coreutils-8.21/man/chcon.x	2013-02-15 14:31:58.937482694 +0100
65faf8
@@ -1,4 +1,4 @@
65faf8
 [NAME]
65faf8
-chcon \- change file security context
65faf8
+chcon \- change file SELinux security context
65faf8
 [DESCRIPTION]
65faf8
 .\" Add any additional description here
65faf8
diff -urNp coreutils-8.21-orig/man/runcon.x coreutils-8.21/man/runcon.x
65faf8
--- coreutils-8.21-orig/man/runcon.x	2011-08-23 15:44:01.000000000 +0200
65faf8
+++ coreutils-8.21/man/runcon.x	2013-02-15 14:31:58.938486496 +0100
65faf8
@@ -1,5 +1,5 @@
65faf8
 [NAME]
65faf8
-runcon \- run command with specified security context
65faf8
+runcon \- run command with specified SELinux security context
65faf8
 [DESCRIPTION]
65faf8
 Run COMMAND with completely-specified CONTEXT, or with current or
65faf8
 transitioned security context modified by one or more of LEVEL,
65faf8
diff -urNp coreutils-8.21-orig/src/copy.c coreutils-8.21/src/copy.c
65faf8
--- coreutils-8.21-orig/src/copy.c	2013-02-07 10:37:05.000000000 +0100
65faf8
+++ coreutils-8.21/src/copy.c	2013-02-15 14:31:58.941467872 +0100
65faf8
@@ -2410,6 +2410,17 @@ copy_internal (char const *src_name, cha
65faf8
       else
65faf8
         {
65faf8
           omitted_permissions = 0;
65faf8
+
65faf8
+          /* For directories, the process global context could be reset for
65faf8
+             descendents, so use it to set the context for existing dirs here.
65faf8
+             This will also give earlier indication of failure to set ctx.  */
65faf8
+          if (x->set_security_context || x->preserve_security_context)
65faf8
+            if (! set_file_security_ctx (dst_name, x->preserve_security_context,
65faf8
+                                         false, x))
65faf8
+              {
65faf8
+                if (x->require_preserve_context)
65faf8
+                  goto un_backup;
65faf8
+              }
65faf8
         }
65faf8
 
65faf8
       /* Decide whether to copy the contents of the directory.  */
65faf8
@@ -2415,6 +2426,8 @@ copy_internal (char const *src_name, cha
65faf8
         {
65faf8
           /* Here, we are crossing a file system boundary and cp's -x option
65faf8
              is in effect: so don't copy the contents of this directory. */
65faf8
+        if (x->preserve_security_context)
65faf8
+           restore_default_fscreatecon_or_die ();
65faf8
         }
65faf8
       else
65faf8
         {
65faf8
@@ -2602,7 +2613,7 @@ copy_internal (char const *src_name, cha
65faf8
 
65faf8
   /* With -Z or --preserve=context, set the context for existing files.
65faf8
      Note this is done already for copy_reg() for reasons described therein.  */
65faf8
-  if (!new_dst && !x->copy_as_regular
65faf8
+  if (!new_dst && !x->copy_as_regular && !S_ISDIR (src_mode)
65faf8
       && (x->set_security_context || x->preserve_security_context))
65faf8
     {
65faf8
       if (! set_file_security_ctx (dst_name, x->preserve_security_context,
65faf8
diff -urNp coreutils-8.21-orig/src/cp.c coreutils-8.21/src/cp.c
65faf8
--- coreutils-8.21-orig/src/cp.c	2013-02-07 10:37:05.000000000 +0100
65faf8
+++ coreutils-8.21/src/cp.c	2013-02-15 14:31:58.945468929 +0100
65faf8
@@ -201,6 +202,9 @@ Copy SOURCE to DEST, or multiple SOURCE(
65faf8
                                  all\n\
65faf8
 "), stdout);
65faf8
       fputs (_("\
65faf8
+  -c                           deprecated, same as --preserve=context\n\
65faf8
+"), stdout);
65faf8
+      fputs (_("\
65faf8
       --no-preserve=ATTR_LIST  don't preserve the specified attributes\n\
65faf8
       --parents                use full source file name under DIRECTORY\n\
65faf8
 "), stdout);
65faf8
@@ -933,7 +939,7 @@ main (int argc, char **argv)
65faf8
      we'll actually use backup_suffix_string.  */
65faf8
   backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
65faf8
 
65faf8
-  while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ",
65faf8
+  while ((c = getopt_long (argc, argv, "abcdfHilLnprst:uvxPRS:TZ",
65faf8
                            long_opts, NULL))
65faf8
          != -1)
65faf8
     {
65faf8
@@ -981,6 +987,17 @@ main (int argc, char **argv)
65faf8
           copy_contents = true;
65faf8
           break;
65faf8
 
65faf8
+        case 'c':
65faf8
+          fprintf (stderr, "%s: warning: option '-c' is deprecated, please use '--preserve=context' instead\n", argv[0]);
65faf8
+          if ( x.set_security_context ) { 
65faf8
+              (void) fprintf(stderr, "%s: cannot force target context and preserve it\n", argv[0]);
65faf8
+             exit( 1 );
65faf8
+           }
65faf8
+           else if (selinux_enabled) {
65faf8
+              x.preserve_security_context = true;
65faf8
+              x.require_preserve_context = true;
65faf8
+           }
65faf8
+          break;
65faf8
         case 'd':
65faf8
           x.preserve_links = true;
65faf8
           x.dereference = DEREF_NEVER;
65faf8
diff -urNp coreutils-8.21-orig/src/id.c coreutils-8.21/src/id.c
65faf8
--- coreutils-8.21-orig/src/id.c	2013-01-31 01:46:24.000000000 +0100
65faf8
+++ coreutils-8.21/src/id.c	2013-02-15 14:31:58.946469154 +0100
65faf8
@@ -106,7 +106,7 @@ int
65faf8
 main (int argc, char **argv)
65faf8
 {
65faf8
   int optc;
65faf8
-  int selinux_enabled = (is_selinux_enabled () > 0);
65faf8
+  bool selinux_enabled = (is_selinux_enabled () > 0);
65faf8
   bool smack_enabled = is_smack_enabled ();
65faf8
   bool opt_zero = false;
65faf8
   char *pw_name = NULL;
65faf8
diff -urNp coreutils-8.21-orig/src/install.c coreutils-8.21/src/install.c
65faf8
--- coreutils-8.21-orig/src/install.c	2013-02-07 10:37:05.000000000 +0100
65faf8
+++ coreutils-8.21/src/install.c	2013-02-15 14:31:58.948469440 +0100
65faf8
@@ -639,7 +640,7 @@ In the 4th form, create all components o
65faf8
   -v, --verbose       print the name of each directory as it is created\n\
65faf8
 "), stdout);
65faf8
       fputs (_("\
65faf8
-      --preserve-context  preserve SELinux security context\n\
65faf8
+  -P, --preserve-context  preserve SELinux security context (-P deprecated)\n\
65faf8
   -Z, --context[=CTX]     set SELinux security context of destination file to\n\
65faf8
                             default type, or to CTX if specified\n\
65faf8
 "), stdout);
65faf8
@@ -782,7 +783,7 @@ main (int argc, char **argv)
65faf8
      we'll actually use backup_suffix_string.  */
65faf8
   backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
65faf8
 
65faf8
-  while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z", long_options,
65faf8
+  while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pPt:TvS:Z", long_options,
65faf8
                               NULL)) != -1)
65faf8
     {
65faf8
       switch (optc)
65faf8
@@ -853,6 +854,8 @@ main (int argc, char **argv)
65faf8
           no_target_directory = true;
65faf8
           break;
65faf8
 
65faf8
+        case 'P':
65faf8
+          fprintf (stderr, "%s: warning: option '-P' is deprecated, please use '--preserve-context' instead\n", argv[0]);
65faf8
         case PRESERVE_CONTEXT_OPTION:
65faf8
           if (! selinux_enabled)
65faf8
             {
65faf8
@@ -860,6 +862,10 @@ main (int argc, char **argv)
65faf8
                              "this kernel is not SELinux-enabled"));
65faf8
               break;
65faf8
             }
65faf8
+          if ( x.set_security_context ) {
65faf8
+             (void) fprintf(stderr, "%s: cannot force target context and preserve it\n", argv[0]);
65faf8
+             exit( 1 );
65faf8
+          }
65faf8
           x.preserve_security_context = true;
65faf8
           use_default_selinux_context = false;
65faf8
           break;
65faf8
diff -urNp coreutils-8.21-orig/src/ls.c coreutils-8.21/src/ls.c
65faf8
--- coreutils-8.21-orig/src/ls.c	2013-02-03 04:24:02.000000000 +0100
65faf8
+++ coreutils-8.21/src/ls.c	2013-02-15 14:31:58.953469008 +0100
65faf8
@@ -165,7 +165,8 @@ enum filetype
65faf8
     symbolic_link,
65faf8
     sock,
65faf8
     whiteout,
65faf8
-    arg_directory
65faf8
+    arg_directory,
65faf8
+    command_line
65faf8
   };
65faf8
 
65faf8
 /* Display letters and indicators for each filetype.
65faf8
@@ -281,6 +282,7 @@ static void queue_directory (char const 
65faf8
                              bool command_line_arg);
65faf8
 static void sort_files (void);
65faf8
 static void parse_ls_color (void);
65faf8
+static void print_scontext_format (const struct fileinfo *f);
65faf8
 
65faf8
 /* Initial size of hash table.
65faf8
    Most hierarchies are likely to be shallower than this.  */
65faf8
@@ -350,7 +352,7 @@ static struct pending *pending_dirs;
65faf8
 
65faf8
 static struct timespec current_time;
65faf8
 
65faf8
-static bool print_scontext;
65faf8
+static int print_scontext = 0;
65faf8
 static char UNKNOWN_SECURITY_CONTEXT[] = "?";
65faf8
 
65faf8
 /* Whether any of the files has an ACL.  This affects the width of the
65faf8
@@ -390,7 +392,9 @@ enum format
65faf8
     one_per_line,		/* -1 */
65faf8
     many_per_line,		/* -C */
65faf8
     horizontal,			/* -x */
65faf8
-    with_commas			/* -m */
65faf8
+    with_commas,			/* -m */
65faf8
+    security_format, /* -Z */
65faf8
+    invalid_format
65faf8
   };
65faf8
 
65faf8
 static enum format format;
65faf8
@@ -793,6 +797,9 @@ enum
65faf8
   SHOW_CONTROL_CHARS_OPTION,
65faf8
   SI_OPTION,
65faf8
   SORT_OPTION,
65faf8
+  CONTEXT_OPTION,
65faf8
+  LCONTEXT_OPTION,
65faf8
+  SCONTEXT_OPTION,
65faf8
   TIME_OPTION,
65faf8
   TIME_STYLE_OPTION
65faf8
 };
65faf8
@@ -839,7 +846,9 @@ static struct option const long_options[
65faf8
   {"time-style", required_argument, NULL, TIME_STYLE_OPTION},
65faf8
   {"color", optional_argument, NULL, COLOR_OPTION},
65faf8
   {"block-size", required_argument, NULL, BLOCK_SIZE_OPTION},
65faf8
-  {"context", no_argument, 0, 'Z'},
65faf8
+  {"context", no_argument, 0, CONTEXT_OPTION},
65faf8
+  {"lcontext", no_argument, 0, LCONTEXT_OPTION},
65faf8
+  {"scontext", no_argument, 0, SCONTEXT_OPTION},
65faf8
   {"author", no_argument, NULL, AUTHOR_OPTION},
65faf8
   {GETOPT_HELP_OPTION_DECL},
65faf8
   {GETOPT_VERSION_OPTION_DECL},
65faf8
@@ -849,12 +858,12 @@ static struct option const long_options[
65faf8
 static char const *const format_args[] =
65faf8
 {
65faf8
   "verbose", "long", "commas", "horizontal", "across",
65faf8
-  "vertical", "single-column", NULL
65faf8
+  "vertical", "single-column", "context", NULL
65faf8
 };
65faf8
 static enum format const format_types[] =
65faf8
 {
65faf8
   long_format, long_format, with_commas, horizontal, horizontal,
65faf8
-  many_per_line, one_per_line
65faf8
+  many_per_line, one_per_line, security_format
65faf8
 };
65faf8
 ARGMATCH_VERIFY (format_args, format_types);
65faf8
 
65faf8
@@ -1296,7 +1305,8 @@ main (int argc, char **argv)
65faf8
       /* Avoid following symbolic links when possible.  */
65faf8
       if (is_colored (C_ORPHAN)
65faf8
           || (is_colored (C_EXEC) && color_symlink_as_referent)
65faf8
-          || (is_colored (C_MISSING) && format == long_format))
65faf8
+          || (is_colored (C_MISSING) && (format == long_format
65faf8
+              || format == security_format)))
65faf8
         check_symlink_color = true;
65faf8
 
65faf8
       /* If the standard output is a controlling terminal, watch out
65faf8
@@ -1343,7 +1353,7 @@ main (int argc, char **argv)
65faf8
   if (dereference == DEREF_UNDEFINED)
65faf8
     dereference = ((immediate_dirs
65faf8
                     || indicator_style == classify
65faf8
-                    || format == long_format)
65faf8
+                    || format == long_format || format == security_format)
65faf8
                    ? DEREF_NEVER
65faf8
                    : DEREF_COMMAND_LINE_SYMLINK_TO_DIR);
65faf8
 
65faf8
@@ -1363,7 +1373,7 @@ main (int argc, char **argv)
65faf8
 
65faf8
   format_needs_stat = sort_type == sort_time || sort_type == sort_size
65faf8
     || format == long_format
65faf8
-    || print_scontext
65faf8
+    || format == security_format || print_scontext
65faf8
     || print_block_size;
65faf8
   format_needs_type = (! format_needs_stat
65faf8
                        && (recursive
65faf8
@@ -1394,7 +1404,7 @@ main (int argc, char **argv)
65faf8
     }
65faf8
   else
65faf8
     do
65faf8
-      gobble_file (argv[i++], unknown, NOT_AN_INODE_NUMBER, true, "");
65faf8
+      gobble_file (argv[i++], command_line, NOT_AN_INODE_NUMBER, true, "");
65faf8
     while (i < argc);
65faf8
 
65faf8
   if (cwd_n_used)
65faf8
@@ -1565,7 +1575,7 @@ decode_switches (int argc, char **argv)
65faf8
   ignore_mode = IGNORE_DEFAULT;
65faf8
   ignore_patterns = NULL;
65faf8
   hide_patterns = NULL;
65faf8
-  print_scontext = false;
65faf8
+  print_scontext = 0;
65faf8
 
65faf8
   /* FIXME: put this in a function.  */
65faf8
   {
65faf8
@@ -1941,13 +1951,27 @@ decode_switches (int argc, char **argv)
65faf8
           break;
65faf8
 
65faf8
         case 'Z':
65faf8
-          print_scontext = true;
65faf8
+          print_scontext = 1;
65faf8
+    format = security_format;
65faf8
           break;
65faf8
 
65faf8
         case_GETOPT_HELP_CHAR;
65faf8
 
65faf8
         case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
65faf8
 
65faf8
+  case CONTEXT_OPTION: /* default security context format */
65faf8
+                print_scontext = 1;
65faf8
+                format = security_format;
65faf8
+                break;
65faf8
+        case LCONTEXT_OPTION: /* long format plus security context */
65faf8
+                print_scontext = 1;
65faf8
+                format = long_format;
65faf8
+                break;
65faf8
+        case SCONTEXT_OPTION: /* short form of new security format */
65faf8
+                print_scontext = 0;
65faf8
+                format = security_format;
65faf8
+                break;
65faf8
+
65faf8
         default:
65faf8
           usage (LS_FAILURE);
65faf8
         }
65faf8
@@ -2883,6 +2907,7 @@ gobble_file (char const *name, enum file
65faf8
   memset (f, '\0', sizeof *f);
65faf8
   f->stat.st_ino = inode;
65faf8
   f->filetype = type;
65faf8
+  f->scontext = NULL;
65faf8
 
65faf8
   if (command_line_arg
65faf8
       || format_needs_stat
65faf8
@@ -2995,7 +3020,7 @@ gobble_file (char const *name, enum file
65faf8
           && print_with_color && is_colored (C_CAP))
65faf8
         f->has_capability = has_capability_cache (absolute_name, f);
65faf8
 
65faf8
-      if (format == long_format || print_scontext)
65faf8
+      if (format == long_format || format == security_format || print_scontext)
65faf8
         {
65faf8
           bool have_scontext = false;
65faf8
           bool have_acl = false;
65faf8
@@ -3016,7 +3041,7 @@ gobble_file (char const *name, enum file
65faf8
                 err = 0;
65faf8
             }
65faf8
 
65faf8
-          if (err == 0 && format == long_format)
65faf8
+          if (err == 0 && (format == long_format || format == security_format))
65faf8
             {
65faf8
               int n = file_has_acl_cache (absolute_name, f);
65faf8
               err = (n < 0);
65faf8
@@ -3035,7 +3060,8 @@ gobble_file (char const *name, enum file
65faf8
         }
65faf8
 
65faf8
       if (S_ISLNK (f->stat.st_mode)
65faf8
-          && (format == long_format || check_symlink_color))
65faf8
+          && (format == long_format || format == security_format
65faf8
+              || check_symlink_color))
65faf8
         {
65faf8
           struct stat linkstats;
65faf8
 
65faf8
@@ -3054,6 +3080,7 @@ gobble_file (char const *name, enum file
65faf8
                  command line are automatically traced if not being
65faf8
                  listed as files.  */
65faf8
               if (!command_line_arg || format == long_format
65faf8
+                  || format == security_format
65faf8
                   || !S_ISDIR (linkstats.st_mode))
65faf8
                 {
65faf8
                   /* Get the linked-to file's mode for the filetype indicator
65faf8
@@ -3087,7 +3114,7 @@ gobble_file (char const *name, enum file
65faf8
             block_size_width = len;
65faf8
         }
65faf8
 
65faf8
-      if (format == long_format)
65faf8
+      if (format == long_format || format == security_format)
65faf8
         {
65faf8
           if (print_owner)
65faf8
             {
65faf8
@@ -3591,6 +3618,13 @@ print_current_files (void)
65faf8
           print_long_format (sorted_file[i]);
65faf8
           DIRED_PUTCHAR ('\n');
65faf8
         }
65faf8
+     break;
65faf8
+    case security_format:
65faf8
+      for (i = 0; i < cwd_n_used; i++)
65faf8
+      {
65faf8
+        print_scontext_format (sorted_file[i]);
65faf8
+        DIRED_PUTCHAR ('\n');
65faf8
+      }
65faf8
       break;
65faf8
     }
65faf8
 }
65faf8
@@ -3753,6 +3787,67 @@ format_inode (char *buf, size_t buflen, 
65faf8
           : (char *) "?");
65faf8
 }
65faf8
 
65faf8
+/* Print info about f in scontext format */
65faf8
+static void
65faf8
+print_scontext_format (const struct fileinfo *f)
65faf8
+{
65faf8
+  char modebuf[12];
65faf8
+
65faf8
+  /* 7 fields that may require LONGEST_HUMAN_READABLE bytes,
65faf8
+     1 10-byte mode string,
65faf8
+     9 spaces, one following each of these fields, and
65faf8
+     1 trailing NUL byte.  */
65faf8
+
65faf8
+  char init_bigbuf[7 * LONGEST_HUMAN_READABLE + 10  + 9 + 1];
65faf8
+  char *buf = init_bigbuf;
65faf8
+  char *p;
65faf8
+
65faf8
+  p = buf;
65faf8
+
65faf8
+  if ( print_scontext ) { /* zero means terse listing */
65faf8
+    filemodestring (&f->stat, modebuf);
65faf8
+    if (! any_has_acl)
65faf8
+      modebuf[10] = '\0';
65faf8
+    else if (f->acl_type == ACL_T_SELINUX_ONLY)
65faf8
+      modebuf[10] = '.';
65faf8
+    else if (f->acl_type == ACL_T_YES)
65faf8
+      modebuf[10] = '+';
65faf8
+    modebuf[11] = '\0';
65faf8
+
65faf8
+    /* print mode */
65faf8
+
65faf8
+    (void) sprintf (p, "%s ", modebuf);
65faf8
+    p += strlen (p);
65faf8
+
65faf8
+    /* print standard user and group */
65faf8
+
65faf8
+    DIRED_FPUTS (buf, stdout, p - buf);
65faf8
+    format_user (f->stat.st_uid, owner_width, f->stat_ok);
65faf8
+    format_group (f->stat.st_gid, group_width, f->stat_ok);
65faf8
+    p = buf;
65faf8
+  }
65faf8
+
65faf8
+  (void) sprintf (p, "%-32s ", f->scontext ?: "");
65faf8
+  p += strlen (p);
65faf8
+
65faf8
+  DIRED_INDENT ();
65faf8
+  DIRED_FPUTS (buf, stdout, p - buf);
65faf8
+  size_t w = print_name_with_quoting (f, false, &dired_obstack, p - buf);
65faf8
+
65faf8
+  if (f->filetype == symbolic_link) {
65faf8
+      if (f->linkname) {
65faf8
+          DIRED_FPUTS_LITERAL (" -> ", stdout);
65faf8
+          print_name_with_quoting (f, true, NULL, (p - buf) + w + 4);
65faf8
+          if (indicator_style != none)
65faf8
+            print_type_indicator (f->stat_ok, f->linkmode, f->filetype);
65faf8
+      }
65faf8
+  }
65faf8
+  else {
65faf8
+    if (indicator_style != none)
65faf8
+      print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
65faf8
+  }
65faf8
+}
65faf8
+
65faf8
 /* Print information about F in long format.  */
65faf8
 static void
65faf8
 print_long_format (const struct fileinfo *f)
65faf8
@@ -3844,9 +3939,15 @@ print_long_format (const struct fileinfo
65faf8
      The latter is wrong when nlink_width is zero.  */
65faf8
   p += strlen (p);
65faf8
 
65faf8
+  if (print_scontext)
65faf8
+    {
65faf8
+      sprintf (p, "%-32s ", f->scontext ? f->scontext : "");
65faf8
+      p += strlen (p);
65faf8
+    }
65faf8
+
65faf8
   DIRED_INDENT ();
65faf8
 
65faf8
-  if (print_owner || print_group || print_author || print_scontext)
65faf8
+  if (print_owner || print_group || print_author)
65faf8
     {
65faf8
       DIRED_FPUTS (buf, stdout, p - buf);
65faf8
 
65faf8
@@ -3859,9 +3960,6 @@ print_long_format (const struct fileinfo
65faf8
       if (print_author)
65faf8
         format_user (f->stat.st_author, author_width, f->stat_ok);
65faf8
 
65faf8
-      if (print_scontext)
65faf8
-        format_user_or_group (f->scontext, 0, scontext_width);
65faf8
-
65faf8
       p = buf;
65faf8
     }
65faf8
 
65faf8
@@ -4207,9 +4305,6 @@ print_file_name_and_frills (const struct
65faf8
             : human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts,
65faf8
                               ST_NBLOCKSIZE, output_block_size));
65faf8
 
65faf8
-  if (print_scontext)
65faf8
-    printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
65faf8
-
65faf8
   size_t width = print_name_with_quoting (f, false, NULL, start_col);
65faf8
 
65faf8
   if (indicator_style != none)
65faf8
@@ -4417,9 +4512,6 @@ length_of_file_name_and_frills (const st
65faf8
                                             output_block_size))
65faf8
                 : block_size_width);
65faf8
 
65faf8
-  if (print_scontext)
65faf8
-    len += 1 + (format == with_commas ? strlen (f->scontext) : scontext_width);
65faf8
-
65faf8
   quote_name (NULL, f->name, filename_quoting_options, &name_width);
65faf8
   len += name_width;
65faf8
 
65faf8
@@ -4856,9 +4948,16 @@ Sort entries alphabetically if none of -
65faf8
   -w, --width=COLS           assume screen width instead of current value\n\
65faf8
   -x                         list entries by lines instead of by columns\n\
65faf8
   -X                         sort alphabetically by entry extension\n\
65faf8
-  -Z, --context              print any SELinux security context of each file\n\
65faf8
   -1                         list one file per line\n\
65faf8
 "), stdout);
65faf8
+      fputs(_("\nSELinux options:\n\n\
65faf8
+  --lcontext                 Display security context.   Enable -l. Lines\n\
65faf8
+                             will probably be too wide for most displays.\n\
65faf8
+  -Z, --context              Display security context so it fits on most\n\
65faf8
+                             displays.  Displays only mode, user, group,\n\
65faf8
+                             security context and file name.\n\
65faf8
+  --scontext                 Display only security context and file name.\n\
65faf8
+"), stdout);
65faf8
       fputs (HELP_OPTION_DESCRIPTION, stdout);
65faf8
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
65faf8
       emit_size_note ();
65faf8
diff -urNp coreutils-8.21-orig/tests/misc/selinux.sh coreutils-8.21/tests/misc/selinux.sh
65faf8
--- coreutils-8.21-orig/tests/misc/selinux.sh	2013-01-31 01:46:24.000000000 +0100
65faf8
+++ coreutils-8.21/tests/misc/selinux.sh	2013-02-15 14:31:58.957469955 +0100
65faf8
@@ -37,7 +37,7 @@ chcon $ctx f d p ||
65faf8
 
65faf8
 # inspect that context with both ls -Z and stat.
65faf8
 for i in d f p; do
65faf8
-  c=$(ls -dogZ $i|cut -d' ' -f3); test x$c = x$ctx || fail=1
65faf8
+  c=$(ls -dogZ $i|cut -d' ' -f4); test x$c = x$ctx || fail=1
65faf8
   c=$(stat --printf %C $i); test x$c = x$ctx || fail=1
65faf8
 done
65faf8