Lukáš Zaoral ec87f8
From fc96cab095d704e8bf9934812dd8d6f87fbf4be4 Mon Sep 17 00:00:00 2001
Kamil Dudka baf644
From: rpm-build <rpm-build>
Lukáš Zaoral bf0817
Date: Wed, 30 Aug 2023 17:19:58 +0200
Kamil Dudka baf644
Subject: [PATCH] coreutils-selinux.patch
Kamil Dudka baf644
Kamil Dudka baf644
---
Kamil Dudka 9d8502
 src/cp.c      | 19 ++++++++++++++++++-
Kamil Dudka 9d8502
 src/install.c | 12 +++++++++++-
Kamil Dudka 9d8502
 2 files changed, 29 insertions(+), 2 deletions(-)
Kamil Dudka baf644
Kamil Dudka 8d9eac
diff --git a/src/cp.c b/src/cp.c
Lukáš Zaoral ec87f8
index a0ec067..1169c6a 100644
Kamil Dudka 8d9eac
--- a/src/cp.c
Kamil Dudka 8d9eac
+++ b/src/cp.c
Lukáš Zaoral ec87f8
@@ -996,7 +996,7 @@ main (int argc, char **argv)
Kamil Dudka 8d9eac
   selinux_enabled = (0 < is_selinux_enabled ());
Kamil Dudka 8d9eac
   cp_option_init (&x);
Ondrej Vasik 66a4fe
 
Ondřej Vašík bb33bc
-  while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ",
Ondřej Vašík bb33bc
+  while ((c = getopt_long (argc, argv, "abcdfHilLnprst:uvxPRS:TZ",
Lukáš Zaoral bf0817
                            long_opts, nullptr))
Ondrej Vasik 66a4fe
          != -1)
Ondrej Vasik 66a4fe
     {
Lukáš Zaoral ec87f8
@@ -1048,6 +1048,23 @@ main (int argc, char **argv)
Ondrej Vasik 66a4fe
           copy_contents = true;
Ondrej Vasik 66a4fe
           break;
Ondrej Vasik 66a4fe
 
Ondrej Vasik 66a4fe
+        case 'c':
Kamil Dudka 9d8502
+          fprintf (stderr, "%s: warning: option '-c' is deprecated,"
Kamil Dudka 9d8502
+                  " please use '--preserve=context' instead\n", argv[0]);
Kamil Dudka 9d8502
+          if (x.set_security_context)
Kamil Dudka 9d8502
+            {
Kamil Dudka 9d8502
+              fprintf (stderr,
Kamil Dudka 9d8502
+                      "%s: cannot force target context and preserve it\n",
Kamil Dudka 9d8502
+                      argv[0]);
Kamil Dudka 9d8502
+              exit (1);
Kamil Dudka 9d8502
+            }
Kamil Dudka 9d8502
+          else if (selinux_enabled)
Kamil Dudka 9d8502
+            {
Ondrej Vasik 66a4fe
+              x.preserve_security_context = true;
Ondrej Vasik 66a4fe
+              x.require_preserve_context = true;
Kamil Dudka 9d8502
+            }
Ondrej Vasik 66a4fe
+          break;
Kamil Dudka 9d8502
+
Ondrej Vasik 66a4fe
         case 'd':
Ondrej Vasik 66a4fe
           x.preserve_links = true;
Ondrej Vasik 66a4fe
           x.dereference = DEREF_NEVER;
Kamil Dudka 8d9eac
diff --git a/src/install.c b/src/install.c
Lukáš Zaoral ec87f8
index b3b26ab..2d2f072 100644
Kamil Dudka 8d9eac
--- a/src/install.c
Kamil Dudka 8d9eac
+++ b/src/install.c
Lukáš Zaoral bf0817
@@ -807,7 +807,7 @@ main (int argc, char **argv)
Kamil Dudka 8d9eac
   dir_arg = false;
Kamil Dudka 8d9eac
   umask (0);
Ondrej Vasik 66a4fe
 
Ondřej Vašík bb33bc
-  while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z", long_options,
Ondřej Vašík bb33bc
+  while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pPt:TvS:Z", long_options,
Lukáš Zaoral bf0817
                               nullptr))
Lukáš Zaoral bf0817
          != -1)
Ondrej Vasik 66a4fe
     {
Lukáš Zaoral bf0817
@@ -872,6 +872,9 @@ main (int argc, char **argv)
Ondřej Vašík 50a3ba
           no_target_directory = true;
Ondřej Vašík 50a3ba
           break;
Ondřej Vašík 50a3ba
 
Ondrej Vasik 66a4fe
+        case 'P':
Kamil Dudka 9d8502
+          fprintf (stderr, "%s: warning: option '-P' is deprecated,"
Kamil Dudka 9d8502
+                  " please use '--preserve-context' instead\n", argv[0]);
Ondrej Vasik 66a4fe
         case PRESERVE_CONTEXT_OPTION:
Ondřej Vašík bb33bc
           if (! selinux_enabled)
Ondrej Vasik 66a4fe
             {
Lukáš Zaoral bf0817
@@ -879,6 +882,13 @@ main (int argc, char **argv)
Ondrej Vasik 66a4fe
                              "this kernel is not SELinux-enabled"));
Ondrej Vasik 66a4fe
               break;
Ondrej Vasik 66a4fe
             }
Kamil Dudka 9d8502
+          if (x.set_security_context)
Kamil Dudka 9d8502
+            {
Kamil Dudka 9d8502
+              fprintf (stderr,
Kamil Dudka 9d8502
+                      "%s: cannot force target context and preserve it\n",
Kamil Dudka 9d8502
+                      argv[0]);
Kamil Dudka 9d8502
+              exit (1);
Kamil Dudka 9d8502
+            }
Ondrej Vasik 66a4fe
           x.preserve_security_context = true;
Ondrej Vasik 66a4fe
           use_default_selinux_context = false;
Ondrej Vasik 66a4fe
           break;
Kamil Dudka baf644
-- 
Lukáš Zaoral ec87f8
2.48.1
Kamil Dudka baf644