From 8c243ff965d477a89582a1b329923516a4d64668 Mon Sep 17 00:00:00 2001 From: Ondřej Vašík Date: Tue, 17 Feb 2009 15:53:39 +0100 Subject: cp: -a now preserves SELinux context, with reduced diagnostics * copy.c (copy_reg): Reduce SELinux context diagnostics for 'cp -a'. (copy_internal): Likewise * copy.h (cp_options): Add boolean reduce_diagnostics. * cp.c (usage): Say that --archive (-a) behaves like -dR --preserve=all. (cp_option_init): Initialize added reduce_diagnostics. (main): Add reduce_diagnostics for the -a option, and preserve SELinux context, if possible. * mv.c (cp_options_init): Initialize new cp_options booleans. * install.c (cp_option_init): Likewise. * NEWS: Mention those behaviour changes. * doc/coreutils.texi: Document --preserve=context, document that diagnostics are not shown for failures of non-mandatory attributes (just SELinux at the moment). * tests/cp/cp-a-selinux: Check not only failures, but succesful use of preserving SELinux context in cp. --- src/cp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/cp.c') diff --git a/src/cp.c b/src/cp.c index 9171fa652..57907cc79 100644 --- a/src/cp.c +++ b/src/cp.c @@ -160,7 +160,7 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ - -a, --archive same as -dpR\n\ + -a, --archive same as -dR --preserve=all\n\ --backup[=CONTROL] make a backup of each existing destination file\n\ -b like --backup but does not accept an argument\n\ --copy-contents copy contents of special files when recursive\n\ @@ -766,6 +766,7 @@ cp_option_init (struct cp_options *x) x->preserve_security_context = false; x->require_preserve_context = false; x->preserve_xattr = false; + x->reduce_diagnostics = false; x->require_preserve_xattr = false; x->require_preserve = false; @@ -921,13 +922,16 @@ main (int argc, char **argv) sparse_type_string, sparse_type); break; - case 'a': /* Like -dpR. */ + case 'a': /* Like -dR --preserve=all with reduced failure diagnostics. */ x.dereference = DEREF_NEVER; x.preserve_links = true; x.preserve_ownership = true; x.preserve_mode = true; x.preserve_timestamps = true; x.require_preserve = true; + if (selinux_enabled) + x.preserve_security_context = true; + x.reduce_diagnostics = true; x.recursive = true; break; -- cgit v1.2.3-54-g00ecf