1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

More changes for CE. gpgsm does now build and run a keylisting.

This commit is contained in:
Werner Koch 2010-03-24 12:15:30 +00:00
parent d1591a97f4
commit f080b353ed
28 changed files with 595 additions and 329 deletions

View file

@ -1,3 +1,17 @@
2010-03-24 Werner Koch <wk@g10code.com>
* Makefile.am (gpgsm_LDADD): Add extra_sys_libs.
2010-03-23 Werner Koch <wk@g10code.com>
* qualified.c (gpgsm_is_in_qualified_list): Replace rewind by
fseek+clearerr.
2010-03-22 Werner Koch <wk@g10code.com>
* import.c (parse_p12): Use estream functions for the tmp streams.
* export.c (export_p12): Ditto.
2010-03-11 Werner Koch <wk@g10code.com>
* verify.c (gpgsm_verify): Use gpgsm_es_print_name.

View file

@ -56,7 +56,8 @@ common_libs = ../kbx/libkeybox.a $(libcommon) ../gl/libgnu.a
gpgsm_LDADD = $(common_libs) ../common/libgpgrl.a \
$(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) \
$(GPG_ERROR_LIBS) $(LIBREADLINE) $(LIBINTL) $(ZLIBS) $(LIBICONV)
$(GPG_ERROR_LIBS) $(LIBREADLINE) $(LIBINTL) $(ZLIBS) \
$(LIBICONV) $(extra_sys_libs)
# Make sure that all libs are build before we use them. This is
# important for things like make -j2.

View file

@ -786,7 +786,7 @@ format_name_writer (void *cookie, const void *buffer, size_t size)
else if (c->len + size < c->len)
{
p = NULL;
errno = ENOMEM;
gpg_err_set_errno (ENOMEM);
}
else if (c->size < c->len + size)
{
@ -804,7 +804,7 @@ format_name_writer (void *cookie, const void *buffer, size_t size)
c->error = errno;
xfree (c->buffer);
c->buffer = NULL;
errno = c->error;
gpg_err_set_errno (c->error);
return -1;
}
memcpy (p + c->len, buffer, size);
@ -834,8 +834,8 @@ gpgsm_format_name2 (const char *name, int translate)
if (!fp)
{
int save_errno = errno;
log_error ("error creating memory stream: %s\n", strerror (errno));
errno = save_errno;
log_error ("error creating memory stream: %s\n", strerror (save_errno));
gpg_err_set_errno (save_errno);
return NULL;
}
gpgsm_es_print_name2 (fp, name, translate);
@ -843,7 +843,7 @@ gpgsm_format_name2 (const char *name, int translate)
if (cookie.error || !cookie.buffer)
{
xfree (cookie.buffer);
errno = cookie.error;
gpg_err_set_errno (cookie.error);
return NULL;
}
return cookie.buffer;

View file

@ -561,7 +561,8 @@ print_short_info (ksba_cert_t cert, FILE *fp, estream_t stream)
static gpg_error_t
popen_protect_tool (ctrl_t ctrl, const char *pgmname,
FILE *infile, estream_t outfile, FILE **statusfile,
estream_t infile, estream_t outfile,
estream_t *statusfile,
const char *prompt, const char *keygrip,
pid_t *pid)
{
@ -611,7 +612,8 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
gpg_error_t err = 0, child_err = 0;
int c, cont_line;
unsigned int pos;
FILE *infp = NULL, *fp = NULL;
estream_t infp = NULL;
estream_t fp = NULL;
estream_t outfp = NULL;
char buffer[1024];
pid_t pid = -1;
@ -622,7 +624,7 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
else
pgmname = opt.protect_tool_program;
infp = gnupg_tmpfile ();
infp = es_tmpfile ();
if (!infp)
{
err = gpg_error_from_syserror ();
@ -630,7 +632,7 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
goto cleanup;
}
if (fwrite (certimg, certimglen, 1, infp) != 1)
if (es_fwrite (certimg, certimglen, 1, infp) != 1)
{
err = gpg_error_from_syserror ();
log_error (_("error writing to temporary file: %s\n"),
@ -653,13 +655,13 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
pid = -1;
goto cleanup;
}
fclose (infp);
es_fclose (infp);
infp = NULL;
/* Read stderr of the protect tool. */
pos = 0;
cont_line = 0;
while ((c=getc (fp)) != EOF)
while ((c=es_getc (fp)) != EOF)
{
/* fixme: We could here grep for status information of the
protect tool to figure out better error codes for
@ -709,10 +711,8 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
child_err = gpg_error (GPG_ERR_DECRYPT_FAILED);
cleanup:
if (infp)
fclose (infp);
if (fp)
fclose (fp);
es_fclose (infp);
es_fclose (fp);
if (pid != -1)
{
if (!gnupg_wait_process (pgmname, pid, NULL))
@ -721,9 +721,7 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
if (!err)
err = child_err;
if (err)
{
es_fclose (outfp);
}
es_fclose (outfp);
else
*retfp = outfp;
if (bad_pass)

View file

@ -1969,6 +1969,7 @@ static void
emergency_cleanup (void)
{
gcry_control (GCRYCTL_TERM_SECMEM );
gnupg_sleep (2);
}
@ -2105,7 +2106,8 @@ open_fwrite (const char *filename)
fd = check_special_filename (filename, 1);
if (fd != -1)
{
fp = fdopen (dup (fd), "wb");
#warning replace the line below
fp = NULL; /*fdopen (dup (fd), "wb"); */
if (!fp)
{
log_error ("fdopen(%d) failed: %s\n", fd, strerror (errno));

View file

@ -1,5 +1,5 @@
/* import.c - Import certificates
* Copyright (C) 2001, 2003, 2004, 2009 Free Software Foundation, Inc.
* Copyright (C) 2001, 2003, 2004, 2009, 2010 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@ -578,14 +578,14 @@ gpgsm_import_files (ctrl_t ctrl, int nfiles, char **files,
}
/* Fork and exec the protecttool, connect the file descriptor of
INFILE to stdin, return a new stream in STATUSFILE, write the
/* Fork and exec the protect tool, connect the file descriptor of
INFILE to stdin, return a new estream in STATUSFILE, write the
output to OUTFILE and the pid of the process in PID. Returns 0 on
success or an error code. */
static gpg_error_t
popen_protect_tool (ctrl_t ctrl, const char *pgmname,
FILE *infile, estream_t outfile,
FILE **statusfile, pid_t *pid)
estream_t infile, estream_t outfile,
estream_t *statusfile, pid_t *pid)
{
const char *argv[22];
int i=0;
@ -637,7 +637,8 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
gpg_error_t err = 0, child_err = 0;
int c, cont_line;
unsigned int pos;
FILE *tmpfp, *fp = NULL;
estream_t tmpfp;
estream_t fp = NULL;
estream_t certfp = NULL;
char buffer[1024];
size_t nread;
@ -655,7 +656,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 = gnupg_tmpfile ();
tmpfp = es_tmpfile ();
if (!tmpfp)
{
err = gpg_error_from_syserror ();
@ -664,7 +665,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
}
while (!(err = ksba_reader_read (reader, buffer, sizeof buffer, &nread)))
{
if (nread && fwrite (buffer, nread, 1, tmpfp) != 1)
if (nread && es_fwrite (buffer, nread, 1, tmpfp) != 1)
{
err = gpg_error_from_syserror ();
log_error (_("error writing to temporary file: %s\n"),
@ -694,13 +695,13 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
pid = -1;
goto cleanup;
}
fclose (tmpfp);
es_fclose (tmpfp);
tmpfp = NULL;
/* Read stderr of the protect tool. */
pos = 0;
cont_line = 0;
while ((c=getc (fp)) != EOF)
while ((c=es_getc (fp)) != EOF)
{
/* fixme: We could here grep for status information of the
protect tool to figure out better error codes for
@ -768,10 +769,8 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
child_err = gpg_error (GPG_ERR_DECRYPT_FAILED);
cleanup:
if (tmpfp)
fclose (tmpfp);
if (fp)
fclose (fp);
es_fclose (tmpfp);
es_fclose (fp);
if (pid != -1)
{
if (!gnupg_wait_process (pgmname, pid, NULL))

View file

@ -161,7 +161,11 @@ gpgsm_is_in_qualified_list (ctrl_t ctrl, ksba_cert_t cert, char *country)
return gpg_error (GPG_ERR_GENERAL);
if (listfp)
rewind (listfp);
{
/* W32ce has no rewind, thus we use the equivalent code. */
fseek (listfp, 0, SEEK_SET);
clearerr (listfp);
}
while (!(err = read_list (key, mycountry, &lnr)))
{
if (!strcmp (key, fpr))

View file

@ -136,7 +136,7 @@ data_line_cookie_write (void *cookie, const void *buffer, size_t size)
if (assuan_send_data (ctx, buffer, size))
{
errno = EIO;
gpg_err_set_errno (EIO);
return -1;
}
@ -150,7 +150,7 @@ data_line_cookie_close (void *cookie)
if (assuan_send_data (ctx, NULL, 0))
{
errno = EIO;
gpg_err_set_errno (EIO);
return -1;
}