From 1a04446f088c79cc2cf85fd86e60ebcc228d3075 Mon Sep 17 00:00:00 2001 From: Eric van Gyzen Date: Thu, 8 Sep 2016 15:53:49 +0000 Subject: [PATCH] etcupdate: preserve the metadata of the destination file When using diff3 to perform a three-way merge, etcupdate lost the destination file's metadata. The metadata from the temporary file were used instead. This was unpleasant for rc.d scripts, which require execute permission. Use "cat >" to overwrite the destination file's contents while preserving its metadata. Reviewed by: bapt Sponsored by: Dell Technologies Differential Revision: https://reviews.freebsd.org/D7817 --- usr.sbin/etcupdate/etcupdate.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh index 6330c60da85..2b4c145fa3f 100755 --- a/usr.sbin/etcupdate/etcupdate.sh +++ b/usr.sbin/etcupdate/etcupdate.sh @@ -824,7 +824,9 @@ merge_file() if [ -z "$dryrun" ]; then temp=$(mktemp -t etcupdate) diff3 -E -m ${DESTDIR}$1 ${OLDTREE}$1 ${NEWTREE}$1 > ${temp} - mv -f ${temp} ${DESTDIR}$1 + # Use "cat >" to preserve metadata. + cat ${temp} > ${DESTDIR}$1 + rm -f ${temp} fi post_install_file $1 echo " M $1"