]> git.ozlabs.org Git - petitboot/log
petitboot
8 years agodiscover/grub2: Fix handling of positional parameters
Alan Dunn [Wed, 2 Mar 2016 16:59:02 +0000 (08:59 -0800)]
discover/grub2: Fix handling of positional parameters

Positional parameters are set in the environment with '$' prepended to
the name.  This causes lookups to fail because parameter lookups don't
include the '$'.

TESTED:
 Added a test that covers positional parameters in GRUB2 parser.
 Build succeeds, tests pass.

Bootstrapped-by: Nancy Yuen <yuenn@google.com>
Signed-off-by: Alan Dunn <amdunn@google.com>
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoChange parser interface to allow stat
Alan Dunn [Wed, 24 Feb 2016 16:12:25 +0000 (08:12 -0800)]
Change parser interface to allow stat

Currently, the GRUB2 parser incorrectly reports "[ -f <path> ]" as
false if the size of the file is above 1 MB.  This patch changes the
parser interface to allow stating files (with parser_stat_file).  Then
in the implementation of "[ -f <path> ]", we can use parser_stat_file
instead of parser_request_file which has the size limitation.  I
eliminate parser_check_dir in lieu of this new interface, which has
the side effect of making "[ -d <path> ]" work (the error code for
stat was not checked correctly before).

I add a basic test for the test file operations -f, -s, and -d (to
show that my changes to test file operations do not break them) and
minorly modify the test framework to ensure it has enough fidelity to
cause the expected results.  Unfortunately the test wouldn't have
caught the issue with -d, since the test framework stubs out the
parser interface itself.  Nor can the test framework catch the initial
problem with -f because the imposed limit is (transitively) in
function parser_request_file.

Note that -f and -d follow symlinks despite the fact that GRUB does
not (see
http://lists.gnu.org/archive/html/grub-devel/2016-02/msg00142.html
discussing GRUB's behavior).  This is not a change to Petitboot's
behavior though.

Tested:
 The test test-grub2-test-file-ops passes.  I booted Petitboot against
 a GRUB snippet:

status=success

if [ ! -f /large_file -a $status = success ]
then status=fail_large_file
fi
if [ ! -d /a_directory -a $status = success ]
then status=fail_dir
fi

menuentry $status {
  linux /vmlinux
}

 (after making /large_file a file of size > 1 MiB and /a_directory a
 directory) and the menuentry had title "success", as desired.

Signed-off-by: Alan Dunn <amdunn@google.com>
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoIn GRUB2 parser save_env, treat unset variable value as empty
Alan Dunn [Tue, 15 Mar 2016 00:40:47 +0000 (17:40 -0700)]
In GRUB2 parser save_env, treat unset variable value as empty

It seems better to treat unset variable values as empty rather than
crashing in save_env.  While GRUB's behavior is actually to delete the
variable from the environment block, it seems useful to at least not
crash while later on someone can do further work to improve GRUB
compatibility if desired.

Tested:
 Modified test-grub2-save-env to cover this case.

Signed-off-by: Alan Dunn <amdunn@google.com>
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agopo: Update help string and add untranslated strings
Sam Mendoza-Jonas [Sun, 6 Mar 2016 23:42:46 +0000 (10:42 +1100)]
po: Update help string and add untranslated strings

Update the nc-lang help string translation to reflect the change
introduced in the previous commit, "Remove "h=help" hint in language page".
Also update each .po file with any new strings lacking a translation.

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoMerge pull request #13 from johnhihi/master
Sam Mendoza-Jonas [Sun, 6 Mar 2016 23:52:06 +0000 (10:52 +1100)]
Merge pull request #13 from johnhihi/master

Remove "h=help" hint in language page

8 years agolib/flash: Fix version side being interpreted backwards
Sam Mendoza-Jonas [Fri, 4 Mar 2016 23:20:33 +0000 (10:20 +1100)]
lib/flash: Fix version side being interpreted backwards

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoRemove "h=help" hint in language page
Johnny [Wed, 2 Mar 2016 07:52:22 +0000 (15:52 +0800)]
Remove "h=help" hint in language page

Signed-off-by: Johnny <johnny.cl.chang@foxconn.com>
8 years agoUse 'Primary' instead of 'Current' for flash sides
Sam Mendoza-Jonas [Thu, 25 Feb 2016 23:39:55 +0000 (10:39 +1100)]
Use 'Primary' instead of 'Current' for flash sides

When queried libflash will return the 'first' flash side (ie. the one
with the lowest TOC address), however we label this the 'Current' side
which is incorrect if the machine has booted from the alternate side.

A future fix will inlcude additional platform logic to determine which
flash side is current; in the interim label the first flash side as
'Primary' instead of 'Current'.

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agodiscover: Include leading zero in firmware version string
Sam Mendoza-Jonas [Wed, 24 Feb 2016 23:40:59 +0000 (10:40 +1100)]
discover: Include leading zero in firmware version string

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agodiscover: Add support for IPMI network override
Sam Mendoza-Jonas [Mon, 15 Feb 2016 05:47:01 +0000 (16:47 +1100)]
discover: Add support for IPMI network override

On BMC platforms the 'Get System Boot Options' command can also be used
to check for a temporary network interface config override. This is
implemented via the optional 'OEM Parameters' field defined in the IPMI
v2 spec. We define the actual format of the field as:
- 4 byte cookie value
- 2 byte version value
- 1 byte hardware address size
- 1 byte IP address size
- Hardware address
- 1 byte flags for 'ignore' and 'method'
And for static configs:
- IP Address
- 1 byte subnet value
- Gateway address

If set the config override replaces any other interface config, forcing
the use of the specified configuration.

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoutils/hooks: Write offb device address to device tree
Sam Mendoza-Jonas [Tue, 22 Dec 2015 02:39:28 +0000 (10:39 +0800)]
utils/hooks: Write offb device address to device tree

On OpenPOWER machines, kernels missing the AST video driver can use the
existing 'Open Firmware' framebuffer device code to inherit an existing
framebuffer from Petitboot. This requires us to translate the 64-bit
address of the framebuffer 'back' into a PCI address and write it into
an assigned-addresses property in the device tree.

Bootstrapped-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoui/ncurses: Add missing newline in nc-sysinfo
Sam Mendoza-Jonas [Wed, 10 Feb 2016 04:28:49 +0000 (15:28 +1100)]
ui/ncurses: Add missing newline in nc-sysinfo

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoRetrieve BMC version info via IPMI
Sam Mendoza-Jonas [Fri, 29 Jan 2016 04:16:34 +0000 (15:16 +1100)]
Retrieve BMC version info via IPMI

On BMC machines the "Get Device ID" and "Get BMC Golden Side Version"
IPMI commands are available. If possible retrieve some interesting
version numbers and display them in the System Information screen.

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoDisplay VERSION partition info on BMC machines
Samuel Mendoza-Jonas [Tue, 8 Dec 2015 23:32:41 +0000 (10:32 +1100)]
Display VERSION partition info on BMC machines

On supported platforms read the VERSION partition on startup and display
the available versions strings in the System Information screen.

This adds a skeleton hostboot.c to support possible additional BMC
platform support.

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agolib/flash: Add support for platform versions
Samuel Mendoza-Jonas [Mon, 14 Dec 2015 23:02:31 +0000 (10:02 +1100)]
lib/flash: Add support for platform versions

Add basic libflash support to read the VERSION partition on BMC
machines. This adds a dependency on the libflash shared library from
Skiboot.
The MTD partition is accessed through the libflash helper functions.
Once read into a buffer, the VERSION partition is a simple list of
newline-terminated version strings. Some BMC platforms may have two
'sides' to flash - these are interpreted as the "current" and "other"
sides depending on which one the current Petitboot is running from.

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agolib: Add CCAN headers for endian helpers
Samuel Mendoza-Jonas [Mon, 14 Dec 2015 23:02:46 +0000 (10:02 +1100)]
lib: Add CCAN headers for endian helpers

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoAdd --enable-mtd configure option
Samuel Mendoza-Jonas [Mon, 14 Dec 2015 03:25:12 +0000 (14:25 +1100)]
Add --enable-mtd configure option

Support optionally building features that rely on libflash support.

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agodiscover: Print IPMI bootdev response for debug
Sam Mendoza-Jonas [Wed, 13 Jan 2016 02:11:05 +0000 (13:11 +1100)]
discover: Print IPMI bootdev response for debug

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agodiscover/grub: Fix handling of empty strings
Sam Mendoza-Jonas [Tue, 12 Jan 2016 04:58:13 +0000 (15:58 +1100)]
discover/grub: Fix handling of empty strings

If "" or '' are used in a statement to omit a word, we must still
return a TOKEN_WORD for an empty string.

In particular this fixes an issue where Petitboot would fail to parse
the grub.cfg included in the Debian 8.2 install image, which includes a
menuentry statement with an empty name.

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agolib/talloc: Avoid early exit before va_end()
Samuel Mendoza-Jonas [Fri, 18 Dec 2015 03:04:15 +0000 (14:04 +1100)]
lib/talloc: Avoid early exit before va_end()

Fixes Coverity defect #30486

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agodiscover: Release process resources on error
Samuel Mendoza-Jonas [Fri, 18 Dec 2015 03:00:49 +0000 (14:00 +1100)]
discover: Release process resources on error

Fixes Coverity defect #30472

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agoui/common: Only close valid file descriptor
Samuel Mendoza-Jonas [Fri, 18 Dec 2015 02:51:00 +0000 (13:51 +1100)]
ui/common: Only close valid file descriptor

Fixes Coverity defect #30466

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agodiscover: Handle BTRFS root subvolumes
Sam Mendoza-Jonas [Tue, 5 Jan 2016 04:01:58 +0000 (15:01 +1100)]
discover: Handle BTRFS root subvolumes

During install some distributions[0] will create subvolumes when formatting
the root filesystem with BTRFS. In particular this can mean that
bootloader config files will appear (in the case of GRUB) under
/var/petitboot/mnt/dev/$device/@/boot/grub/
rather than the expected
/var/petitboot/mnt/dev/$device/boot/grub/

If this is the case, perform all file operations from the parser
relative to this subvolume rather than the mount point. At the moment
this only supports the trivial case where the subvolume name for root is
blank (ie. '@').

[0] In particular, Ubuntu from at least 14.04

Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agodiscover/grub2: Fix behavior of save_env -f
Alan Dunn [Tue, 12 Jan 2016 23:43:02 +0000 (15:43 -0800)]
discover/grub2: Fix behavior of save_env -f

Currently, "save_env -f" in the GRUB2 parser only works with three
arguments, which means only commands of the form "save_env -f <path>"
that save *no* environment variables are allowed.

Allow "save_env -f <path> [<var>]*", making "save_env -f" useful.

Tested:
 Unit test test-grub2-save-env-dash-f tests this change, and the
 remaining unit tests still pass.

Signed-off-by: Alan Dunn <amdunn@google.com>
Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
8 years agolib/pb-protocol: Fix NULL dereference on non-powerpc
Samuel Mendoza-Jonas [Mon, 21 Dec 2015 05:16:40 +0000 (16:16 +1100)]
lib/pb-protocol: Fix NULL dereference on non-powerpc

If not running on a powerpc platform the bmc_mac pointer remains NULL.
If this is the case set an address of zero when serialising rather
than dereferencing the pointer.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: extend URL in UI to support auto-discovery
Nishanth Aravamudan [Wed, 19 Aug 2015 21:05:43 +0000 (14:05 -0700)]
discover: extend URL in UI to support auto-discovery

The URL field currently only supports loading a particular file for
static network configurations. But it makes sense in certain static
network configurations to 'auto-discover' a file like petitboot does
with DHCP -- based off the MAC address and IP. Extend
device_handler_process_url to take those as parameters, and toggle off
the URL ending in a '/' to indicate whether to 'auto-discover' or
directly load the specified URL.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui: add URL for static configurations to load a specified file
Nishanth Aravamudan [Wed, 19 Aug 2015 21:05:05 +0000 (14:05 -0700)]
ui: add URL for static configurations to load a specified file

In certain configurations, e.g. automation, we want to use static
networking but load a particular file, automatically and parse it as a
pxelinux config file. Currently, we support something like this for DHCP
based booting, but not static. Add a URL field to the UI for static
configurations and reuse the logic from device_handler_process_url() to
load the specified file.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoMerge pull request #11 from open-power/coverity
Sam Mendoza-Jonas [Fri, 18 Dec 2015 00:28:30 +0000 (11:28 +1100)]
Merge pull request #11 from open-power/coverity

Coverity fixes

8 years agoui/ncurses: Remove redundant assignment
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 23:24:29 +0000 (10:24 +1100)]
ui/ncurses: Remove redundant assignment

Fixes Coverity defect #30484

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Set umask before mkstemp()
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 23:04:23 +0000 (10:04 +1100)]
discover: Set umask before mkstemp()

Fixes Coverity defect #30479

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Null-terminate buffer in user_event_process()
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 06:08:01 +0000 (17:08 +1100)]
discover: Null-terminate buffer in user_event_process()

Fixes Coverity defect #30480

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Add two missing talloc_free()s
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 06:01:28 +0000 (17:01 +1100)]
discover: Add two missing talloc_free()s

Fixes Coverity defects #30474 and #30475

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Skip malformed bootdev fields
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 05:58:59 +0000 (16:58 +1100)]
discover: Skip malformed bootdev fields

Fixes Coverity defect #30471

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/common: Free message on return
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 05:44:07 +0000 (16:44 +1100)]
ui/common: Free message on return

Fixes Coverity defect #30468

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agolib/talloc: Add missing va_end() calls
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 05:38:24 +0000 (16:38 +1100)]
lib/talloc: Add missing va_end() calls

Fixes Coverity defects #30485 and #30486

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Fix dead code in udev_handle_cdrom_events()
Samuel Mendoza-Jonas [Fri, 18 Dec 2015 00:15:01 +0000 (11:15 +1100)]
discover: Fix dead code in udev_handle_cdrom_events()

The check against ddev->mounted to cause an eject action is logically
impossible. Change it so a cdrom_eject() is called properly.
Change the return value to 'true' for any action caused by
DISK_EJECT_REQUEST - no further action is appropriate in this case

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Check for NULL in pmenu_item_get_index()
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 05:11:41 +0000 (16:11 +1100)]
ui/ncurses: Check for NULL in pmenu_item_get_index()

Fixes Coverity defect #30476

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Use snprintf() when building sysparam path
Samuel Mendoza-Jonas [Mon, 9 Nov 2015 03:59:41 +0000 (14:59 +1100)]
discover: Use snprintf() when building sysparam path

Fixes Coverity defects #30481 and #30482

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Properly handle return values
Samuel Mendoza-Jonas [Mon, 9 Nov 2015 03:45:58 +0000 (14:45 +1100)]
discover: Properly handle return values

Fixes three unchecked return values, and one missing
initialisation.
Fixes Coverity defects #30450, #30451, #30454, and #30483

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoMerge pull request #10 from themoken/master
Sam Mendoza-Jonas [Thu, 17 Dec 2015 00:42:41 +0000 (11:42 +1100)]
Merge pull request #10 from themoken/master

Add BMC interface MAC to system info output

8 years agoAdd BMC interface MAC to system info output
Jack Miller [Wed, 9 Dec 2015 18:03:24 +0000 (12:03 -0600)]
Add BMC interface MAC to system info output

Useful for identifying the initial BMC traffic on the network.

Signed-off-by: Jack Miller <jack@codezen.org>
8 years agopo: Translation updates
Samuel Mendoza-Jonas [Wed, 11 Nov 2015 03:00:12 +0000 (14:00 +1100)]
po: Translation updates

- Abbreviate several translations of "Disk R/W".
- Do not expand 'DHCP' in pt_BR.
- Remove several extra space characters in French translations.
- Shorten some translations of "Boot Order", "DNS Servers".

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agopo: Translation Updates
Samuel Mendoza-Jonas [Fri, 30 Oct 2015 02:18:02 +0000 (13:18 +1100)]
po: Translation Updates

Abbreviation and help text updates.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover/ipmi: Increase IPMI timeout to a reasonable value
Jeremy Kerr [Wed, 30 Sep 2015 00:38:36 +0000 (08:38 +0800)]
discover/ipmi: Increase IPMI timeout to a reasonable value

We've seen some IPMI timeouts during testing - meaning that an IPMI
bootdev setting will be ignored. This can result in a machine booting
from an incorrect boot device, or missing a 'safe mode' indication, or
incorrectly proceeding past petitboot.

The firmware & kernel has its own timeout & retry mechanism, so we
already have a little error-recovery there; the timeout in petitboot is
to prevent an indefinite block if the kernel interface isn't behaving
correctly.

So, this change bumps the timeout to a value that suits BMCs we've seen
in the field (specifying a 2 second timeout, with one retry).

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agodiscover/ipmi: Use advisory locking on ipmi device
Jeremy Kerr [Tue, 29 Sep 2015 04:14:16 +0000 (12:14 +0800)]
discover/ipmi: Use advisory locking on ipmi device

The ipmi module is shared between pb-config and pb-discover. During
system initilisation, we're likely to have a few invocations of
pb-config running, as well as pb-discover starting.

We may have multiple potential concurrent accesses to the ipmi device
node. To avoid problems, this change introduces a fcntl lock on the
device node.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agodiscover/devmapper: Use explicit 64-bit types for sector counts
Jeremy Kerr [Wed, 30 Sep 2015 02:26:35 +0000 (10:26 +0800)]
discover/devmapper: Use explicit 64-bit types for sector counts

We currently have a bug where the return value from get_block_sectors
may overflow an unsigned int, so we create a snapshot that is too small.

This change uses uint64_t types for the sector counts.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agodiscover: Set default language
Jeremy Kerr [Thu, 24 Sep 2015 04:38:47 +0000 (14:38 +1000)]
discover: Set default language

Rather than setting NULL, do a setlocale(LC_ALL, NULL) to query the
system locale value as our default.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopo: Add missed translations fixes
Jeremy Kerr [Fri, 18 Sep 2015 06:25:50 +0000 (14:25 +0800)]
po: Add missed translations fixes

We have a few manual fixes missing from the fr.po translation.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agodiscover: status messages shouldn't have a trailing newline
Jeremy Kerr [Fri, 18 Sep 2015 02:47:33 +0000 (10:47 +0800)]
discover: status messages shouldn't have a trailing newline

Fix the status message, and remove the newline from our translations.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopo: Manual translation formatting fixes
Jeremy Kerr [Fri, 18 Sep 2015 02:42:43 +0000 (10:42 +0800)]
po: Manual translation formatting fixes

We have a few minor issues, mostly formatting, from the latest translation
drop.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopo: translation updates
Jeremy Kerr [Fri, 18 Sep 2015 01:34:28 +0000 (09:34 +0800)]
po: translation updates

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agodiscover: Add translation comments for status messages
Jeremy Kerr [Fri, 18 Sep 2015 01:13:24 +0000 (09:13 +0800)]
discover: Add translation comments for status messages

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopo: Update translation files
Samuel Mendoza-Jonas [Tue, 15 Sep 2015 06:25:04 +0000 (16:25 +1000)]
po: Update translation files

Add additional source files to POTFILES.in and update the *.po files
where able.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoFix certain calls to gettext
Samuel Mendoza-Jonas [Tue, 15 Sep 2015 06:24:24 +0000 (16:24 +1000)]
Fix certain calls to gettext

Properly call gettext for strings in discover/device-handler.c that are
user-visible, and fix the help string in ui/ncurses/nc-subset.c

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoMerge branch 'pb-plugin' into master
Samuel Mendoza-Jonas [Fri, 11 Sep 2015 05:56:18 +0000 (15:56 +1000)]
Merge branch 'pb-plugin' into master

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agopb-plugin: Don't execute metadata files
Jeremy Kerr [Fri, 11 Sep 2015 04:40:16 +0000 (12:40 +0800)]
pb-plugin: Don't execute metadata files

Rather than sourcing a plugin's metadata file, explicitly parse
variables.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agoui/ncurses: Improve scrolling behaviour
Samuel Mendoza-Jonas [Wed, 9 Sep 2015 04:39:34 +0000 (14:39 +1000)]
ui/ncurses: Improve scrolling behaviour

The nc-config screen now includes several select options with a FIELD
height greater than one, but config_screen_widget_focus() will only
scroll down enough to see the first line of text.
Update config_screen_widget_focus() to try and make as much of the
focussed widget visible as possible.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Allow text wrapping in select widgets
Samuel Mendoza-Jonas [Tue, 8 Sep 2015 23:03:52 +0000 (09:03 +1000)]
ui/ncurses: Allow text wrapping in select widgets

Several string translations used in select widgets are longer than the
maximum possible width of the widget. Rather than associating several
FIELDs with a select option, use a fold_text callback to pad out
substrings of the original string such that the ncurses O_WRAP option
properly wraps strings within the field.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Allow fs recovery if snapshot available
Samuel Mendoza-Jonas [Tue, 25 Aug 2015 00:33:14 +0000 (10:33 +1000)]
discover: Allow fs recovery if snapshot available

If we have a device-mapper snapshot available we can now guarantee
filesystem recovery will not write back to a read-only mounted disk.
Allow recovery on those devices with the notable exception of XFS which
may fail to mount if the filesystem is the opposite endian of Petitboot.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Improve update handling in nested screens
Samuel Mendoza-Jonas [Wed, 2 Sep 2015 05:43:39 +0000 (15:43 +1000)]
ui/ncurses: Improve update handling in nested screens

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>
8 years agoui/ncurses: Change arrangement of boot order buttons
Samuel Mendoza-Jonas [Fri, 4 Sep 2015 05:52:20 +0000 (15:52 +1000)]
ui/ncurses: Change arrangement of boot order buttons

The buttons 'Add Device', 'Clear', and 'Clear & Boot Any' are short
enough to be positioned horizontally, but several localisations have
strings as long as all three buttons combined.

Instead arrange the buttons vertically and allow longer strings to
resize the width of the button to fit the whole string.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Resize & adjust OK/Help/Cancel buttons
Samuel Mendoza-Jonas [Fri, 4 Sep 2015 05:47:42 +0000 (15:47 +1000)]
ui/ncurses: Resize & adjust OK/Help/Cancel buttons

The localisation of 'OK' is cut short in a few languages by a character
or two - adjust the buttons in each affected screen slightly to
accommodate.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agopb-plugin: Fix invalid command reference
Jeremy Kerr [Wed, 2 Sep 2015 15:10:50 +0000 (23:10 +0800)]
pb-plugin: Fix invalid command reference

We had the old code for using 'run'. Also, fix the error we see when
issuing an invalid command.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopb-console: Always add plugins directory to PATH
Jeremy Kerr [Wed, 2 Sep 2015 15:08:26 +0000 (23:08 +0800)]
pb-console: Always add plugins directory to PATH

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopb-plugin: Add lint command
Jeremy Kerr [Wed, 2 Sep 2015 14:54:58 +0000 (22:54 +0800)]
pb-plugin: Add lint command

This change adds a `lint` command, to do some basic checks on the plugin
structure and metadata.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopb-plugin: Implement plugin ABI versioning
Jeremy Kerr [Wed, 2 Sep 2015 09:13:27 +0000 (17:13 +0800)]
pb-plugin: Implement plugin ABI versioning

If a future update to plugins is not compatbile with the installed
plugin infrastructure, we want to abort the scan / install process.

This change adds an ABI version to the script, as well as version (and
minimum-supported version) to the plugin metadata. This means we can
check before plugin execution.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopb-plugin: Only require a fixed plugin extension, instead of full name
Jeremy Kerr [Wed, 2 Sep 2015 07:41:38 +0000 (15:41 +0800)]
pb-plugin: Only require a fixed plugin extension, instead of full name

Currently, the `pb-plugin scan` code requires a fixed archive name at
the root of distributed media. This means that vendors need to have a
fixed name, and can only ship one plugin per device.

This change shifts the requirement to just a filename extension
(.pb-plugin) instead.

To handle this, we now look for any plugin with a .pb-plugin extension,
and so may find multiple plugins on a device.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agoConsolidate display string for optical devices
Samuel Mendoza-Jonas [Tue, 25 Aug 2015 01:08:09 +0000 (11:08 +1000)]
Consolidate display string for optical devices

Instead of using 'Optical' in some places and 'CD/DVD' in others, simply
use 'CD/DVD' for all cases.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoRecognise storage devices on USB bus
Samuel Mendoza-Jonas [Fri, 21 Aug 2015 05:18:48 +0000 (15:18 +1000)]
Recognise storage devices on USB bus

Users may want to prioritise USB-attached storage devices differently to
other devices. Detect if a device is USB-attached and add a new device
type to identify it.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Fix positioning of i18n strings in button labels
Samuel Mendoza-Jonas [Fri, 10 Jul 2015 05:57:48 +0000 (15:57 +1000)]
ui/ncurses: Fix positioning of i18n strings in button labels

Since the visual length of localised strings is not necessarily equal to
the number of chars in the array, button labels could 'finish' early.

For example:
'[確定]  ' and '[  說明  ]  '
vs the correct
'[ 確定 ]' and '[   說明   ]'

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agolib/i18n: Move strncols to i18n.c
Samuel Mendoza-Jonas [Thu, 9 Oct 2014 03:40:38 +0000 (14:40 +1100)]
lib/i18n: Move strncols to i18n.c

Make the strncols() helper available generally to i18n-concerned code.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agopb-plugin: Move plugin wrappers to a separate dir
Jeremy Kerr [Thu, 27 Aug 2015 08:33:32 +0000 (16:33 +0800)]
pb-plugin: Move plugin wrappers to a separate dir

Use /var/lib/pb-plugins/bin, to prevent overwriting system binaries.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agoui/ncurses: Update nc-config help text for Disk R/W
Samuel Mendoza-Jonas [Wed, 19 Aug 2015 05:28:30 +0000 (15:28 +1000)]
ui/ncurses: Update nc-config help text for Disk R/W

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agolib/fold: Handle extra mbrtowc return case
Samuel Mendoza-Jonas [Thu, 20 Aug 2015 06:32:25 +0000 (16:32 +1000)]
lib/fold: Handle extra mbrtowc return case

Commit 9781a370 ("Handle mblen return code when n is zero.") in glibc
changes the return value for when the number of bytes ('n') is zero.
Add an extra condition to detect if we've reached the end of the buffer.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agopb-plugin: Keep chroot persistent, and create wrapper scripts
Jeremy Kerr [Fri, 21 Aug 2015 05:12:19 +0000 (13:12 +0800)]
pb-plugin: Keep chroot persistent, and create wrapper scripts

Rather than having to 'pb-plugin run' multiple times, we want users to
be able to execute multiple plugin binaries with more accessible
command-line statements.

This change reverts to the previous 'install' (rather than 'run')
behaviour, and creates wrapper scripts to call into the chroot.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agopo: Translation updates for all languages
Samuel Mendoza-Jonas [Wed, 19 Aug 2015 04:19:48 +0000 (14:19 +1000)]
po: Translation updates for all languages

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Add disable param for dm-snapshots
Samuel Mendoza-Jonas [Mon, 17 Aug 2015 04:33:25 +0000 (14:33 +1000)]
discover: Add disable param for dm-snapshots

Add a debug-style nvram parameter to disallow the use of device-mapper
snapshots.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover/udev: Additional checks in udev_handle_block_add
Samuel Mendoza-Jonas [Fri, 14 Aug 2015 05:57:55 +0000 (15:57 +1000)]
discover/udev: Additional checks in udev_handle_block_add

- Several filesystem types can appear that we won't be able to mount.
Instead of waiting to fail mounting them in device_handler_discover(),
skip processing them at all.

- Do not create dm-snapshots on top of raid arrays until we have a
reliable way of determining the sector count for a md raid device.

- Turn down the verbosity on skipping dm-devices.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover/devmapper: Disable libdm udev sync support
Samuel Mendoza-Jonas [Fri, 14 Aug 2015 05:25:14 +0000 (15:25 +1000)]
discover/devmapper: Disable libdm udev sync support

Certain userspace environments that Petitboot is packaged with include
a libdm built with udev sync support which hung with the previous approach.
Relying on udev to properly process dm device creation makes some
assumptions about the flavour of udev available - until that is certain
disable udev sync support and have device-mapper control device creation
itself.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agopb-plugin: Update to chroot-style plugins
Jeremy Kerr [Fri, 7 Aug 2015 04:14:42 +0000 (12:14 +0800)]
pb-plugin: Update to chroot-style plugins

This change uses a chroot for all plugins, so that plugins have complete
flexibility with their libraries, dependencies and configuration.

We remove the 'install' action, as we simply run the plugin once.
Running involves extracting the archive, setting up a root filesystem,
and running a chroot.

To simplify plugin discovery behaviour, we standardise the plugin file
to be at pb-plugin.conf of attached devices, and read the metadatafile
straight out of the archive.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agoMake read-only guarantee user-settable
Samuel Mendoza-Jonas [Wed, 6 May 2015 07:03:30 +0000 (17:03 +1000)]
Make read-only guarantee user-settable

Create a new Petitboot option 'petitboot,write?' that specifies whether
the system is allowed to mount devices read-write. The option can be
toggled by the user in the nc-config screen.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Mount snapshots for all eligible disk devices
Samuel Mendoza-Jonas [Wed, 13 May 2015 07:06:01 +0000 (17:06 +1000)]
discover: Mount snapshots for all eligible disk devices

Device-mapper snapshots are created for all disk devices prior to
being mounted. If explicit writes are made to the snapshot they are
merged back to the disk once write access is released.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Support creation of device-mapper devices
Samuel Mendoza-Jonas [Wed, 13 May 2015 06:46:08 +0000 (16:46 +1000)]
discover: Support creation of device-mapper devices

Add discover/dm-snapshot that allows the creation of device-mapper
snapshots that support merging changes back to disk.

Device-mapper snapshots are a CoW device backed by a ramdisk, mirroring
the contents of a source device. No changes are made to the original
disk unless an explicit merge action is performed. This guarantees
read-only mounting of host disks even when writes could implicitly
occur, eg. when performing recovering a journaled filesystem.

In the event that writing back to the disk is desired, such as when
updating grubenv, the changes made to the snapshot can be merged back to
the source disk.

This patch adds support but does not change functionality.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Keep track of available ramdisk devices
Samuel Mendoza-Jonas [Wed, 13 May 2015 06:45:42 +0000 (16:45 +1000)]
discover: Keep track of available ramdisk devices

Store information on available ramdisk devices when they are recognised
by udev, and add functions to 'reserve' and 'release' these devices.

This will be used to associate device-mapper snapshots with a backing
ramdisk in a following patch.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Ensure destroy_device is called on reinit
Samuel Mendoza-Jonas [Thu, 21 May 2015 06:30:07 +0000 (16:30 +1000)]
discover: Ensure destroy_device is called on reinit

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agopo: Translation updates for autoboot/ipmi changes
Samuel Mendoza-Jonas [Tue, 28 Jul 2015 04:56:07 +0000 (14:56 +1000)]
po: Translation updates for autoboot/ipmi changes

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Layout tweaks for boot order interface
Jeremy Kerr [Fri, 26 Jun 2015 04:06:33 +0000 (12:06 +0800)]
ui/ncurses: Layout tweaks for boot order interface

This change implements a few minor tweaks for the bootorder layout
interface:

 - make the verical spacing of widgets more consistent (we have
   a couple of 3-line gaps)

 - use a consistent 2-space gap between buttons on the same line

 - clarify the title text for the subset widget instance, and
   move the select widget closer to the title

 - use consistent title-case for widget labels

 - left-align the select & button widgets on the subset screen, for
   consistency with other screens

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agodiscover: Fix raw string argument to talloc_asprintf_append
Jeremy Kerr [Fri, 26 Jun 2015 03:41:46 +0000 (11:41 +0800)]
discover: Fix raw string argument to talloc_asprintf_append

Current builds give a warning:

  ../discover/platform-powerpc.c: In function ‘update_bootdev_config’:
  ../discover/platform-powerpc.c:667:4: warning: format not a string
  literal and no format arguments [-Wformat-security]
      tmp = val = talloc_asprintf_append(val, boot_str);
          ^

This change uses "%s" for the format string.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agoMerge remote-tracking rbanch sammj/master
Jeremy Kerr [Fri, 26 Jun 2015 03:36:19 +0000 (11:36 +0800)]
Merge remote-tracking rbanch sammj/master

Conflicts:
discover/platform-powerpc.c
discover/ipmi.h

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
8 years agoui/ncurses: Properly reposition cursor after menu update
Samuel Mendoza-Jonas [Mon, 20 Apr 2015 07:12:04 +0000 (17:12 +1000)]
ui/ncurses: Properly reposition cursor after menu update

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>
8 years agoui/ncurses: Toggle visibility of timeout help label
Samuel Mendoza-Jonas [Fri, 8 May 2015 03:42:00 +0000 (13:42 +1000)]
ui/ncurses: Toggle visibility of timeout help label

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Fix whitespace in discover_handler_conf
Samuel Mendoza-Jonas [Thu, 30 Apr 2015 06:38:31 +0000 (16:38 +1000)]
discover: Fix whitespace in discover_handler_conf

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Display devices currently being parsed
Samuel Mendoza-Jonas [Thu, 30 Apr 2015 04:38:43 +0000 (14:38 +1000)]
discover: Display devices currently being parsed

Send a short message to the UI to inform the user a device is being
parsed for boot options. This helps slightly in environments when the UI
appears well before devices are available for parsing, giving the user
an indication that work is still being done.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agodiscover: Clear default-boot-device when invalidated
Samuel Mendoza-Jonas [Thu, 9 Apr 2015 05:27:01 +0000 (15:27 +1000)]
discover: Clear default-boot-device when invalidated

Update the clear_ipmi_bootdev functions to optionally invalidate the
next- or default-boot-device for their respective machines.
If a client invalidates the ipmi_bootdev in the config, invalidate the
respective bootdev.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Display current ipmi bootdev settings
Samuel Mendoza-Jonas [Tue, 6 Jan 2015 02:35:11 +0000 (13:35 +1100)]
ui/ncurses: Display current ipmi bootdev settings

Display the current IPMI bootdev override if it exists, and allow the
user to clear it from the configuration screen.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agolib: Move ipmi_bootdev enum to types.h
Samuel Mendoza-Jonas [Tue, 7 Apr 2015 23:45:43 +0000 (09:45 +1000)]
lib: Move ipmi_bootdev enum to types.h

Move the ipmi_bootdev definition to types.h to support returning
descriptive strings to the system configuration UI.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Update config screen help text
Samuel Mendoza-Jonas [Thu, 29 Jan 2015 05:06:38 +0000 (16:06 +1100)]
ui/ncurses: Update config screen help text

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agopetitboot: Implement ordered boot options
Samuel Mendoza-Jonas [Wed, 21 Jan 2015 05:12:14 +0000 (16:12 +1100)]
petitboot: Implement ordered boot options

Move petitboot to a more familiar 'boot-order' based autoboot system.
The discover server now reads multiple values from the petitboot,bootdev
parameter and adds them in order to config->autoboot_opts. Boot priority
is determined by the options' position in the list.
On the client, nc-config now recognises the new boot order, and allows
the user to add, remove, and reorder the devices in the list.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Use sorted field navigation
Samuel Mendoza-Jonas [Wed, 21 Jan 2015 04:25:15 +0000 (15:25 +1100)]
ui/ncurses: Use sorted field navigation

Changing the visual order of widgets will cause their associated fields to be
out of order relative to the widgetset field array. Rather than manually
resorting the array, use sorted navigation to move according to a field's
visual positon

Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
8 years agoui/ncurses: Add nc-subset selection screen
Samuel Mendoza-Jonas [Wed, 21 Jan 2015 03:48:38 +0000 (14:48 +1100)]
ui/ncurses: Add nc-subset selection screen

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>