Blame SOURCES/coreutils-selinux.patch

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