summaryrefslogtreecommitdiffstats
path: root/discover
Commit message (Collapse)AuthorAgeFilesLines
...
* configure: Add conditional platform buildsGeoff Levand2018-08-071-4/+7
| | | | | | | | | | | | Add configure --enable-platform-XXX options to allow specifying which platform support to build. --enable-platform-auto, the default, will use the host triplet to guess which platforms to build. --enable-platform-all will build all platforms. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add platform-dummyGeoff Levand2018-08-072-0/+19
| | | | | | | | | | With the new configure enable-platform parameters it is possible configure no platform support. Add a new minimal 'dummy' platform so that the __start_platforms and __stop_platforms variables needed by platform_init are created. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Move generic params routines to platformGe Song2018-08-073-123/+129
| | | | | | | | | | Move the generic params routines from platform-powerpc to platform. Also, for clarity, add a params prefix to the names. Signed-off-by: Ge Song <ge.song@hxt-semitech.com> [Split from a larger patch and cleaned up] Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Move generic config routines to platformGe Song2018-08-073-309/+311
| | | | | | | | | | Move the generic config routines from platform-powerpc to platform. Also, for clarity, add a config_ prefix to the names. Signed-off-by: Ge Song <ge.song@hxt-semitech.com> [Split from a larger patch and cleaned up] Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/powerpc: Switch to new param_listGeoff Levand2018-08-071-149/+53
| | | | | | Signed-off-by: Geoff Levand <geoff@infradead.org> [Name string fixup] Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/powerpc: Add param_name argGeoff Levand2018-08-071-7/+7
| | | | | | | | Update update_network_config and update_bootdev_config to operate on a generic parameter name passed as an argument. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/powerpc: Rearange save_configGe Song2018-08-071-14/+11
| | | | | | | | | | Rearange update_config and save_config so that update_config only operates on the platform params list. Signed-off-by: Ge Song <ge.song@hxt-semitech.com> [Split from a larger patch and cleaned up] Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/event: Rename param -> event_paramGeoff Levand2018-08-072-5/+5
| | | | | | | To avoid name clash with other 'struct param'. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Move generic ipmi routines to ipmiGe Song2018-08-073-129/+131
| | | | | | | Signed-off-by: Ge Song <ge.song@hxt-semitech.com> [Split from a larger patch] Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/powerpc: Use process_get_stdoutGeoff Levand2018-08-071-11/+5
| | | | | Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/process: Cleanup stdout callbackGeoff Levand2018-08-071-1/+1
| | | | | | | | | | | General cleanup of async stdout processing. The process_stdout_cb and process_stdout_custom routines were doing the same thing, so rename process_stdout_custom to process_process_stdout and make process_stdout_cb a wrapper that calls process_process_stdout. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/parser: Hookup parser_is_uniqueGeoff Levand2018-08-072-39/+23
| | | | | Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/parser: Add new parser_is_uniqueGeoff Levand2018-08-072-0/+44
| | | | | | | | | Add a new routine parser_is_unique that tests a file's inode against a list of known file inodes. Useful when searching case-insensitive filesystems. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add some debug print messagesGeoff Levand2018-08-072-0/+2
| | | | | | | | To aid in debugging print some additinal discover messages to the log. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/kboot-parser: Look in /bootGeoff Levand2018-08-071-0/+4
| | | | | | | | Other parsers look in /boot for config files, so add it to the kboot parser. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add --debug to kexecGeoff Levand2018-08-071-6/+10
| | | | | | | | | If verbose logging is enabled then add '--debug' to the kexec command line. Adds a new routine pb_log_get_debug() that can be used to query the log debug state. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/log: Switch to pb_log_fnGeoff Levand2018-08-0711-40/+40
| | | | | | | | The only functional change should be an additional '/n' to a few log messagees that seemed to be missing it. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/paths: Cleanup res after getaddrinfoSamuel Mendoza-Jonas2018-08-071-6/+8
| | | | | | Fixes Coverity defect #187192. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/paths: Set suffix to default value on error.Samuel Mendoza-Jonas2018-07-301-1/+3
| | | | | | | 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>
* discover: Be more verbose about boot failuresSamuel Mendoza-Jonas2018-07-302-0/+8
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Determine connectivity with getaddrinfo()Samuel Mendoza-Jonas2018-07-103-13/+6
| | | | | | | | | Use getaddrinfo() to determine if a remote URL is reachable instead of only checking if we have an addresses configured. This avoids, for example, trying to load an IPv4 URL when only an IPv6 address is available. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/pxe-parser: Parse simple iPXE scriptsSamuel Mendoza-Jonas2018-07-101-2/+94
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/user-event: Use bootfile_url if availableSamuel Mendoza-Jonas2018-07-101-1/+8
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Support IPv6 addressesSamuel Mendoza-Jonas2018-07-103-40/+109
| | | | | | | Support handling IPv6 addresses from user events and call the udhcpc6 client in addition to the udhcpc client. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/sysinfo: Set IPv6 addressesSamuel Mendoza-Jonas2018-07-101-4/+18
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Implement F10-F12 for autoboot device controlJeremy Kerr2018-07-101-0/+25
| | | | | | | | | | | | | Add a few mappings to specify temporary autoboot settings: F10: Only autoboot from disk F11: Only autoboot from USB devices F12: Only autoboot from network These use the new code to prevent cancelling autoboot. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/handler: Implement temporary autoboot messagesJeremy Kerr2018-07-103-6/+75
| | | | | | | | Handle incoming requests for temporary autoboot settings. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> [indenting fixup] Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/handler: Split autoboot matching into a new functionJeremy Kerr2018-07-101-10/+17
| | | | | | | | A future change will want to match autoboot option settings, so abstract this into its own function. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: implement a periodic requery for network devicesJeremy Kerr2018-07-094-4/+180
| | | | | | | | | | | | | | | | | | 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>
* discover/user-event: Check for required parametersSamuel Mendoza-Jonas2018-07-091-1/+9
| | | | | | | | Check for some required parameters in the 'dhcp' handler, and in the 'add' handler return an error if parse_user_event() fails rather than charging ahead into a segfault. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/udev: Don't require ID_NET_NAME_PATH propertySamuel Mendoza-Jonas2018-07-091-3/+2
| | | | | | | | Drop the requirement for the ID_NET_NAME_PATH property since it prevents Petitboot from recognising virtio network devices, and is not otherwise used. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Improve BLS grub environment variables expansionJavier Martinez Canillas2018-06-181-16/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | The fields from a BootLoaderSpec file can contain environment variables, in GRUB 2 these are show verbatim and are evaluated later when an entry is selected. But on Petitboot these have to be expanded before creating the GRUB 2 resources and show in the UI the values after the evaluation. The current blscfg handler had a very limited support for variables, it only had support for the options field and also didn't take into account that variables could be mixed with literal values. So for example the following fields were not expanded correctly: linux $bootprefix/vmlinuz options $kernelopts foo=bar options foo=bar $kernelopts options $kernelopts $debugopts Also change some of the tests to cover mixing variables and literals. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Use different paths to search for the BLS directoryJavier Martinez Canillas2018-06-181-3/+19
| | | | | | | | | | | | | | | | Currenlty the BLS fragments are only searched in the /loader/entries directory, but this assumes that there is a boot partition mounted in /boot. This may not always be the case, /boot may not be a mount point and just a directory inside the root partition. To cover this case, Petitboot tries to find a GRUB 2 config file in different paths. So let's do the same for the BLS files directory. Also change some of the unit tests to use /boot/loader/entries as a BLS directory instead of /loader/entries. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/syslinux-parser: consistent cmdline arg processingBrett Grandbois2018-06-121-6/+5
| | | | | | | | | | | In signed-boot environments consistent handling of kernel commandline options is essential as they must be pre-signed. In the syslinux parser ensure that in the absence of a global APPEND they are processed exactly as found and not with the leading space that the current APPEND processing has as a shortcut. Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Null terminate ifname buffer explicitlySamuel Mendoza-Jonas2018-06-121-3/+4
| | | | | | | | | | | | | | | | | | | | GCC 8 produces the following warning for network.c: In function ‘network_handle_nlmsg’, inlined from ‘network_netlink_process’ at ../discover/network.c:726:3: ../discover/network.c:568:3: warning: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 16 [-Wstringop-truncation] strncpy(interface->name, ifname, sizeof(interface->name) - 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../discover/network.c:586:3: warning: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 16 [-Wstringop-truncation] strncpy(interface->name, ifname, sizeof(interface->name) - 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The code is safe since interface is allocated with talloc_zero() and we could use -Wno-stringop-truncation to hide this but since this is the only offender instead just copy the whole IFNAMSIZ bytes and explicitly terminate the ifname buffer to be safe. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Rescan SCSI devices on reinitSamuel Mendoza-Jonas2018-06-121-0/+3
| | | | | | | Explicitly rescan SCSI devices on reinit rather than just remounting them in case a device did not init properly on boot. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Fix pb-discover segfaults caused by list corruption.Brandon Bergren2018-06-123-0/+3
| | | | | | | | | | | | | | I was seeing list corruption and segfaults in pb-discover on my Talos II when using both yaboot and kboot config files on the same device. My assumption is that discover_context_add_boot_option() was being called on the same pointer more than once. So, null the pointer right after the call. The ownership was transferred anyway so the parsers should not keep it around. Signed-off-by: Brandon Bergren <git@bdragon.rtk0.net> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Update to reflect generic signed boot APIBrett Grandbois2018-05-302-8/+7
| | | | | Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/boot: abort kexec on any error from validationBrett Grandbois2018-05-231-2/+2
| | | | | | | | | | | gpg_validate_boot_files() can return error codes for a variety of reasons but kexec_load only aborts for signature or decryption failure. In any other failure case like unable to open LOCKDOWN_FILE or do the secure copy the validation is bypassed by an early return but kexec_load does not abort. Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub: Add cmdline signature support for BLS entriesBrett Grandbois2018-05-041-0/+6
| | | | | | | Follow along the way the linux builtin does it. Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/syslinux-parser: filter out duplicate conf filesBrett Grandbois2018-04-191-0/+37
| | | | | | | | | in case insensitive filesystems like vfat the duplicate conf file list will create duplicate boot options. to filter that out strore the struct stat of each parsed conf file and compare inodes Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/syslinux-parser: clean up boot option list entriesBrett Grandbois2018-04-191-1/+6
| | | | | | | | in finalize loop or we can get duplicate boot entries as well as the memory leak Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* 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>
OpenPOWER on IntegriCloud