libfwupd: Restore recognizing gpg and pkcs7 types still

The snap-store intends to ship an updated libfwupd library but
to use it with whatever version daemon is on the host system.

This means that the library needs to still work with older metadata
signing types.

This fixes the following error in that scenario:
```Failed to update metadata for lvfs: Keyring kind jcat not supported```
This commit is contained in:
Mario Limonciello 2020-11-20 16:09:15 -06:00 committed by Mario Limonciello
parent 23f9cca6b4
commit 2f49da7f4e
3 changed files with 22 additions and 11 deletions

View File

@ -1,6 +1,6 @@
[fwupd Remote] [fwupd Remote]
Enabled=true Enabled=true
Type=download Type=download
Keyring=gpg Keyring=jcat
MetadataURI=https://s3.amazonaws.com/lvfsbucket/downloads/firmware.xml.gz MetadataURI=https://s3.amazonaws.com/lvfsbucket/downloads/firmware.xml.gz
FirmwareBaseURI=https://my.fancy.cdn/ FirmwareBaseURI=https://my.fancy.cdn/

View File

@ -1,5 +1,5 @@
[fwupd Remote] [fwupd Remote]
Enabled=true Enabled=true
Type=download Type=download
Keyring=gpg Keyring=jcat
MetadataURI=https://s3.amazonaws.com/lvfsbucket/downloads/firmware.xml.gz MetadataURI=https://s3.amazonaws.com/lvfsbucket/downloads/firmware.xml.gz

View File

@ -154,6 +154,18 @@ fwupd_remote_set_filename_source (FwupdRemote *self, const gchar *filename_sourc
priv->filename_source = g_strdup (filename_source); priv->filename_source = g_strdup (filename_source);
} }
static const gchar *
fwupd_remote_get_suffix_for_keyring_kind (FwupdKeyringKind keyring_kind)
{
if (keyring_kind == FWUPD_KEYRING_KIND_JCAT)
return ".jcat";
if (keyring_kind == FWUPD_KEYRING_KIND_GPG)
return ".asc";
if (keyring_kind == FWUPD_KEYRING_KIND_PKCS7)
return ".p7b";
return NULL;
}
static CURLU * static CURLU *
fwupd_remote_build_uri (FwupdRemote *self, const gchar *url, GError **error) fwupd_remote_build_uri (FwupdRemote *self, const gchar *url, GError **error)
{ {
@ -224,13 +236,15 @@ static void
fwupd_remote_set_metadata_uri (FwupdRemote *self, const gchar *metadata_uri) fwupd_remote_set_metadata_uri (FwupdRemote *self, const gchar *metadata_uri)
{ {
FwupdRemotePrivate *priv = GET_PRIVATE (self); FwupdRemotePrivate *priv = GET_PRIVATE (self);
const gchar *suffix;
/* save this so we can export the object as a GVariant */ /* save this so we can export the object as a GVariant */
priv->metadata_uri = g_strdup (metadata_uri); priv->metadata_uri = g_strdup (metadata_uri);
/* generate the signature URI too */ /* generate the signature URI too */
if (priv->keyring_kind == FWUPD_KEYRING_KIND_JCAT) suffix = fwupd_remote_get_suffix_for_keyring_kind (priv->keyring_kind);
priv->metadata_uri_sig = g_strconcat (metadata_uri, ".jcat", NULL); if (suffix != NULL)
priv->metadata_uri_sig = g_strconcat (metadata_uri, suffix, NULL);
} }
/* note, this has to be set after MetadataURI */ /* note, this has to be set after MetadataURI */
@ -303,6 +317,7 @@ static void
fwupd_remote_set_filename_cache (FwupdRemote *self, const gchar *filename) fwupd_remote_set_filename_cache (FwupdRemote *self, const gchar *filename)
{ {
FwupdRemotePrivate *priv = GET_PRIVATE (self); FwupdRemotePrivate *priv = GET_PRIVATE (self);
const gchar *suffix;
g_return_if_fail (FWUPD_IS_REMOTE (self)); g_return_if_fail (FWUPD_IS_REMOTE (self));
@ -310,9 +325,10 @@ fwupd_remote_set_filename_cache (FwupdRemote *self, const gchar *filename)
priv->filename_cache = g_strdup (filename); priv->filename_cache = g_strdup (filename);
/* create for all remote types */ /* create for all remote types */
if (priv->keyring_kind == FWUPD_KEYRING_KIND_JCAT) { suffix = fwupd_remote_get_suffix_for_keyring_kind (priv->keyring_kind);
if (suffix != NULL) {
g_free (priv->filename_cache_sig); g_free (priv->filename_cache_sig);
priv->filename_cache_sig = g_strconcat (filename, ".jcat", NULL); priv->filename_cache_sig = g_strconcat (filename, suffix, NULL);
} }
} }
@ -377,11 +393,6 @@ fwupd_remote_load_from_filename (FwupdRemote *self,
keyring_kind); keyring_kind);
return FALSE; return FALSE;
} }
if (priv->keyring_kind == FWUPD_KEYRING_KIND_GPG ||
priv->keyring_kind == FWUPD_KEYRING_KIND_PKCS7) {
g_debug ("converting Keyring value to Jcat");
priv->keyring_kind = FWUPD_KEYRING_KIND_JCAT;
}
} }
/* all remotes need a URI, even if it's file:// to the cache */ /* all remotes need a URI, even if it's file:// to the cache */