mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
2004-07-19 Moritz Schulte <moritz@g10code.com>
* command-ssh.c: Only log debugging message if asked to do so. * command-ssh.c (gpg_stream_copy): Remove function. Update Libgpg-stream.
This commit is contained in:
parent
1a9a732165
commit
57f0fbdaf2
@ -1,5 +1,10 @@
|
||||
2004-07-19 Moritz Schulte <moritz@g10code.com>
|
||||
|
||||
* command-ssh.c: Only log debugging message if asked to do so.
|
||||
|
||||
* command-ssh.c (gpg_stream_copy): Remove function.
|
||||
Update Libgpg-stream.
|
||||
|
||||
* command-ssh.c: Fix handling of iqmp vs. u.
|
||||
|
||||
* command-ssh.c (ssh_identity_register): passphrase must not be freed.
|
||||
|
@ -157,6 +157,9 @@ buffer_read (buffer_t buffer,
|
||||
size_t data_read = 0;
|
||||
size_t data_to_copy = 0;
|
||||
|
||||
if (! (buffer->flags & BUFFER_FLAG_DIRTY))
|
||||
err = buffer_flush_do (buffer);
|
||||
|
||||
while ((bytes_to_read - data_read) && (! err))
|
||||
{
|
||||
if (buffer->buffer_in.data_offset == buffer->buffer_in.data_size)
|
||||
|
@ -158,27 +158,6 @@ static uint32_t lifetime_default;
|
||||
|
||||
/* Primitive I/O functions. */
|
||||
|
||||
static gpg_err_code_t
|
||||
gpg_stream_copy (gpg_stream_t dest, gpg_stream_t src)
|
||||
{
|
||||
gpg_err_code_t err = GPG_ERR_NO_ERROR;
|
||||
unsigned char buffer[STREAM_BLOCK_SIZE];
|
||||
size_t bytes_read = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
err = gpg_stream_read (src, buffer, sizeof (buffer), &bytes_read);
|
||||
if (err || (! bytes_read))
|
||||
break;
|
||||
|
||||
err = gpg_stream_write (dest, buffer, bytes_read, NULL);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static gpg_err_code_t
|
||||
gpg_stream_read_byte (gpg_stream_t stream, byte_t *b)
|
||||
{
|
||||
@ -648,10 +627,6 @@ ssh_extract_key_public_from_blob (unsigned char *blob, size_t blob_size,
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = gpg_stream_flush (blob_stream);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = gpg_stream_seek (blob_stream, 0, SEEK_SET);
|
||||
if (err)
|
||||
goto out;
|
||||
@ -687,10 +662,6 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = gpg_stream_flush (blob_stream);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = gpg_stream_seek (blob_stream, 0, SEEK_SET);
|
||||
if (err)
|
||||
goto out;
|
||||
@ -959,9 +930,6 @@ ssh_handler_request_identities (ctrl_t ctrl,
|
||||
break;
|
||||
}
|
||||
|
||||
err = gpg_stream_flush (key_blobs);
|
||||
if (err)
|
||||
goto out;
|
||||
err = gpg_stream_seek (key_blobs, 0, SEEK_SET);
|
||||
if (err)
|
||||
goto out;
|
||||
@ -1063,10 +1031,6 @@ data_sign (CTRL ctrl, unsigned char **sig, size_t *sig_n)
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = gpg_stream_flush (stream);
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = gpg_stream_seek (stream, 0, SEEK_SET);
|
||||
if (err)
|
||||
goto out;
|
||||
@ -1126,6 +1090,7 @@ ssh_handler_sign_request (ctrl_t ctrl,
|
||||
size_t sig_n = 0;
|
||||
uint32_t flags = 0;
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] sign request\n");
|
||||
|
||||
/* Receive key. */
|
||||
@ -1295,6 +1260,7 @@ ssh_identity_register (ssh_key_secret_t *key, int ttl)
|
||||
char passphrase[100] = { 0 };
|
||||
int ret = 0;
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] registering identity `%s'\n", key_grip);
|
||||
|
||||
err = ssh_key_grip (NULL, key, key_grip);
|
||||
@ -1340,6 +1306,7 @@ ssh_identity_drop (ssh_key_public_t *key)
|
||||
|
||||
/* FIXME */
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] dropping identity `%s'\n", key_grip);
|
||||
|
||||
out:
|
||||
@ -1358,6 +1325,7 @@ ssh_handler_add_identity (ctrl_t ctrl,
|
||||
int confirm = 0;
|
||||
int death = 0;
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] add identity\n");
|
||||
|
||||
err = ssh_receive_key_secret (request, &key);
|
||||
@ -1434,6 +1402,7 @@ ssh_handler_remove_identity (ctrl_t ctrl,
|
||||
|
||||
/* Receive key. */
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] remove identity\n");
|
||||
|
||||
err = gpg_stream_read_string (request, &key_blob, NULL);
|
||||
@ -1463,6 +1432,7 @@ ssh_identities_remove_all (void)
|
||||
{
|
||||
gpg_err_code_t err = GPG_ERR_NO_ERROR;
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] remove all identities\n");
|
||||
|
||||
/* FIXME: shall we remove _all_ cache entries or only those
|
||||
@ -1490,6 +1460,7 @@ ssh_lock (void)
|
||||
{
|
||||
gpg_err_code_t err = GPG_ERR_NOT_IMPLEMENTED;
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] lock\n");
|
||||
|
||||
return err;
|
||||
@ -1500,6 +1471,7 @@ ssh_unlock (void)
|
||||
{
|
||||
gpg_err_code_t err = GPG_ERR_NOT_IMPLEMENTED;
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] unlock\n");
|
||||
|
||||
return err;
|
||||
@ -1563,6 +1535,7 @@ ssh_request_process (ctrl_t ctrl, gpg_stream_t request, gpg_stream_t response)
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] request: %u\n", request_type);
|
||||
|
||||
for (i = 0; i < DIM (request_specs); i++)
|
||||
@ -1609,6 +1582,7 @@ start_command_handler_ssh (int sock_client)
|
||||
|
||||
/* Setup control structure. */
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] Starting command handler\n");
|
||||
|
||||
ctrl.connection_fd = sock_client;
|
||||
@ -1645,26 +1619,21 @@ start_command_handler_ssh (int sock_client)
|
||||
if (err)
|
||||
break;
|
||||
|
||||
log_debug ("[ssh-agent] Received request of length: %u\n", request_size);
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] Received request of length: %u\n",
|
||||
request_size);
|
||||
|
||||
/* Write request data to request stream. */
|
||||
err = gpg_stream_write (stream_request, request, request_size, NULL);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
err = gpg_stream_flush (stream_request);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
err = gpg_stream_seek (stream_request, 0, SEEK_SET);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
/* Process request. */
|
||||
err = ssh_request_process (&ctrl, stream_request, stream_response);
|
||||
if (err)
|
||||
break;
|
||||
err = gpg_stream_flush (stream_response);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
@ -1672,7 +1641,7 @@ start_command_handler_ssh (int sock_client)
|
||||
err = gpg_stream_seek (stream_response, 0, SEEK_SET);
|
||||
if (err)
|
||||
break;
|
||||
err = gpg_stream_peek (stream_response, NULL, &size);
|
||||
err = gpg_stream_stat (stream_response, &size);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
@ -1687,7 +1656,6 @@ start_command_handler_ssh (int sock_client)
|
||||
err = gpg_stream_flush (stream_sock);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
};
|
||||
if (err)
|
||||
goto out;
|
||||
@ -1700,6 +1668,7 @@ start_command_handler_ssh (int sock_client)
|
||||
gpg_stream_destroy (stream_response);
|
||||
free (request);
|
||||
|
||||
if (DBG_COMMAND)
|
||||
log_debug ("[ssh-agent] Leaving ssh command handler: %s\n", gpg_strerror (err));
|
||||
|
||||
/* fixme: make sure that stream_destroy closes client socket. */
|
||||
|
@ -912,3 +912,37 @@ gpg_stream_stat (gpg_stream_t stream,
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
static gpg_error_t
|
||||
gpg_stream_copy_do (gpg_stream_t dst,
|
||||
gpg_stream_t src)
|
||||
{
|
||||
gpg_error_t err = GPG_ERR_NO_ERROR;
|
||||
unsigned char buffer[STREAM_BLOCK_SIZE];
|
||||
size_t bytes_read = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
err = gpg_stream_read (src, buffer, sizeof (buffer), &bytes_read);
|
||||
if (err || (! bytes_read))
|
||||
break;
|
||||
|
||||
err = gpg_stream_write (dst, buffer, bytes_read, NULL);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
gpg_error_t
|
||||
gpg_stream_copy (gpg_stream_t dst,
|
||||
gpg_stream_t src)
|
||||
{
|
||||
gpg_error_t err = GPG_ERR_NO_ERROR;
|
||||
|
||||
err = gpg_stream_copy_do (dst, src);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -121,6 +121,9 @@ gpg_error_t gpg_stream_seek (gpg_stream_t stream,
|
||||
gpg_error_t gpg_stream_stat (gpg_stream_t stream,
|
||||
size_t *size);
|
||||
|
||||
gpg_error_t gpg_stream_copy (gpg_stream_t dst,
|
||||
gpg_stream_t src);
|
||||
|
||||
typedef struct gpg_stream_spec_mem
|
||||
{
|
||||
char *memory;
|
||||
|
Loading…
x
Reference in New Issue
Block a user