summaryrefslogtreecommitdiffstats
path: root/src/core/settings.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into openslxopenslxSimon Rettberg2024-04-121-0/+107
|\
| * [settings] Expose current working URI and directory URI via settingsMichael Brown2024-03-191-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | iPXE maintains a concept of a current working URI, which is used when resolving relative URIs and allows scripts to download files using URIs relative to the script itself. There are situations in which it is valuable for a script to be able to access the URI explicitly as a string, not just implicitly as a base URI for subsequent downloads. For example, when booting a Fedora installer, the "inst.repo" command-line parameter may be used to pass the URI of the repository to the installer. Expose the current working URI as ${cwuri}. Since relative URIs may be constructed as strings only from a directory URI (not from a full URI), also expose the current working directory URI as ${cwduri}. This feature may be used as e.g. #!ipxe echo Booting from ${cwuri} prompt -k 0x197e -t 2000 Press F12 to install Fedora... || exit kernel images/pxeboot/vmlinux inst.repo=${cwduri} initrd images/pxeboot/initrd.img boot Signed-off-by: Michael Brown <mcb30@ipxe.org>
* | Merge branch 'aqc1xx' into openslxSimon Rettberg2024-04-121-0/+33
|\|
| * [settings] Add parsing for UUID and GUID settings typesMichael Brown2024-02-291-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | The ":uuid" and ":guid" settings types are currently format-only: it is possible to format a setting as a UUID (via e.g. "show foo:uuid") but it is not currently possible to parse a string into a UUID setting (via e.g. "set foo:uuid 406343fe-998b-44be-8a28-44ca38cb202b"). Use uuid_aton() to implement parsing of these settings types, and add appropriate test cases for both. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* | Merge branch 'master' into openslxSimon Rettberg2022-05-111-12/+21
|\|
| * [settings] Always process all settings applicatorsMichael Brown2022-02-161-7/+3Star
| | | | | | | | | | | | | | | | Settings applicators are entirely independent, and there is no reason why a failure in one applicator should prevent other applicators from being processed. Signed-off-by: Michael Brown <mcb30@ipxe.org>
| * [settings] Support formatting UUIDs as little-endian GUIDsMichael Brown2022-01-041-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The RFC4122 specification defines UUIDs as being in network byte order, but an unfortunately significant amount of (mostly Microsoft) software treats them as having the first three fields in little-endian byte order. In an ideal world, any server-side software that compares UUIDs for equality would perform an endian-insensitive comparison (analogous to comparing strings for equality using a case-insensitive comparison), and would therefore not care about byte order differences. Define a setting type name ":guid" to allow a UUID setting to be formatted in little-endian order, to simplify interoperability with server-side software that expects such a formatting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* | Merge branch 'master' into openslxSimon Rettberg2020-02-241-2/+7
|\|
| * [settings] Eliminate variable-length stack allocationMichael Brown2020-02-161-2/+7
| | | | | | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* | [settings] Fix md5 buffer size handlingSimon Rettberg2018-09-251-2/+2
| | | | | | | | | | Return value is treated like snprintf, so returing ENOSPC doesn't make any sense.
* | [settings] Add md5 encoding type for doing ${foo:md5}Simon Rettberg2018-05-291-0/+47
|/ | | | | | | This obviously only works for formatting, not parsing. This makes it possible to implement client side password checks without giving the password away too easily. Not super secure as it's md5, but enough for basic protection.
* [settings] Extend numerical setting tags to 64 bitsMichael Brown2017-05-221-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [block] Allow use of a non-default EFI SAN boot filenameMichael Brown2017-04-121-0/+9
| | | | | | | | | | | | | | | | | | | | | | | Some older operating systems (e.g. RHEL6) use a non-default filename on the root disk and rely on setting an EFI variable to point to the bootloader. This does not work when performing a SAN boot on a machine where the EFI variable is not present. Fix by allowing a non-default filename to be specified via the "sanboot --filename" option or the "san-filename" setting. For example: sanboot --filename \efi\redhat\grub.efi \ iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6 or option ipxe.san-filename code 188 = string; option ipxe.san-filename "\\efi\\redhat\\grub.efi"; option root-path "iscsi:192.168.0.1::::iqn.2010-04.org.ipxe.demo:rhel6"; Originally-implemented-by: Vishvananda Ishaya Abrams <vish.ishaya@oracle.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dhcp] Allow vendor class to be changed in DHCP requestsMichael Brown2017-03-201-0/+9
| | | | | | | Allow the DHCPv4 vendor class to be specified via the "vendor-class" setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "unixtime" builtin setting to expose the current timeMichael Brown2017-01-261-0/+33
| | | | | | | | | | | Expose the current wall-clock time (in seconds since the Epoch), since this is often useful in captured boot logs and can also be useful when checking unexpected X.509 certificate validation failures. Use a :uint32 setting to avoid Y2K38 rollover, thereby ensuring that this will eventually be somebody else's problem. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow settings blocks to specify a sibling orderingMichael Brown2016-07-191-0/+2
| | | | | | | Allow settings blocks to provide an explicit default ordering between siblings, with lower precedence than the existing ${priority} setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Correctly mortalise autovivified child settings blocksMichael Brown2016-07-191-0/+1
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ipv6] Rename ipv6_scope to dhcpv6_scopeMichael Brown2016-07-161-1/+1
| | | | | | | | The settings scope ipv6_scope refers specifically to IPv6 settings that have a corresponding DHCPv6 option. Rename to dhcpv6_scope to more accurately reflect this purpose. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pci] Support systems with multiple PCI root bridgesMichael Brown2016-06-091-2/+11
| | | | | | | | | Extend the 16-bit PCI bus:dev.fn address to a 32-bit seg:bus:dev.fn address, assuming a segment value of zero in contexts where multiple segments are unsupported by the underlying data structures (e.g. in the iBFT or BOFM tables). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Extend numerical setting tags to "unsigned long"Michael Brown2016-05-201-2/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Re-add "uristring" setting typeMichael Brown2015-08-251-5/+33
| | | | | | | | | | | | | | | | | | | | Commit 09b057c ("[settings] Remove "uristring" setting type") removed support for URI-encoded settings via the "uristring" setting type, on the basis that such encoding was no longer necessary to avoid problems with the command line parser. Other valid use cases for the "uristring" setting type do exist: for example, a password containing a '/' character expanded via chain http://username:${password:uristring}@server.name/boot.php Restore the existence of the "uristring" setting, avoiding the potentially large stack allocations that were used in the old code prior to commit 09b057c ("[settings] Remove "uristring" setting type"). Requested-by: Robin Smidsrød <robin@smidsrod.no> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "base64" setting typeMichael Brown2015-04-241-0/+41
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [base16] Add buffer size parameter to base16_encode() and base16_decode()Michael Brown2015-04-241-32/+6Star
| | | | | | | | | | | | | | The current API for Base16 (and Base64) encoding requires the caller to always provide sufficient buffer space. This prevents the use of the generic encoding/decoding functionality in some situations, such as in formatting the hex setting types. Implement a generic hex_encode() (based on the existing format_hex_setting()), implement base16_encode() and base16_decode() in terms of the more generic hex_encode() and hex_decode(), and update all callers to provide the additional buffer length parameter. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Rewrite unrelicensable portions of settings.cMichael Brown2015-03-031-6/+13
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Use list_first_entry() when unregistering child settingsMichael Brown2015-03-031-2/+2
| | | | | | | | | Unregistering a child settings block can have almost arbitrary effects, due to the call to apply_settings(). Avoid potentially dereferencing a stale pointer by using list_first_entry() rather than list_for_each_entry_safe() to iterate over the list of child settings. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove "uristring" setting typeMichael Brown2014-02-271-49/+5Star
| | | | | | | | | | | | | | Commit b5f5f73 ("[cmdline] Expand settings within each command-line token individually") effectively rendered the "uristring" setting type obsolete, since strings containing whitespace no longer break the command line parser. The concept of the "uristring" type is not well defined, since URI escaping rules depend on which portion of a URI is being escaped. Remove the "uristring" type, converting it into an alias for the "string" setting type so as to avoid breaking existing scripts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Merge SETTING_IPv4 and SETTING_IPv6Michael Brown2013-12-051-1/+1
| | | | | | | Allow for equivalent IPv4 and IPv6 settings (which requires equivalent settings to be adjacent within the settings list). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow for multiple definitions of each predefined settingMichael Brown2013-12-051-4/+30
| | | | | | | | | | Allow for multiple setting definitions with the same name but different scopes and tags. For example, allow for a "filename" setting with default scope and tag value 67 (for DHCPv4) and a corresponding "filename" setting with IPv6 scope and tag value 59 (for DHCPv6). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Force settings into alphabetical order within sectionsMichael Brown2013-12-051-13/+14
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add fetch_ipv6_setting()Michael Brown2013-12-051-0/+38
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow for IPv6 setting types in non-IPv6 buildsMichael Brown2013-12-051-24/+55
| | | | | | | | | Allow for the existence of references to IPv6 setting types without dragging in the whole IPv6 stack, by placing the definition of setting_type_ipv6 in core/settings.c and providing weak stub methods for parse_ipv6_setting() and format_ipv6_setting(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Explicitly separate the concept of a completed fetched settingMichael Brown2013-12-051-187/+253
| | | | | | | | | | The fetch_setting() family of functions may currently modify the definition of the specified setting (e.g. to add missing type information). Clean up this interface by requiring callers to provide an explicit buffer to contain the completed definition of the fetched setting, if required. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Move user-class setting from dhcp.c to settings.cMichael Brown2013-11-141-0/+8
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Make built-in settings a linker tableMichael Brown2013-08-271-46/+46
| | | | | | | Allow for configurable provision of built-in settings by placing them in a linker table rather than an array. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow numeric_setting_value() to handle long setting valuesMichael Brown2013-08-121-4/+4
| | | | | | | | | | | Allow numeric_setting_value() to handle e.g. the byte sequence 00:00:00:00:12:34:56:78 by returning -ERANGE only if the value actually overflows the return type. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Introduce the generalised concept of a numeric settingMichael Brown2013-08-011-175/+412
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove now-unused fetchf_named_setting() and storef_named_setting()Michael Brown2013-07-221-114/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove now-unused store_named_setting()Michael Brown2013-07-191-35/+0Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Eliminate call to fetchf_named_setting() in expand_settings()Michael Brown2013-07-191-22/+25
| | | | | | | | | | Use parse_setting_name() and fetchf_setting_copy() in expand_settings(), to eliminate the call to fetchf_named_setting(). This change also eliminates the potentially large stack-allocated buffer in expand_settings(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add fetchf_setting_copy()Michael Brown2013-07-191-2/+39
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Change "not-found" semantics of fetch_setting_copy()Michael Brown2013-07-191-14/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | | fetch_settings_copy() currently returns success and a NULL data pointer to indicate a non-existent setting. This is intended to allow the caller to differentiate between a non-existent setting and an error in allocating memory for the copy of the setting. The underlying settings blocks' fetch() methods provide no way to perform an existence check separate from an attempt to fetch the setting. A "non-existent setting" therefore means simply a setting for which an error was encountered when attempting to fetch from every settings block within the subtree. Since any underlying error within a settings block (e.g. a GuestRPC failure when attempting to retrieve a VMware GuestInfo setting) will produce the effect of a "non-existent setting", it seems somewhat meaningless to give special treatment to memory allocation errors within fetch_setting_copy(). Remove the special treatment and simplify the semantics of fetch_setting_copy() by directly passing through any underlying error (including non-existence) encountered while fetching the setting. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Expose parse_setting_name()Michael Brown2013-07-191-11/+5Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove default_type parameter from parse_setting_name()Michael Brown2013-07-191-9/+20
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove temporary name buffer parameter from parse_setting_name()Michael Brown2013-07-181-22/+40
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Avoid potentially large stack allocationsMichael Brown2013-07-181-26/+43
| | | | | | | Avoid potentially large stack allocations in fetchf_setting() and storef_setting(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Clarify usage of the term "named setting"Michael Brown2013-07-181-10/+10
| | | | | | | | | | | | There are currently two conflicting usages of the term "named setting" within iPXE: one refers to predefined settings (such as show up in the "config" UI), the other refers to settings identified by a name (such as "net0.dhcp/ip"). Split these usages into the term "predefined setting" and "named setting" to avoid ambiguity. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "version" builtin settingRobin Smidsrød2013-07-131-0/+22
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Make "netX" settings block function as a symbolic linkMichael Brown2013-07-131-23/+50
| | | | | | | | | | | | | | Add a facility for settings blocks to act as symbolic links to other settings blocks, and reimplement the "netX" virtual settings block using this facility. The primary advantage of this approach is that unscoped settings such as ${mac} and ${filename} will now reflect the settings obtained from the most recently opened network device: in most cases, this will mean the settings obtained from the most recent DHCP attempt. This should improve conformance to the principle of least astonishment. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "busdevfn" setting typeMichael Brown2013-07-121-0/+47
| | | | | | | Allow network device's "busloc" setting to be formatted as a PCI bus:dev.fn address using e.g. ${net0/busloc:busdevfn}. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "hexraw" setting typeMichael Brown2013-07-121-0/+35
| | | | | Originally-implemented-by: Jeppe Toustrup <ipxe@tenzer.dk> Signed-off-by: Michael Brown <mcb30@ipxe.org>