summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2018-03-12 11:06:14 +0100
committerFabian Groffen <grobian@gentoo.org>2018-03-12 11:06:14 +0100
commit6e4d403adaa5efd03ee731a05c016d7c6affe6c8 (patch)
treee6ad569835202a809afc42cc47de691782482f4e
parentscripts/bootstrap-bash: copy efetch behaviour from bootstrap-prefix (diff)
downloadprefix-6e4d403adaa5efd03ee731a05c016d7c6affe6c8.tar.gz
prefix-6e4d403adaa5efd03ee731a05c016d7c6affe6c8.tar.bz2
prefix-6e4d403adaa5efd03ee731a05c016d7c6affe6c8.zip
scripts/rsync-generation/hashgen: report no garbage when key is missing
-rw-r--r--scripts/rsync-generation/hashgen.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/scripts/rsync-generation/hashgen.c b/scripts/rsync-generation/hashgen.c
index c4955f65c7..60121978da 100644
--- a/scripts/rsync-generation/hashgen.c
+++ b/scripts/rsync-generation/hashgen.c
@@ -829,24 +829,31 @@ verify_gpg_sig(const char *path)
vres = gpgme_op_verify_result(g_ctx);
fclose(f);
+ if (vres == NULL || vres->signatures == NULL) {
+ fprintf(stderr, "verification failed due to a missing gpg keyring\n");
+ return ret;
+ }
+
for (sig = vres->signatures; sig != NULL; sig = sig->next) {
- ctime = gmtime((time_t *)&sig->timestamp);
- strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S UTC", ctime);
- printf("%s key fingerprint "
- "%.4s %.4s %.4s %.4s %.4s %.4s %.4s %.4s %.4s %.4s\n"
- "%s signature made %s by\n",
- gpgme_pubkey_algo_name(sig->pubkey_algo),
- sig->fpr + 0, sig->fpr + 4, sig->fpr + 8, sig->fpr + 12,
- sig->fpr + 16, sig->fpr + 20, sig->fpr + 24, sig->fpr + 28,
- sig->fpr + 32, sig->fpr + 36,
- sig->status == GPG_ERR_NO_ERROR ? "good" : "BAD",
- buf);
-
- if (gpgme_get_key(g_ctx, sig->fpr, &key, 0) == GPG_ERR_NO_ERROR) {
- ret = 0; /* valid */
- if (key->uids != NULL)
- printf("%s\n", key->uids->uid);
- gpgme_key_release(key);
+ if (sig->status != GPG_ERR_NO_PUBKEY) {
+ ctime = gmtime((time_t *)&sig->timestamp);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S UTC", ctime);
+ printf("%s key fingerprint "
+ "%.4s %.4s %.4s %.4s %.4s %.4s %.4s %.4s %.4s %.4s\n"
+ "%s signature made %s by\n",
+ gpgme_pubkey_algo_name(sig->pubkey_algo),
+ sig->fpr + 0, sig->fpr + 4, sig->fpr + 8, sig->fpr + 12,
+ sig->fpr + 16, sig->fpr + 20, sig->fpr + 24, sig->fpr + 28,
+ sig->fpr + 32, sig->fpr + 36,
+ sig->status == GPG_ERR_NO_ERROR ? "good" : "BAD",
+ buf);
+
+ if (gpgme_get_key(g_ctx, sig->fpr, &key, 0) == GPG_ERR_NO_ERROR) {
+ ret = 0; /* valid */
+ if (key->uids != NULL)
+ printf("%s\n", key->uids->uid);
+ gpgme_key_release(key);
+ }
}
switch (sig->status) {