summaryrefslogtreecommitdiffstats
path: root/discover/pxe-parser.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix pb-discover segfaults caused by list corruption.Brandon Bergren2018-06-121-0/+1
| | | | | | | | | | | | | | 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/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: 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: Allow load_async_url() to call callback for local pathsSamuel Mendoza-Jonas2018-02-271-3/+0
| | | | | | | | | | | | | | | | | | | | | 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/pxe-parser: Fix relative parsing for manual config filesSamuel Mendoza-Jonas2017-12-121-2/+14
| | | | | | | | | | | | 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-211-1/+13
| | | | | | | | | | | | | | | | | | | | 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/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: Allow process_url request to be pendingSamuel Mendoza-Jonas2017-07-111-0/+3
| | | | | | | 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 stdout callback parameter for load_url_async()Samuel Mendoza-Jonas2016-12-201-2/+3
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/status: Use full URL in parse status messageJeremy Kerr2016-12-201-1/+1
| | | | | | | ->conf_url is the base address, we want the actual loaded URL. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/status: report on PXE download failuresJeremy Kerr2016-12-201-2/+12
| | | | | | | | Add dev_err messages on both autoconfiguration and specified-configuration download failures. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/status: report attempts at PXE configuration downloadJeremy Kerr2016-12-201-3/+13
| | | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: add handler reference to struct discover_contextJeremy Kerr2016-12-201-2/+4
| | | | | | | | | | | | | Since the device handler provides the status message functions, we need a pointer to it for device discovery (which we use a struct discover_context for). This change adds a 'handler' member to struct discover_context, to allow status reporting. Since we now have a handler, there's no need for the network pointer, so provide an accessor function instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Use device_handler_status_dev_* for device-specific statusJeremy Kerr2016-12-201-2/+3
| | | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add helpers for status reportingJeremy Kerr2016-12-201-4/+1
| | | | | | | | | This change adds a couple of helpers for the status reporting API, allowing callers to provide just a set of printf-style arguments, rather than having to build up a struct status. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: separate status-reporting function from boot() callbackJeremy Kerr2016-12-201-1/+1
| | | | | | | | | | | | Currently, the device_discover_boot_status function is both used for internal status updates, as well as the callback passed to boot(). This change splits this into two functions; one for the latter and one for the former. The latter just has a void * for its first argument, to match the boot_status_fn type. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* types: shorten boot_status definitionsJeremy Kerr2016-12-201-2/+2
| | | | | | | | | | | struct boot_status is a bit misnamed; we report status on things that aren't just the boot status (eg, discovery). This change refactors struct boot_status into just struct status. We give the type enum a name, and shorten the enum values to suit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/pxe-parser: Parse only the first configv1.3.1Samuel Mendoza-Jonas2016-10-111-34/+59
| | | | | | | | | | | | | | | | | | | Commit 2163af5 "discover/pxe-parser: Retrieve configs asynchronously" added asynchronous loading of remote pxe filenames, but made an unintended change in behaviour to the PXE parser. Previously the parser would try a list of possible filenames, and parse the first one it found. However the above commit spawns an asynchronous job for every filename, and parses any that can be retrieved. It is a common configuration to have a machine-specific config and a 'fallback' default config, and the change means we could erroneously retrieve and parse both configs. Update the PXE parser so that asynchronous jobs are spawned sequentially. That is, spawn a job for the first filename and if not successful spawn another job for the next filename, and so on. Once a remote config is successfully retrieved, parse it and stop. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* Add support for GPG signature enforcement on bootedtpearson@raptorengineering.com2016-08-261-0/+7
| | | | | | | | | | | | | 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)
* discover/pxe-parser: Retrieve configs asynchronouslySamuel Mendoza-Jonas2016-06-281-39/+122
| | | | | | | | | | | | | | | | | | 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>
* pb-discover: add dtb support for PXE configOliver O'Halloran2016-05-241-0/+4
| | | | | | | | | | | | | | Currently there is no way to manually specify a DTB file when with a PXE network boot configuration file. This makes it difficult when you need to work with or emulate a special snowflake machines with special snowflake hardware. Some ARM systems provide this feature with the "fdt" option so this patch adds support for using the ftd or dtb configuration options to the PXE config parser. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/pxe: Format IPAPPEND mac addresses correctlySamuel Mendoza-Jonas2014-12-031-3/+15
| | | | | | | | | | | | | | | | | | | | | The SYSAPPEND/IPAPPEND option 2 in PXE configs requires the MAC address of the booting interface to be appended to the boot options. Previously we formatted this as "BOOTIF=01:02:03:04:05:06", but syslinux/pxelinux implementation use this format: "BOOTIF=01-01-02-03-04-05-06", where the leading '01' represents the hardware type. The relevant part of the pxelinux doc is at: http://www.syslinux.org/wiki/index.php/SYSLINUX#SYSAPPEND_bitmask Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Implement PXE SYSAPPEND syntaxJeremy Kerr2014-08-251-1/+47
| | | | | | | This change implements SYSAPPEND/IPAPPEND 2, to add a BOOTIF argument to the kernel command line. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe-parser: Remove unnecessary semicolonJeremy Kerr2014-07-161-1/+1
| | | | | | | We have an unnecessary semicolon on an empty for-loop, which causes a clang warning. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: pxe parser should only treat "::" paths as absoluteJeremy Kerr2014-02-271-3/+41
| | | | | | | | | | PXELinux treats all paths as relative, requiring a "::/path" syntax for truly absolute URLs. This change implements the same behaviour in petitboot, and updates the testcases to suit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: Add pxelinux.cfg/ directory to autodiscovered pxe pathsJeremy Kerr2014-02-271-9/+13
| | | | | | | | | | The pxelinux project will perform autodiscovery by looking for files under the pxelinux.cfg/ prefix (in addition to any pxepathprefix from DHCP option 210) This change unifies petitboot's behaviour with pxelinux. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Don't rely on ctx->conf_url side-effect in user_event_parse_conf_urlJeremy Kerr2014-01-171-2/+5
| | | | | | | | Currently, user_event_parse_conf_url sets dc->conf_url if it detects we have a full URL (rather than a base URL). This is a little too subtle, so replace it with an explicit output parameter. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* configure: Use AC_GNU_SOURCEJeremy Kerr2013-12-181-1/+3
| | | | | | | Rather than #defining _GNU_SOURCE in our .c files, we can define this from config.h instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Fix potentially-uninitialised variablesJeremy Kerr2013-11-131-0/+2
| | | | | | | We've been compiling with --enable-debug; this change fixes some problems exposed by the optimiser. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Change parsers to explicitly request configuration filesNeelesh Gupta2013-11-061-4/+58
| | | | | | | | | | | | | | | | | | | Add a new function parser_request_url() to read the data from configuration files present remotely. We deprecate iterate_parser_files() and download_config() functions along with the 'filenames' and 'method' members of the 'parser' structure so that individual parsers would now require to request the configuration files data from the parser code and doesn't necessarily export the list of configuration files. Add the support to handle incoming DHCP event, done by passing all the relevant environment variables of the udhcpc to the discover code. Also, update the pxe parser code to populate the list of configuration file names as per PXELINUX convention of fallback names using mac and ip addresses of the booting machine. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: Implement default optionsJeremy Kerr2013-09-201-4/+24
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: check for a valid boot option before addingJeremy Kerr2013-09-061-1/+2
| | | | | | | | | | If we didn't find any valid boot options in the pxe buffer, we'll call discover_context_add_boot_option with a NULL boot option. This change adds a check before we try to add the boot option, and a test to verify this situation. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: remove debug statementJeremy Kerr2013-07-231-1/+0
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe: Handle initrdsJeremy Kerr2013-07-231-1/+25
| | | | | | | We may see initrds specified on the kernel argument line, or as their own configuration directive. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/pxe-parser: All options are name <space> value pairsJeremy Kerr2013-07-041-0/+3
| | | | | | Abort the pair parse if we don't have both a name and a value. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: handle boot_option->device_id entirely within handlerJeremy Kerr2013-05-091-2/+1
| | | | | | | No need for parsers to populate (or forget to populate, in the case of most parsers) opt->device_id, as we should do it on finalise. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add PXE parserJeremy Kerr2013-04-291-0/+78
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud