FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-27-2011, 09:39 PM
Dan McGee
 
Default signing: check validity of all available signatures

Change the check into a loop over all signatures present and returned by
GPGME. Also modify the return values and checks slightly now that I know
a little bit more about what type of values are returned.

Signed-off-by: Dan McGee <dan@archlinux.org>
---

The code change looks bigger here due mostly to the reindent needed to move the
checks inside the loop.

lib/libalpm/signing.c | 54 +++++++++++++++++++++++-------------------------
1 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c
index 06cb6ac..a19c1cb 100644
--- a/lib/libalpm/signing.c
+++ b/lib/libalpm/signing.c
@@ -292,7 +292,7 @@ int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
goto error;
}

- {
+ while(gpgsig) {
alpm_list_t *summary_list, *summary;

_alpm_log(handle, PM_LOG_DEBUG, "fingerprint: %s
", gpgsig->fpr);
@@ -304,35 +304,33 @@ int _alpm_gpgme_checksig(pmhandle_t *handle, const char *path,
_alpm_log(handle, PM_LOG_DEBUG, "status: %s
", gpgme_strerror(gpgsig->status));
_alpm_log(handle, PM_LOG_DEBUG, "timestamp: %lu
", gpgsig->timestamp);
_alpm_log(handle, PM_LOG_DEBUG, "exp_timestamp: %lu
", gpgsig->exp_timestamp);
- _alpm_log(handle, PM_LOG_DEBUG, "validity: %s
",
- string_validity(gpgsig->validity));
- _alpm_log(handle, PM_LOG_DEBUG, "validity_reason: %s
",
+ _alpm_log(handle, PM_LOG_DEBUG, "validity: %s; reason: %s
",
+ string_validity(gpgsig->validity),
gpgme_strerror(gpgsig->validity_reason));
- _alpm_log(handle, PM_LOG_DEBUG, "pubkey algo: %s
",
- gpgme_pubkey_algo_name(gpgsig->pubkey_algo));
- _alpm_log(handle, PM_LOG_DEBUG, "hash algo: %s
",
- gpgme_hash_algo_name(gpgsig->hash_algo));
- }

- if(gpgsig->summary & GPGME_SIGSUM_VALID) {
- /* good signature, continue */
- _alpm_log(handle, PM_LOG_DEBUG, _("File %s has a valid signature.
"),
- path);
- } else if(gpgsig->summary & GPGME_SIGSUM_GREEN) {
- /* 'green' signature, not sure what to do here */
- _alpm_log(handle, PM_LOG_WARNING, _("File %s has a green signature.
"),
- path);
- } else if(gpgsig->summary & GPGME_SIGSUM_KEY_MISSING) {
- handle->pm_errno = PM_ERR_SIG_UNKNOWN;
- _alpm_log(handle, PM_LOG_WARNING, _("File %s has a signature from an unknown key.
"),
- path);
- ret = -1;
- } else {
- /* we'll capture everything else here */
- handle->pm_errno = PM_ERR_SIG_INVALID;
- _alpm_log(handle, PM_LOG_ERROR, _("File %s has an invalid signature.
"),
- path);
- ret = 1;
+ if(gpgsig->summary & GPGME_SIGSUM_VALID) {
+ /* definite good signature */
+ _alpm_log(handle, PM_LOG_DEBUG, "result: valid signature
");
+ } else if(gpgsig->summary & GPGME_SIGSUM_GREEN) {
+ /* good signature */
+ _alpm_log(handle, PM_LOG_DEBUG, "result: green signature
");
+ } else if(gpgsig->summary & GPGME_SIGSUM_RED) {
+ /* definite bad signature, error */
+ _alpm_log(handle, PM_LOG_DEBUG, "result: red signature
");
+ handle->pm_errno = PM_ERR_SIG_INVALID;
+ ret = 1;
+ } else if(gpgsig->summary & GPGME_SIGSUM_KEY_MISSING) {
+ _alpm_log(handle, PM_LOG_DEBUG, "result: signature from unknown key
");
+ handle->pm_errno = PM_ERR_SIG_UNKNOWN;
+ ret = 1;
+ } else {
+ /* we'll capture everything else here */
+ _alpm_log(handle, PM_LOG_DEBUG, "result: invalid signature
");
+ handle->pm_errno = PM_ERR_SIG_INVALID;
+ ret = 1;
+ }
+
+ gpgsig = gpgsig->next;
}

error:
--
1.7.5.4
 

Thread Tools




All times are GMT. The time now is 07:04 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org