Commit Graph

102 Commits

Author SHA1 Message Date
Richard Hughes
4257d5f451 Add support for Quit() in fwupdmgr
This allows us to only shut down the P2P daemon in the installed tests.
The easy fix would have been to use something like:

    gdbus call --address unix:path=/run/fwupd.sock --object-path / --method org.freedesktop.fwupd.Quit'

...but the daemon does not implement an ObjectManager, which gdbus requires.

This worked correctly for so long because the p2p tests were being run after
the bus tests, so shutting down the system daemon had no effect.

Fedora 37 seems to have flipped the order for some reason -- and now it
*sometimes* matters that we were doing the worng thing...
2023-02-07 11:00:53 +00:00
Richard Hughes
a6deceda32 Allow desktop software to inhibit the system to prevent all updates
On edge hardware a process may want to disable firmware updates as it might be
a bad time to allow an upgrade.
2023-01-23 13:14:23 +00:00
Richard Hughes
7a4fa63d0e Add a 'get-report-metadata' command to allow debugging metadata collection 2022-12-14 14:43:52 +00:00
Richard Hughes
09eb3fc7f6 Fix a regression when using fwuptool install-blob with FMAP firmware
Only set _NO_SEARCH when specified, and do not piggy-back on the --force
command line option.

Fixes https://github.com/fwupd/fwupd/issues/5227
2022-11-02 15:01:23 +00: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
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
088397618a Add bash-completion for BIOS settings 2022-08-11 09:52:26 -05: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
Gaël PORTAY
299b42fe96 trivial: Make meson.build indentation consistent 2022-06-21 03:27:38 -04:00
Gaël PORTAY
c73d37fc6f Revert "fu-tool: Save device state to @LOCALSTATEDIR@/lib/fwupd/state.json on actions"
This reverts commit 3143bad0f5.
2022-06-20 12:57:40 -04:00
Gaël PORTAY
97a627b54b Cache list of devices to cache directory 2022-06-20 12:57:40 -04:00
Gaël PORTAY
2cc5449ae8 trivial: Use bash-completion facilities to get arguments 2022-06-20 12:57:40 -04:00
Gaël PORTAY
d893b80bbc trivial: Fix missing bash-completion for firmware-read 2022-06-20 12:57:40 -04:00
Gaël PORTAY
c8987ab100 trivial: Allow mixing modifiers/parameters in bash-completion scripts 2022-06-20 12:57:40 -04:00
Gaël PORTAY
5bdbf0dd0a trivial: Add missing comments in bash-completion scripts
For the sake of consistency.
2022-06-20 12:57:40 -04:00
Gaël PORTAY
4b3352e2f5 trivial: Add bash-completion for device-id
The four commands `get-details`, `install`, `install-blob`, and
`firmware-plugin` use device-id as second command argument but the
fwupdtool bash completion script does not completed it yet.

This calls function `_show_device_ids` to add completion for device-id
if completion the second argument of the commands mention above.
2022-06-20 12:57:40 -04:00
Gaël PORTAY
b670404127 trivial: Fix fwupdtool bash-completion script
The commands `attach`, `detach`, `activate`, `verify-update`,
`reinstall`, and `get-updates` calls `_show_device_ids` but that
function is not defined in the fwduptool bash-completion script.

This defines the function `_show_device_ids` by reusing the function
of the name in the fwupdmgr bash-completion script.

Fixes:

	$ sudo fwupdtool attach
	                        ^-- tabulation
	bash: _show_device_ids: command not found
2022-06-20 12:57:40 -04: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
63f2e9ee28 Allow 'fwupdmgr install' to install a specified firmware version
This also moves the 'local-install' action to a new verb, although we
fall back for compatibility.

Fixes https://github.com/fwupd/fwupd/issues/4514
2022-04-12 19:53:38 +01:00
Mario Limonciello
8281e17a4b trivial: update variable reading to the method in meson 0.56 or later 2022-02-28 08:34:48 -06:00
Richard Hughes
02d8753097 Move the clear-history command to fwupdtool
This is perhaps a useful thing to do when debugging, but isn't the sort
of thing we need users to understand.
2022-01-21 15:25:05 +00:00
Richard Hughes
ffac7d6024 Merge the little-used clear-offline action into clear-results
Fixes https://github.com/fwupd/fwupd/issues/3581
2022-01-21 15:25:05 +00:00
Crag Wang
fbcc031ae4 trivial: refresh bash completion to reflect recent changes 2022-01-17 13:41:20 -06:00
Richard Hughes
f885ab6d2a Allow patching firmware files at known offsets
This allows us to replace the 'dfu-tool replace' with a much more
controlled 'fwupdtool firmware-patch' command that patches at a set of
specific offsets.

Drop in the new functionality into the existing firmware ->write()
vfuncs so that the image headers, footers and/or checksums are correct.
2022-01-05 09:51:45 +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
Mario Limonciello
6ebccf1e1e Remove support for --ignore-power by frontends
This functionality broke a number of releases ago as part of
implementing device inhibition and was just noticed now.

Instead of fixing it, the preference seems to be to remove the
functionality as it exists today as inhibitions can happen for
a number of reasons.

To still allow people to override these power warnings (such as during
development) add a new daemon configuration item that can be used.

Fixes: #3778
2021-09-21 13:13:52 -05:00
Richard Hughes
9d37e447a1 Convert the device test script to a fwupdmgr subcommand
This allows us to do a few things:

 * Remove the runtime dep on Python 3, which is tricky for ChromeOS
 * Test composite devices more efficiently, only writing once per test
 * Automatically upload signed reports for successful device tests.
2021-09-16 15:01:36 +01:00
Richard Hughes
3747e245e5 uefi-capsule: Add support for CapsuleOnDisk
Based on a patch by Ilias Apalodimas <ilias.apalodimas@linaro.org>,
many thanks.

Fixes https://github.com/fwupd/fwupd/issues/2900
2021-07-28 17:11:39 +01:00
Richard Hughes
eb215753ee trivial: Add the ability to download files using PkClient for testing 2021-07-27 15:59:17 +01:00
Richard Hughes
f0bc835769 Move all the fwupdagent code to fwupdmgr
We want to provide a lot more in JSON format in the future, and this
will reduce a lot of code duplication.

As various people are using this in the wild, the existing fwupdagent
binary just shims requests to fwupdmgr as required. We'll stop doing
this for 2.0.0 or something.
2021-07-15 20:34:07 +01:00
Richard Hughes
e65d28d817 Add a utility to resign firmware files
This can be used like this:

    fwupdtool firmware-sign firmware.cab rhughes_signed.pem rhughes.key

Test signing certificates can be generated using the example script here:
https://github.com/hughsie/libjcat/blob/master/contrib/build-certs.py although
these certificates should not be used for enterprise use.
2021-04-19 12:59:35 +01:00
Richard Hughes
52441f28a4 Allow objects to deserialize to XML
This makes a lot more sense; we can parse a firmware and export the same XML
we would use in a .builder.xml file. This allows us to two two things:

 * Check we can round trip from XML -> binary -> XML

 * Using a .builder.xml file we can check ->write() is endian safe
2021-03-15 12:07:30 +00:00
Richard Hughes
6de10e118c Allow downloading firmware from IPFS
Only a small amount of the firmware on the LVFS will be available. The user
can use --ipfs on the command line for testing, or change the system-wide
default in /etc/fwupd/daemon.conf.

The IPFS daemon and command line client will need to be installed manually.
2021-02-01 19:33:31 +00:00
Richard Hughes
f6751cd783 Allow using custom data to generate CHIDs
This is really useful when working out HwId quirk values for remote systems.

    fwupdtool export-hwids target.hwids
    vim target.hwids
    fwupdtool hwids target.hwids
2021-01-18 07:56:34 +00:00
Mario Limonciello
a7d1530385 fu-util: Add a new --no-remote-check to ignore checking for download remotes
This fixes the overloaded `--no-metadata-check` that was previously
present from being used in multiple instances.
2020-12-14 12:52:38 -06:00
Mario Limonciello
02f2cc311e Add switch-branch support to fwupdtool 2020-10-21 12:00:55 -05:00
Richard Hughes
7bcb8d4385 Export FwupdPlugin so we can convey enumerated system errors to the end user
For instance, we can tell the user that UEFI UpdateCapsule is disabled in the
system firmware, or that efivarfs is not mounted. This is much better than
creating "dummy" devices which are really just hacks around the problem because
no better API existed. THe dummy devices cause as many problems as they solve.

Plugins have to set FWUPD_PLUGIN_FLAG_USER_WARNING if a warning should be shown
to the user, and only one warning will be shown of each failure type.

It is expected that GUI clients like gnome-software and gnome-firmware would use
this API to notify the user the localized message for why firmware updates are
not being shown.

Fixes https://github.com/fwupd/fwupd/issues/2456
2020-10-13 15:56:49 +01:00
Richard Hughes
6450d0deb4 Add FwupdInstallFlags of _IGNORE_CHECKSUM, _IGNORE_VID_PID and _IGNORE_POWER
The FWUPD_INSTALL_FLAG_FORCE flag has really unclear semantics, and ignoring a
file CRC, checksum or model ID should only be done when using fwupdtool actually
debugging a plugin or firmware parser.

Use the existing --force flag when we want a "gentle nudge" like reuploading
previously processed reports.
2020-10-07 13:15:09 +01:00
Richard Hughes
5bbf013879 Add a --allow-branch-switch to fwupdmgr
This allows us to turn off the tests like version format differences and
checking for downgrades.
2020-10-07 13:15:09 +01:00
Richard Hughes
460c4b75fe Add the concept of firmware 'branches'
This allows a device to identify with different streams, for instance a Lenovo
laptop could have a coreboot firmware or a AMI firmware. The GUIDs would be the
same, but switching firmware would only be done rarely and very carefully.

Another example would be switching the Broadcom BCM57xx nework adaptors from the
vendor nonfree firmware with a signed PXE image, to the free software reverse
engineered driver with no PXE support (and thus no signed DXE) at all.

It is expected firmware would have additional metadata something like this:

    ...
    <branch>sdcc</branch>
    <description>
      <p>
        This is an alternate firmware built by the community using only free
        software tools.
      </p>
    </description>
    <requires>
      <id compare="ge" version="1.5.0">org.freedesktop.fwupd</id>
      <client>switch-branch</client>
    </requires>
    ...

Additionally, alternate branch firmware will not be returned for clients not
setting the FWUPD_FEATURE_FLAG_SWITCH_BRANCH before the GetReleases request.
2020-09-30 18:33:00 +01:00
Daniel Campello
9fbd7fe65d Allow to filter get-updates on device-id
This change allows to get available updates for a given device. This is
similar to what is done for the update and activate commands.
2020-09-28 16:43:42 -05: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
Richard Hughes
0924c93422 Do not use firmware-convert to build firmware
Copying the images from the src to the destination meant we could never set
properties on the new FuFirmware instance or subclass.
2020-09-23 15:22:31 +01:00
Richard Hughes
dd65344dde Add firmware-extract subcommand to fwupdtool 2020-09-22 12:11:38 +01:00
Richard Hughes
34f7d9d8fb Allow binding and unbinding kernel drivers 2020-09-21 20:07:54 +01:00
Richard Hughes
5c82b94322 Do not show HSI obsoleted attributes by default
When one result is obsoleted by another, then do not show the old result by
default.

Additionally hide the HSI URLs as this was designed more for GUI clients like
gnome-firmware than CLI tools such as fwupdmgr.
2020-09-14 09:58:46 -05:00
Richard Hughes
a83deb42b5 Add commands to fwupdtool for interacting with the ESP 2020-08-12 18:35:15 +01: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