git: a78bc42bcc31 - main - reboot: Disallow -k and -r, it doesn't make sense.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 12 Feb 2024 18:53:36 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=a78bc42bcc31f04fdb3319f7b11c6d8da5a30bee
commit a78bc42bcc31f04fdb3319f7b11c6d8da5a30bee
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-02-12 18:44:43 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-02-12 18:44:43 +0000
reboot: Disallow -k and -r, it doesn't make sense.
When we're re-rooting to a new /, there is no next kernel. Error out
rather than leaving a timebomb in /boot/nextboot.conf.
Sponsored by: Netflix
Reviewed by: kevans, kib, emaste
Differential Revision: https://reviews.freebsd.org/D43800
---
sbin/reboot/reboot.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c
index 7daf38b88a3e..90c67caf9d07 100644
--- a/sbin/reboot/reboot.c
+++ b/sbin/reboot/reboot.c
@@ -115,6 +115,8 @@ main(int argc, char *argv[])
errx(1, "-c and -p cannot be used together");
if ((howto & RB_REROOT) != 0 && howto != RB_REROOT)
errx(1, "-r cannot be used with -c, -d, -n, or -p");
+ if ((howto & RB_REROOT) != 0 && kernel != NULL)
+ errx(1, "-r and -k cannot be used together, there is no next kernel");
if (geteuid()) {
errno = EPERM;
err(1, NULL);