/sbin/reboot editing /boot/nextboot.conf
This is a multi-part message in MIME format.
--------------040407020004020306050302
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hello,
The userland utility reboot(8) can leave garbage in
/boot/nextkernel.conf when specifying the next kernel to boot.
How to reproduce:
Running "reboot -k kernel.GENERIC" followed by "reboot -k kernel" leaves
/boot/nextboot.conf as:
kernel="/kernel"
ENERIC"
The attached patch truncates the file on opening.
Regards
Gary
--------------040407020004020306050302
Content-Type: text/plain;
name="reboot.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="reboot.c.diff"
diff -ru /usr/src.old/sbin/reboot/reboot.c /usr/src/sbin/reboot/reboot.c
--- /usr/src.old/sbin/reboot/reboot.c 2005-01-02 01:35:13.000000000 +0000
+++ /usr/src/sbin/reboot/reboot.c 2005-03-21 16:59:59.000000000 +0000
@@ -114,7 +114,7 @@
}
if (kflag) {
- fd = open("/boot/nextboot.conf", O_WRONLY | O_CREAT, 0444);
+ fd = open("/boot/nextboot.conf", O_WRONLY | O_CREAT | O_TRUNC, 0444);
if (fd > -1) {
write(fd, "kernel=\"", 8L);
write(fd, kernel, strlen(kernel));
--------------040407020004020306050302--
討論串 (同標題文章)