From 39f9d4b8d96ee2d23f1e39c3618926ba146483f5 Mon Sep 17 00:00:00 2001 From: millert <> Date: Wed, 4 Aug 1999 17:07:27 +0000 Subject: [PATCH] Use mktemp(1) for motd /tmp file during boot. This fixes a potential problem noted by hugh@openbsd.org whereby a user could create the well-known /tmp/_motd file and use chflags to make it unremovable. Then at the next reboot the user's /tmp/_motd would end up in the system motd. --- src/etc/rc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/etc/rc b/src/etc/rc index 136d17fb..63640401 100644 --- a/src/etc/rc +++ b/src/etc/rc @@ -1,4 +1,4 @@ -# $OpenBSD: rc,v 1.101 1999/08/03 22:52:42 deraadt Exp $ +# $OpenBSD: rc,v 1.102 1999/08/04 17:07:27 millert Exp $ # System startup script run by init on autoboot # or after single-user. @@ -301,13 +301,14 @@ fi if [ ! -f /etc/motd ]; then install -c -o root -g wheel -m 664 /dev/null /etc/motd fi -T=/tmp/_motd -rm -f $T -sysctl -n kern.version | sed 1q > $T -echo "" >> $T -sed '1,/^$/d' < /etc/motd >> $T -cmp -s $T /etc/motd || cp $T /etc/motd -rm -f $T +T=`mktemp /tmp/_motd.XXXXXX` +if [ $? -ne 0 ]; then + sysctl -n kern.version | sed 1q > $T + echo "" >> $T + sed '1,/^$/d' < /etc/motd >> $T + cmp -s $T /etc/motd || cp $T /etc/motd + rm -f $T +fi # nvi file recovery if [ ! -d /var/tmp/vi.recover ]; then