summaryrefslogtreecommitdiffstats
path: root/src/pacman/util.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-07-01 23:50:32 +0200
committerDan McGee <dan@archlinux.org>2011-07-05 17:13:20 +0200
commit07502f2d82393854f36f5c3ff608458e74fcb747 (patch)
tree24ec485afd9feceeebf326566b323a974a939cd1 /src/pacman/util.c
parente8443b1685cc99cf3a46461e7a12c9b616fac44e (diff)
downloadpacman-07502f2d82393854f36f5c3ff608458e74fcb747.tar.gz
pacman-07502f2d82393854f36f5c3ff608458e74fcb747.tar.xz
Allow frontend access to signature verification information
Show output in -Qip for each package signature, which includes the UID string from the key ("Joe User <joe@example.com>") and the validity of said key. Example output: Signatures : Valid signature from "Dan McGee <dpmcgee@gmail.com>" Unknown signature from "<Key Unknown>" Invalid signature from "Dan McGee <dpmcgee@gmail.com>" Also add a backend alpm_sigresult_cleanup() function since memory allocation took place on this object, and we need some way of freeing it. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/util.c')
-rw-r--r--src/pacman/util.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 9ced7aad..28beaca3 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -613,7 +613,6 @@ void list_display(const char *title, const alpm_list_t *list)
void list_display_linebreak(const char *title, const alpm_list_t *list)
{
- const alpm_list_t *i;
int len = 0;
if(title) {
@@ -624,6 +623,7 @@ void list_display_linebreak(const char *title, const alpm_list_t *list)
if(!list) {
printf("%s\n", _("None"));
} else {
+ const alpm_list_t *i;
/* Print the first element */
indentprint((const char *) alpm_list_getdata(list), len);
printf("\n");
@@ -639,6 +639,52 @@ void list_display_linebreak(const char *title, const alpm_list_t *list)
}
}
+void signature_display(const char *title, alpm_sigresult_t *result)
+{
+ int len = 0;
+
+ if(title) {
+ len = string_length(title) + 1;
+ printf("%s ", title);
+ }
+ if(result->count == 0) {
+ printf(_("None"));
+ } else {
+ int i;
+ for(i = 0; i < result->count; i++) {
+ char sigline[PATH_MAX];
+ const char *validity, *name;
+ /* Don't re-indent the first result */
+ if(i != 0) {
+ int j;
+ for(j = 1; j <= len; j++) {
+ printf(" ");
+ }
+ }
+ switch(result->status[i]) {
+ case ALPM_SIGSTATUS_VALID:
+ validity = _("Valid signature");
+ break;
+ case ALPM_SIGSTATUS_MARGINAL:
+ validity = _("Marginal signature");
+ break;
+ case ALPM_SIGSTATUS_UNKNOWN:
+ validity = _("Unknown signature");
+ break;
+ case ALPM_SIGSTATUS_BAD:
+ validity = _("Invalid signature");
+ break;
+ default:
+ validity = _("Signature error");
+ }
+ name = result->uid[i] ? result->uid[i] : _("<Key Unknown>");
+ snprintf(sigline, PATH_MAX, _("%s from \"%s\""), validity, name);
+ indentprint(sigline, len);
+ printf("\n");
+ }
+ }
+}
+
/* creates a header row for use with table_display */
static alpm_list_t *create_verbose_header(int install)
{