summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2006-09-14 18:50:33 +0200
committerWerner Koch <wk@gnupg.org>2006-09-14 18:50:33 +0200
commit03d3322e5fb928d48ea4192fd2f2cc851d791421 (patch)
tree768acc2e54f6e4abcc405e665bf058aa1556d3f5
parentVarious fixes and new features. (diff)
downloadgnupg2-03d3322e5fb928d48ea4192fd2f2cc851d791421.tar.xz
gnupg2-03d3322e5fb928d48ea4192fd2f2cc851d791421.zip
Take advantage of newer gpg-error features.
-rw-r--r--ChangeLog8
-rw-r--r--Makefile.am2
-rw-r--r--NEWS2
-rw-r--r--README4
-rw-r--r--acinclude.m419
-rw-r--r--agent/ChangeLog11
-rw-r--r--agent/call-pinentry.c6
-rw-r--r--agent/call-scd.c6
-rw-r--r--agent/command-ssh.c80
-rw-r--r--agent/command.c8
-rw-r--r--agent/divert-scd.c4
-rw-r--r--agent/findkey.c18
-rw-r--r--agent/preset-passphrase.c10
-rw-r--r--common/ChangeLog8
-rw-r--r--common/asshelp.c6
-rw-r--r--common/b64enc.c6
-rw-r--r--common/exechelp.c14
-rw-r--r--common/http.c62
-rw-r--r--common/iobuf.c16
-rw-r--r--common/miscellaneous.c2
-rw-r--r--common/util.h4
-rw-r--r--configure.ac7
-rw-r--r--g10/ChangeLog5
-rw-r--r--g10/call-agent.c16
-rw-r--r--g10/dearmor.c4
-rw-r--r--g10/decrypt.c2
-rw-r--r--g10/encode.c4
-rw-r--r--g10/exec.c8
-rw-r--r--g10/gpg.c2
-rw-r--r--g10/keydb.c4
-rw-r--r--g10/keygen.c2
-rw-r--r--g10/keyring.c26
-rw-r--r--g10/keyserver.c2
-rw-r--r--g10/openfile.c4
-rw-r--r--g10/plaintext.c24
-rw-r--r--g10/sign.c12
-rw-r--r--g10/tdbio.c12
-rw-r--r--g10/verify.c4
-rw-r--r--kbx/ChangeLog5
-rw-r--r--kbx/keybox-openpgp.c4
-rw-r--r--scd/ChangeLog8
-rw-r--r--scd/app-openpgp.c20
-rw-r--r--scd/app-p15.c30
-rw-r--r--scd/app.c8
-rw-r--r--scd/command.c4
-rw-r--r--scd/iso7816.c2
-rw-r--r--sm/ChangeLog5
-rw-r--r--sm/base64.c2
-rw-r--r--sm/certchain.c2
-rw-r--r--sm/export.c8
-rw-r--r--sm/import.c6
-rw-r--r--sm/keylist.c2
-rw-r--r--sm/qualified.c12
-rw-r--r--tools/ChangeLog3
-rw-r--r--tools/gpgkey2ssh.c2
55 files changed, 297 insertions, 260 deletions
diff --git a/ChangeLog b/ChangeLog
index d2cadef1d..bcf0251ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-14 Werner Koch <wk@g10code.com>
+
+ Replaced all call gpg_error_from_errno(errno) by
+ gpg_error_from_syserror().
+
+ * configure.ac: Build gpg by default.
+ (GNUPG_SYS_SO_PEERCRED): Removed.
+
2006-09-13 Werner Koch <wk@g10code.com>
* autogen.sh: Better detection of the cross compiler kit.
diff --git a/Makefile.am b/Makefile.am
index 8281496cf..11875afb0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,7 @@ ACLOCAL_AMFLAGS = -I m4 -I gl/m4
AUTOMAKE_OPTIONS = dist-bzip2
DISTCHECK_CONFIGURE_FLAGS = --enable-gpg
-EXTRA_DIST = scripts/config.rpath autogen.sh README.CVS
+EXTRA_DIST = scripts/config.rpath autogen.sh README.SVN
DISTCLEANFILES = g10defs.h
if BUILD_GPGSM
diff --git a/NEWS b/NEWS
index b4eb576d8..89fbad87c 100644
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ Noteworthy changes in version 1.9.23
-------------------------------------------------
* Regular man pages for most tools are now build directly from the
- texinfo source.
+ Texinfo source.
* The gpg code from 1.4.5 has been fully merged into this release.
The configure option --enable-gpg is still required to build this
diff --git a/README b/README
index 008b84b17..c3359e9a8 100644
--- a/README
+++ b/README
@@ -5,9 +5,7 @@
GnuPG 1.9 is the future version of GnuPG; it is based on some gnupg-1.3
code and the previous newpg package. It will eventually lead to a
-GnuPG 2.0 release. Note that GnuPG 1.4 and 1.9 are not always in sync
-and thus features and bug fixes done in 1.4 are not necessary
-available in 1.9.
+GnuPG 2.0 release.
You should use this GnuPG version if you want to use the gpg-agent or
gpgsm (the S/MIME variant of gpg). Note that the gpg-agent is also
diff --git a/acinclude.m4 b/acinclude.m4
index b8af93245..aa2199de0 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -157,25 +157,6 @@ AC_DEFUN([GNUPG_CHECK_ENDIAN],
-# Check for the getsockopt SO_PEERCRED
-AC_DEFUN([GNUPG_SYS_SO_PEERCRED],
- [ AC_MSG_CHECKING(for SO_PEERCRED)
- AC_CACHE_VAL(gnupg_cv_sys_so_peercred,
- [AC_TRY_COMPILE([#include <sys/socket.h>],
- [struct ucred cr;
- int cl = sizeof cr;
- getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
- gnupg_cv_sys_so_peercred=yes,
- gnupg_cv_sys_so_peercred=no)
- ])
- AC_MSG_RESULT($gnupg_cv_sys_so_peercred)
- if test $gnupg_cv_sys_so_peercred = yes; then
- AC_DEFINE(HAVE_SO_PEERCRED, 1,
- [Defined if SO_PEERCRED is supported (Linux)])
- fi
- ])
-
-
# GNUPG_BUILD_PROGRAM(NAME,DEFAULT)
# Add a --enable-NAME option to configure an set the
diff --git a/agent/ChangeLog b/agent/ChangeLog
index 714ce15cc..4c4177110 100644
--- a/agent/ChangeLog
+++ b/agent/ChangeLog
@@ -1,3 +1,14 @@
+2006-09-14 Werner Koch <wk@g10code.com>
+
+ Replaced all call gpg_error_from_errno(errno) by
+ gpg_error_from_syserror().
+
+ * call-pinentry.c (start_pinentry): Replaced pipe_connect2 by
+ pipe_connect_ext.
+ * call-scd.c (start_scd): Ditto.
+ * command.c (start_command_handler): Replaced
+ init_connected_socket_server by init_socket_server_ext.
+
2006-09-13 Werner Koch <wk@g10code.com>
* preset-passphrase.c (main) [W32]: Check for WSAStartup error.
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c
index 55758d020..734cf45b9 100644
--- a/agent/call-pinentry.c
+++ b/agent/call-pinentry.c
@@ -238,8 +238,8 @@ start_pinentry (ctrl_t ctrl)
no_close_list[i] = -1;
/* Connect to the pinentry and perform initial handshaking */
- rc = assuan_pipe_connect2 (&ctx, opt.pinentry_program, argv,
- no_close_list, atfork_cb, NULL);
+ rc = assuan_pipe_connect_ext (&ctx, opt.pinentry_program, argv,
+ no_close_list, atfork_cb, NULL, 0);
if (rc)
{
log_error ("can't connect to the PIN entry module: %s\n",
@@ -649,7 +649,7 @@ agent_popup_message_start (ctrl_t ctrl, const char *desc,
popup_tid = pth_spawn (tattr, popup_message_thread, NULL);
if (!popup_tid)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("error spawning popup message handler: %s\n",
strerror (errno) );
pth_attr_destroy (tattr);
diff --git a/agent/call-scd.c b/agent/call-scd.c
index 1c22ab364..2f91e1e84 100644
--- a/agent/call-scd.c
+++ b/agent/call-scd.c
@@ -217,7 +217,7 @@ start_scd (ctrl_t ctrl)
{
ctrl->scd_local = xtrycalloc (1, sizeof *ctrl->scd_local);
if (!ctrl->scd_local)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
ctrl->scd_local->ctrl_backlink = ctrl;
ctrl->scd_local->next_local = scd_local_list;
scd_local_list = ctrl->scd_local;
@@ -316,8 +316,8 @@ start_scd (ctrl_t ctrl)
no_close_list[i] = -1;
/* Connect to the pinentry and perform initial handshaking */
- rc = assuan_pipe_connect2 (&ctx, opt.scdaemon_program, argv,
- no_close_list, atfork_cb, NULL);
+ rc = assuan_pipe_connect_ext (&ctx, opt.scdaemon_program, argv,
+ no_close_list, atfork_cb, NULL, 0);
if (rc)
{
log_error ("can't connect to the SCdaemon: %s\n",
diff --git a/agent/command-ssh.c b/agent/command-ssh.c
index d038768fe..b3be057c5 100644
--- a/agent/command-ssh.c
+++ b/agent/command-ssh.c
@@ -294,7 +294,7 @@ stream_read_byte (estream_t stream, unsigned char *b)
if (ret == EOF)
{
if (es_ferror (stream))
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
err = gpg_error (GPG_ERR_EOF);
*b = 0;
@@ -317,7 +317,7 @@ stream_write_byte (estream_t stream, unsigned char b)
ret = es_fputc (b, stream);
if (ret == EOF)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
err = 0;
@@ -335,7 +335,7 @@ stream_read_uint32 (estream_t stream, u32 *uint32)
ret = es_read (stream, buffer, sizeof (buffer), &bytes_read);
if (ret)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
{
if (bytes_read != sizeof (buffer))
@@ -368,7 +368,7 @@ stream_write_uint32 (estream_t stream, u32 uint32)
ret = es_write (stream, buffer, sizeof (buffer), NULL);
if (ret)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
err = 0;
@@ -385,7 +385,7 @@ stream_read_data (estream_t stream, unsigned char *buffer, size_t size)
ret = es_read (stream, buffer, size, &bytes_read);
if (ret)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
{
if (bytes_read != size)
@@ -406,7 +406,7 @@ stream_write_data (estream_t stream, const unsigned char *buffer, size_t size)
ret = es_write (stream, buffer, size, NULL);
if (ret)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
err = 0;
@@ -438,7 +438,7 @@ stream_read_string (estream_t stream, unsigned int secure,
buffer = xtrymalloc (length + 1);
if (! buffer)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -587,13 +587,13 @@ stream_copy (estream_t dst, estream_t src)
if (ret || (! bytes_read))
{
if (ret)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
break;
}
ret = es_write (dst, buffer, bytes_read, NULL);
if (ret)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
break;
}
}
@@ -623,21 +623,21 @@ file_to_buffer (const char *filename, unsigned char **buffer, size_t *buffer_n)
stream = es_fopen (filename, "r");
if (! stream)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
ret = fstat (es_fileno (stream), &statbuf);
if (ret)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
buffer_new = xtrymalloc (statbuf.st_size);
if (! buffer_new)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -865,7 +865,7 @@ ssh_receive_mpint_list (estream_t stream, int secret,
mpis = xtrycalloc (elems_n + 1, sizeof *mpis );
if (!mpis)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1040,7 +1040,7 @@ sexp_key_construct (gcry_sexp_t *sexp,
sexp_template = xtrymalloc (sexp_template_n);
if (! sexp_template)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1048,7 +1048,7 @@ sexp_key_construct (gcry_sexp_t *sexp,
arg_list = xtrymalloc (sizeof (*arg_list) * (2 + elems_n + 1));
if (! arg_list)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1153,7 +1153,7 @@ sexp_key_extract (gcry_sexp_t sexp,
mpis_new = xtrycalloc (elems_n + 1, sizeof *mpis_new );
if (!mpis_new)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1204,7 +1204,7 @@ sexp_key_extract (gcry_sexp_t sexp,
comment_new = make_cstring (data, data_n);
if (! comment_new)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1401,7 +1401,7 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! stream)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1417,7 +1417,7 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
blob_size_new = es_ftell (stream);
if (blob_size_new == -1)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1428,7 +1428,7 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
blob_new = xtrymalloc (blob_size_new);
if (! blob_new)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1520,7 +1520,7 @@ ssh_read_key_public_from_blob (unsigned char *blob, size_t blob_size,
blob_stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! blob_stream)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1684,7 +1684,7 @@ card_key_available (ctrl_t ctrl, gcry_sexp_t *r_pk, char **cardsn)
shadow_info = make_shadow_info (serialno, authkeyid);
if (!shadow_info)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
xfree (pkbuf);
gcry_sexp_release (s_pk);
xfree (serialno);
@@ -1734,7 +1734,7 @@ card_key_available (ctrl_t ctrl, gcry_sexp_t *r_pk, char **cardsn)
*cardsn = xtryasprintf ("cardno:%s", serialno);
if (!*cardsn)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
xfree (pkbuf);
gcry_sexp_release (s_pk);
xfree (serialno);
@@ -1801,7 +1801,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! key_blobs)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -1925,7 +1925,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
ret = es_fseek (key_blobs, 0, SEEK_SET);
if (ret)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2032,7 +2032,7 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! stream)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2046,7 +2046,7 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
identifier = make_cstring (identifier_raw, identifier_n);
if (! identifier)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2064,7 +2064,7 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
mpis = xtrycalloc (elems_n + 1, sizeof *mpis);
if (!mpis)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2098,21 +2098,21 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
sig_blob_n = es_ftell (stream);
if (sig_blob_n == -1)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
sig_blob = xtrymalloc (sig_blob_n);
if (! sig_blob)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
ret = es_fseek (stream, 0, SEEK_SET);
if (ret)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2269,7 +2269,7 @@ ssh_key_extract_comment (gcry_sexp_t key, char **comment)
comment_new = make_cstring (data, data_n);
if (! comment_new)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2299,7 +2299,7 @@ ssh_key_to_protected_buffer (gcry_sexp_t key, const char *passphrase,
buffer_new = xtrymalloc_secure (buffer_new_n);
if (! buffer_new)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2356,7 +2356,7 @@ ssh_identity_register (ctrl_t ctrl, gcry_sexp_t key, int ttl)
"within gpg-agent's key storage"),
comment ? comment : "?") < 0)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2364,7 +2364,7 @@ ssh_identity_register (ctrl_t ctrl, gcry_sexp_t key, int ttl)
pi = gcry_calloc_secure (1, sizeof (*pi) + 100 + 1);
if (!pi)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
pi->max_length = 100;
@@ -2720,13 +2720,13 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
request = es_mopen (NULL, 0, 0, 1, gcry_realloc, gcry_free, "r+");
if (! request)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
ret = es_setvbuf (request, NULL, _IONBF, 0);
if (ret)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
err = stream_write_data (request, request_data + 1, request_data_size - 1);
@@ -2737,7 +2737,7 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
response = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! response)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto out;
}
@@ -2853,7 +2853,7 @@ start_command_handler_ssh (int sock_client)
stream_sock = es_fdopen (sock_client, "r+");
if (!stream_sock)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("failed to create stream from socket: %s\n"),
gpg_strerror (err));
goto out;
@@ -2863,7 +2863,7 @@ start_command_handler_ssh (int sock_client)
ret = es_setvbuf (stream_sock, NULL, _IONBF, 0);
if (ret)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("failed to disable buffering "
"on socket stream: %s\n"), gpg_strerror (err));
goto out;
diff --git a/agent/command.c b/agent/command.c
index 730a7e1cd..1c6ab8b79 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -585,7 +585,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
assert (len);
buf = xtrymalloc (len);
if (!buf)
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
else
{
len = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, buf, len);
@@ -1038,7 +1038,7 @@ cmd_putval (assuan_context_t ctx, char *line)
{
vl = xtrymalloc (sizeof *vl + strlen (key) + valuelen);
if (!vl)
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
else
{
vl->len = valuelen;
@@ -1221,11 +1221,11 @@ start_command_handler (int listen_fd, int fd)
}
else if (listen_fd != -1)
{
- rc = assuan_init_socket_server (&ctx, listen_fd);
+ rc = assuan_init_socket_server_ext (&ctx, listen_fd, 0);
}
else
{
- rc = assuan_init_connected_socket_server (&ctx, fd);
+ rc = assuan_init_socket_server_ext (&ctx, fd, 2);
ctrl.connection_fd = fd;
}
if (rc)
diff --git a/agent/divert-scd.c b/agent/divert-scd.c
index 471f1bf34..9ba0b3b6d 100644
--- a/agent/divert-scd.c
+++ b/agent/divert-scd.c
@@ -248,7 +248,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
again:
pi = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10);
if (!pi)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
pi->max_length = maxbuf-1;
pi->min_digits = 0; /* we want a real passphrase */
pi->max_digits = 8;
@@ -264,7 +264,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
pi2 = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10);
if (!pi2)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
xfree (pi);
return rc;
}
diff --git a/agent/findkey.c b/agent/findkey.c
index 3f793e5dd..b32b22eda 100644
--- a/agent/findkey.c
+++ b/agent/findkey.c
@@ -215,7 +215,7 @@ modify_description (const char *in, const char *comment, char **result)
{
*result = out = xtrymalloc (out_len + 1);
if (!out)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
}
@@ -270,7 +270,7 @@ unprotect (ctrl_t ctrl, const char *desc_text,
pi = gcry_calloc_secure (1, sizeof (*pi) + 100);
if (!pi)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
pi->max_length = 100;
pi->min_digits = 0; /* we want a real passphrase */
pi->max_digits = 8;
@@ -318,7 +318,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
fp = fopen (fname, "rb");
if (!fp)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("can't open `%s': %s\n", fname, strerror (errno));
xfree (fname);
return rc;
@@ -326,7 +326,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
if (fstat (fileno(fp), &st))
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("can't stat `%s': %s\n", fname, strerror (errno));
xfree (fname);
fclose (fp);
@@ -337,7 +337,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
buf = xtrymalloc (buflen+1);
if (!buf || fread (buf, buflen, 1, fp) != 1)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("error reading `%s': %s\n", fname, strerror (errno));
xfree (fname);
fclose (fp);
@@ -394,7 +394,7 @@ agent_key_from_file (ctrl_t ctrl, const char *desc_text,
buf = xtrymalloc (len);
if (!buf)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
gcry_sexp_release (s_skey);
return rc;
}
@@ -435,7 +435,7 @@ agent_key_from_file (ctrl_t ctrl, const char *desc_text,
shouldn't be a problem. */
char *tmp = xtrymalloc (comment_length+1);
if (!tmp)
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
else
{
memcpy (tmp, comment, comment_length);
@@ -593,7 +593,7 @@ agent_public_key_from_file (ctrl_t ctrl,
array = xtrycalloc (strlen(elems) + 1, sizeof *array);
if (!array)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
gcry_sexp_release (list);
gcry_sexp_release (s_skey);
return rc;
@@ -655,7 +655,7 @@ agent_public_key_from_file (ctrl_t ctrl,
format = xtrymalloc (15+7*strlen (elems)+10+15+1+1);
if (!format)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
for (i=0; array[i]; i++)
gcry_mpi_release (array[i]);
xfree (array);
diff --git a/agent/preset-passphrase.c b/agent/preset-passphrase.c
index 1b54248a5..dc6a9057f 100644
--- a/agent/preset-passphrase.c
+++ b/agent/preset-passphrase.c
@@ -144,7 +144,7 @@ map_spwq_error (int err)
case SPWQ_NO_AGENT:
return gpg_error (GPG_ERR_NO_AGENT);
case SPWQ_SYS_ERROR:
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
case SPWQ_GENERAL_ERROR:
default:
return gpg_error (GPG_ERR_GENERAL);
@@ -165,7 +165,7 @@ make_hexstring (const char *src)
if (!dst)
{
log_error ("can not escape string: %s\n",
- gpg_strerror (gpg_error_from_errno (errno)));
+ gpg_strerror (gpg_error_from_syserror ()));
return NULL;
}
@@ -199,7 +199,7 @@ preset_passphrase (const char *keygrip)
if (rc < 0)
{
log_error ("reading passphrase failed: %s\n",
- gpg_strerror (gpg_error_from_errno (errno)));
+ gpg_strerror (gpg_error_from_syserror ()));
return;
}
passphrase[rc] = '\0';
@@ -230,7 +230,7 @@ preset_passphrase (const char *keygrip)
if (rc < 0)
{
log_error ("caching passphrase failed: %s\n",
- gpg_strerror (gpg_error_from_errno (errno)));
+ gpg_strerror (gpg_error_from_syserror ()));
return;
}
if (!opt_passphrase)
@@ -258,7 +258,7 @@ forget_passphrase (const char *keygrip)
if (rc < 0)
{
log_error ("clearing passphrase failed: %s\n",
- gpg_strerror (gpg_error_from_errno (errno)));
+ gpg_strerror (gpg_error_from_syserror ()));
return;
}
free (line);
diff --git a/common/ChangeLog b/common/ChangeLog
index 88dfdff9c..e24250c17 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-14 Werner Koch <wk@g10code.com>
+
+ * util.h (out_of_core): Use new gpg_error_from_syserror function.
+
+ * http.c (init_sockets): Changed it to require 2.2 unless it is
+ build within gnupg 1 where we require 1.1 (and not anymore allow
+ for 1.0).
+
2006-09-07 Werner Koch <wk@g10code.com>
* exechelp.c (gnupg_spawn_process): Factor out post fork code to ..
diff --git a/common/asshelp.c b/common/asshelp.c
index 3b46b5ed3..54d7224d8 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -44,7 +44,7 @@ send_one_option (assuan_context_t ctx, gpg_err_source_t errsource,
if (!value || !*value)
err = 0; /* Avoid sending empty strings. */
else if (asprintf (&optstr, "OPTION %s=%s", name, value ) < 0)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
{
err = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL);
@@ -116,7 +116,7 @@ send_pinentry_environment (assuan_context_t ctx,
{
old_lc = strdup (old_lc);
if (!old_lc)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
dft_lc = setlocale (LC_CTYPE, "");
#endif
@@ -142,7 +142,7 @@ send_pinentry_environment (assuan_context_t ctx,
{
old_lc = strdup (old_lc);
if (!old_lc)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
dft_lc = setlocale (LC_MESSAGES, "");
#endif
diff --git a/common/b64enc.c b/common/b64enc.c
index bfc49deb6..73e3d4f64 100644
--- a/common/b64enc.c
+++ b/common/b64enc.c
@@ -57,7 +57,7 @@ b64enc_start (struct b64state *state, FILE *fp, const char *title)
{
state->title = xtrystrdup (title);
if (!state->title)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
return 0;
}
@@ -130,7 +130,7 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes)
return 0;
write_error:
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
gpg_error_t
@@ -200,7 +200,7 @@ b64enc_finish (struct b64state *state)
goto cleanup;
write_error:
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
cleanup:
if (state->title)
diff --git a/common/exechelp.c b/common/exechelp.c
index cfb76c2f5..19fb04ffa 100644
--- a/common/exechelp.c
+++ b/common/exechelp.c
@@ -96,7 +96,7 @@ build_w32_commandline (const char *pgmname, const char **argv, char **cmdline)
buf = p = xtrymalloc (n);
if (!buf)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
/* fixme: PGMNAME may not contain spaces etc. */
p = stpcpy (p, pgmname);
@@ -342,7 +342,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
}
if (!*statusfile)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("can't fdopen pipe for reading: %s\n"), gpg_strerror (err));
CloseHandle (pi.hProcess);
return err;
@@ -366,7 +366,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
if (pipe (rp) == -1)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("error creating a pipe: %s\n"), strerror (errno));
return err;
}
@@ -378,7 +378,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
#endif
if (*pid == (pid_t)(-1))
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("error forking process: %s\n"), strerror (errno));
close (rp[0]);
close (rp[1]);
@@ -399,7 +399,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
*statusfile = fdopen (rp[0], "r");
if (!*statusfile)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("can't fdopen pipe for reading: %s\n"), strerror (errno));
kill (*pid, SIGTERM);
*pid = (pid_t)(-1);
@@ -528,7 +528,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
return gpg_error (GPG_ERR_BUG);
if (access (pgmname, X_OK))
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
#ifdef USE_GNU_PTH
pid = pth_fork? pth_fork () : fork ();
@@ -538,7 +538,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
if (pid == (pid_t)(-1))
{
log_error (_("error forking process: %s\n"), strerror (errno));
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
if (!pid)
{
diff --git a/common/http.c b/common/http.c
index 83b6216cc..3720b00af 100644
--- a/common/http.c
+++ b/common/http.c
@@ -200,6 +200,16 @@ struct http_context_s
#ifdef HAVE_W32_SYSTEM
+
+#if GNUPG_MAJOR_VERSION == 1
+#define REQ_WINSOCK_MAJOR 1
+#define REQ_WINSOCK_MINOR 1
+#else
+#define REQ_WINSOCK_MAJOR 2
+#define REQ_WINSOCK_MINOR 2
+#endif
+
+
static void
deinit_sockets (void)
{
@@ -215,16 +225,18 @@ init_sockets (void)
if (initialized)
return;
- if ( WSAStartup( 0x0101, &wsdata ) )
+ if ( WSAStartup( MAKEWORD (REQ_WINSOCK_MINOR, REQ_WINSOCK_MAJOR), &wsdata ) )
{
log_error ("error initializing socket library: ec=%d\n",
(int)WSAGetLastError () );
return;
}
- if ( wsdata.wVersion < 0x0001 )
+ if ( LOBYTE(wsdata.wVersion) != REQ_WINSOCK_MAJOR
+ || HIBYTE(wsdata.wVersion) != REQ_WINSOCK_MINOR )
{
- log_error ("socket library version is %x.%x - but 1.1 needed\n",
- LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion));
+ log_error ("socket library version is %x.%x - but %d.%d needed\n",
+ LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion)
+ REQ_WINSOCK_MAJOR, REQ_WINSOCK_MINOR);
WSACleanup();
return;
}
@@ -313,7 +325,7 @@ http_open (http_t *r_hd, http_req_t reqtype, const char *url,
/* Create the handle. */
hd = xtrycalloc (1, sizeof *hd);
if (!hd)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
hd->sock = -1;
hd->req_type = reqtype;
hd->flags = flags;
@@ -383,7 +395,7 @@ http_wait_response (http_t hd)
{
hd->sock = dup (hd->sock);
if (hd->sock == -1)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
P_ES(fclose) (hd->fp_write);
hd->fp_write = NULL;
@@ -401,7 +413,7 @@ http_wait_response (http_t hd)
cookie = xtrycalloc (1, sizeof *cookie);
if (!cookie)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
cookie->fd = hd->sock;
if (hd->uri->use_tls)
cookie->tls_session = hd->tls_context;
@@ -410,13 +422,13 @@ http_wait_response (http_t hd)
if (!hd->fp_read)
{
xfree (cookie);
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
}
#else /*!HTTP_USE_ESTREAM*/
hd->fp_read = fdopen (hd->sock, "r");
if (!hd->fp_read)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
#endif /*!HTTP_USE_ESTREAM*/
err = parse_response (hd);
@@ -851,7 +863,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
uri->auth, strlen(uri->auth));
if (!proxy_authstr)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
http_release_parsed_uri (uri);
return err;
}
@@ -919,7 +931,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
if (!myauth)
{
xfree (proxy_authstr);
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
remove_escapes (myauth);
}
@@ -937,13 +949,13 @@ send_request (http_t hd, const char *auth, const char *proxy)
if (!authstr)
{
xfree (proxy_authstr);
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
}
p = build_rel_path (hd->uri);
if (!p)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
request = xtrymalloc (2 * strlen (server)
+ strlen (p)
@@ -952,7 +964,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
+ 100);
if (!request)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
xfree (p);
xfree (authstr);
xfree (proxy_authstr);
@@ -997,7 +1009,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
cookie = xtrycalloc (1, sizeof *cookie);
if (!cookie)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
cookie->fd = hd->sock;
@@ -1011,10 +1023,10 @@ send_request (http_t hd, const char *auth, const char *proxy)
if (!hd->fp_write)
{
xfree (cookie);
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
}
else if (es_fputs (request, hd->fp_write) || es_fflush (hd->fp_write))
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
err = 0;
}
@@ -1030,7 +1042,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
{
hd->fp_write = fdopen (hd->sock, "w");
if (!hd->fp_write)
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
}
#endif /*!HTTP_USE_ESTREAM*/
@@ -1237,7 +1249,7 @@ store_header (http_t hd, char *line)
n += strlen (hd->headers->value);
p = xtrymalloc (n+1);
if (!p)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
strcpy (stpcpy (p, hd->headers->value), line);
xfree (hd->headers->value);
hd->headers->value = p;
@@ -1262,7 +1274,7 @@ store_header (http_t hd, char *line)
it is a comma separated list and merge them. */
p = xtrymalloc (strlen (h->value) + 1 + strlen (value)+ 1);
if (!p)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
strcpy (stpcpy (stpcpy (p, h->value), ","), value);
xfree (h->value);
h->value = p;
@@ -1272,13 +1284,13 @@ store_header (http_t hd, char *line)
/* Append a new header. */
h = xtrymalloc (sizeof *h + strlen (line));
if (!h)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
strcpy (h->name, line);
h->value = xtrymalloc (strlen (value)+1);
if (!h->value)
{
xfree (h);
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
strcpy (h->value, value);
h->next = hd->headers;
@@ -1334,7 +1346,7 @@ parse_response (http_t hd)
len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen);
line = hd->buffer;
if (!line)
- return gpg_error_from_errno (errno); /* Out of core. */
+ return gpg_error_from_syserror (); /* Out of core. */
if (!maxlen)
return gpg_error (GPG_ERR_TRUNCATED); /* Line has been truncated. */
if (!len)
@@ -1378,7 +1390,7 @@ parse_response (http_t hd)
len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen);
line = hd->buffer;
if (!line)
- return gpg_error_from_errno (errno); /* Out of core. */
+ return gpg_error_from_syserror (); /* Out of core. */
/* Note, that we can silently ignore truncated lines. */
if (!len)
return gpg_error (GPG_ERR_EOF);
@@ -1700,7 +1712,7 @@ write_server (int sock, const char *data, size_t length)
continue;
}
log_info ("network write failed: %s\n", strerror (errno));
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
#endif /*!HAVE_W32_SYSTEM*/
nleft -= nwritten;
diff --git a/common/iobuf.c b/common/iobuf.c
index 8f7374f8c..b15d76a0a 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -392,7 +392,7 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
}
else if (ferror (f) && errno != EPIPE)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("%s: read error: %s\n", a->fname, strerror (errno));
}
*ret_len = nbytes;
@@ -406,7 +406,7 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
nbytes = fwrite (buf, 1, size, f);
if (ferror (f))
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("%s: write error: %s\n", a->fname, strerror (errno));
}
}
@@ -481,7 +481,7 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
{ /* error */
if (errno != EPIPE)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("%s: read error: %s\n",
a->fname, strerror (errno));
}
@@ -543,7 +543,7 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
while (n != -1 && nbytes);
if (n == -1)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("%s: write error: %s\n", a->fname, strerror (errno));
}
nbytes = p - buf;
@@ -849,14 +849,14 @@ block_filter (void *opaque, int control, iobuf_t chain, byte * buffer,
{ /* write stuff from the buffer */
assert (n == OP_MIN_PARTIAL_CHUNK);
if (iobuf_write (chain, a->buffer, n))
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
a->buflen = 0;
nbytes -= n;
}
if ((n = nbytes) > blen)
n = blen;
if (n && iobuf_write (chain, p, n))
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
p += n;
nbytes -= n;
}
@@ -935,7 +935,7 @@ block_filter (void *opaque, int control, iobuf_t chain, byte * buffer,
{
log_error ("block_filter: write error: %s\n",
strerror (errno));
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
}
xfree (a->buffer);
a->buffer = NULL;
@@ -1649,7 +1649,7 @@ underflow (iobuf_t a)
if (len < a->d.size)
{
if (ferror (fp))
- a->error = gpg_error_from_errno (errno);
+ a->error = gpg_error_from_syserror ();
}
a->d.len = len;
a->d.start = 0;
diff --git a/common/miscellaneous.c b/common/miscellaneous.c
index da74f65bc..364f13489 100644
--- a/common/miscellaneous.c
+++ b/common/miscellaneous.c
@@ -99,7 +99,7 @@ is_file_compressed (const char *s, int *ret_rc)
a = iobuf_open( s );
if ( a == NULL ) {
- *ret_rc = gpg_error_from_errno (errno);
+ *ret_rc = gpg_error_from_syserror ();
return 0;
}
diff --git a/common/util.h b/common/util.h
index 10828d7e5..92b88aa8d 100644
--- a/common/util.h
+++ b/common/util.h
@@ -71,9 +71,7 @@
static inline gpg_error_t
out_of_core (void)
{
- return gpg_error (errno
- ? gpg_err_code_from_errno(errno)
- : GPG_ERR_MISSING_ERRNO);
+ return gpg_error_from_syserror ();
}
/* A type to hold the ISO time. Note that this this is the same as
diff --git a/configure.ac b/configure.ac
index bcce906e1..fe2b28076 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,7 +76,7 @@ use_exec=yes
disable_keyserver_path=no
-GNUPG_BUILD_PROGRAM(gpg, no)
+GNUPG_BUILD_PROGRAM(gpg, yes)
GNUPG_BUILD_PROGRAM(gpgsm, yes)
GNUPG_BUILD_PROGRAM(agent, yes)
GNUPG_BUILD_PROGRAM(scdaemon, yes)
@@ -946,11 +946,6 @@ if test "$ac_cv_sizeof_unsigned_short" = "0" \
AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
fi
-#
-# fixme: do we really need this - it should be encapsulated in libassuan
-#
-GNUPG_SYS_SO_PEERCRED
-
#
# Checks for library functions.
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 99d73a6b7..e2ddb3f4e 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-14 Werner Koch <wk@g10code.com>
+
+ Replaced all call gpg_error_from_errno(errno) by
+ gpg_error_from_syserror().
+
2006-09-13 Werner Koch <wk@g10code.com>
* gpg.c (main): Made --require-cross-certification the default.
diff --git a/g10/call-agent.c b/g10/call-agent.c
index 14218f83c..e26f290d9 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -104,7 +104,7 @@ start_agent (void)
if (fflush (NULL))
{
- gpg_error_t tmperr = gpg_error_from_errno (errno);
+ gpg_error_t tmperr = gpg_error_from_syserror ();
log_error ("error flushing pending output: %s\n", strerror (errno));
return tmperr;
}
@@ -191,7 +191,7 @@ start_agent (void)
char *optstr;
if (asprintf (&optstr, "OPTION display=%s",
opt.display ? opt.display : dft_display) < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
@@ -209,7 +209,7 @@ start_agent (void)
char *optstr;
if (asprintf (&optstr, "OPTION ttyname=%s",
opt.ttyname ? opt.ttyname : dft_ttyname) < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
@@ -222,7 +222,7 @@ start_agent (void)
char *optstr;
if (asprintf (&optstr, "OPTION ttytype=%s",
opt.ttyname ? opt.ttytype : dft_ttytype) < 0)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL);
free (optstr);
@@ -235,7 +235,7 @@ start_agent (void)
{
old_lc = strdup (old_lc);
if (!old_lc)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
dft_lc = setlocale (LC_CTYPE, "");
@@ -245,7 +245,7 @@ start_agent (void)
char *optstr;
if (asprintf (&optstr, "OPTION lc-ctype=%s",
opt.lc_ctype ? opt.lc_ctype : dft_lc) < 0)
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
else
{
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
@@ -268,7 +268,7 @@ start_agent (void)
{
old_lc = strdup (old_lc);
if (!old_lc)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
dft_lc = setlocale (LC_MESSAGES, "");
#endif
@@ -277,7 +277,7 @@ start_agent (void)
char *optstr;
if (asprintf (&optstr, "OPTION lc-messages=%s",
opt.lc_messages ? opt.lc_messages : dft_lc) < 0)
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
else
{
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
diff --git a/g10/dearmor.c b/g10/dearmor.c
index 7f69a1bba..ae89e8e58 100644
--- a/g10/dearmor.c
+++ b/g10/dearmor.c
@@ -58,7 +58,7 @@ dearmor_file( const char *fname )
errno = EPERM;
}
if (!inp) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) );
goto leave;
@@ -107,7 +107,7 @@ enarmor_file( const char *fname )
errno = EPERM;
}
if (!inp) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) );
goto leave;
diff --git a/g10/decrypt.c b/g10/decrypt.c
index 9a37283c1..39071427a 100644
--- a/g10/decrypt.c
+++ b/g10/decrypt.c
@@ -66,7 +66,7 @@ decrypt_message( const char *filename )
errno = EPERM;
}
if( !fp ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"), print_fname_stdin(filename),
gpg_strerror (rc));
return rc;
diff --git a/g10/encode.c b/g10/encode.c
index 292e2bc5a..1ce5e01de 100644
--- a/g10/encode.c
+++ b/g10/encode.c
@@ -189,7 +189,7 @@ encode_simple( const char *filename, int mode, int use_seskey )
errno = EPERM;
}
if( !inp ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]",
strerror(errno) );
return rc;
@@ -481,7 +481,7 @@ encode_crypt( const char *filename, STRLIST remusr, int use_symkey )
errno = EPERM;
}
if( !inp ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"),
filename? filename: "[stdin]",
gpg_strerror (rc) );
diff --git a/g10/exec.c b/g10/exec.c
index 203c4c78f..268a1a5d8 100644
--- a/g10/exec.c
+++ b/g10/exec.c
@@ -441,7 +441,7 @@ int exec_write(struct exec_info **info,const char *program,
(*info)->tochild=fdopen(to[1],binary?"wb":"w");
if((*info)->tochild==NULL)
{
- ret = gpg_error_from_errno (errno);
+ ret = gpg_error_from_syserror ();
close(to[1]);
goto fail;
}
@@ -451,7 +451,7 @@ int exec_write(struct exec_info **info,const char *program,
(*info)->fromchild=iobuf_fdopen(from[0],"r");
if((*info)->fromchild==NULL)
{
- ret = gpg_error_from_errno (errno);
+ ret = gpg_error_from_syserror ();
close(from[0]);
goto fail;
}
@@ -476,7 +476,7 @@ int exec_write(struct exec_info **info,const char *program,
(*info)->tochild=fopen((*info)->tempfile_in,binary?"wb":"w");
if((*info)->tochild==NULL)
{
- ret = gpg_error_from_errno (errno);
+ ret = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"),
(*info)->tempfile_in,strerror(errno));
goto fail;
@@ -550,7 +550,7 @@ int exec_read(struct exec_info *info)
}
if(info->fromchild==NULL)
{
- ret = gpg_error_from_errno (errno);
+ ret = gpg_error_from_syserror ();
log_error(_("unable to read external program response: %s\n"),
strerror(errno));
goto fail;
diff --git a/g10/gpg.c b/g10/gpg.c
index 79617ee3c..472dc50d0 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -1834,7 +1834,7 @@ main (int argc, char **argv )
opt.rfc2440_text=1;
opt.def_sig_expire="0";
opt.def_cert_expire="0";
- opt.require_cross_cert = 1;
+ opt.flags.require_cross_cert = 1;
set_homedir ( default_homedir () );
/* Check whether we have a config file on the command line. */
diff --git a/g10/keydb.c b/g10/keydb.c
index b3595cf36..830c5127b 100644
--- a/g10/keydb.c
+++ b/g10/keydb.c
@@ -112,7 +112,7 @@ maybe_create_keyring (char *filename, int force)
}
if (access (filename, F_OK))
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
*last_slash_in_filename = DIRSEP_C;
goto leave;
}
@@ -166,7 +166,7 @@ maybe_create_keyring (char *filename, int force)
umask (oldmask);
if (!iobuf)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ( _("error creating keyring `%s': %s\n"),
filename, strerror(errno));
goto leave;
diff --git a/g10/keygen.c b/g10/keygen.c
index 32bccbb5f..260e6625f 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -3732,7 +3732,7 @@ gen_card_key_with_backup (int algo, int keyno, int is_primary,
umask (oldmask);
if (!fp)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error (_("can't create backup file `%s': %s\n"),
fname, strerror(errno) );
xfree (fname);
diff --git a/g10/keyring.c b/g10/keyring.c
index bd577a63b..56acaa3ea 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -661,7 +661,7 @@ prepare_search (KEYRING_HANDLE hd)
hd->current.iobuf = iobuf_open (hd->current.kr->fname);
if (!hd->current.iobuf)
{
- hd->current.error = gpg_error_from_errno (errno);
+ hd->current.error = gpg_error_from_syserror ();
log_error(_("can't open `%s'\n"), hd->current.kr->fname );
return hd->current.error;
}
@@ -1200,7 +1200,7 @@ create_tmp_file (const char *template,
umask(oldmask);
if (!*r_fp)
{
- int rc = gpg_error_from_errno (errno);
+ int rc = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"), tmpfname, strerror(errno) );
xfree (tmpfname);
xfree (bakfname);
@@ -1232,7 +1232,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
#endif
if (rename (fname, bakfname) )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("renaming `%s' to `%s' failed: %s\n",
fname, bakfname, strerror(errno) );
return rc;
@@ -1247,7 +1247,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
unregister_secured_file (fname);
if (rename (tmpfname, fname) )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error (_("renaming `%s' to `%s' failed: %s\n"),
tmpfname, fname, strerror(errno) );
register_secured_file (fname);
@@ -1317,7 +1317,7 @@ write_keyblock (IOBUF fp, KBNODE keyblock)
iobuf_put (fp, 0); /* unused */
if (iobuf_put (fp, cacheval))
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("writing sigcache packet failed\n");
return rc;
}
@@ -1362,7 +1362,7 @@ keyring_rebuild_cache (void *token,int noisy)
{
if (iobuf_close (tmpfp))
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("error closing `%s': %s\n",
tmpfilename, strerror (errno));
goto leave;
@@ -1442,7 +1442,7 @@ keyring_rebuild_cache (void *token,int noisy)
{
if (iobuf_close (tmpfp))
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("error closing `%s': %s\n",
tmpfilename, strerror (errno));
goto leave;
@@ -1486,7 +1486,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
/* Open the source file. Because we do a rename, we have to check the
permissions of the file */
if (access (fname, W_OK))
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
fp = iobuf_open (fname);
if (mode == 1 && !fp && errno == ENOENT) {
@@ -1504,7 +1504,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
umask(oldmask);
if( !newfp )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error (_("can't create `%s': %s\n"), fname, strerror(errno));
return rc;
}
@@ -1521,7 +1521,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
}
}
if( iobuf_close(newfp) ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("%s: close failed: %s\n", fname, strerror(errno));
return rc;
}
@@ -1530,7 +1530,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
if( !fp )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
goto leave;
}
@@ -1613,12 +1613,12 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
/* close both files */
if( iobuf_close(fp) ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error("%s: close failed: %s\n", fname, strerror(errno) );
goto leave;
}
if( iobuf_close(newfp) ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error("%s: close failed: %s\n", tmpfname, strerror(errno) );
goto leave;
}
diff --git a/g10/keyserver.c b/g10/keyserver.c
index 125872e1c..cbf55c091 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -1406,7 +1406,7 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
maxlen=1024;
if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0)
{
- ret = gpg_error_from_errno (errno);
+ ret = gpg_error_from_syserror ();
goto fail; /* i.e. EOF */
}
diff --git a/g10/openfile.c b/g10/openfile.c
index 8c0601c3e..5e3ae3fa8 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -184,7 +184,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
if( iobuf_is_pipe_filename (iname) && !opt.outfile ) {
*a = iobuf_create(NULL);
if( !*a ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), "[stdout]", strerror(errno) );
}
else if( opt.verbose )
@@ -261,7 +261,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
*a = iobuf_create( name );
if( !*a )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"), name, strerror(errno) );
}
else if( opt.verbose )
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 8032f15f0..9ac259820 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -132,12 +132,12 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
else if (is_secured_filename (fname))
{
errno = EPERM;
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
goto leave;
}
else if( !(fp = fopen(fname,"wb")) ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
goto leave;
}
@@ -187,7 +187,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
if( convert ) { /* text mode */
for( ; pt->len; pt->len-- ) {
if( (c = iobuf_get(pt->buf)) == -1 ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("problem reading source (%u bytes remaining)\n",
(unsigned)pt->len);
goto leave;
@@ -210,7 +210,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
else if( putc( c, fp ) == EOF )
{
if (ferror (fp))
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
else
rc = gpg_error (GPG_ERR_EOF);
log_error ("error writing to `%s': %s\n",
@@ -226,7 +226,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
int len = pt->len > 32768 ? 32768 : pt->len;
len = iobuf_read( pt->buf, buffer, len );
if( len == -1 ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("problem reading source (%u bytes remaining)\n",
(unsigned)pt->len);
xfree( buffer );
@@ -246,7 +246,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
else if( fwrite( buffer, 1, len, fp ) != len )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("error writing to `%s': %s\n",
fname, strerror(errno) );
xfree( buffer );
@@ -279,7 +279,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
else if( putc( c, fp ) == EOF )
{
if ( ferror (fp ) )
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
else
rc = gpg_error (GPG_ERR_EOF);
log_error("error writing to `%s': %s\n",
@@ -317,7 +317,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
goto leave;
}
else if( fwrite( buffer, 1, len, fp ) != len ) {
- rc = (errno? gpg_error_from_errno (errno)
+ rc = (errno? gpg_error_from_syserror ()
: gpg_error (GPG_ERR_INTERNAL));
log_error ("error writing to `%s': %s\n",
fname, strerror(errno) );
@@ -345,7 +345,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
else if( putc( c, fp ) == EOF )
{
- rc = (errno? gpg_error_from_errno (errno)
+ rc = (errno? gpg_error_from_syserror ()
: gpg_error (GPG_ERR_INTERNAL));
log_error ("error writing to `%s': %s\n",
fname, strerror(errno) );
@@ -385,7 +385,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
if( fp && fp != stdout && fclose(fp) ) {
- rc = (errno? gpg_error_from_errno (errno)
+ rc = (errno? gpg_error_from_syserror ()
: gpg_error (GPG_ERR_INTERNAL));
log_error ("error closing `%s': %s\n", fname, strerror(errno) );
fp = NULL;
@@ -487,7 +487,7 @@ ask_for_detached_datafile (gcry_md_hd_t md, gcry_md_hd_t md2,
}
else if( !fp )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), answer, strerror(errno));
goto leave;
}
@@ -544,7 +544,7 @@ hash_datafiles( gcry_md_hd_t md, gcry_md_hd_t md2, STRLIST files,
errno = EPERM;
}
if( !fp ) {
- int rc = gpg_error_from_errno (errno);
+ int rc = gpg_error_from_syserror ();
log_error(_("can't open signed data `%s'\n"),
print_fname_stdin(sl->d));
return rc;
diff --git a/g10/sign.c b/g10/sign.c
index 7b6a81e10..07947b894 100644
--- a/g10/sign.c
+++ b/g10/sign.c
@@ -808,7 +808,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
}
if( !inp )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) );
goto leave;
@@ -826,7 +826,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
out = iobuf_create( outfile );
if( !out )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
goto leave;
}
@@ -1003,7 +1003,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
}
if( !inp )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"),
sl->d,strerror(errno));
goto leave;
@@ -1116,7 +1116,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
errno = EPERM;
}
if( !inp ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"),
fname? fname: "[stdin]", strerror(errno) );
goto leave;
@@ -1132,7 +1132,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
out = iobuf_create( outfile );
if( !out )
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
goto leave;
}
@@ -1268,7 +1268,7 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
errno = EPERM;
}
if( !inp ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"),
fname? fname: "[stdin]", strerror(errno) );
goto leave;
diff --git a/g10/tdbio.c b/g10/tdbio.c
index 11e3bb3fd..c6fe995df 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -126,14 +126,14 @@ write_cache_item( CACHE_CTRL r )
int n;
if( lseek( db_fd, r->recno * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) {
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error(_("trustdb rec %lu: lseek failed: %s\n"),
r->recno, strerror(errno) );
return err;
}
n = write( db_fd, r->data, TRUST_RECORD_LEN);
if( n != TRUST_RECORD_LEN ) {
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"),
r->recno, n, strerror(errno) );
return err;
@@ -1162,7 +1162,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected )
buf = get_record_from_cache( recnum );
if( !buf ) {
if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) {
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error(_("trustdb: lseek failed: %s\n"), strerror(errno) );
return err;
}
@@ -1171,7 +1171,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected )
return -1; /* eof */
}
else if( n != TRUST_RECORD_LEN ) {
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error(_("trustdb: read failed (n=%d): %s\n"), n,
strerror(errno) );
return err;
@@ -1435,14 +1435,14 @@ tdbio_new_recnum()
rec.recnum = recnum;
rc = 0;
if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("trustdb rec %lu: lseek failed: %s\n"),
recnum, strerror(errno) );
}
else {
int n = write( db_fd, &rec, TRUST_RECORD_LEN);
if( n != TRUST_RECORD_LEN ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"),
recnum, n, strerror(errno) );
}
diff --git a/g10/verify.c b/g10/verify.c
index 54aa76544..f8a1fd90c 100644
--- a/g10/verify.c
+++ b/g10/verify.c
@@ -98,7 +98,7 @@ verify_signatures( int nfiles, char **files )
errno = EPERM;
}
if( !fp ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"),
print_fname_stdin(sigfile), strerror (errno));
return rc;
@@ -154,7 +154,7 @@ verify_one_file( const char *name )
errno = EPERM;
}
if( !fp ) {
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"),
print_fname_stdin(name), strerror (errno));
print_file_status( STATUS_FILE_ERROR, name, 1 );
diff --git a/kbx/ChangeLog b/kbx/ChangeLog
index 14b702318..a7202a69e 100644
--- a/kbx/ChangeLog
+++ b/kbx/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-14 Werner Koch <wk@g10code.com>
+
+ Replaced all call gpg_error_from_errno(errno) by
+ gpg_error_from_syserror().
+
2005-10-08 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (kbxutil_LDADD): Add ../gl/libgnu.a after
diff --git a/kbx/keybox-openpgp.c b/kbx/keybox-openpgp.c
index 8ac713979..dea0047ca 100644
--- a/kbx/keybox-openpgp.c
+++ b/kbx/keybox-openpgp.c
@@ -405,7 +405,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen,
u = xtrycalloc (1, sizeof *u);
if (!u)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
break;
}
u->off = data - image_start;
@@ -447,7 +447,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen,
k = xtrycalloc (1, sizeof *k);
if (!k)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
break;
}
err = parse_key (data, datalen, k);
diff --git a/scd/ChangeLog b/scd/ChangeLog
index a62b8b06a..4b133c9e8 100644
--- a/scd/ChangeLog
+++ b/scd/ChangeLog
@@ -1,3 +1,11 @@
+2006-09-14 Werner Koch <wk@g10code.com>
+
+ Replaced all call gpg_error_from_errno(errno) by
+ gpg_error_from_syserror().
+
+ * command.c (scd_command_handler): Replaced
+ init_connected_socket_server by init_socket_server_ext.
+
2006-09-07 Werner Koch <wk@g10code.com>
* command.c (update_reader_status_file): Execute an event handler
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 0e35e097c..0db21781e 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -566,7 +566,7 @@ store_fpr (int slot, int keynumber, u32 timestamp,
n = 6 + 2 + mlen + 2 + elen;
p = buffer = xtrymalloc (3 + n);
if (!buffer)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
*p++ = 0x99; /* ctb */
*p++ = n >> 8; /* 2 byte length header */
@@ -880,7 +880,7 @@ retrieve_key_material (FILE *fp, const char *hexkeyid,
break; /* EOF. */
if (i < 0)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave; /* Error. */
}
if (!max_length)
@@ -1036,7 +1036,7 @@ get_public_key (app_t app, int keyno)
mbuf = xtrymalloc ( mlen + 1);
if (!mbuf)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
*mbuf = 0;
@@ -1049,7 +1049,7 @@ get_public_key (app_t app, int keyno)
ebuf = xtrymalloc ( elen + 1);
if (!ebuf)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
*ebuf = 0;
@@ -1091,7 +1091,7 @@ get_public_key (app_t app, int keyno)
fpr);
if (ret < 0)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
@@ -1099,7 +1099,7 @@ get_public_key (app_t app, int keyno)
free (command);
if (!fp)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error ("running gpg failed: %s\n", gpg_strerror (err));
goto leave;
}
@@ -1120,7 +1120,7 @@ get_public_key (app_t app, int keyno)
keybuf = xtrymalloc (50 + 2*35 + mlen + elen + 1);
if (!keybuf)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
@@ -1260,7 +1260,7 @@ do_readkey (app_t app, const char *keyid, unsigned char **pk, size_t *pklen)
*pk = xtrymalloc (*pklen);
if (!*pk)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
*pklen = 0;
return err;
}
@@ -1819,7 +1819,7 @@ do_writekey (app_t app, ctrl_t ctrl,
template = tp = xtrymalloc_secure (template_len);
if (!template)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
*tp++ = 0xC0;
@@ -2185,7 +2185,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
prompt = malloc (strlen (PROMPTSTRING) + 50);
if (!prompt)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
sprintf (prompt, PROMPTSTRING, sigcount);
rc = pincb (pincb_arg, prompt, &pinvalue);
free (prompt);
diff --git a/scd/app-p15.c b/scd/app-p15.c
index 8a7732c85..21dbad47a 100644
--- a/scd/app-p15.c
+++ b/scd/app-p15.c
@@ -520,7 +520,7 @@ parse_certid (app_t app, const char *certid,
objidlen /= 2;
objid = xtrymalloc (objidlen);
if (!objid)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
for (s=certid, i=0; i < objidlen; i++, s+=2)
objid[i] = xtoi_2 (s);
*r_objid = objid;
@@ -1130,14 +1130,14 @@ read_ef_prkdf (app_t app, unsigned short fid, prkdf_object_t *result)
+ objlen/2 * sizeof(unsigned short)));
if (!prkdf)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
prkdf->objidlen = objidlen;
prkdf->objid = xtrymalloc (objidlen);
if (!prkdf->objid)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
xfree (prkdf);
goto leave;
}
@@ -1148,7 +1148,7 @@ read_ef_prkdf (app_t app, unsigned short fid, prkdf_object_t *result)
prkdf->authid = xtrymalloc (authidlen);
if (!prkdf->authid)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
xfree (prkdf->objid);
xfree (prkdf);
goto leave;
@@ -1416,14 +1416,14 @@ read_ef_cdf (app_t app, unsigned short fid, cdf_object_t *result)
+ objlen/2 * sizeof(unsigned short)));
if (!cdf)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
cdf->objidlen = objidlen;
cdf->objid = xtrymalloc (objidlen);
if (!cdf->objid)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
xfree (cdf);
goto leave;
}
@@ -2135,7 +2135,7 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
continue; /* Ready. */
no_core:
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
release_aodf_object (aodf);
goto leave;
@@ -2272,7 +2272,7 @@ read_ef_tokeninfo (app_t app)
app->app_local->serialno = xtrymalloc (objlen);
if (!app->app_local->serialno)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave;
}
memcpy (app->app_local->serialno, p, objlen);
@@ -2368,7 +2368,7 @@ send_certinfo (app_t app, ctrl_t ctrl, const char *certtype,
buf = xtrymalloc (9 + certinfo->objidlen*2 + 1);
if (!buf)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
p = stpcpy (buf, "P15");
if (app->app_local->home_df)
{
@@ -2463,7 +2463,7 @@ send_keypairinfo (app_t app, ctrl_t ctrl, prkdf_object_t keyinfo)
buf = xtrymalloc (9 + keyinfo->objidlen*2 + 1);
if (!buf)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
p = stpcpy (buf, "P15");
if (app->app_local->home_df)
{
@@ -2544,7 +2544,7 @@ readcert_by_cdf (app_t app, cdf_object_t cdf,
{
*r_cert = xtrymalloc (cdf->imagelen);
if (!*r_cert)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
memcpy (*r_cert, cdf->image, cdf->imagelen);
*r_certlen = cdf->imagelen;
return 0;
@@ -2687,7 +2687,7 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
{
buf = xtrymalloc (9 + prkdf->objidlen*2 + 1);
if (!buf)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
p = stpcpy (buf, "P15");
if (app->app_local->home_df)
{
@@ -3059,7 +3059,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
paddedpin = xtrymalloc (aodf->stored_length+1);
if (!paddedpin)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
xfree (pinvalue);
return err;
}
@@ -3087,7 +3087,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
paddedpin = xtrymalloc (aodf->stored_length+1);
if (!paddedpin)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
xfree (pinvalue);
return err;
}
@@ -3345,7 +3345,7 @@ app_select_p15 (app_t app)
app->app_local = xtrycalloc (1, sizeof *app->app_local);
if (!app->app_local)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
goto leave;
}
diff --git a/scd/app.c b/scd/app.c
index ed00d232d..eb07d48b9 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -69,7 +69,7 @@ lock_reader (int slot)
{
if (!pth_mutex_init (&lock_table[slot].lock))
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error ("error initializing mutex: %s\n", strerror (errno));
return err;
}
@@ -80,7 +80,7 @@ lock_reader (int slot)
if (!pth_mutex_acquire (&lock_table[slot].lock, 0, NULL))
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error ("failed to acquire APP lock for slot %d: %s\n",
slot, strerror (errno));
return err;
@@ -278,7 +278,7 @@ select_application (ctrl_t ctrl, int slot, const char *name, app_t *r_app)
app = xtrycalloc (1, sizeof *app);
if (!app)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_info ("error allocating context: %s\n", gpg_strerror (err));
unlock_reader (slot);
return err;
@@ -480,7 +480,7 @@ app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp)
buf = xtrymalloc (app->serialnolen * 2 + 1);
if (!buf)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
for (p=buf, i=0; i < app->serialnolen; p +=2, i++)
sprintf (p, "%02X", app->serialno[i]);
*p = 0;
diff --git a/scd/command.c b/scd/command.c
index 573a91706..3883bfc5e 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -1504,7 +1504,7 @@ cmd_apdu (assuan_context_t ctx, char *line)
apdu = hex_to_buffer (line, &apdulen);
if (!apdu)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
goto leave;
}
if (apdulen)
@@ -1603,7 +1603,7 @@ scd_command_handler (int fd)
}
else
{
- rc = assuan_init_connected_socket_server (&ctx, fd);
+ rc = assuan_init_socket_server_ext (&ctx, fd, 2);
}
if (rc)
{
diff --git a/scd/iso7816.c b/scd/iso7816.c
index 5c62e1371..250ee40d5 100644
--- a/scd/iso7816.c
+++ b/scd/iso7816.c
@@ -677,7 +677,7 @@ iso7816_read_binary (int slot, size_t offset, size_t nmax,
unsigned char *p = xtryrealloc (*result, *resultlen + bufferlen);
if (!p)
{
- gpg_error_t err = gpg_error_from_errno (errno);
+ gpg_error_t err = gpg_error_from_syserror ();
xfree (buffer);
xfree (*result);
*result = NULL;
diff --git a/sm/ChangeLog b/sm/ChangeLog
index 7bf2c0713..cb7e98712 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-14 Werner Koch <wk@g10code.com>
+
+ Replaced all call gpg_error_from_errno(errno) by
+ gpg_error_from_syserror().
+
2006-09-13 Werner Koch <wk@g10code.com>
* keylist.c (list_internal_keys): Print marker line to FP and not
diff --git a/sm/base64.c b/sm/base64.c
index 1d5456788..37ec9ce35 100644
--- a/sm/base64.c
+++ b/sm/base64.c
@@ -451,7 +451,7 @@ base64_writer_cb (void *cb_value, const void *buffer, size_t count)
parm->base64.idx = idx;
parm->base64.quad_count = quad_count;
- return ferror (fp) ? gpg_error_from_errno (errno) : 0;
+ return ferror (fp) ? gpg_error_from_syserror () : 0;
}
static int
diff --git a/sm/certchain.c b/sm/certchain.c
index 054ca4c83..6be6fbe5a 100644
--- a/sm/certchain.c
+++ b/sm/certchain.c
@@ -351,7 +351,7 @@ find_up_external (KEYDB_HANDLE kh, const char *issuer, ksba_sexp_t keyid)
pattern = xtrymalloc (strlen (s)+2);
if (!pattern)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
strcpy (stpcpy (pattern, "/"), s);
add_to_strlist (&names, pattern);
xfree (pattern);
diff --git a/sm/export.c b/sm/export.c
index e230f780e..0f01e5f64 100644
--- a/sm/export.c
+++ b/sm/export.c
@@ -117,7 +117,7 @@ insert_duptable (duptable_t *table, unsigned char *fpr, int *exists)
/* Insert that fingerprint. */
t = xtrymalloc (sizeof *t);
if (!t)
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
memcpy (t->fpr, fpr+1, 19);
t->next = table[idx];
table[idx] = t;
@@ -558,14 +558,14 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
infp = tmpfile ();
if (!infp)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("error creating temporary file: %s\n"), strerror (errno));
goto cleanup;
}
if (fwrite (certimg, certimglen, 1, infp) != 1)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("error writing to temporary file: %s\n"),
strerror (errno));
goto cleanup;
@@ -574,7 +574,7 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
outfp = tmpfile ();
if (!outfp)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("error creating temporary file: %s\n"), strerror (errno));
goto cleanup;
}
diff --git a/sm/import.c b/sm/import.c
index acb55152d..5dcd09508 100644
--- a/sm/import.c
+++ b/sm/import.c
@@ -521,7 +521,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
tmpfp = tmpfile ();
if (!tmpfp)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("error creating temporary file: %s\n"), strerror (errno));
goto cleanup;
}
@@ -529,7 +529,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
{
if (nread && fwrite (buffer, nread, 1, tmpfp) != 1)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("error writing to temporary file: %s\n"),
strerror (errno));
goto cleanup;
@@ -546,7 +546,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
certfp = tmpfile ();
if (!certfp)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("error creating temporary file: %s\n"), strerror (errno));
goto cleanup;
}
diff --git a/sm/keylist.c b/sm/keylist.c
index 927bc88a6..f2aac11f5 100644
--- a/sm/keylist.c
+++ b/sm/keylist.c
@@ -1164,7 +1164,7 @@ list_internal_keys (ctrl_t ctrl, STRLIST names, FILE *fp,
desc = xtrycalloc (ndesc, sizeof *desc);
if (!ndesc)
{
- rc = gpg_error_from_errno (errno);
+ rc = gpg_error_from_syserror ();
log_error ("out of core\n");
goto leave;
}
diff --git a/sm/qualified.c b/sm/qualified.c
index 474e1488d..920d15f4a 100644
--- a/sm/qualified.c
+++ b/sm/qualified.c
@@ -70,7 +70,7 @@ read_list (char *key, char *country, int *lnr)
listfp = fopen (listname, "r");
if (!listfp && errno != ENOENT)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"), listname, gpg_strerror (err));
return err;
}
@@ -85,7 +85,7 @@ read_list (char *key, char *country, int *lnr)
{
if (feof (listfp))
return gpg_error (GPG_ERR_EOF);
- return gpg_error_from_errno (errno);
+ return gpg_error_from_syserror ();
}
if (!*line || line[strlen(line)-1] != '\n')
@@ -234,7 +234,7 @@ gpgsm_qualified_consent (ctrl_t ctrl, ksba_cert_t cert)
"to create or verify such signatures.\n"),
opt.qualsig_approval? "":"\n"
) < 0 )
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
err = 0;
@@ -251,7 +251,7 @@ gpgsm_qualified_consent (ctrl_t ctrl, ksba_cert_t cert)
buffer = p = xtrymalloc (strlen (name) * 3 + 1);
if (!buffer)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
free (name);
return err;
}
@@ -324,7 +324,7 @@ gpgsm_not_qualified_warning (ctrl_t ctrl, ksba_cert_t cert)
"Note, that this certificate will NOT create a "
"qualified signature!"),
subject? subject:"?") < 0 )
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
else
err = 0;
@@ -341,7 +341,7 @@ gpgsm_not_qualified_warning (ctrl_t ctrl, ksba_cert_t cert)
buffer = p = xtrymalloc (strlen (name) * 3 + 1);
if (!buffer)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
free (name);
return err;
}
diff --git a/tools/ChangeLog b/tools/ChangeLog
index 295a574c7..e861b2953 100644
--- a/tools/ChangeLog
+++ b/tools/ChangeLog
@@ -1,5 +1,8 @@
2006-09-12 Werner Koch <wk@g10code.com>
+ Replaced all call gpg_error_from_errno(errno) by
+ gpg_error_from_syserror().
+
* gpg-connect-agent.c (read_and_print_response): With verbosity
level 2 also print comment lines.
diff --git a/tools/gpgkey2ssh.c b/tools/gpgkey2ssh.c
index 3dcb6516e..dd2b5bb2c 100644
--- a/tools/gpgkey2ssh.c
+++ b/tools/gpgkey2ssh.c
@@ -85,7 +85,7 @@ retrieve_key_material (FILE *fp, const char *hexkeyid, int *algorithm_id,
break; /* EOF. */
if (i < 0)
{
- err = gpg_error_from_errno (errno);
+ err = gpg_error_from_syserror ();
goto leave; /* Error. */
}
if (!max_length)