Date: Wed, 3 Oct 2001 22:13:10 -0700 From: "Crist J. Clark" <cristjc@earthlink.net> To: freebsd-audit@freebsd.org Subject: dmesg.boot Gets Overwritten without Reboot Message-ID: <20011003221310.Q8391@blossom.cjclark.org>
next in thread | raw e-mail | index | archive | help
This is a potential fix for bin/24592. The problem is that the file /var/run/dmesg.boot is overwritten unconditionally in /etc/rc. This occurs whether we are really freshly booting the kernel or coming up from single-user mode. I do not believe that the dmesg.boot file should be overwritten if we are coming up from single-user mode. There is a very good chance the boot messages have fallen out of the dmesg(8) buffer by now and we are overwriting the file with whatever happens to be in the buffer. This is not what we want to have in the dmesg.boot file. The basic fix for this is to only write dmesg(8) to the /var/run/dmesg.boot file if we are in an "autoboot." However, there is some ugliness in actually getting this done since we have to temporarily store dmesg.boot elsewhere when /var/run is purged. There is one basic problem with this approach. If we freshly boot the system and go to sigle user before going to multi-user mode, we will not get a new dmesg.boot. When coming from single-user mode to multi-user mode, I do not know of a way to tell how we got into that single-user mode whether from a fresh boot or down from multi-user. But I would rather miss saving the dmesg(8) in this case rather than overwrite it with gibberish in the second. Others may disagree. Any comments on the patch or the concept? Index: rc =================================================================== RCS file: /export/ncvs/src/etc/rc,v retrieving revision 1.283 diff -u -r1.283 rc --- rc 2001/10/02 12:00:39 1.283 +++ rc 2001/10/04 05:07:44 @@ -339,10 +339,19 @@ clean_var() { if [ ! -f /var/run/clean_var ]; then + # We may wish to save the boot messages + if [ -f /var/run/dmesg.boot ]; then + mv -f /var/run/dmesg.boot /tmp/dmesg.boot + fi purgedir /var/run /var/spool/lock rm -rf /var/spool/uucp/.Temp/* # Keep a copy of the boot messages around - dmesg >/var/run/dmesg.boot + if [ X"$bootmode" = X"autoboot" -o ! -f /tmp/dmesg.boot ]; then + dmesg >/var/run/dmesg.boot + else + mv -f /tmp/dmesg.boot /var/run/dmesg.boot + rm -f /tmp/dmesg.boot + fi # And an initial utmp file (cd /var/run && cp /dev/null utmp && chmod 644 utmp;) >/var/run/clean_var -- Crist J. Clark cjclark@alum.mit.edu cjclark@jhu.edu cjc@freebsd.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011003221310.Q8391>