<SECTION>
<FILE>ostree-gpg-verify-result</FILE>
+OstreeGpgError
OstreeGpgVerifyResult
OstreeGpgSignatureAttr
ostree_gpg_verify_result_count_all
OSTREE_IS_GPG_VERIFY_RESULT
OSTREE_TYPE_GPG_VERIFY_RESULT
ostree_gpg_verify_result_get_type
+OSTREE_GPG_ERROR
+ostree_gpg_error_quark
</SECTION>
<FILE>ostree-lzma-compressor</FILE>
/* Add new symbols here. Release commits should copy this section into -released.sym. */
LIBOSTREE_2017.10 {
+ ostree_gpg_error_quark;
ostree_repo_set_alias_ref_immediate;
};
if (ostree_gpg_verify_result_count_valid (result) == 0)
{
- return glnx_throw (error, "%s",
- "GPG signatures found, but none are in trusted keyring");
+ g_set_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_MISSING_KEY,
+ "GPG signatures found, but none are in trusted keyring");
+ return FALSE;
}
return TRUE;
}
+
+G_DEFINE_QUARK (OstreeGpgError, ostree_gpg_error)
gboolean ostree_gpg_verify_result_require_valid_signature (OstreeGpgVerifyResult *result,
GError **error);
+/**
+ * OstreeGpgError:
+ * @OSTREE_GPG_ERROR_NO_SIGNATURE: A signature was expected, but not found.
+ * @OSTREE_GPG_ERROR_INVALID_SIGNATURE: A signature was malformed.
+ * @OSTREE_GPG_ERROR_MISSING_KEY: A signature was found, but was created with a key not in the configured keyrings.
+ *
+ * Errors returned by signature creation and verification operations in OSTree.
+ * These may be returned by any API which creates or verifies signatures.
+ *
+ * Since: 2017.10
+ */
+typedef enum {
+ OSTREE_GPG_ERROR_NO_SIGNATURE = 0,
+ OSTREE_GPG_ERROR_INVALID_SIGNATURE,
+ OSTREE_GPG_ERROR_MISSING_KEY,
+} OstreeGpgError;
+
+_OSTREE_PUBLIC
+GQuark ostree_gpg_error_quark (void);
+#define OSTREE_GPG_ERROR (ostree_gpg_error_quark ())
+
G_END_DECLS
if (!detached_metadata)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ g_set_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE,
"Commit %s: no detached metadata found for GPG verification",
checksum);
return FALSE;
*/
if (pull_data->gpg_verify_summary && !summary_csum)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ g_set_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE,
"GPG verification enabled, but no summary signatures found (use gpg-verify-summary=false in remote config to disable)");
goto out;
}
if (!bytes_summary && pull_data->gpg_verify_summary)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"GPG verification enabled, but no summary found (use gpg-verify-summary=false in remote config to disable)");
goto out;
}
if (!bytes_summary && pull_data->require_static_deltas)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"Fetch configured to require static deltas, but no summary found");
goto out;
}
if (!bytes_sig && pull_data->gpg_verify_summary)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ g_set_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE,
"GPG verification enabled, but no summary.sig found (use gpg-verify-summary=false in remote config to disable)");
goto out;
}
if (gpg_verify_summary && signatures == NULL)
{
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ g_set_error (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE,
"GPG verification enabled, but no summary signatures found (use gpg-verify-summary=false in remote config to disable)");
goto out;
}
if (!result)
{
/* "Not found" just means the commit is not yet signed. That's okay. */
- if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ if (g_error_matches (local_error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE))
{
g_clear_error (&local_error);
}
_OSTREE_METADATA_GPGSIGS_TYPE);
if (!signaturedata)
{
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ g_set_error_literal (error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE,
"GPG verification enabled, but no signatures found (use gpg-verify=false in remote config to disable)");
return NULL;
}
&local_error);
}
- if (g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ if (g_error_matches (local_error, OSTREE_GPG_ERROR, OSTREE_GPG_ERROR_NO_SIGNATURE))
{
/* Ignore */
}