Commit Graph

138 Commits

Author SHA1 Message Date
Richard Hughes
1bf7ff9966 trivial: Fix a debugging typo 2018-08-24 20:21:51 +01:00
Richard Hughes
8fe7cddc74 trivial: Add helper function for getting an integer quirk value 2018-08-23 10:09:45 +01:00
Mario Limonciello
e3b1a3f558 Plumb through support to set FwupdInstallFlags for update_prepare/update_cleanup
This will be used by other future commits.
2018-08-21 13:49:38 -05:00
Richard Hughes
128c0160b3 Only add new device children
This prevents horrible things happening when different plugins provide the
parent and child, and the child gets added before the parent.

Alternative to https://github.com/hughsie/fwupd/pull/645
2018-08-10 09:21:06 -05:00
Richard Hughes
68f12ddb44 trivial: Do not define _GNU_SOURCE
It prevents coverity from running with gcc7.
2018-08-09 16:59:04 +01:00
Richard Hughes
02c90d8a03 Remove the unused Emacs indenting headers from all source files
Fixes https://github.com/hughsie/fwupd/issues/636
2018-08-09 12:48:04 +01:00
Richard Hughes
69a5f3587b trivial: Allow plugins to get the list of HWIDs 2018-08-08 14:44:47 +01:00
Richard Hughes
81c427ca6d Allow different plugins to add the same device
In this instance, we define the 'same device' to be a FuDevice that has at
least one matching GUID. We allow the plugins to define which one is 'better'
than other plugins, and use this to only have one FuDevice for the physical
device.

Alternative to https://github.com/hughsie/fwupd/pull/604
2018-08-06 21:58:28 -05:00
Richard Hughes
87fb9ff447 Change the quirk file structure to be more efficient
This pivots the data storage so that the group is used as the preconditon
and the key name is used as the parameter to change. This allows a more natural
data flow, where a new device needs one new group and a few few keys, rather
than multiple groups, each with one key.

This also allows us to remove the key globbing when matching the version format
which is often a source of confusion.

Whilst changing all the quirk files, change the key prefixes to be more familiar
to Windows users (e.g. Hwid -> Smbios, and FuUsbDevice -> DeviceInstanceId)
who have to use the same IDs in Windows Update.

This also allows us to pre-match the desired plugin, rather than calling the
probe() function on each plugin.
2018-06-28 13:32:30 +01:00
Richard Hughes
5f3a56b0fa Add fu_plugin_has_rule()
This allows us to check if a specific name exists for a given rule type.
2018-06-28 12:13:59 +01:00
Mario Limonciello
4910b244d1 trivial: Do not notify plugins for their "own" device registrations 2018-06-24 07:18:04 +01:00
Richard Hughes
dbd8c76eb8 Run a plugin vfunc before and after all the composite devices are updated
Now we can update multiple devices (in multiple plugins) using one firmware
archive we need a way to cleanup after all the plugins have been run.

Fixes https://github.com/hughsie/fwupd/issues/561
2018-06-18 16:06:15 +01:00
Mario Limonciello
3f9a1c182a Clean up plugins as the last step of engine cleanup (Closes: #550)
Fixes a segfault that occurs during cleanup of USB plugins.

When g_module_close was called memory allocated by the plugin would
get freed leading to the finalize method for object class pointing
to garbage.
2018-06-06 14:39:03 -05:00
Richard Hughes
4be17d1364 Add support for relocating various runtime paths
This allows a snap package to be easily built.

With much help from Mario Limonciello <mario.limonciello@dell.com>, many thanks.
2018-05-31 16:25:22 +01:00
Mario Limonciello
51308e648a Adjust all licensing to LGPL 2.1+ (Closes: #526) 2018-05-29 09:03:13 +01:00
Richard Hughes
8c71a3f2e9 Add a get-plugins command to fwupdtool
This returns the list of currently enabled plugins.
2018-05-22 16:03:14 -05:00
Richard Hughes
026cdd8c17 trivial: Do not crash if trying to do fu_engine_install_blob() as OFFLINE 2018-05-18 10:23:19 +01:00
Richard Hughes
1e456bcd39 Do not call fu_plugin_init() on blacklisted plugins
Fixes https://github.com/hughsie/fwupd/issues/503
2018-05-11 07:26:17 -05:00
Richard Hughes
5e447293fa Add the concept of logical mappings between different devices
This allows us to find out the logical parent device, for instance in composite
devices with more than one firmware image for a single device.

We also allow lazily specifying the device parent using a GUID and the engine
then automatically sets the parent object when the GUIDs match, which allows
children and parents to exist in different plugins.
2018-05-03 08:07:04 +01:00
Richard Hughes
34e0dab1f1 Add fu_plugin_add_compile_version()
This allows plugins to set and explicit build-time version. It also uses the
same AppStream component-ID scheme rather than the home-grown 'FooVersion' key.

Also, use the new runtime and compile-time versions in the report metadata.
Due to the key change we'll also need to update some LVFS rules.
2018-04-20 20:45:08 +01:00
Richard Hughes
b01b4869bb trivial: Use fu_plugin_add_runtime_version() in the Dell plugin 2018-04-20 20:45:08 +01:00
Richard Hughes
275d3b4f0f trivial: Fix a tiny memory leak introduced in the last commit 2018-04-20 20:45:08 +01:00
Richard Hughes
0eb123b986 Allow requiring specific versions of libraries for firmware updates
In some cases firmware can only be installed with an up to date GUsb (e.g. with
some STM-DFU hardware) or with a new version of fwupdate (e.g. any UEFI
UpdateCapsule without a capsule header).

We should be able to match against other software versions like we can the
fwupd version, e.g.

    <requires>
      <id compare="ge" version="0.9.2">org.freedesktop.fwupd</id>
      <id compare="ge" version="11">com.redhat.fwupdate</id>
    </requires>

Also, rather than checking each requirement we know about on the component,
check each requirement on the component about things we know. This ensures we
don't allow firmware to be installs that requires for instance fwupdate 22 when
the runtime version is only being added in fwupdate 12 and up.

This means the following is now an error that will fail to allow the firmware
to be installed:

    <requires>
      <firmware>doesnotexist</firmware>
      <some_future_tag>also_unknown</some_future_tag>
    </requires>

Also add a lot of self tests to test the various new failure modes.

Fixes https://github.com/hughsie/fwupd/issues/463
2018-04-20 16:19:05 +01:00
Mario Limonciello
963dc4245c
uefi: Allow overriding ESP mount point via conf file (Fixes: #421) (#422)
* uefi: Allow overriding ESP mount point via conf file (Fixes: #421)
2018-02-27 14:26:58 -06:00
Richard Hughes
c0cd023d31 Be more careful deleting and modifying device history
If this happens:

1.2.3 -> 1.2.4 = failure
1.2.3 -> 1.2.5 = success

...we want to preserve both in the history database so they can both be shared
with the LVFS. Use the device ID and the new and old firmware versions when
modifying and deleting entries.

This fix is made slightly more tricky as we have to drop the PRIMARY KEY
attribute on the device_id, and due to a limitation in SQLite, it means copying
the old history into a new table.
2018-02-07 10:20:19 +00:00
Richard Hughes
65e44cac96 Always return useful information when calling GetResults()
Previous to having the history database we could only notify about firmware that
as installed using the uefi plugin, as that had a few system-wide API calls to
say 'this update failed' or 'this was the error'.

Now we have the local history database not only can we report more details about
the UEFI update (e.g. the old version number) but we can also offer the same
functionality for all other plugins.

Although this does rework how the data for GetResults() is populated, it does
make the FuEngine object quite a lot less confused.

It also fixes a warning in the fwupd plugin for gnome-software, which was
expecting the FwupdRelease to be populated for the FwupdDevice.
2018-02-07 10:20:19 +00:00
Richard Hughes
38fb56cab1 trivial: Ensure the pending firmware has the new version set correctly
This is only important if the pending update fails to be scheduled, and then
we need the new version for the history database.
2018-02-01 22:18:45 +00:00
Richard Hughes
41c1548674 trivial: Add some trivial debugging for my sanity 2018-02-01 22:17:26 +00:00
Richard Hughes
83e54e46ab trivial: Don't include the device-id in the plugin error string
It's not needed, or desired in the history database.
2018-02-01 14:01:39 +00:00
Richard Hughes
6b0e5c4f21 Fix a daemon warning when using fwupdmgr get-results
The FwupdRelease needs to be manually added in some circumstances.
2018-01-28 21:51:41 +00:00
Richard Hughes
2de8f13b2c Allow each plugin to opt-in to the recoldplug action
Recoldplug is really not required for the USB based plugins, and we should
restrict this action to plugins that have inter-dependencies on each other.
2018-01-17 20:19:58 +00:00
Richard Hughes
d949d961e8 trivial: Pass the device-id to the fu_history_set_X() methods
This allows us to use a FwupdDevice or just use a string for testing.
2018-01-12 16:50:24 +00:00
Richard Hughes
0b9d996d4d trivial: Rename some methods in FuHistory to reflect the device-centric nature 2018-01-12 16:50:24 +00:00
Richard Hughes
780ef3f2ba trivial: Use 'history' for the FuHistory object name 2018-01-12 16:20:31 +00:00
Richard Hughes
80b79bb9aa trivial: Allow plugins to add metadata to the uploaded reports 2018-01-11 21:28:22 +00:00
Richard Hughes
bc3a4e1f57 Store firmware update success and failure to a local database
Rename FuPending to FuHistory to better represent what the object is now doing.
Also, while we're here, switch to using SQLite prepared statements to avoid a
possible invalid read on i386 hardware.
2018-01-11 09:59:34 +00:00
Richard Hughes
3e90a58096 trivial: Do not hardcode the update state in fu_pending_add_device() 2018-01-11 08:16:33 +00:00
Richard Hughes
696e6fdcf3 trivial: Don't allow deleting the pending database
If we're going to use this for history we have to be a little more subtle.
2018-01-11 08:16:25 +00:00
Richard Hughes
639da4776b trivial: Allow calling all FuPlugin runners from the self tests 2018-01-06 22:44:24 +00:00
Richard Hughes
5060246526 trivial: Move the USB quirks from FuPlugin to FuUsbDevice
Also rename some general USB quirks that are not specific to any one plugin.
2017-12-11 10:47:18 +00:00
Richard Hughes
725c19fa88 Add a quirk for setting the USB device vendor 2017-12-08 19:36:09 +00:00
Richard Hughes
e755d6bb05 Add a more general quirk for adding GUIDs to devices
This replaces fwupd-dfu-alternate-vidpid which was only useful in the DFU plugin
and somewhat poorly defined.
2017-12-04 17:00:22 +00:00
Richard Hughes
23135eb1c9 trivial: Remove the now-unused fu_plugin_set_status() 2017-12-04 17:00:22 +00:00
Richard Hughes
4591bdacbf Add quirks to set common USB properties
The name, summary and icon are not strictly required for a USB device
supporting both DFU interfaces, but having this extra data makes GNOME Software
look much nicer. Using the quirks feature means we can merge in support for new
devices after fwupd has been released for stable distros.
2017-11-27 18:07:53 +00:00
Richard Hughes
104f651132 Add a fu_plugin_usb_device_added() dedicated vfunc
This saves all the USB plugins from connecting to the context and managing the
device lifecycle and allows devices that uses FuUsbDevice to be removed
automatically.

This makes supported plugins *much* smaller indeed.
2017-11-24 16:13:44 +00:00
Richard Hughes
3483410076 Look up the FuPlugin from the FuDevice each time it is used 2017-11-24 14:42:27 +00:00
Richard Hughes
9c4b531945 trivial: Use fu_plugin_runner_device_generic() for unlock() 2017-11-14 11:34:53 +00:00
Richard Hughes
d3d96ccbb2 trivial: Allow running generic vfuncs in the tests without a GModule
This makes it easier to set up test harness in the daemon self tests.
2017-11-14 11:34:33 +00:00
Richard Hughes
0d7fdb3110 Split out the update detach and attach phases as explicit optional vfuncs
This allows us to do two things:

* Attach after a failed update, so the user isn't left with 'dead' hardware
* Split the detach and attach actions into different plugins in the future

This also allows us to have a separate vfunc to get the new version number
after flashing the firmware, as this may be handled in a different plugin to
the detach phase.
2017-11-14 10:49:43 +00:00
Richard Hughes
9c028f06b5 Move the database of supported devices out into runtime loaded files
When fwupd is installed in long-term support distros it's very hard to backport
new versions as new hardware is released.

There are several reasons why we can't just include the mapping and quirk
information in the AppStream metadata:

 * The extra data is hugely specific to the installed fwupd plugin versions
 * The device-id is per-device, and the mapping is usually per-plugin
 * Often the information is needed before the FuDevice is created
 * There are security implications in allowing plugins to handle new devices

The idea with quirks is that the end user can drop an additional (or replace
an existing) file in a .d director with a simple format and the hardware will
magically start working. This assumes no new quirks are required, as this would
obviously need code changes, but allows us to get most existing devices working
in an easy way without the user compiling anything.

This allows us to fix issues like https://github.com/hughsie/fwupd/issues/265
2017-11-02 19:08:51 +00:00
Richard Hughes
4eada34d4c trivial: Fix up introspection issues in the daemon code 2017-10-05 10:32:05 +01:00
Richard Hughes
08a37992f9 Allow plugins to depend on each other
The only things that plugins can declare is that they should be run before,
after or never with regard to another plugin.
2017-09-21 17:09:06 +01:00
Richard Hughes
1354ea9cd8 Add fu_plugin_check_supported()
This allows a plugin to see if a GUID is supported in the AppStream metadata of
configured remotes. It allows plugins to skip devices that are not supported
and that do bad things when probed.
2017-09-19 16:00:45 +01:00
Richard Hughes
0dec274e56 Fix a crash when using fu_plugin_device_add_delay()
By removing the device from the hash table before we add it to the devices
array we could inadvertently drop the last object reference if the plugin is
not using the (optional) cache.

Just re-arrange things to fix https://github.com/hughsie/fwupd/issues/259
2017-09-18 11:08:27 +01:00
Richard Hughes
cc3de2efa4 Do not store the newest release as part of the FuDevice object 2017-09-15 14:12:18 +01:00
Richard Hughes
68982c6624 Make FuDevice derive from FwupdDevice rather than FwupdResult
We're aiming for a model where devices can have multiple releases and we can
nuke FwupdResult completely.
2017-09-15 14:12:18 +01:00
Richard Hughes
9dde04fbda trivial: Split out some functionality not to be used by plugins 2017-09-13 14:59:32 +01:00
Richard Hughes
a1aab517d1 Move the update state to FwupdDevice
It only remained on FwupdResult because I couldn't make up my mind about whether
it was a property of the device, or the firmware release. It's more logically
the former, and that's how plugins are using it.
2017-09-13 14:59:32 +01:00
Richard Hughes
49e5e05aa8 Parse the SMBIOS DMI table directly
The Linux DMI class still does not provide the information we need, and parsing
the blob directly also allows the Dell and Redfish plugins to get the raw data.
2017-09-05 18:10:36 +01:00
Richard Hughes
a785a1c2f6 Remove the confusing ALLOW_OFFLINE and ALLOW_ONLINE flags
Over the months the original meaning of ALLOW_OFFLINE and ALLOW_ONLINE have be
lost, and there is now a confusing mixture of uses in the source tree. With this
commit we make it clear the UPDATABLE flag is used to specify when the device is
updatable (e.g. from the desktop live session, or from the systemd offline
updates mode, or both) and the NEEDS_REBOOT flag lets us know when the update
is actually going to be done.

For instance, a UEFI UpdateCapsule can be *scheduled* from either the desktop
or from the update mode (but the latter would be a bit weird), but does require
a reboot. Some devices might only be updatable outside the live session, for
instance a hard drive update or a GPU update -- there's just too much going on
with a live session and we want to tightly control what's running during the
firmware flash.

This also means we don't have to "retry" the update when scheduling an update
that really can be scheduled whenever, but just requires a reboot to apply.
2017-08-26 18:09:21 +01:00
Richard Hughes
e1fd34d5f1 Allow plugins to set metadata on devices created by other plugins
This could be used, for instance, to set a property on ThunderBolt controllers
inside Dell computers saying that they support forcing the power level during
coldplug. It could also be used to set the dock type for the synapticsmst hub.

Adding this level of complexity allows us to avoid the creep of HAVE_DELL and
HAVE_LENOVO into seemingly unrelated plugins, and also allows us to have
multiple vendor plugins providing the same end result with two different
vendor-specific mechanisms.
2017-08-24 16:15:11 +01:00
Richard Hughes
7ef96b8a4e trivial: Fix up a few NULL/FALSE mismatches 2017-08-23 18:28:24 +01:00
Richard Hughes
d7704d4cc2 Allow plugins to get DMI data from the hardware in a safe way
The returned strings are converted to ASCII and have leading and trailing
spaces removed.
2017-08-09 10:19:13 +01:00
Richard Hughes
3cca1c65c2 trivial: Remove or downgrade some superfluous warnings
Fixes bugs like https://github.com/hughsie/fwupd/issues/159
2017-07-21 13:38:27 +01:00
Richard Hughes
e8b5db66f4 Fix a hang on 32 bit computers
It turns out using a string hash for a pointer object doesn't always work...
2017-07-17 14:18:29 +01:00
Richard Hughes
ababbb7ae1 trivial: Clear any device checksums before doing device::verify 2017-06-15 20:19:23 +01:00
Richard Hughes
f556d371da trivial: Clear any device checksums after the online update 2017-06-15 20:19:19 +01:00
Richard Hughes
68cc00c7e9 Allow multiple checksums on devices and releases
Although we supported other hashes than SHA1 (which is now moderately unsafe)
we had to switch the metadata provider and daemon on some kind of flag day to
using SHA256. Since that's somewhat impractical, just allow multiple checksums
to be set on objects and just try to match whatever is given in preference
order.

This also means we can easily transition to other hash types in the future.

The removed API was never present in a tarball release, so not an API break.
2017-06-06 20:06:53 +01:00
Richard Hughes
1642b3b95a Deprecate the old FwupdResult API
It will be removed next time we bump soname.
2017-06-05 17:41:11 +01:00
Richard Hughes
b8f8db2082 Add support for Microsoft HardwareIDs
This commit provides a new "hwids" subcommand for fwupdmgr that shows the
hardware GUIDs on the local system. It also provides API that plugins can use
to self-disable when a specific HWID does not match.

The GUIDs used in this implementation match that of ComputerHardwareIds.exe
2017-06-04 19:46:36 +01:00
Mario Limonciello
6d0aa3dcf7 trivial: make valgrind an optional build dependency
Packagers should still enable it so that tracking lost memory
in plugins is possible, but on some distros some archs don't
have valgrind available which would otherwise prevent fwupd
from running.

This is as problem currently for Debian unstable where some
archs valgrind fails to compile.
2017-02-28 08:22:27 -06:00
Richard Hughes
576c012d20 Do not dlclose modules when running under valgrind
Without this patch, unloading the module means we can't resolve the symbols
where the memory was leaked.
2017-02-24 09:47:00 +00:00
Richard Hughes
6ad951d27c trivial: Do not allow plugins to call _device_add_delay() with the same device
Also, add some unit tests for this codepath.
2017-02-03 10:12:14 +00:00
Richard Hughes
f0a799eabf Only register the D-Bus service when all devices have been added
Poll each plugin, and only register the service when all the delayed coldplug
devices have been added to the device list. This prevents returning an error
when calling "fwupdmgr get-devices" for the very first time.

Resolves: https://github.com/hughsie/fwupd/issues/82
2017-01-18 08:10:32 +00:00
Richard Hughes
ccd78a9703 trivial: Add some sanity guards in plugin-calling functions 2017-01-11 16:57:41 +00:00
Richard Hughes
44dee88ad6 trivial: Protect against multiple uses of fu_plugin_alloc_data() in a plugin 2017-01-11 08:31:10 +00:00
Richard Hughes
57d18229a1 trivial: Add some more documentation for functions used by plugins 2017-01-10 16:09:32 +00:00
Richard Hughes
4190178f94 trivial: Remove the unused fu_plugin_set_name() 2017-01-10 16:09:32 +00:00
Richard Hughes
b082903c5f Add fu_plugin_set_coldplug_delay() to allow hardware to initialize if required 2017-01-10 09:27:08 +00:00
Richard Hughes
362d6d7d7d Allow plugins to request that all plugins re-coldplug
This allows a plugin to signal the daemon that something has happened and that
all plugins should wake up connected devices, re-add them all and then put the
devices back to powersave mode. Any duplicate devices will be ignored.
2017-01-07 21:42:17 +00:00
Richard Hughes
46487c944a Add the ability to run a prepare->exec->cleanup on coldplug
The idea here is that plugins can 'wake up' hardware in prepare, and put it
back into powersaving mode when doing cleanup.
2017-01-07 21:26:36 +00:00
Richard Hughes
d4184cf2c6 trivial: Fix a crash when a Unifying USB device is quickly replugged
We need to remove the device from the delayed hash table to ensure we don't
accidently free the helper when it removed a *second* time.
2016-12-21 16:05:19 +00:00
Richard Hughes
ae3d65f60b Move the device add delay to shared code
This allows us to reuse the logic in other plugins.
2016-12-16 12:41:57 +00:00
Richard Hughes
7b8b202786 Add a set of vfuncs that are run before and after a device update 2016-12-12 16:15:03 +00:00
Richard Hughes
cff38bcb3a Convert the providers to plugins to simplify code and for future features
This is a large commit that removes all the providers and turns them into
plugins. I think having both providers _and_ plugins was super confusing.

Plugins are loaded at runtime so you could in theory develop a new plugin
without putting it in the fwupd source tree, although there are no installed
headers or PC files as I'm not sure it's a good idea at this stage.

This commit moves all the per-provider docs, tests, notes, debug dumps and test
data to plugin-specific directories -- these also allows the plugin author to
"own" more of the source tree so we don't enforce fu- prefixes and the style
guide everywhere.

This allows us to run the same action on all the plugins in the future, so we
could have a prepare(FuPlugin, FuDevice) and cleanup(FuPlugin, FuDevice) run
on *all* plugins, so doing an update using one plugin would allow us to work
around hardware quirks in other plugins.

If I've broken your out-of-tree provider it's trivial to port to the new API
with sed and a fixed up build file. If you need help please let me know.
2016-12-12 12:31:23 +00:00
Richard Hughes
bc93e4ab6e Make all providers and plugins share a GUsbContext
This means we don't have more that one thread just watching for the USB
hotplug events. To achieve this split up the coldplug into setup and coldplug
phases and run the enumerate just once in the daemon.
2016-12-08 19:51:55 +00:00
Richard Hughes
ce38d94d5e trivial: Get rid of useless internal-only gtk-doc markup 2016-06-29 11:25:25 +01:00
Richard Hughes
d090514f15 Add a simple plugin infrastructure
This allows vendors to write small self-contained modules that can be used to
override the default behaviour in the various providers.
2016-03-13 09:52:55 +00:00