From: Philip Withnall Date: Tue, 4 Aug 2026 15:49:43 +0000 (+0100) Subject: ostree-repo: Add a new ostree_repo_verify_local_summary() API X-Git-Tag: archive/raspbian/2026.4-1+rpi1^2~9^2~1^2~1^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8eac67e4d74d06098dd1509bed7d44013878c4b8;p=ostree.git ostree-repo: Add a new ostree_repo_verify_local_summary() API This will be used in the following commit to add signature verification to `ostree summary` when used to view the summary of a local repository. It needs to be separate from `ostree_repo_verify_summary()`, as that API expects to take a remote name and use the keyring for that remote. As far as I can tell there isn’t a way to use an arbitrary GPG homedir to verify a summary file, as is needed when running on the OSTree server rather than on a client checkout. Signed-off-by: Philip Withnall --- diff --git a/Makefile-libostree.am b/Makefile-libostree.am index cffad416..af6a2854 100644 --- a/Makefile-libostree.am +++ b/Makefile-libostree.am @@ -178,7 +178,7 @@ symbol_files = $(top_srcdir)/src/libostree/libostree-released.sym # Uncomment this include when adding new development symbols. #if BUILDOPT_IS_DEVEL_BUILD -#symbol_files += $(top_srcdir)/src/libostree/libostree-devel.sym +symbol_files += $(top_srcdir)/src/libostree/libostree-devel.sym #endif # http://blog.jgc.org/2007/06/escaping-comma-and-space-in-gnu-make.html diff --git a/apidoc/ostree-sections.txt b/apidoc/ostree-sections.txt index 9af45b1a..596e5e2d 100644 --- a/apidoc/ostree-sections.txt +++ b/apidoc/ostree-sections.txt @@ -490,6 +490,7 @@ ostree_repo_verify_commit ostree_repo_verify_commit_ext ostree_repo_verify_commit_for_remote ostree_repo_verify_summary +ostree_repo_verify_local_summary ostree_repo_regenerate_metadata ostree_repo_regenerate_summary diff --git a/src/libostree/libostree-devel.sym b/src/libostree/libostree-devel.sym index 6640e11c..3780d530 100644 --- a/src/libostree/libostree-devel.sym +++ b/src/libostree/libostree-devel.sym @@ -29,3 +29,8 @@ global: someostree_symbol_deleteme; } LIBOSTREE_$YEAR.$LASTSTABLE; */ + +LIBOSTREE_2026.3 { +global: + ostree_repo_verify_local_summary; +} LIBOSTREE_2025.2; diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c index d158e800..487f9354 100644 --- a/src/libostree/ostree-repo.c +++ b/src/libostree/ostree-repo.c @@ -5822,6 +5822,52 @@ ostree_repo_verify_summary (OstreeRepo *self, const char *remote_name, GBytes *s #endif /* OSTREE_DISABLE_GPGME */ } +/** + * ostree_repo_verify_local_summary: + * @self: Repo + * @summary: Summary data as a #GBytes + * @signatures: Summary signatures as a #GBytes + * @keyringdir: (nullable): Path to directory GPG keyrings; overrides built-in default if given + * @extra_keyring: (nullable): Path to additional keyring file (not a directory) + * @cancellable: Cancellable + * @error: Error + * + * Verify @signatures for @summary data using GPG keys in the given keyring (GPG + * homedir), and return an #OstreeGpgVerifyResult. + * + * This is intended to be used on a server repository, for verifying the + * signatures on the summary file it exports. Use ostree_repo_verify_summary() + * to verify the summary file from a configured remote in a repository. + * + * Returns: (transfer full): an #OstreeGpgVerifyResult, or %NULL on error + */ +OstreeGpgVerifyResult * +ostree_repo_verify_local_summary (OstreeRepo *self, GBytes *summary, GBytes *signatures, + GFile *keyringdir, GFile *extra_keyring, + GCancellable *cancellable, GError **error) +{ + g_autoptr (GVariant) signatures_variant = NULL; + + g_return_val_if_fail (OSTREE_IS_REPO (self), NULL); + g_return_val_if_fail (summary != NULL, NULL); + g_return_val_if_fail (signatures != NULL, NULL); + g_return_val_if_fail (keyringdir == NULL || G_IS_FILE (keyringdir), NULL); + g_return_val_if_fail (extra_keyring == NULL || G_IS_FILE (extra_keyring), NULL); + g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + signatures_variant + = g_variant_new_from_bytes (OSTREE_SUMMARY_SIG_GVARIANT_FORMAT, signatures, FALSE); + +#ifndef OSTREE_DISABLE_GPGME + return _ostree_repo_gpg_verify_with_metadata (self, summary, signatures_variant, NULL, keyringdir, + extra_keyring, cancellable, error); +#else + glnx_throw (error, "GPG has been disabled at build time"); + return NULL; +#endif /* OSTREE_DISABLE_GPGME */ +} + /* Add an entry for a @ref ↦ @checksum mapping to an `a(s(t@ay@a{sv}))` * @refs_builder to go into a `summary` file. This includes building the * standard additional metadata keys for the ref. */ diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h index 460188b0..c3338336 100644 --- a/src/libostree/ostree-repo.h +++ b/src/libostree/ostree-repo.h @@ -1279,6 +1279,12 @@ OstreeGpgVerifyResult *ostree_repo_verify_summary (OstreeRepo *self, const char GBytes *summary, GBytes *signatures, GCancellable *cancellable, GError **error); +_OSTREE_PUBLIC +OstreeGpgVerifyResult *ostree_repo_verify_local_summary (OstreeRepo *self, GBytes *summary, + GBytes *signatures, GFile *keyfiledir, + GFile *extra_keyring, + GCancellable *cancellable, GError **error); + /** * OstreeRepoVerifyFlags: * @OSTREE_REPO_VERIFY_FLAGS_NONE: No flags