Commit Graph

1770 Commits

Author SHA1 Message Date
Mario Limonciello
7db8e88d98 When PK is disabled only allow trusted payloads
Loosen the requirement of the user ID to match root for the following
actions:
* Install release
* Activate firmware

For install release action, reject CAB files not signed by LVFS
2020-10-20 15:24:08 -05:00
Richard Hughes
d7e3f09cbf trivial: Show what the device does support if the protocol match fails 2020-10-20 18:21:04 +01:00
Mario Limonciello
c3a8173a12 Show an error when a plugin is missing dependencies (Fixes: #1526)
```
$ sudo mv /usr/lib/x86_64-linux-gnu/libtss2-esys.so.0.0.0 /usr/lib/x86_64-linux-gnu/libtss2-esys.so.0.0.0.renamed
$ sudo fwupdtool get-devices --plugins=uefi
14:15:48:0735 FuEngine             cannot load: failed to open plugin /usr/local/lib/x86_64-linux-gnu/fwupd-plugins-3/libfu_plugin_uefi.so: libtss2-esys.so.0: cannot open shared object file: No such file or directory
Loading…                 [-                                      ]14:15:48:0753 FuEngine             failed to update history database: device ID b6c08fb9e5384d9d101853cc1ca20cf0ce2df2e2 was not found
Loading…                 [***************************************]
WARNING: Plugin depdendencies missing
No detected devices
```
2020-10-20 10:57:21 -05:00
Richard Hughes
43053d2a13 Do not include fullstops in the --help output
Fixes https://github.com/fwupd/fwupd/issues/2487
2020-10-19 00:43:49 +01:00
Richard Hughes
377feea500 Only show the HSI for sane chassis types
Fixes https://github.com/fwupd/fwupd/issues/2440
2020-10-18 20:24:10 +01:00
Richard Hughes
f2a3e01f96 Simplify fu_device_list_wait_for_replug() for sanity
Rather than using a recursive GMainLoop, just run a single iteration of the
mainloop every 1ms while we're waiting.

This simplifies the device lifecycle dramatically as we don't have to worry
about reentrant removals. It's also a lot simpler to debug as we know the only
way to return is the timeout elapsing or FWUPD_DEVICE_FLAG_WAIT_FOR_REPLUG being
unset.

If multiple devices got removed and we're waiting for one to re-appear, also
wait for all devices to come back before returning to the main loop.

In the worst case, this causes the device list to wait the full removal_delay
for the device rather than returning when the first device matches. This allows
us to simplify the hub update when we reboot the entire device and various
devices from different plugins come back in an unpredictable order.

Fixes the other half of https://github.com/fwupd/fwupd/issues/2376
2020-10-18 07:35:46 +01:00
Richard Hughes
84781f41cf trivial: Fix a segfault when installing without PolicyKit 2020-10-16 15:25:27 +01:00
Richard Hughes
65698015ae Do not fix up the version on post-update mismatch
We already set a update error if the fu_common_vercmp_full() fails to match,
and trying to do anything else would just be papering over the issue.
2020-10-16 14:02:10 +01:00
Daniel Campello
edab096c64 trivial: Fix build error on build=standalone and polkit=true
This fixes error introduced by 11b71f4978
2020-10-15 14:05:23 -06:00
Richard Hughes
1c62adec69 Get the list of unique branch names for 'switch-branch' 2020-10-15 18:05:29 +01:00
Richard Hughes
88fdc59330 Set _HAS_MULTIPLE_BRANCHES when release differs from device
Enable switch-branch any time a branch other than the default exists.

Based on a patch by Evan Lojewski <github@meklort.com>, many thanks.
2020-10-15 18:05:29 +01:00
Mario Limonciello
11b71f4978 Offer to compile daemon without polkit support
Based on a patch from Daniel Campello at
https://chromium-review.googlesource.com/c/chromiumos/third_party/fwupd/+/2354521
2020-10-14 07:58:16 -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
Érico Rolim
0651aeef24 Fix header names.
- <sys/poll.h> should be <poll.h>
- <sys/errno.h> should be <errno.h>
2020-10-10 12:33:56 +01:00
Richard Hughes
f4c206d319 libfwupd: Do not export the HSI AppStream IDs
The clients don't need to know this, and exporting them means we paint-ourselves
into a corner if we want to change the 'namespace' or how HSI actually works.
2020-10-08 16:36:56 +01:00
Richard Hughes
f083af3e71 Download the metadata first when using 'fwupdtool refresh'
This allows us to use fwupd_remote_load_signature_bytes() to enable all the
JCat mirror-fix features.
2020-10-07 15:38:08 +01:00
Richard Hughes
738e3f01e1 trivial: Ensure config.h is included in all C files 2020-10-07 13:46:33 +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
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
Richard Hughes
26e57dd4e2 Do not auto-detach when dumping firmware
This allows us to handle this in the plugin, which might mean detaching the
*proxy* device. It's also very important as a few plugins reboot the device
in ->attach() to get the new firmware version, which isn't required for a dump.

This partially reverts a58510b246 and does the
detach and attach in the few plugins where actually required.
2020-10-05 19:44:44 +01:00
Richard Hughes
2428147659 trivial: Show a single line for each plugin state at startup 2020-10-05 15:42:00 +01:00
Richard Hughes
9ed4d47040 trivial: Remove more debugging when disabling plugins
We already have a list of enabled and disabled plugins, don't tell the user
hundreds of times that 'optionrom is not found'.
2020-10-05 15:42:00 +01:00
Mario Limonciello
933e43005f trivial: fu-engine: don't show information for disabled remotes 2020-10-03 06:58:13 -05:00
Richard Hughes
f64e7a9cb4 trivial: Fix typo when setting _HAS_MULTIPLE_BRANCHES
Fixes https://github.com/fwupd/fwupd/issues/2439
2020-10-01 18:05:36 +01:00
Richard Hughes
521c2e2cd2 trivial: Do not print 'bare' GError strings
Give them come context so we know where they came from...
2020-10-01 16:39:10 +01:00
Richard Hughes
f4052b53f4 trivial: Do not warn about the same missing remote more than once
Removes 4 instances of 'ignoring unfound remote fwupd' at startup.
2020-10-01 16:39:10 +01:00
Richard Hughes
61a2dbad13 trivial: Do not inform if no fwupd::ReleaseFlags were set
This is never set in the AppStream metadata, and means that every call to
fu_engine_ensure_device_supported() at startup does not generate 16x debugs.

For cab archives we know if the archive was unsigned as we show the flags in
the to_string() output.
2020-10-01 16:39:10 +01:00
Richard Hughes
2d22ee2fae Remove 16 extra lines of debugging at startup
On my system I get 16 lines of 'device overwriting same name value' for the ME
device. Once we set valid metadata about a device just remove the flag to stop
scanning for every call to fu_engine_ensure_device_supported()
2020-10-01 16:39:10 +01:00
Richard Hughes
1a61258239 Allow devices to save the old firmware to disk for recovery
This would also help, for example, to go back to the nonfree firmware when the
alternate firmware did not work as well as hoped. It would also allow flashing
the firmware using an SPI programmer if everything went very wrong indeed.
2020-09-30 18:33:00 +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
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
0f89a0d2f0 Use pkttyagent to request user passwords if running without GUI
This change will allow it to use pkcon over remote-shells (ssh) or
to use it witout a running GUI desktop environment in the background.

Should fix https://github.com/fwupd/fwupd/issues/2429
2020-09-29 19:21:18 +01:00
Richard Hughes
a350198f53 Quit the replug loop on idle
If we wait for the child of a composite device to reappear and *then* go on to
update the replugged parent in the same transaction then we still use the old
GUsbDevice as the add event is still pending when we quit the replug loop.

Just schedule an idle action to quit the loop to allow the child *and* parent
to be added on replug.

Fixes https://github.com/fwupd/fwupd/issues/2376
2020-09-29 13:43:45 +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
Mario Limonciello
c53940e7d7 trivial: fu-history: don't show message on every device fetch 2020-09-28 15:58:53 -05:00
Mario Limonciello
c7cf40ebda trivial: fu-engine: simplify missing plugin errors 2020-09-28 15:58:53 -05:00
Mario Limonciello
7a3664f52b use < instead of less than 2020-09-28 15:58:53 -05:00
Mario Limonciello
4a20214183 trivial: fu-engine: don't show 0 devices with subsystem %s message 2020-09-28 15:58:53 -05:00
Mario Limonciello
67a8b89453 trivial: clean up some debugging statements 2020-09-28 15:58:53 -05:00
Richard Hughes
33dcfb7219 trivial: Remove over-eager debugging output 2020-09-28 16:43:12 +01:00
Richard Hughes
c46aa815ea trivial: Do not show the libxmlb debugging by default 2020-09-28 16:43:12 +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
Richard Hughes
6f4f1caca4 trivial: Fix some typos spotted by codespell 2020-09-24 10:48:26 +01: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
mendel5
f75ff42613 flag_require_ac: System requires external power source 2020-09-20 12:08:52 -05:00