From owner-freebsd-bugs Fri Aug 6 13:20:21 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 197A014D6D for ; Fri, 6 Aug 1999 13:20:18 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id NAA30086; Fri, 6 Aug 1999 13:20:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from rucus.ru.ac.za (rucus.ru.ac.za [146.231.29.2]) by hub.freebsd.org (Postfix) with SMTP id 2AC4F14D1C for ; Fri, 6 Aug 1999 13:12:41 -0700 (PDT) (envelope-from nbm@rucus.ru.ac.za) Received: (qmail 75420 invoked by uid 1003); 6 Aug 1999 20:13:16 -0000 Message-Id: <19990806201316.75419.qmail@rucus.ru.ac.za> Date: 6 Aug 1999 20:13:16 -0000 From: nbm@rucus.ru.ac.za Reply-To: nbm@rucus.ru.ac.za To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/13005: make rc use mktemp for temporary motd file Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 13005 >Category: bin >Synopsis: make rc use mktemp for temporary motd file >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Aug 6 13:20:00 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Neil Blakey-Milner >Release: FreeBSD 3.0-STABLE i386 >Organization: Rhodes University Computer Users' Society >Environment: FreeBSD rucus.ru.ac.za 3.0-STABLE FreeBSD 3.0-STABLE #0: Tue Feb 9 22:52:23 GMT 1999 grahams@rucus.ru.ac.za:/usr/src/sys/compile/RUCUS-SMP i386 >Description: rc currently uses the file /tmp/_motd as a temporary file, and despite attempting to delete it, that operation may fail (chflags) and cause arbitrary non-roots to effectively replace the motd at bootup. >How-To-Repeat: su - arb cd /tmp touch _motd chflags >Fix: --- rc.orig Fri Aug 6 19:15:16 1999 +++ rc Fri Aug 6 22:02:34 1999 @@ -400,13 +400,16 @@ fi if [ "X${update_motd}" != X"NO" ]; then - T=/tmp/_motd - rm -rf $T - 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 - cp $T /etc/motd - chmod 644 /etc/motd - rm -rf $T + T=`mktemp -q /tmp/_motd.XXXXXX` + if [ $? -eq 0 ]; then + 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 + cp $T /etc/motd + chmod 644 /etc/motd + rm -rf $T + else + echo "Could not create temporary file $T for motd update!" + fi fi # Run rc.devfs if present to customify devfs >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message