aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2025-04-29 09:33:41 +0000
committerWerner Koch <[email protected]>2025-04-29 09:33:41 +0000
commit41d6ae8f41ededf0d0cc34649c96157581d67687 (patch)
tree29fa695a81ccabc6ceeef9ae63ced2bd1ee2a8bb /g10
parentdoc: Add missing whitespace gnupg7 manpage. (diff)
downloadgnupg-41d6ae8f41ededf0d0cc34649c96157581d67687.tar.gz
gnupg-41d6ae8f41ededf0d0cc34649c96157581d67687.zip
gpg: New list options "show-trustsig"
* g10/options.h (LIST_SHOW_TRUSTSIG): New. * g10/gpg.c (parse_list_options): Add "show-trustsig". * g10/keylist.c (parse_trust_name): New. (list_signature_print): Print trust signature info.
Diffstat (limited to 'g10')
-rw-r--r--g10/gpg.c2
-rw-r--r--g10/keylist.c56
-rw-r--r--g10/options.h1
3 files changed, 59 insertions, 0 deletions
diff --git a/g10/gpg.c b/g10/gpg.c
index db898c41d..d6c2372d8 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -2129,6 +2129,8 @@ parse_list_options(char *str)
N_("show preferences")},
{"show-ownertrust", LIST_SHOW_OWNERTRUST, NULL,
N_("show ownertrust")},
+ {"show-trustsig", LIST_SHOW_TRUSTSIG, NULL,
+ N_("show trust signature information")},
{"show-only-fpr-mbox",LIST_SHOW_ONLY_FPR_MBOX, NULL,
NULL},
{"sort-sigs", LIST_SORT_SIGS, NULL,
diff --git a/g10/keylist.c b/g10/keylist.c
index 499bdf91f..fc0e161ea 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -1291,6 +1291,37 @@ cmp_signodes (const void *av, const void *bv)
}
+/* Given a domain name at NAME with length NAME, check whether this is
+ * a valid domain name and in that case return a malloced string ith
+ * the name. Escaped dots are ignored and removed from the result.
+ * Example: "example\.org" -> "example.org" Note that the input may
+ * not be Nul terminated. */
+static char *
+parse_trust_name (const char *name, size_t namelen)
+{
+ char *buffer, *p;
+
+ p = buffer = xtrymalloc (namelen+1);
+ if (!buffer)
+ return NULL; /* Oops - caller needs to use some fallback */
+
+ for (; namelen; name++, namelen--)
+ {
+ if (*name == '\\' && namelen > 1 && name[1] == '.')
+ ; /* Skip the escape character. */
+ else
+ *p++ = *name;
+ }
+ *p = 0;
+ if (!is_valid_domain_name (buffer))
+ {
+ xfree (buffer);
+ buffer = NULL;
+ }
+ return buffer;
+}
+
+
/* Helper for list_keyblock_print. The caller must have set
* NODFLG_MARK_B to indicate self-signatures. */
static void
@@ -1403,6 +1434,31 @@ list_signature_print (ctrl_t ctrl, kbnode_t keyblock, kbnode_t node,
print_utf8_buffer (es_stdout, p, n);
xfree (p);
}
+ if ((opt.list_options & LIST_SHOW_TRUSTSIG)
+ && (sig->trust_depth || sig->trust_value || sig->trust_regexp))
+ {
+ es_fprintf (es_stdout, " [T=%d,%d", sig->trust_depth, sig->trust_value);
+ if (sig->trust_regexp)
+ {
+ size_t n = strlen (sig->trust_regexp);
+ char *tname = NULL;
+
+ if (!strncmp (sig->trust_regexp, "<[^>]+[@.]", 10)
+ && n > 12 && !strcmp (sig->trust_regexp+n-2, ">$")
+ && (tname=parse_trust_name (sig->trust_regexp+10, n-12)))
+ {
+ es_fprintf (es_stdout, ",\"%s", tname);
+ xfree (tname);
+ }
+ else
+ {
+ es_fputs (",R\"", es_stdout);
+ es_write_sanitized (es_stdout, sig->trust_regexp, n, "\"", NULL);
+ }
+ es_putc ('\"', es_stdout);
+ }
+ es_putc (']', es_stdout);
+ }
es_putc ('\n', es_stdout);
if (sig->flags.policy_url
diff --git a/g10/options.h b/g10/options.h
index 89f04526f..c877404a7 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -463,6 +463,7 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
#define LIST_SHOW_X509_NOTATIONS (1<<17)
#define LIST_STORE_X509_NOTATIONS (1<<18)
#define LIST_SHOW_OWNERTRUST (1<<19)
+#define LIST_SHOW_TRUSTSIG (1<<20)
#define VERIFY_SHOW_PHOTOS (1<<0)
#define VERIFY_SHOW_POLICY_URLS (1<<1)