aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'dirmngr/server.c')
-rw-r--r--dirmngr/server.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/dirmngr/server.c b/dirmngr/server.c
index bf4e891f3..b43390be0 100644
--- a/dirmngr/server.c
+++ b/dirmngr/server.c
@@ -324,6 +324,46 @@ strcpy_escaped_plus (char *d, const unsigned char *s)
}
+/* Break the LINE into space delimited tokens, put them into a new
+ * strlist and return it at R_LIST. On error an erro code is
+ * returned. If no tokens are found the list is set to NULL.
+ * Percent-plus encoding is removed from each token. Note that the
+ * function will modify LINE. */
+static gpg_error_t
+percentplus_line_to_strlist (char *line, strlist_t *r_list)
+{
+ strlist_t list = NULL;
+ strlist_t sl;
+ char *p;
+
+ for (p=line; *p; line = p)
+ {
+ while (*p && *p != ' ')
+ p++;
+ if (*p)
+ *p++ = 0;
+ if (*line)
+ {
+ sl = xtrymalloc (sizeof *sl + strlen (line));
+ if (!sl)
+ {
+ gpg_error_t err = gpg_error_from_syserror ();
+ free_strlist (list);
+ *r_list = NULL;
+ return err;
+ }
+ sl->flags = 0;
+ strcpy_escaped_plus (sl->d, line);
+ sl->next = list;
+ list = sl;
+ }
+ }
+
+ *r_list = list;
+ return 0;
+}
+
+
/* This function returns true if a Tor server is running. The status
* is cached for the current connection. */
static int
@@ -2702,6 +2742,51 @@ cmd_ks_put (assuan_context_t ctx, char *line)
}
+static const char hlp_ks_del[] =
+ "KS_DEL --ldap {<fingerprints>}\n"
+ "\n"
+ "Delete the keys specified by primary keys FINGERPRINTS from the\n"
+ "configured OpenPGP LDAP server. The option --ldap is mandatory.";
+static gpg_error_t
+cmd_ks_del (assuan_context_t ctx, char *line)
+{
+ ctrl_t ctrl = assuan_get_pointer (ctx);
+ gpg_error_t err;
+ strlist_t list = NULL;
+ unsigned int flags = 0;
+
+ if (has_option (line, "--ldap"))
+ flags |= KS_GET_FLAG_ONLY_LDAP;
+ line = skip_options (line);
+
+ err = percentplus_line_to_strlist (line, &list);
+ if (err)
+ goto leave;
+
+ if (!(flags & KS_GET_FLAG_ONLY_LDAP))
+ {
+ err = set_error (GPG_ERR_SYNTAX, "option --ldap is mandatory");
+ goto leave;
+ }
+
+ if (!list)
+ {
+ err = set_error (GPG_ERR_SYNTAX, "no fingerprints given");
+ goto leave;
+ }
+
+ err = ensure_keyserver (ctrl);
+ if (err)
+ goto leave;
+
+ err = ks_action_del (ctrl, ctrl->server_local->keyservers, list);
+
+ leave:
+ free_strlist (list);
+ return leave_cmd (ctx, err);
+}
+
+
static const char hlp_ad_query[] =
"AD_QUERY [--first|--next] [--] <filter> \n"
@@ -3035,6 +3120,7 @@ register_commands (assuan_context_t ctx)
{ "KS_GET", cmd_ks_get, hlp_ks_get },
{ "KS_FETCH", cmd_ks_fetch, hlp_ks_fetch },
{ "KS_PUT", cmd_ks_put, hlp_ks_put },
+ { "KS_DEL", cmd_ks_del, hlp_ks_del },
{ "AD_QUERY", cmd_ad_query, hlp_ad_query },
{ "GETINFO", cmd_getinfo, hlp_getinfo },
{ "LOADSWDB", cmd_loadswdb, hlp_loadswdb },