[PATCH] cp: Have -a imply -c when SELinux is enabled.
Chris PeBenito
chpebeni at linux.microsoft.com
Fri Apr 26 15:01:52 UTC 2019
Have cp preserve SELinux context when using -a. Coreutils cp also does
this.
Signed-off-by: Chris PeBenito <chpebeni at 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
More information about the busybox
mailing list