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
This commit is contained in:
Eric van Gyzen 2016-09-08 15:53:49 +00:00
parent a6be469014
commit 1a04446f08

View File

@ -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"