mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Updated estream.
More changes for Windows.
This commit is contained in:
parent
a5743d1017
commit
f81f521a72
23 changed files with 508 additions and 281 deletions
17
sm/ChangeLog
17
sm/ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2007-08-22 Werner Koch <wk@g10code.com>
|
||||
|
||||
* certreqgen-ui.c (gpgsm_gencertreq_tty): Use es_fopenmem.
|
||||
|
||||
2007-08-21 Werner Koch <wk@g10code.com>
|
||||
|
||||
* import.c (parse_p12): Use gnupg_tmpfile.
|
||||
* export.c (export_p12): Ditto.
|
||||
|
||||
2007-08-20 Werner Koch <wk@g10code.com>
|
||||
|
||||
* certreqgen.c (read_parameters): Change FP to an estream_t.
|
||||
(gpgsm_genkey): Replace in_fd and in_stream by a estream_t.
|
||||
* server.c (cmd_genkey): Adjust for that.
|
||||
* certreqgen-ui.c (gpgsm_gencertreq_tty): Use es_open_memstream
|
||||
instead of a temporary file.
|
||||
|
||||
2007-08-14 Werner Koch <wk@g10code.com>
|
||||
|
||||
* call-dirmngr.c (start_dirmngr): Use dirmngr_socket_name. change
|
||||
|
|
|
@ -97,7 +97,7 @@ gpgsm_gencertreq_tty (ctrl_t ctrl, FILE *output_fp)
|
|||
gpg_error_t err;
|
||||
char *answer;
|
||||
int selection;
|
||||
FILE *fp = NULL;
|
||||
estream_t fp = NULL;
|
||||
int method;
|
||||
char *keytype;
|
||||
char *keygrip = NULL;
|
||||
|
@ -278,20 +278,20 @@ gpgsm_gencertreq_tty (ctrl_t ctrl, FILE *output_fp)
|
|||
goto leave;
|
||||
|
||||
/* Now create a parameter file and generate the key. */
|
||||
fp = tmpfile ();
|
||||
fp = es_fopenmem (0, "w+");
|
||||
if (!fp)
|
||||
{
|
||||
log_error (_("error creating temporary file: %s\n"), strerror (errno));
|
||||
goto leave;
|
||||
}
|
||||
fputs (result, fp);
|
||||
rewind (fp);
|
||||
es_fputs (result, fp);
|
||||
es_rewind (fp);
|
||||
tty_printf (_("Now creating certificate request. "
|
||||
"This may take a while ...\n"));
|
||||
{
|
||||
int save_pem = ctrl->create_pem;
|
||||
ctrl->create_pem = 1; /* Force creation of PEM. */
|
||||
err = gpgsm_genkey (ctrl, -1, fp, output_fp);
|
||||
err = gpgsm_genkey (ctrl, fp, output_fp);
|
||||
ctrl->create_pem = save_pem;
|
||||
}
|
||||
if (!err)
|
||||
|
@ -302,8 +302,7 @@ gpgsm_gencertreq_tty (ctrl_t ctrl, FILE *output_fp)
|
|||
mem_error:
|
||||
log_error (_("resource problem: out or core\n"));
|
||||
leave:
|
||||
if (fp)
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
xfree (keytype);
|
||||
xfree (subject_name);
|
||||
xfree (keygrip);
|
||||
|
|
|
@ -247,7 +247,7 @@ get_parameter_uint (struct para_data_s *para, enum para_name key)
|
|||
/* Read the certificate generation parameters from FP and generate
|
||||
(all) certificate requests. */
|
||||
static int
|
||||
read_parameters (ctrl_t ctrl, FILE *fp, ksba_writer_t writer)
|
||||
read_parameters (ctrl_t ctrl, estream_t fp, ksba_writer_t writer)
|
||||
{
|
||||
static struct {
|
||||
const char *name;
|
||||
|
@ -275,7 +275,7 @@ read_parameters (ctrl_t ctrl, FILE *fp, ksba_writer_t writer)
|
|||
|
||||
err = NULL;
|
||||
para = NULL;
|
||||
while (fgets (line, DIM(line)-1, fp) )
|
||||
while (es_fgets (line, DIM(line)-1, fp) )
|
||||
{
|
||||
char *keyword, *value;
|
||||
|
||||
|
@ -391,7 +391,7 @@ read_parameters (ctrl_t ctrl, FILE *fp, ksba_writer_t writer)
|
|||
log_error ("line %d: %s\n", outctrl.lnr, err);
|
||||
rc = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
else if (ferror(fp))
|
||||
else if (es_ferror(fp))
|
||||
{
|
||||
log_error ("line %d: read error: %s\n", outctrl.lnr, strerror(errno) );
|
||||
rc = gpg_error (GPG_ERR_GENERAL);
|
||||
|
@ -829,27 +829,15 @@ create_request (ctrl_t ctrl,
|
|||
|
||||
|
||||
|
||||
/* Create a new key by reading the parameters from in_fd or in_stream.
|
||||
Multiple keys may be created */
|
||||
/* Create a new key by reading the parameters from IN_FP. Multiple
|
||||
keys may be created */
|
||||
int
|
||||
gpgsm_genkey (ctrl_t ctrl, int in_fd, FILE *in_stream, FILE *out_fp)
|
||||
gpgsm_genkey (ctrl_t ctrl, estream_t in_stream, FILE *out_fp)
|
||||
{
|
||||
int rc;
|
||||
FILE *in_fp;
|
||||
Base64Context b64writer = NULL;
|
||||
ksba_writer_t writer;
|
||||
|
||||
if (in_stream)
|
||||
in_fp = in_stream;
|
||||
else
|
||||
in_fp = fdopen (dup (in_fd), "rb");
|
||||
if (!in_fp)
|
||||
{
|
||||
gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
|
||||
log_error ("fdopen() failed: %s\n", strerror (errno));
|
||||
return tmperr;
|
||||
}
|
||||
|
||||
ctrl->pem_name = "CERTIFICATE REQUEST";
|
||||
rc = gpgsm_create_writer (&b64writer, ctrl, out_fp, NULL, &writer);
|
||||
if (rc)
|
||||
|
@ -858,7 +846,7 @@ gpgsm_genkey (ctrl_t ctrl, int in_fd, FILE *in_stream, FILE *out_fp)
|
|||
goto leave;
|
||||
}
|
||||
|
||||
rc = read_parameters (ctrl, in_fp, writer);
|
||||
rc = read_parameters (ctrl, in_stream, writer);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("error creating certificate request: %s <%s>\n",
|
||||
|
@ -878,8 +866,6 @@ gpgsm_genkey (ctrl_t ctrl, int in_fd, FILE *in_stream, FILE *out_fp)
|
|||
|
||||
leave:
|
||||
gpgsm_destroy_writer (b64writer);
|
||||
if (!in_stream)
|
||||
fclose (in_fp);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "keydb.h"
|
||||
#include "exechelp.h"
|
||||
#include "i18n.h"
|
||||
#include "sysutils.h"
|
||||
|
||||
|
||||
|
||||
|
@ -606,7 +607,7 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
|
|||
else
|
||||
pgmname = opt.protect_tool_program;
|
||||
|
||||
infp = tmpfile ();
|
||||
infp = gnupg_tmpfile ();
|
||||
if (!infp)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
|
@ -622,7 +623,7 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
outfp = tmpfile ();
|
||||
outfp = gnupg_tmpfile ();
|
||||
if (!outfp)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
|
|
|
@ -325,7 +325,7 @@ int gpgsm_encrypt (ctrl_t ctrl, certlist_t recplist, int in_fd, FILE *out_fp);
|
|||
int gpgsm_decrypt (ctrl_t ctrl, int in_fd, FILE *out_fp);
|
||||
|
||||
/*-- certreqgen.c --*/
|
||||
int gpgsm_genkey (ctrl_t ctrl, int in_fd, FILE *in_stream, FILE *out_fp);
|
||||
int gpgsm_genkey (ctrl_t ctrl, estream_t in_stream, FILE *out_fp);
|
||||
|
||||
/*-- certreqgen-ui.c --*/
|
||||
void gpgsm_gencertreq_tty (ctrl_t ctrl, FILE *out_fp);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "keydb.h"
|
||||
#include "exechelp.h"
|
||||
#include "i18n.h"
|
||||
#include "sysutils.h"
|
||||
|
||||
struct stats_s {
|
||||
unsigned long count;
|
||||
|
@ -517,7 +518,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
|
|||
gpg-protect-tool will anyway parse the entire pkcs#12 message in
|
||||
memory, we simply use tempfiles here and pass them to
|
||||
the gpg-protect-tool. */
|
||||
tmpfp = tmpfile ();
|
||||
tmpfp = gnupg_tmpfile ();
|
||||
if (!tmpfp)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
|
@ -542,7 +543,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
certfp = tmpfile ();
|
||||
certfp = gnupg_tmpfile ();
|
||||
if (!certfp)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
|
|
12
sm/server.c
12
sm/server.c
|
@ -863,6 +863,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||
int inp_fd, out_fd;
|
||||
FILE *out_fp;
|
||||
int rc;
|
||||
estream_t in_stream;
|
||||
|
||||
inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
|
||||
if (inp_fd == -1)
|
||||
|
@ -871,10 +872,17 @@ cmd_genkey (assuan_context_t ctx, char *line)
|
|||
if (out_fd == -1)
|
||||
return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
|
||||
|
||||
in_stream = es_fdopen_nc (inp_fd, "r");
|
||||
if (!in_stream)
|
||||
return set_error (GPG_ERR_ASS_GENERAL, "es_fdopen failed");
|
||||
|
||||
out_fp = fdopen ( dup(out_fd), "w");
|
||||
if (!out_fp)
|
||||
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
|
||||
rc = gpgsm_genkey (ctrl, inp_fd, NULL, out_fp);
|
||||
{
|
||||
es_fclose (in_stream);
|
||||
return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");
|
||||
}
|
||||
rc = gpgsm_genkey (ctrl, in_stream, out_fp);
|
||||
fclose (out_fp);
|
||||
|
||||
/* close and reset the fds */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue