Take advantage of newer gpg-error features.

This commit is contained in:
Werner Koch 2006-09-14 16:50:33 +00:00
parent 9577dd45ab
commit 03d3322e5f
55 changed files with 297 additions and 260 deletions

View File

@ -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> 2006-09-13 Werner Koch <wk@g10code.com>
* autogen.sh: Better detection of the cross compiler kit. * autogen.sh: Better detection of the cross compiler kit.

View File

@ -24,7 +24,7 @@ ACLOCAL_AMFLAGS = -I m4 -I gl/m4
AUTOMAKE_OPTIONS = dist-bzip2 AUTOMAKE_OPTIONS = dist-bzip2
DISTCHECK_CONFIGURE_FLAGS = --enable-gpg 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 DISTCLEANFILES = g10defs.h
if BUILD_GPGSM if BUILD_GPGSM

2
NEWS
View File

@ -2,7 +2,7 @@ Noteworthy changes in version 1.9.23
------------------------------------------------- -------------------------------------------------
* Regular man pages for most tools are now build directly from the * 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 gpg code from 1.4.5 has been fully merged into this release.
The configure option --enable-gpg is still required to build this The configure option --enable-gpg is still required to build this

4
README
View File

@ -5,9 +5,7 @@
GnuPG 1.9 is the future version of GnuPG; it is based on some gnupg-1.3 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 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 GnuPG 2.0 release.
and thus features and bug fixes done in 1.4 are not necessary
available in 1.9.
You should use this GnuPG version if you want to use the gpg-agent or 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 gpgsm (the S/MIME variant of gpg). Note that the gpg-agent is also

View File

@ -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) # GNUPG_BUILD_PROGRAM(NAME,DEFAULT)
# Add a --enable-NAME option to configure an set the # Add a --enable-NAME option to configure an set the

View File

@ -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> 2006-09-13 Werner Koch <wk@g10code.com>
* preset-passphrase.c (main) [W32]: Check for WSAStartup error. * preset-passphrase.c (main) [W32]: Check for WSAStartup error.

View File

@ -238,8 +238,8 @@ start_pinentry (ctrl_t ctrl)
no_close_list[i] = -1; no_close_list[i] = -1;
/* Connect to the pinentry and perform initial handshaking */ /* Connect to the pinentry and perform initial handshaking */
rc = assuan_pipe_connect2 (&ctx, opt.pinentry_program, argv, rc = assuan_pipe_connect_ext (&ctx, opt.pinentry_program, argv,
no_close_list, atfork_cb, NULL); no_close_list, atfork_cb, NULL, 0);
if (rc) if (rc)
{ {
log_error ("can't connect to the PIN entry module: %s\n", 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); popup_tid = pth_spawn (tattr, popup_message_thread, NULL);
if (!popup_tid) if (!popup_tid)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("error spawning popup message handler: %s\n", log_error ("error spawning popup message handler: %s\n",
strerror (errno) ); strerror (errno) );
pth_attr_destroy (tattr); pth_attr_destroy (tattr);

View File

@ -217,7 +217,7 @@ start_scd (ctrl_t ctrl)
{ {
ctrl->scd_local = xtrycalloc (1, sizeof *ctrl->scd_local); ctrl->scd_local = xtrycalloc (1, sizeof *ctrl->scd_local);
if (!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->ctrl_backlink = ctrl;
ctrl->scd_local->next_local = scd_local_list; ctrl->scd_local->next_local = scd_local_list;
scd_local_list = ctrl->scd_local; scd_local_list = ctrl->scd_local;
@ -316,8 +316,8 @@ start_scd (ctrl_t ctrl)
no_close_list[i] = -1; no_close_list[i] = -1;
/* Connect to the pinentry and perform initial handshaking */ /* Connect to the pinentry and perform initial handshaking */
rc = assuan_pipe_connect2 (&ctx, opt.scdaemon_program, argv, rc = assuan_pipe_connect_ext (&ctx, opt.scdaemon_program, argv,
no_close_list, atfork_cb, NULL); no_close_list, atfork_cb, NULL, 0);
if (rc) if (rc)
{ {
log_error ("can't connect to the SCdaemon: %s\n", log_error ("can't connect to the SCdaemon: %s\n",

View File

@ -294,7 +294,7 @@ stream_read_byte (estream_t stream, unsigned char *b)
if (ret == EOF) if (ret == EOF)
{ {
if (es_ferror (stream)) if (es_ferror (stream))
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
err = gpg_error (GPG_ERR_EOF); err = gpg_error (GPG_ERR_EOF);
*b = 0; *b = 0;
@ -317,7 +317,7 @@ stream_write_byte (estream_t stream, unsigned char b)
ret = es_fputc (b, stream); ret = es_fputc (b, stream);
if (ret == EOF) if (ret == EOF)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
err = 0; err = 0;
@ -335,7 +335,7 @@ stream_read_uint32 (estream_t stream, u32 *uint32)
ret = es_read (stream, buffer, sizeof (buffer), &bytes_read); ret = es_read (stream, buffer, sizeof (buffer), &bytes_read);
if (ret) if (ret)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
{ {
if (bytes_read != sizeof (buffer)) 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); ret = es_write (stream, buffer, sizeof (buffer), NULL);
if (ret) if (ret)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
err = 0; 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); ret = es_read (stream, buffer, size, &bytes_read);
if (ret) if (ret)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
{ {
if (bytes_read != size) 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); ret = es_write (stream, buffer, size, NULL);
if (ret) if (ret)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
err = 0; err = 0;
@ -438,7 +438,7 @@ stream_read_string (estream_t stream, unsigned int secure,
buffer = xtrymalloc (length + 1); buffer = xtrymalloc (length + 1);
if (! buffer) if (! buffer)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -587,13 +587,13 @@ stream_copy (estream_t dst, estream_t src)
if (ret || (! bytes_read)) if (ret || (! bytes_read))
{ {
if (ret) if (ret)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
break; break;
} }
ret = es_write (dst, buffer, bytes_read, NULL); ret = es_write (dst, buffer, bytes_read, NULL);
if (ret) if (ret)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
break; break;
} }
} }
@ -623,21 +623,21 @@ file_to_buffer (const char *filename, unsigned char **buffer, size_t *buffer_n)
stream = es_fopen (filename, "r"); stream = es_fopen (filename, "r");
if (! stream) if (! stream)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
ret = fstat (es_fileno (stream), &statbuf); ret = fstat (es_fileno (stream), &statbuf);
if (ret) if (ret)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
buffer_new = xtrymalloc (statbuf.st_size); buffer_new = xtrymalloc (statbuf.st_size);
if (! buffer_new) if (! buffer_new)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -865,7 +865,7 @@ ssh_receive_mpint_list (estream_t stream, int secret,
mpis = xtrycalloc (elems_n + 1, sizeof *mpis ); mpis = xtrycalloc (elems_n + 1, sizeof *mpis );
if (!mpis) if (!mpis)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -1040,7 +1040,7 @@ sexp_key_construct (gcry_sexp_t *sexp,
sexp_template = xtrymalloc (sexp_template_n); sexp_template = xtrymalloc (sexp_template_n);
if (! sexp_template) if (! sexp_template)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -1048,7 +1048,7 @@ sexp_key_construct (gcry_sexp_t *sexp,
arg_list = xtrymalloc (sizeof (*arg_list) * (2 + elems_n + 1)); arg_list = xtrymalloc (sizeof (*arg_list) * (2 + elems_n + 1));
if (! arg_list) if (! arg_list)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -1153,7 +1153,7 @@ sexp_key_extract (gcry_sexp_t sexp,
mpis_new = xtrycalloc (elems_n + 1, sizeof *mpis_new ); mpis_new = xtrycalloc (elems_n + 1, sizeof *mpis_new );
if (!mpis_new) if (!mpis_new)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -1204,7 +1204,7 @@ sexp_key_extract (gcry_sexp_t sexp,
comment_new = make_cstring (data, data_n); comment_new = make_cstring (data, data_n);
if (! comment_new) if (! comment_new)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; 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+"); stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! stream) if (! stream)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -1417,7 +1417,7 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
blob_size_new = es_ftell (stream); blob_size_new = es_ftell (stream);
if (blob_size_new == -1) if (blob_size_new == -1)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -1428,7 +1428,7 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
blob_new = xtrymalloc (blob_size_new); blob_new = xtrymalloc (blob_size_new);
if (! blob_new) if (! blob_new)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; 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+"); blob_stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! blob_stream) if (! blob_stream)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; 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); shadow_info = make_shadow_info (serialno, authkeyid);
if (!shadow_info) if (!shadow_info)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
xfree (pkbuf); xfree (pkbuf);
gcry_sexp_release (s_pk); gcry_sexp_release (s_pk);
xfree (serialno); xfree (serialno);
@ -1734,7 +1734,7 @@ card_key_available (ctrl_t ctrl, gcry_sexp_t *r_pk, char **cardsn)
*cardsn = xtryasprintf ("cardno:%s", serialno); *cardsn = xtryasprintf ("cardno:%s", serialno);
if (!*cardsn) if (!*cardsn)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
xfree (pkbuf); xfree (pkbuf);
gcry_sexp_release (s_pk); gcry_sexp_release (s_pk);
xfree (serialno); xfree (serialno);
@ -1801,7 +1801,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! key_blobs) if (! key_blobs)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -1925,7 +1925,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
ret = es_fseek (key_blobs, 0, SEEK_SET); ret = es_fseek (key_blobs, 0, SEEK_SET);
if (ret) if (ret)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; 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+"); stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! stream) if (! stream)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -2046,7 +2046,7 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
identifier = make_cstring (identifier_raw, identifier_n); identifier = make_cstring (identifier_raw, identifier_n);
if (! identifier) if (! identifier)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -2064,7 +2064,7 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
mpis = xtrycalloc (elems_n + 1, sizeof *mpis); mpis = xtrycalloc (elems_n + 1, sizeof *mpis);
if (!mpis) if (!mpis)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -2098,21 +2098,21 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
sig_blob_n = es_ftell (stream); sig_blob_n = es_ftell (stream);
if (sig_blob_n == -1) if (sig_blob_n == -1)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
sig_blob = xtrymalloc (sig_blob_n); sig_blob = xtrymalloc (sig_blob_n);
if (! sig_blob) if (! sig_blob)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
ret = es_fseek (stream, 0, SEEK_SET); ret = es_fseek (stream, 0, SEEK_SET);
if (ret) if (ret)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -2269,7 +2269,7 @@ ssh_key_extract_comment (gcry_sexp_t key, char **comment)
comment_new = make_cstring (data, data_n); comment_new = make_cstring (data, data_n);
if (! comment_new) if (! comment_new)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; 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); buffer_new = xtrymalloc_secure (buffer_new_n);
if (! buffer_new) if (! buffer_new)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -2356,7 +2356,7 @@ ssh_identity_register (ctrl_t ctrl, gcry_sexp_t key, int ttl)
"within gpg-agent's key storage"), "within gpg-agent's key storage"),
comment ? comment : "?") < 0) comment ? comment : "?") < 0)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; 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); pi = gcry_calloc_secure (1, sizeof (*pi) + 100 + 1);
if (!pi) if (!pi)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
pi->max_length = 100; 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+"); request = es_mopen (NULL, 0, 0, 1, gcry_realloc, gcry_free, "r+");
if (! request) if (! request)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
ret = es_setvbuf (request, NULL, _IONBF, 0); ret = es_setvbuf (request, NULL, _IONBF, 0);
if (ret) if (ret)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
err = stream_write_data (request, request_data + 1, request_data_size - 1); 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+"); response = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! response) if (! response)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto out; goto out;
} }
@ -2853,7 +2853,7 @@ start_command_handler_ssh (int sock_client)
stream_sock = es_fdopen (sock_client, "r+"); stream_sock = es_fdopen (sock_client, "r+");
if (!stream_sock) if (!stream_sock)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
log_error (_("failed to create stream from socket: %s\n"), log_error (_("failed to create stream from socket: %s\n"),
gpg_strerror (err)); gpg_strerror (err));
goto out; goto out;
@ -2863,7 +2863,7 @@ start_command_handler_ssh (int sock_client)
ret = es_setvbuf (stream_sock, NULL, _IONBF, 0); ret = es_setvbuf (stream_sock, NULL, _IONBF, 0);
if (ret) if (ret)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
log_error (_("failed to disable buffering " log_error (_("failed to disable buffering "
"on socket stream: %s\n"), gpg_strerror (err)); "on socket stream: %s\n"), gpg_strerror (err));
goto out; goto out;

View File

@ -585,7 +585,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
assert (len); assert (len);
buf = xtrymalloc (len); buf = xtrymalloc (len);
if (!buf) if (!buf)
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
else else
{ {
len = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, buf, len); 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); vl = xtrymalloc (sizeof *vl + strlen (key) + valuelen);
if (!vl) if (!vl)
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
else else
{ {
vl->len = valuelen; vl->len = valuelen;
@ -1221,11 +1221,11 @@ start_command_handler (int listen_fd, int fd)
} }
else if (listen_fd != -1) else if (listen_fd != -1)
{ {
rc = assuan_init_socket_server (&ctx, listen_fd); rc = assuan_init_socket_server_ext (&ctx, listen_fd, 0);
} }
else else
{ {
rc = assuan_init_connected_socket_server (&ctx, fd); rc = assuan_init_socket_server_ext (&ctx, fd, 2);
ctrl.connection_fd = fd; ctrl.connection_fd = fd;
} }
if (rc) if (rc)

View File

@ -248,7 +248,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
again: again:
pi = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10); pi = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10);
if (!pi) if (!pi)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
pi->max_length = maxbuf-1; pi->max_length = maxbuf-1;
pi->min_digits = 0; /* we want a real passphrase */ pi->min_digits = 0; /* we want a real passphrase */
pi->max_digits = 8; 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); pi2 = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10);
if (!pi2) if (!pi2)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
xfree (pi); xfree (pi);
return rc; return rc;
} }

View File

@ -215,7 +215,7 @@ modify_description (const char *in, const char *comment, char **result)
{ {
*result = out = xtrymalloc (out_len + 1); *result = out = xtrymalloc (out_len + 1);
if (!out) 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); pi = gcry_calloc_secure (1, sizeof (*pi) + 100);
if (!pi) if (!pi)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
pi->max_length = 100; pi->max_length = 100;
pi->min_digits = 0; /* we want a real passphrase */ pi->min_digits = 0; /* we want a real passphrase */
pi->max_digits = 8; pi->max_digits = 8;
@ -318,7 +318,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
fp = fopen (fname, "rb"); fp = fopen (fname, "rb");
if (!fp) if (!fp)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("can't open `%s': %s\n", fname, strerror (errno)); log_error ("can't open `%s': %s\n", fname, strerror (errno));
xfree (fname); xfree (fname);
return rc; return rc;
@ -326,7 +326,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
if (fstat (fileno(fp), &st)) 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)); log_error ("can't stat `%s': %s\n", fname, strerror (errno));
xfree (fname); xfree (fname);
fclose (fp); fclose (fp);
@ -337,7 +337,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
buf = xtrymalloc (buflen+1); buf = xtrymalloc (buflen+1);
if (!buf || fread (buf, buflen, 1, fp) != 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)); log_error ("error reading `%s': %s\n", fname, strerror (errno));
xfree (fname); xfree (fname);
fclose (fp); fclose (fp);
@ -394,7 +394,7 @@ agent_key_from_file (ctrl_t ctrl, const char *desc_text,
buf = xtrymalloc (len); buf = xtrymalloc (len);
if (!buf) if (!buf)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
gcry_sexp_release (s_skey); gcry_sexp_release (s_skey);
return rc; return rc;
} }
@ -435,7 +435,7 @@ agent_key_from_file (ctrl_t ctrl, const char *desc_text,
shouldn't be a problem. */ shouldn't be a problem. */
char *tmp = xtrymalloc (comment_length+1); char *tmp = xtrymalloc (comment_length+1);
if (!tmp) if (!tmp)
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
else else
{ {
memcpy (tmp, comment, comment_length); memcpy (tmp, comment, comment_length);
@ -593,7 +593,7 @@ agent_public_key_from_file (ctrl_t ctrl,
array = xtrycalloc (strlen(elems) + 1, sizeof *array); array = xtrycalloc (strlen(elems) + 1, sizeof *array);
if (!array) if (!array)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
gcry_sexp_release (list); gcry_sexp_release (list);
gcry_sexp_release (s_skey); gcry_sexp_release (s_skey);
return rc; return rc;
@ -655,7 +655,7 @@ agent_public_key_from_file (ctrl_t ctrl,
format = xtrymalloc (15+7*strlen (elems)+10+15+1+1); format = xtrymalloc (15+7*strlen (elems)+10+15+1+1);
if (!format) if (!format)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
for (i=0; array[i]; i++) for (i=0; array[i]; i++)
gcry_mpi_release (array[i]); gcry_mpi_release (array[i]);
xfree (array); xfree (array);

View File

@ -144,7 +144,7 @@ map_spwq_error (int err)
case SPWQ_NO_AGENT: case SPWQ_NO_AGENT:
return gpg_error (GPG_ERR_NO_AGENT); return gpg_error (GPG_ERR_NO_AGENT);
case SPWQ_SYS_ERROR: case SPWQ_SYS_ERROR:
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
case SPWQ_GENERAL_ERROR: case SPWQ_GENERAL_ERROR:
default: default:
return gpg_error (GPG_ERR_GENERAL); return gpg_error (GPG_ERR_GENERAL);
@ -165,7 +165,7 @@ make_hexstring (const char *src)
if (!dst) if (!dst)
{ {
log_error ("can not escape string: %s\n", log_error ("can not escape string: %s\n",
gpg_strerror (gpg_error_from_errno (errno))); gpg_strerror (gpg_error_from_syserror ()));
return NULL; return NULL;
} }
@ -199,7 +199,7 @@ preset_passphrase (const char *keygrip)
if (rc < 0) if (rc < 0)
{ {
log_error ("reading passphrase failed: %s\n", log_error ("reading passphrase failed: %s\n",
gpg_strerror (gpg_error_from_errno (errno))); gpg_strerror (gpg_error_from_syserror ()));
return; return;
} }
passphrase[rc] = '\0'; passphrase[rc] = '\0';
@ -230,7 +230,7 @@ preset_passphrase (const char *keygrip)
if (rc < 0) if (rc < 0)
{ {
log_error ("caching passphrase failed: %s\n", log_error ("caching passphrase failed: %s\n",
gpg_strerror (gpg_error_from_errno (errno))); gpg_strerror (gpg_error_from_syserror ()));
return; return;
} }
if (!opt_passphrase) if (!opt_passphrase)
@ -258,7 +258,7 @@ forget_passphrase (const char *keygrip)
if (rc < 0) if (rc < 0)
{ {
log_error ("clearing passphrase failed: %s\n", log_error ("clearing passphrase failed: %s\n",
gpg_strerror (gpg_error_from_errno (errno))); gpg_strerror (gpg_error_from_syserror ()));
return; return;
} }
free (line); free (line);

View File

@ -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> 2006-09-07 Werner Koch <wk@g10code.com>
* exechelp.c (gnupg_spawn_process): Factor out post fork code to .. * exechelp.c (gnupg_spawn_process): Factor out post fork code to ..

View File

@ -44,7 +44,7 @@ send_one_option (assuan_context_t ctx, gpg_err_source_t errsource,
if (!value || !*value) if (!value || !*value)
err = 0; /* Avoid sending empty strings. */ err = 0; /* Avoid sending empty strings. */
else if (asprintf (&optstr, "OPTION %s=%s", name, value ) < 0) else if (asprintf (&optstr, "OPTION %s=%s", name, value ) < 0)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
{ {
err = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL); 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); old_lc = strdup (old_lc);
if (!old_lc) if (!old_lc)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
dft_lc = setlocale (LC_CTYPE, ""); dft_lc = setlocale (LC_CTYPE, "");
#endif #endif
@ -142,7 +142,7 @@ send_pinentry_environment (assuan_context_t ctx,
{ {
old_lc = strdup (old_lc); old_lc = strdup (old_lc);
if (!old_lc) if (!old_lc)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
dft_lc = setlocale (LC_MESSAGES, ""); dft_lc = setlocale (LC_MESSAGES, "");
#endif #endif

View File

@ -57,7 +57,7 @@ b64enc_start (struct b64state *state, FILE *fp, const char *title)
{ {
state->title = xtrystrdup (title); state->title = xtrystrdup (title);
if (!state->title) if (!state->title)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
return 0; return 0;
} }
@ -130,7 +130,7 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes)
return 0; return 0;
write_error: write_error:
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
gpg_error_t gpg_error_t
@ -200,7 +200,7 @@ b64enc_finish (struct b64state *state)
goto cleanup; goto cleanup;
write_error: write_error:
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
cleanup: cleanup:
if (state->title) if (state->title)

View File

@ -96,7 +96,7 @@ build_w32_commandline (const char *pgmname, const char **argv, char **cmdline)
buf = p = xtrymalloc (n); buf = p = xtrymalloc (n);
if (!buf) if (!buf)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
/* fixme: PGMNAME may not contain spaces etc. */ /* fixme: PGMNAME may not contain spaces etc. */
p = stpcpy (p, pgmname); p = stpcpy (p, pgmname);
@ -342,7 +342,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
} }
if (!*statusfile) 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)); log_error (_("can't fdopen pipe for reading: %s\n"), gpg_strerror (err));
CloseHandle (pi.hProcess); CloseHandle (pi.hProcess);
return err; return err;
@ -366,7 +366,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
if (pipe (rp) == -1) 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)); log_error (_("error creating a pipe: %s\n"), strerror (errno));
return err; return err;
} }
@ -378,7 +378,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
#endif #endif
if (*pid == (pid_t)(-1)) 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)); log_error (_("error forking process: %s\n"), strerror (errno));
close (rp[0]); close (rp[0]);
close (rp[1]); close (rp[1]);
@ -399,7 +399,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
*statusfile = fdopen (rp[0], "r"); *statusfile = fdopen (rp[0], "r");
if (!*statusfile) 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)); log_error (_("can't fdopen pipe for reading: %s\n"), strerror (errno));
kill (*pid, SIGTERM); kill (*pid, SIGTERM);
*pid = (pid_t)(-1); *pid = (pid_t)(-1);
@ -528,7 +528,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
return gpg_error (GPG_ERR_BUG); return gpg_error (GPG_ERR_BUG);
if (access (pgmname, X_OK)) if (access (pgmname, X_OK))
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
pid = pth_fork? pth_fork () : fork (); 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)) if (pid == (pid_t)(-1))
{ {
log_error (_("error forking process: %s\n"), strerror (errno)); log_error (_("error forking process: %s\n"), strerror (errno));
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
if (!pid) if (!pid)
{ {

View File

@ -200,6 +200,16 @@ struct http_context_s
#ifdef HAVE_W32_SYSTEM #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 static void
deinit_sockets (void) deinit_sockets (void)
{ {
@ -215,16 +225,18 @@ init_sockets (void)
if (initialized) if (initialized)
return; return;
if ( WSAStartup( 0x0101, &wsdata ) ) if ( WSAStartup( MAKEWORD (REQ_WINSOCK_MINOR, REQ_WINSOCK_MAJOR), &wsdata ) )
{ {
log_error ("error initializing socket library: ec=%d\n", log_error ("error initializing socket library: ec=%d\n",
(int)WSAGetLastError () ); (int)WSAGetLastError () );
return; 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", log_error ("socket library version is %x.%x - but %d.%d needed\n",
LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion)); LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion)
REQ_WINSOCK_MAJOR, REQ_WINSOCK_MINOR);
WSACleanup(); WSACleanup();
return; return;
} }
@ -313,7 +325,7 @@ http_open (http_t *r_hd, http_req_t reqtype, const char *url,
/* Create the handle. */ /* Create the handle. */
hd = xtrycalloc (1, sizeof *hd); hd = xtrycalloc (1, sizeof *hd);
if (!hd) if (!hd)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
hd->sock = -1; hd->sock = -1;
hd->req_type = reqtype; hd->req_type = reqtype;
hd->flags = flags; hd->flags = flags;
@ -383,7 +395,7 @@ http_wait_response (http_t hd)
{ {
hd->sock = dup (hd->sock); hd->sock = dup (hd->sock);
if (hd->sock == -1) if (hd->sock == -1)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
P_ES(fclose) (hd->fp_write); P_ES(fclose) (hd->fp_write);
hd->fp_write = NULL; hd->fp_write = NULL;
@ -401,7 +413,7 @@ http_wait_response (http_t hd)
cookie = xtrycalloc (1, sizeof *cookie); cookie = xtrycalloc (1, sizeof *cookie);
if (!cookie) if (!cookie)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
cookie->fd = hd->sock; cookie->fd = hd->sock;
if (hd->uri->use_tls) if (hd->uri->use_tls)
cookie->tls_session = hd->tls_context; cookie->tls_session = hd->tls_context;
@ -410,13 +422,13 @@ http_wait_response (http_t hd)
if (!hd->fp_read) if (!hd->fp_read)
{ {
xfree (cookie); xfree (cookie);
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
} }
#else /*!HTTP_USE_ESTREAM*/ #else /*!HTTP_USE_ESTREAM*/
hd->fp_read = fdopen (hd->sock, "r"); hd->fp_read = fdopen (hd->sock, "r");
if (!hd->fp_read) if (!hd->fp_read)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
#endif /*!HTTP_USE_ESTREAM*/ #endif /*!HTTP_USE_ESTREAM*/
err = parse_response (hd); err = parse_response (hd);
@ -851,7 +863,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
uri->auth, strlen(uri->auth)); uri->auth, strlen(uri->auth));
if (!proxy_authstr) if (!proxy_authstr)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
http_release_parsed_uri (uri); http_release_parsed_uri (uri);
return err; return err;
} }
@ -919,7 +931,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
if (!myauth) if (!myauth)
{ {
xfree (proxy_authstr); xfree (proxy_authstr);
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
remove_escapes (myauth); remove_escapes (myauth);
} }
@ -937,13 +949,13 @@ send_request (http_t hd, const char *auth, const char *proxy)
if (!authstr) if (!authstr)
{ {
xfree (proxy_authstr); xfree (proxy_authstr);
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
} }
p = build_rel_path (hd->uri); p = build_rel_path (hd->uri);
if (!p) if (!p)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
request = xtrymalloc (2 * strlen (server) request = xtrymalloc (2 * strlen (server)
+ strlen (p) + strlen (p)
@ -952,7 +964,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
+ 100); + 100);
if (!request) if (!request)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
xfree (p); xfree (p);
xfree (authstr); xfree (authstr);
xfree (proxy_authstr); xfree (proxy_authstr);
@ -997,7 +1009,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
cookie = xtrycalloc (1, sizeof *cookie); cookie = xtrycalloc (1, sizeof *cookie);
if (!cookie) if (!cookie)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
cookie->fd = hd->sock; cookie->fd = hd->sock;
@ -1011,10 +1023,10 @@ send_request (http_t hd, const char *auth, const char *proxy)
if (!hd->fp_write) if (!hd->fp_write)
{ {
xfree (cookie); 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)) 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 else
err = 0; err = 0;
} }
@ -1030,7 +1042,7 @@ send_request (http_t hd, const char *auth, const char *proxy)
{ {
hd->fp_write = fdopen (hd->sock, "w"); hd->fp_write = fdopen (hd->sock, "w");
if (!hd->fp_write) if (!hd->fp_write)
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
} }
#endif /*!HTTP_USE_ESTREAM*/ #endif /*!HTTP_USE_ESTREAM*/
@ -1237,7 +1249,7 @@ store_header (http_t hd, char *line)
n += strlen (hd->headers->value); n += strlen (hd->headers->value);
p = xtrymalloc (n+1); p = xtrymalloc (n+1);
if (!p) if (!p)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
strcpy (stpcpy (p, hd->headers->value), line); strcpy (stpcpy (p, hd->headers->value), line);
xfree (hd->headers->value); xfree (hd->headers->value);
hd->headers->value = p; hd->headers->value = p;
@ -1262,7 +1274,7 @@ store_header (http_t hd, char *line)
it is a comma separated list and merge them. */ it is a comma separated list and merge them. */
p = xtrymalloc (strlen (h->value) + 1 + strlen (value)+ 1); p = xtrymalloc (strlen (h->value) + 1 + strlen (value)+ 1);
if (!p) if (!p)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
strcpy (stpcpy (stpcpy (p, h->value), ","), value); strcpy (stpcpy (stpcpy (p, h->value), ","), value);
xfree (h->value); xfree (h->value);
h->value = p; h->value = p;
@ -1272,13 +1284,13 @@ store_header (http_t hd, char *line)
/* Append a new header. */ /* Append a new header. */
h = xtrymalloc (sizeof *h + strlen (line)); h = xtrymalloc (sizeof *h + strlen (line));
if (!h) if (!h)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
strcpy (h->name, line); strcpy (h->name, line);
h->value = xtrymalloc (strlen (value)+1); h->value = xtrymalloc (strlen (value)+1);
if (!h->value) if (!h->value)
{ {
xfree (h); xfree (h);
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
strcpy (h->value, value); strcpy (h->value, value);
h->next = hd->headers; 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); len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen);
line = hd->buffer; line = hd->buffer;
if (!line) if (!line)
return gpg_error_from_errno (errno); /* Out of core. */ return gpg_error_from_syserror (); /* Out of core. */
if (!maxlen) if (!maxlen)
return gpg_error (GPG_ERR_TRUNCATED); /* Line has been truncated. */ return gpg_error (GPG_ERR_TRUNCATED); /* Line has been truncated. */
if (!len) if (!len)
@ -1378,7 +1390,7 @@ parse_response (http_t hd)
len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen); len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen);
line = hd->buffer; line = hd->buffer;
if (!line) 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. */ /* Note, that we can silently ignore truncated lines. */
if (!len) if (!len)
return gpg_error (GPG_ERR_EOF); return gpg_error (GPG_ERR_EOF);
@ -1700,7 +1712,7 @@ write_server (int sock, const char *data, size_t length)
continue; continue;
} }
log_info ("network write failed: %s\n", strerror (errno)); log_info ("network write failed: %s\n", strerror (errno));
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
#endif /*!HAVE_W32_SYSTEM*/ #endif /*!HAVE_W32_SYSTEM*/
nleft -= nwritten; nleft -= nwritten;

View File

@ -392,7 +392,7 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
} }
else if (ferror (f) && errno != EPIPE) 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)); log_error ("%s: read error: %s\n", a->fname, strerror (errno));
} }
*ret_len = nbytes; *ret_len = nbytes;
@ -406,7 +406,7 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
nbytes = fwrite (buf, 1, size, f); nbytes = fwrite (buf, 1, size, f);
if (ferror (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)); 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 */ { /* error */
if (errno != EPIPE) if (errno != EPIPE)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("%s: read error: %s\n", log_error ("%s: read error: %s\n",
a->fname, strerror (errno)); a->fname, strerror (errno));
} }
@ -543,7 +543,7 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
while (n != -1 && nbytes); while (n != -1 && nbytes);
if (n == -1) 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)); log_error ("%s: write error: %s\n", a->fname, strerror (errno));
} }
nbytes = p - buf; nbytes = p - buf;
@ -849,14 +849,14 @@ block_filter (void *opaque, int control, iobuf_t chain, byte * buffer,
{ /* write stuff from the buffer */ { /* write stuff from the buffer */
assert (n == OP_MIN_PARTIAL_CHUNK); assert (n == OP_MIN_PARTIAL_CHUNK);
if (iobuf_write (chain, a->buffer, n)) if (iobuf_write (chain, a->buffer, n))
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
a->buflen = 0; a->buflen = 0;
nbytes -= n; nbytes -= n;
} }
if ((n = nbytes) > blen) if ((n = nbytes) > blen)
n = blen; n = blen;
if (n && iobuf_write (chain, p, n)) if (n && iobuf_write (chain, p, n))
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
p += n; p += n;
nbytes -= 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", log_error ("block_filter: write error: %s\n",
strerror (errno)); strerror (errno));
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
} }
xfree (a->buffer); xfree (a->buffer);
a->buffer = NULL; a->buffer = NULL;
@ -1649,7 +1649,7 @@ underflow (iobuf_t a)
if (len < a->d.size) if (len < a->d.size)
{ {
if (ferror (fp)) if (ferror (fp))
a->error = gpg_error_from_errno (errno); a->error = gpg_error_from_syserror ();
} }
a->d.len = len; a->d.len = len;
a->d.start = 0; a->d.start = 0;

View File

@ -99,7 +99,7 @@ is_file_compressed (const char *s, int *ret_rc)
a = iobuf_open( s ); a = iobuf_open( s );
if ( a == NULL ) { if ( a == NULL ) {
*ret_rc = gpg_error_from_errno (errno); *ret_rc = gpg_error_from_syserror ();
return 0; return 0;
} }

View File

@ -71,9 +71,7 @@
static inline gpg_error_t static inline gpg_error_t
out_of_core (void) out_of_core (void)
{ {
return gpg_error (errno return gpg_error_from_syserror ();
? gpg_err_code_from_errno(errno)
: GPG_ERR_MISSING_ERRNO);
} }
/* A type to hold the ISO time. Note that this this is the same as /* A type to hold the ISO time. Note that this this is the same as

View File

@ -76,7 +76,7 @@ use_exec=yes
disable_keyserver_path=no disable_keyserver_path=no
GNUPG_BUILD_PROGRAM(gpg, no) GNUPG_BUILD_PROGRAM(gpg, yes)
GNUPG_BUILD_PROGRAM(gpgsm, yes) GNUPG_BUILD_PROGRAM(gpgsm, yes)
GNUPG_BUILD_PROGRAM(agent, yes) GNUPG_BUILD_PROGRAM(agent, yes)
GNUPG_BUILD_PROGRAM(scdaemon, 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]); AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
fi fi
#
# fixme: do we really need this - it should be encapsulated in libassuan
#
GNUPG_SYS_SO_PEERCRED
# #
# Checks for library functions. # Checks for library functions.

View File

@ -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> 2006-09-13 Werner Koch <wk@g10code.com>
* gpg.c (main): Made --require-cross-certification the default. * gpg.c (main): Made --require-cross-certification the default.

View File

@ -104,7 +104,7 @@ start_agent (void)
if (fflush (NULL)) 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)); log_error ("error flushing pending output: %s\n", strerror (errno));
return tmperr; return tmperr;
} }
@ -191,7 +191,7 @@ start_agent (void)
char *optstr; char *optstr;
if (asprintf (&optstr, "OPTION display=%s", if (asprintf (&optstr, "OPTION display=%s",
opt.display ? opt.display : dft_display) < 0) 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, rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL); NULL);
free (optstr); free (optstr);
@ -209,7 +209,7 @@ start_agent (void)
char *optstr; char *optstr;
if (asprintf (&optstr, "OPTION ttyname=%s", if (asprintf (&optstr, "OPTION ttyname=%s",
opt.ttyname ? opt.ttyname : dft_ttyname) < 0) 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, rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL); NULL);
free (optstr); free (optstr);
@ -222,7 +222,7 @@ start_agent (void)
char *optstr; char *optstr;
if (asprintf (&optstr, "OPTION ttytype=%s", if (asprintf (&optstr, "OPTION ttytype=%s",
opt.ttyname ? opt.ttytype : dft_ttytype) < 0) 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, rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
NULL); NULL);
free (optstr); free (optstr);
@ -235,7 +235,7 @@ start_agent (void)
{ {
old_lc = strdup (old_lc); old_lc = strdup (old_lc);
if (!old_lc) if (!old_lc)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
dft_lc = setlocale (LC_CTYPE, ""); dft_lc = setlocale (LC_CTYPE, "");
@ -245,7 +245,7 @@ start_agent (void)
char *optstr; char *optstr;
if (asprintf (&optstr, "OPTION lc-ctype=%s", if (asprintf (&optstr, "OPTION lc-ctype=%s",
opt.lc_ctype ? opt.lc_ctype : dft_lc) < 0) opt.lc_ctype ? opt.lc_ctype : dft_lc) < 0)
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
else else
{ {
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
@ -268,7 +268,7 @@ start_agent (void)
{ {
old_lc = strdup (old_lc); old_lc = strdup (old_lc);
if (!old_lc) if (!old_lc)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
dft_lc = setlocale (LC_MESSAGES, ""); dft_lc = setlocale (LC_MESSAGES, "");
#endif #endif
@ -277,7 +277,7 @@ start_agent (void)
char *optstr; char *optstr;
if (asprintf (&optstr, "OPTION lc-messages=%s", if (asprintf (&optstr, "OPTION lc-messages=%s",
opt.lc_messages ? opt.lc_messages : dft_lc) < 0) opt.lc_messages ? opt.lc_messages : dft_lc) < 0)
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
else else
{ {
rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL, rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,

View File

@ -58,7 +58,7 @@ dearmor_file( const char *fname )
errno = EPERM; errno = EPERM;
} }
if (!inp) { if (!inp) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]", log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) ); strerror(errno) );
goto leave; goto leave;
@ -107,7 +107,7 @@ enarmor_file( const char *fname )
errno = EPERM; errno = EPERM;
} }
if (!inp) { if (!inp) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]", log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) ); strerror(errno) );
goto leave; goto leave;

View File

@ -66,7 +66,7 @@ decrypt_message( const char *filename )
errno = EPERM; errno = EPERM;
} }
if( !fp ) { 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), log_error (_("can't open `%s': %s\n"), print_fname_stdin(filename),
gpg_strerror (rc)); gpg_strerror (rc));
return rc; return rc;

View File

@ -189,7 +189,7 @@ encode_simple( const char *filename, int mode, int use_seskey )
errno = EPERM; errno = EPERM;
} }
if( !inp ) { if( !inp ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]", log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]",
strerror(errno) ); strerror(errno) );
return rc; return rc;
@ -481,7 +481,7 @@ encode_crypt( const char *filename, STRLIST remusr, int use_symkey )
errno = EPERM; errno = EPERM;
} }
if( !inp ) { if( !inp ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), log_error(_("can't open `%s': %s\n"),
filename? filename: "[stdin]", filename? filename: "[stdin]",
gpg_strerror (rc) ); gpg_strerror (rc) );

View File

@ -441,7 +441,7 @@ int exec_write(struct exec_info **info,const char *program,
(*info)->tochild=fdopen(to[1],binary?"wb":"w"); (*info)->tochild=fdopen(to[1],binary?"wb":"w");
if((*info)->tochild==NULL) if((*info)->tochild==NULL)
{ {
ret = gpg_error_from_errno (errno); ret = gpg_error_from_syserror ();
close(to[1]); close(to[1]);
goto fail; goto fail;
} }
@ -451,7 +451,7 @@ int exec_write(struct exec_info **info,const char *program,
(*info)->fromchild=iobuf_fdopen(from[0],"r"); (*info)->fromchild=iobuf_fdopen(from[0],"r");
if((*info)->fromchild==NULL) if((*info)->fromchild==NULL)
{ {
ret = gpg_error_from_errno (errno); ret = gpg_error_from_syserror ();
close(from[0]); close(from[0]);
goto fail; 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"); (*info)->tochild=fopen((*info)->tempfile_in,binary?"wb":"w");
if((*info)->tochild==NULL) if((*info)->tochild==NULL)
{ {
ret = gpg_error_from_errno (errno); ret = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"), log_error(_("can't create `%s': %s\n"),
(*info)->tempfile_in,strerror(errno)); (*info)->tempfile_in,strerror(errno));
goto fail; goto fail;
@ -550,7 +550,7 @@ int exec_read(struct exec_info *info)
} }
if(info->fromchild==NULL) 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"), log_error(_("unable to read external program response: %s\n"),
strerror(errno)); strerror(errno));
goto fail; goto fail;

View File

@ -1834,7 +1834,7 @@ main (int argc, char **argv )
opt.rfc2440_text=1; opt.rfc2440_text=1;
opt.def_sig_expire="0"; opt.def_sig_expire="0";
opt.def_cert_expire="0"; opt.def_cert_expire="0";
opt.require_cross_cert = 1; opt.flags.require_cross_cert = 1;
set_homedir ( default_homedir () ); set_homedir ( default_homedir () );
/* Check whether we have a config file on the command line. */ /* Check whether we have a config file on the command line. */

View File

@ -112,7 +112,7 @@ maybe_create_keyring (char *filename, int force)
} }
if (access (filename, F_OK)) if (access (filename, F_OK))
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
*last_slash_in_filename = DIRSEP_C; *last_slash_in_filename = DIRSEP_C;
goto leave; goto leave;
} }
@ -166,7 +166,7 @@ maybe_create_keyring (char *filename, int force)
umask (oldmask); umask (oldmask);
if (!iobuf) if (!iobuf)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ( _("error creating keyring `%s': %s\n"), log_error ( _("error creating keyring `%s': %s\n"),
filename, strerror(errno)); filename, strerror(errno));
goto leave; goto leave;

View File

@ -3732,7 +3732,7 @@ gen_card_key_with_backup (int algo, int keyno, int is_primary,
umask (oldmask); umask (oldmask);
if (!fp) if (!fp)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error (_("can't create backup file `%s': %s\n"), log_error (_("can't create backup file `%s': %s\n"),
fname, strerror(errno) ); fname, strerror(errno) );
xfree (fname); xfree (fname);

View File

@ -661,7 +661,7 @@ prepare_search (KEYRING_HANDLE hd)
hd->current.iobuf = iobuf_open (hd->current.kr->fname); hd->current.iobuf = iobuf_open (hd->current.kr->fname);
if (!hd->current.iobuf) 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 ); log_error(_("can't open `%s'\n"), hd->current.kr->fname );
return hd->current.error; return hd->current.error;
} }
@ -1200,7 +1200,7 @@ create_tmp_file (const char *template,
umask(oldmask); umask(oldmask);
if (!*r_fp) 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) ); log_error(_("can't create `%s': %s\n"), tmpfname, strerror(errno) );
xfree (tmpfname); xfree (tmpfname);
xfree (bakfname); xfree (bakfname);
@ -1232,7 +1232,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
#endif #endif
if (rename (fname, bakfname) ) if (rename (fname, bakfname) )
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("renaming `%s' to `%s' failed: %s\n", log_error ("renaming `%s' to `%s' failed: %s\n",
fname, bakfname, strerror(errno) ); fname, bakfname, strerror(errno) );
return rc; return rc;
@ -1247,7 +1247,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
unregister_secured_file (fname); unregister_secured_file (fname);
if (rename (tmpfname, 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"), log_error (_("renaming `%s' to `%s' failed: %s\n"),
tmpfname, fname, strerror(errno) ); tmpfname, fname, strerror(errno) );
register_secured_file (fname); register_secured_file (fname);
@ -1317,7 +1317,7 @@ write_keyblock (IOBUF fp, KBNODE keyblock)
iobuf_put (fp, 0); /* unused */ iobuf_put (fp, 0); /* unused */
if (iobuf_put (fp, cacheval)) if (iobuf_put (fp, cacheval))
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("writing sigcache packet failed\n"); log_error ("writing sigcache packet failed\n");
return rc; return rc;
} }
@ -1362,7 +1362,7 @@ keyring_rebuild_cache (void *token,int noisy)
{ {
if (iobuf_close (tmpfp)) if (iobuf_close (tmpfp))
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("error closing `%s': %s\n", log_error ("error closing `%s': %s\n",
tmpfilename, strerror (errno)); tmpfilename, strerror (errno));
goto leave; goto leave;
@ -1442,7 +1442,7 @@ keyring_rebuild_cache (void *token,int noisy)
{ {
if (iobuf_close (tmpfp)) if (iobuf_close (tmpfp))
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("error closing `%s': %s\n", log_error ("error closing `%s': %s\n",
tmpfilename, strerror (errno)); tmpfilename, strerror (errno));
goto leave; 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 /* Open the source file. Because we do a rename, we have to check the
permissions of the file */ permissions of the file */
if (access (fname, W_OK)) if (access (fname, W_OK))
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
fp = iobuf_open (fname); fp = iobuf_open (fname);
if (mode == 1 && !fp && errno == ENOENT) { if (mode == 1 && !fp && errno == ENOENT) {
@ -1504,7 +1504,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
umask(oldmask); umask(oldmask);
if( !newfp ) if( !newfp )
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error (_("can't create `%s': %s\n"), fname, strerror(errno)); log_error (_("can't create `%s': %s\n"), fname, strerror(errno));
return rc; return rc;
} }
@ -1521,7 +1521,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
} }
} }
if( iobuf_close(newfp) ) { 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)); log_error ("%s: close failed: %s\n", fname, strerror(errno));
return rc; return rc;
} }
@ -1530,7 +1530,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
if( !fp ) if( !fp )
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) ); log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
goto leave; goto leave;
} }
@ -1613,12 +1613,12 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
/* close both files */ /* close both files */
if( iobuf_close(fp) ) { 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) ); log_error("%s: close failed: %s\n", fname, strerror(errno) );
goto leave; goto leave;
} }
if( iobuf_close(newfp) ) { 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) ); log_error("%s: close failed: %s\n", tmpfname, strerror(errno) );
goto leave; goto leave;
} }

View File

@ -1406,7 +1406,7 @@ keyserver_spawn(enum ks_action action,STRLIST list,KEYDB_SEARCH_DESC *desc,
maxlen=1024; maxlen=1024;
if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0) 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 */ goto fail; /* i.e. EOF */
} }

View File

@ -184,7 +184,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
if( iobuf_is_pipe_filename (iname) && !opt.outfile ) { if( iobuf_is_pipe_filename (iname) && !opt.outfile ) {
*a = iobuf_create(NULL); *a = iobuf_create(NULL);
if( !*a ) { if( !*a ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), "[stdout]", strerror(errno) ); log_error(_("can't open `%s': %s\n"), "[stdout]", strerror(errno) );
} }
else if( opt.verbose ) else if( opt.verbose )
@ -261,7 +261,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
*a = iobuf_create( name ); *a = iobuf_create( name );
if( !*a ) if( !*a )
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"), name, strerror(errno) ); log_error(_("can't create `%s': %s\n"), name, strerror(errno) );
} }
else if( opt.verbose ) else if( opt.verbose )

View File

@ -132,12 +132,12 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
else if (is_secured_filename (fname)) else if (is_secured_filename (fname))
{ {
errno = EPERM; errno = EPERM;
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("error creating `%s': %s\n"), fname, strerror(errno) ); log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
goto leave; goto leave;
} }
else if( !(fp = fopen(fname,"wb")) ) { 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) ); log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
goto leave; goto leave;
} }
@ -187,7 +187,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
if( convert ) { /* text mode */ if( convert ) { /* text mode */
for( ; pt->len; pt->len-- ) { for( ; pt->len; pt->len-- ) {
if( (c = iobuf_get(pt->buf)) == -1 ) { 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", log_error ("problem reading source (%u bytes remaining)\n",
(unsigned)pt->len); (unsigned)pt->len);
goto leave; goto leave;
@ -210,7 +210,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
else if( putc( c, fp ) == EOF ) else if( putc( c, fp ) == EOF )
{ {
if (ferror (fp)) if (ferror (fp))
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
else else
rc = gpg_error (GPG_ERR_EOF); rc = gpg_error (GPG_ERR_EOF);
log_error ("error writing to `%s': %s\n", 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; int len = pt->len > 32768 ? 32768 : pt->len;
len = iobuf_read( pt->buf, buffer, len ); len = iobuf_read( pt->buf, buffer, len );
if( len == -1 ) { if( len == -1 ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("problem reading source (%u bytes remaining)\n", log_error ("problem reading source (%u bytes remaining)\n",
(unsigned)pt->len); (unsigned)pt->len);
xfree( buffer ); xfree( buffer );
@ -246,7 +246,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
} }
else if( fwrite( buffer, 1, len, fp ) != len ) 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", log_error ("error writing to `%s': %s\n",
fname, strerror(errno) ); fname, strerror(errno) );
xfree( buffer ); xfree( buffer );
@ -279,7 +279,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
else if( putc( c, fp ) == EOF ) else if( putc( c, fp ) == EOF )
{ {
if ( ferror (fp ) ) if ( ferror (fp ) )
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
else else
rc = gpg_error (GPG_ERR_EOF); rc = gpg_error (GPG_ERR_EOF);
log_error("error writing to `%s': %s\n", log_error("error writing to `%s': %s\n",
@ -317,7 +317,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
goto leave; goto leave;
} }
else if( fwrite( buffer, 1, len, fp ) != len ) { 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)); : gpg_error (GPG_ERR_INTERNAL));
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, strerror(errno) ); fname, strerror(errno) );
@ -345,7 +345,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
} }
else if( putc( c, fp ) == EOF ) else if( putc( c, fp ) == EOF )
{ {
rc = (errno? gpg_error_from_errno (errno) rc = (errno? gpg_error_from_syserror ()
: gpg_error (GPG_ERR_INTERNAL)); : gpg_error (GPG_ERR_INTERNAL));
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, strerror(errno) ); fname, strerror(errno) );
@ -385,7 +385,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
} }
if( fp && fp != stdout && fclose(fp) ) { if( fp && fp != stdout && fclose(fp) ) {
rc = (errno? gpg_error_from_errno (errno) rc = (errno? gpg_error_from_syserror ()
: gpg_error (GPG_ERR_INTERNAL)); : gpg_error (GPG_ERR_INTERNAL));
log_error ("error closing `%s': %s\n", fname, strerror(errno) ); log_error ("error closing `%s': %s\n", fname, strerror(errno) );
fp = NULL; fp = NULL;
@ -487,7 +487,7 @@ ask_for_detached_datafile (gcry_md_hd_t md, gcry_md_hd_t md2,
} }
else if( !fp ) 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)); log_error(_("can't open `%s': %s\n"), answer, strerror(errno));
goto leave; goto leave;
} }
@ -544,7 +544,7 @@ hash_datafiles( gcry_md_hd_t md, gcry_md_hd_t md2, STRLIST files,
errno = EPERM; errno = EPERM;
} }
if( !fp ) { if( !fp ) {
int rc = gpg_error_from_errno (errno); int rc = gpg_error_from_syserror ();
log_error(_("can't open signed data `%s'\n"), log_error(_("can't open signed data `%s'\n"),
print_fname_stdin(sl->d)); print_fname_stdin(sl->d));
return rc; return rc;

View File

@ -808,7 +808,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
} }
if( !inp ) if( !inp )
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]", log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]",
strerror(errno) ); strerror(errno) );
goto leave; goto leave;
@ -826,7 +826,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
out = iobuf_create( outfile ); out = iobuf_create( outfile );
if( !out ) if( !out )
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) ); log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
goto leave; goto leave;
} }
@ -1003,7 +1003,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
} }
if( !inp ) if( !inp )
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), log_error(_("can't open `%s': %s\n"),
sl->d,strerror(errno)); sl->d,strerror(errno));
goto leave; goto leave;
@ -1116,7 +1116,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
errno = EPERM; errno = EPERM;
} }
if( !inp ) { if( !inp ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"), log_error (_("can't open `%s': %s\n"),
fname? fname: "[stdin]", strerror(errno) ); fname? fname: "[stdin]", strerror(errno) );
goto leave; goto leave;
@ -1132,7 +1132,7 @@ clearsign_file( const char *fname, STRLIST locusr, const char *outfile )
out = iobuf_create( outfile ); out = iobuf_create( outfile );
if( !out ) if( !out )
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) ); log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
goto leave; goto leave;
} }
@ -1268,7 +1268,7 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
errno = EPERM; errno = EPERM;
} }
if( !inp ) { if( !inp ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error (_("can't open `%s': %s\n"), log_error (_("can't open `%s': %s\n"),
fname? fname: "[stdin]", strerror(errno) ); fname? fname: "[stdin]", strerror(errno) );
goto leave; goto leave;

View File

@ -126,14 +126,14 @@ write_cache_item( CACHE_CTRL r )
int n; int n;
if( lseek( db_fd, r->recno * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { 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"), log_error(_("trustdb rec %lu: lseek failed: %s\n"),
r->recno, strerror(errno) ); r->recno, strerror(errno) );
return err; return err;
} }
n = write( db_fd, r->data, TRUST_RECORD_LEN); n = write( db_fd, r->data, TRUST_RECORD_LEN);
if( n != 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"), log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"),
r->recno, n, strerror(errno) ); r->recno, n, strerror(errno) );
return err; return err;
@ -1162,7 +1162,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected )
buf = get_record_from_cache( recnum ); buf = get_record_from_cache( recnum );
if( !buf ) { if( !buf ) {
if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { 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) ); log_error(_("trustdb: lseek failed: %s\n"), strerror(errno) );
return err; return err;
} }
@ -1171,7 +1171,7 @@ tdbio_read_record( ulong recnum, TRUSTREC *rec, int expected )
return -1; /* eof */ return -1; /* eof */
} }
else if( n != TRUST_RECORD_LEN ) { 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, log_error(_("trustdb: read failed (n=%d): %s\n"), n,
strerror(errno) ); strerror(errno) );
return err; return err;
@ -1435,14 +1435,14 @@ tdbio_new_recnum()
rec.recnum = recnum; rec.recnum = recnum;
rc = 0; rc = 0;
if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) { 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"), log_error(_("trustdb rec %lu: lseek failed: %s\n"),
recnum, strerror(errno) ); recnum, strerror(errno) );
} }
else { else {
int n = write( db_fd, &rec, TRUST_RECORD_LEN); int n = write( db_fd, &rec, TRUST_RECORD_LEN);
if( n != 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"), log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"),
recnum, n, strerror(errno) ); recnum, n, strerror(errno) );
} }

View File

@ -98,7 +98,7 @@ verify_signatures( int nfiles, char **files )
errno = EPERM; errno = EPERM;
} }
if( !fp ) { if( !fp ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), log_error(_("can't open `%s': %s\n"),
print_fname_stdin(sigfile), strerror (errno)); print_fname_stdin(sigfile), strerror (errno));
return rc; return rc;
@ -154,7 +154,7 @@ verify_one_file( const char *name )
errno = EPERM; errno = EPERM;
} }
if( !fp ) { if( !fp ) {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error(_("can't open `%s': %s\n"), log_error(_("can't open `%s': %s\n"),
print_fname_stdin(name), strerror (errno)); print_fname_stdin(name), strerror (errno));
print_file_status( STATUS_FILE_ERROR, name, 1 ); print_file_status( STATUS_FILE_ERROR, name, 1 );

View File

@ -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> 2005-10-08 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (kbxutil_LDADD): Add ../gl/libgnu.a after * Makefile.am (kbxutil_LDADD): Add ../gl/libgnu.a after

View File

@ -405,7 +405,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen,
u = xtrycalloc (1, sizeof *u); u = xtrycalloc (1, sizeof *u);
if (!u) if (!u)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
break; break;
} }
u->off = data - image_start; u->off = data - image_start;
@ -447,7 +447,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen,
k = xtrycalloc (1, sizeof *k); k = xtrycalloc (1, sizeof *k);
if (!k) if (!k)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
break; break;
} }
err = parse_key (data, datalen, k); err = parse_key (data, datalen, k);

View File

@ -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> 2006-09-07 Werner Koch <wk@g10code.com>
* command.c (update_reader_status_file): Execute an event handler * command.c (update_reader_status_file): Execute an event handler

View File

@ -566,7 +566,7 @@ store_fpr (int slot, int keynumber, u32 timestamp,
n = 6 + 2 + mlen + 2 + elen; n = 6 + 2 + mlen + 2 + elen;
p = buffer = xtrymalloc (3 + n); p = buffer = xtrymalloc (3 + n);
if (!buffer) if (!buffer)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
*p++ = 0x99; /* ctb */ *p++ = 0x99; /* ctb */
*p++ = n >> 8; /* 2 byte length header */ *p++ = n >> 8; /* 2 byte length header */
@ -880,7 +880,7 @@ retrieve_key_material (FILE *fp, const char *hexkeyid,
break; /* EOF. */ break; /* EOF. */
if (i < 0) if (i < 0)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; /* Error. */ goto leave; /* Error. */
} }
if (!max_length) if (!max_length)
@ -1036,7 +1036,7 @@ get_public_key (app_t app, int keyno)
mbuf = xtrymalloc ( mlen + 1); mbuf = xtrymalloc ( mlen + 1);
if (!mbuf) if (!mbuf)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
*mbuf = 0; *mbuf = 0;
@ -1049,7 +1049,7 @@ get_public_key (app_t app, int keyno)
ebuf = xtrymalloc ( elen + 1); ebuf = xtrymalloc ( elen + 1);
if (!ebuf) if (!ebuf)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
*ebuf = 0; *ebuf = 0;
@ -1091,7 +1091,7 @@ get_public_key (app_t app, int keyno)
fpr); fpr);
if (ret < 0) if (ret < 0)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
@ -1099,7 +1099,7 @@ get_public_key (app_t app, int keyno)
free (command); free (command);
if (!fp) if (!fp)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
log_error ("running gpg failed: %s\n", gpg_strerror (err)); log_error ("running gpg failed: %s\n", gpg_strerror (err));
goto leave; goto leave;
} }
@ -1120,7 +1120,7 @@ get_public_key (app_t app, int keyno)
keybuf = xtrymalloc (50 + 2*35 + mlen + elen + 1); keybuf = xtrymalloc (50 + 2*35 + mlen + elen + 1);
if (!keybuf) if (!keybuf)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
@ -1260,7 +1260,7 @@ do_readkey (app_t app, const char *keyid, unsigned char **pk, size_t *pklen)
*pk = xtrymalloc (*pklen); *pk = xtrymalloc (*pklen);
if (!*pk) if (!*pk)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
*pklen = 0; *pklen = 0;
return err; return err;
} }
@ -1819,7 +1819,7 @@ do_writekey (app_t app, ctrl_t ctrl,
template = tp = xtrymalloc_secure (template_len); template = tp = xtrymalloc_secure (template_len);
if (!template) if (!template)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
*tp++ = 0xC0; *tp++ = 0xC0;
@ -2185,7 +2185,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
prompt = malloc (strlen (PROMPTSTRING) + 50); prompt = malloc (strlen (PROMPTSTRING) + 50);
if (!prompt) if (!prompt)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
sprintf (prompt, PROMPTSTRING, sigcount); sprintf (prompt, PROMPTSTRING, sigcount);
rc = pincb (pincb_arg, prompt, &pinvalue); rc = pincb (pincb_arg, prompt, &pinvalue);
free (prompt); free (prompt);

View File

@ -520,7 +520,7 @@ parse_certid (app_t app, const char *certid,
objidlen /= 2; objidlen /= 2;
objid = xtrymalloc (objidlen); objid = xtrymalloc (objidlen);
if (!objid) if (!objid)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
for (s=certid, i=0; i < objidlen; i++, s+=2) for (s=certid, i=0; i < objidlen; i++, s+=2)
objid[i] = xtoi_2 (s); objid[i] = xtoi_2 (s);
*r_objid = objid; *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))); + objlen/2 * sizeof(unsigned short)));
if (!prkdf) if (!prkdf)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
prkdf->objidlen = objidlen; prkdf->objidlen = objidlen;
prkdf->objid = xtrymalloc (objidlen); prkdf->objid = xtrymalloc (objidlen);
if (!prkdf->objid) if (!prkdf->objid)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
xfree (prkdf); xfree (prkdf);
goto leave; goto leave;
} }
@ -1148,7 +1148,7 @@ read_ef_prkdf (app_t app, unsigned short fid, prkdf_object_t *result)
prkdf->authid = xtrymalloc (authidlen); prkdf->authid = xtrymalloc (authidlen);
if (!prkdf->authid) if (!prkdf->authid)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
xfree (prkdf->objid); xfree (prkdf->objid);
xfree (prkdf); xfree (prkdf);
goto leave; goto leave;
@ -1416,14 +1416,14 @@ read_ef_cdf (app_t app, unsigned short fid, cdf_object_t *result)
+ objlen/2 * sizeof(unsigned short))); + objlen/2 * sizeof(unsigned short)));
if (!cdf) if (!cdf)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
cdf->objidlen = objidlen; cdf->objidlen = objidlen;
cdf->objid = xtrymalloc (objidlen); cdf->objid = xtrymalloc (objidlen);
if (!cdf->objid) if (!cdf->objid)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
xfree (cdf); xfree (cdf);
goto leave; goto leave;
} }
@ -2135,7 +2135,7 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result)
continue; /* Ready. */ continue; /* Ready. */
no_core: no_core:
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
release_aodf_object (aodf); release_aodf_object (aodf);
goto leave; goto leave;
@ -2272,7 +2272,7 @@ read_ef_tokeninfo (app_t app)
app->app_local->serialno = xtrymalloc (objlen); app->app_local->serialno = xtrymalloc (objlen);
if (!app->app_local->serialno) if (!app->app_local->serialno)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; goto leave;
} }
memcpy (app->app_local->serialno, p, objlen); 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); buf = xtrymalloc (9 + certinfo->objidlen*2 + 1);
if (!buf) if (!buf)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
p = stpcpy (buf, "P15"); p = stpcpy (buf, "P15");
if (app->app_local->home_df) 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); buf = xtrymalloc (9 + keyinfo->objidlen*2 + 1);
if (!buf) if (!buf)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
p = stpcpy (buf, "P15"); p = stpcpy (buf, "P15");
if (app->app_local->home_df) 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); *r_cert = xtrymalloc (cdf->imagelen);
if (!*r_cert) if (!*r_cert)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
memcpy (*r_cert, cdf->image, cdf->imagelen); memcpy (*r_cert, cdf->image, cdf->imagelen);
*r_certlen = cdf->imagelen; *r_certlen = cdf->imagelen;
return 0; return 0;
@ -2687,7 +2687,7 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name)
{ {
buf = xtrymalloc (9 + prkdf->objidlen*2 + 1); buf = xtrymalloc (9 + prkdf->objidlen*2 + 1);
if (!buf) if (!buf)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
p = stpcpy (buf, "P15"); p = stpcpy (buf, "P15");
if (app->app_local->home_df) 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); paddedpin = xtrymalloc (aodf->stored_length+1);
if (!paddedpin) if (!paddedpin)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
xfree (pinvalue); xfree (pinvalue);
return err; return err;
} }
@ -3087,7 +3087,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo,
paddedpin = xtrymalloc (aodf->stored_length+1); paddedpin = xtrymalloc (aodf->stored_length+1);
if (!paddedpin) if (!paddedpin)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
xfree (pinvalue); xfree (pinvalue);
return err; return err;
} }
@ -3345,7 +3345,7 @@ app_select_p15 (app_t app)
app->app_local = xtrycalloc (1, sizeof *app->app_local); app->app_local = xtrycalloc (1, sizeof *app->app_local);
if (!app->app_local) if (!app->app_local)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
goto leave; goto leave;
} }

View File

@ -69,7 +69,7 @@ lock_reader (int slot)
{ {
if (!pth_mutex_init (&lock_table[slot].lock)) 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)); log_error ("error initializing mutex: %s\n", strerror (errno));
return err; return err;
} }
@ -80,7 +80,7 @@ lock_reader (int slot)
if (!pth_mutex_acquire (&lock_table[slot].lock, 0, NULL)) 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", log_error ("failed to acquire APP lock for slot %d: %s\n",
slot, strerror (errno)); slot, strerror (errno));
return err; 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); app = xtrycalloc (1, sizeof *app);
if (!app) if (!app)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
log_info ("error allocating context: %s\n", gpg_strerror (err)); log_info ("error allocating context: %s\n", gpg_strerror (err));
unlock_reader (slot); unlock_reader (slot);
return err; 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); buf = xtrymalloc (app->serialnolen * 2 + 1);
if (!buf) if (!buf)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
for (p=buf, i=0; i < app->serialnolen; p +=2, i++) for (p=buf, i=0; i < app->serialnolen; p +=2, i++)
sprintf (p, "%02X", app->serialno[i]); sprintf (p, "%02X", app->serialno[i]);
*p = 0; *p = 0;

View File

@ -1504,7 +1504,7 @@ cmd_apdu (assuan_context_t ctx, char *line)
apdu = hex_to_buffer (line, &apdulen); apdu = hex_to_buffer (line, &apdulen);
if (!apdu) if (!apdu)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
goto leave; goto leave;
} }
if (apdulen) if (apdulen)
@ -1603,7 +1603,7 @@ scd_command_handler (int fd)
} }
else else
{ {
rc = assuan_init_connected_socket_server (&ctx, fd); rc = assuan_init_socket_server_ext (&ctx, fd, 2);
} }
if (rc) if (rc)
{ {

View File

@ -677,7 +677,7 @@ iso7816_read_binary (int slot, size_t offset, size_t nmax,
unsigned char *p = xtryrealloc (*result, *resultlen + bufferlen); unsigned char *p = xtryrealloc (*result, *resultlen + bufferlen);
if (!p) if (!p)
{ {
gpg_error_t err = gpg_error_from_errno (errno); gpg_error_t err = gpg_error_from_syserror ();
xfree (buffer); xfree (buffer);
xfree (*result); xfree (*result);
*result = NULL; *result = NULL;

View File

@ -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> 2006-09-13 Werner Koch <wk@g10code.com>
* keylist.c (list_internal_keys): Print marker line to FP and not * keylist.c (list_internal_keys): Print marker line to FP and not

View File

@ -451,7 +451,7 @@ base64_writer_cb (void *cb_value, const void *buffer, size_t count)
parm->base64.idx = idx; parm->base64.idx = idx;
parm->base64.quad_count = quad_count; 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 static int

View File

@ -351,7 +351,7 @@ find_up_external (KEYDB_HANDLE kh, const char *issuer, ksba_sexp_t keyid)
pattern = xtrymalloc (strlen (s)+2); pattern = xtrymalloc (strlen (s)+2);
if (!pattern) if (!pattern)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
strcpy (stpcpy (pattern, "/"), s); strcpy (stpcpy (pattern, "/"), s);
add_to_strlist (&names, pattern); add_to_strlist (&names, pattern);
xfree (pattern); xfree (pattern);

View File

@ -117,7 +117,7 @@ insert_duptable (duptable_t *table, unsigned char *fpr, int *exists)
/* Insert that fingerprint. */ /* Insert that fingerprint. */
t = xtrymalloc (sizeof *t); t = xtrymalloc (sizeof *t);
if (!t) if (!t)
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
memcpy (t->fpr, fpr+1, 19); memcpy (t->fpr, fpr+1, 19);
t->next = table[idx]; t->next = table[idx];
table[idx] = t; table[idx] = t;
@ -558,14 +558,14 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
infp = tmpfile (); infp = tmpfile ();
if (!infp) if (!infp)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
log_error (_("error creating temporary file: %s\n"), strerror (errno)); log_error (_("error creating temporary file: %s\n"), strerror (errno));
goto cleanup; goto cleanup;
} }
if (fwrite (certimg, certimglen, 1, infp) != 1) 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"), log_error (_("error writing to temporary file: %s\n"),
strerror (errno)); strerror (errno));
goto cleanup; goto cleanup;
@ -574,7 +574,7 @@ export_p12 (ctrl_t ctrl, const unsigned char *certimg, size_t certimglen,
outfp = tmpfile (); outfp = tmpfile ();
if (!outfp) if (!outfp)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
log_error (_("error creating temporary file: %s\n"), strerror (errno)); log_error (_("error creating temporary file: %s\n"), strerror (errno));
goto cleanup; goto cleanup;
} }

View File

@ -521,7 +521,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
tmpfp = tmpfile (); tmpfp = tmpfile ();
if (!tmpfp) if (!tmpfp)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
log_error (_("error creating temporary file: %s\n"), strerror (errno)); log_error (_("error creating temporary file: %s\n"), strerror (errno));
goto cleanup; goto cleanup;
} }
@ -529,7 +529,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
{ {
if (nread && fwrite (buffer, nread, 1, tmpfp) != 1) 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"), log_error (_("error writing to temporary file: %s\n"),
strerror (errno)); strerror (errno));
goto cleanup; goto cleanup;
@ -546,7 +546,7 @@ parse_p12 (ctrl_t ctrl, ksba_reader_t reader,
certfp = tmpfile (); certfp = tmpfile ();
if (!certfp) if (!certfp)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
log_error (_("error creating temporary file: %s\n"), strerror (errno)); log_error (_("error creating temporary file: %s\n"), strerror (errno));
goto cleanup; goto cleanup;
} }

View File

@ -1164,7 +1164,7 @@ list_internal_keys (ctrl_t ctrl, STRLIST names, FILE *fp,
desc = xtrycalloc (ndesc, sizeof *desc); desc = xtrycalloc (ndesc, sizeof *desc);
if (!ndesc) if (!ndesc)
{ {
rc = gpg_error_from_errno (errno); rc = gpg_error_from_syserror ();
log_error ("out of core\n"); log_error ("out of core\n");
goto leave; goto leave;
} }

View File

@ -70,7 +70,7 @@ read_list (char *key, char *country, int *lnr)
listfp = fopen (listname, "r"); listfp = fopen (listname, "r");
if (!listfp && errno != ENOENT) 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)); log_error (_("can't open `%s': %s\n"), listname, gpg_strerror (err));
return err; return err;
} }
@ -85,7 +85,7 @@ read_list (char *key, char *country, int *lnr)
{ {
if (feof (listfp)) if (feof (listfp))
return gpg_error (GPG_ERR_EOF); return gpg_error (GPG_ERR_EOF);
return gpg_error_from_errno (errno); return gpg_error_from_syserror ();
} }
if (!*line || line[strlen(line)-1] != '\n') 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"), "to create or verify such signatures.\n"),
opt.qualsig_approval? "":"\n" opt.qualsig_approval? "":"\n"
) < 0 ) ) < 0 )
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
err = 0; err = 0;
@ -251,7 +251,7 @@ gpgsm_qualified_consent (ctrl_t ctrl, ksba_cert_t cert)
buffer = p = xtrymalloc (strlen (name) * 3 + 1); buffer = p = xtrymalloc (strlen (name) * 3 + 1);
if (!buffer) if (!buffer)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
free (name); free (name);
return err; 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 " "Note, that this certificate will NOT create a "
"qualified signature!"), "qualified signature!"),
subject? subject:"?") < 0 ) subject? subject:"?") < 0 )
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
else else
err = 0; err = 0;
@ -341,7 +341,7 @@ gpgsm_not_qualified_warning (ctrl_t ctrl, ksba_cert_t cert)
buffer = p = xtrymalloc (strlen (name) * 3 + 1); buffer = p = xtrymalloc (strlen (name) * 3 + 1);
if (!buffer) if (!buffer)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
free (name); free (name);
return err; return err;
} }

View File

@ -1,5 +1,8 @@
2006-09-12 Werner Koch <wk@g10code.com> 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 * gpg-connect-agent.c (read_and_print_response): With verbosity
level 2 also print comment lines. level 2 also print comment lines.

View File

@ -85,7 +85,7 @@ retrieve_key_material (FILE *fp, const char *hexkeyid, int *algorithm_id,
break; /* EOF. */ break; /* EOF. */
if (i < 0) if (i < 0)
{ {
err = gpg_error_from_errno (errno); err = gpg_error_from_syserror ();
goto leave; /* Error. */ goto leave; /* Error. */
} }
if (!max_length) if (!max_length)