]> git.ozlabs.org Git - petitboot/blobdiff - ui/ncurses/nc-cui.c
ui/ncurses: Implement non-boot-cancelling keys
[petitboot] / ui / ncurses / nc-cui.c
index ee6df87b0c7d0a00f305a6460235d3b7215d93b3..87540cad66243f8ac56267122879ab43836005fb 100644 (file)
@@ -61,10 +61,14 @@ static void cui_cancel_autoboot_on_exit(struct cui *cui);
 
 static bool lockdown_active(void)
 {
+#if defined(SIGNED_BOOT) && defined(HARD_LOCKDOWN)
+       return true;
+#else
        bool lockdown = false;
        if (access(LOCKDOWN_FILE, F_OK) != -1)
                lockdown = true;
        return lockdown;
+#endif
 }
 
 static void cui_start(void)
@@ -523,6 +527,14 @@ struct nc_scr *cui_set_current(struct cui *cui, struct nc_scr *scr)
        return old;
 }
 
+static bool key_cancels_boot(int key)
+{
+       if (key == 0xc)
+               return false;
+
+       return true;
+}
+
 static bool process_global_keys(struct cui *cui, int key)
 {
        switch (key) {
@@ -578,7 +590,7 @@ static int cui_process_key(void *arg)
                        }
                }
 
-               if (!cui->has_input) {
+               if (!cui->has_input && key_cancels_boot(c)) {
                        cui->has_input = true;
                        if (cui->client) {
                                pb_log("UI input received (key = %d), aborting "
@@ -964,8 +976,8 @@ fallback:
         * If this option was faked above move the context under
         * the item so it is cleaned up later in cui_plugins_remove().
         */
-       if (strncmp(cod->opt->id, "dummy", strlen("dummy") == 0 &&
-                               cod->dev->type == DEVICE_TYPE_UNKNOWN)) {
+       if (strcmp(cod->opt->id, "dummy") == 0 &&
+                       cod->dev->type == DEVICE_TYPE_UNKNOWN) {
                talloc_steal(item, cod->dev);
                talloc_steal(item, cod->opt);
        }
@@ -1574,7 +1586,8 @@ static void cui_cancel_autoboot_on_exit(struct cui *cui)
 
 int cui_run(struct cui *cui)
 {
-       assert(main);
+       assert(cui);
+       assert(cui->main);
 
        cui->current = &cui->main->scr;
        cui->default_item = 0;