petitboot
12 months agodiscover/device-handler: Restore autoboot setting on requery v1.7.3
Samuel Mendoza-Jonas [Mon, 27 Aug 2018 01:50:47 +0000 (11:50 +1000)]
discover/device-handler: Restore autoboot setting on requery

When a device requery is triggered we cancel any default boot option on
the device. This also disables autoboot which we don't want; any boot
options found after the requery will not be able to autoboot.
To avoid this restore the existing autoboot setting after checking for
default options.

This prevents a particular corner case where a default boot option has
been selected for boot but one of its boot files has stalled or is
taking more time to download than the requery timeout and the requery
accidentally cancels autoboot preventing Petitboot from trying to boot
again.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
(cherry picked from commit 3917e88b838001b13a19fc6ea01d08b08c0770ca)

13 months agodiscover/paths: Set suffix to default value on error. v1.7.2
Samuel Mendoza-Jonas [Mon, 30 Jul 2018 01:48:26 +0000 (11:48 +1000)]
discover/paths: Set suffix to default value on error.

This avoids the log filling up with "Couldn't recognise suffix" messages
if a lot of partial stdout updates are received.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
(cherry picked from commit 70bb4980b19a4ba1d3f92c18df0b03104c4a9b6b)

13 months agodiscover: Be more verbose about boot failures
Samuel Mendoza-Jonas [Mon, 30 Jul 2018 01:48:25 +0000 (11:48 +1000)]
discover: Be more verbose about boot failures

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
(cherry picked from commit 0dca9e11c5bacd76a12b2e52a263ca7bd94b9a00)

13 months agolib/log: Include timestamp prefix
Samuel Mendoza-Jonas [Mon, 30 Jul 2018 01:48:24 +0000 (11:48 +1000)]
lib/log: Include timestamp prefix

The relative time between logged events is very useful during debugging,
particularly when debugging autoboot failures. Prepend a short HH:MM:SS
timestamp to each line logged.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
(cherry picked from commit b0c603d007174e75452c1c14402d62d305da76ab)

13 months agodiscover: implement a periodic requery for network devices
Jeremy Kerr [Tue, 3 Jul 2018 06:24:58 +0000 (16:24 +1000)]
discover: implement a periodic requery for network devices

If we boot a machine before external (network) dependencies are properly
configured, it will have tried once to download configuration, and
possibly failed due to that configuration not being present.

This change introduces a periodic requery of network resources. After a
timeout, petitboot will either re-acquire its DHCP lease (causing any
downloads to be re-processed, possibly with different parameters from
the new lease), or re-download a statically defined URL.

This timeout defaults to five minutes (similar to pxelinux), and is
configurable by DHCP option 211, "reboot time".

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
[added test stub]
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
(cherry picked from commit 6fa0edfb029726968cbacad9d4e193a345956ff3)

18 months agodiscover/boot: Fix stale boot cancellation code v1.7.1
Samuel Mendoza-Jonas [Tue, 6 Mar 2018 05:44:44 +0000 (16:44 +1100)]
discover/boot: Fix stale boot cancellation code

In dc85de97 "Allow load_async_url() to call callback for local paths"
several load_url_result fields of the boot_task struct were deprecated
but were accidentally left in the struct. This caused the now out of
date code in cleanup_cancellations() to go unnoticed since it can return
safely if these fields are NULL. However freeing the boot task can free
the memory associated with each load before it is complete, resulting in
a confusing segfault.

This brings cleanup_cancellations() up to date and along the way
implicitly includes the signature resources in cleanup which were missed
originally.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
18 months agodiscover: pxe: Avoid dereferencing null pointer
Joel Stanley [Tue, 6 Mar 2018 04:02:20 +0000 (14:32 +1030)]
discover: pxe: Avoid dereferencing null pointer

When result is null, we may end up in the error handling path where we
try to dereference null to call cleanup_local. This adds a check for
result.

Found with scan-build.

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]

18 months agotest/parser: Fixed uninitialized variable warning
Joel Stanley [Tue, 6 Mar 2018 04:02:19 +0000 (14:32 +1030)]
test/parser: Fixed uninitialized variable warning

Clang has a problem with list_for_each_entry:

test/parser/utils.c:290:36: error: variable 'file' is used uninitialized whenever 'for' loop exits because its condition is false [-Werror,-Wsometimes-uninitialized]
        list_for_each_entry(&test->files, f, list) {
                                          ^
./lib/list/list.h:30:3: note: expanded from macro 'list_for_each_entry'
                _pos; _pos = list_next_entry(_list, _pos, _member))
                ^~~~
test/parser/utils.c:300:7: note: uninitialized use occurs here
        if (!file) {
             ^~~~
test/parser/utils.c:290:36: note: remove the condition if it is always true
        list_for_each_entry(&test->files, f, list) {
                                          ^
./lib/list/list.h:30:3: note: expanded from macro 'list_for_each_entry'
                _pos; _pos = list_next_entry(_list, _pos, _member))
                ^
test/parser/utils.c:288:28: note: initialize the variable 'file' to silence this warning
        struct test_file *f, *file;
                                  ^
                                   = NULL

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
18 months agodiscover: Fix unused function warning
Joel Stanley [Tue, 6 Mar 2018 04:02:18 +0000 (14:32 +1030)]
discover: Fix unused function warning

clang errors out about an unused have_busybox function:

 discover/paths.c:44:13: error: unused function 'have_busybox' [-Werror,-Wunused-function]
 static bool have_busybox(void)
            ^

Move have_busybox() to inside the #ifndef PETITBOOT_TEST scope to
eliminate the warning and avoid having #ifdefs in load_url_async().

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
[Moved definition into #ifndef PETITBOOT_TEST instead of using
 #ifdef at the call site]

18 months agoncurses: Fix bad strncmp
Joel Stanley [Tue, 6 Mar 2018 04:02:17 +0000 (14:32 +1030)]
ncurses: Fix bad strncmp

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]

18 months agodiscover: Fix bad check of version string
Joel Stanley [Tue, 6 Mar 2018 04:02:16 +0000 (14:32 +1030)]
discover: Fix bad check of version string

Clang says this:

discover/device-handler.c:1564:27: warning: size argument in 'strncmp' call is a comparison [-Wmemsize-comparison]
                                        strlen(opt->version) == 0)) {
                                        ~~~~~~~~~~~~~~~~~~~~~^~~~
discover/device-handler.c:1563:5: note: did you mean to compare the result of 'strncmp' instead?
                                strncmp(opt->version, tmp->version,
                                ^

It looks like it's correct. However, we can go one better and 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>
18 months agoutils/hooks: Set stdout-path property
Samuel Mendoza-Jonas [Fri, 2 Mar 2018 04:20:29 +0000 (15:20 +1100)]
utils/hooks: Set stdout-path property

The linux,stdout-path property was deprecated in favour of stdout-path
in the v3.14 kernel. 'stdout-path' takes priority in newer kernels but
older kernels won't be aware of it, so set both at boot time.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
18 months agolib: Fix gpg.h path
Samuel Mendoza-Jonas [Fri, 2 Mar 2018 04:19:58 +0000 (15:19 +1100)]
lib: Fix gpg.h path

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
18 months agoui/ncurses: Validate URL field v1.7.0
Samuel Mendoza-Jonas [Mon, 26 Feb 2018 04:58:10 +0000 (15:58 +1100)]
ui/ncurses: Validate URL field

Make sure the URL field is a valid URL before allowing the user to
proceed.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
18 months agodiscover/platform-powerpc: Avoid confusing gateway and URL
Samuel Mendoza-Jonas [Fri, 23 Feb 2018 04:26:49 +0000 (15:26 +1100)]
discover/platform-powerpc: Avoid confusing gateway and URL

If we have a static network config with a URL set but not a gateway we
can confuse the URL as the gateway due to how we write the network
string in NVRAM.

To avoid changing the parameter format if we only have one of the two
tokens check whether or not it's actually a URL; the gateway and the URL
will have distinct formats.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
18 months agoui/ncurses: Fix boot editor segfault on update
Samuel Mendoza-Jonas [Fri, 16 Feb 2018 02:55:26 +0000 (13:55 +1100)]
ui/ncurses: Fix boot editor segfault on update

The boot option editor screen segfaults on a system info update since it
loses track of which fields actually exist.

The boot editor screen's setup and drawing logic is a bit different from
other screens, so to fix this bug and preserve the maintainer's sanity,
bring the screen setup and redraw into line with other screens. This
includes a full teardown of the widgets on update, so save the content
of any textboxes on update so the user's changes are not lost.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
18 months agodiscover: Allow load_async_url() to call callback for local paths
Samuel Mendoza-Jonas [Fri, 9 Feb 2018 04:14:22 +0000 (15:14 +1100)]
discover: Allow load_async_url() to call callback for local paths

Several pxe-parser tests fail because the test harness's version of
load_async_url() will call the callback directly, but in pxe-parser the
caller checks if the path was local and calls the callback immediately.
Being called twice, a use-after-free occurs in the callback.

For consistency change the load_async_url() semantics such that it is
possible for load_async_url() to call the callback before it returns in
the case of local paths. Callers need to know this is possible, but now
won't need to check to call it manually.

This requires a slight reorganisation of the boot_process() code, since
it checks the result of several asynchronous load operations in the same
callback, and with this change not all of those results will necessarily
be initialised at callback time. Add a list of 'boot_resources' which
carry the required information for the resource and allow the boot
handler to treat different resources generically.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
18 months agodiscover/syslinux-parser: Fix missing comma in ignored names.
Samuel Mendoza-Jonas [Tue, 13 Feb 2018 00:05:00 +0000 (11:05 +1100)]
discover/syslinux-parser: Fix missing comma in ignored names.

Fixes Coverity defect CID 182828.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
19 months agodiscover/device-handler: Treat empty boot order as 'boot any'
Samuel Mendoza-Jonas [Mon, 29 Jan 2018 03:21:47 +0000 (14:21 +1100)]
discover/device-handler: Treat empty boot order as 'boot any'

It is possible to have autoboot enabled with an empty boot order.
Currently this acts as if autoboot is disabled, but it likely makes more
sense to the user for this to behave as "autoboot any device".

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
19 months agoui/ncurses: Clear remaining space when drawing help line
Samuel Mendoza-Jonas [Fri, 12 Jan 2018 04:35:20 +0000 (15:35 +1100)]
ui/ncurses: Clear remaining space when drawing help line

When drawing the screen's help line clear each character after the new
help line to avoid stale parts of the previous screen's help line
remaining on the screen.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
19 months agosyslinux: add syslinux parser support
Brett Grandbois [Fri, 9 Feb 2018 03:26:41 +0000 (13:26 +1000)]
syslinux: add syslinux parser support

Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
19 months agotest/parser: test no whitespace on grub menuentry
Brett Grandbois [Mon, 5 Feb 2018 20:40:33 +0000 (06:40 +1000)]
test/parser: test no whitespace on grub menuentry

Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
19 months agogrub2/grub2: add Yocto paths to default grub2 conf search paths
Brett Grandbois [Mon, 5 Feb 2018 20:40:32 +0000 (06:40 +1000)]
grub2/grub2: add Yocto paths to default grub2 conf search paths

Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
19 months agogrub2/grub2-parser: accept no whitespace in grub menuentry
Brett Grandbois [Mon, 5 Feb 2018 20:40:31 +0000 (06:40 +1000)]
grub2/grub2-parser: accept no whitespace in grub menuentry

The Yocto wic grub support will generate a grub.cfg with no whitespace
between the ending quote of the menuentry label and the opening bracket.
There doesn't seem to be anything in the specification that this is
illegal so accept it here.

Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
19 months agoncurses/nc-cui: fix unreferenced assertion variable
Brett Grandbois [Mon, 5 Feb 2018 20:40:30 +0000 (06:40 +1000)]
ncurses/nc-cui: fix unreferenced assertion variable

Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
19 months agoncurses/nc-cui: musl libc fixes
Brett Grandbois [Mon, 5 Feb 2018 20:40:29 +0000 (06:40 +1000)]
ncurses/nc-cui: musl libc fixes

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>
19 months agodiscover/pb-discover: #include <locale.h> for musl libc
Brett Grandbois [Mon, 5 Feb 2018 20:40:28 +0000 (06:40 +1000)]
discover/pb-discover: #include <locale.h> for musl libc

Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
20 months agoprintf: Fix format type warnings
Geoff Levand [Sat, 6 Jan 2018 00:47:39 +0000 (00:47 +0000)]
printf: Fix format type warnings

Fixes build warnings like these when building 32 bit programs:

  warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument has type ‘uint64_t’

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
20 months agoconfigure: Update AC_PACKAGE_BUGREPORT
Geoff Levand [Sat, 6 Jan 2018 00:47:39 +0000 (00:47 +0000)]
configure: Update AC_PACKAGE_BUGREPORT

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
20 months agoconfigure: Add check for lex, yacc
Geoff Levand [Sat, 6 Jan 2018 00:47:39 +0000 (00:47 +0000)]
configure: Add check for lex, yacc

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
20 months agobootstrap: Add dependency checks
Geoff Levand [Mon, 8 Jan 2018 17:47:04 +0000 (09:47 -0800)]
bootstrap: Add dependency checks

Signed-off-by: Geoff Levand <geoff@infradead.org>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
20 months agoui/ncurses: Allow multiple hot key handlers per pmenu
Samuel Mendoza-Jonas [Mon, 18 Dec 2017 05:39:50 +0000 (16:39 +1100)]
ui/ncurses: Allow multiple hot key handlers per pmenu

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>
21 months agodiscover/pxe-parser: Fix relative parsing for manual config files
Samuel Mendoza-Jonas [Tue, 12 Dec 2017 03:05:40 +0000 (14:05 +1100)]
discover/pxe-parser: Fix relative parsing for manual config files

Manually specified config files are asynchronously downloaded by
device_handler_process_url() before being parsed. This overwrites the
'pxeconffile' parameter, causing the parser to create relative paths
relative to the downloaded file's path, not the original remote path.

Work around this by setting 'pxeconffile-local' instead to differentiate
between the original config file's location and the local copy.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
21 months agoTest with .travis.yml
Daniel Axtens [Mon, 14 Nov 2016 02:43:40 +0000 (13:43 +1100)]
Test with .travis.yml

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
21 months agoUse --no-location instead of --add-location=never
Daniel Axtens [Mon, 14 Nov 2016 03:20:59 +0000 (14:20 +1100)]
Use --no-location instead of --add-location=never

This fixes things for old versions of msgmerge such as the one
used on Travis CI (Ubuntu 14.04)

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
21 months agoui/ncurses: Always cancel autoboot on exit
Samuel Mendoza-Jonas [Thu, 23 Nov 2017 02:25:29 +0000 (13:25 +1100)]
ui/ncurses: Always cancel autoboot on exit

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>
22 months agoui/ncurses: Handle arrow key variants
Samuel Mendoza-Jonas [Mon, 20 Nov 2017 01:59:26 +0000 (12:59 +1100)]
ui/ncurses: Handle arrow key variants

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>
22 months agodiscover/pxe-parser: Fine grained proxy control
Cyril Bur [Thu, 16 Nov 2017 03:49:14 +0000 (14:49 +1100)]
discover/pxe-parser: Fine grained proxy control

Petitboot provides a method for a user to manually specify a
configuration file that should be retrieved. Petitboot also has a
global proxy configuration.

This patch aims to marry the two so that a custom configuration file
can specify that a specific proxy should be used to access one (or all)
of the options within it.

This makes custom configuration files more powerful as they can point
to files behind proxies without the user needing to also specify the
global proxy for that specific custom configuration file to work.

This adds parsing for a `proxy` option which will apply to all boot
items found after.

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
22 months agoBetter recognition of ncurses header files
Cyril Bur [Thu, 16 Nov 2017 03:49:13 +0000 (14:49 +1100)]
Better recognition of ncurses header files

This patch was lifted directly from:
https://github.com/Tlf/tlf/commit/a21513254ce8bf66d0b019f6075eea918958741a

The commit message reads:
  If ax_with_ncurses finds a ncursesw instance the former code checks
  only for <ncursesw/panelh>. If not there the search fails.
  That let to problems at least in Arch Linux which has only <panel.h>
  installed.
  The patched version here checks first for <ncursesw/panel.h> and if
  not found also for <panel.h>.

  Tested for the following distributions:

  Gentoo, Debian 7..9, Linux Mint 17 and 18.1, Arch Linux, Ubuntu

ARCH Linux builds ncurses with wide character support but does not add
any ncurses specific headers. nurses its self (by default) adds almost
no ncurses specific headers. No {prefix}/include/ncurses directory. In
fact the only ncurses specific file is the ncurses.h symlink to
curses.h, other than that there are no ncurses headers.

The ax_with_curses.m4 script detects if the installed ncurses has wide
character support. It checks using code snippets against all possible
ncurses header files.

If the ax_with_curses.m4 script detects wide character support the
ax_with_curses_extra.m4 will only look for extra curses features (in
the case of petitboot, form.h and menu.h) inside the
{prefix}/include/ncurses directory, when they could simply be in
{prefix}/include.

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
22 months agoFix bootstrap warning: noinst_PROGRAMS was already defined
Cyril Bur [Thu, 16 Nov 2017 03:49:12 +0000 (14:49 +1100)]
Fix bootstrap warning: noinst_PROGRAMS was already defined

utils/Makefile.am:27: warning: noinst_PROGRAMS was already defined in
condition TRUE, which includes condition HAVE_LIBFDT ...

utils/Makefile.am should probably be adding to noinst_PROGRAMS rather
than reclaring it.

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
22 months agoconfigure.ac: Fix unmatched brackets
Cyril Bur [Thu, 16 Nov 2017 03:49:11 +0000 (14:49 +1100)]
configure.ac: Fix unmatched brackets

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
22 months agoui/ncurses: Safely handle lost terminal control commands v1.6.3
Samuel Mendoza-Jonas [Mon, 30 Oct 2017 23:49:51 +0000 (10:49 +1100)]
ui/ncurses: Safely handle lost terminal control commands

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>
22 months agoAdd root .gitignore
Cyril Bur [Tue, 3 May 2016 23:25:44 +0000 (09:25 +1000)]
Add root .gitignore

This project uses autotools which generates many files not kept in git. This
commit adds files generated by:
./bootstrap
./configure

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
22 months agodiscover/platform-powerpc: Increase IPMI timeout v1.6.2
Samuel Mendoza-Jonas [Thu, 26 Oct 2017 03:10:57 +0000 (14:10 +1100)]
discover/platform-powerpc: Increase IPMI timeout

On OpenBMC platforms IPMI requests can take over five seconds to
complete. OpenBMC does inform OPAL in BT init that it may take up to
ten seconds to respond to any requests, so update our timeout value to
accommodate this extra delay.

On other platforms this will won't change anything (AMI- and SMC- based
BMCs for example respond in under a second), but on OpenBMC platforms
such as Witherspoon this will delay Petitboot significantly while we
wait for the response. This is not ideal but we need to wait in order to
receive important information such as a safe mode request.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
23 months agoui/ncurses: Remove help shortcut from nc-subset
Samuel Mendoza-Jonas [Thu, 12 Oct 2017 03:46:15 +0000 (14:46 +1100)]
ui/ncurses: Remove help shortcut from nc-subset

Subset screens do not include a help screen, so remove the misleading
"h=help" shortcut from the lower frame title.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
23 months agodiscover/device-handler: Fallback to device if snapshot fails to mount v1.6.1
Samuel Mendoza-Jonas [Tue, 10 Oct 2017 02:24:48 +0000 (13:24 +1100)]
discover/device-handler: Fallback to device if snapshot fails to mount

In the event that a snapshot fails to mount, destroy it and fall back to
the actual source device. While this loses the protection afforded by a
snapshot it avoids users being greeted with an empty boot menu and
unable to continue booting.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
23 months agoui/ncurses: Display multibyte strings correctly in textscreens
Samuel Mendoza-Jonas [Tue, 10 Oct 2017 04:36:27 +0000 (15:36 +1100)]
ui/ncurses: Display multibyte strings correctly in textscreens

In nc-textscreen each line of text is capped at a certain length to
avoid running off the side of the viewable screen. However it appears
the ncurses function mvwaddnstr() counts by byte instead of actual
character, causing strings which contain multibyte characters to be cut
short.

To avoid this check the displayed length of each string against the
screen width, and if under instruct mvwaddnstr() to print the whole
string.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
23 months agoui/ncurses: Spawn shell in exit handler
Samuel Mendoza-Jonas [Tue, 29 Aug 2017 03:52:31 +0000 (13:52 +1000)]
ui/ncurses: Spawn shell in exit handler

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>
2 years agoui/ncurses: Fixup some missing gettext calls
Samuel Mendoza-Jonas [Fri, 15 Sep 2017 01:24:17 +0000 (11:24 +1000)]
ui/ncurses: Fixup some missing gettext calls

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agopo: Translation Updates
Samuel Mendoza-Jonas [Wed, 13 Sep 2017 04:15:45 +0000 (14:15 +1000)]
po: Translation Updates

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agopo: Update translations v1.6.0
Samuel Mendoza-Jonas [Fri, 30 Jun 2017 01:51:45 +0000 (11:51 +1000)]
po: Update translations

General translation update, adds several new translation source files
including parsers and the plugin and statuslog screens.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoui/ncurses: Don't modify config when clearing IPMI override
Samuel Mendoza-Jonas [Thu, 24 Aug 2017 01:43:45 +0000 (11:43 +1000)]
ui/ncurses: Don't modify config when clearing IPMI override

When safe mode is active the config displayed in nc-config is only a
subset of the actual config since device init has not yet occurred.
However when the "clear override" checkbox is ticked and the config
saved, the form will set the config as it is displayed, resulting in
device-specific config (eg. boot order and network settings) being
cleared. If the user only ticked the "clear override" checkbox this most
likely isn't what they intended.

Instead change the checkbox to a button which when pressed clears the
override and exits safe mode if active, without modifying the rest of
the configuration.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/device-handler: Disable safe mode warning on reinit
Samuel Mendoza-Jonas [Wed, 23 Aug 2017 01:05:58 +0000 (11:05 +1000)]
discover/device-handler: Disable safe mode warning on reinit

If a user pressed "Rescan Devices" in safe mode the reinit would
complete successfully, but the big warning that safe mode is active
would remain. On reinit clear the safe_mode flag properly.

This has no functional change aside from clearing the UI warning - the
IPMI override remains active until cleared or a successful boot occurs.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agolib/flash: Update type of size field
Samuel Mendoza-Jonas [Tue, 22 Aug 2017 06:51:07 +0000 (16:51 +1000)]
lib/flash: Update type of size field

Skiboot commit c043065 "flash: Make size 64 bit safe" updated the
prototype of blocklevel_get_info() to use a uint64_t for the size
parameter. Update our usage to reflect this.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover: Update env vars at init and suppress LVM warnings
Samuel Mendoza-Jonas [Tue, 22 Aug 2017 01:41:09 +0000 (11:41 +1000)]
discover: Update env vars at init and suppress LVM warnings

Environment variables are not platform-specific so move
set_proxy_variables to device-handler and call it at handler init.

At the same time set LVM_SUPPRESS_FD_WARNINGS to ignore the "file
descriptor leaked" warnings when calling LVM-utilities, since we must
keep some file descriptors open in lib/process.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/ipmi: Open devnode with O_CLOEXEC
Samuel Mendoza-Jonas [Tue, 22 Aug 2017 01:36:06 +0000 (11:36 +1000)]
discover/ipmi: Open devnode with O_CLOEXEC

The IPMI device node is kept open for the life of the platform - include
the O_CLOEXEC flag so it is not kept open for child processes.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/device-handler: Be ready for user events earlier
Samuel Mendoza-Jonas [Tue, 15 Aug 2017 01:08:58 +0000 (11:08 +1000)]
discover/device-handler: Be ready for user events earlier

Actions performed in network and udev init may result in pb-event
callbacks (such as from udhcpc or pb-plugin), so make sure the user
event interface is set up beforehand.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoui/ncurses: Add plugin menu and nc-plugin screen
Samuel Mendoza-Jonas [Mon, 24 Jul 2017 05:58:50 +0000 (15:58 +1000)]
ui/ncurses: Add plugin menu and nc-plugin screen

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>
2 years agoui/ncurses: Update cui_run_cmd() to pass display to command
Samuel Mendoza-Jonas [Wed, 15 Feb 2017 03:47:45 +0000 (14:47 +1100)]
ui/ncurses: Update cui_run_cmd() to pass display to command

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>
2 years agodiscover: Handle plugin install request
Samuel Mendoza-Jonas [Fri, 16 Jun 2017 05:09:55 +0000 (15:09 +1000)]
discover: Handle plugin install request

Handle "_PLUGIN_INSTALL" requests from clients. Calling the pb-plugin
script from pb-discover ensures different clients don't trip over each
other. Successfully installed plugins are automatically communicated
back to clients once pb-plugin sends a 'plugin' user event.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/device-handler: Scan devices for plugins
Samuel Mendoza-Jonas [Mon, 24 Jul 2017 05:14:49 +0000 (15:14 +1000)]
discover/device-handler: Scan devices for plugins

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoAdd pb-plugin and pb-exec to pb_system_apps
Samuel Mendoza-Jonas [Tue, 25 Jul 2017 06:07:53 +0000 (16:07 +1000)]
Add pb-plugin and pb-exec to pb_system_apps

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoutils/pb-plugin: Advertise pb-plugins to discover server
Samuel Mendoza-Jonas [Tue, 25 Jul 2017 06:07:40 +0000 (16:07 +1000)]
utils/pb-plugin: Advertise pb-plugins to discover server

Update the pb-plugin utility to create a 'plugin' pb-event when it
successfully scans or installs a pb-plugin.
To aid invoking pb-plugin from pb-discover there following two commands
are updated:
 - `pb-plugin scan` can now be called for a single directory.
 - `pb-plugin install` now has an optional "auto" argument that will
 skip asking for confirmation before installation.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoutils: Add pb-exec wrapper
Samuel Mendoza-Jonas [Tue, 25 Jul 2017 06:08:11 +0000 (16:08 +1000)]
utils: Add pb-exec wrapper

Add a small wrapper script for the Petitboot UI to call interactable
programs with. The wrapper calls the program and waits for user input
before returning to the Petitboot UI.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agolib/process: Add raw stdout mode
Samuel Mendoza-Jonas [Tue, 14 Feb 2017 04:52:35 +0000 (15:52 +1100)]
lib/process: Add raw stdout mode

Allow process users to set 'raw_stdout', which if set skips redirecting
and saving output from processes.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover: Add 'plugin' user-event
Samuel Mendoza-Jonas [Tue, 25 Jul 2017 05:55:19 +0000 (15:55 +1000)]
discover: Add 'plugin' user-event

Add a new user event to advertise pb-plugins and add them to the
device_handler. Plugins described by this event can either be
uninstalled pb-plugin files or successfully installed pb-plugins
depending on the associated parameters.
The is primarily intended for use by the pb-plugin utility itself to
notify Petitboot as it operates on pb-plugin files.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover: Handle and track plugin_options
Samuel Mendoza-Jonas [Wed, 1 Feb 2017 05:11:43 +0000 (16:11 +1100)]
discover: Handle and track plugin_options

Track plugin_options in the device_handler. Plugins can be added with
device_handler_add_plugin_option() and accessed via
device_handler_get_plugin().
Extend discover_server to support the new 'add' and 'remove' pb-protocol
actions and advertise new plugins to connecting clients.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/pxe-parser: Recognise plugin sources
Samuel Mendoza-Jonas [Tue, 14 Feb 2017 04:56:14 +0000 (15:56 +1100)]
discover/pxe-parser: Recognise plugin sources

Extend the pxe-parser to recognise 'PLUGIN' as well as the usual 'LABEL'
when parsing a config file. 'PLUGIN' will be used to specify an option
that provides the location of an installable pb-plugin file, named by
the 'TARBALL' label.

Since plugin options are discovered via the same mechanism as boot
options treat them the same as boot options and at the 'type' field to
the boot_option struct to differentiate between them.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agolib: Add plugin_option type and protocol
Samuel Mendoza-Jonas [Tue, 14 Feb 2017 04:56:55 +0000 (15:56 +1100)]
lib: Add plugin_option type and protocol

Add a new struct 'plugin_option' to represent pb-plugins that are
installed on the system. This consists of plugin metadata and an array
of installed executables.
This also adds two new pb-protocol actions to advertise the addition of
a new plugin_option, and to remove known plugin_options.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoui/ncurses: Create pad for nc-add-url screen
Samuel Mendoza-Jonas [Thu, 10 Aug 2017 01:04:58 +0000 (11:04 +1000)]
ui/ncurses: Create pad for nc-add-url screen

Bring setup for the add-url screen into line with other screens. This
fixes an issue with a proper redraw not occurring on help screen init or
screen exit, and facilitates other work on simplifying screen init.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoui/ncurses: Increase height of boot-editor pad v1.5.1
Samuel Mendoza-Jonas [Wed, 26 Jul 2017 04:08:26 +0000 (14:08 +1000)]
ui/ncurses: Increase height of boot-editor pad

Similarly to nc-subset, extend the maximum height of the boot-editor pad
to account for the fields of the device select potentially wrapping due
to long device names.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/device-handler: Mention booting device in timeout status
Samuel Mendoza-Jonas [Thu, 13 Jul 2017 00:19:18 +0000 (10:19 +1000)]
discover/device-handler: Mention booting device in timeout status

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agopb-sos: effectively compress the pb-sos file with gzip v1.5.0
Guilherme G. Piccoli [Tue, 11 Jul 2017 18:04:05 +0000 (15:04 -0300)]
pb-sos: effectively compress the pb-sos file with gzip

Currently the pb-sos tool creates a TAR file with logs, but without
compressing it using gzip, for example. Even the output of command
says "Compressing...", but in fact no compression is done.

This patch uses gzip to effectively compress the logs. It achieves
83% of compression, observed after a simple experiment.
Also, makes use of $tarflags variable instead of pass the flags
directly in the command call.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agopb-sos: capture Skiboot log
Guilherme G. Piccoli [Tue, 11 Jul 2017 18:04:04 +0000 (15:04 -0300)]
pb-sos: capture Skiboot log

Makes sense to capture Skiboot log in pb-sos, specially since
it might help clarify about HW problems, like PCI initialization
failures.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover: Wait for net interfaces to be marked ready
Samuel Mendoza-Jonas [Thu, 15 Jun 2017 05:23:06 +0000 (15:23 +1000)]
discover: Wait for net interfaces to be marked ready

If pb-discover is started before udev has settled there is a race
between Petitboot configuring interfaces and udev renaming them. If an
interface is set "up" the name change will fail and interfaces can be
inconsistently named, eg:

  Device:        (*) eth0 [0c:c4:7a:f4:1c:50, link up]
                 ( ) enP1p9s0f1 [0c:c4:7a:f4:1c:51, link down]
                 ( ) enP1p9s0f2 [0c:c4:7a:f4:1c:52, link down]
                 ( ) enP1p9s0f3 [0c:c4:7a:f4:1c:53, link down]

Add "net" devices to the udev filter and wait for them to be announced
by udev before configuring them.
udev_enumerate_add_match_is_initialized() ensures that by the time an
interface appears via udev its name will be consistent.

This also swaps the network and udev init order, but since interfaces
now will not be configured until after udev is ready this should not
have a user-visible effect.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/udev: Handle LVM logical volumes
Samuel Mendoza-Jonas [Wed, 14 Jun 2017 05:17:21 +0000 (15:17 +1000)]
discover/udev: Handle LVM logical volumes

If logical volumes are active and recognised by udev, no longer ignore
them. We also do some extra handling to use user-friendly device names
and mount the /dev/mapper/foo device rather than the /dev/dm-xx device.

Additionally if we see "LMV2_member" devices start a rescan in case
LVM-formatted disks came up after the LVM initscript.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agolib/system: Add vgscan, vgchange utilities
Samuel Mendoza-Jonas [Wed, 14 Jun 2017 08:53:01 +0000 (18:53 +1000)]
lib/system: Add vgscan, vgchange utilities

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/devmapper: Add prefix to devmapper device names
Samuel Mendoza-Jonas [Wed, 14 Jun 2017 05:17:28 +0000 (15:17 +1000)]
discover/devmapper: Add prefix to devmapper device names

Add a 'pb-' prefix to all device mapper devices created by Petitboot.
Beyond helping to identify Petitboot-related devices, this avoids naming
collisions if we create snapshots of LVM logical volumes which also
exist in /dev/mapper.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoui/ncurses: Extend nc-subset pad height
Samuel Mendoza-Jonas [Wed, 14 Jun 2017 05:17:35 +0000 (15:17 +1000)]
ui/ncurses: Extend nc-subset pad height

The nc-subset screen can exceed its maximum height if some options are
long enough to wrap around to two lines. Increaes the maximum size of
the pad to account for every line potentially wrapping once.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/device-handler: Allow process_url request to be pending
Samuel Mendoza-Jonas [Thu, 23 Mar 2017 06:43:29 +0000 (17:43 +1100)]
discover/device-handler: Allow process_url request to be pending

device_handler_process_url() fails immediately if no network is
available. For individual files queue the load task for later instead.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/paths: Add network jobs to queue
Samuel Mendoza-Jonas [Thu, 23 Mar 2017 06:42:37 +0000 (17:42 +1100)]
discover/paths: Add network jobs to queue

Load tasks that start before the network is available will fail. Rather
than just fail these tasks, add them to a queue that is processed once
the network is ready. This helps users who try to request files early in
setup, as well as very early running load tasks.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/sysinfo: Add network availability helper
Samuel Mendoza-Jonas [Thu, 23 Mar 2017 06:42:03 +0000 (17:42 +1100)]
discover/sysinfo: Add network availability helper

Add a helper function that describes interfaces as available if they
have an assigned address.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/sysinfo: Add system_info_reinit()
Samuel Mendoza-Jonas [Thu, 23 Mar 2017 06:41:28 +0000 (17:41 +1100)]
discover/sysinfo: Add system_info_reinit()

Currently over reinit events the system info is not affected. However
network and block device information can change over reinit, so clear
this information.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoconfigure.ac: correct name of device-mapper-devel for RHEL v1.4.3
Daniel Black [Tue, 6 Jun 2017 00:20:50 +0000 (10:20 +1000)]
configure.ac: correct name of device-mapper-devel for RHEL

The RHEL and Fedora package name for development device mapper library is device-mapper-devel

Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/platform-powerpc: Handle optional Get Device ID section
Samuel Mendoza-Jonas [Wed, 14 Jun 2017 02:01:35 +0000 (12:01 +1000)]
discover/platform-powerpc: Handle optional Get Device ID section

The 'auxiliary' section of the 'Get Device ID' response is optional,
and some platforms exclude it from the response entirely. However
Petitboot only recognises the response as valid if it includes the full
16 bytes.
Update get_ipmi_bmc_versions() to also handle responses of only 12 bytes.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/platform-powerpc: Correct aux revision format
Samuel Mendoza-Jonas [Thu, 27 Apr 2017 06:33:32 +0000 (16:33 +1000)]
discover/platform-powerpc: Correct aux revision format

The Auxiliary Firmware Revision Information should be displayed as four
hexadecimal bytes if a manufacturer-specific format is not known. Update
the "Firmware version" format to reflect this.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/device-handler: Include makedev() from sysmacros.h
Samuel Mendoza-Jonas [Thu, 27 Apr 2017 05:35:45 +0000 (15:35 +1000)]
discover/device-handler: Include makedev() from sysmacros.h

Include sys/sysmacros.h explicitly in response to the following error
message:

../discover/device-handler.c:1001:13: warning: In the GNU C Library, "makedev" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "makedev", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "makedev", you should undefine it after including <sys/types.h>.
  id = makedev(1, handler->n_ramdisks);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/platform-powerpc: Don't fail early if nvram fails
Samuel Mendoza-Jonas [Thu, 27 Apr 2017 05:28:49 +0000 (15:28 +1000)]
discover/platform-powerpc: Don't fail early if nvram fails

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoutil/hooks: Don't update DT when ttyS* console active v1.4.2
Samuel Mendoza-Jonas [Fri, 10 Mar 2017 05:44:33 +0000 (16:44 +1100)]
util/hooks: Don't update DT when ttyS* console active

Update 30-dtb-updates to not accidentally treat ttyS* consoles as tty*
and update linux,stdout-path with the VGA console details.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoutils/hooks: Don't fail early if fb0 missing
Samuel Mendoza-Jonas [Wed, 8 Mar 2017 23:59:15 +0000 (10:59 +1100)]
utils/hooks: Don't fail early if fb0 missing

30-dtb-updates would exit early if the 'fb0' file was missing, however
the set_stdout() step does not depend on this.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover: Track both configured and current autoboot settings
Samuel Mendoza-Jonas [Wed, 25 Jan 2017 03:45:37 +0000 (14:45 +1100)]
discover: Track both configured and current autoboot settings

If autoboot is enabled but later disabled or cancelled by, for example,
an IPMI override then the nc-config screen will set the autoboot widget
as disabled. If the user then makes and saves a change in nc-config,
autoboot will also be saved as disabled. This accidental change is
particularly awkward if the user is attempting to remove an IPMI
override.

Instead only ever change the autoboot setting if the user explicitly
changes it. Use a new helper function 'config_autoboot_active()' to
determine the current autoboot status where needed.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoui/ncurses: Fix adding unnecessary leading slashes to paths
Samuel Mendoza-Jonas [Mon, 20 Feb 2017 05:24:47 +0000 (16:24 +1100)]
ui/ncurses: Fix adding unnecessary leading slashes to paths

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/sysinfo: Fix useless error message
Samuel Mendoza-Jonas [Mon, 16 Jan 2017 03:28:57 +0000 (14:28 +1100)]
discover/sysinfo: Fix useless error message

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoprocess: Cancel all asynchronous jobs on reinit v1.4.1
Samuel Mendoza-Jonas [Mon, 23 Jan 2017 03:53:32 +0000 (14:53 +1100)]
process: Cancel all asynchronous jobs on reinit

If an asynchronous job is running over a reinit, the process can return
and run its callback function after the reinit. This becomes a problem
if the callback function accesses pointers that were only valid before
the reinit (eg. device structs).
If a reinit is requested explicitly stop all active asynchronous jobs
and clear their callback functions before the reinit.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/device-handler: Cancel pending boot on reinit
Samuel Mendoza-Jonas [Mon, 23 Jan 2017 03:53:08 +0000 (14:53 +1100)]
discover/device-handler: Cancel pending boot on reinit

When a reinit is requested device_handler_cancel_default() is
called, however as the name suggests this only cancels the boot task if
it is the result of a default boot option. We also want to cancel a boot
task if it was executed manually because it may have outstanding
asynchronous transfers running, so explicitly cancel it during reinit.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/device-handler: Process queue after device added
Samuel Mendoza-Jonas [Tue, 24 Jan 2017 03:52:20 +0000 (14:52 +1100)]
discover/device-handler: Process queue after device added

In device_handler_discover() we process the unresolved boot options
queue first. However the discover_device in question has not yet been
added to handler->devices so when a parser tries to search for a
matching device it will fail.
The discover_device will be added to the handler if it has not already
in device_handler_discover_context_commit() so move the call to
process_boot_option_queue() after it.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/network: Ignore interfaces with pre-existing MAC address
Samuel Mendoza-Jonas [Thu, 12 Jan 2017 00:12:42 +0000 (11:12 +1100)]
discover/network: Ignore interfaces with pre-existing MAC address

Petitboot uses the MAC address of network interfaces as a unique
identifier. This can cause a crash in pb-discover on a machine that has
multiple interfaces with the same MAC address.
While duplicate MAC addresses are rare and imply an issue with the
larger system configuration Petitboot should handle this gracefully, so
log a warning and ignore any interfaces other than the first to appear
that share a MAC address.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/network: Ensure interfaces have device before configuring
Samuel Mendoza-Jonas [Wed, 21 Dec 2016 04:46:09 +0000 (15:46 +1100)]
discover/network: Ensure interfaces have device before configuring

Reorganise network_handle_nlmsg() slightly to create interface->dev just
before calling configure_interface() rather than only for brand new
interfaces. This ensures existing interfaces which have had ->dev
removed but receive a new configure event do not access a NULL pointer
during the configuration process.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agodiscover/network: Search by UUID only if available
Samuel Mendoza-Jonas [Fri, 23 Dec 2016 01:01:26 +0000 (12:01 +1100)]
discover/network: Search by UUID only if available

When registering a new discover device it is possible the device does
not have an associated UUID, for example when created via
device_handler_process_url(). Fall back to find_interface_by_name() in
this case.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
2 years agoui/ncurses: Display IP address in nc-sysinfo v1.4.0
Samuel Mendoza-Jonas [Mon, 19 Dec 2016 04:59:04 +0000 (15:59 +1100)]
ui/ncurses: Display IP address in nc-sysinfo

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>