aboutsummaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2010-03-24 12:15:30 +0000
committerWerner Koch <[email protected]>2010-03-24 12:15:30 +0000
commitf080b353ed4ea5c16ad3fda79497a0ebe3be9a7d (patch)
treece173438e276aa2ac40a254e557219ce1a25ba23 /sm
parentReorganized the exechelp code. (diff)
downloadgnupg-f080b353ed4ea5c16ad3fda79497a0ebe3be9a7d.tar.gz
gnupg-f080b353ed4ea5c16ad3fda79497a0ebe3be9a7d.zip
More changes for CE. gpgsm does now build and run a keylisting.
Diffstat (limited to 'sm')
-rw-r--r--sm/ChangeLog14
-rw-r--r--sm/Makefile.am3
-rw-r--r--sm/certdump.c10
-rw-r--r--sm/export.c24
-rw-r--r--sm/gpgsm.c4
-rw-r--r--sm/import.c27
-rw-r--r--sm/qualified.c6
-rw-r--r--sm/server.c4
8 files changed, 55 insertions, 37 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index c47aa464f..d1c4becec 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,17 @@
+2010-03-24 Werner Koch <[email protected]>
+
+ * Makefile.am (gpgsm_LDADD): Add extra_sys_libs.
+
+2010-03-23 Werner Koch <[email protected]>
+
+ * qualified.c (gpgsm_is_in_qualified_list): Replace rewind by
+ fseek+clearerr.
+
+2010-03-22 Werner Koch <[email protected]>
+
+ * import.c (parse_p12): Use estream functions for the tmp streams.
+ * export.c (export_p12): Ditto.
+
2010-03-11 Werner Koch <[email protected]>
* verify.c (gpgsm_verify): Use gpgsm_es_print_name.
diff --git a/sm/Makefile.am b/sm/Makefile.am
index ba194811d..2754b8535 100644
--- a/sm/Makefile.am
+++ b/sm/Makefile.am
@@ -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.
diff --git a/sm/certdump.c b/sm/certdump.c
index d3390702d..6d7d5b68e 100644
--- a/sm/certdump.c
+++ b/sm/certdump.c
@@ -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;
diff --git a/sm/export.c b/sm/export.c
index 2c8e57b5d..61d827b9b 100644
--- a/sm/export.c
+++ b/sm/export.c
@@ -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)
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index 1ce3797d2..cf4eafa25 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -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));
diff --git a/sm/import.c b/sm/import.c
index b2383d80f..71cefff65 100644
--- a/sm/import.c
+++ b/sm/import.c
@@ -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))
diff --git a/sm/qualified.c b/sm/qualified.c
index d0db481b6..bb8e78f7f 100644
--- a/sm/qualified.c
+++ b/sm/qualified.c
@@ -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))
diff --git a/sm/server.c b/sm/server.c
index bdba6393e..072064539 100644
--- a/sm/server.c
+++ b/sm/server.c
@@ -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;
}