aboutsummaryrefslogtreecommitdiffstats
path: root/agent
diff options
context:
space:
mode:
Diffstat (limited to '')
-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
8 files changed, 77 insertions, 66 deletions
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 <[email protected]>
+
+ 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 <[email protected]>
* 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);