Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386/stand/boot When a password is set for the boot...



details:   https://anonhg.NetBSD.org/src/rev/a3fdbb95194b
branches:  trunk
changeset: 751922:a3fdbb95194b
user:      hubertf <hubertf%NetBSD.org@localhost>
date:      Mon Feb 08 21:25:32 2010 +0000

description:
When a password is set for the bootloader ("installboot -o password=..."),
it currently complains about an unknown command and prints a usage if the
password is entered wrong:

        ...
        Choose an option; RETURN for default; SPACE to stop countdown.
        Option 1 will be chosen in 0 seconds.
        Password: *
        Password: *
        Password: *
        unknown command
        commands are:
        boot [xdNx:][filename] [-12acdqsvxz]
             (ex. "hd0a:netbsd.old -s"
        ls [path]
        dev xd[N[x]]:
        consdev {pc|com[0123]|com[0123]kbd|auto}
        modules {enabled|disabled}
        load {path_to_module}
        multiboot [xdNx:][filename] [<args>]
        help|?
        quit

        Choose an option; RETURN for default; SPACE to stop countdown.
        Option 1 will be chosen in 0 seconds.
        ...

This is confusing, plus someone may use it to determine bits of
information about the system. What should happen instead is that the user
is informed that the password is wrong:

        ...
        Choose an option; RETURN for default; SPACE to stop countdown.
        Option 1 will be chosen in 0 seconds.
        Password: ****
        Password: ****
        Password: ****
        Wrong password.

        Choose an option; RETURN for default; SPACE to stop countdown.
        ...

Implement the latter behaviour.

diffstat:

 sys/arch/i386/stand/boot/boot2.c |  22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diffs (37 lines):

diff -r de4333d53a0e -r a3fdbb95194b sys/arch/i386/stand/boot/boot2.c
--- a/sys/arch/i386/stand/boot/boot2.c  Mon Feb 08 20:45:43 2010 +0000
+++ b/sys/arch/i386/stand/boot/boot2.c  Mon Feb 08 21:25:32 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot2.c,v 1.47 2010/01/17 14:54:44 drochner Exp $      */
+/*     $NetBSD: boot2.c,v 1.48 2010/02/08 21:25:32 hubertf Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -344,11 +344,23 @@
 #else
                c = awaitkey((bootconf.timeout < 0) ? 0 : bootconf.timeout, 1);
 #endif
-               if ((c != '\r') && (c != '\n') && (c != '\0') &&
-                   ((boot_params.bp_flags & X86_BP_FLAGS_PASSWORD) == 0
-                    || check_password(boot_params.bp_password))) {
-                       printf("type \"?\" or \"help\" for help.\n");
+               if ((c != '\r') && (c != '\n') && (c != '\0')) {
+                   if ((boot_params.bp_flags & X86_BP_FLAGS_PASSWORD) == 0) {
+                       /* do NOT ask for password */
                        bootmenu(); /* does not return */
+                   } else {
+                       /* DO ask for password */
+                       if (check_password(boot_params.bp_password)) {
+                           /* password ok */
+                           printf("type \"?\" or \"help\" for help.\n");
+                           bootmenu(); /* does not return */
+                       } else {
+                           /* bad password */
+                           printf("Wrong password.\n");
+                           currname = 0;
+                           continue;
+                       }
+                   }
                }
 
                /*



Home | Main Index | Thread Index | Old Index