summaryrefslogtreecommitdiffstats
path: root/discover
Commit message (Collapse)AuthorAgeFilesLines
* discover: Recognise and open LUKS encrypted partitionsSamuel Mendoza-Jonas2019-03-264-7/+200
| | | | | | | | | | | | | | Handle devices encrypted with LUKS and call cryptsetup to open them if a client sends the associated password. If a new device has the "crypto_LUKS" filesystem type it is marked as a LUKS device and sent to clients but further discovery is not performed. Once a client sends the device's password cryptsetup is called to open it. The opened device will appear separately, so the source device is "forgotten" at this point and then the newly opened device is treated as a normal partition. On destruction the device is "closed" with cryptsetup so that discovery can start from the beginning. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/devmapper: Retry dm-device remove if busyv1.10.0Samuel Mendoza-Jonas2018-12-131-5/+19
| | | | | | | | | | | | | | | | | | | | Buildroot's libdm is not built with --enable-udev_sync, so device-mapper actions are not able to sync or wait for udev events. (see 185676316, "discover/devmapper: Disable libdm udev sync support") This can cause an issue when tearing down a snapshot in devmapper_destroy_snapshot() which performs a DM_DEVICE_REMOVE task against the snapshot, origin, and base devices one after the other. In some cases if the interval between these actions is too short the action can fail as the preceding device hasn't disappeared yet and the device being removed is still busy. Since we don't yet have a way to tell exactly when the device is ready, pause for a short time and retry the action, letting devmapper_destroy_snapshot() continue and, for example, letting mount_device() fall back to the physical device. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platform-powerpc: read bootdev config from IPMI boot mailboxSamuel Mendoza-Jonas2018-12-133-1/+260
| | | | | | | | | | | | The IPMI Get System Boot Options commands includes parameter 7, the "boot initiator mailbox". This can be used to hold arbitrary data to influence the boot order. Use this to provide an alternate bootdev configuration to Petitboot that will override the one saved to NVRAM. This provides more fine grained override options than the existing device-type based overrides. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Keep track of the default boot optionSamuel Mendoza-Jonas2018-12-031-0/+4
| | | | | | | | | Keep track of the default boot option, and prefix its display name with a '(*)' to point it out to the user. This avoids having to authenticate with pb-discover even if only booting the default option. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platform-powerpc: Read and write password hash from NVRAMSamuel Mendoza-Jonas2018-12-031-0/+29
| | | | | | | | | If petitboot,password exists set it as the root password. This will be the password used to authenticate clients. This is the *hash* of a password as it would appear in /etc/shadow, not the password itself. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/device-handler: Prevent normal users changing boot targetSamuel Mendoza-Jonas2018-12-032-2/+14
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/discover-server: Restrict clients based on uidSamuel Mendoza-Jonas2018-12-036-3/+274
| | | | | | | | | | | | | | | | | | | | | If crypt support is enabled restrict what actions clients can perform by default. Initial authorisation is set at connection time; clients running as root are unrestricted, anything else runs as restricted until it makes an authentication to pb-discover. Unprivileged clients may only perform the following actions: - Boot the default boot option. - Cancel the autoboot timeout. - Make an authentication request. If a group named "petitgroup" exists then the socket permissions are also modified so that only clients running as root or in that group may connect to the socket. The user-event socket is only usable by root since the two main usecases are by utilities called by pb-discover or by a user in the shell who will need to su to root anyway. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platform-powerpc: Remove unused variableSamuel Mendoza-Jonas2018-11-291-1/+0
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Display warning if saving config failsSamuel Mendoza-Jonas2018-11-291-1/+4
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/boot: Fix talloc parent for resource URLsSamuel Mendoza-Jonas2018-11-291-7/+9
| | | | | | | | | The pb_urls for the boot resources use 'opt' as the talloc parent but this may be NULL, for example if this is a user-created boot option. Move the boot_task initialisation so it can be used as the talloc parent instead. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/grub2: Add support for initrd16 builtinShawn Anastasio2018-11-221-0/+4
| | | | | | | | | This commit adds support for the initrd16 builtin which compliments the existing linux16 support and improves usability on x86 platforms. Signed-off-by: Shawn Anastasio <shawn@anastas.io> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Nicely format IPMI response buffersv1.9.2Samuel Mendoza-Jonas2018-11-162-33/+23
| | | | | | | | | | | | | | | A few places where we print out the response buffer from an IPMI command weren't updated when log timestamps were added, resulting in very hard to read output. Add a little helper to format buffers and use it to print these with only one timestamp. Example: [04:59:01] ipmi_get_bmc_versions: BMC version resp [0][16]: 0x00 0x20 0x01 0x02 0x13 0x02 0xbf 0x00 0x00 0x00 0xbb 0xaa 0x58 0x98 0x01 0x00 Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* ui/ncurses: Reset console options on bootSamuel Mendoza-Jonas2018-11-162-3/+5
| | | | | | | | | | | | | | | The ncurses UI sets a few console options at startup that are needed for ncurses to work properly. These aren't reset however and can lead to quirks like the cursor being invisible after kexecing to the next kernel. The UI process doesn't have time to reset these when it is killed by kexec, so instead add a 'boot_active' field to status updates. This is set by boot.c's update handler so the UI can assume it is about to boot if it receives a status update with this field, and resets the console options. If the boot is cancelled for any reason the status update will reflect that and the console options are restored. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Reimplement native-parser as a Bison parserSamuel Mendoza-Jonas2018-11-167-131/+402
| | | | | | | | | | | | | | | | | | | Occasionally you look at some code and realise that a) this never gets built, and b) even if it did it would never compile. Today's example is native-parser.c which we must have just assumed worked for quite a while. The native parser has bitrotted entirely and needs to be brought up to date. While we're here, lets take the chance to implement a proper grammar for it. This helps us reason more effectively about the parser, lets us extend it easily in the future, and.. I wanted to write a Bison parser too. This implements most of the old functionality, but drops off some smaller details like settings icons which needs some separate attention to bring up to date. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Remove unused params.cSamuel Mendoza-Jonas2018-11-143-603/+0
| | | | | | | The discover/params code is an artifact from a long time ago, and isn't used by anything today: remove it. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/kboot-parser: Recognise 'default' parameterv1.9.1Samuel Mendoza-Jonas2018-08-281-1/+5
| | | | | | | | | | | | | The kboot parser doesn't set a default option. Change it so that if we see the 'default' parameter we match against this value when deciding if an option should be set as default. For example: default=linux linux='/vmlinux initrd=/initrd arg1=value1 arg2' Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/device-handler: Restore autoboot setting on requerySamuel Mendoza-Jonas2018-08-281-1/+9
| | | | | | | | | | | | | | | | When a device requery is triggered we cancel any default boot option on the device. This also disables autoboot which we don't want; any boot options found after the requery will not be able to autoboot. To avoid this restore the existing autoboot setting after checking for default options. This prevents a particular corner case where a default boot option has been selected for boot but one of its boot files has stalled or is taking more time to download than the requery timeout and the requery accidentally cancels autoboot preventing Petitboot from trying to boot again. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Let 'boot' user-event boot by nameSamuel Mendoza-Jonas2018-08-283-6/+48
| | | | | | | | | If a 'name' parameter is used for a boot user event, search existing boot options for one that matches that name on the given device. This allows a pb-event user to boot based on name rather than having to specify the exact boot arguments. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Stop udhcpc6 process on requerySamuel Mendoza-Jonas2018-08-281-0/+6
| | | | Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/arm64: Update to struct efi_mountGeoff Levand2018-08-151-32/+25
| | | | | Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* lib/efi: Add EFI_DEFALT_ATTRIBUTES macroGeoff Levand2018-08-141-4/+1
| | | | | | | | For convenience, add a new efi data attributes macro EFI_DEFALT_ATTRIBUTES. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platforms: Fix param_list talloc failureGeoff Levand2018-08-142-12/+14
| | | | | Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/platform: Use pb_log_fnGeoff Levand2018-08-141-1/+1
| | | | | Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Add platform-arm64Ge Song2018-08-072-0/+282
| | | | | | | 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>
* 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>
OpenPOWER on IntegriCloud