ostree-repo: Add a new ostree_repo_verify_local_summary() API
authorPhilip Withnall <pwithnall@gnome.org>
Tue, 4 Aug 2026 15:49:43 +0000 (16:49 +0100)
committerPhilip Withnall <pwithnall@gnome.org>
Tue, 4 Aug 2026 15:58:57 +0000 (16:58 +0100)
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 <pwithnall@gnome.org>
Makefile-libostree.am
apidoc/ostree-sections.txt
src/libostree/libostree-devel.sym
src/libostree/ostree-repo.c
src/libostree/ostree-repo.h

index cffad4163d4966d87547ef319210226dc5aa603d..af6a2854cf7f3ebd8abbf6fac05e95cea127bc13 100644 (file)
@@ -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
index 9af45b1a8d446a7c0b926c861c2d69ac6ddb22bc..596e5e2d75d9ebc1088c67c053286c831ac52389 100644 (file)
@@ -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
 <SUBSECTION Standard>
index 6640e11c78d7a370a8191ff9a97b285a29df0b8f..3780d530808d8616df8c3def2d1e338928a5e45f 100644 (file)
@@ -29,3 +29,8 @@ global:
   someostree_symbol_deleteme;
 } LIBOSTREE_$YEAR.$LASTSTABLE;
 */
+
+LIBOSTREE_2026.3 {
+global:
+  ostree_repo_verify_local_summary;
+} LIBOSTREE_2025.2;
index d158e80012504dfbfa9ea6301c33800a9a652b32..487f9354421140527bc18f256fa7be3862e1c15d 100644 (file)
@@ -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. */
index 460188b008adff692ea5e467fa98b63091248d1a..c3338336c35413ce29e87f7884814700647b8c5b 100644 (file)
@@ -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