0363d66
diff -urp coreutils-6.10-orig/configure.ac coreutils-6.10/configure.ac
0363d66
--- coreutils-6.10-orig/configure.ac	2008-01-25 12:32:33.000000000 +0100
0363d66
+++ coreutils-6.10/configure.ac	2008-01-25 14:10:34.000000000 +0100
0363d66
@@ -51,6 +51,13 @@ AC_ARG_ENABLE(pam, dnl
0363d66
 LIB_PAM="-ldl -lpam -lpam_misc"
0363d66
 AC_SUBST(LIB_PAM)])
0363d66
 
0363d66
+dnl Give the chance to enable SELINUX
0363d66
+AC_ARG_ENABLE(selinux, dnl
0363d66
+[  --enable-selinux              Enable use of the SELINUX libraries],
0363d66
+[AC_DEFINE(WITH_SELINUX, 1, [Define if you want to use SELINUX])
0363d66
+LIB_SELINUX="-lselinux"
0363d66
+AC_SUBST(LIB_SELINUX)])
0363d66
+
0363d66
 AC_FUNC_FORK
0363d66
 
0363d66
 optional_bin_progs=
893c388
diff -urNp coreutils-6.12-orig/man/chcon.x coreutils-6.12/man/chcon.x
893c388
--- coreutils-6.12-orig/man/chcon.x	2008-03-07 17:05:53.000000000 +0100
893c388
+++ coreutils-6.12/man/chcon.x	2008-10-21 15:53:43.000000000 +0200
893c388
@@ -1,4 +1,4 @@
893c388
 [NAME]
0363d66
-chcon \- change file security context
0363d66
+chcon \- change file SELinux security context
893c388
 [DESCRIPTION]
0363d66
 .\" Add any additional description here
893c388
diff -urNp coreutils-6.12-orig/man/runcon.x coreutils-6.12/man/runcon.x
893c388
--- coreutils-6.12-orig/man/runcon.x	2008-03-07 17:05:53.000000000 +0100
893c388
+++ coreutils-6.12/man/runcon.x	2008-10-21 15:54:01.000000000 +0200
893c388
@@ -1,5 +1,5 @@
893c388
 [NAME]
893c388
-runcon \- run command with specified security context
893c388
+runcon \- run command with specified SELinux security context
893c388
 [DESCRIPTION]
893c388
 Run COMMAND with completely-specified CONTEXT, or with current or
893c388
 transitioned security context modified by one or more of LEVEL,
3ed40da
diff -urNp coreutils-6.12-orig/src/chcon.c coreutils-6.12/src/chcon.c
3ed40da
--- coreutils-6.12-orig/src/chcon.c	2008-05-26 08:40:32.000000000 +0200
3ed40da
+++ coreutils-6.12/src/chcon.c	2008-06-16 14:43:24.000000000 +0200
3ed40da
@@ -302,9 +302,11 @@ process_file (FTS *fts, FTSENT *ent)
3ed40da
 
3ed40da
   if (ok)
3ed40da
     {
3ed40da
-      if (verbose)
3ed40da
-	printf (_("changing security context of %s"),
3ed40da
+      if (verbose) {
3ed40da
+	printf (_("changing security context of %s"),
3ed40da
 		quote (file_full_name));
3ed40da
+	putchar ('\n');
3ed40da
+     }
3ed40da
 
3ed40da
       if (change_file_context (fts->fts_cwd_fd, file) != 0)
3ed40da
 	ok = false;
893c388
@@ -352,7 +352,7 @@ Usage: %s [OPTION]... CONTEXT FILE...\n\
893c388
 "),
893c388
 	program_name, program_name, program_name);
893c388
       fputs (_("\
893c388
-Change the security context of each FILE to CONTEXT.\n\
893c388
+Change the SELinux security context of each FILE to CONTEXT.\n\
893c388
 With --reference, change the security context of each FILE to that of RFILE.\n\
893c388
 \n\
46776eb
   -c, --changes          like verbose but report only when a change is made\n\
0363d66
diff -urp coreutils-6.10-orig/src/copy.c coreutils-6.10/src/copy.c
0363d66
--- coreutils-6.10-orig/src/copy.c	2008-01-05 23:59:11.000000000 +0100
0363d66
+++ coreutils-6.10/src/copy.c	2008-01-25 17:23:17.000000000 +0100
5d66c4c
@@ -371,9 +371,10 @@ copy_reg (char const *src_name, char con
0363d66
 	  security_context_t con = NULL;
0363d66
 	  if (getfscreatecon (&con) < 0)
0363d66
 	    {
0363d66
-	      error (0, errno, _("failed to get file system create context"));
0363d66
+        //do not show error when we not require security context (-a option)
0363d66
 	      if (x->require_preserve_context)
0363d66
 		{
0363d66
+      error (0, errno, _("failed to get file system create context"));
0363d66
 		  return_val = false;
0363d66
 		  goto close_src_and_dst_desc;
0363d66
 		}
5d66c4c
@@ -383,11 +384,12 @@ copy_reg (char const *src_name, char con
0363d66
 	    {
0363d66
 	      if (fsetfilecon (dest_desc, con) < 0)
0363d66
 		{
0363d66
-		  error (0, errno,
0363d66
-			 _("failed to set the security context of %s to %s"),
0363d66
-			 quote_n (0, dst_name), quote_n (1, con));
0363d66
+      //do not show error when we not require security context (-a option)
0363d66
 		  if (x->require_preserve_context)
0363d66
 		    {
0363d66
+          error (0, errno,
0363d66
+		    	 _("failed to set the security context of %s to %s"),
0363d66
+    			 quote_n (0, dst_name), quote_n (1, con));
0363d66
 		      return_val = false;
0363d66
 		      freecon (con);
0363d66
 		      goto close_src_and_dst_desc;
5d66c4c
@@ -1630,11 +1632,12 @@ copy_internal (char const *src_name, cha
0363d66
 	{
0363d66
 	  if (setfscreatecon (con) < 0)
0363d66
 	    {
0363d66
-	      error (0, errno,
0363d66
-		     _("failed to set default file creation context to %s"),
0363d66
-		     quote (con));
0363d66
+        //do not show error when we not require security context (-a option)
0363d66
 	      if (x->require_preserve_context)
0363d66
 		{
0363d66
+      error (0, errno,
0363d66
+		     _("failed to set default file creation context to %s"),
0363d66
+		     quote (con));
0363d66
 		  freecon (con);
0363d66
 		  return false;
0363d66
 		}
5d66c4c
@@ -1644,12 +1647,14 @@ copy_internal (char const *src_name, cha
0363d66
       else
0363d66
 	{
0363d66
 	  if (errno != ENOTSUP && errno != ENODATA)
0363d66
-	    {
0363d66
-	      error (0, errno,
0363d66
-		     _("failed to get security context of %s"),
0363d66
-		     quote (src_name));
0363d66
-	      if (x->require_preserve_context)
0363d66
-		return false;
0363d66
+	    { 
0363d66
+        //do not show error when we not require security context (-a option)
0363d66
+	      if (x->require_preserve_context) {
0363d66
+           error (0, errno,
0363d66
+    		   _("failed to get security context of %s"),
0363d66
+		       quote (src_name));
0363d66
+           return false;
0363d66
+        }
0363d66
 	    }
0363d66
 	}
0363d66
     }
5d66c4c
@@ -1735,6 +1740,8 @@ copy_internal (char const *src_name, cha
0363d66
 	{
0363d66
 	  /* Here, we are crossing a file system boundary and cp's -x option
0363d66
 	     is in effect: so don't copy the contents of this directory. */
0363d66
+        if (x->preserve_security_context)
0363d66
+      	    restore_default_fscreatecon_or_die ();
0363d66
 	}
0363d66
       else
0363d66
 	{
0363d66
diff -urp coreutils-6.10-orig/src/copy.h coreutils-6.10/src/copy.h
0363d66
--- coreutils-6.10-orig/src/copy.h	2008-01-05 23:58:25.000000000 +0100
0363d66
+++ coreutils-6.10/src/copy.h	2008-01-25 16:29:21.000000000 +0100
0363d66
@@ -141,6 +141,9 @@ struct cp_options
0363d66
   bool preserve_mode;
0363d66
   bool preserve_timestamps;
0363d66
 
0363d66
+  /* If true, attempt to set specified security context */
0363d66
+  bool set_security_context;
0363d66
+
0363d66
   /* Enabled for mv, and for cp by the --preserve=links option.
0363d66
      If true, attempt to preserve in the destination files any
0363d66
      logical hard links between the source files.  If used with cp's
0363d66
diff -urp coreutils-6.10-orig/src/cp.c coreutils-6.10/src/cp.c
0363d66
--- coreutils-6.10-orig/src/cp.c	2008-01-11 12:19:53.000000000 +0100
0363d66
+++ coreutils-6.10/src/cp.c	2008-01-25 16:26:22.000000000 +0100
0363d66
@@ -147,6 +147,7 @@ static struct option const long_opts[] =
0363d66
   {"target-directory", required_argument, NULL, 't'},
0363d66
   {"update", no_argument, NULL, 'u'},
0363d66
   {"verbose", no_argument, NULL, 'v'},
0363d66
+  {"context", required_argument, NULL, 'Z'},
0363d66
   {GETOPT_HELP_OPTION_DECL},
0363d66
   {GETOPT_VERSION_OPTION_DECL},
0363d66
   {NULL, 0, NULL, 0}
d476553
@@ -175,7 +175,7 @@ Copy SOURCE to DEST, or multiple SOURCE(
d476553
 Mandatory arguments to long options are mandatory for short options too.\n\
d476553
 "), stdout);
d476553
       fputs (_("\
d476553
-  -a, --archive                same as -dpR\n\
d476553
+  -a, --archive                same as -cdpR\n\
d476553
       --backup[=CONTROL]       make a backup of each existing destination file\n\
d476553
   -b                           like --backup but does not accept an argument\n\
d476553
       --copy-contents          copy contents of special files when recursive\n\
0363d66
@@ -200,6 +201,9 @@ Mandatory arguments to long options are 
0363d66
                                  additional attributes: context, links, all\n\
0363d66
 "), stdout);
0363d66
       fputs (_("\
0363d66
+  -c                           same as --preserve=context\n\
0363d66
+"), stdout);
0363d66
+      fputs (_("\
0363d66
       --no-preserve=ATTR_LIST  don't preserve the specified attributes\n\
0363d66
       --parents                use full source file name under DIRECTORY\n\
0363d66
 "), stdout);
0363d66
@@ -225,6 +229,7 @@ Mandatory arguments to long options are 
0363d66
                                  destination file is missing\n\
0363d66
   -v, --verbose                explain what is being done\n\
0363d66
   -x, --one-file-system        stay on this file system\n\
0363d66
+  -Z, --context=CONTEXT        set security context of copy to CONTEXT\n\
0363d66
 "), stdout);
0363d66
       fputs (HELP_OPTION_DESCRIPTION, stdout);
0363d66
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
0363d66
@@ -774,6 +779,7 @@ cp_option_init (struct cp_options *x)
0363d66
   x->preserve_timestamps = false;
0363d66
   x->preserve_security_context = false;
0363d66
   x->require_preserve_context = false;
0363d66
+  x->set_security_context = false;
d66c4db
 
0363d66
   x->require_preserve = false;
0363d66
   x->recursive = false;
0363d66
@@ -909,7 +917,7 @@ main (int argc, char **argv)
0363d66
      we'll actually use backup_suffix_string.  */
0363d66
   backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
d66c4db
 
0363d66
-  while ((c = getopt_long (argc, argv, "abdfHilLprst:uvxPRS:T",
146c35e
+  while ((c = getopt_long (argc, argv, "abcdfHilLprst:uvxPRS:TZ:",
0363d66
 			   long_opts, NULL))
0363d66
 	 != -1)
0363d66
     {
0363d66
@@ -920,13 +928,15 @@ main (int argc, char **argv)
0363d66
 				     sparse_type_string, sparse_type);
0363d66
 	  break;
d66c4db
 
0363d66
-	case 'a':		/* Like -dpPR. */
0363d66
+	case 'a':		/* Like -dpPRc. */
0363d66
 	  x.dereference = DEREF_NEVER;
0363d66
 	  x.preserve_links = true;
0363d66
 	  x.preserve_ownership = true;
0363d66
 	  x.preserve_mode = true;
0363d66
 	  x.preserve_timestamps = true;
0363d66
-	  x.require_preserve = true;
0363d66
+    x.require_preserve = true;
0363d66
+    if (selinux_enabled)
0363d66
+	     x.preserve_security_context = true;
0363d66
 	  x.recursive = true;
0363d66
 	  break;
d66c4db
 
0363d66
@@ -940,6 +950,16 @@ main (int argc, char **argv)
0363d66
 	  copy_contents = true;
0363d66
 	  break;
0363d66
 
0363d66
+  case 'c':
0363d66
+	  if ( x.set_security_context ) { 
0363d66
+	      (void) fprintf(stderr, "%s: cannot force target context and preserve it\n", argv[0]);
0363d66
+	    exit( 1 );
0363d66
+	  }
0363d66
+	  else if (selinux_enabled) {
0363d66
+	    x.preserve_security_context = true;
0363d66
+      x.require_preserve_context = true;
0363d66
+    }
0363d66
+	  break;
0363d66
 	case 'd':
0363d66
 	  x.preserve_links = true;
0363d66
 	  x.dereference = DEREF_NEVER;
0363d66
@@ -1052,6 +1072,27 @@ main (int argc, char **argv)
0363d66
 	  x.one_file_system = true;
0363d66
 	  break;
d66c4db
 
129baa8
+
0363d66
+  case 'Z':
0363d66
+	  /* politely decline if we're not on a selinux-enabled kernel. */
0363d66
+	  if( !selinux_enabled ) {
0363d66
+	    fprintf( stderr, "Warning:  ignoring --context (-Z). "
0363d66
+		             "It requires a SELinux enabled kernel.\n" );
0363d66
+	    break;
0363d66
+	  }
0363d66
+	  if ( x.preserve_security_context ) {
0363d66
+	    (void) fprintf(stderr, "%s: cannot force target context to '%s' and preserve it\n", argv[0], optarg);
0363d66
+	    exit( 1 );
0363d66
+	  }
0363d66
+	  x.set_security_context = true;
0363d66
+	  /* if there's a security_context given set new path 
0363d66
+	     components to that context, too */
0363d66
+	  if ( setfscreatecon(optarg) < 0 ) {
0363d66
+	    (void) fprintf(stderr, _("cannot set default security context %s\n"), optarg);
0363d66
+	    exit( 1 );
0363d66
+	  }
0363d66
+	  break;
129baa8
+
0363d66
 	case 'S':
0363d66
 	  make_backups = true;
0363d66
 	  backup_suffix_string = optarg;
0363d66
diff -urp coreutils-6.10-orig/src/id.c coreutils-6.10/src/id.c
0363d66
--- coreutils-6.10-orig/src/id.c	2008-01-05 23:59:11.000000000 +0100
0363d66
+++ coreutils-6.10/src/id.c	2008-01-25 17:13:53.000000000 +0100
0363d66
@@ -110,7 +110,7 @@ int
0363d66
 main (int argc, char **argv)
0363d66
 {
0363d66
   int optc;
0363d66
-  int selinux_enabled = (is_selinux_enabled () > 0);
0363d66
+  bool selinux_enabled = (is_selinux_enabled () > 0);
0363d66
 
0363d66
   /* If true, output the list of all group IDs. -G */
0363d66
   bool just_group_list = false;
0363d66
diff -urp coreutils-6.10-orig/src/install.c coreutils-6.10/src/install.c
0363d66
--- coreutils-6.10-orig/src/install.c	2008-01-05 23:59:11.000000000 +0100
0363d66
+++ coreutils-6.10/src/install.c	2008-01-25 17:32:42.000000000 +0100
0363d66
0363d66
@@ -146,11 +146,11 @@ static struct option const long_options[
0363d66
   {"no-target-directory", no_argument, NULL, 'T'},
0363d66
   {"owner", required_argument, NULL, 'o'},
0363d66
   {"preserve-timestamps", no_argument, NULL, 'p'},
0363d66
-  {"preserve-context", no_argument, NULL, PRESERVE_CONTEXT_OPTION},
0363d66
+  {"preserve-context", no_argument, NULL, 'P'},
0363d66
   /* Continue silent support for --preserve_context until Jan 2008. FIXME-obs
0363d66
      After that, FIXME-obs: warn in, say, late 2008, and disable altogether
0363d66
      a year or two later.  */
0363d66
-  {"preserve_context", no_argument, NULL, PRESERVE_CONTEXT_OPTION},
0363d66
+  {"preserve_context", no_argument, NULL, 'P'},
0363d66
   {"strip", no_argument, NULL, 's'},
0363d66
   {"suffix", required_argument, NULL, 'S'},
0363d66
   {"target-directory", required_argument, NULL, 't'},
0363d66
@@ -178,6 +178,7 @@ cp_option_init (struct cp_options *x)
0363d66
   x->preserve_timestamps = false;
0363d66
   x->require_preserve = false;
0363d66
   x->require_preserve_context = false;
0363d66
+  x->set_security_context = false;
0363d66
   x->recursive = false;
0363d66
   x->sparse_mode = SPARSE_AUTO;
0363d66
   x->symbolic_link = false;
6feaf70
@@ -346,7 +338,7 @@ main (int argc, char **argv)
6feaf70
      we'll actually use backup_suffix_string.  */
6feaf70
   backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
6feaf70
 
6feaf70
-  while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pt:TvS:Z:", long_options,
6feaf70
+  while ((optc = getopt_long (argc, argv, "bcsDdg:m:o:pPt:TvS:Z:", long_options,
6feaf70
 			      NULL)) != -1)
6feaf70
     {
6feaf70
       switch (optc)
0363d66
@@ -408,6 +409,7 @@ main (int argc, char **argv)
0363d66
 	  no_target_directory = true;
0363d66
 	  break;
0363d66
 
0363d66
+  case 'P':
0363d66
 	case PRESERVE_CONTEXT_OPTION:
0363d66
 	  if ( ! selinux_enabled)
0363d66
 	    {
0363d66
@@ -415,6 +417,10 @@ main (int argc, char **argv)
0363d66
 			     "this kernel is not SELinux-enabled."));
0363d66
 	      break;
0363d66
 	    }
0363d66
+    if ( x.set_security_context ) {
0363d66
+		  (void) fprintf(stderr, "%s: cannot force target context and preserve it\n", argv[0]);
0363d66
+ 	    exit( 1 );
0363d66
+ 	  }
0363d66
 	  x.preserve_security_context = true;
0363d66
 	  use_default_selinux_context = false;
0363d66
 	  break;
55707b6
@@ -432,6 +432,7 @@ main (int argc, char **argv)
55707b6
 	      break;
55707b6
 	    }
55707b6
 	  scontext = optarg;
55707b6
+	  x.set_security_context = true;
55707b6
 	  use_default_selinux_context = false;
55707b6
 	  break;
55707b6
 	case_GETOPT_HELP_CHAR;
0363d66
@@ -825,8 +831,8 @@ Mandatory arguments to long options are 
0363d66
   -v, --verbose       print the name of each directory as it is created\n\
0363d66
 "), stdout);
0363d66
       fputs (_("\
0363d66
-      --preserve-context  preserve SELinux security context\n\
0363d66
-  -Z, --context=CONTEXT  set SELinux security context of files and directories\n\
0363d66
+  -P, --preserve-context (SELinux) preserve security context\n\
0363d66
+  -Z, --context=CONTEXT  (SELinux) set security context of files and directories\n\
0363d66
 "), stdout);
d66c4db
 
0363d66
       fputs (HELP_OPTION_DESCRIPTION, stdout);
0363d66
diff -urp coreutils-6.10-orig/src/ls.c coreutils-6.10/src/ls.c
0363d66
--- coreutils-6.10-orig/src/ls.c	2008-01-11 11:34:22.000000000 +0100
0363d66
+++ coreutils-6.10/src/ls.c	2008-01-25 15:34:49.000000000 +0100
0363d66
@@ -134,7 +134,8 @@ enum filetype
d66c4db
     symbolic_link,
d66c4db
     sock,
d66c4db
     whiteout,
d66c4db
-    arg_directory
d66c4db
+    arg_directory,
d66c4db
+    command_line
d66c4db
   };
d66c4db
 
d66c4db
 /* Display letters and indicators for each filetype.
5d66c4c
@@ -177,8 +178,9 @@ struct fileinfo
5d66c4c
        exists, otherwise false.  */
5d66c4c
     bool linkok;
5d66c4c
 
5d66c4c
-    /* For long listings, true if the file has an access control list,
5d66c4c
-       or an SELinux security context.  */
5d66c4c
+    /* For long listings, true if the file has an access control list.
5d66c4c
+       Unlike with upstream not true for SELinux scontext(#430779) as
5d66c4c
+       this removes possibility to detect ACL via ls */
5d66c4c
     bool have_acl;
5d66c4c
   };
5d66c4c
 
0363d66
@@ -241,6 +242,7 @@ static void queue_directory (char const 
d66c4db
 static void sort_files (void);
d66c4db
 static void parse_ls_color (void);
d66c4db
 void usage (int status);
d66c4db
+static void print_scontext_format (const struct fileinfo *f);
d66c4db
 
d66c4db
 /* The name this program was run with.  */
d66c4db
 char *program_name;
0363d66
@@ -314,7 +316,7 @@ static struct pending *pending_dirs;
0e06139
 
0e06139
 static struct timespec current_time;
0363d66
 
0363d66
-static bool print_scontext;
0363d66
+static int print_scontext = 0;
0363d66
 static char UNKNOWN_SECURITY_CONTEXT[] = "?";
0363d66
 
0363d66
 /* Whether any of the files has an ACL.  This affects the width of the
0363d66
@@ -354,7 +356,9 @@ enum format
d66c4db
     one_per_line,		/* -1 */
d66c4db
     many_per_line,		/* -C */
d66c4db
     horizontal,			/* -x */
d66c4db
-    with_commas			/* -m */
0363d66
+    with_commas,			/* -m */
0363d66
+    security_format, /* -Z */
d66c4db
+    invalid_format
d66c4db
   };
d66c4db
 
d66c4db
 static enum format format;
0363d66
@@ -731,6 +735,9 @@ enum
d66c4db
   SHOW_CONTROL_CHARS_OPTION,
d66c4db
   SI_OPTION,
d66c4db
   SORT_OPTION,
d66c4db
+  CONTEXT_OPTION,
d66c4db
+  LCONTEXT_OPTION,
d66c4db
+  SCONTEXT_OPTION,
d66c4db
   TIME_OPTION,
d66c4db
   TIME_STYLE_OPTION
d66c4db
 };
0363d66
@@ -776,7 +783,9 @@ static struct option const long_options[
d66c4db
   {"time-style", required_argument, NULL, TIME_STYLE_OPTION},
d66c4db
   {"color", optional_argument, NULL, COLOR_OPTION},
d66c4db
   {"block-size", required_argument, NULL, BLOCK_SIZE_OPTION},
0363d66
-  {"context", no_argument, 0, 'Z'},
d66c4db
+  {"context", no_argument, 0, CONTEXT_OPTION},
d66c4db
+  {"lcontext", no_argument, 0, LCONTEXT_OPTION},
d66c4db
+  {"scontext", no_argument, 0, SCONTEXT_OPTION},
d66c4db
   {"author", no_argument, NULL, AUTHOR_OPTION},
d66c4db
   {GETOPT_HELP_OPTION_DECL},
d66c4db
   {GETOPT_VERSION_OPTION_DECL},
0363d66
@@ -786,12 +795,12 @@ static struct option const long_options[
d66c4db
 static char const *const format_args[] =
d66c4db
 {
d66c4db
   "verbose", "long", "commas", "horizontal", "across",
d66c4db
-  "vertical", "single-column", NULL
0363d66
+  "vertical", "single-column", "context", NULL
d66c4db
 };
d66c4db
 static enum format const format_types[] =
d66c4db
 {
d66c4db
   long_format, long_format, with_commas, horizontal, horizontal,
0363d66
-  many_per_line, one_per_line
0363d66
+  many_per_line, one_per_line, security_format
d66c4db
 };
d66c4db
 ARGMATCH_VERIFY (format_args, format_types);
d66c4db
 
0363d66
@@ -1236,7 +1245,7 @@ main (int argc, char **argv)
d66c4db
 
d66c4db
   format_needs_stat = sort_type == sort_time || sort_type == sort_size
d66c4db
     || format == long_format
0363d66
-    || print_scontext
d66c4db
+    || format == security_format || print_scontext
d66c4db
     || print_block_size;
d66c4db
   format_needs_type = (! format_needs_stat
d66c4db
 		       && (recursive
0363d66
@@ -1267,7 +1276,7 @@ main (int argc, char **argv)
d66c4db
     }
d66c4db
   else
d66c4db
     do
d66c4db
-      gobble_file (argv[i++], unknown, NOT_AN_INODE_NUMBER, true, "");
d66c4db
+      gobble_file (argv[i++], command_line, NOT_AN_INODE_NUMBER, true, "");
d66c4db
     while (i < argc);
d66c4db
 
bb664a7
   if (cwd_n_used)
0363d66
@@ -1429,7 +1438,7 @@ decode_switches (int argc, char **argv)
d66c4db
   ignore_mode = IGNORE_DEFAULT;
d66c4db
   ignore_patterns = NULL;
d66c4db
   hide_patterns = NULL;
0363d66
-  print_scontext = false;
0363d66
+  print_scontext = 0;
d66c4db
 
d66c4db
   /* FIXME: put this in a function.  */
d66c4db
   {
0363d66
@@ -1811,13 +1820,27 @@ decode_switches (int argc, char **argv)
d66c4db
 	  break;
d66c4db
 
0363d66
 	case 'Z':
0363d66
-	  print_scontext = true;
d66c4db
+	  print_scontext = 1;
0363d66
+    format = security_format;
0363d66
 	  break;
0363d66
 
0363d66
 	case_GETOPT_HELP_CHAR;
d66c4db
 
d66c4db
 	case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
d66c4db
 
0363d66
+  case CONTEXT_OPTION: /* default security context format */
d66c4db
+		print_scontext = 1;
d66c4db
+		format = security_format;
d66c4db
+		break;
d66c4db
+	case LCONTEXT_OPTION: /* long format plus security context */
d66c4db
+		print_scontext = 1;
d66c4db
+		format = long_format;
d66c4db
+		break;
d66c4db
+	case SCONTEXT_OPTION: /* short form of new security format */
d66c4db
+		print_scontext = 0;
d66c4db
+		format = security_format;
d66c4db
+		break;
5505e28
+
d66c4db
 	default:
d66c4db
 	  usage (LS_FAILURE);
d66c4db
 	}
0363d66
@@ -2517,8 +2540,10 @@ clear_files (void)
bb664a7
       struct fileinfo *f = sorted_file[i];
bb664a7
       free (f->name);
bb664a7
       free (f->linkname);
0363d66
-      if (f->scontext != UNKNOWN_SECURITY_CONTEXT)
0363d66
-	freecon (f->scontext);
0363d66
+      if (f->scontext != UNKNOWN_SECURITY_CONTEXT) {
0363d66
+       	freecon (f->scontext);
0363d66
+        f->scontext = NULL;
0363d66
+      }
d66c4db
     }
0363d66
 
0363d66
   cwd_n_used = 0;
0363d66
@@ -2560,6 +2585,7 @@ gobble_file (char const *name, enum file
d66c4db
   memset (f, '\0', sizeof *f);
d66c4db
   f->stat.st_ino = inode;
d66c4db
   f->filetype = type;
d66c4db
+  f->scontext = NULL;
d66c4db
 
d66c4db
   if (command_line_arg
d66c4db
       || format_needs_stat
0363d66
@@ -2659,7 +2685,7 @@ gobble_file (char const *name, enum file
0363d66
 
3275244
       f->stat_ok = true;
d66c4db
 
0363d66
-      if (format == long_format || print_scontext)
98cf8da
+      if (format == long_format || format == security_format || print_scontext)
d66c4db
 	{
0363d66
 	  bool have_acl = false;
0363d66
 	  int attr_len = (do_deref
5d66c4c
@@ -2667,9 +2694,7 @@ gobble_file (char const *name, enum file
0e06139
 	      f->scontext = xstrdup ("unlabeled");
0e06139
 	    }
5d66c4c
 
5d66c4c
-	  if (err == 0)
5d66c4c
-	    have_acl = ! STREQ ("unlabeled", f->scontext);
5d66c4c
-	  else
5d66c4c
+	  if (err != 0)
5d66c4c
 	    {
5d66c4c
 	      f->scontext = UNKNOWN_SECURITY_CONTEXT;
5d66c4c
 
5d66c4c
@@ -2681,7 +2706,7 @@ gobble_file (char const *name, enum file
5d66c4c
 		err = 0;
5d66c4c
 	    }
5d66c4c
 
5d66c4c
-	  if (err == 0 && ! have_acl && format == long_format)
5d66c4c
+	  if (err == 0 && format == long_format)
5d66c4c
 	    {
5d66c4c
 	      int n = file_has_acl (absolute_name, &f->stat);
5d66c4c
 	      err = (n < 0);
0363d66
@@ -3255,6 +3281,13 @@ print_current_files (void)
0363d66
 	  print_long_format (sorted_file[i]);
d66c4db
 	  DIRED_PUTCHAR ('\n');
d66c4db
 	}
0363d66
+     break;
d66c4db
+    case security_format:
bb664a7
+      for (i = 0; i < cwd_n_used; i++)
d66c4db
+      {
bb664a7
+        print_scontext_format (sorted_file[i]);
d66c4db
+        DIRED_PUTCHAR ('\n');
d66c4db
+      }
0363d66
       break;
d66c4db
     }
d66c4db
 }
0363d66
@@ -3481,7 +3514,7 @@ print_long_format (const struct fileinfo
0363d66
 	 The latter is wrong when inode_number_width is zero.  */
0363d66
       p += strlen (p);
0363d66
     }
0363d66
-
0363d66
+  
0363d66
   if (print_block_size)
0363d66
     {
0363d66
       char hbuf[LONGEST_HUMAN_READABLE + 1];
0363d66
@@ -3510,9 +3543,15 @@ print_long_format (const struct fileinfo
d66c4db
      The latter is wrong when nlink_width is zero.  */
d66c4db
   p += strlen (p);
d66c4db
 
d66c4db
+  if (print_scontext)
5505e28
+    {
d66c4db
+      sprintf (p, "%-32s ", f->scontext ? f->scontext : "");
d66c4db
+      p += strlen (p);
5505e28
+    }
5505e28
+
d66c4db
   DIRED_INDENT ();
d66c4db
 
0363d66
-  if (print_owner | print_group | print_author | print_scontext)
0363d66
+  if (print_owner | print_group | print_author)
0363d66
     {
0363d66
       DIRED_FPUTS (buf, stdout, p - buf);
0363d66
 
0363d66
@@ -3525,9 +3564,6 @@ print_long_format (const struct fileinfo
0363d66
       if (print_author)
0363d66
 	format_user (f->stat.st_author, author_width, f->stat_ok);
0363d66
 
0363d66
-      if (print_scontext)
0363d66
-	format_user_or_group (f->scontext, 0, scontext_width);
0363d66
-
0363d66
       p = buf;
0363d66
     }
0363d66
 
0363d66
@@ -3864,9 +3900,6 @@ print_file_name_and_frills (const struct
0363d66
 	    human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts,
0363d66
 			    ST_NBLOCKSIZE, output_block_size));
0363d66
 
0363d66
-  if (print_scontext)
0363d66
-    printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
0363d66
-
0363d66
   print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok,
0363d66
 			   f->stat_ok, f->filetype, NULL);
0363d66
 
0363d66
@@ -4030,9 +4063,6 @@ length_of_file_name_and_frills (const st
0363d66
 					  output_block_size))
0363d66
 		: block_size_width);
0363d66
 
0363d66
-  if (print_scontext)
0363d66
-    len += 1 + (format == with_commas ? strlen (f->scontext) : scontext_width);
0363d66
-
0363d66
   quote_name (NULL, f->name, filename_quoting_options, &name_width);
0363d66
   len += name_width;
0363d66
 
0363d66
@@ -4461,9 +4491,16 @@ Mandatory arguments to long options are 
0363d66
   -w, --width=COLS           assume screen width instead of current value\n\
0363d66
   -x                         list entries by lines instead of by columns\n\
d66c4db
   -X                         sort alphabetically by entry extension\n\
0363d66
-  -Z, --context              print any SELinux security context of each file\n\
d66c4db
   -1                         list one file per line\n\
d66c4db
 "), stdout);
893c388
+      fputs(_("\nSELinux options:\n\n\
0363d66
+  --lcontext                 Display security context.   Enable -l. Lines\n\
0363d66
+                             will probably be too wide for most displays.\n\
0363d66
+  -Z, --context              Display security context so it fits on most\n\
0363d66
+                             displays.  Displays only mode, user, group,\n\
0363d66
+                             security context and file name.\n\
0363d66
+  --scontext                 Display only security context and file name.\n\
0363d66
+"), stdout);
d66c4db
       fputs (HELP_OPTION_DESCRIPTION, stdout);
d66c4db
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
d66c4db
       fputs (_("\n\
0363d66
@@ -4487,3 +4524,67 @@ Exit status is 0 if OK, 1 if minor probl
d66c4db
     }
d66c4db
   exit (status);
d66c4db
 }
5505e28
+
d66c4db
+static void
d66c4db
+print_scontext_format (const struct fileinfo *f)
d66c4db
+{
d66c4db
+  char modebuf[12];
5505e28
+
d66c4db
+  /* 7 fields that may require LONGEST_HUMAN_READABLE bytes,
d66c4db
+     1 10-byte mode string,
d66c4db
+     9 spaces, one following each of these fields, and
d66c4db
+     1 trailing NUL byte.  */
129baa8
+
d66c4db
+  char init_bigbuf[7 * LONGEST_HUMAN_READABLE + 10  + 9 + 1];
d66c4db
+  char *buf = init_bigbuf;
d66c4db
+  size_t bufsize = sizeof (init_bigbuf);
d66c4db
+  size_t s;
d66c4db
+  char *p;
d66c4db
+  const char *fmt;
d66c4db
+  char *user_name;
d66c4db
+  char *group_name;
d66c4db
+  int rv;
d66c4db
+  char *scontext;
129baa8
+
d66c4db
+  p = buf;
129baa8
+
d66c4db
+  if ( print_scontext ) { /* zero means terse listing */
d66c4db
+    filemodestring (&f->stat, modebuf);
0363d66
+    modebuf[10] = (f->have_acl ? '+' : ' ');
d66c4db
+    modebuf[11] = '\0';
129baa8
+
d66c4db
+    /* print mode */
129baa8
+
d66c4db
+    (void) sprintf (p, "%s ", modebuf);
d66c4db
+    p += strlen (p);
cvsdist 5adf0da
+
d66c4db
+    /* print standard user and group */
5505e28
+
d66c4db
+    DIRED_FPUTS (buf, stdout, p - buf);
d66c4db
+    format_user (f->stat.st_uid, owner_width, f->stat_ok);
d66c4db
+    format_group (f->stat.st_gid, group_width, f->stat_ok);
d66c4db
+    p = buf;
5505e28
+  }
5505e28
+
d66c4db
+  (void) sprintf (p, "%-32s ", f->scontext ?: "");
d66c4db
+  p += strlen (p);
d66c4db
+ 
d66c4db
+  DIRED_INDENT ();
d66c4db
+  DIRED_FPUTS (buf, stdout, p - buf);
d66c4db
+  print_name_with_quoting (f->name, f->stat.st_mode, f->linkok,
d66c4db
+			   f->stat_ok, f->filetype, &dired_obstack);
d66c4db
+ 
d66c4db
+  if (f->filetype == symbolic_link) {
d66c4db
+      if (f->linkname) {
d66c4db
+	  DIRED_FPUTS_LITERAL (" -> ", stdout);
d66c4db
+	  print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1,
d66c4db
+				   f->stat_ok, f->filetype, NULL);
d66c4db
+	  if (indicator_style != none)
d66c4db
+	    print_type_indicator (f->stat_ok, f->linkmode, f->filetype);
d66c4db
+      }
5505e28
+  }
d66c4db
+  else {
d66c4db
+    if (indicator_style != none)
d66c4db
+      print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
5505e28
+  }
cvsdist 4d15f3c
+}
0363d66
diff -urp coreutils-6.10-orig/src/mkdir.c coreutils-6.10/src/mkdir.c
0363d66
--- coreutils-6.10-orig/src/mkdir.c	2008-01-05 23:58:25.000000000 +0100
0363d66
+++ coreutils-6.10/src/mkdir.c	2008-01-25 16:35:14.000000000 +0100
0363d66
@@ -41,6 +41,7 @@ char *program_name;
0363d66
 static struct option const longopts[] =
0363d66
 {
0363d66
   {GETOPT_SELINUX_CONTEXT_OPTION_DECL},
5505e28
+  {"context", required_argument, NULL, 'Z'},
0363d66
   {"mode", required_argument, NULL, 'm'},
0363d66
   {"parents", no_argument, NULL, 'p'},
0363d66
   {"verbose", no_argument, NULL, 'v'},
0363d66
diff -urp coreutils-6.10-orig/src/mknod.c coreutils-6.10/src/mknod.c
0363d66
--- coreutils-6.10-orig/src/mknod.c	2008-01-05 23:58:25.000000000 +0100
0363d66
+++ coreutils-6.10/src/mknod.c	2008-01-25 17:01:11.000000000 +0100
0363d66
@@ -38,7 +38,7 @@ char *program_name;
5505e28
 
0363d66
 static struct option const longopts[] =
0363d66
 {
0363d66
-  {GETOPT_SELINUX_CONTEXT_OPTION_DECL},
0363d66
+  {GETOPT_SELINUX_CONTEXT_OPTION_DECL}, 
0363d66
   {"mode", required_argument, NULL, 'm'},
0363d66
   {GETOPT_HELP_OPTION_DECL},
0363d66
   {GETOPT_VERSION_OPTION_DECL},
0363d66
diff -urp coreutils-6.10-orig/src/mv.c coreutils-6.10/src/mv.c
0363d66
--- coreutils-6.10-orig/src/mv.c	2008-01-05 23:59:11.000000000 +0100
0363d66
+++ coreutils-6.10/src/mv.c	2008-01-25 17:11:50.000000000 +0100
0363d66
@@ -137,6 +137,7 @@ cp_option_init (struct cp_options *x)
0363d66
   x->preserve_mode = true;
0363d66
   x->preserve_timestamps = true;
0363d66
   x->preserve_security_context = selinux_enabled;
0363d66
+  x->set_security_context = false;
0363d66
   x->require_preserve = false;  /* FIXME: maybe make this an option */
0363d66
   x->require_preserve_context = false;
0363d66
   x->recursive = true;
893c388
diff -urNp coreutils-6.12-orig/src/runcon.c coreutils-6.12/src/runcon.c
893c388
--- coreutils-6.12-orig/src/runcon.c	2008-05-26 12:10:20.000000000 +0200
893c388
+++ coreutils-6.12/src/runcon.c	2008-10-21 15:57:30.000000000 +0200
893c388
@@ -88,7 +88,7 @@ Usage: %s CONTEXT COMMAND [args]\n\
893c388
   or:  %s [ -c ] [-u USER] [-r ROLE] [-t TYPE] [-l RANGE] COMMAND [args]\n\
893c388
 "), program_name, program_name);
893c388
       fputs (_("\
893c388
-Run a program in a different security context.\n\
893c388
+Run a program in a different SELinux security context.\n\
893c388
 With neither CONTEXT nor COMMAND, print the current security context.\n\
893c388
 \n\
893c388
   CONTEXT            Complete security context\n\
0363d66
diff -urp coreutils-6.10-orig/src/stat.c coreutils-6.10/src/stat.c
0363d66
--- coreutils-6.10-orig/src/stat.c	2008-01-05 23:59:11.000000000 +0100
0363d66
+++ coreutils-6.10/src/stat.c	2008-01-25 16:50:24.000000000 +0100
0363d66
@@ -831,7 +831,7 @@ print_it (char const *format, char const
5505e28
 
0363d66
 /* Stat the file system and print what we find.  */
0363d66
 static bool
0363d66
-do_statfs (char const *filename, bool terse, char const *format)
0363d66
+do_statfs (char const *filename, bool terse, bool secure, char const *format)
0363d66
 {
0363d66
   STRUCT_STATVFS statfsbuf;
5505e28
 
0363d66
@@ -843,15 +843,31 @@ do_statfs (char const *filename, bool te
0363d66
     }
5505e28
 
0363d66
   if (format == NULL)
0363d66
+  {
0363d66
+    if (terse)
5505e28
     {
0363d66
-      format = (terse
0363d66
-		? "%n %i %l %t %s %S %b %f %a %c %d\n"
0363d66
-		: "  File: \"%n\"\n"
0363d66
-		"    ID: %-8i Namelen: %-7l Type: %T\n"
0363d66
-		"Block size: %-10s Fundamental block size: %S\n"
0363d66
-		"Blocks: Total: %-10b Free: %-10f Available: %a\n"
0363d66
-		"Inodes: Total: %-10c Free: %d\n");
0363d66
+      if (secure)
0363d66
+        format = "%n %i %l %t %s %S %b %f %a %c %d %C\n";
0363d66
+   	  else
0363d66
+	      format = "%n %i %l %t %s %S %b %f %a %c %d\n";
0363d66
     }
0363d66
+    else
0363d66
+  	{
0363d66
+	    if (secure)
0363d66
+	      format = "  File: \"%n\"\n"
0363d66
+	        "    ID: %-8i Namelen: %-7l Type: %T\n"
0363d66
+  	      "Block size: %-10s Fundamental block size: %S\n"
0363d66
+	        "Blocks: Total: %-10b Free: %-10f Available: %a\n"
0363d66
+	        "Inodes: Total: %-10c Free: %d\n"
0363d66
+	        "   S_Context: %C\n";
0363d66
+  	  else
0363d66
+	      format = "  File: \"%n\"\n"
0363d66
+	        "    ID: %-8i Namelen: %-7l Type: %T\n"
0363d66
+	        "Block size: %-10s Fundamental block size: %S\n"
0363d66
+	        "Blocks: Total: %-10b Free: %-10f Available: %a\n"
0363d66
+  	      "Inodes: Total: %-10c Free: %d\n";
0363d66
+     }
0363d66
+  }
b9e1cc9
 
0363d66
   print_it (format, filename, print_statfs, &statfsbuf);
0363d66
   return true;
0363d66
@@ -859,7 +875,7 @@ do_statfs (char const *filename, bool te
5505e28
 
0363d66
 /* stat the file and print what we find */
0363d66
 static bool
0363d66
-do_stat (char const *filename, bool terse, char const *format)
1ecd64d
+do_stat (char const *filename, bool terse, bool secure, char const *format)
0363d66
 {
0363d66
   struct stat statbuf;
5505e28
 
0363d66
@@ -872,9 +888,12 @@ do_stat (char const *filename, bool ters
0363d66
   if (format == NULL)
0363d66
     {
0363d66
       if (terse)
0363d66
-	{
0363d66
-	  format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n";
0363d66
-	}
0363d66
+      {
0363d66
+        if (secure)
0363d66
+  	     format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n";
0363d66
+  	   else
0363d66
+	       format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n";
0363d66
+      }
0363d66
       else
0363d66
 	{
0363d66
 	  /* Temporary hack to match original output until conditional
0363d66
@@ -891,12 +910,22 @@ do_stat (char const *filename, bool ters
0363d66
 	    }
0363d66
 	  else
0363d66
 	    {
0363d66
-	      format =
0363d66
-		"  File: %N\n"
0363d66
-		"  Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
0363d66
-		"Device: %Dh/%dd\tInode: %-10i  Links: %h\n"
0363d66
-		"Access: (%04a/%10.10A)  Uid: (%5u/%8U)   Gid: (%5g/%8G)\n"
0363d66
-		"Access: %x\n" "Modify: %y\n" "Change: %z\n";
0363d66
+        if (secure)
0363d66
+           format =
0363d66
+  		  "  File: %N\n"
0363d66
+	  	  "  Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
0363d66
+  		  "Device: %Dh/%dd\tInode: %-10i  Links: %-5h"
0363d66
+	  	  " Device type: %t,%T\n"
0363d66
+ 		    "Access: (%04a/%10.10A)  Uid: (%5u/%8U)   Gid: (%5g/%8G)\n"
0363d66
+  		  "   S_Context: %C\n"
0363d66
+	  	  "Access: %x\n" "Modify: %y\n" "Change: %z\n";
0363d66
+        else 
0363d66
+	        format =
0363d66
+    		"  File: %N\n"
0363d66
+	    	"  Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
0363d66
+  	  	"Device: %Dh/%dd\tInode: %-10i  Links: %h\n"
0363d66
+  	  	"Access: (%04a/%10.10A)  Uid: (%5u/%8U)   Gid: (%5g/%8G)\n"
0363d66
+    		"Access: %x\n" "Modify: %y\n" "Change: %z\n";
0363d66
 	    }
0363d66
 	}
0363d66
     }
0363d66
@@ -917,6 +946,7 @@ usage (int status)
0363d66
 Display file or file system status.\n\
0363d66
 \n\
0363d66
   -L, --dereference     follow links\n\
0363d66
+  -Z, --context         print the SELinux security context \n\
0363d66
   -f, --file-system     display file system status instead of file status\n\
0363d66
 "), stdout);
0363d66
       fputs (_("\
0363d66
@@ -1001,6 +1031,7 @@ main (int argc, char *argv[])
0363d66
   int i;
0363d66
   bool fs = false;
0363d66
   bool terse = false;
0363d66
+  bool secure = false;
0363d66
   char *format = NULL;
0363d66
   bool ok = true;
5505e28
 
0363d66
@@ -1040,9 +1071,13 @@ main (int argc, char *argv[])
0363d66
 	  terse = true;
0363d66
 	  break;
5505e28
 
0363d66
-	case 'Z':  /* FIXME: remove in 2010, warn in mid 2008 */
0363d66
-	  /* Ignored, for compatibility with distributions
0363d66
-	     that implemented this before upstream.  */
0363d66
+	case 'Z':  
0363d66
+    if((is_selinux_enabled()>0))
0363d66
+	    secure = 1;
0363d66
+	  else {
0363d66
+	    error (0, 0, _("Kernel is not SELinux enabled"));
0363d66
+	    usage (EXIT_FAILURE);
0363d66
+	  }
0363d66
 	  break;
5505e28
 
0363d66
 	case_GETOPT_HELP_CHAR;
0363d66
@@ -1062,8 +1097,8 @@ main (int argc, char *argv[])
129baa8
 
5505e28
   for (i = optind; i < argc; i++)
5505e28
     ok &= (fs
5505e28
-	   ? do_statfs (argv[i], terse, format)
0363d66
-	   : do_stat (argv[i], terse, format));
5505e28
+	   ? do_statfs (argv[i], terse, secure, format)
0363d66
+	   : do_stat (argv[i], terse, secure, format));
5505e28
 
5505e28
   exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
5505e28
 }
0363d66
diff -urp coreutils-6.10-orig/tests/misc/selinux coreutils-6.10/tests/misc/selinux
0363d66
--- coreutils-6.10-orig/tests/misc/selinux	2008-01-11 11:34:22.000000000 +0100
0363d66
+++ coreutils-6.10/tests/misc/selinux	2008-01-25 18:17:59.000000000 +0100
5d66c4c
@@ -32,12 +32,10 @@ chcon $ctx f d p 2>/dev/null || {
0363d66
 
0363d66
 # inspect that context with both ls -Z and stat.
0363d66
 for i in d f p; do
0363d66
-  c=`ls -dogZ $i|cut -d' ' -f3`; test x$c = x$ctx || fail=1
5d66c4c
+  c=`ls -dogZ $i|cut -d' ' -f5`; test x$c = x$ctx || fail=1
0363d66
   c=`stat --printf %C $i`; test x$c = x$ctx || fail=1
0363d66
 done
5d66c4c
5d66c4c
-# ensure that ls -l output includes the "+".
5d66c4c
-c=`ls -l f|cut -c11`; test "$c" = + || fail=1
5d66c4c
5d66c4c
 # Copy each to a new directory and ensure that context is preserved.
5d66c4c
 cp -r --preserve=all d f p s1 || fail=1