Commit Graph

838 Commits

Author SHA1 Message Date
Richard Hughes
5ef0ae182d Add a 'name' attribute to each FuProgress step
This allows us to print better warning strings, and in the future
would allow us to profile each operation in a meaningful way.

Also, add context to some of the progress steps as required.
2022-06-01 15:05:43 +01:00
Gaël PORTAY
41cbf8aa18 progress: Inherit status from parent 2022-05-27 11:19:51 -04:00
Richard Hughes
a78f660363 Emit a critical warning when duplicating private flags 2022-05-26 11:55:32 +01:00
Richard Hughes
6c93fe8b13 trivial: Fix a tiny leak when reading archives 2022-05-26 11:49:47 +01:00
Richard Hughes
67c77d7ec1 trivial: Fix a gtk-doc warning on build 2022-05-25 09:02:50 +01:00
Richard Hughes
2319f19306 Allow a plugin to only use the RemoveDelay when waiting for replug
Only opt-in plugins that have been tested -- unconditionally enabling
this may cause regressions on devices like docks.

Fixes https://github.com/fwupd/fwupd/issues/4378
2022-05-24 19:52:04 +01:00
Richard Hughes
4df0d2176b trivial: Fix docstring for fu_archive_write() 2022-05-22 11:28:25 +01:00
Gaël PORTAY
f862b8c9f3 trivial: Fix typos 2022-05-21 13:49:36 -04:00
Gaël PORTAY
f64783a75b trivial: Rename local that is not related to firmware 2022-05-21 13:49:36 -04:00
Gaël PORTAY
e6b01cbb18 archive: Add writing support 2022-05-21 08:21:55 -04:00
Richard Hughes
8ebad4ea75 Specify an enumerated problem when inhibiting devices
This allows us to make smarter policy decisions in the future on when
to show unavailable updates. It also means we can show translated
text in the frond-end clients.

Only problems the user can "fix" are enumerated. For example, opening
the laptop lid, or charging the device battery.
2022-05-19 13:09:03 -05:00
Gaël PORTAY
d7ffd821ff bluetooth: Set version if REV has been set 2022-05-18 02:23:59 -04:00
Richard Hughes
679628c091 Move the battery attributes down into libfwupd
This allows us to show the current value and the threshold on the CLI
and in tools like gnome-firmware.
2022-05-18 07:16:07 +01:00
Richard Hughes
f06061701c Allow setting the quirk ID from the quirk entry
Allow the admin to override the inhibit(s) on devices using a similar
format to the other kvs. For instance, setting two different quirks and
clearing another could be done using:

Quirk = usb-blocked:Device defective,needs-reboot:Reboot system,not-authorized:

This also allows unsetting the quirk, which was impossible before as
`@value` was always non-NULL.
2022-05-17 16:54:01 +01:00
Richard Hughes
c0a668ab18 Allow the device to pause the polling when writing firmware 2022-05-10 18:51:17 +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
Richard Hughes
517dc88f4f trivial: Fix the win32 CI tests 2022-05-06 13:55:51 +01:00
Richard Hughes
5031ea2c6b trivial: Fix introspection warning when building docs 2022-05-06 08:38:01 +01:00
Richard Hughes
f6c6e98786 trivial: Include header needed for GetLastError() 2022-05-02 12:36:28 +01:00
Richard Hughes
2fcdf352df Retry the device ioctl for EAGAIN 2022-04-29 15:01:32 +01:00
Richard Hughes
beb49d7ac0 trivial: Add fu_common_read_uint24() helper for future code 2022-04-28 14:18:30 +01:00
Richard Hughes
855ece352d Check the alignment when reading in raw firmware 2022-04-28 14:15:49 +01:00
Richard Hughes
3553336eff trivial: Don't print a critical warning in fu_common_sum8_bytes()
If the size if zero, the buffer may be NULL.

Fixes: https://oss-fuzz.com/testcase-detail/5453386322935808
2022-04-28 07:24:00 +01:00
Richard Hughes
f3ec632492 trivial: Add some new helper API for future functionality 2022-04-26 14:30:28 +01:00
Richard Hughes
492563d5f2 trivial: Ignore the return value of g_strlcpy() when safe 2022-04-23 10:30:50 +01:00
Richard Hughes
a1517e4875 dfu: Use the correct icon automatically for USB webcams 2022-04-23 08:56:58 +01:00
Richard Hughes
519110b70e Support firmware with uSWID header version 2
This allows multiple coSWID objects to be saved into a uSWID firmware,
and adds support for Zlib compressed payloads.
2022-04-18 17:48:52 +01:00
Richard Hughes
2d5186622c Add FuProgress to ->prepare and ->cleanup
Some plugins were creating local versions (which were not attached to
the daemon progress in any way) as a workaround as they needed to do
actions that took a long time to complete.
2022-04-15 16:50:06 +01:00
Richard Hughes
a8497ad5c2 trivial: Allow invalidating backends when subsystems change 2022-04-15 16:49:48 +01:00
Richard Hughes
58fd419fb8 Do not clear the instance-id hash during ->setup()
Some plugins rely on adding more instance IDs after the device has been
added.
2022-04-15 06:49:51 +01:00
Richard Hughes
0b7af7d54b trivial: Ignore the return value of setenv() in most cases
This makes Coverity happy.
2022-04-13 15:08:12 +01:00
Richard Hughes
0d7d8b3240 trivial: Always call va_end() even in the error path 2022-04-13 15:08:12 +01:00
Richard Hughes
2883b577dc trivial: Fix a potential OOB write that can't actually happen 2022-04-13 15:08:12 +01:00
Mario Limonciello
65e3bc57c5 trivial: fix a logic error in obsolete calculation 2022-04-12 12:23:16 -05:00
Mario Limonciello
3006d238d6 Automatically obsolete negative duplicate attributes
To a user there is no point to explicitly showing two failures for
encrypted RAM if the system supports SME and TSME both.

To show them a single failure, de-duplicate the attributes by appstream
ID during depsolve.

If the plugin didn't explicitly set obsoletes and two attributes are both
failures and both share the same appstream ID obsolete one of them.
2022-04-12 11:59:49 -05:00
Richard Hughes
f4fb625fba Set the context automatically when setting the device proxy 2022-04-11 15:36:13 +01:00
Sergii Dmytruk
4795ab3122 trivial: libfwupd,libfwupdplugin: fix typos in several comments
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
2022-04-11 15:31:03 +01:00
Richard Hughes
633571fa99 trivial: Fix some 'Comparison of narrow type with wide type in loop condition' 2022-04-05 14:45:42 +01:00
Richard Hughes
91e9f359c3 Add a plugin for the CH341A device 2022-04-03 16:29:30 +01:00
Mario Limonciello
55af9a8238 trivial: return an error string rather than HSI number for missing data 2022-04-03 09:06:00 -05:00
Richard Hughes
18f3b927e0 Add some default size values to the CFI device 2022-04-01 19:35:36 +01:00
Richard Hughes
f042bbd42c Add fu_common_reverse_uint8() for future functionality 2022-03-31 16:34:27 +01:00
Richard Hughes
356bd2fa5e Use the CFI manufacturer ID to set the vendor 2022-03-31 15:44:54 +01:00
Richard Hughes
ea9dd851af trivial: Add a missing possible CFI quirk key 2022-03-31 15:44:54 +01:00
Richard Hughes
dcd39d80a7 Add the CFI quirks in setup() so the device can be open 2022-03-31 12:47:13 +01:00
Richard Hughes
b3e1b74d21 trivial: Use the proxy physical ID automatically 2022-03-31 09:59:33 +01:00
Richard Hughes
691166d203 trivial: Use a short string form for the CFI commands 2022-03-30 18:45:49 +01:00
Richard Hughes
04f00e8a17 trivial: Never return the invalid value from fu_progress_get_percentage() 2022-03-30 18:42:01 +01:00
Richard Hughes
16edfd345e Correctly probe USB-2 hubs with more than 7 ports
See https://github.com/fwupd/fwupd/pull/4426#discussion_r836155609
2022-03-30 07:09:26 +01:00
Richard Hughes
5817ef3b4f Emit 0% in FuProgress to show the child has started
This prevents showing the 'old' percentage until the first sub-task has
completed for some device firmware updates.
2022-03-29 20:04:26 +01:00
Richard Hughes
c1ff3e67af trivial: Fix a small memory leak when getting the udev parent 2022-03-25 21:12:53 +00:00
Richard Hughes
41bc319331 trivial: Fix -Wundef warning when compiling without libcbor 2022-03-18 10:38:12 +00:00
Richard Hughes
da37d93eb0 trivial: Remove some long dead docs about fu_plugin_device_add_delay() 2022-03-16 09:18:29 +00:00
Richard Hughes
8b62bf6b64 Set the context in the right place more often 2022-03-16 09:18:29 +00:00
Richard Hughes
945002f7a3 Fix build for MacOS
This is more for curiosity than anything else.
2022-03-15 14:37:28 +00:00
Richard Hughes
92515d193a Add coSWID and uSWID parsers to libfwupdplugin
These parse the structures as defined in:

 * https://datatracker.ietf.org/doc/draft-ietf-sacm-coswid/
 * https://github.com/hughsie/python-uswid
2022-03-15 14:37:02 +00:00
Richard Hughes
6b5d933e99 Do not show unconnected or unreachable devices in the client tools
Fixes https://github.com/fwupd/fwupd/issues/4378
2022-03-15 14:08:17 +00:00
Richard Hughes
e8f0d76da7 Do not leak child processes when cancelling
See https://github.com/fwupd/fwupd/pull/4372
2022-03-15 14:01:45 +00:00
Richard Hughes
b4e88bae49 trivial: Move the UNREACHABLE inhibit to common code 2022-03-15 11:29:00 +00:00
Daniel Campello
61226b49f3 fwupdplugin-self-test: fix spawn tests for qemu
Wrap the spawned script with an explicit call to the /bin/sh
interpreter needed when running tests in a cross compiled enviroment.

Also increase the timeout for the spawned script to execute to give
enough time for the print to happen in the much slower virtualized
environment.

Change-Id: I71ed377e1bc8db4be4c522cdb9562c1662df7266
2022-03-09 17:32:40 -07:00
Richard Hughes
66cb93c4e2 trivial: Make clear sizes are in hex 2022-03-07 12:38:33 +00:00
Richard Hughes
94d572375f trivial: Clarify the unit for the device remove delay 2022-03-03 11:26:17 +00:00
Richard Hughes
c4ca026294 Allow devices to build instance IDs more easily
Provide a device instance builder that allows plugins to easily
create multiple instance IDs based on parent attributes.

Also fix a lot of the instance ID orders, so that we add more generic
IDs first, and more specific IDs after.
2022-03-03 09:13:29 +00:00
Mario Limonciello
d04f2468c0 trivial: switch from path to full_path for meson 0.56+ 2022-02-28 08:34:48 -06:00
Mario Limonciello
6896e0ab52 trivial: switch from meson.source_root to meson.project_source_root
The former is deprecated in meson 0.56 or later.
2022-02-28 08:34:48 -06:00
Mario Limonciello
661990ed98 Convert build system to use meson tristate features
tristate features will automatically disable if dependencies marked
as required are missing.

Packagers can manually override using `auto_features`.

Link: https://mesonbuild.com/Build-options.html#features
2022-02-28 08:34:48 -06:00
Daniel Campello
bcaeda34ad Backfill SHA256 when generating metadata from cab files
This change allows for the computation of SHA256 checksum when
generating metadata from cabinet file. This is particularly used when
working with the directory type of remote config.

Change-Id: I1a6e90a76b79cdae97d68d799a5cea81430da03f
2022-02-25 10:31:03 +00:00
Richard Hughes
adfef91731 trivial: Strip leading and trailing spaces from the vendor name 2022-02-24 17:07:44 +00:00
Richard Hughes
e3583793ed trivial: Fix two potential critical warnings when finding devices 2022-02-24 17:07:32 +00:00
Richard Hughes
f3a13f89dd Allow specifing the DeviceIntegrity flag from metadata 2022-02-22 19:12:06 +00:00
Richard Hughes
758d5d8c6f Add a flag to indicate the device is signed or unsigned
Devices without either flag are unknown.
2022-02-22 19:12:06 +00:00
Richard Hughes
7ef94d7a31 vli: Skip probing the Dell DA300 device
Although 2109:2820 and 2109:0820 is the generic reference firmware,
firmware revision 3003 is specific to this device.

Fixes https://github.com/fwupd/fwupd/issues/4305
2022-02-22 17:22:13 +00:00
Richard Hughes
e21391f85d trivial: Don't warn if the superclass is using custom flags 2022-02-22 13:28:48 +00:00
Richard Hughes
4cd8468722 trivial: Don't warn if overwriting with the same device name 2022-02-22 13:28:48 +00:00
Richard Hughes
bd02edcc43 trivial: Add missing API wrapper for future functionality 2022-02-21 18:57:20 +00:00
Richard Hughes
308e03a6f4 Sanitize the instance ID parts more carefully
The only users of `SERIO\FWID` and `I2C\NAME` are already 'safe' and
the device GUIDs should all be unchanged.

There are no current users of the `MTD\NAME` instance IDs, and these
are the ones that may be more unpredictable and in need of sanity.
2022-02-18 08:23:39 +00:00
Richard Hughes
eb6ba4eafb trivial: Show the firmware GType in the device ->to_string() 2022-02-17 06:15:30 +00:00
Richard Hughes
f63080fbe2 Allow assigning issues to devices
This allows us to show in the tools if a device is currently affected
by a specific CVE. For instance, we could inform the user that a device
requires a critical firmware update that is being actively exploited.

Note, this also means we can show the user a firmware update is now
required, even though the firmware may not be available on the LVFS.

Also show the issue in the `fwupdmgr security` output, e.g.

    There are devices with issues:
      Samsung — MZVLB2T0HALB-000L7:
       • CVE-2022-12345
       • CVE-2022-54321
2022-02-16 14:50:29 +00:00
Richard Hughes
c71ca76235 Add a plugin to set GPIOs for the duration of an update 2022-02-16 14:01:07 +00:00
Richard Hughes
55bd4862d3 Try harder to convert to a version into a correct semver
This is really useful for the flashrom plugin.
2022-02-11 15:28:05 +00:00
Richard Hughes
171ebda355 Check the IFD sections have non-zero data length
This fixes a critical warning when loading an invalid builder file.
2022-02-09 13:31:55 +00:00
Richard Hughes
8cec5d8686 Allow padding firmware sections in builder XML files 2022-02-09 13:31:55 +00:00
Richard Hughes
2448660922 trivial: Print the RemoveDelay in the device debug string 2022-02-07 14:21:01 +00:00
Richard Hughes
24c041c3f8 trivial: Fix the range check for the RemoveDelay quirk 2022-02-07 14:21:01 +00:00
Richard Hughes
2fd4ea5ddc Get the SMBIOS table on Windows
Fixes https://github.com/fwupd/fwupd/issues/4253
2022-02-07 14:04:44 +00:00
Richard Hughes
75b68ed9f9 trivial: Allow NULL @error for fu_device_retry_full()
The docs say `(nullable)` and it's the only function that seems to hard require
an error, for no good reason I can see.
2022-02-01 16:18:28 +00:00
Richard Hughes
6f87fc5ee3 trivial: Fix 'fwupdtool firmware-sign' by removing debugging 2022-01-31 10:57:10 +00:00
Richard Hughes
b9960095b8 trivial: Fix the FreeBSD build
Mea culpa. Fixes https://github.com/fwupd/fwupd/issues/4225
2022-01-27 20:35:41 +00:00
Richard Hughes
f966dfe251 Fall back to the Device Tree 'compatible' data as required
This allows us to use CHID requirements on the PinePhone, and
potentially other hardware too.

See https://github.com/fwupd/fwupd/discussions/4209
2022-01-24 21:30:15 +00:00
Richard Hughes
38bab8fc4f Allow overriding daemon parameters using /var/etc/fwupd/daemon.conf
This is super useful for debugging immutable systems like ChromeOS.
2022-01-21 11:52:06 +00:00
Crag Wang
b728608baa Show results when calling get-details if failing requirements 2022-01-19 12:10:52 +00:00
Richard Hughes
ca43733a8c Show why devices are not marked as updatable
At the moment a lot of the failures are only visible when running the
daemon in verbose mode, and the inhibit functionalit provides us a way
to unset FWUPD_DEVICE_FLAG_UPDATABLE from multiple places, as well as
setting the update error for the user to see why.
2022-01-13 12:40:56 +00:00
Richard Hughes
45673e7d9f trivial: Show results when using FWUPD_XMLB_VERBOSE 2022-01-12 16:16:52 +00:00
Richard Hughes
1ef67c60ca Only accept GUIDs when calling fu_quirks_lookup_by_id()
The only place we were using the instance ID -> GUID conversion was in
the self tests, and assuming the group is always a GUID removes a lot
of checks from a very hot path at startup.
2022-01-12 16:16:52 +00:00
Richard Hughes
c74c0ab655 trivial: Fix builds with -Dgusb=false 2022-01-11 09:40:57 +00:00
Richard Hughes
dbdb207561 Increase the chances of success of WAIT_FOR_REPLUG on WIN32
Decrease the GUsb polling interval when any of the devices is in
`WAIT_FOR_REPLUG` on when running on Windows. Any device that can
re-enumerate much faster than the default 1000ms may be missed and the
detach may fail.

Linux doesn't have this problem as it has `LIBUSB_CAP_HAS_HOTPLUG`.
2022-01-06 13:20:34 -06:00
Richard Hughes
25b1813069 trivial: Fix up some clang-format issues that snuck in recently 2022-01-06 17:04:34 +00:00
Richard Hughes
e70f2df7f7 trivial: Fix some recently added gtk-doc markup 2022-01-05 09:51:45 +00: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
1c62194dd3 trivial: Fix fu_common_dump_full() header when specifying both flags 2022-01-04 22:06:33 +00:00