We better save the description of PKITS along with the test data.
[gnupg.git] / sm / call-agent.c
blob625ca9d6e64ef042e5fe2c57fdb509a21972bbff
1 /* call-agent.c - Divert GPGSM operations to the agent
2 * Copyright (C) 2001, 2002, 2003, 2005, 2007,
3 * 2008 Free Software Foundation, Inc.
5 * This file is part of GnuPG.
7 * GnuPG is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * GnuPG is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include <config.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <errno.h>
26 #include <unistd.h>
27 #include <time.h>
28 #include <assert.h>
29 #ifdef HAVE_LOCALE_H
30 #include <locale.h>
31 #endif
33 #include "gpgsm.h"
34 #include <gcrypt.h>
35 #include <assuan.h>
36 #include "i18n.h"
37 #include "asshelp.h"
38 #include "keydb.h" /* fixme: Move this to import.c */
39 #include "membuf.h"
42 static assuan_context_t agent_ctx = NULL;
45 struct cipher_parm_s
47 ctrl_t ctrl;
48 assuan_context_t ctx;
49 const unsigned char *ciphertext;
50 size_t ciphertextlen;
53 struct genkey_parm_s
55 ctrl_t ctrl;
56 assuan_context_t ctx;
57 const unsigned char *sexp;
58 size_t sexplen;
61 struct learn_parm_s
63 int error;
64 ctrl_t ctrl;
65 assuan_context_t ctx;
66 membuf_t *data;
71 /* Try to connect to the agent via socket or fork it off and work by
72 pipes. Handle the server's initial greeting */
73 static int
74 start_agent (ctrl_t ctrl)
76 int rc;
78 if (agent_ctx)
79 rc = 0; /* fixme: We need a context for each thread or
80 serialize the access to the agent (which is
81 suitable given that the agent is not MT. */
82 else
84 rc = start_new_gpg_agent (&agent_ctx,
85 GPG_ERR_SOURCE_DEFAULT,
86 opt.homedir,
87 opt.agent_program,
88 opt.display, opt.ttyname, opt.ttytype,
89 opt.lc_ctype, opt.lc_messages,
90 opt.xauthority, opt.pinentry_user_data,
91 opt.verbose, DBG_ASSUAN,
92 gpgsm_status2, ctrl);
94 if (!rc)
96 /* Tell the agent that we support Pinentry notifications. No
97 error checking so that it will work also with older
98 agents. */
99 assuan_transact (agent_ctx, "OPTION allow-pinentry-notify",
100 NULL, NULL, NULL, NULL, NULL, NULL);
104 if (!ctrl->agent_seen)
106 ctrl->agent_seen = 1;
107 audit_log_ok (ctrl->audit, AUDIT_AGENT_READY, rc);
110 return rc;
115 static int
116 membuf_data_cb (void *opaque, const void *buffer, size_t length)
118 membuf_t *data = opaque;
120 if (buffer)
121 put_membuf (data, buffer, length);
122 return 0;
126 /* This is the default inquiry callback. It mainly handles the
127 Pinentry notifications. */
128 static int
129 default_inq_cb (void *opaque, const char *line)
131 gpg_error_t err;
132 ctrl_t ctrl = opaque;
134 if (!strncmp (line, "PINENTRY_LAUNCHED", 17) && (line[17]==' '||!line[17]))
136 err = gpgsm_proxy_pinentry_notify (ctrl, line);
137 if (err)
138 log_error (_("failed to proxy %s inquiry to client\n"),
139 "PINENTRY_LAUNCHED");
140 /* We do not pass errors to avoid breaking other code. */
142 else
143 log_error ("ignoring gpg-agent inquiry `%s'\n", line);
145 return 0;
151 /* Call the agent to do a sign operation using the key identified by
152 the hex string KEYGRIP. */
154 gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
155 unsigned char *digest, size_t digestlen, int digestalgo,
156 unsigned char **r_buf, size_t *r_buflen )
158 int rc, i;
159 char *p, line[ASSUAN_LINELENGTH];
160 membuf_t data;
161 size_t len;
163 *r_buf = NULL;
164 rc = start_agent (ctrl);
165 if (rc)
166 return rc;
168 if (digestlen*2 + 50 > DIM(line))
169 return gpg_error (GPG_ERR_GENERAL);
171 rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
172 if (rc)
173 return rc;
175 snprintf (line, DIM(line)-1, "SIGKEY %s", keygrip);
176 line[DIM(line)-1] = 0;
177 rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
178 if (rc)
179 return rc;
181 if (desc)
183 snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc);
184 line[DIM(line)-1] = 0;
185 rc = assuan_transact (agent_ctx, line,
186 NULL, NULL, NULL, NULL, NULL, NULL);
187 if (rc)
188 return rc;
191 sprintf (line, "SETHASH %d ", digestalgo);
192 p = line + strlen (line);
193 for (i=0; i < digestlen ; i++, p += 2 )
194 sprintf (p, "%02X", digest[i]);
195 rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
196 if (rc)
197 return rc;
199 init_membuf (&data, 1024);
200 rc = assuan_transact (agent_ctx, "PKSIGN",
201 membuf_data_cb, &data, default_inq_cb, ctrl,
202 NULL, NULL);
203 if (rc)
205 xfree (get_membuf (&data, &len));
206 return rc;
208 *r_buf = get_membuf (&data, r_buflen);
210 if (!gcry_sexp_canon_len (*r_buf, *r_buflen, NULL, NULL))
212 xfree (*r_buf); *r_buf = NULL;
213 return gpg_error (GPG_ERR_INV_VALUE);
216 return *r_buf? 0 : out_of_core ();
220 /* Call the scdaemon to do a sign operation using the key identified by
221 the hex string KEYID. */
223 gpgsm_scd_pksign (ctrl_t ctrl, const char *keyid, const char *desc,
224 unsigned char *digest, size_t digestlen, int digestalgo,
225 unsigned char **r_buf, size_t *r_buflen )
227 int rc, i;
228 char *p, line[ASSUAN_LINELENGTH];
229 membuf_t data;
230 size_t len;
231 const char *hashopt;
232 unsigned char *sigbuf;
233 size_t sigbuflen;
235 *r_buf = NULL;
237 switch(digestalgo)
239 case GCRY_MD_SHA1: hashopt = "--hash=sha1"; break;
240 case GCRY_MD_RMD160:hashopt = "--hash=rmd160"; break;
241 case GCRY_MD_MD5: hashopt = "--hash=md5"; break;
242 case GCRY_MD_SHA256:hashopt = "--hash=sha256"; break;
243 default:
244 return gpg_error (GPG_ERR_DIGEST_ALGO);
247 rc = start_agent (ctrl);
248 if (rc)
249 return rc;
251 if (digestlen*2 + 50 > DIM(line))
252 return gpg_error (GPG_ERR_GENERAL);
254 p = stpcpy (line, "SCD SETDATA " );
255 for (i=0; i < digestlen ; i++, p += 2 )
256 sprintf (p, "%02X", digest[i]);
257 rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
258 if (rc)
259 return rc;
261 init_membuf (&data, 1024);
263 snprintf (line, DIM(line)-1, "SCD PKSIGN %s %s", hashopt, keyid);
264 line[DIM(line)-1] = 0;
265 rc = assuan_transact (agent_ctx, line,
266 membuf_data_cb, &data, default_inq_cb, ctrl,
267 NULL, NULL);
268 if (rc)
270 xfree (get_membuf (&data, &len));
271 return rc;
273 sigbuf = get_membuf (&data, &sigbuflen);
275 /* Create an S-expression from it which is formatted like this:
276 "(7:sig-val(3:rsa(1:sSIGBUFLEN:SIGBUF)))" Fixme: If a card ever
277 creates non-RSA keys we need to change things. */
278 *r_buflen = 21 + 11 + sigbuflen + 4;
279 p = xtrymalloc (*r_buflen);
280 *r_buf = (unsigned char*)p;
281 if (!p)
283 xfree (sigbuf);
284 return 0;
286 p = stpcpy (p, "(7:sig-val(3:rsa(1:s" );
287 sprintf (p, "%u:", (unsigned int)sigbuflen);
288 p += strlen (p);
289 memcpy (p, sigbuf, sigbuflen);
290 p += sigbuflen;
291 strcpy (p, ")))");
292 xfree (sigbuf);
294 assert (gcry_sexp_canon_len (*r_buf, *r_buflen, NULL, NULL));
295 return 0;
301 /* Handle a CIPHERTEXT inquiry. Note, we only send the data,
302 assuan_transact talkes care of flushing and writing the end */
303 static int
304 inq_ciphertext_cb (void *opaque, const char *line)
306 struct cipher_parm_s *parm = opaque;
307 int rc;
309 if (!strncmp (line, "CIPHERTEXT", 10) && (line[10]==' '||!line[10]))
311 assuan_begin_confidential (parm->ctx);
312 rc = assuan_send_data (parm->ctx, parm->ciphertext, parm->ciphertextlen);
313 assuan_end_confidential (parm->ctx);
315 else
316 rc = default_inq_cb (parm->ctrl, line);
318 return rc;
322 /* Call the agent to do a decrypt operation using the key identified by
323 the hex string KEYGRIP. */
325 gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
326 ksba_const_sexp_t ciphertext,
327 char **r_buf, size_t *r_buflen )
329 int rc;
330 char line[ASSUAN_LINELENGTH];
331 membuf_t data;
332 struct cipher_parm_s cipher_parm;
333 size_t n, len;
334 char *p, *buf, *endp;
335 size_t ciphertextlen;
337 if (!keygrip || strlen(keygrip) != 40 || !ciphertext || !r_buf || !r_buflen)
338 return gpg_error (GPG_ERR_INV_VALUE);
339 *r_buf = NULL;
341 ciphertextlen = gcry_sexp_canon_len (ciphertext, 0, NULL, NULL);
342 if (!ciphertextlen)
343 return gpg_error (GPG_ERR_INV_VALUE);
345 rc = start_agent (ctrl);
346 if (rc)
347 return rc;
349 rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
350 if (rc)
351 return rc;
353 assert ( DIM(line) >= 50 );
354 snprintf (line, DIM(line)-1, "SETKEY %s", keygrip);
355 line[DIM(line)-1] = 0;
356 rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
357 if (rc)
358 return rc;
360 if (desc)
362 snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc);
363 line[DIM(line)-1] = 0;
364 rc = assuan_transact (agent_ctx, line,
365 NULL, NULL, NULL, NULL, NULL, NULL);
366 if (rc)
367 return rc;
370 init_membuf (&data, 1024);
371 cipher_parm.ctrl = ctrl;
372 cipher_parm.ctx = agent_ctx;
373 cipher_parm.ciphertext = ciphertext;
374 cipher_parm.ciphertextlen = ciphertextlen;
375 rc = assuan_transact (agent_ctx, "PKDECRYPT",
376 membuf_data_cb, &data,
377 inq_ciphertext_cb, &cipher_parm, NULL, NULL);
378 if (rc)
380 xfree (get_membuf (&data, &len));
381 return rc;
384 put_membuf (&data, "", 1); /* Make sure it is 0 terminated. */
385 buf = get_membuf (&data, &len);
386 if (!buf)
387 return gpg_error (GPG_ERR_ENOMEM);
388 assert (len); /* (we forced Nul termination.) */
390 if (*buf == '(')
392 if (len < 13 || memcmp (buf, "(5:value", 8) ) /* "(5:valueN:D)\0" */
393 return gpg_error (GPG_ERR_INV_SEXP);
394 len -= 11; /* Count only the data of the second part. */
395 p = buf + 8; /* Skip leading parenthesis and the value tag. */
397 else
399 /* For compatibility with older gpg-agents handle the old style
400 incomplete S-exps. */
401 len--; /* Do not count the Nul. */
402 p = buf;
405 n = strtoul (p, &endp, 10);
406 if (!n || *endp != ':')
407 return gpg_error (GPG_ERR_INV_SEXP);
408 endp++;
409 if (endp-p+n > len)
410 return gpg_error (GPG_ERR_INV_SEXP); /* Oops: Inconsistent S-Exp. */
412 memmove (buf, endp, n);
414 *r_buflen = n;
415 *r_buf = buf;
416 return 0;
423 /* Handle a KEYPARMS inquiry. Note, we only send the data,
424 assuan_transact takes care of flushing and writing the end */
425 static int
426 inq_genkey_parms (void *opaque, const char *line)
428 struct genkey_parm_s *parm = opaque;
429 int rc;
431 if (!strncmp (line, "KEYPARAM", 8) && (line[8]==' '||!line[8]))
433 rc = assuan_send_data (parm->ctx, parm->sexp, parm->sexplen);
435 else
436 rc = default_inq_cb (parm->ctrl, line);
438 return rc;
443 /* Call the agent to generate a newkey */
445 gpgsm_agent_genkey (ctrl_t ctrl,
446 ksba_const_sexp_t keyparms, ksba_sexp_t *r_pubkey)
448 int rc;
449 struct genkey_parm_s gk_parm;
450 membuf_t data;
451 size_t len;
452 unsigned char *buf;
454 *r_pubkey = NULL;
455 rc = start_agent (ctrl);
456 if (rc)
457 return rc;
459 rc = assuan_transact (agent_ctx, "RESET", NULL, NULL, NULL, NULL, NULL, NULL);
460 if (rc)
461 return rc;
463 init_membuf (&data, 1024);
464 gk_parm.ctrl = ctrl;
465 gk_parm.ctx = agent_ctx;
466 gk_parm.sexp = keyparms;
467 gk_parm.sexplen = gcry_sexp_canon_len (keyparms, 0, NULL, NULL);
468 if (!gk_parm.sexplen)
469 return gpg_error (GPG_ERR_INV_VALUE);
470 rc = assuan_transact (agent_ctx, "GENKEY",
471 membuf_data_cb, &data,
472 inq_genkey_parms, &gk_parm, NULL, NULL);
473 if (rc)
475 xfree (get_membuf (&data, &len));
476 return rc;
478 buf = get_membuf (&data, &len);
479 if (!buf)
480 return gpg_error (GPG_ERR_ENOMEM);
481 if (!gcry_sexp_canon_len (buf, len, NULL, NULL))
483 xfree (buf);
484 return gpg_error (GPG_ERR_INV_SEXP);
486 *r_pubkey = buf;
487 return 0;
491 /* Call the agent to read the public key part for a given keygrip. If
492 FROMCARD is true, the key is directly read from the current
493 smartcard. In this case HEXKEYGRIP should be the keyID
494 (e.g. OPENPGP.3). */
496 gpgsm_agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip,
497 ksba_sexp_t *r_pubkey)
499 int rc;
500 membuf_t data;
501 size_t len;
502 unsigned char *buf;
503 char line[ASSUAN_LINELENGTH];
505 *r_pubkey = NULL;
506 rc = start_agent (ctrl);
507 if (rc)
508 return rc;
510 rc = assuan_transact (agent_ctx, "RESET",NULL, NULL, NULL, NULL, NULL, NULL);
511 if (rc)
512 return rc;
514 snprintf (line, DIM(line)-1, "%sREADKEY %s",
515 fromcard? "SCD ":"", hexkeygrip);
516 line[DIM(line)-1] = 0;
518 init_membuf (&data, 1024);
519 rc = assuan_transact (agent_ctx, line,
520 membuf_data_cb, &data,
521 default_inq_cb, ctrl, NULL, NULL);
522 if (rc)
524 xfree (get_membuf (&data, &len));
525 return rc;
527 buf = get_membuf (&data, &len);
528 if (!buf)
529 return gpg_error (GPG_ERR_ENOMEM);
530 if (!gcry_sexp_canon_len (buf, len, NULL, NULL))
532 xfree (buf);
533 return gpg_error (GPG_ERR_INV_SEXP);
535 *r_pubkey = buf;
536 return 0;
541 static int
542 istrusted_status_cb (void *opaque, const char *line)
544 struct rootca_flags_s *flags = opaque;
546 if (!strncmp (line, "TRUSTLISTFLAG", 13) && (line[13]==' ' || !line[13]))
548 for (line += 13; *line == ' '; line++)
550 if (!strncmp (line, "relax", 5) && (line[5] == ' ' || !line[5]))
551 flags->relax = 1;
552 else if (!strncmp (line, "cm", 2) && (line[2] == ' ' || !line[2]))
553 flags->chain_model = 1;
555 return 0;
560 /* Ask the agent whether the certificate is in the list of trusted
561 keys. ROOTCA_FLAGS is guaranteed to be cleared on error. */
563 gpgsm_agent_istrusted (ctrl_t ctrl, ksba_cert_t cert,
564 struct rootca_flags_s *rootca_flags)
566 int rc;
567 char *fpr;
568 char line[ASSUAN_LINELENGTH];
570 memset (rootca_flags, 0, sizeof *rootca_flags);
572 rc = start_agent (ctrl);
573 if (rc)
574 return rc;
576 fpr = gpgsm_get_fingerprint_hexstring (cert, GCRY_MD_SHA1);
577 if (!fpr)
579 log_error ("error getting the fingerprint\n");
580 return gpg_error (GPG_ERR_GENERAL);
583 snprintf (line, DIM(line)-1, "ISTRUSTED %s", fpr);
584 line[DIM(line)-1] = 0;
585 xfree (fpr);
587 rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL,
588 istrusted_status_cb, rootca_flags);
589 if (!rc)
590 rootca_flags->valid = 1;
591 return rc;
594 /* Ask the agent to mark CERT as a trusted Root-CA one */
596 gpgsm_agent_marktrusted (ctrl_t ctrl, ksba_cert_t cert)
598 int rc;
599 char *fpr, *dn;
600 char line[ASSUAN_LINELENGTH];
602 rc = start_agent (ctrl);
603 if (rc)
604 return rc;
606 fpr = gpgsm_get_fingerprint_hexstring (cert, GCRY_MD_SHA1);
607 if (!fpr)
609 log_error ("error getting the fingerprint\n");
610 return gpg_error (GPG_ERR_GENERAL);
613 dn = ksba_cert_get_issuer (cert, 0);
614 if (!dn)
616 xfree (fpr);
617 return gpg_error (GPG_ERR_GENERAL);
619 snprintf (line, DIM(line)-1, "MARKTRUSTED %s S %s", fpr, dn);
620 line[DIM(line)-1] = 0;
621 ksba_free (dn);
622 xfree (fpr);
624 rc = assuan_transact (agent_ctx, line, NULL, NULL,
625 default_inq_cb, ctrl, NULL, NULL);
626 return rc;
631 /* Ask the agent whether the a corresponding secret key is available
632 for the given keygrip */
634 gpgsm_agent_havekey (ctrl_t ctrl, const char *hexkeygrip)
636 int rc;
637 char line[ASSUAN_LINELENGTH];
639 rc = start_agent (ctrl);
640 if (rc)
641 return rc;
643 if (!hexkeygrip || strlen (hexkeygrip) != 40)
644 return gpg_error (GPG_ERR_INV_VALUE);
646 snprintf (line, DIM(line)-1, "HAVEKEY %s", hexkeygrip);
647 line[DIM(line)-1] = 0;
649 rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL, NULL, NULL);
650 return rc;
654 static int
655 learn_cb (void *opaque, const void *buffer, size_t length)
657 struct learn_parm_s *parm = opaque;
658 size_t len;
659 char *buf;
660 ksba_cert_t cert;
661 int rc;
663 if (parm->error)
664 return 0;
666 if (buffer)
668 put_membuf (parm->data, buffer, length);
669 return 0;
671 /* END encountered - process what we have */
672 buf = get_membuf (parm->data, &len);
673 if (!buf)
675 parm->error = gpg_error (GPG_ERR_ENOMEM);
676 return 0;
680 /* FIXME: this should go into import.c */
681 rc = ksba_cert_new (&cert);
682 if (rc)
684 parm->error = rc;
685 return 0;
687 rc = ksba_cert_init_from_mem (cert, buf, len);
688 if (rc)
690 log_error ("failed to parse a certificate: %s\n", gpg_strerror (rc));
691 ksba_cert_release (cert);
692 parm->error = rc;
693 return 0;
696 rc = gpgsm_basic_cert_check (parm->ctrl, cert);
697 if (gpg_err_code (rc) == GPG_ERR_MISSING_CERT)
698 { /* For later use we store it in the ephemeral database. */
699 log_info ("issuer certificate missing - storing as ephemeral\n");
700 keydb_store_cert (cert, 1, NULL);
702 else if (rc)
703 log_error ("invalid certificate: %s\n", gpg_strerror (rc));
704 else
706 int existed;
708 if (!keydb_store_cert (cert, 0, &existed))
710 if (opt.verbose > 1 && existed)
711 log_info ("certificate already in DB\n");
712 else if (opt.verbose && !existed)
713 log_info ("certificate imported\n");
717 ksba_cert_release (cert);
718 init_membuf (parm->data, 4096);
719 return 0;
722 /* Call the agent to learn about a smartcard */
724 gpgsm_agent_learn (ctrl_t ctrl)
726 int rc;
727 struct learn_parm_s learn_parm;
728 membuf_t data;
729 size_t len;
731 rc = start_agent (ctrl);
732 if (rc)
733 return rc;
735 init_membuf (&data, 4096);
736 learn_parm.error = 0;
737 learn_parm.ctrl = ctrl;
738 learn_parm.ctx = agent_ctx;
739 learn_parm.data = &data;
740 rc = assuan_transact (agent_ctx, "LEARN --send",
741 learn_cb, &learn_parm,
742 NULL, NULL, NULL, NULL);
743 xfree (get_membuf (&data, &len));
744 if (rc)
745 return rc;
746 return learn_parm.error;
750 /* Ask the agent to change the passphrase of the key identified by
751 HEXKEYGRIP. If DESC is not NULL, display instead of the default
752 description message. */
754 gpgsm_agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc)
756 int rc;
757 char line[ASSUAN_LINELENGTH];
759 rc = start_agent (ctrl);
760 if (rc)
761 return rc;
763 if (!hexkeygrip || strlen (hexkeygrip) != 40)
764 return gpg_error (GPG_ERR_INV_VALUE);
766 if (desc)
768 snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc);
769 line[DIM(line)-1] = 0;
770 rc = assuan_transact (agent_ctx, line,
771 NULL, NULL, NULL, NULL, NULL, NULL);
772 if (rc)
773 return rc;
776 snprintf (line, DIM(line)-1, "PASSWD %s", hexkeygrip);
777 line[DIM(line)-1] = 0;
779 rc = assuan_transact (agent_ctx, line, NULL, NULL,
780 default_inq_cb, ctrl, NULL, NULL);
781 return rc;
786 /* Ask the agent to pop up a confirmation dialog with the text DESC
787 and an okay and cancel button. */
788 gpg_error_t
789 gpgsm_agent_get_confirmation (ctrl_t ctrl, const char *desc)
791 int rc;
792 char line[ASSUAN_LINELENGTH];
794 rc = start_agent (ctrl);
795 if (rc)
796 return rc;
798 snprintf (line, DIM(line)-1, "GET_CONFIRMATION %s", desc);
799 line[DIM(line)-1] = 0;
801 rc = assuan_transact (agent_ctx, line, NULL, NULL,
802 default_inq_cb, ctrl, NULL, NULL);
803 return rc;