Commit Graph

256 Commits

Author SHA1 Message Date
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
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
Richard Hughes
603e4f6956 Shut down automatically when there is system memory pressure
We can just rescan hardware if required; near OOM it's just more important to
free what we can and get out of the way.
2020-01-07 12:29:07 +00:00
Richard Hughes
668ee21567 trivial: Use prefixes for DATADIR in config.h for portability
DATADIR is an enumerated type in MinGW, and the other names are very generic.
2019-11-24 14:17:38 -06:00
Mario Limonciello
eb4c76416c Add a new property Interactive to the daemon
Clients can use this as a hint whether the daemon is running on
a terminal.

`fwupdmgr` uses this to bypass the systemd service check.
2019-11-11 11:16:21 -06:00
Richard Hughes
0917fb6aec Export the salted machine ID as a daemon property 2019-09-23 17:34:47 +01:00
Mario Limonciello
20cc9eebc5 Try to only show DMI product name once
* libfwupd: export new property HostProduct
* clients: Use this property for setting the title of trees

Before:
```
○
├─XPS 13 7390 TPM 2.0:
│     Device ID:           c56e9f77cfee65151bdef90310776f9d62827f5a
│     Summary:             Platform TPM device
│     Current version:     7.2.1.0
│     Vendor:              Dell Inc.
│     Update Error:        Updating disabled due to TPM ownership
│     Flags:               internal|require-ac|registered
└─XPS 13 7390 System Firmware:
      Device ID:           b6c08fb9e5384d9d101853cc1ca20cf0ce2df2e2
      Current version:     0.1.1.1
      Minimum Version:     0.1.1.1
      Vendor:              Dell Inc.
      Flags:               internal|updatable|require-ac|registered|needs-reboot

```

After:
```
XPS 13 7390
│
├─TPM 2.0:
│     Device ID:           c56e9f77cfee65151bdef90310776f9d62827f5a
│     Summary:             Platform TPM device
│     Current version:     7.2.1.0
│     Vendor:              Dell Inc.
│     Update Error:        Updating disabled due to TPM ownership
│     Flags:               internal|require-ac|registered
└─System Firmware:
      Device ID:           b6c08fb9e5384d9d101853cc1ca20cf0ce2df2e2
      Current version:     0.1.1.1
      Minimum Version:     0.1.1.1
      Vendor:              Dell Inc.
      Flags:               internal|updatable|require-ac|registered|needs-reboot
```
2019-09-05 11:22:39 -05:00
Richard Hughes
3d00522dd3 Check if the system is offline during install, rather than at startup
This splits out the systemd functionality to a new file, but makes no other
logic changes.
2019-05-18 08:02:29 -07:00
Mario Limonciello
bfcf75b7a6 Allow fwupdmgr to modify the daemon config
This allows several things, for instance:

 * Adding or removing blacklisted plugins or devices
 * Changing the idle timeout where allowed

...without a user needing to manually modify a configuration file.
2019-04-17 12:12:13 -04:00
Richard Hughes
f3dc1621bc Shut down the daemon if the on-disk binary is replaced
If we update fwupd 'live' rather than from an ostree or offline update then
kill the running instance unless a firmware update is ongoing.

When users update fwupd at runtime they often forget to restart the fwupd daemon
and say that the update didn't fix it when actually they using the the old code.
2019-03-27 09:54:06 -04:00
Richard Hughes
86923b95e9 trivial: Fix CI failure by using the correct enum type 2019-03-23 13:57:51 +00:00
Richard Hughes
f517c9aa09 Allow running offline updates when in system-update.target 2019-03-23 10:45:52 +00:00
Richard Hughes
8356a83c4a trivial: Fix potential critical when converting empty object to GVariant 2019-03-21 17:15:43 +00:00
Richard Hughes
3d60762bed Add a D-Bus method to generate a signature using the self-signed client certificate 2019-03-11 13:57:39 +00:00
Richard Hughes
c8cc77c1c2 trivial: Add FuEngineLoadFlags argument to fu_engine_load()
No functionality changes, but allows us to do something new in the future.
2019-03-07 08:28:36 -06:00
Richard Hughes
8dd4c1c4dd Allow restricting firmware updates for enterprise use 2019-03-05 19:05:07 +00:00
Mario Limonciello
96a0dd5606 Add a support for delayed activation
This is intended for devices that it is not safe to immediately activate
the firmware.  It may be called at a more convenient time instead.

Both fwupdmgr and fwupdtool support the feature.

- if called at runtime with fwupdmgr it uses the daemon
- during shutdown fwupdtool uses the pending.db to perform this feature.
2019-02-27 09:04:54 +00:00
Mario Limonciello
7a3df4bb07 fu-tool: Show UpdateMessage if applicable for install command
When calling with a CAB as an install argument, this needs to be
manually populated since the release won't be built.
2019-01-31 13:54:01 -06:00
Mario Limonciello
51ddf18faa When generating a CAB Silo use the prefix "components"
This makes fu_engine_get_details use a more standard prefix.
2019-01-28 09:52:37 +00:00
Richard Hughes
f425d29a28 Show a console warning if loading an out-of-tree plugin
Fixes https://github.com/hughsie/fwupd/issues/950
2019-01-19 07:26:20 +00:00
Mario Limonciello
46bb4e91a0 fu-main: remove incompatible locale error message
Downgrade this to debugging instead. (Fixes: #912)
2019-01-08 11:03:50 +00:00
Richard Hughes
8be03791c7 Log an error if started with an incompatible locale
Test with `LC_ALL=de_DE.UTF-8 ./src/fwupd`
2018-12-26 06:28:30 -06:00
Richard Hughes
75b965d01d Shut down the daemon after 2h of inactivity
Plugins are allowed to 'opt-out' of this behaviour using _RULE_INHIBITS_IDLE.
This should be used where waking up the hardware to coldplug is expensive,
either from a power consumption point of view, or if other artifacts are going
to be seem -- for instance if the screen flickers when probing display devices.

This functionality is also inhibited when the actual upgrade is happening,
for obvious reasons.

Admins can turn off this auto-sleep behaviour by editing the daemon.conf file.

Fixes https://github.com/hughsie/fwupd/issues/417
2018-11-21 18:54:44 +00:00
Richard Hughes
481aa2a923 Port from libappstream-glib to libxmlb
The libxmlb library is much faster to query, and does not require the daemon
to parse the XML metadata at startup. It's a zero-copy mmap design that is more
modern and less clunky.

RSS has reduced from 3Mb (peak 3.61Mb) to 1Mb (peak 1.07Mb) and the startup
time has gone from 280ms to 250ms.
2018-10-17 14:41:13 +01:00
Mario Limonciello
6754f5aa70 fu-main: Catch SIGTERM while update is in progress
This prevents systemd from stopping while a firmware update is in
progress.
2018-10-16 13:06:23 -05:00
Mario Limonciello
2dd731b2f0 Update all sub-devices for a composite update
This allows a frontend to call update on an individual device ID which will
cause a CAB file to be downloaded, but then also re-use the same CAB file to
try to process devices with a relationship as part of a transaction.
2018-10-10 11:24:27 -05:00
Richard Hughes
34fcc02052 trivial: Fix a tiny memory leak on startup
The property value is a floating reference, and so if we're not using it as a
parameter to g_variant_new() we need to unref it manually.
2018-09-19 18:17:38 +01:00
Richard Hughes
e671c05771 trivial: Do not use AsProfile
The profiling data is of limited use, and better data can be obtained using
kcachegrind and massif. Additionally, the profile samples were the cause of the
small RSS growth over time, when in reality the data would only be shown when
the verbose switch is used at daemon startup.
2018-09-18 06:23:25 -05:00
Richard Hughes
b08e7bc7aa trivial: Set a log domain for each file
This allows us to do something like:

G_MESSAGES_DEBUG=FuEngine ./src/fwupd
2018-09-11 18:59:05 +01:00
Richard Hughes
83cce1bdfa trivial: Fix a NULL/FALSE confusion 2018-09-10 16:42:30 +01:00
Richard Hughes
ebae396d0a udev: Do not add devices after a small delay
Now devices can have multiple GUIDs and do not share platform IDs there is
really no point waiting to add the device.

This allows us to remove a whole lot of code for this now-unused functionality.
2018-09-09 16:24:30 +01:00
Mario Limonciello
e3016602f8 Include serial number in daemon device output when trusted
This moves the storing of the serial number into the daemon and
when the calling process is UID 0 includes it in device output
2018-09-06 13:34:28 -05: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
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
51308e648a Adjust all licensing to LGPL 2.1+ (Closes: #526) 2018-05-29 09:03:13 +01:00
Richard Hughes
e82eef3190 trivial: Move the install error heuristic into common code 2018-05-21 21:23:45 +01:00
Richard Hughes
c02cb83d20 trivial: Split out fu_install_task_compare() for future use 2018-05-21 21:23:45 +01:00
Richard Hughes
1d1f5cf098 trivial: Refactor the requirement tests to use a FuInstallTask 2018-05-21 21:23:45 +01:00
Richard Hughes
5b5f655e0b trivial: Allow the daemon to run without any idle sources
We need this if we want to run plugins without a daemon process.
2018-05-18 10:22:39 +01:00
Richard Hughes
76e0f94c86 Allow the client tools to avoid writing the history database 2018-05-14 18:54:15 +01:00
Richard Hughes
9f86ade6bf Allow plugins to define the order composite firmwares are installed 2018-05-12 20:46:02 +01:00
Richard Hughes
4ad41f027c Allow installing more than one firmware using 'fwupdmgr install'
When using failed to open firmware.cab we pass in a device ID of '*' which
tells the daemon to update anything that matches. The current implementation
will fail in two ways:

* If duplicate hardware is installed (for instance two Unifying receivers) then
  only the first matching device will be updated.

* If the firmware archive contains two different images then we only try and
  upgrade the first device that matches. This means we're unable to update
  composite devices using one firmware file.

To fix both issues, carefully build a list of tasks that can be processed using
the given firmware and installed devices, request authentication using all the
different action IDs, then upgrade all the devices one-at-a-time.

Based on a patch by Mario Limonciello <mario.limonciello@dell.com>, many thanks.
2018-05-10 09:26:07 +01:00
Mario Limonciello
6b9f07cbf7 trivial: fix a null pointer dereference
../src/fu-main.c: In function ‘fu_main_daemon_method_call’:
../src/fu-main.c:667:47: error: null pointer dereference [-Werror=null-dereference]
   polkit_authority_check_authorization (helper->priv->authority, subject,
                                         ~~~~~~^~~~~~
../src/fu-main.c:698:47: error: null pointer dereference [-Werror=null-dereference]
   polkit_authority_check_authorization (helper->priv->authority, subject,
                                         ~~~~~~^~~~~~
2018-04-17 10:10:43 +01:00
Mario Limonciello
a98df55d82 Disable -Wunused-function on clang builds (Closes #467)
GLib creates two static inline functions for paramaters that may
not be used that set off warnings in clang but not gcc.

Ignore these on clang builds everywhere that
G_DEFINE_AUTOPTR_CLEANUP_FUNC is used.
2018-04-17 10:10:43 +01:00
Richard Hughes
747b9eeef2 trivial: Fix a small memory leak if parsing the .xml file fails 2018-04-16 16:47:07 +01:00
Richard Hughes
6b22295cf0 Add a D-Bus method to modify a historical device
This allows us to set specific flags on the device stored in the database.
2018-01-11 10:20:48 +00:00
Richard Hughes
476363ac19 Add a D-Bus method to get the history information 2018-01-11 10:08:58 +00:00
Richard Hughes
c7bbbc246b Allow specifying the maximum archive size in the daemon config 2018-01-03 07:38:27 +00:00
Richard Hughes
f3d46c6b03 trivial: Include the remote name if it failed to be updated 2017-11-28 14:14:39 +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