admin: Conditionally show GPG signatures in status command

Only if GPG verification is enabled for a deployment's origin.
This commit is contained in:
Matthew Barnes 2015-04-15 15:04:53 -04:00
parent 54bf665521
commit 6a7b9defb8
1 changed files with 58 additions and 24 deletions

View File

@ -49,6 +49,37 @@ version_of_commit (OstreeRepo *repo, const char *checksum)
return NULL;
}
static gboolean
deployment_get_gpg_verify (OstreeDeployment *deployment,
OstreeRepo *repo)
{
/* XXX Something like this could be added to the OstreeDeployment
* API in libostree if the OstreeRepo parameter is acceptable. */
GKeyFile *origin;
gs_free char *refspec = NULL;
gs_free char *remote = NULL;
gboolean gpg_verify = FALSE;
origin = ostree_deployment_get_origin (deployment);
if (origin == NULL)
goto out;
refspec = g_key_file_get_string (origin, "origin", "refspec", NULL);
if (refspec == NULL)
goto out;
if (!ostree_parse_refspec (refspec, &remote, NULL, NULL))
goto out;
(void) ostree_repo_remote_get_gpg_verify (repo, remote, &gpg_verify, NULL);
out:
return gpg_verify;
}
gboolean
ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GError **error)
{
@ -112,6 +143,8 @@ ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GErro
g_print (" origin refspec: %s\n", origin_refspec);
}
if (deployment_get_gpg_verify (deployment, repo))
{
/* Print any digital signatures on this commit. */
result = ostree_repo_verify_commit_ext (repo, ref, NULL, NULL,
@ -142,6 +175,7 @@ ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GErro
g_string_free (output_buffer, TRUE);
}
}
}
ret = TRUE;
out: