Commit Graph

92 Commits

Author SHA1 Message Date
Richard Hughes
e3fb2e45cd trivial: Fix two more missing <string.h> instances 2020-12-14 20:24:04 +00:00
Richard Hughes
4ab347ec78 trivial: Do not use g_file_load_bytes() in the self tests
This is not available in older GLib versions.
2020-12-14 20:24:01 +00:00
Richard Hughes
05efd7b960 trivial: Don't assume a specific page size in the unit tests
This was found in the self tests on PPC64.

Fixes https://github.com/fwupd/fwupd/issues/2581
2020-11-15 09:17:08 +00:00
Richard Hughes
41a1650c2a Remove HSI update and attestation suffixes
The logic here is that the attestation is more than just the PCR0 value, and
multiple device firmware (such as EC, ME, etc.) needs to be included to validate
the system.

By the same logic, updates for the system firmware do not tell the whole story,
and confuse HSI as a specification. Remove them.
2020-11-05 15:12:12 +00:00
Richard Hughes
203ed841da trivial: Codespell fixes 2020-11-02 14:26:26 +00:00
Richard Hughes
6d257cbe7f Fix probe warning for the Logitech Unifying device
The same plugin name was being added to the device from the quirk file more than
once, and so we enumerated the device *again* and tried to add a duplicate
device -- the device list correctly refusing to do so.

Check the plugin name does not already exist before adding it, and add a self
test to catch this for the future.
2020-10-27 15:43:17 +00:00
Richard Hughes
49c2a78c99 Include the amount of NVRAM size in use in the LVFS failure report 2020-10-27 13:58:40 +00:00
Richard Hughes
a2a8f8ea70 Add fu_byte_array_set_size()
The GLib g_byte_array_set_size() function does not zero the contents if the
array size is larger, which leads to unpredictable output when using valgrind.
2020-10-20 19:54:07 +01:00
Richard Hughes
81b5defaa6 uefi: Use fu_efivar_get_data() to fix setting BootNext correctly
Fixes https://github.com/fwupd/fwupd/issues/2169
2020-10-19 16:13:21 +01:00
Richard Hughes
f27e19beac Parse the HEX version before comparing for equality
This fixes the error: 'Update Error: device version not updated on success,
0x00000002 != 0x0002' -- it seems a bit crazy to have to specify 32 bits of
zero digits in the firmware.metainfo.xml
2020-10-13 15:57:03 -05:00
Richard Hughes
10c3fd2ff9 Support loading DMI data from DT systems
To do this with the existing codebase just fake the required SMBIOS structures.
2020-09-30 19:22:45 -05:00
Richard Hughes
44ae2a75e4 trivial: Add CRC8 as well 2020-09-25 18:00:21 +01:00
Richard Hughes
6f5e35a3ea Add common CRC routines
We have quite a few versions of CRC in-tree, and are about to get two more...
2020-09-25 17:52:43 +01:00
Richard Hughes
3e9fafcc6f Add fu_firmware_remove_image() 2020-09-24 10:54:27 -05:00
Richard Hughes
41400a8cc6 Allow contructing a firmware with multiple images
At the moment there are commands to convert one file format to another, but not
to 'merge' or alter them. Some firmware files are containers which can store
multiple images, each with optional id, idx and addresses.

This would allow us to, for instance, create a DfuSe file with two different
raw files that are flashed to different addresses on the SPI flash. It would
also allow us to create very small complicated container formats for fuzzing.

This can be used by writing a `firmware.builder.xml` file like:

   <?xml version="1.0" encoding="UTF-8"?>
   <firmware gtype="FuBcm57xxFirmware">
     <version>1.2.3</version>
     <image>
       <version>4.5.6</version>
       <id>header</id>
       <idx>456</idx>
       <addr>0x456</addr>
       <filename>header.bin</filename>
     </image>
     <image>
       <version>7.8.9</version>
       <id>payload</id>
       <idx>789</idx>
       <addr>0x789</addr>
       <data>aGVsbG8=</data>
     </image>
   </firmware>

...and then using something like:

   # fwupdtool firmware-convert firmware.builder.xml firmware.dfu builder dfu
2020-09-21 18:11:13 +01:00
Richard Hughes
f17db477eb Tag the FuFirmwareImage objects with the filename
For containers with multiple images it is sometimes very helpful to know what
file they've been loaded from. This would also allow us to 'explode' the
firmware container into seporate image files on disk.
2020-09-21 18:11:13 +01:00
Richard Hughes
6da96cd04a Add FuFirmwareFlags to allow opt-in dedupe of added images
The function fu_firmware_add_image() has the comment text 'If an image with the
same ID is present it is replaced' which has not been true for some time.

This was removed, as the common case of adding two images with no ID would only
leave one. However, some plugins do actually want to dedupe on the ID or IDX,
so provide a flag they can set which enables this functionality without
introducing regressions into other plugins.
2020-09-17 20:49:01 +01:00
Richard Hughes
2506dbff6f trivial: Use the same indent size when appending key values 2020-09-03 16:50:41 +01:00
Richard Hughes
fd0ee5153e Add some of the HSI specification to the generated documentation 2020-08-17 20:23:49 +01:00
Richard Hughes
664b8aa9ad Add XB_QUERY_FLAG_FORCE_NODE_CACHE
Newer versions of libxmlb do not auto-cache XbNodes, and we have to opt-into
this beahviour for the _set_data() and _get_data() to work.

Although this is a behaviour change which also increases complexity, it lowers
our RSS usage by 200kB which is about a quarter of the total RSS used...
2020-06-23 16:30:38 +01:00
Mario Limonciello
b0e1e5ec12 Add daemon version into the HSI string 2020-05-18 15:41:51 -05:00
Richard Hughes
b246bcaecb Allow client tools to translate the HSI attributes and results
To do this, rely on the AppStream ID to map to a translated string (providing a
fallback for clients that do not care) and switch the free-form result string
into a set of enumerated values that can be translated.

This fixes some of the problems where some things have to be enabled to "pass"
and other attributes have to be some other state. For cases where we want the
user to "do" something, provide a URL to a wiki page that we update out-of-band
of fwupd releases.
2020-05-18 17:03:49 +01:00
Richard Hughes
cae111d1de Save the plugin that created the FwupdSecurityAttr
This is really useful for debugging.
2020-05-15 16:17:27 +01:00
Richard Hughes
f58ac7316c hsi: Abstract out the list of FwupdSecurityAttr objects for plugins
This exports FuSecurityAttrs into libfwupdplugin so that we can pass the plugins
this object rather than a 'bare' GPtrArray. This greatly simplifies the object
ownership, and also allows us to check the object type before adding.

In the future we could also check for duplicate appstream IDs or missing
properties at insertion time.

This change also changes the fu_plugin_add_security_attrs() to not return an
error. This forces the plugin to handle the error, storing the failure in the
attribute itself.

Only the plugin know if a missing file it needs to read indicates a runtime
problem or a simple failure to obtain a specific HSI level.
2020-05-12 16:47:24 +01:00
Richard Hughes
cf0a7678b8 Allow removing device flags from quirk files
This also means we do the right thing when plugins call fu_device_add_flag()
directly, instead of just from a quirk file.

For instance, now `Flags = ~updatable` is a valid and useful thing to have and
allows us to remove the `Flags = None` hack.
2020-04-13 23:18:19 +01:00
Richard Hughes
348719f759 Add fu_device_retry() helper functionality
Sometimes plugins need to retry various commands send to hardware, either due
to unreliable transfers (e.g. using USB bulk) or from slightly quirky hardware.

Between them they seem to get various things wrong; either the error messages
are repeated and thus difficult to parse, or they just get the memory handling
of `g_propagate_prefixed_error()` wrong.

Providing sane helpers we can reduce the amount of boilerplate. Additionally
we can support a 'reset' function that can try to automatically recover the
hardware for specific error domains and codes.
2020-03-27 15:47:08 +00:00
Richard Hughes
d5aab65f30 Use Jcat files in firmware archives and for metadata
A Jcat file can be used to store GPG, PKCS-7 and SHA-256 checksums for multiple
files. This allows us to sign a firmware or metadata multiple times (perhaps
by the OEM and also then the LVFS) which further decentralizes the trust model
of the LVFS.

The Jcat format was chosen as the Microsoft catalog format is nonfree and not
documented. We also don't want to modify an existing .cat file created from WU
as this may make it unsuitable to use on Windows.

More information can be found here: https://github.com/hughsie/libjcat
2020-03-23 19:55:12 +00:00
Richard Hughes
51b4a1666e Add fu_device_get_root() shared API
This gets the 'topmost parent' for a composite device, as devices such as hubs
may have more logical layers than just one.
2020-03-10 17:09:13 +00:00
Mario Limonciello
c8bae2a68c Introduce a new VersionFormat for hex
When CPU microcode is distributed it typically is versioned in
hexadecimal in all tools.  Converting it to any of the existing version
formats provides an unexpected result that requires converting back to
hexadecimal.
2020-03-06 08:12:58 -06:00
Mario Limonciello
b87d48a042 When TPM PCR0 measurements fail, query if secure boot is available and enabled
If the measurements are missing but it's a UEFI system, it's a good indication
that the user has secure boot turned off.
Notify the user on the UEFI device through a non-fatal `UpdateMessage`

To accomplish this, move fu-uefi-vars into the plugin library for other plugins to use
2020-03-05 07:54:15 -06:00
Richard Hughes
f50ff2c27e Decouple the version format from the version itself
If we say that the version format should be the same for the `version_lowest`
and the `version_bootloader` then it does not always make sense to set it at
the same time.

Moving the `version_format` to a standalone first-class property also means it
can be typically be set in the custom device `_init()` function, which means we
don't need to worry about *changing* ther version format as set by the USB and
UDev superclass helpers.
2020-02-25 14:00:09 +00:00
Richard Hughes
8d919b3acb Remove support for GCab less than v1.0
We can fall back to the subproject version if required for CI targets.
2020-02-24 12:33:44 +00:00
Mario Limonciello
9dce1f7011 Detect kernel lockdown status
Disable superio when kernel lockdown in effect.
2020-02-04 10:08:25 -06:00
Richard Hughes
f1a7122250 Add a dell-bios version format
Dell does not include the first byte in the ESRT value, ignoring it. Using a
`quad` means we get versions like `0.1.4.0` rather than `1.4.0` which confuses
both users comparing versions to the vendor website, and also anyone trying to
do analysis on the firmware.
2019-12-04 16:22:46 +00:00
Richard Hughes
1fbcb1a180 Do not do semver conversion in fu_common_vercmp()
We don't know the version format, and so it's impossible to do it reliably --
just do it in the caller where we *do* know the FuDevice version format.
2019-12-04 15:45:30 +00:00
Richard Hughes
df8833e875 trivial: Deprecate fu_common_version_parse()
This hardcodes the version format of 'triplet' which isn't always correct for
obvious reasons.
2019-12-04 15:45:30 +00:00
Richard Hughes
d865d2473e trivial: Add fu_common_version_from_uint64() 2019-12-04 14:50:41 +00:00
Richard Hughes
45a00738d8 Allow building on Windows with MinGW
Add various fixes to enable us to build a selection of useful USB plugins.
Also, skip tests that don't make sense on WIN32 or that will not work.

With much help from Mario Limonciello <mario.limonciello@dell.com> -- Thanks!
2019-12-03 16:33:43 +00:00
Mario Limonciello
5beceda89b trivial: Move progressbar out of libfwupdplugin
The intention with f0f504c740 was to
not offer this in the plugin, but when rebasing 6b0e66354b
this was forgotten to be removed.
2019-11-27 08:18:02 -06:00
Richard Hughes
3ed2ac8315 trivial: Unexport fu_test_get_filename()
We don't actually need either of the things it provides (looking up in source
and built, and converting to an absolute path) so just replace it with
g_build_filename() instead.

This also has the advantage that it does the right thing on Windows.
2019-11-27 12:45:35 +00:00
Richard Hughes
f3d5207351 trivial: Unexport fu_test_loop_run_with_timeout() 2019-11-27 12:45:35 +00:00
Mario Limonciello
6b0e66354b Convert libfwupdprivate to a shared library libfwupdplugin 2019-11-27 11:32:43 +00:00