aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine-assuan.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-09-09 10:12:51 +0000
committerWerner Koch <[email protected]>2020-09-09 10:13:20 +0000
commite4ee706e270c38937afe26ce9f54d17d037cb86f (patch)
tree5b0535c6d050f2cbe62cf43597e3cbf0688107c4 /src/engine-assuan.c
parentqt: Update the documentation of ListAllKeysJob (diff)
downloadgpgme-e4ee706e270c38937afe26ce9f54d17d037cb86f.tar.gz
gpgme-e4ee706e270c38937afe26ce9f54d17d037cb86f.zip
core: Fully implement the inquire callback for assuan_transact
* src/engine-assuan.c (inquire_cb): Implement returning data. * tests/opassuan/t-command.c (inq_cb): Send some test data. -- The old code only allowed to send an empty response which was good enough for scdaemon's KNOWNCARDP inquire but not to send actual data. A quick test using a test smartcard might be ./t-command 'scd setattr --inquire PRIVATE-DO-1' and then reading the data back using gpg-connect-agent 'scd getattr PRIVATE-DO-1' /bye Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/engine-assuan.c')
-rw-r--r--src/engine-assuan.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/engine-assuan.c b/src/engine-assuan.c
index b51c17e3..eb6d2a8e 100644
--- a/src/engine-assuan.c
+++ b/src/engine-assuan.c
@@ -445,7 +445,10 @@ llass_set_locale (void *engine, int category, const char *value)
static gpgme_error_t
inquire_cb (engine_llass_t llass, const char *keyword, const char *args)
{
- gpg_error_t err;
+ gpg_error_t err, err2;
+ gpgme_data_t data = NULL;
+ char buf[1024];
+ gpgme_ssize_t n;
if (llass->opt.gpg_agent && !strcmp (keyword, "PINENTRY_LAUNCHED"))
{
@@ -454,17 +457,23 @@ inquire_cb (engine_llass_t llass, const char *keyword, const char *args)
if (llass->user.inq_cb)
{
- gpgme_data_t data = NULL;
-
err = llass->user.inq_cb (llass->user.inq_cb_value,
keyword, args, &data);
if (!err && data)
{
- /* FIXME: Returning data is not yet implemented. However we
- need to allow the caller to cleanup his data object.
- Thus we run the callback in finish mode immediately. */
- err = llass->user.inq_cb (llass->user.inq_cb_value,
- NULL, NULL, &data);
+ while ((n = gpgme_data_read (data, buf, sizeof buf)) > 0)
+ {
+ err = assuan_send_data (llass->assuan_ctx, buf, n);
+ if (err)
+ break;
+ }
+ /* Tell the caller that we are finished with the data
+ * object. The error code from assuan_send_data has
+ * priority over the one from the cleanup function. */
+ err2 = llass->user.inq_cb (llass->user.inq_cb_value,
+ NULL, NULL, &data);
+ if (!err)
+ err = err2;
}
}
else