1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-14 00:19:50 +02:00

agent: Fix binary vs. text mode problem in ssh.

* agent/command-ssh.c (file_to_buffer)
(ssh_handler_request_identities): Open streams in binary mode.
(start_command_handler_ssh): Factor some code out to ..
(setup_ssh_env): new function.
--

This is for now a theoretical fix because there is no ssh client yet
which uses the GnuPG style IPC.  OpenSSL for Cygwin uses only a quite
similar one.  gniibe suggested to implement that IPC style in
Libassuan so that a Cygwin version of OpenSSL may be used with GnuPG.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2013-07-03 13:10:29 +02:00
parent 27e403bff7
commit ed056d67c7

View File

@ -683,7 +683,7 @@ file_to_buffer (const char *filename, unsigned char **buffer, size_t *buffer_n)
buffer_new = NULL; buffer_new = NULL;
err = 0; err = 0;
stream = es_fopen (filename, "r"); stream = es_fopen (filename, "rb");
if (! stream) if (! stream)
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
@ -2200,7 +2200,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
key_counter = 0; key_counter = 0;
err = 0; err = 0;
key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+b");
if (! key_blobs) if (! key_blobs)
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
@ -3275,20 +3275,16 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
return !!err; return !!err;
} }
/* Start serving client on SOCK_CLIENT. */
void
start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client)
{
estream_t stream_sock = NULL;
gpg_error_t err = 0;
int ret;
/* Because the ssh protocol does not send us information about the /* Because the ssh protocol does not send us information about the the
the current TTY setting, we resort here to use those from startup current TTY setting, we use this function to use those from startup
or those explictly set. */ or those explictly set. */
static gpg_error_t
setup_ssh_env (ctrl_t ctrl)
{ {
static const char *names[] = static const char *names[] =
{"GPG_TTY", "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL}; {"GPG_TTY", "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL};
gpg_error_t err = 0;
int idx; int idx;
const char *value; const char *value;
@ -3306,14 +3302,25 @@ start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client)
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
if (err) if (err)
{
log_error ("error setting default session environment: %s\n", log_error ("error setting default session environment: %s\n",
gpg_strerror (err)); gpg_strerror (err));
goto out;
} return err;
} }
/* Start serving client on SOCK_CLIENT. */
void
start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client)
{
estream_t stream_sock = NULL;
gpg_error_t err;
int ret;
err = setup_ssh_env (ctrl);
if (err)
goto out;
/* Create stream from socket. */ /* Create stream from socket. */
stream_sock = es_fdopen (FD2INT(sock_client), "r+"); stream_sock = es_fdopen (FD2INT(sock_client), "r+");
if (!stream_sock) if (!stream_sock)