int any; /* any data line seen */
} colon;
+ gpgme_data_t inline_data; /* Used to collect D lines. */
+
struct gpgme_io_cbs io_cbs;
};
gpgsm->colon.attic.linelen = 0;
gpgsm->colon.any = 0;
+ gpgsm->inline_data = NULL;
+
gpgsm->io_cbs.add = NULL;
gpgsm->io_cbs.add_priv = NULL;
gpgsm->io_cbs.remove = NULL;
char **aline = &gpgsm->colon.attic.line;
int *alinelen = &gpgsm->colon.attic.linelen;
- if (gpgsm->colon.attic.linesize
- < *alinelen + linelen + 1)
+ if (gpgsm->colon.attic.linesize < *alinelen + linelen + 1)
{
char *newline = realloc (*aline, *alinelen + linelen + 1);
if (!newline)
"fd 0x%x: D line; final status: %s",
fd, err? gpg_strerror (err):"ok");
}
+ else if (linelen > 2
+ && line[0] == 'D' && line[1] == ' '
+ && gpgsm->inline_data)
+ {
+ char *src = line + 2;
+ char *end = line + linelen;
+ char *dst = src;
+ ssize_t nwritten;
+
+ linelen = 0;
+ while (src < end)
+ {
+ if (*src == '%' && src + 2 < end)
+ {
+ /* Handle escaped characters. */
+ ++src;
+ *dst++ = _gpgme_hextobyte (src);
+ src += 2;
+ }
+ else
+ *dst++ = *src++;
+
+ linelen++;
+ }
+
+ src = line + 2;
+ while (linelen > 0)
+ {
+ nwritten = gpgme_data_write (gpgsm->inline_data, src, linelen);
+ if (!nwritten || (nwritten < 0 && errno != EINTR)
+ || nwritten > linelen)
+ {
+ err = gpg_error_from_errno (errno);
+ break;
+ }
+ src += nwritten;
+ linelen -= nwritten;
+ }
+
+ TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
+ "fd 0x%x: D inlinedata; final status: %s",
+ fd, err? gpg_strerror (err):"ok");
+ }
else if (linelen > 2
&& line[0] == 'S' && line[1] == ' ')
{
if (err)
return gpg_error (GPG_ERR_GENERAL); /* FIXME */
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (engine, "DECRYPT");
return err;
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, line);
free (line);
if (err)
return err;
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = set_recipients (gpgsm, recp);
return err;
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, cmd);
free (cmd);
return err;
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, line);
free (line);
if (err)
return err;
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, "GENKEY");
return err;
return err;
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, "IMPORT");
return err;
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, line);
free (line);
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, line);
free (line);
if (err)
return err;
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, mode == GPGME_SIG_MODE_DETACH
? "SIGN --detached" : "SIGN");
err = gpgsm_set_fd (gpgsm, MESSAGE_FD, 0);
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
}
+ gpgsm->inline_data = NULL;
if (!err)
err = start (gpgsm, "VERIFY");
if (!gpgsm || !output)
return gpg_error (GPG_ERR_INV_VALUE);
+#if USE_DESCRIPTOR_PASSING
gpgsm->output_cb.data = output;
err = gpgsm_set_fd (gpgsm, OUTPUT_FD, 0);
if (err)
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
+# define CMD "GETAUDITLOG"
+#else
+ gpgsm_clear_fd (gpgsm, OUTPUT_FD);
+ gpgsm_clear_fd (gpgsm, INPUT_FD);
+ gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = output;
+# define CMD "GETAUDITLOG --data"
+#endif
- err = start (gpgsm, "GETAUDITLOG");
+ err = start (gpgsm, (flags & GPGME_AUDITLOG_HTML)? CMD " --html" : CMD);
return err;
}