Commit Graph

730 Commits

Author SHA1 Message Date
Richard Hughes
98622b690b trivial: Rename an internal function to reflect reality 2022-10-25 10:46:29 -05:00
Richard Hughes
33347866de Revert "trivial: load hwinfo early so plugins can use the info timely"
This reverts commit 960b6141a6 as
fu_context_load_hwinfo() needs to load the HWID quirks, and we need to load the
plugins before the quirks otherwise we'll get warnings about quirk keys not
being registered.
2022-10-25 10:46:29 -05:00
Crag Wang
960b6141a6 trivial: load hwinfo early so plugins can use the info timely 2022-10-24 23:21:39 +08:00
Richard Hughes
fab1066314 trivial: Add a few more kernel command line arguements we don't care about 2022-10-21 12:17:46 +01:00
Richard Hughes
c190c0877d Allow parsing metadata more than 1MB in size
The LVFS crept over this limit yesterday. I've put some emergency commits in
place that take it back down to 800KB, and I'll focus next week on getting it
much lower than that.

The real problem is that we thought that g_input_stream_read_bytes() was using
`count` as the chunk size, not the total size. Raise the total size to 32MB and
chunk in 32kB blocks to reduce the RSS peak when loading metadata.

Fixes https://github.com/fwupd/fwupd/issues/5173
2022-10-19 15:09:57 +01:00
Richard Hughes
1c35757f85 Consider the release priority when returning results
This means we might be able to offer two versions of firmware for the same
device, where one has additional requirement such as a CHID.

The idea here is to allow OEMs to distribute thier own superset dbx updates on
the LVFS without having to invent an anti-CHID requirement type.
2022-10-18 17:55:31 +01:00
Richard Hughes
617137922d Add some more profiling to debug custom device GType creation
It turns out using tss2_esys is slow (200ms) -- and now we know.
2022-10-07 14:41:48 +01:00
Richard Hughes
423637ef80 Use LVFS::UpdateRequestId to create a translated FwupdRequest 2022-10-06 10:30:31 +01:00
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
Mario Limonciello
d5585728a2 trivial: don't refer to plugindir in the build system anymore 2022-09-28 15:12:10 -05:00
Richard Hughes
439c364f46 trivial: Fold FuPluginVfuncs into FuPluginClass
This adds 7 pointer-size blocks of wasted space for each modular plugin, and
three pointers for builtin plugins, but allows us to use the exact same vfuncs
when building plugins in either mode.

This will allow us to convert nearly all the plugins to being builtin.
2022-09-28 14:42:04 +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
b50ef90aa6 trivial: Fix up some internal docs to reflect reality 2022-09-23 16:39:21 +01:00
Richard Hughes
5d38e0aeea Move the getting the ESP to the context
We now have two plugins getting the ESP values, and we only allow hardcoding
the ESP in uefi_capsule.conf.

Make all this a lot simpler by moving the ESP+BDP code to `FuContext`, which
also means we can handle the override (via the config file) in the engine,
and the override (in the command line tools) using the same mechanism.

Also, automate the migration of the `OverrideESPMountPoint` -> `EspLocation`
when loading the engine.

Fixes https://github.com/fwupd/fwupd/issues/5042
2022-09-22 14:31:06 +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
Richard Hughes
f7b4f43744 Fix checking for invalid depth requirements
PVS: It's possible that the 'device_tmp' should be checked here.
2022-09-09 19:23:29 +01:00
Richard Hughes
ce014ccf65 trivial: Fix a tiny memory leak when loading BIOS settings 2022-09-06 21:23:44 +01:00
Richard Hughes
39b931938f trivial: Allow parsing thunderbolt-nvm images from fwupdtool 2022-09-06 20:45:38 +01:00
Richard Hughes
1faac75aa5 Ensure the context is set for all backends
This isn't required right now, but new functionality is much easier to add if
we know the context has always been set.
2022-09-06 20:30:21 +01:00
Richard Hughes
709af2a269 Add shared functionality to get the parsed kernel cmdline 2022-09-02 14:35:48 +01:00
Mario Limonciello
ad461d504d bios-settings: Fix plugin functionality
By moving the attribute loading into udev it was loading too late
and plugins couldn't use it.  Move the loading to earlier in the
daemon and ignore add events if we already have attributes loaded.

Fixes: #4979
2022-08-31 09:21:07 -05:00
Richard Hughes
16b463334e Export the generic Intel Thunderbolt firmware format
This is being used for other products, e.g. USB4 docks.

If non-Intel firmware is being used (e.g. ASMedia) then the explicit
calls to `fu_intel_thunderbolt_nvm_new()` can be changed to something
like `fu_firmware_new_from_gtypes()` with all the formats listed.
2022-08-30 14:20:14 +01:00
Mario Limonciello
273a363a71 trivial: bios-settings: don't show error for nothing to do
After policy applies for the first time, you don't want to show
messaging to users that the policy can't apply the next time.
2022-08-25 14:40:09 -05:00
Richard Hughes
e12b46b991 Force the chassis type to be valid if emulating
The logic being that if we're emulating another system we're possibly
on a VM, and that's possibly going to report that it isn't a desktop.

I also think it makes sense to serialize out the FuSmbios object
to-and-from JSON, but that's a patch for another day.
2022-08-25 13:56:41 +01:00
Richard Hughes
50f0953b32 trivial: Fix a Coverity issue which is really a false positive 2022-08-25 12:15:23 +01:00
Richard Hughes
afb56d4286 trivial: Fix one -Wunused-variable warning 2022-08-25 12:08:33 +01:00
Mario Limonciello
9391deb2d7 trivial: only accept bios settings ending in .json 2022-08-25 10:08:39 +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
2f9cb74c59 trivial: don't assume we know about pending_reboot
The `pending_reboot` variable is tracked by the kernel, make sure
that it is updated from the kernel when BIOS settings are changed.
2022-08-24 12:59:42 -05:00
Mario Limonciello
e49c64553d trivial: return FWUPD_ERRROR_NOTHING_TO_DO if BIOS settings already set
This will prevent setting `pending_reboot` if the settings already match
those desired by the client.
2022-08-24 10:58:25 -05:00
kate
3d199058bb fu-engine: HSI prefix fixing for invalid chassis
The invalid HSI prefix should be "HSI:INVALID" not "HSI-INVALID".

Signed-off-by: Kate Hsuan <hpa@redhat.com>
2022-08-24 16:27:02 +01: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
fa661c595d trivial: map common positive or negative keys to possible enumeration values
Dell and Lenovo use Enable or Enabled and Disable or Disabled which is confusing
to an end user.

Set up some heuristics to map positive values and negative values when passed
into the client.
2022-08-10 10:37:27 -05:00
Richard Hughes
934002553a Allow loading BIOS attributes for host emulation 2022-08-01 13:32:12 +01:00
Richard Hughes
77006b75eb Set the target value on the security attribute
Semantically it is the desire of the security attribute, not the bios
attribute, i.e. you could imagine that a specific attribute would have
to be *foo or bar or baz* for HSI-1 and *only foo* for HSI-2

Also make it easier to add possible BIOS attribute target values in
plugin code.
2022-08-01 07:12:18 +01:00
Richard Hughes
47efacfe5d Remove the firmware builder functionality
We used the firmware builder functionality to either build or modify
firmware images on the end-user system, e.g. copying the MAC address
from the old system image to the new system image.

Unfortunately running fwupd on the command line (e.g. ./src/fwupd)
leaves the tty connected and thus bubblewrap doesn't protect us from
installing malicious signed firmware. The firmware would have to have
been uploaded to the LVFS by a trusted vendor and signed before being
installed, which further decreases the severity of this problem.

As there was only one vendor who asked for this functionality (who have
yet to upload a single firmware to the LVFS...) just rip out this
functionality to reduce our attack surface and completely fix the bug,
and any like it.

Many thanks to Aaron Janse <aaron@ajanse.me> for discovering and
disclosing this issue to us.
2022-07-29 16:52:38 +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
829258401e Allow plugins and backends to print debugging information to the console
This is really useful for debugging.
2022-07-28 16:10:06 +01:00
Richard Hughes
93a162397c trivial: Ensure HSI attributes are fixed-up when returned as history 2022-07-26 14:30:48 +01:00
Richard Hughes
dc25187059 Add a title and long translated description for security attributes
We need these in at least two projects (gnome-control-center, cockpit)
and it makes sense to store these where we define the new IDs.
2022-07-26 11:47:27 +01:00
Richard Hughes
1d590bb32a trivial: Fix a thinko when waiting for acquiesce
Of course, the timeout has to be restarted after a qualifying hotplug event...
2022-07-21 17:19:21 +01: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
027a75a146 Wait for system acquiesce when installing each device of composite firmware
This makes installing firmware onto docks a bit less confusing.
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
62fc515714 Allow loading in emulated host profiles for debugging
This allows us to load sets of different host security attributes
for testing the various front end tools we have now. e.g.

    sudo FWUPD_HOST_EMULATE=thinkpad-p1-iommu.json.gz fwupd

or, using a non-compressed absolute path:

    sudo FWUPD_HOST_EMULATE=/tmp/test/thinkpad-p1-iommu.json fwupd

Data can be created with `./contrib/generate-emulation.py file.json`
and then can be manually modified if required. Running the script on
a file that already exists will just strip out any unneeded data, as
well as piping content into it using stdin.

As a precaution, the org.fwupd.hsi.HostEmulation attribute is added
so we do not ask the user to upload the HSI report. It also allows
the LVFS to ignore any HSI reports with this attribute for clients
that upload HSI reports regardless.

See https://github.com/fwupd/fwupd/discussions/4832
2022-07-18 16:27:59 +01:00
Richard Hughes
6adc60b5ba Ensure the container checksum has always been added before install 2022-07-18 16:12:43 +01:00
Richard Hughes
3487eb223b trivial: Add the container checksums when getting file details
This makes it easier to debug, as this shows what the checksum would be
stored in the history database on successful update.

We're already generating them, and so it's really just being helpful.
2022-07-18 16:12:43 +01:00
Richard Hughes
0f2298095d trivial: Simplify the engine FuProgress setup 2022-07-16 21:42:23 +01:00
Richard Hughes
ae0c3fe38a Add 'action' resolution flags to each FwupdSecurityAttr
We tried to solve this by matching the org.fwupd.hsi AppStream ID, but
in some cases the resolution depends on what actually failed.

Add "the action the user is supposed to do" as flags so that the
front-end can translate this in the appropriate way, for instance,
using a different string for log events and HSI dialogs.
2022-07-14 14:47:44 +01:00