Commit Graph

143 Commits

Author SHA1 Message Date
Mario Limonciello
e8946a74d1 fwupdtool/fwupdmgr: make return code different for get-updates with no updates
This allows other tools to depend on it when checking for updates rather than
reading the output.
2020-10-06 13:34:41 -05: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
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
88dd7c4402 Add fu_firmware_image_get_bytes
Without a 'getter' it's impossible to obtain the raw data for the image
extractor or in a image subclass that wants to add a header or CRC.
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
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
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
a1ebcbf743 trivial: Add back the hidden --plugin-whitelist option
It is essentially part of our 'CLI API' and we have to support people using the
old name.
2020-09-14 09:58:46 -05: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
Jochen Sprickerhof
25b78a6870 Check returned volumes before accessing them
Without udisks2 installed the list of volumes is empty and fwupdtool
esp-list segfaults.
2020-09-10 17:29:35 -05:00
Richard Hughes
db344d5a40 trivial: Fix several small memory leaks discovered with valgrind 2020-09-09 14:16:49 -05:00
Richard Hughes
fb6315f1c6 trivial: Show the failing remote when using 'fwupdtool refresh' 2020-09-09 14:16:49 -05:00
Richard Hughes
5976125e25 trivial: Fix two translator comment typos 2020-08-20 07:54:00 +01:00
Daniel Campello
722f532781 fwupd-remote: Download remote firmware on local remote
This changes allows for downloading firmware from a remote server
pointed from a local remote manifest.xml.gz file

Change-Id: Id00870f9c2817d48d6d301d2b6d229ba1ca6045a
2020-08-12 20:09:17 +01:00
Richard Hughes
a83deb42b5 Add commands to fwupdtool for interacting with the ESP 2020-08-12 18:35:15 +01:00
Richard Hughes
f8c10c2b11 Use --plugins for the fwupdtool argument name
This is much more obvious than --plugin-enable=foo,bar,baz ever was.
2020-07-20 22:50:31 +01:00
Mario Limonciello
eb7be16bf0 fu-util/fu-tool: Group devices in get-updates/update calls
Fixes: #1840
2020-07-03 11:58:34 -05:00
Richard Hughes
85226fd9d1 Remove potentially problematic language
Red Hat wants to drive an initiative in correcting problematic and potentially
divisive language in open source projects. These naming conventions and
descriptive phrases are hurtful and offensive to many of our colleagues across
the open source universe.

See https://www.redhat.com/en/blog/making-open-source-more-inclusive-eradicating-problematic-language
2020-06-30 17:31:17 +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
c5710d91bd Be more defensive when remotes are missing required keys
Fixes half of https://github.com/fwupd/fwupd/issues/2223
2020-06-26 12:29:08 +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
Mario Limonciello
890963108e Clarify invalid arguments display (Fixes: #2045)
Avoid a wall of text and instead direct people to `--help` output.
Also sync up this section of code between `fu-util.c` and `fu-tool.c`
2020-04-30 14:20:36 -05:00
Richard Hughes
9c09e2c9bc trivial: Fix some recent NULL/FALSE confusion 2020-04-22 10:53:59 +01:00
Mario Limonciello
c6009f59fe trivial: fu-util/fu-tool: check for '-' in arguments
Make sure if something doesn't look like a duck that it's not a duck.
2020-04-21 09:04:50 +01:00
Mario Limonciello
9917bb44bc trivial: fu-tool: correct a reference to wrong device ID when using GUID
When finding the device by GUID we need to do a lookup first.
2020-04-20 13:42:31 -05:00
Mario Limonciello
aac9c74ec6 trivial: fu-tool: correct an infinite loop from 3aaf53c6f0 2020-04-20 13:39:17 -05: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
Richard Hughes
ee562b5164 Ignore indirect devices that replug during the composite firmware update
This fixes the confusing case where installing the CCGX firmware on a dock
would reboot the hub, leading to this output:

Installing on USB-I2C Bridge…                                    ]
Installing on USB2.0 Hub…[************************************** ]
Installing on USB3.1 Hub…[************************************** ]
Installing on USB2.0 Hub…[************************************** ]
Installing on USB3.1 Hub…[************************************** ]
Installing on ThinkPad USB-C Dock Gen2 USB Audio…*************** ]
Installing on USB-I2C Bridge…*********************************** ]
Restarting device…       [***************************************]

With the patch, this is now:

Installing on USB-I2C Bridge…                                    ]
Restarting device…       [***************************************]
2020-04-07 15:04:01 +01:00
Richard Hughes
f1fa73e349 trivial: Allow using --force with install-blob 2020-04-06 14:36:46 -05:00
Filipe Laíns
b2f377a00c fu-tool: add reinstall command
Closes #1914

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
Richard Hughes
09a4f7559c Add the optional device-id to the update --help output
Fixes https://github.com/fwupd/fwupd/issues/1870
2020-03-17 13:03:16 +00:00
Richard Hughes
bca63edccf Add 'firmware-convert' subcommand to fwupdtool
This is a useful function that allows us to use all the fwupdplugin loaders.
2020-03-09 21:12:01 +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
Mario Limonciello
2a0c066a2f trivial: remove unused variables 2020-03-05 09:40:05 -06:00
Mario Limonciello
984e29ca33 fu-tool: Correctly append the release to devices in get-details
Previously the device would helpfully show nothing about the CAB
when you ran `get-details` using `fwupdtool`.
2020-02-26 08:47:43 -06:00
Mario Limonciello
dc0608dea4 For the get-details command make sure to always show devices
This was likely an existing bug; but if running `get-details` on a CAB
for a device not in your system it would be filtered by default device
filters.
2020-02-26 08:47:43 -06:00
Mario Limonciello
dc9a1a8512 trivial: fwupdtool: fix tree title
The title isn't initialized until the engine is started, so don't
try to read it too early.
2020-02-20 14:31:14 -06:00
Mario Limonciello
27164b70b6 Discard the reason upgrades aren't available (Fixes: #1678)
Also fixes: #1792
2020-02-20 09:40:52 -06:00
Richard Hughes
4959baa65b Add 'refresh' to fwupdtool
This actually makes 'get-updates' do something useful when using the flatpak.
2020-01-17 16:33:07 +00:00
Richard Hughes
fd7e994971 Add 'get-remotes' to fwupdtool 2020-01-17 16:33:07 +00:00
Richard Hughes
429f72b214 Fix display of UTF-8 characters on Windows 2020-01-16 12:23:08 -06:00
Mario Limonciello
234c864ea4 trivial: fu-util/fu-tool: Unify usage of - and _ in help output (Fixes: #1662) 2020-01-08 20:07:29 -06:00
Richard Hughes
0ef47201eb Set the FwupdDevice parents in fwupdtool
This requires splitting out a helper function as a new symbol so it can be used
without fwupd_device_array_from_variant().
2020-01-06 15:16:48 +00:00
Mario Limonciello
7e4949c4f8 Clarify error messages when no upgrades available 2019-12-09 10:45:49 -06:00