This is a partial revert of https://git.busybox.net/busybox/commit/libbb/copy_file.c?id=6f58be07485fd2fbac1b828e5f2c631e7d5bc9e4
S. also http://freetz.org/changeset/4289

TODO: document the problem we have without this patch
      check if it could be solved in a better way

--- libbb/copy_file.c
+++ libbb/copy_file.c
@@ -298,7 +298,11 @@
 		if (!S_ISREG(source_stat.st_mode))
 			new_mode = 0666;
 
-		if (ENABLE_FEATURE_NON_POSIX_CP || (flags & FILEUTILS_INTERACTIVE)) {
+	{
+		smallint do_O_TRUNC = dest_exists
+			&& !(flags & (FILEUTILS_RECUR|FILEUTILS_INTERACTIVE))
+			&& !S_ISLNK(dest_stat.st_mode);
+		if ((ENABLE_FEATURE_NON_POSIX_CP || (flags & FILEUTILS_INTERACTIVE)) && !do_O_TRUNC) {
 			/*
 			 * O_CREAT|O_EXCL: require that file did not exist before creation
 			 */
@@ -309,6 +313,7 @@
 			 */
 			dst_fd = open(dest, O_WRONLY|O_CREAT|O_TRUNC, new_mode);
 		}
+	}
 		if (dst_fd == -1) {
 			ovr = ask_and_unlink(dest, flags);
 			if (ovr <= 0) {
