diff options
author | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2019-02-15 10:40:56 +1100 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2019-03-26 16:46:38 +1100 |
commit | 1ad18bf128c4edfae76adaffd9c7801355f29b91 (patch) | |
tree | 40808aac6ec04d42c62eb445f99c286372a29b06 /ui/ncurses/nc-auth.c | |
parent | f583f0cf35fc227db5f73ecd04daf7702735b740 (diff) | |
download | talos-petitboot-1ad18bf128c4edfae76adaffd9c7801355f29b91.tar.gz talos-petitboot-1ad18bf128c4edfae76adaffd9c7801355f29b91.zip |
ui/ncurses: Add prompt for LUKS device password
Implement device_add() in cui_client_ops and use this interface to
recognise when the server notifies the client of an encrypted device. A
"device header" will be created for this device and added to the menu
with no associated boot options.
The nc-auth prompt is extended to ask for a disk password when the device
header for an encrypted device is selected.
Assuming the password is correct pb-discover will remove the original
device and notify the client about the newly opened device, which will
be reflected in the menu.
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'ui/ncurses/nc-auth.c')
-rw-r--r-- | ui/ncurses/nc-auth.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/ui/ncurses/nc-auth.c b/ui/ncurses/nc-auth.c index 5bfda8b..227c57b 100644 --- a/ui/ncurses/nc-auth.c +++ b/ui/ncurses/nc-auth.c @@ -42,6 +42,7 @@ struct auth_screen { void (*process_key)(struct nc_scr *, int); bool set_password; + const struct device *dev; void (*callback)(struct nc_scr *); int offset_y; int label_x; @@ -144,6 +145,9 @@ static void ok_click(void *arg) if (screen->set_password) { new_password = widget_textbox_get_value(screen->widgets.new_f); rc = cui_send_set_password(screen->cui, password, new_password); + } else if (screen->dev) { + rc = cui_send_open_luks_device(screen->cui, password, + screen->dev->id); } else rc = cui_send_authenticate(screen->cui, password); @@ -194,6 +198,7 @@ static void auth_screen_layout_widgets(struct auth_screen *screen) static void auth_screen_draw(struct auth_screen *screen) { struct nc_widgetset *set; + char *label; set = widgetset_create(screen, screen->scr.main_ncw, screen->scr.sub_ncw); @@ -203,10 +208,20 @@ static void auth_screen_draw(struct auth_screen *screen) } screen->widgetset = set; - screen->widgets.title_a_l = widget_new_label(set, 0, 0, - _("This action requires authorisation.")); - screen->widgets.title_b_l = widget_new_label(set, 0, 0, - _("Please enter the system password.")); + if (screen->dev) { + label = talloc_asprintf(screen, + _("Opening encrypted device %s"), + screen->dev->id); + screen->widgets.title_a_l = widget_new_label(set, 0, 0, label); + screen->widgets.title_b_l = widget_new_label(set, 0, 0, + _("Please enter the disk password.")); + talloc_free(label); + } else { + screen->widgets.title_a_l = widget_new_label(set, 0, 0, + _("This action requires authorisation.")); + screen->widgets.title_b_l = widget_new_label(set, 0, 0, + _("Please enter the system password.")); + } screen->widgets.password_f = widget_new_textbox_hidden(set, 0, 0, COLS - 20 - 20, "", true); @@ -236,6 +251,7 @@ static int auth_screen_destroy(void *arg) struct auth_screen *auth_screen_init(struct cui *cui, WINDOW *parent, bool set_password, + const struct device *dev, void (*callback)(struct nc_scr *), void (*on_exit)(struct cui *)) { @@ -246,6 +262,11 @@ struct auth_screen *auth_screen_init(struct cui *cui, if (!cui || !parent) return NULL; + if (set_password && dev) { + pb_log_fn("Incorrect parameters (set_password and device)\n"); + return NULL; + } + screen = talloc_zero(cui, struct auth_screen); if (!screen) return NULL; @@ -254,6 +275,7 @@ struct auth_screen *auth_screen_init(struct cui *cui, screen->cui = cui; screen->return_scr = cui->current; screen->set_password = set_password; + screen->dev = dev; screen->callback = callback; screen->on_exit = on_exit; screen->label_x = 5; |