aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-04-29 10:18:48 +0000
committerWerner Koch <[email protected]>2021-04-29 10:18:48 +0000
commit0eed0ced9bcd3c14621076d26cf4d9f809e1873c (patch)
tree3f6fee897a6e0e7d20b7bf3b8acfb961478a1eb1
parentscd: Minor changes to assist in backporting from 2.3 (diff)
downloadgnupg-0eed0ced9bcd3c14621076d26cf4d9f809e1873c.tar.gz
gnupg-0eed0ced9bcd3c14621076d26cf4d9f809e1873c.zip
scd: New function send_keyinfo to assist in backporting.
* scd/command.c (send_keyinfo): New.
-rw-r--r--scd/command.c28
-rw-r--r--scd/scdaemon.h2
2 files changed, 30 insertions, 0 deletions
diff --git a/scd/command.c b/scd/command.c
index e8c9ff66d..e1895c6e3 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -1846,6 +1846,34 @@ scd_command_handler (ctrl_t ctrl, int fd)
}
+
+/* Send a keyinfo string. If DATA is true the string is emitted as a
+ * data line, else as a status line. */
+void
+send_keyinfo (ctrl_t ctrl, int data, const char *keygrip_str,
+ const char *serialno, const char *idstr)
+{
+ char *string;
+ assuan_context_t ctx = ctrl->server_local->assuan_ctx;
+
+ string = xtryasprintf ("%s T %s %s%s", keygrip_str,
+ serialno? serialno : "-",
+ idstr? idstr : "-",
+ data? "\n" : "");
+
+ if (!string)
+ return;
+
+ if (!data)
+ assuan_write_status (ctx, "KEYINFO", string);
+ else
+ assuan_send_data (ctx, string, strlen (string));
+
+ xfree (string);
+ return;
+}
+
+
/* Send a line with status information via assuan and escape all given
buffers. The variable elements are pairs of (char *, size_t),
terminated with a (NULL, 0). */
diff --git a/scd/scdaemon.h b/scd/scdaemon.h
index 806ad8f1a..336013805 100644
--- a/scd/scdaemon.h
+++ b/scd/scdaemon.h
@@ -122,6 +122,8 @@ const char *scd_get_socket_name (void);
/*-- command.c --*/
gpg_error_t initialize_module_command (void);
int scd_command_handler (ctrl_t, int);
+void send_keyinfo (ctrl_t ctrl, int data, const char *keygrip_str,
+ const char *serialno, const char *idstr);
void send_status_info (ctrl_t ctrl, const char *keyword, ...)
GPGRT_ATTR_SENTINEL(1);
gpg_error_t send_status_direct (ctrl_t ctrl, const char *keyword,