summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Consolidate petitboot,tty and petitboot,consoleSamuel Mendoza-Jonas2016-09-083-0/+9
| | | | | | | | | | | | | | | | | | | | Commit ce54f86 "Add petitboot,tty and track available consoles" added the petitboot,tty parameter, but the petitboot,console parameter is also recognised by Petitboot. These are ultimately handled by the 30-add-offb and 80-set-stdout hooks respectively, but exist for mostly the same purpose. We consolidate these down to just the original petitboot,console parameter. If the contents of petitboot,console have been configured by Petitboot (ie. it is of the form /dev/dev# [ Description ]) we behave as normal, otherwise we assume that petitboot,console contains a full OF path to the intended console device and do not allow it to be modified. This follows petitboot,console's original intent to be a debug aid, and takes precedence over any other use. The 80-set-stdout hook is removed as 30-add-offb now accounts for both use cases. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Use 'consoles' instead of 'tty' to refer to interfacesSamuel Mendoza-Jonas2016-09-083-30/+30
| | | | | | | 'Console' is more readily understandable and technically more correct than 'tty' for referring to the interfaces that Petitboot starts a UI on. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Avoid writing network overrides to NVRAMSamuel Mendoza-Jonas2016-09-083-0/+11
| | | | | | | | Explicitly keep track of whether the current interface config was set by an IPMI network override, and avoid overwriting any saved config unless the override was marked persistent. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Add encrypted file supporttpearson@raptorengineering.com2016-08-262-28/+275
| | | | | | | | | | | | In certain cases, such as network booting over an untrusted connection, it may be useful to fully encrypt and sign the kernel files. Enable fully encrypted boot using builtin keyring via the addition of the string "ENCRYPTED" to the first line of the /etc/pb-lockdown file. This disables detached (plaintext) signature verification. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Add support for GPG signature enforcement on bootedtpearson@raptorengineering.com2016-08-267-1/+513
| | | | | | | | | | | | | kernels and related blobs This can be used to implement a form of organization-controlled secure boot, whereby kernels may be loaded from a variety of sources but they will only boot if a valid signature file is found for each component, and only if the signature is listed in the /etc/pb-lockdown file. Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> (Minor build fixes and gpgme.m4, comment on secure boot in gpg.c)
* lib: Add support for tracking boot consolesSamuel Mendoza-Jonas2016-06-283-2/+49
| | | | | | | | | | Add tty_list and boot_tty to the config struct to keep track of available console interfaces and the default console to set as primary respectively. Also add a tty field to the boot_command struct so that the current console can be sent to the discover server during a manual boot command. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/pxe-parser: Retrieve configs asynchronouslySamuel Mendoza-Jonas2016-06-284-2/+4
| | | | | | | | | | | | | | | | | | Depending on the configuration of the DHCP server and the network, tftp requests made by the pxe parser can timeout. The pxe parser makes these requests synchronously so several timeouts can block the server completely for several minutes, leaving the server unresponsive to UI requests. Rework the pxe parser such that it handles the result of each tftp request in a callback, which can complete after iterate_parsers() has returned. Each callback is allocated its own conf_context which takes a talloc reference on the discover_context so that each callback can commit new boot options after the initial iterate loop has completed. This also means talloc_unlink must be used instead by the original parent of the discover_context. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/pb-config: Properly initialise interface_configSamuel Mendoza-Jonas2016-06-271-1/+4
| | | | | | | | | | | The addition of the "url" field is not reflected in config_copy_interface() which leaves the pointer uninitialised, causing a potential segfault later on. Copy the field from the source config, and use talloc_zero() for the interface_config struct to prevent this more generally. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/flash: fix resource leak in flash_setup_buffer() error pathsAndrew Donnellan2016-05-061-5/+8
| | | | | | | | | | | Some error paths in flash_setup_buffer() fail to free the flash_info struct or close the open ffs before they return. Change them to goto the cleanup code at the end. Separate the cleanup code into separate labels depending on whether we need to call ffs_close(), arch_flash_close() and talloc_free(). Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* configure.ac: Add checks for libflash and libdevmapperSamuel Mendoza-Jonas2016-04-051-1/+1
| | | | | | | | | libdevmapper is a hard dependency since snapshots were introduced, so add an unconditional configure-time check for it. Also add a check for libflash library and headers if --enable-mtd is set. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/fold: Catch error case from mbrtowc()Sam Mendoza-Jonas2016-03-151-3/+4
| | | | | | | | | | | | | The assert() statement in fold_text() only evaluates in a debug build. If mbrtowc() encounters an error return the portion of the string that has been parsed and stop. This avoids an issue with glibc 2.22 where previous calls to setlocale() failed and set an unsuitable locale. Since the error was not caught this resulted in an infinite loop when trying to access the Language screen. Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* lib/flash: Fix version side being interpreted backwardsSam Mendoza-Jonas2016-03-051-1/+1
| | | | Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* Use 'Primary' instead of 'Current' for flash sidesSam Mendoza-Jonas2016-02-262-12/+12
| | | | | | | | | | | | 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>
* Retrieve BMC version info via IPMISam Mendoza-Jonas2016-02-102-1/+43
| | | | | | | | 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>
* Display VERSION partition info on BMC machinesSamuel Mendoza-Jonas2016-02-092-0/+43
| | | | | | | | | | 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>
* lib/flash: Add support for platform versionsSamuel Mendoza-Jonas2016-02-094-1/+273
| | | | | | | | | | | | | 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>
* lib: Add CCAN headers for endian helpersSamuel Mendoza-Jonas2016-02-096-0/+550
| | | | Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* lib/talloc: Avoid early exit before va_end()Samuel Mendoza-Jonas2016-02-091-1/+3
| | | | | | Fixes Coverity defect #30486 Signed-off-by: Sam Mendoza-Jonas <sam@mendozajonas.com>
* lib/pb-protocol: Fix NULL dereference on non-powerpcSamuel Mendoza-Jonas2015-12-211-1/+4
| | | | | | | | 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>
* ui: add URL for static configurations to load a specified fileNishanth Aravamudan2015-12-182-0/+7
| | | | | | | | | | | | 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>
* lib/talloc: Add missing va_end() callsSamuel Mendoza-Jonas2015-12-181-0/+2
| | | | | | Fixes Coverity defects #30485 and #30486 Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* Add BMC interface MAC to system info outputJack Miller2015-12-152-1/+18
| | | | | | Useful for identifying the initial BMC traffic on the network. Signed-off-by: Jack Miller <jack@codezen.org>
* Consolidate display string for optical devicesSamuel Mendoza-Jonas2015-08-311-1/+1
| | | | | | | 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>
* Recognise storage devices on USB busSamuel Mendoza-Jonas2015-08-312-0/+7
| | | | | | | | 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>
* lib/i18n: Move strncols to i18n.cSamuel Mendoza-Jonas2015-08-313-0/+53
| | | | | | Make the strncols() helper available generally to i18n-concerned code. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* lib/fold: Handle extra mbrtowc return caseSamuel Mendoza-Jonas2015-08-251-2/+3
| | | | | | | | 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>
* discover: Add disable param for dm-snapshotsSamuel Mendoza-Jonas2015-08-181-0/+1
| | | | | | | 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>
* Make read-only guarantee user-settableSamuel Mendoza-Jonas2015-08-063-0/+13
| | | | | | | | 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>
* lib: Move ipmi_bootdev enum to types.hSamuel Mendoza-Jonas2015-05-052-0/+31
| | | | | | | 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>
* petitboot: Implement ordered boot optionsSamuel Mendoza-Jonas2015-05-053-49/+47
| | | | | | | | | | | 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>
* lib: Define autoboot_options, device_type helpersSamuel Mendoza-Jonas2015-05-053-0/+67
| | | | | | | | | Add the new autoboot_option struct, and helper functions for working with device_type enums. device_type_name() returns exact strings as used by platform code to read/write nvram params, so device_type_display_name() is added for use in user-visible strings. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Integrate ipmi bootdev settings into the priority systemJeremy Kerr2014-12-153-1/+22
| | | | | | | | | | | | | | | | | | Currently, we expose the boot device priorities through an array in struct config, which will either be the default (network -> disk), or a single device type specified by the IPMI code. Rather than hide the implementation details in this array, we'd like to expose the details of the machine configuration instead. This allows user visibility of the real boot configuration (for example, if an IPMI boot preference is set). This change removes the priority array, and replaces it with the ipmi_bootdev data (and a persistent flag). We update the default-conflict-resolution code to reflect the priorities between IPMI and UUID preferences. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/fold: fix warning with -DDEBUGJeremy Kerr2014-12-011-1/+1
| | | | | | | | | | | | | When compiling the fold code with DEBUG defined, we get: ../lib/fold/fold.c: In function 'fold_text': ../lib/fold/fold.c:37:3: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] assert(bytes >= 0); ^ We should be comparing with != (size_t)-1, not >= 0 Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/fold: Add support for multibyte stringsJeremy Kerr2014-09-231-11/+59
| | | | | | | | | | Currently, the fold_text function doesn't understand multibyte strings, so may break a line in the middle of a multibyte sequence. This change adds multibyte-awareness to the fold code, and uses proper width calculations for the contents of the folded string. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add debug flag to configJeremy Kerr2014-08-051-1/+4
| | | | | | | | | | This change adds a debug flag to the config, and groups it under not-user-modifiable parts of struct config. This means we no longer need the pb-sysinfo helper, as the last remaining function (--debug-enabled) can be implemented with pb-config. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib: Move generic file-handling code to lib/Jeremy Kerr2014-08-053-1/+149
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* autotools: Use non-recursive makeJeremy Kerr2014-08-011-31/+30
| | | | | | | | | | | | With the current testing infrastructure, we don't have a strictly hierarchical set of dependencies. This causes problems with a recursive make, and means we have to hack around some of the dependencies. This change generates a single, top-level makefile from all of the Makefile.am fragments. We still need the po/ directory as a separate SUBDIR, but all others can be converted to non-recursive. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-protocol: Define new 'add-url' actionSamuel Mendoza-Jonas2014-07-282-0/+21
| | | | | Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* config: Add lang member to configJeremy Kerr2014-07-283-0/+15
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* i18n: Mark translatable strings for ncurses UIJeremy Kerr2014-07-281-0/+26
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add safe modeJeremy Kerr2014-07-223-1/+11
| | | | | | | | | | | Safe mode configures the discover server to not start any device parsing; this can be used to diagnose any problems with early device handing. In safe mode, we don't initialise any of the device sources - udev, network and user events are disabled. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: check config.boot_device before setting a defaultJeremy Kerr2014-07-211-0/+2
| | | | | | If a default device is set, we only allow booting from that device. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* config: Add boot_device member to configJeremy Kerr2014-07-213-3/+16
| | | | | | | We'd like to specify a way to only boot from a specific block device; this adds a field to the configuration to hold the value. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* autotools: Don't require custom automake optionsJeff Bailey2014-07-161-0/+2
| | | | | | | | | | | | | We need a couple of automake options to prevent errors when regenerating Makefile.ins during source preparation. Some makefiles assume GNU make, so add 'foreign' where necessary. Also, we are building objects in subdirectories, so we need 'subdir-objects'. Modified to suit recent petitboot by Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Jeff Bailey <jeffbailey@google.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/pb-protocol: fix deserialise of boot option prioritiesJeremy Kerr2014-04-071-0/+3
| | | | | | | | | | | | Commit aa530148 introduced a priority member to struct boot_priority, but didn't update the protocol deserialise function to properly decode config messages. This meant we were leaving half of the struct uninitialised, and getting invalid values in the initialised part. This change updates the config deserialise function to do proper handling for boot priority data. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* log: Allow runtime selection of 'debug' log levelJeremy Kerr2014-04-072-0/+6
| | | | | | | | | | | | | | | | | Currently, we need to compile with -DDEBUG to implement debug-level logging in the UIs and discover server. Since we may not be able to easily replace a system's petitboot binaries, this change introduces a -v|--verbose option to the discver server and ncurses UI, which enables debug at runtime. We also move some of the udev debug code out of an #ifdef DEBUG block. Since petitboot is generally started on boot, we also add a little infrastructure to pass -v to petitboot on certain system contitions: either petitboot.debug on the kernel command line, or a petitboot,debug? NVRAM property containing the value 'true'. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Add debug on process killJeremy Kerr2014-04-031-0/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* protocol: expose discovery reinit over client/server protocolJeremy Kerr2014-04-021-0/+1
| | | | | | | Now that we can re-initialise the device handler, allow this to be triggered from UIs over the petitboot protocol. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: Don't abort stdout reads on EINTRJeremy Kerr2014-02-201-3/+15
| | | | | | | | | | | | | | | | | If our read() of the process stdout pipe fails with EINTR (eg, if we receive a SIGCHLD because the process exited), then process_read_stdout_once will return a non-zero exit code, and we'll abort any further stdout collection. Instead, we should check for EINTR, and allow the reads to continue. This change normalises the return value from process_read_stdout_once to return positive on success, negative on failure, and zero on competion. We use a positive return value for the non-error EINTR case. Also, add a pb_log if the read fails for non-EINTR reasons. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/fold: Add text fold utilityJeremy Kerr2014-01-313-0/+73
| | | | | | | We want to fold help text into the ncurses UI, so add a little module to split text into lines. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud