summaryrefslogtreecommitdiff
path: root/src/copy.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-01-31 23:01:50 +0100
committerJim Meyering <jim@meyering.net>2007-03-29 21:37:06 +0200
commit8a86223d45be7597b229a95381aebab3512bf6d7 (patch)
tree6e26ddcaefd7f1cc3dd92cb014c5a2fb4135b585 /src/copy.c
parentadcfd944a8e7b64e11672ef8d0d077bb8de1b666 (diff)
downloadcoreutils-8a86223d45be7597b229a95381aebab3512bf6d7.tar.xz
* tests/cp/cp-a-selinux: New file. Test for the bug reported in
* tests/cp/Makefile.am (TESTS): Add cp-a-selinux. * tests/selinux: New file. * tests/Makefile.am (EXTRA_DIST): Add selinux. * tests/misc/selinux: Source the new script, rather than open coding it. Change how "cp -a" and "cp --preserve=context" work with SELinux. Now, cp -a attempts to preserve context, but failure to do so does not change cp's exit status. However "cp --preserve=context" is similar, but failure *does* cause cp to exit with nonzero status. * src/copy.h (struct cp_options) [require_preserve_context]: New member. * src/copy.c (copy_reg, copy_internal): Implement the above. * src/mv.c (cp_option_init): Initialize the new member. * src/install.c (cp_option_init): Likewise. * src/cp.c (cp_option_init): Likewise. (decode_preserve_arg): Set it or reset it. FIXME: add an on-writable-NFS-only test
Diffstat (limited to 'src/copy.c')
-rw-r--r--src/copy.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/copy.c b/src/copy.c
index f60fa55bd..d2088ae46 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -310,8 +310,11 @@ copy_reg (char const *src_name, char const *dst_name,
if (getfscreatecon (&con) < 0)
{
error (0, errno, _("failed to get file system create context"));
- return_val = false;
- goto close_src_desc;
+ if (x->require_preserve_context)
+ {
+ return_val = false;
+ goto close_src_desc;
+ }
}
if (con)
@@ -321,9 +324,12 @@ copy_reg (char const *src_name, char const *dst_name,
error (0, errno,
_("failed to set the security context of %s to %s"),
quote_n (0, dst_name), quote_n (1, con));
- return_val = false;
- freecon (con);
- goto close_src_desc;
+ if (x->require_preserve_context)
+ {
+ return_val = false;
+ freecon (con);
+ goto close_src_desc;
+ }
}
freecon(con);
}
@@ -1590,7 +1596,7 @@ copy_internal (char const *src_name, char const *dst_name,
error (0, errno,
_("failed to set default file creation context to %s"),
quote (con));
- if (x->require_preserve)
+ if (x->require_preserve_context)
{
freecon (con);
return false;
@@ -1605,7 +1611,8 @@ copy_internal (char const *src_name, char const *dst_name,
error (0, errno,
_("failed to get security context of %s"),
quote (src_name));
- return false;
+ if (x->require_preserve_context)
+ return false;
}
}
}