Commit Graph

106 Commits

Author SHA1 Message Date
Richard Hughes
fc3cfbad92 Do not check the build hash of modular plugins
We removed the abilty to easily build modular plugins, and so we don't need to
worry so much about random 3rd party modules being loaded.
2022-09-30 14:19:56 +01:00
Richard Hughes
99e9e5d523 Allow compiling plugin as built-in GObjects
Allow plugins to be built into libfwupdpluginbuiltin.so and created via GType.
2022-09-28 12:52:00 +01:00
Richard Hughes
bfebede490 Add support for platform capability descriptors so devices can set quirks
This feature adds support for platform capability BOS descriptors which allows
the device itself to ship quirk data.

Use `sudo fwupdtool get-devices --save-backends=FILENAME` to save fake backend
devices to a file. This allows easy creation of self tests that do not require
physical hardware.
2022-09-13 12:07:35 +01:00
Mario Limonciello
04c2186edc Add support for loading default BIOS settings policy
A user can place a JSON file in /etc/fwupd/bios-settings.d/ with
the default desired policy for the machine.

fwupd will load this policy on startup to ensure BIOS settings
are set as desired by the system administrator.
2022-08-24 12:59:42 -05:00
Mario Limonciello
b7b0ce533d trivial: Unify ambiguity between bios-attrs and bios-settings
These are currently used interchangeably since there was indecisiveness
which to use as the feature was being developed.

As outward facing it will be named with "settings", change all uses
in the code to match this.
2022-08-24 07:20:01 -05:00
Mario Limonciello
826983b8a7 Add support to set BIOS settings using a JSON payload
The JSON payload is ideally generated from `fwupdmgr get-bios-settings --json`
with all attributes expected to be included as additional arguments.
2022-08-24 09:51:46 +01:00
Mario Limonciello
5ded4f44fe Add support for reading and writing firmware attributes
This support is comprehensive:
 * Client library support
 * Daemon support
 * plugin support
 * Client tool support (with new commands)
2022-07-28 17:30:57 -05:00
Richard Hughes
221238b4c0 trivial: Allow each device to specify a different acquiesce delay
Different device classes may need different values, and these may need
modifying by quirks. Also use 50ms to flush out any pending events.
2022-07-21 15:27:04 +01:00
Richard Hughes
847151a51a Wait for the system to acquiesce after doing each update
We want to allow all the device hotplug events to be processed before
marking the update as completed. Otherwise, we might have a situation
where we have a child device attached to a parent, where we want to
update the parent, then the child. e.g.

 1. Add parent
 2. Add child
 3. Update parent
 4. Attach parent
 5. Wait for parent

...some time passes...

 6. Parent re-appears
 7. Update finishes, client indicates success

...child update is scheduled...
...which returns with failure as it does not exist...

 8. Add child

The child should have been added *before* the update completed to avoid
the caller from needing an unspecified delay as a *workaround*.
2022-07-20 19:10:12 +01:00
Richard Hughes
1e6d75a47e Add the HostVendor to the D-Bus interface
This allows us to show it in the same places as the host product.
2022-07-06 16:10:43 +01:00
Richard Hughes
17a10e4645 Fix get-details when the device requirements fail
First, fix a memory leak -- we had already done `_load_release()`
on an allocated release a few lines above and added a veto for the
get-details case. This also fixes the bug as the 2nd load is no longer
fatal as it does not exist.

Also, add some tests to check this for both the device-exists and
device-does-not-exist cases.

Fixes https://github.com/fwupd/fwupd/issues/4783
2022-06-30 18:01:27 +01:00
Richard Hughes
3e0a4dc1c3 Be smarter and include less header files per source file 2022-06-14 14:36:52 -05:00
Richard Hughes
2822d724b2 Unexport the nearly-unused FuAppFlags 2022-06-14 14:36:52 -05:00
Richard Hughes
770a452132 Unexport fu_common_error_array_get_best()
Plugins should not be using this.
2022-06-14 14:36:52 -05:00
Richard Hughes
45f71b1ecc trivial: Remove one layer of indirection when getting config keys
This makes it much easier to add new config keys in the future.
2022-06-08 13:41:38 +01:00
Richard Hughes
e6b487e762 Add FuProgress to ->startup() and ->coldplug()
This allows us to profile the daemon startup so we can find any plugins
taking an inordinate amount of time to start.
2022-06-04 20:21:50 +01:00
Richard Hughes
06e009297b Store the last-set status in the daemon
We emit to the client from the daemon, and also proxy the status from
the engine, i.e. we're setting the same property in two places.

When the client requests the last-set status, recover the value sent
from the lowest layer (the daemon) rather than the engine. The former
gets reset back to IDLE automatically, the latter does not.

Fixes https://github.com/fwupd/fwupd/issues/4649
2022-05-26 11:53:28 +01:00
Richard Hughes
a4906010d6 Add a way to read the device firmware in fwupdtool
In most cases 'fwupdtool firmware-dump' and 'fwupdtool firmware-read'
are going to be the same. This isn't true in all cases, especially when
dealing with composite firmware like archives.

See https://github.com/fwupd/fwupd/pull/4623#issuecomment-1129227133
2022-05-19 09:29:44 +01:00
Richard Hughes
d3d7cfa816 Add plugin quirk keys earlier in the startup process
This allows creating the silo when starting the engine with custom
plugin keys such as WacomI2cFlashBaseAddr.

If we move the plugin initialization earlier then we don't get the
HwID matches, so we really do have to split this into a 4-stage startup,
e.g. ->load(), ->init(), ->startup() and ->coldplug().
2022-05-09 11:13:52 +01:00
Mario Limonciello
b3de9ffd21 Add support for a new TrustedUids key
This key is used to specify that a dedicated user runs the fwupd
client process and sensitive strings such as the serial number should
be shared with the calling process.

(Fixes: #4524)
2022-04-14 10:30:54 -05:00
Richard Hughes
3ce161dfc2 Show the device serial number and instance IDs by default
This is a feature that seems useful, but one that no vendor has actually
asked for. It's also of limited use for peripheral devices.

Showing the instance IDs by default is also going to make it much easier
to explain to hardware vendors where the GUIDs come from.

Fixes https://github.com/fwupd/fwupd/issues/4445
2022-03-30 13:21:55 +01:00
Richard Hughes
0eeaad76ec Modernize and refactor the requirement checking code
Before we had FuInstallTask which represented the specific install
action (install foo on bar), FuEngineRequest which described why the
install task was created, and FuEngine. The latter being both reposible
for calling *into* FuInstallTask and also *from* FuInstallTask as well.

Depending on the code, we had XbNodes of component and release, *and*
FwupdReleases as releases and lots of duplicated code to marshall the
former into various forms of the latter.

Create a FuRelease wrapper around FwupdRelease to replace FuInstallTask
and to simplify the code. Make the FuRelease builder do the device
requirement checks, and then use the engine to do checks requiring
engine state and context.
2022-03-30 08:17:24 +01:00
Crag Wang
a2b46e15cf Add daemon configuration 'OnlyTrusted' to D-Bus properties 2022-03-10 09:46:54 +00:00
Richard Hughes
beb29ff698 Add a sync-bkc subcommand to ensure a known set of firmware versions
Install or downgrade firmware on all devices to make the system match
a well known set. This allows two things:

 * Factory recovery where a device in the field has been upgraded
 * Ensuring a consistent set of tested firmware for a specific workload

A tag is assigned either during upload or added post-upload on the LVFS
which is included in the metadata. A single firmware can be marked with
multiple tags, and tags can be duplicated for different firmwares.
2021-11-29 15:16:14 +00:00
Richard Hughes
b932c16b17 Remove the FuEngine::percentage-changed signal
Proxying the values is firstly inefficient, in that there were only
three functions in fu-engine.c that did not already have FuProgress
objects passed to them.

Secondly, processing the 'status' values from the engine meant that we
reset the percentage value to 0 for a split second, which made the
progress bar jump back to zero for one frame making it flicker.

Just make it all simpler and use FuProgress directly.
2021-11-15 14:59:37 +00:00
Richard Hughes
a0cb743700 Show changes in HSI attributes when required
e.g. `fwupdmgr security --force` would display:

    Host Security Events
      2021-10-29 10:51:42:  ✘ Kernel lockdown disabled
      2021-10-29 10:51:42:  ✘ SecureBoot disabled
      2021-10-29 09:32:32:  ✔ IOMMU device protection enabled
      2021-10-29 09:28:52:  ✘ IOMMU device protection disabled
2021-11-01 06:58:44 +00:00
Richard Hughes
644ac0ea05 Only installing firmwares with signatures by default
99.9999% of users are consuming firmware updates from the LVFS or
another trusted remote. It's far too easy to get a user to enter the
password to install an untrusted firmware, where the security
consequences are pretty dire.

Provide an escape-hatch for firmware engineers, but it does mean
editing a file in /etc as root. This seems like an acceptable level of
inconvenience.
2021-10-15 15:54:44 +01:00
Richard Hughes
40cd18fa97 Allow using a per-device global percentage completion
It's actually quite hard to build a front-end for fwupd at the moment
as you're never sure when the progress bar is going to zip back to 0%
and start all over again. Some plugins go 0..100% for write, others
go 0..100% for erase, then again for write, then *again* for verify.

By creating a helper object we can easily split up the progress of the
specific task, e.g. write_firmware().

We can encode at the plugin level "the erase takes 50% of the time, the
write takes 40% and the read takes 10%". This means we can have a
progressbar which goes up just once at a consistent speed.
2021-09-13 14:28:15 +01:00
Mario Limonciello
55de39c077 trivial: reformat the whole tree to match new format 2021-08-24 11:18:40 -05:00
Richard Hughes
f2fd6b0717 trivial: Do not save the self test quirk silo to disk
This also speeds up the tests as the amount of pointless i/o is reduced.

Fixes https://github.com/fwupd/fwupd/issues/3522
2021-07-22 12:51:47 +01:00
Richard Hughes
19abf996c7 Allow the daemon to request interactive action from the end user
The "return error and hope the client resubmits the firmware again"
pattern is clunky. There are two plugins doing this now, and about to
be one more.

This adds FwupdRequest which provides a structured way of asking the
user to perform an action, e.g. to replug the device or to press a
special key or button.

This replaces much of the UpdateMessage and UpdateImage API although
it is still used internally. Clients capable of processing the new
DeviceRequest signal should add REQUESTS to their feature flags.

Also, this allows us go back to the old meaning of _NEEDS_BOOTLOADER,
which was "needs rebooting into a bootloader mode" rather than the
slightly weird "user needs to do something and resubmit request".
2021-07-14 17:03:50 +01:00
Richard Hughes
63bc42eace Add a composite ID that is used to identify all devices in the same physical package 2021-04-22 16:27:04 +01:00
Richard Hughes
b333e0045c Split out a shared system context
There is a lot of code in fwupd that just assigns a shared object type to
a FuPlugin, and then for each device on that plugin assigns that same shared
object to each FuDevice.

Rather than proxy several kinds of information stores over two different levels
of abstraction create a 'context' which contains the shared *system* state
between the daemon, the plugins and the daemon.

This will allow us to hold other per-machine state in the future, for instance
the system battery level or AC state.
2021-04-01 21:11:29 +01:00
Richard Hughes
c7d870aa97 Allow using fwupdtool as non-root for firmware commands
Just avoid loading SMBIOS and re-generating remotes when all we want to use is
the firmware loader. It also speeds up the self tests somewhat too.
2020-12-10 20:43:54 +00:00
Mario Limonciello
381c27ca44 trivial: Split check for signed metadata when no polkit
Checking this requirement at daemon startup meant that trust was
evaluated before releases could actually be checked.

It's only important to check at install time.
2020-10-24 07:07:26 +01:00
Daniel Campello
f8fb2dc436 Fix get-updates and activate to use GUID in addition to device-id
Also merge fu_engine_get_device and fu_engine_get_device_by_id
2020-09-30 09:38:56 +01:00
Richard Hughes
fbd8b5d325 Add fu_device_dump_firmware()
Conceptually we were trying to stuff subtly different actions into one vfunc:

 * Read firmware from the device to update the verification checksums

 * Read a firmware blob from the device for debugging

For the first action we might want to mask out the sections of the flash with
serial numbers (so the verification hashes match the ones published on the LVFS)
and for the second we want just a raw ROM file from the hardware with no
pre-processing that we can compare against an external SPI dumper.

Split out ->dump_firmware to get the raw blob, and allow plugins to also
implement ->read_firmware() if they have to mask out specific offsets or remove
specific images from the FuFirmware container.

In the common case when masking is not required, fall back to using a 'binary'
FuFirmware automatically to make most plugins simpler.
2020-09-24 10:54:27 -05:00
Mario Limonciello
02085a0371 trivial: rework fwupdtool activate
Only use the history database to tell if activation should be run.
Instead query the connected devices to find the ones needing activation.

This should allow non-connected devices to not cause a failure (although
it might be a longer shutdown).

Also sort the devices, so that the order follows the defined order from
the daemon and they activate in the same order they install.
2020-09-14 11:28:55 -05:00
Richard Hughes
3120683143 Allow blocking specific firmware releases by checksum
Fixes https://github.com/fwupd/fwupd/issues/2280
2020-08-10 17:14:15 +01:00
Richard Hughes
df89cd566e Allow firmware to require specific features from front-end clients
At the moment we just blindly assume the capabilities of the front-end client
when installing firmware. We can somewhat work around by requiring a new enough
fwupd daemon version, but the client software may be older or just incomplete.

This would allow, for instance, the firmware to specify that it requries the
client to be able to show a detach image. This would not be set by a command
line tool using FwupdClient, but would be set by a GUI client that is capable
of downloading a URL and showing a PNG image.

Clients that do not register features are assumed to be dumb.
2020-06-27 15:43:57 +01:00
Richard Hughes
6ecc4ca144 Export the report metadata on the D-Bus interface
This allows the client to easily query metadata to upload with the report,
without exporting rarely used attributes as D-Bus properties on the interface.

It also allows us to add extra metadata values in the future without changing
the public API.
2020-05-20 19:47:53 +01:00
Richard Hughes
0c6efe2e04 Revert "Export the host vendor, family and SKU"
This reverts commit 81c371098c.
2020-05-20 19:47:53 +01:00
Richard Hughes
81c371098c Export the host vendor, family and SKU
The 'product name' is not typically what the hardware is known as. We need the
vendor, family and SKU if the user is going to recognise the hardware.
2020-05-19 19:42:45 +01:00
Richard Hughes
56e7ae503a trivial: Remove the GError from fu_engine_get_host_security_attrs()
It cannot fail.
2020-05-18 11:24:50 +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
196c6c69db Add support for the Host Security ID
The HSI specification assigns a simple text ID to the current state of firmware
security. As new vulnerabilities are found, and as protection measures are
updated, new requirements will be added to the required firmware behaviours for
each HSI value.

The HSI specification is currently incomplete and in active development, and
so the --force flag is required in all command line tools. The current ID value
will probably change on a given platform so please do not start using the result
for any kind of compliance requirements.
2020-05-11 22:11:49 +01:00
Richard Hughes
3aaf53c6f0 Allow specifying the device on the command line by GUID
The GUID is the only stable identifier, and allowing using the GUID makes it
much easier to test specific devices.
2020-04-20 18:45:45 +01:00
Filipe Laíns
d3a4fd3e1c fu-engine: export fu_engine_get_releases_for_device in header
Signed-off-by: Filipe Laíns <lains@archlinux.org>
2020-03-31 10:46:40 +01: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
Mario Limonciello
537da0e98b fu-engine: Make two passes of requirements checking
Resolves installation for local CAB files that have `VersionFormat`
    set but not yet also set from metadata.

    In the first pass ignore the version format. This will rule out all
    other checks such as GUID and protocol.

    Then apply version format to the device if specified in the CAB.
    Lastly do a second pass with all requirements set.
2020-03-09 15:54:30 -05:00