DragonFly BSD
DragonFly submit List (threaded) for 2005-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

/sbin/reboot editing /boot/nextboot.conf


From: Gary Allan <dragonfly@xxxxxxxxxxxxxxx>
Date: Mon, 21 Mar 2005 17:25:17 +0000

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
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));


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]