mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
cp -a: diagnose failure when preserving xattr/context required
* src/copy.c (copy_attr_by_fs): Always print diagnostics when preserving xattrs is required. (copy_attr_by_name): Likewise. (copy_reg): Always print diagnostics when preserving SELinux context is required. (copy_internal): Likewise. Also, do not ignore ENOTSUP and ENODATA errors when preserving SELinux context is required. * NEWS (Bug fixes): Mention it.
This commit is contained in:
1 parent
941bd48235
commit
1fa226772c
2 files changed
+14
-7
No files matched your search
@@ -4,6 +4,11 @@ GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
** Bug fixes
|
||||
|
||||
cp now diagnoses failure to preserve selinux/xattr attributes when
|
||||
--preserve=context,xattr is specified in combination with -a.
|
||||
Also, cp no longer suppresses attribute-preservation diagnostics
|
||||
when preserving SELinux context was explicitly requested.
|
||||
|
||||
sort -m no longer segfaults when its output file is also an input file.
|
||||
E.g., with this, touch 1; sort -m -o 1 1, sort would segfault.
|
||||
[introduced in coreutils-7.2]
|
||||
|
||||
+9
-7
@@ -184,7 +184,8 @@ copy_attr_by_fd (char const *src_path, int src_fd,
|
||||
.quote_free = copy_attr_free
|
||||
};
|
||||
return 0 == attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0,
|
||||
x->reduce_diagnostics ? NULL : &ctx);
|
||||
(x->reduce_diagnostics
|
||||
&& !x->require_preserve_xattr)? NULL : &ctx);
|
||||
}
|
||||
|
||||
static bool
|
||||
@@ -198,7 +199,8 @@ copy_attr_by_name (char const *src_path, char const *dst_path,
|
||||
.quote_free = copy_attr_free
|
||||
};
|
||||
return 0 == attr_copy_file (src_path, dst_path, 0,
|
||||
x-> reduce_diagnostics ? NULL :&ctx);
|
||||
(x-> reduce_diagnostics
|
||||
&& !x->require_preserve_xattr) ? NULL : &ctx);
|
||||
}
|
||||
#else /* USE_XATTR */
|
||||
|
||||
@@ -481,7 +483,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
security_context_t con = NULL;
|
||||
if (getfscreatecon (&con) < 0)
|
||||
{
|
||||
if (!x->reduce_diagnostics)
|
||||
if (!x->reduce_diagnostics || x->require_preserve_context)
|
||||
error (0, errno, _("failed to get file system create context"));
|
||||
if (x->require_preserve_context)
|
||||
{
|
||||
@@ -494,7 +496,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
{
|
||||
if (fsetfilecon (dest_desc, con) < 0)
|
||||
{
|
||||
if (!x->reduce_diagnostics)
|
||||
if (!x->reduce_diagnostics || x->require_preserve_context)
|
||||
error (0, errno,
|
||||
_("failed to set the security context of %s to %s"),
|
||||
quote_n (0, dst_name), quote_n (1, con));
|
||||
@@ -1748,7 +1750,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
{
|
||||
if (setfscreatecon (con) < 0)
|
||||
{
|
||||
if (!x->reduce_diagnostics)
|
||||
if (!x->reduce_diagnostics || x->require_preserve_context)
|
||||
error (0, errno,
|
||||
_("failed to set default file creation context to %s"),
|
||||
quote (con));
|
||||
@@ -1762,9 +1764,9 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errno != ENOTSUP && errno != ENODATA)
|
||||
if ((errno != ENOTSUP && errno != ENODATA) || x->require_preserve_context)
|
||||
{
|
||||
if (!x->reduce_diagnostics)
|
||||
if (!x->reduce_diagnostics || x->require_preserve_context)
|
||||
error (0, errno,
|
||||
_("failed to get security context of %s"),
|
||||
quote (src_name));
|
||||
|
||||
Reference in new issue
Block a user