- Fix 'cp -Z' when the destination exists (bug #189967).

This commit is contained in:
Tim Waugh 2006-04-26 11:02:25 +00:00
parent 49a3f898a6
commit 67916194fb
2 changed files with 36 additions and 7 deletions

View File

@ -2245,8 +2245,8 @@
+ } + }
+#endif +#endif
} }
--- coreutils-5.94/src/copy.c.selinux 2006-03-24 13:23:39.000000000 +0000 --- coreutils-5.94/src/copy.c 2006-03-24 13:23:45.000000000 +0000
+++ coreutils-5.94/src/copy.c 2006-03-24 13:23:45.000000000 +0000 +++ coreutils-5.94/src/copy.c 2006-04-26 14:06:02.000000000 +1000
@@ -51,6 +51,11 @@ @@ -51,6 +51,11 @@
#include "xreadlink.h" #include "xreadlink.h"
#include "yesno.h" #include "yesno.h"
@ -2259,7 +2259,33 @@
#ifndef HAVE_FCHMOD #ifndef HAVE_FCHMOD
# define HAVE_FCHMOD false # define HAVE_FCHMOD false
#endif #endif
@@ -1416,6 +1421,32 @@ @@ -238,6 +243,25 @@
{
dest_desc = open (dst_name, O_WRONLY | O_TRUNC | O_BINARY, dst_mode);
+#ifdef WITH_SELINUX
+ if (dest_desc >= 0)
+ {
+ security_context_t con;
+ if(getfscreatecon(&con) == -1)
+ {
+ return_val = false;
+ goto close_src_desc;
+ }
+ if(fsetfilecon(dest_desc, con) == -1)
+ {
+ return_val = false;
+ freecon(con);
+ goto close_src_desc;
+ }
+ freecon(con);
+ }
+#endif
+
if (dest_desc < 0 && x->unlink_dest_after_failed_open)
{
if (unlink (dst_name) != 0)
@@ -1416,6 +1440,32 @@
In such cases, set this variable to zero. */ In such cases, set this variable to zero. */
preserve_metadata = true; preserve_metadata = true;
@ -2292,7 +2318,7 @@
if (S_ISDIR (src_mode)) if (S_ISDIR (src_mode))
{ {
struct dir_list *dir; struct dir_list *dir;
@@ -1486,7 +1517,13 @@ @@ -1486,7 +1536,13 @@
/* Are we crossing a file system boundary? */ /* Are we crossing a file system boundary? */
if (x->one_file_system && device != 0 && device != src_sb.st_dev) if (x->one_file_system && device != 0 && device != src_sb.st_dev)
@ -2307,7 +2333,7 @@
/* Copy the contents of the directory. */ /* Copy the contents of the directory. */
@@ -1622,6 +1659,11 @@ @@ -1622,6 +1678,11 @@
} }
} }
@ -2319,7 +2345,7 @@
/* There's no need to preserve timestamps or permissions. */ /* There's no need to preserve timestamps or permissions. */
preserve_metadata = false; preserve_metadata = false;
@@ -1760,6 +1802,11 @@ @@ -1760,6 +1821,11 @@
un_backup: un_backup:

View File

@ -1,7 +1,7 @@
Summary: The GNU core utilities: a set of tools commonly used in shell scripts Summary: The GNU core utilities: a set of tools commonly used in shell scripts
Name: coreutils Name: coreutils
Version: 5.94 Version: 5.94
Release: 3 Release: 4
License: GPL License: GPL
Group: System Environment/Base Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/ Url: http://www.gnu.org/software/coreutils/
@ -261,6 +261,9 @@ fi
/sbin/runuser /sbin/runuser
%changelog %changelog
* Wed Apr 26 2006 Tim Waugh <twaugh@redhat.com> 5.94-4
- Fix 'cp -Z' when the destination exists (bug #189967).
* Thu Apr 20 2006 Tim Waugh <twaugh@redhat.com> 5.94-3 * Thu Apr 20 2006 Tim Waugh <twaugh@redhat.com> 5.94-3
- Make 'ls -Z' output more consistent with other output formats. - Make 'ls -Z' output more consistent with other output formats.