1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

gpg: Show just keyserver and port with --send-keys.

* g10/call-dirmngr.c (ks_status_cb): Mangle the keyserver url
This commit is contained in:
Werner Koch 2022-09-30 16:40:31 +02:00
parent 4cf8dc2d96
commit 2b2f8a1a0c
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -397,6 +397,7 @@ ks_status_cb (void *opaque, const char *line)
const char *s, *s2; const char *s, *s2;
const char *warn = NULL; const char *warn = NULL;
int is_note = 0; int is_note = 0;
char *p;
if ((s = has_leading_keyword (line, parm->keyword? parm->keyword : "SOURCE"))) if ((s = has_leading_keyword (line, parm->keyword? parm->keyword : "SOURCE")))
{ {
@ -406,6 +407,30 @@ ks_status_cb (void *opaque, const char *line)
parm->source = xtrystrdup (s); parm->source = xtrystrdup (s);
if (!parm->source) if (!parm->source)
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
else
{
p = strchr (parm->source, ':');
if (p && p[1] == '/' && p[2] == '/')
{
/* This is a real URL like "ldap://foo:389/bla,bla"
* Strip off the local part. */
if ((p = strchr (p+3, '/')))
*p = 0;
}
else
{
/* This is an LDAP config entry like
* "foo:389:user:pass:base:flags"
* we strip off everything beyound the port. */
if ((p = strchr (p+1, ':')))
{
if (p[-1] == ':')
p[-1] = 0; /* No port given. */
else
*p = 0;
}
}
}
} }
} }
else if ((s = has_leading_keyword (line, "WARNING")) else if ((s = has_leading_keyword (line, "WARNING"))