Blame SOURCES/coreutils-selinux.patch

e63663
diff --git a/man/chcon.x b/man/chcon.x
e63663
index 8c1ff6f..c84fb96 100644
e63663
--- a/man/chcon.x
e63663
+++ b/man/chcon.x
e63663
@@ -1,4 +1,4 @@
e63663
 [NAME]
e63663
-chcon \- change file security context
e63663
+chcon \- change file SELinux security context
e63663
 [DESCRIPTION]
e63663
 .\" Add any additional description here
e63663
diff --git a/man/runcon.x b/man/runcon.x
e63663
index d2df13e..5c5f5d8 100644
e63663
--- a/man/runcon.x
e63663
+++ b/man/runcon.x
e63663
@@ -1,5 +1,5 @@
e63663
 [NAME]
e63663
-runcon \- run command with specified security context
e63663
+runcon \- run command with specified SELinux security context
e63663
 [DESCRIPTION]
e63663
 Run COMMAND with completely-specified CONTEXT, or with current or
e63663
 transitioned security context modified by one or more of LEVEL,
e63663
diff --git a/src/cp.c b/src/cp.c
e63663
index 1b528c6..25dbb88 100644
e63663
--- a/src/cp.c
e63663
+++ b/src/cp.c
e63663
@@ -203,6 +203,9 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
e63663
                                  all\n\
e63663
 "), stdout);
e63663
       fputs (_("\
e63663
+  -c                           deprecated, same as --preserve=context\n\
e63663
+"), stdout);
e63663
+      fputs (_("\
e63663
       --no-preserve=ATTR_LIST  don't preserve the specified attributes\n\
e63663
       --parents                use full source file name under DIRECTORY\n\
e63663
 "), stdout);
e63663
@@ -929,7 +932,7 @@ main (int argc, char **argv)
e63663
   selinux_enabled = (0 < is_selinux_enabled ());
e63663
   cp_option_init (&x);
e63663
 
e63663
-  while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ",
e63663
+  while ((c = getopt_long (argc, argv, "abcdfHilLnprst:uvxPRS:TZ",
e63663
                            long_opts, NULL))
e63663
          != -1)
e63663
     {
e63663
@@ -977,6 +980,17 @@ main (int argc, char **argv)
e63663
           copy_contents = true;
e63663
           break;
e63663
 
e63663
+        case 'c':
e63663
+          fprintf (stderr, "%s: warning: option '-c' is deprecated, please use '--preserve=context' instead\n", argv[0]);
e63663
+          if ( x.set_security_context ) {
e63663
+              (void) fprintf(stderr, "%s: cannot force target context and preserve it\n", argv[0]);
e63663
+             exit( 1 );
e63663
+           }
e63663
+           else if (selinux_enabled) {
e63663
+              x.preserve_security_context = true;
e63663
+              x.require_preserve_context = true;
e63663
+           }
e63663
+          break;
e63663
         case 'd':
e63663
           x.preserve_links = true;
e63663
           x.dereference = DEREF_NEVER;
e63663
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
e63663
index 47e4480..cff2ead 100644
e63663
--- a/doc/coreutils.texi
e63663
+++ b/doc/coreutils.texi
e63663
@@ -8083,6 +8083,11 @@ done
e63663
 exit $fail
e63663
 @end example
e63663
 
e63663
+@item -c
e63663
+@cindex SELinux security context information, preserving
e63663
+Preserve SELinux security context of the original files if possible.
e63663
+Some file systems don't support storing of SELinux security context.
e63663
+
e63663
 @item --copy-contents
e63663
 @cindex directories, copying recursively
e63663
 @cindex copying directories recursively
e63663
diff --git a/src/install.c b/src/install.c
e63663
index d79d597..437889a 100644
e63663
--- a/src/install.c
e63663
+++ b/src/install.c
e63663
@@ -673,7 +673,7 @@ In the 4th form, create all components of the given DIRECTORY(ies).\n\
e63663
   -v, --verbose       print the name of each directory as it is created\n\
e63663
 "), stdout);
e63663
       fputs (_("\
e63663
-      --preserve-context  preserve SELinux security context\n\
e63663
+  -P, --preserve-context  preserve SELinux security context (-P deprecated)\n\
e63663
   -Z                      set SELinux security context of destination\n\
e63663
                             file and each created directory to default type\n\
e63663
       --context[=CTX]     like -Z, or if CTX is specified then set the\n\
e63663
@@ -824,7 +824,7 @@ main (int argc, char **argv)
e63663
   dir_arg = false;
e63663
   umask (0);
e63663
 
e63663
-  while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z", long_options,
e63663
+  while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pPt:TvS:Z", long_options,
e63663
                               NULL)) != -1)
e63663
     {
e63663
       switch (optc)
e63663
@@ -885,6 +885,8 @@ main (int argc, char **argv)
e63663
           no_target_directory = true;
e63663
           break;
e63663
 
e63663
+        case 'P':
e63663
+          fprintf (stderr, "%s: warning: option '-P' is deprecated, please use '--preserve-context' instead\n", argv[0]);
e63663
         case PRESERVE_CONTEXT_OPTION:
e63663
           if (! selinux_enabled)
e63663
             {
e63663
@@ -892,6 +894,10 @@ main (int argc, char **argv)
e63663
                              "this kernel is not SELinux-enabled"));
e63663
               break;
e63663
             }
e63663
+          if ( x.set_security_context ) {
e63663
+             (void) fprintf(stderr, "%s: cannot force target context and preserve it\n", argv[0]);
e63663
+             exit( 1 );
e63663
+          }
e63663
           x.preserve_security_context = true;
e63663
           use_default_selinux_context = false;
e63663
           break;