summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* lib/process: Cleanup stdout callbackGeoff Levand2018-08-073-26/+10
| | | | | | | | | | | 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>
* test/parser: Add parser_is_uniqueGeoff Levand2018-08-071-0/+12
| | | | | 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-073-6/+16
| | | | | | | | | 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-0732-148/+148
| | | | | | | | 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>
* lib/log: Add verbose logging routinesGeoff Levand2018-08-073-0/+41
| | | | | | | | | | Add three new logging routines pb_log_fn and pb_debug_fn, which print the calling function's name to the log, and pb_debug_fl which prints the calling function's name and the file line number to the log. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* configure: Remove unused ENABLE_DEBUGGeoff Levand2018-08-071-1/+0
| | | | | | | | We setup debug builds in the configure script with DEFAULT_CFLAGS and DEFAULT_CPPFLAGS. Remove the unused ENABLE_DEBUG AM conditional. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* configure: Add check for UI buildGeoff Levand2018-08-071-0/+7
| | | | | | | Emit configure warning if no UI program is to be built. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* docker: Add libfdt-devGeoff Levand2018-08-072-1/+2
| | | | | | | Add package libfdt-dev to the pb-builder docker image. 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>
* docker: Pass extra options to configureSamuel Mendoza-Jonas2018-08-071-10/+20
| | | | | | | Pass extra configure options and CFLAGS/LDFLAGS to docker to enable building multiple configurations. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* docker: Pass proxy variables to docker buildSamuel Mendoza-Jonas2018-08-071-0/+2
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* docker: Add signed boot dependenciesSamuel Mendoza-Jonas2018-08-071-0/+2
| | | | 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>
* lib/log: Include timestamp prefixSamuel Mendoza-Jonas2018-07-301-0/+11
| | | | | | | | The relative time between logged events is very useful during debugging, particularly when debugging autoboot failures. Prepend a short HH:MM:SS timestamp to each line logged. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* jenkins: Add build jobsGeoff Levand2018-07-262-0/+105
| | | | | | | | | | Adds two Jenkins pipeline jobs pb-upstream-trigger and pb-build-matrix. pb-upstream-trigger checks for upstream updates and runs pb-build-matrix. pb-build-matrix builds a pb-builder image and runs the build-pb script. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Allow IPv6 addresses in address fieldsSamuel Mendoza-Jonas2018-07-103-43/+84
| | | | 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-105-2/+216
| | | | 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>
* utils/pb-udhcpc: Recognise DHCPv6 parametersSamuel Mendoza-Jonas2018-07-101-1/+1
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/system: Add udhcpc6Samuel Mendoza-Jonas2018-07-103-0/+3
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/sysinfo: Set IPv6 addressesSamuel Mendoza-Jonas2018-07-102-4/+21
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib: Add support and helpers for IPv6 host addressesSamuel Mendoza-Jonas2018-07-108-6/+72
| | | | | | | | Recognise IPv6 addresses and URLs, and allow an interface_info struct to have both an IPv4 and IPv6 address. The addr_scheme() helper returns the address family of a given address. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Implement F10-F12 for autoboot device controlJeremy Kerr2018-07-106-0/+112
| | | | | | | | | | | | | 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>
* ui/ncurses: Implement non-boot-cancelling keysJeremy Kerr2018-07-101-1/+9
| | | | | | | | | Allow some keys to not cancel the default-boot process. For the moment, this is just the screen refresh (ctrl+L). 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>
* protocol: Add definition and serialisation for temporary autobootJeremy Kerr2018-07-102-0/+76
| | | | | | | Add a new message format for a temporarily-applied autoboot setting. 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-096-6/+189
| | | | | | | | | | | | | | | | | | 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>
* po/en: Fix inconsistencies with trailing colonsJeremy Kerr2018-07-091-4/+4
| | | | | | | | We have a few cases where the english translations have matched against strings with/without colon suffixes. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> 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-183-20/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-187-15/+43
| | | | | | | | | | | | | | | | 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>
* test/parser: Make parser_scandir() ignore files with path len less than dirJavier Martinez Canillas2018-06-181-0/+3
| | | | | | | | | | | | | Both the test files and directories added into the test harness are stored into the same file list. So the parser_scandir() stub compares the absolute file path of the files and the directory to scan, to know if a file belongs to the directory. Files whose absolute file path length isn't bigger than the directory to scan should just be ignored, since it means they can't be from that dir. 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-124-12/+22
| | | | | | | | | | | 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>
* lib/security: hard_lockdown flag to stop runtime disable of signed bootBrett Grandbois2018-06-125-1/+19
| | | | | | | | | | | | | | | Currently if signed-boot is enabled in configure the presence of the LOCKDOWN_FILE is used as a runtime determination to perform the actual verification. In some environments this may be acceptable or even the intended operation but in other environments could be a security hole since the removal of the file will then cause boot task verification. Add a 'hard_lockdown' enable flag to generate a HARD_LOCKDOWN preprocessor definition to force the system to always do a signed boot verification for each boot task, which in the case of a missing file the boot will fail. 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-126-1/+13
| | | | | | | 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>
* test/lib: Add OpenSSL verify and decrypt testsBrett Grandbois2018-05-3016-0/+392
| | | | | Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Update LOCKDOWN_FILE check to reflect generic SIGNED_BOOTBrett Grandbois2018-05-301-1/+1
| | | | | Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> 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>
* lib/security: add in openssl supportBrett Grandbois2018-05-307-291/+849
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor to export a generic API rather than specific gpg_ prefixes by changing gpg.h to security.h and renaming some of the exports. Break out the common and specific functionality into common.c and none.c/gpg.c/openssl.c for no/gpgme/openssl modes respectively. gpgme should work as before OpenSSL support works like this: The pb-lockdown file is a PKCS12 file or X509 certificate or PEM-encoded raw public key. To follow the current conventions the presence of a PKCS12 file as a lockdown signals decrypt mode because of the presence of the private key, anything else signals signature verification mode. The keyring path is currently ignored but in the future could be used to point to an X509 certificate chain for validity checking. Because of this self-signed certificates are currently supported and really just used as a public key container. Signature verification mode supports: * Cryptographic Message Syntax (CMS) as detached S/MIME, this is really more for consistency for the encryption mode (see below). This mode requires the lockdown file to be an X509 certificate. A sample creation command would be: openssl cms -sign -in (infile) -out (outfile) -binary -nocerts \ -inkey (private key) -signer (recipient certificate) * Raw signature digest as output from openssl dgst -sign command. This mode can have the lockdown file be an X509 certificate or a PEM raw public key but the digest algorithm must be pre-defined by the VERIFY_DIGEST configure argument. The default is SHA256. A sample creation command would be: openssl dgst -sign (private key) -out (outfile) -(digest mode) \ (infile) Decryption mode supports: * CMS signed-envelope as attached S/MIME. This is for consistency with the current expectation of no external file for decryption. Some future enhancement could be to come up with some proprietary external file format containing the cipher used, the encrypted cipher key, and the IV (if necessary). A sample creation command would be: openssl cms -sign -in (infile) -signer (recipient certificate) \ -binary -nocerts -nodetach -inkey (private key) | \ openssl cms -encrypt -(cipher mode) -out (outfile) \ (recipient certificate) The PKCS12 file is expecting the private key to have password of NULL or "" as there is currently no mechanism to supply a custom one. Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
OpenPOWER on IntegriCloud