summaryrefslogtreecommitdiffstats
path: root/ui/ncurses/nc-cui.c
Commit message (Collapse)AuthorAgeFilesLines
* ncurses: Fix bad strncmpJoel Stanley2018-03-071-2/+2
| | | | | | | | | | | | | | | | | | ui/ncurses/nc-cui.c:967:58: warning: size argument in 'strncmp' call is a comparison [-Wmemsize-comparison] if (strncmp(cod->opt->id, "dummy", strlen("dummy") == 0 && ~~~~~~~~~~~~~~~~~~~~~^~ ui/ncurses/nc-cui.c:967:6: note: did you mean to compare the result of 'strncmp' instead? if (strncmp(cod->opt->id, "dummy", strlen("dummy") == 0 && ^ There appears to be two bonus conditions inside the length field. I chose to drop the pointless strncmp(foo, bar, strlen(bar)), as this is equivalent to strcmp(foo, bar). Signed-off-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Cyril Bur <cyrilbur@gmail.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> [Fixed up commit message typo]
* ncurses/nc-cui: fix unreferenced assertion variableBrett Grandbois2018-02-081-1/+2
| | | | | Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ncurses/nc-cui: musl libc fixesBrett Grandbois2018-02-081-1/+2
| | | | | | | | | | add missing #inlcude <locale.h> musl libc can segfault with a NULL format string so need to add a redundant "%s", "" to keep it happy Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Allow multiple hot key handlers per pmenuSamuel Mendoza-Jonas2018-01-101-1/+8
| | | | | | | | | | | | | | | | | | | | | The main menu and plugin menu are separate screens but they share the pmenu_process_key() handler. This means all the key shortcuts intended for the main menu can also be used in the plugin menu, which is particularly odd for "add new boot option" for example. To work around this extend the 'hot_key' functionality in pmenu to allow multiple handlers. This allows all pmenus to have the usual navigation and action keys, and then add extra handlers as needed. For example, ps3_mm_init() needs main menu shortcuts as well as some PS3-specific shortcuts, whereas plugin_menu_init() only needs the generic key handler. This changes the functionality of pmenu_process_key() such that if a hot_key_fn successfully handles a key, pmenu_process_key() returns instead of continuing to process the key. This does not affect the current usage. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Always cancel autoboot on exitSamuel Mendoza-Jonas2017-11-301-38/+41
| | | | | | | | | | | | | | If the ncurses UI exits before it has contacted the server it is meant to fork a process to wait until the connection is made and cancel autoboot. This prevents users dropping to the shell and then having the machine boot out from underneath them. In e1e2ca68 "Spawn shell in exit handler" the UI doesn't actually exit on "exit", but it isn't listening to server events either while the shell is active. In this case make sure we still fork to notify the server. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Handle arrow key variantsSamuel Mendoza-Jonas2017-11-211-0/+10
| | | | | | | | | | | In the vt100 'application' cursor mode arrow keys produce ^[Ox rather than the usual ^[[x. Add this pattern to our defined keys so we don't accidentally catch the escape key. For reference: http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-21.html Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Safely handle lost terminal control commandsv1.6.3Samuel Mendoza-Jonas2017-11-141-0/+28
| | | | | | | | | | | | | | | | | | Normally terminal control commands are caught and handled before ncurses or Petitboot could see them. However several combinations of broken terminal emulators or console connections can cause these command sequences to be seen by Petitboot, usually resulting in Petitboot exiting due to the ESC character and then the rest printed to the console. Aside from confusing the user this can also cancel autoboot, so it's important we don't let these sequences go unnoticed if possible. In ui/ncurses/console-codes we add a state machine that recognises the syntax of these control/escape sequences and handles the lost characters. We don't try to emulate the functionality of these commands, instead just logging them for reference. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Spawn shell in exit handlerSamuel Mendoza-Jonas2017-10-041-1/+29
| | | | | | | | | In cui_on_exit()_ instead of exiting the program spawn a sh instance. This allows the user to drop to the shell and return without losing any custom boot options, for example. SIGINT still calls cui_abort() to properly exit Petitboot. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Fixup some missing gettext callsSamuel Mendoza-Jonas2017-09-151-2/+2
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Add plugin menu and nc-plugin screenSamuel Mendoza-Jonas2017-08-151-39/+372
| | | | | | | | | | | | Add a second pmenu accessible via the main menu which displays uninstalled and installed pb-plugins. Uninstalled options can be selected to trigger pb-plugin to install them, after which they are updated and marked as installed in the menu. Installed plugins can be investigated by entering the new plugin screen, where plugin metadata and executables are displayed. Executables can be run from this screen via cui_run_cmd(). Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Update cui_run_cmd() to pass display to commandSamuel Mendoza-Jonas2017-08-151-4/+24
| | | | | | | | | Update cui_run_cmd() to setup a process that uses 'raw_stdout' so that output is displayed on the screen instead of being caught in the log. Also update cui_run_cmd() to take a more generic list of arguments, and add a cui_run_cmd_from_item() wrapper for the existing user. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Don't announce pb-discover connectionSamuel Mendoza-Jonas2016-12-201-2/+1
| | | | | | | | | The "Connected to pb-discover!" message is more useful for development than actual use; for users the more important messages are related to device and configuration parsing. Drop the message to slightly reduce the level of noise on start up. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Maintain a backlog of status updatesSamuel Mendoza-Jonas2016-12-201-1/+3
| | | | | | | | | Add status updates to a persistent list in the discover_server struct, and send each client the backlog on connect. This avoids clients missing useful messages from early init. Clients will only show this in the backlog screen to avoid flooding the client's status line. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: remove "Info:" / "Error:" prefix from status areaJeremy Kerr2016-12-201-6/+1
| | | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Add status log UIJeremy Kerr2016-12-201-6/+33
| | | | | | | | | | | | | Currently, status messages from the server are displayed in a single line at the bottom of the main menu UI, and are lost once a new status is reported. This change adds a facility for the UI to collect and display the status messages from the server, in a dedicated UI screen. This allows a user to look back through the discovery & boot process. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* types: shorten boot_status definitionsJeremy Kerr2016-12-201-2/+2
| | | | | | | | | | | struct boot_status is a bit misnamed; we report status on things that aren't just the boot status (eg, discovery). This change refactors struct boot_status into just struct status. We give the type enum a name, and shorten the enum values to suit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Make server connect message more clearv1.3.2Samuel Mendoza-Jonas2016-11-241-3/+5
| | | | | | | | | The current message mentions a "server" which can give the misleading impression that the UI is waiting for a remote network server. The delay is actually in waiting for the pb-discover process to be ready, so update the message to reflect that. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Spin child to ensure autoboot cancelled on exitSamuel Mendoza-Jonas2016-11-231-0/+43
| | | | | | | | | | If the client is not connected to the server instance when exiting, fork and have the child process spin until the server is available and can be told to cancel autoboot. This prevents the scenario of a user exiting the UI and having the server continue to autoboot while they are using the command line. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Disable shell access when lockdown is activetpearson@raptorengineering.com2016-08-261-1/+21
| | | | | | | | This patch disables direct command line access when the /etc/pb-lockdown file is present. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Add support for GPG signature enforcement on bootedtpearson@raptorengineering.com2016-08-261-0/+2
| | | | | | | | | | | | | kernels and related blobs This can be used to implement a form of organization-controlled secure boot, whereby kernels may be loaded from a variety of sources but they will only boot if a valid signature file is found for each component, and only if the signature is listed in the /etc/pb-lockdown file. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (Minor build fixes and gpgme.m4, comment on secure boot in gpg.c)
* ui/ncurses: define KEY_DC (delete key)Samuel Mendoza-Jonas2016-07-121-0/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Remember to abort boot on server connectSamuel Mendoza-Jonas2016-05-261-4/+14
| | | | | | | | | The UI can now come up before the server, but in order for a key press to cancel autoboot a key has to be pressed once the server connects. Instead remember to cancel autoboot if a key has been pressed at any point. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Start UI before connected to serverSamuel Mendoza-Jonas2016-05-061-6/+49
| | | | | | | | | | | | | | | | If petitboot-nc starts before the discover server it will try to connect for a short while waiting for the server to appear. However in some scenarios the server can take longer than expected to come up, for example if the kernel is compiled with modules and the system has many disks, and the process will timeout and exit before the server is ready. The UI does not appear during this time so it can appear as if Petitboot failed to start at all. Change the default behaviour to start the UI first, and then wait for the server to appear. The UI will not timeout in this mode. The "--timeout" option is added to start with the old behaviour. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui: Fix typo: 'deamon' -> 'daemon'Samuel Mendoza-Jonas2016-05-061-4/+4
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Increase timeout when waiting for pb-discoverSamuel Mendoza-Jonas2016-04-201-1/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Define extra key codes encountered in QEMUSamuel Mendoza-Jonas2016-04-051-0/+4
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Improve update handling in nested screensSamuel Mendoza-Jonas2015-09-071-0/+6
| | | | | | | | | | | | | | | | Several screens in petitboot-nc require an update if a config or sysinfo update is received. However if those screens exist but are not the current screen they will incorrectly try to draw to the screen. Where the currently active screen is a textscreen (eg. a help screen) the update is delayed until after the screen is exited. In the particular case of nc-config where the current screen can be an nc-subset screen, the nc-subset screen is exited immediately so the update can be performed, since the nc-subset screen depends on the information in the previous screen. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* ui/ncurses: Properly reposition cursor after menu updateSamuel Mendoza-Jonas2015-05-201-2/+28
| | | | | | | | | The currently selected item in the main menu can be set to an item off the visible portion of the menu after the additional or removal of a boot option. Update the currently selected item and/or the current view such that the item remains in the visible area. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* ui/ncurses: Add nc-subset selection screenSamuel Mendoza-Jonas2015-05-051-0/+24
| | | | | | | | | | The nc-subset screen is intended to be used as a sub-screen from the current screen (eg. nc-config) which passes a pointer to a nc_widget_subset struct. The nc-subset screen allows the user to select an option from a list of 'inactive' options, before returning control back to the current screen. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* ui/ncurses: Define Home, End, and Page Up/Down keysSamuel Mendoza-Jonas2015-04-221-0/+10
|
* ui/ncurses: Add support for 'add-url' actionSamuel Mendoza-Jonas2014-07-281-2/+31
| | | | | | | | Creates a menu option to specify a remote conf file url to send to the server for parsing. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add language selector & support for language changesJeremy Kerr2014-07-281-4/+61
| | | | | | | This change adds a language selector UI, and allows language changes from incoming configuration messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Move menu initialisation to cui codeJeremy Kerr2014-07-281-4/+94
| | | | | | | | | | | We'll want to re-initialise the petitboot main menu (when the language is changed), which we can't do if the items are populated entirely from the main() function. This change moves the menu initilisation to the cui code, we we can re-init when necessary. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* i18n: Add english translationJeremy Kerr2014-07-281-2/+2
| | | | | | No translation necessary. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Use a separate type for help textJeremy Kerr2014-07-281-1/+2
| | | | | | | | | | | | Because it's initialised statically, help text won't be directly gettext()-ed. Instead, we need to perform the gettext translation at runtime, and pass untranslated strings into the help_screen code. Instead of trusting callers to pass the untranslated strings though, we encapsulate the help text data into struct help_text, so we know we have an unstranslated string. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* i18n: Mark translatable strings for ncurses UIJeremy Kerr2014-07-281-13/+16
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Add gettext infrastructureJeremy Kerr2014-07-281-3/+0
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add device hierarchySamuel Mendoza-Jonas2014-07-221-9/+38
| | | | | | | | Boot options are now listed under their matching boot device in the ncurses UI to help differentitate similar boot option names Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add safe mode indicatorJeremy Kerr2014-07-221-0/+5
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: only cancel default boot on valid key eventsJeremy Kerr2014-04-221-4/+7
| | | | | | | | | | We're seeing occasionaly failures to autoboot due to supirious key events (getch() returing -1) on an IPMI console. This change modifies the process_key logic to only abort the default if we see a valid key event. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Always provide a key definition for backtabJeremy Kerr2014-04-161-0/+5
| | | | | | | | | | | | | Petitboot environments will probably want a basic terminfo defintion (eg, vt220) rather than a full linux or xterm, but vt220 and friends don't define a backtab key. Backtab can be useful for proper form navigation, and without a key definition, we just get an escape, which exits the current screen. This change provides a static definition for KEY_BTAB, so we should always have one available. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Fix discover_client leakJeremy Kerr2014-04-101-0/+1
| | | | | | | We're not freeing the discover_client on exit, as it's not attached to any existing talloc context. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Separate menu item creation & initialisation from insertionJeremy Kerr2014-04-101-25/+30
| | | | | | | | | | | | | | | | | | | | | | | Currently, the menu item creation is has two main functions: pmenu_item_alloc and pmenu_item_setup. The latter does initialisation (it sets item->name), and inserts the item into the menu. We have pmenu_item_init to combine this into one, but that means we need to do further initialisation (eg, to set on_execute) after the item has been added to the menu. Instead, this change use a more direct _create and _insert interface. Create does the allocation and initialisation, while _insert does the actual insertion. This means new_item failures will be detected at creation time, rather than during pmenu_insert. Also, we're now insert a completely-populated item into the menu, rather than populating on_edit, on_execute and data after insertion. Because we can detect errors from creation (ie, from new_item failing), we add handling code to cui_boot_option_add and cui_boot_editor_on_exit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Don't use menu offsets for user item numbersJeremy Kerr2014-04-101-1/+2
| | | | | | | The menu offsets are arbitrary, use a separate numbering scheme for user items. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Don't free item in pmenu_item_setupJeremy Kerr2014-04-081-3/+7
| | | | | | | | | | | | | Currently pmenu_item_setup may free its item parameter on error. This makes it non-obvious whether the item is still allocated on exit to the caller. Instead, this change removes the talloc_free, and requires that the caller do this on error. This makes the potential use-after-free in cui_boot_editor_on_exit obvious, so we fix that too. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add menu option to restart discoveryJeremy Kerr2014-04-021-0/+5
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Ensure that the selected menu item is visibleJeremy Kerr2014-03-031-5/+16
| | | | | | | | | | When adding new items to the petitboot menu, we need to ensure that the scroll position of the menu includes the currently-selected item. This change adds a call to set_top_row, calculated from the selected item index, and the number of rows in the menu. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add support for help screensJeremy Kerr2014-01-311-0/+23
| | | | | | | Add a textscreen-based help screen system, triggered from the cui module's cui_show_help() Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* configure: Use AC_GNU_SOURCEJeremy Kerr2013-12-181-2/+2
| | | | | | | Rather than #defining _GNU_SOURCE in our .c files, we can define this from config.h instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* ui/ncurses: Add key debugJeremy Kerr2013-12-021-0/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud