git: f8287caae482 - main - etcupdate: Preserve permissions when installing a resolved file.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 25 May 2022 21:22:43 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=f8287caae48246e34d6a7af5446df3c36127b7f0

commit f8287caae48246e34d6a7af5446df3c36127b7f0
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-25 21:20:40 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-25 21:20:40 +0000

    etcupdate: Preserve permissions when installing a resolved file.
    
    Similar to the change in 1a04446f088c79cc2cf85fd86e60ebcc228d3075, use
    cat to overwrite the contents of the existing file rather than cp so
    that metadata of the existing file such as permissions and ownership
    is preserved.
    
    PR:             255514
    Reported by:    uqs
    MFC after:      1 week
---
 usr.sbin/etcupdate/etcupdate.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh
index 1618fab59fe6..1da8fbf140d9 100755
--- a/usr.sbin/etcupdate/etcupdate.sh
+++ b/usr.sbin/etcupdate/etcupdate.sh
@@ -673,8 +673,9 @@ install_resolved()
 		return 1
 	fi
 
-	log "cp -Rp ${CONFLICTS}$1 ${DESTDIR}$1"
-	cp -Rp ${CONFLICTS}$1 ${DESTDIR}$1 >&3 2>&1
+	# Use cat rather than cp to preserve metadata
+	log "cat ${CONFLICTS}$1 > ${DESTDIR}$1"
+	cat ${CONFLICTS}$1 > ${DESTDIR}$1 2>&3
 	post_install_file $1
 	return 0
 }