ostree-repo: improve error handling

Correctly return "error" from `ostree_repo_sign_commit()`
in case if GPG is not enabled.

Use glnx_* functions in signature related pull code for clear
error handling if GPG isn't enabled.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
This commit is contained in:
Denis Pynkin 2020-03-23 15:54:06 +03:00
parent cce3864160
commit e2c601687b
1 changed files with 9 additions and 29 deletions

View File

@ -2326,10 +2326,7 @@ out:
return ret; return ret;
#else /* OSTREE_DISABLE_GPGME */ #else /* OSTREE_DISABLE_GPGME */
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, return glnx_throw (error, "GPG feature is disabled in a build time");
"'%s': GPG feature is disabled in a build time",
__FUNCTION__);
return FALSE;
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }
@ -4974,10 +4971,7 @@ ostree_repo_append_gpg_signature (OstreeRepo *self,
return TRUE; return TRUE;
#else #else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, return glnx_throw (error, "GPG feature is disabled in a build time");
"'%s': GPG feature is disabled in a build time",
__FUNCTION__);
return FALSE;
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }
@ -5129,7 +5123,7 @@ ostree_repo_sign_commit (OstreeRepo *self,
return TRUE; return TRUE;
#else #else
/* FIXME: Return false until refactoring */ /* FIXME: Return false until refactoring */
return FALSE; return glnx_throw (error, "GPG feature is disabled in a build time");
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }
@ -5221,10 +5215,7 @@ ostree_repo_add_gpg_signature_summary (OstreeRepo *self,
return TRUE; return TRUE;
#else #else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, return glnx_throw (error, "GPG feature is disabled in a build time");
"'%s': GPG feature is disabled in a build time",
__FUNCTION__);
return FALSE;
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }
@ -5498,10 +5489,7 @@ ostree_repo_verify_commit (OstreeRepo *self,
return TRUE; return TRUE;
#else #else
/* FIXME: Return false until refactoring */ /* FIXME: Return false until refactoring */
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, return glnx_throw (error, "GPG feature is disabled in a build time");
"'%s': GPG feature is disabled in a build time",
__FUNCTION__);
return FALSE;
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }
@ -5536,9 +5524,7 @@ ostree_repo_verify_commit_ext (OstreeRepo *self,
cancellable, cancellable,
error); error);
#else #else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, glnx_throw (error, "GPG feature is disabled in a build time");
"'%s': GPG feature is disabled in a build time",
__FUNCTION__);
return NULL; return NULL;
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }
@ -5575,9 +5561,7 @@ ostree_repo_verify_commit_for_remote (OstreeRepo *self,
cancellable, cancellable,
error); error);
#else #else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, glnx_throw (error, "GPG feature is disabled in a build time");
"'%s': GPG feature is disabled in a build time",
__FUNCTION__);
return NULL; return NULL;
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }
@ -5627,9 +5611,7 @@ ostree_repo_gpg_verify_data (OstreeRepo *self,
cancellable, cancellable,
error); error);
#else #else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, glnx_throw (error, "GPG feature is disabled in a build time");
"'%s': GPG feature is disabled in a build time",
__FUNCTION__);
return NULL; return NULL;
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }
@ -5675,9 +5657,7 @@ ostree_repo_verify_summary (OstreeRepo *self,
cancellable, cancellable,
error); error);
#else #else
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, glnx_throw (error, "GPG feature is disabled in a build time");
"'%s': GPG feature is disabled in a build time",
__FUNCTION__);
return NULL; return NULL;
#endif /* OSTREE_DISABLE_GPGME */ #endif /* OSTREE_DISABLE_GPGME */
} }