lib: Define and use cleanup functions for gpgme
Just a cleanup in preparation for future work. Closes: #575 Approved by: giuseppe
This commit is contained in:
parent
bd45e7ac19
commit
a6cfe62eb8
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "libglnx.h"
|
#include "libglnx.h"
|
||||||
#include "ostree-gpg-verifier.h"
|
#include "ostree-gpg-verifier.h"
|
||||||
|
#include "ot-gpg-utils.h"
|
||||||
#include "ostree-gpg-verify-result-private.h"
|
#include "ostree-gpg-verify-result-private.h"
|
||||||
#include "otutil.h"
|
#include "otutil.h"
|
||||||
|
|
||||||
|
|
@ -89,10 +90,9 @@ _ostree_gpg_verifier_check_signature (OstreeGpgVerifier *self,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gpgme_ctx_t gpg_ctx = NULL;
|
|
||||||
gpgme_error_t gpg_error = 0;
|
gpgme_error_t gpg_error = 0;
|
||||||
gpgme_data_t data_buffer = NULL;
|
ot_auto_gpgme_data gpgme_data_t data_buffer = NULL;
|
||||||
gpgme_data_t signature_buffer = NULL;
|
ot_auto_gpgme_data gpgme_data_t signature_buffer = NULL;
|
||||||
g_autofree char *tmp_dir = NULL;
|
g_autofree char *tmp_dir = NULL;
|
||||||
g_autoptr(GOutputStream) target_stream = NULL;
|
g_autoptr(GOutputStream) target_stream = NULL;
|
||||||
OstreeGpgVerifyResult *result = NULL;
|
OstreeGpgVerifyResult *result = NULL;
|
||||||
|
|
@ -191,14 +191,6 @@ _ostree_gpg_verifier_check_signature (OstreeGpgVerifier *self,
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
if (gpg_ctx != NULL)
|
|
||||||
gpgme_release (gpg_ctx);
|
|
||||||
if (data_buffer != NULL)
|
|
||||||
gpgme_data_release (data_buffer);
|
|
||||||
if (signature_buffer != NULL)
|
|
||||||
gpgme_data_release (signature_buffer);
|
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
/* Keep the temporary directory around for the life of the result
|
/* Keep the temporary directory around for the life of the result
|
||||||
|
|
|
||||||
|
|
@ -1440,9 +1440,9 @@ ostree_repo_remote_gpg_import (OstreeRepo *self,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
OstreeRemote *remote;
|
OstreeRemote *remote;
|
||||||
gpgme_ctx_t source_context = NULL;
|
ot_auto_gpgme_ctx gpgme_ctx_t source_context = NULL;
|
||||||
gpgme_ctx_t target_context = NULL;
|
ot_auto_gpgme_ctx gpgme_ctx_t target_context = NULL;
|
||||||
gpgme_data_t data_buffer = NULL;
|
ot_auto_gpgme_data gpgme_data_t data_buffer = NULL;
|
||||||
gpgme_import_result_t import_result;
|
gpgme_import_result_t import_result;
|
||||||
gpgme_import_status_t import_status;
|
gpgme_import_status_t import_status;
|
||||||
const char *tmp_dir = NULL;
|
const char *tmp_dir = NULL;
|
||||||
|
|
@ -1700,15 +1700,6 @@ out:
|
||||||
if (target_tmp_dir != NULL)
|
if (target_tmp_dir != NULL)
|
||||||
(void) glnx_shutil_rm_rf_at (AT_FDCWD, target_tmp_dir, NULL, NULL);
|
(void) glnx_shutil_rm_rf_at (AT_FDCWD, target_tmp_dir, NULL, NULL);
|
||||||
|
|
||||||
if (source_context != NULL)
|
|
||||||
gpgme_release (source_context);
|
|
||||||
|
|
||||||
if (target_context != NULL)
|
|
||||||
gpgme_release (target_context);
|
|
||||||
|
|
||||||
if (data_buffer != NULL)
|
|
||||||
gpgme_data_release (data_buffer);
|
|
||||||
|
|
||||||
g_prefix_error (error, "GPG: ");
|
g_prefix_error (error, "GPG: ");
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,15 @@
|
||||||
|
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
#include "libglnx.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
GLNX_DEFINE_CLEANUP_FUNCTION0(gpgme_data_t, ot_cleanup_gpgme_data, gpgme_data_release)
|
||||||
|
#define ot_auto_gpgme_data __attribute__((cleanup(ot_cleanup_gpgme_data)))
|
||||||
|
GLNX_DEFINE_CLEANUP_FUNCTION0(gpgme_ctx_t, ot_cleanup_gpgme_ctx, gpgme_release)
|
||||||
|
#define ot_auto_gpgme_ctx __attribute__((cleanup(ot_cleanup_gpgme_ctx)))
|
||||||
|
|
||||||
void ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error, GError **error);
|
void ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error, GError **error);
|
||||||
|
|
||||||
gboolean ot_gpgme_ctx_tmp_home_dir (gpgme_ctx_t gpgme_ctx,
|
gboolean ot_gpgme_ctx_tmp_home_dir (gpgme_ctx_t gpgme_ctx,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue