Commit Graph

224 Commits

Author SHA1 Message Date
Richard Hughes
170c0c13c3 trivial: Route the ::added and ::removed through the FuDeviceList
This will allow the list to withhold events in the future, no functional changes now.
2017-11-24 14:42:27 +00:00
Richard Hughes
0a7e783cdd trivial: Move the device list to a new object
This moves more functionality out of the engine, and will allow us to add some
cleverness to the device list to allow the FuDevice to be shared between
different plugins.
2017-11-24 14:42:27 +00:00
Richard Hughes
e7e95452fd trivial: Move the plugin list to a new object
FuEngine is getting somewhat large and complicated, so split out as much plugin
list-specific functionality as possible
2017-11-24 14:42:27 +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
175635b916 trivial: Move assigning a GError for future code 2017-11-22 14:26:49 +00:00
Richard Hughes
e89ab5976f Partially revert the FuDevice weak reference detection
This causes problems for future patchsets that re-populate the FuDeviceItem.
2017-11-22 14:26:49 +00:00
Richard Hughes
43f9dd8c40 Sort the output of GetUpgrades correctly
This allows clients to just select the 'first' FwupdRelease for the newest if
there are multiple installable releases.

Fixes https://github.com/hughsie/fwupd/issues/319
2017-11-16 15:24:47 +00:00
Richard Hughes
b6f79556f1 Use a SHA1 hash for the internal DeviceID
It's actually less scary to see a SHA1 hash than it is to see a path like
/sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.2. It's also way easier to
copy and paste into the various fwupdmgr command that require a device ID and
also means we can match a partial prefix much like git allows.

If we also move to a model where plugins can be changed during different stages
of the update (e.g. during detach) then the device might change connection type
and then the sysfs path not only becomes difficult to paste, but incorrect.

Session software doesn't care about the format of the device ID (it is supposed
to be an implementation detail) and so there's no API or ABI break here. A few
plugins also needed to be ported, but nothing too worrying.
2017-11-16 07:18:36 +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
1cf88d6775 Detect if a plugin incorrectly unrefs the FuDevice
Watch the FuDevice in the FuDeviceItem with a weak reference and try to recover
without crashing the daemon if the plugin does the wrong thing.
2017-11-08 11:02:38 +00:00
Richard Hughes
2ec78d68db Add support for HWID requirements
In the latest version of the LVFS you can restrict the firmware to a specific
machine type, for instance a specific baseboard vendor. This is the same as
done in Microsoft Update using the CHID mechanism.

This commit adds support for the <hardware> requires type, although it needs to
be built against appstream-glib 0.7.4 to be supported and/or tested.
2017-11-03 23:42:57 +00:00
Richard Hughes
74a80ccc50 dell: Use the new quirk infrastructure for version numbers 2017-11-02 19:08:51 +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
cc70f193e9 trivial: Use the new API in libappstream-glib directly 2017-10-09 21:00:26 +01:00
Richard Hughes
4eada34d4c trivial: Fix up introspection issues in the daemon code 2017-10-05 10:32:05 +01:00
Richard Hughes
642ec13754 trivial: Remove GetUpdates as it is no longer used 2017-09-28 09:23:52 +01:00
Richard Hughes
603e42d527 trivial: Include the releases as part of the device a{sv} array 2017-09-28 09:23:52 +01:00
Richard Hughes
80893e29fe trivial: Remove FwupdResult from libfwupd 2017-09-28 09:23:52 +01:00
Richard Hughes
07f963a52d trivial: Remove the deprecated fwupd_client_get_details()
Also, rename fwupd_client_get_details_local() to it's now-removed counterpart.
2017-09-28 09:23:52 +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
f2eccdee5c trivial: Fix a tiny memory leak when getting the upgrades list 2017-09-20 11:18:03 +01:00
Richard Hughes
10bd8ecfb8 trivial: Remove EnableOptionROM from daemon.conf
The exact same thing can be done using BlacklistPlugins=udev
2017-09-19 20:06:44 +01:00
Richard Hughes
b0aa379300 Use a fallback SYSCONFDIR if the default is not set 2017-09-19 20:06:44 +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
7769fb8da7 trivial: Add some more FuEngine self tests 2017-09-18 11:12:52 +01:00
Richard Hughes
c07ac39ad1 trivial: Return a better error for keyring set up failure 2017-09-17 09:33:53 +01:00
Richard Hughes
84bf038a52 trivial: Do not log to the journal when calling GetDetails 2017-09-16 18:52:51 +01:00
Richard Hughes
820dac7fde trivial: Use a different SYSFSFIRMWAREDIR for self tests
This means we can drop some self-test specific code in fu_smbios_setup().
2017-09-16 17:46:41 +01:00
Richard Hughes
068d34307a Do not fail to load the daemon if cached metadata is invalid
Fixes: https://github.com/hughsie/fwupd/issues/257
2017-09-16 08:26:46 +01:00
Richard Hughes
93b1576bef trivial: Add helpers that can be used for returning local files
This also allows us to drop the use of FwupdResult in the daemon.
2017-09-15 14:12:18 +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
e7fd8eb81f trivial: Simplify the check for supported devices 2017-09-15 14:12:18 +01:00
Richard Hughes
a96413a368 Add a method to return a list of upgrades for a specific device 2017-09-15 14:12:18 +01:00
Richard Hughes
97284b1ad8 Move the downgrade calculation to the daemon 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
b3ca245b74 Move the release trust information to FwupdRelease
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 latter, as you could have a .cab file with multiple versions of the
firmware and only the first being signed.
2017-09-15 11:31:01 +01:00
Richard Hughes
d140210b4f trivial: Fix up the hex version numbers when adding to the store
This means we show the 'human readable' version numbers in the debug UI.
2017-09-14 10:26:15 +01:00
Richard Hughes
bd4d2856dd Merge releases where multiple remotes provide the same firmware
For a few months the lvfs-testing remote has not included firmware already
present in the stable lvfs remote. This means if you enable the testing remote
then components in the stable remote are not available to fwupd.

Instead of a simplistic check on the component ID, add the missing releases
no matter the ordering of the remotes.
2017-09-14 10:26:15 +01:00
Richard Hughes
fc0d170334 trivial: Show the available release versions in the daemon debug output
Also, truncate the output when there are lots of versions available.
2017-09-14 10:26:15 +01:00
Richard Hughes
225f3a98fe trivial: Sort the releases returned by GetReleases() 2017-09-13 19:38:51 +01:00
Richard Hughes
30dbf0d7d0 Remove the UniqueID property
This was only ever added for gnome-software, and is too inflexible for anything
else. It turns out we don't even need it in GNOME, as we can construct a
suitable ID ourselves using the existing values.

It was also ambiguous whether the unique ID was in reference to the device
or release -- and for gnome-software we need both.
2017-09-13 15:28:33 +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
d2b4fc5e00 trivial: Set the AppStream ID when returning results from GetReleases
We need this for GUI software.
2017-09-12 16:42:46 +01:00
Richard Hughes
a6bd5580d3 Add ModifyRemote as an easy way to enable and disable remotes like the LVFS
For example:

    $ fwupdmgr modify-remote lvfs-testing Enabled true
2017-09-07 23:02:58 +01:00
Richard Hughes
1941c44559 Do not auto-open all USB devices at startup
Fixes: https://github.com/hughsie/fwupd/issues/220
2017-09-07 19:00:51 +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
Yehezkel Bernat
e43f7fb655 trivial: cleanup for many compilation warnings from clang
Signed-off-by: Yehezkel Bernat <yehezkel.bernat@intel.com>
2017-08-30 10:43:15 +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
c6afb51e32 Add a FirmwareBaseURI parameter to the remote configs
This allows somebody to mirror the CDN without resigning the metadata files.

Fixes: https://github.com/hughsie/fwupd/issues/186
2017-08-23 14:22:12 +01:00
Richard Hughes
adcc16a53c trivial: Check for zero size firmware image 2017-08-21 12:26:46 +01:00
Richard Hughes
14047d7d24 trivial: Split up the keyring setup and public key adding 2017-08-18 11:10:03 +01:00
Richard Hughes
f69a4810fa Return the authority and timestamp as part of the signing validation
This means we return an error when encountering a rollback attack. This can
currently be performed by providing the old metadata and old signature when
calling into UpdateMetadata.
2017-08-17 16:15:47 +01:00
Richard Hughes
556ec355db trivial: Fix getting the keyring for PKCS7-enabled remotes
Found using Coverity, thanks.
2017-08-16 13:42:10 +01:00
Richard Hughes
99e621d388 Save the metadata signature in the local cache
This is useful if the admin wants to re-verify the metadata, or if a public
key is removed or expires.
2017-08-16 13:42:10 +01:00
Richard Hughes
b9ad09ca93 trivial: Correctly search for the .cab detached signature 2017-08-15 15:35:47 +01:00
Richard Hughes
7403dc505f Optionally use GnuTLS to verify PKCS7 certificates
We can use this as an alternative for GPG. No PKCS7 certificates are currently
installed by fwupd and it's expected that the LVFS will still only provide GPG
detached signatures.

If an OEM distributor wants to sign firmware with a PKCS7 and the corresponding
certificate is provided then the firmware will be marked as valid.

Only firmware shipping with a .p7b file will use the PKCS7 functionality,
similarly remote metadata validation will default to GPG unless Keyring=pkcs7
is specified in the config file.
2017-08-14 09:42:48 +01:00
Richard Hughes
0724d8bde0 trivial: Bump the appstream-glib requirement to 0.6.13 2017-08-09 17:21:48 +01:00
Richard Hughes
41cbe2aab3 Add a firmware builder
This runs a script inside the firmware archive to generate firmware specific to
the machine. This uses bubblewrap to protect the local machine.
2017-08-09 10:33:39 +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
1ad45caeec Use new GUsb functionality to fix flashing Unifying devices
This avoids open()ing and close()ing multiple times on hotplug -- which in
itself isn't a huge problem as the requests are refcounted in libusb, but it
matters hugely when a plugin accidentally closes a device that was not opened.

As all the devices are going to be opened anyway (to read the vendor strings)
and the cost of keeping the device is open is tiny, just get libgusb to
auto-open *all* devices and keep them open for the duration.

Fixes: https://github.com/hughsie/fwupd/issues/155
2017-07-24 11:08:25 +01:00
Richard Hughes
535664cd1e Run the plugin coldplug methods in a predictable order
When reading with g_dir_read_name() the returned files do not have to be sorted
in any particular order and could even change between invokation. This patch
makes debugging the interactions between plugins much easier.
2017-07-24 10:32:06 +01:00
Mario Limonciello
c29b398ad0 trivial: fix various spelling errors 2017-07-17 13:07:05 -05:00
Mario Limonciello
5735fd67c1 trivial: set engine back to idle
A regression from 9945edbe74 causes
a missing newline for many actions because it doesn't go back to idle
2017-07-13 16:22:19 -05:00
Mario Limonciello
790701f32b trivial: adjust get-details and get-devices output Display Name output
This returns them back to the more readable 0.8.x behavior where
devices have the name first and then all the details indented.
2017-07-13 16:22:19 -05:00
Richard Hughes
32684f2344 Check all the device GUIDs against the blacklist when added
To the user it's not obvious which is the default GUID.

See https://github.com/hughsie/fwupd/issues/127
2017-07-13 09:32:26 +01:00
Mario Limonciello
dc8c985159 trivial: back the requirement on appstream-glib to 0.6.9
The items that 0.6.13 requires are now guarded by a version test.
This should allow running fwupd master on more distros that haven't
yet picked up appstream-glib 0.6.13.
2017-07-10 14:32:42 -05:00
Richard Hughes
ed34991bd8 Do not unlock devices when doing VerifyUpdate
We used to do this dance to avoid reading the Option ROM on hardware by default
(some faulty hardware would crash...) but now we're doing the verify update in
the daemon there's no need to split this into two steps.

Fixes: https://github.com/hughsie/fwupd/issues/149
2017-06-22 10:37:10 +01:00
Richard Hughes
b9bddfd7ac trivial: Ensure the verify component is replaced on veriy-update, not merged 2017-06-22 10:34:18 +01:00
Richard Hughes
08f12de44c trivial: Avoid warning when doing verify-update multiple times
Applications always need a valid source with newer appstream-glib versions;
even in this case where the source is the hardware itself.
2017-06-22 10:33:32 +01:00
Richard Hughes
22c88de8e4 trivial: Increase the warning level when a plugin adds a device twice 2017-06-22 09:36:32 +01:00
Richard Hughes
943d2c9bb5 trivial: Split out some common functionality from fu-engine.c 2017-06-21 09:04:39 +01:00
Richard Hughes
a5bb4d8428 trivial: Fix a missing signal causing a warning in the recent refactor 2017-06-19 20:22:25 +01:00
Richard Hughes
9945edbe74 Split up the daemon into the loader and an engine object
The idea here is that we move a lot of the 'meat' out of fu-main into the
engine. This also lets us simplify a lot of things and ensures the user
authentication is simple and easy to audit.
2017-06-19 13:50:38 +01:00