mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-28 16:46:22 +00:00
Added Id and fingerprint to pgp key list
This commit is contained in:
@@ -4073,14 +4073,18 @@ cmd_pgp(gchar **args, struct cmd_help_t help)
|
|||||||
if (g_strcmp0(args[0], "keys") == 0) {
|
if (g_strcmp0(args[0], "keys") == 0) {
|
||||||
GSList *keys = p_gpg_list_keys();
|
GSList *keys = p_gpg_list_keys();
|
||||||
if (keys) {
|
if (keys) {
|
||||||
|
cons_show("PGP keys:");
|
||||||
while (keys) {
|
while (keys) {
|
||||||
cons_debug("Key: %s", keys->data);
|
ProfPGPKey *key = keys->data;
|
||||||
|
cons_show(" %s", key->name);
|
||||||
|
cons_show(" ID : %s", key->id);
|
||||||
|
cons_show(" Fingerprint : %s", key->fp);
|
||||||
keys = g_slist_next(keys);
|
keys = g_slist_next(keys);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cons_debug("No keys found");
|
cons_show("No keys found");
|
||||||
}
|
}
|
||||||
g_slist_free_full(keys, (GDestroyNotify)free);
|
g_slist_free_full(keys, (GDestroyNotify)p_gpg_free_key);
|
||||||
} else if (g_strcmp0(args[0], "libver") == 0) {
|
} else if (g_strcmp0(args[0], "libver") == 0) {
|
||||||
const char *libver = p_gpg_libver();
|
const char *libver = p_gpg_libver();
|
||||||
if (libver) {
|
if (libver) {
|
||||||
|
|||||||
@@ -34,9 +34,12 @@
|
|||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
|
|
||||||
|
#include "pgp/gpg.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static const char *libversion;
|
static const char *libversion;
|
||||||
@@ -70,7 +73,14 @@ p_gpg_list_keys(void)
|
|||||||
if (error) {
|
if (error) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result = g_slist_append(result, strdup(key->uids->uid));
|
|
||||||
|
ProfPGPKey *p_pgpkey = malloc(sizeof(ProfPGPKey));
|
||||||
|
p_pgpkey->id = strdup(key->subkeys->keyid);
|
||||||
|
p_pgpkey->name = strdup(key->uids->uid);
|
||||||
|
p_pgpkey->fp = strdup(key->subkeys->fpr);
|
||||||
|
|
||||||
|
result = g_slist_append(result, p_pgpkey);
|
||||||
|
|
||||||
gpgme_key_release(key);
|
gpgme_key_release(key);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -88,3 +98,13 @@ p_gpg_libver(void)
|
|||||||
return libversion;
|
return libversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
p_gpg_free_key(ProfPGPKey *key)
|
||||||
|
{
|
||||||
|
if (key) {
|
||||||
|
free(key->id);
|
||||||
|
free(key->name);
|
||||||
|
free(key->fp);
|
||||||
|
free(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,8 +35,15 @@
|
|||||||
#ifndef GPG_H
|
#ifndef GPG_H
|
||||||
#define GPG_H
|
#define GPG_H
|
||||||
|
|
||||||
|
typedef struct pgp_key_t {
|
||||||
|
char *id;
|
||||||
|
char *name;
|
||||||
|
char *fp;
|
||||||
|
} ProfPGPKey;
|
||||||
|
|
||||||
void p_gpg_init(void);
|
void p_gpg_init(void);
|
||||||
GSList* p_gpg_list_keys(void);
|
GSList* p_gpg_list_keys(void);
|
||||||
char* p_gpg_libver(void);
|
const char* p_gpg_libver(void);
|
||||||
|
void p_gpg_free_key(ProfPGPKey *key);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include "pgp/gpg.h"
|
||||||
|
|
||||||
void p_gpg_init(void) {}
|
void p_gpg_init(void) {}
|
||||||
|
|
||||||
GSList* p_gpg_list_keys(void)
|
GSList* p_gpg_list_keys(void)
|
||||||
@@ -11,3 +13,5 @@ const char* p_gpg_libver(void) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void p_gpg_free_key(ProfPGPKey *key) {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user