[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] cp: Have -a imply -c when SELinux is enabled.
From:       Chris PeBenito <chpebeni () linux ! microsoft ! com>
Date:       2019-04-26 15:01:52
Message-ID: 20190426150152.27553-1-chpebeni () linux ! microsoft ! com
[Download RAW message or body]

Have cp preserve SELinux context when using -a.  Coreutils cp also does
this.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
---
 coreutils/cp.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/coreutils/cp.c b/coreutils/cp.c
index 59e3d2f80..2381d53ec 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -41,8 +41,7 @@
 //usage:       "[OPTIONS] SOURCE... DEST"
 //usage:#define cp_full_usage "\n\n"
 //usage:       "Copy SOURCE(s) to DEST\n"
-//usage:     "\n	-a	Same as -dpR"
-//usage:	IF_SELINUX(
+//usage:     "\n	-a	Same as -dpR" IF_SELINUX("c"
 //usage:     "\n	-c	Preserve security context"
 //usage:	)
 //usage:     "\n	-R,-r	Recurse"
@@ -93,8 +92,8 @@ int cp_main(int argc, char **argv)
 		// -P and -d are the same (-P is POSIX, -d is GNU)
 		// -r and -R are the same
 		// -R (and therefore -r) turns on -d (coreutils does this)
-		// -a = -pdR
-		"-2:l--s:s--l:Pd:rRd:Rd:apdR",
+		// -a = -pdR (-pdRc if SELINUX)
+		"-2:l--s:s--l:Pd:rRd:Rd:apdR" IF_SELINUX("c"),
 		"archive\0"        No_argument "a"
 		"force\0"          No_argument "f"
 		"interactive\0"    No_argument "i"
@@ -128,7 +127,7 @@ int cp_main(int argc, char **argv)
 	flags = getopt32(argv, "^"
 		FILEUTILS_CP_OPTSTR
 		"\0"
-		"-2:l--s:s--l:Pd:rRd:Rd:apdR"
+		"-2:l--s:s--l:Pd:rRd:Rd:apdR" IF_SELINUX("c")
 	);
 #endif
 	/* Options of cp from GNU coreutils 6.10:
-- 
2.20.1

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic