svn commit: r349256 - head/libexec/rc/rc.d
Conrad Meyer
cem at FreeBSD.org
Fri Jun 21 02:37:56 UTC 2019
Author: cem
Date: Fri Jun 21 02:37:54 2019
New Revision: 349256
URL: https://svnweb.freebsd.org/changeset/base/349256
Log:
rc.d/motd: Update motd more robustly
Use appropriate fsyncs to persist the rewritten /etc/motd file, when a
rewrite is performed.
Reported by: Jonathan Walton <jonathan AT isilon.com>
Reviewed by: allanjude, vangyzen
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20701
Modified:
head/libexec/rc/rc.d/motd
Modified: head/libexec/rc/rc.d/motd
==============================================================================
--- head/libexec/rc/rc.d/motd Fri Jun 21 00:52:30 2019 (r349255)
+++ head/libexec/rc/rc.d/motd Fri Jun 21 02:37:54 2019 (r349256)
@@ -37,11 +37,15 @@ motd_start()
uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
- cmp -s $T /etc/motd || {
- cp $T /etc/motd
+ if ! cmp -s $T /etc/motd; then
+ mv -f $T /etc/.motd.tmp
+ fsync /etc/.motd.tmp
+ mv -f /etc/.motd.tmp /etc/motd
chmod ${PERMS} /etc/motd
- }
- rm -f $T
+ fsync /etc
+ else
+ rm -f $T
+ fi
check_startmsgs && echo '.'
}
More information about the svn-src-all
mailing list