summaryrefslogtreecommitdiffstats
path: root/discover
Commit message (Collapse)AuthorAgeFilesLines
* discover/grub: Allow to set a default index for BLS entriesJavier Martinez Canillas2018-04-181-4/+13
| | | | | | | | | | | | When the BLS support was added, the conclusion was that default indexes didn't apply for BLS snippets. But for GRUB 2 the indexes refers to the boot menu entries in memory, regardless of how these were generated. Since in GRUB 2 is valid to set a default index even for menu entries generated from BLS fragments, allow this to also be done in Petitboot. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Don't add discover context boot options in blscfg handlerJavier Martinez Canillas2018-04-181-1/+2
| | | | | | | | | Instead of adding a boot option explicitly, just add it to the grub script boot option list and increment the number of options. That way BLS entries will be known by the grub script handler and can check if is a valid index. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Reverse BLS entries sorting to match Petitboot's boot orderJavier Martinez Canillas2018-04-181-1/+1
| | | | | | | | | | | | The BLS entries were sorted so that the latest entry was at the top in the Petitboot UI, since it matches how menu entries are sorted in GRUB2 config and the GRUB2 UI. But in the Petitboot's UI, the latest entry is expected to be at the bottom and the older one at the top. Sort the BLS entries to match what's expected. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Allow to choose a different BLS directoryJavier Martinez Canillas2018-03-291-2/+7
| | | | | | | | | | The default path to search for BootLoaderSpec configuration files is /loader/entries but in some setups a different directory may be used. So allow this to be chosen by using a blsdir GRUB environment variable. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platform-powerpc: change sys/fcntl.h to fcntl.hBrett Grandbois2018-03-231-1/+1
| | | | | | | for musl libc Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/discover-server: explicit #include <string.h>Brett Grandbois2018-03-231-0/+1
| | | | | | | for musl libc Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Add blscfg command support to parse BootLoaderSpec filesJavier Martinez Canillas2018-03-236-2/+275
| | | | | | | | | | | | | | | | | The BootLoaderSpec (BLS) defines a file format for boot configurations, so bootloaders can parse these files and create their boot menu entries by using the information provided by them [0]. This allow to configure the boot items as drop-in files in a directory instead of having to parse and modify a bootloader configuration file. The GRUB 2 bootloader provides a blscfg command that parses these files and creates menu entries using this information. Add support for it. [0]: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/pxe-parser: Avoid potential null dereferenceSamuel Mendoza-Jonas2018-03-231-2/+4
| | | | | | Fixes Coverity defect CID 149918 Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/boot: Fix stale boot cancellation codev1.7.1Samuel Mendoza-Jonas2018-03-072-16/+5
| | | | | | | | | | | | | | | | 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>
* discover: pxe: Avoid dereferencing null pointerJoel Stanley2018-03-071-1/+1
| | | | | | | | | | | | | 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]
* discover: Fix unused function warningJoel Stanley2018-03-071-9/+6
| | | | | | | | | | | | | | | | 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]
* discover: Fix bad check of version stringJoel Stanley2018-03-071-2/+1
| | | | | | | | | | | | | | | | | | | 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>
* discover/platform-powerpc: Avoid confusing gateway and URLSamuel Mendoza-Jonas2018-02-271-10/+19
| | | | | | | | | | | | 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>
* discover: Allow load_async_url() to call callback for local pathsSamuel Mendoza-Jonas2018-02-274-98/+83
| | | | | | | | | | | | | | | | | | | | | 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>
* discover/syslinux-parser: Fix missing comma in ignored names.Samuel Mendoza-Jonas2018-02-221-1/+1
| | | | | | Fixes Coverity defect CID 182828. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/device-handler: Treat empty boot order as 'boot any'Samuel Mendoza-Jonas2018-02-121-0/+3
| | | | | | | | 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>
* syslinux: add syslinux parser supportBrett Grandbois2018-02-092-1/+486
| | | | | Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* grub2/grub2: add Yocto paths to default grub2 conf search pathsBrett Grandbois2018-02-081-0/+2
| | | | | Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* grub2/grub2-parser: accept no whitespace in grub menuentryBrett Grandbois2018-02-081-1/+1
| | | | | | | | | | 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>
* discover/pb-discover: #include <locale.h> for musl libcBrett Grandbois2018-02-081-0/+1
| | | | | Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* printf: Fix format type warningsGeoff Levand2018-01-102-2/+4
| | | | | | | | | 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>
* discover/pxe-parser: Fix relative parsing for manual config filesSamuel Mendoza-Jonas2017-12-122-3/+15
| | | | | | | | | | | | 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>
* discover/pxe-parser: Fine grained proxy controlCyril Bur2017-11-213-1/+19
| | | | | | | | | | | | | | | | | | | | 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>
* discover/platform-powerpc: Increase IPMI timeoutv1.6.2Samuel Mendoza-Jonas2017-10-261-1/+1
| | | | | | | | | | | | | | | 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>
* discover/device-handler: Fallback to device if snapshot fails to mountv1.6.1Samuel Mendoza-Jonas2017-10-121-3/+14
| | | | | | | | | 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>
* discover/device-handler: Disable safe mode warning on reinitSamuel Mendoza-Jonas2017-08-231-0/+10
| | | | | | | | | | | 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>
* discover: Update env vars at init and suppress LVM warningsSamuel Mendoza-Jonas2017-08-222-15/+20
| | | | | | | | | | | 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>
* discover/ipmi: Open devnode with O_CLOEXECSamuel Mendoza-Jonas2017-08-221-1/+1
| | | | | | | 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>
* discover/device-handler: Be ready for user events earlierSamuel Mendoza-Jonas2017-08-151-4/+4
| | | | | | | | 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>
* discover: Handle plugin install requestSamuel Mendoza-Jonas2017-08-153-0/+64
| | | | | | | | | 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>
* discover/device-handler: Scan devices for pluginsSamuel Mendoza-Jonas2017-08-151-0/+18
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add 'plugin' user-eventSamuel Mendoza-Jonas2017-08-153-0/+113
| | | | | | | | | | | 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>
* discover: Handle and track plugin_optionsSamuel Mendoza-Jonas2017-08-154-1/+134
| | | | | | | | | | 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>
* discover/pxe-parser: Recognise plugin sourcesSamuel Mendoza-Jonas2017-08-151-4/+15
| | | | | | | | | | | | | 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>
* discover/device-handler: Mention booting device in timeout statusSamuel Mendoza-Jonas2017-07-131-1/+2
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Wait for net interfaces to be marked readySamuel Mendoza-Jonas2017-07-114-6/+169
| | | | | | | | | | | | | | | | | | | | | | | 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>
* discover/udev: Handle LVM logical volumesSamuel Mendoza-Jonas2017-07-111-5/+49
| | | | | | | | | | | 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>
* discover/devmapper: Add prefix to devmapper device namesSamuel Mendoza-Jonas2017-07-111-6/+9
| | | | | | | | | 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>
* discover/device-handler: Allow process_url request to be pendingSamuel Mendoza-Jonas2017-07-112-34/+76
| | | | | | | 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>
* discover/paths: Add network jobs to queueSamuel Mendoza-Jonas2017-07-114-0/+110
| | | | | | | | | 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>
* discover/sysinfo: Add network availability helperSamuel Mendoza-Jonas2017-07-112-0/+10
| | | | | | | Add a helper function that describes interfaces as available if they have an assigned address. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/sysinfo: Add system_info_reinit()Samuel Mendoza-Jonas2017-07-113-0/+21
| | | | | | | | 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>
* discover/platform-powerpc: Handle optional Get Device ID sectionSamuel Mendoza-Jonas2017-06-201-8/+18
| | | | | | | | | | 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>
* discover/platform-powerpc: Correct aux revision formatSamuel Mendoza-Jonas2017-06-201-7/+8
| | | | | | | | 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>
* discover/device-handler: Include makedev() from sysmacros.hSamuel Mendoza-Jonas2017-06-201-0/+1
| | | | | | | | | | | | | | | | 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>
* discover/platform-powerpc: Don't fail early if nvram failsSamuel Mendoza-Jonas2017-04-271-1/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Track both configured and current autoboot settingsSamuel Mendoza-Jonas2017-03-152-15/+2
| | | | | | | | | | | | | | | 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>
* discover/sysinfo: Fix useless error messageSamuel Mendoza-Jonas2017-01-311-1/+3
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* process: Cancel all asynchronous jobs on reinitv1.4.1Samuel Mendoza-Jonas2017-01-311-0/+3
| | | | | | | | | | | 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>
* discover/device-handler: Cancel pending boot on reinitSamuel Mendoza-Jonas2017-01-311-0/+6
| | | | | | | | | | 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>
OpenPOWER on IntegriCloud