/*
- *
+ *
* authfd.c
- *
+ *
* Author: Tatu Ylonen <ylo@cs.hut.fi>
- *
+ *
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
- *
+ *
* Created: Wed Mar 29 01:30:28 1995 ylo
- *
+ *
* Functions for connecting the local authentication agent.
- *
+ *
*/
#include "includes.h"
-RCSID("$Id$");
+RCSID("$OpenBSD: authfd.c,v 1.20 2000/06/20 01:39:38 markus Exp $");
#include "ssh.h"
#include "rsa.h"
#include "xmalloc.h"
#include "getput.h"
-#ifdef HAVE_OPENSSL
#include <openssl/rsa.h>
-#endif
-#ifdef HAVE_SSL
-#include <ssl/rsa.h>
-#endif
/* Returns the number of the authentication fd, or -1 if there is none. */
* ssh_get_authentication_socket().
*/
-void
+void
ssh_close_authentication_socket(int sock)
{
if (getenv(SSH_AUTHSOCKET_ENV_NAME))
* memory.
*/
-void
+void
ssh_close_authentication_connection(AuthenticationConnection *ac)
{
buffer_free(&ac->packet);
msg[2] = 0;
msg[3] = 1;
msg[4] = SSH_AGENTC_REQUEST_RSA_IDENTITIES;
- if (write(auth->fd, msg, 5) != 5) {
+ if (atomicio(write, auth->fd, msg, 5) != 5) {
error("write auth->fd: %.100s", strerror(errno));
return 0;
}
*comment = buffer_get_string(&auth->identities, NULL);
if (bits != BN_num_bits(n))
- error("Warning: keysize mismatch: actual %d, announced %u",
- BN_num_bits(n), bits);
+ log("Warning: identity keysize mismatch: actual %d, announced %u",
+ BN_num_bits(n), bits);
/* Decrement the number of remaining entries. */
auth->howmany--;
PUT_32BIT(buf, len);
/* Send the length and then the packet to the agent. */
- if (write(auth->fd, buf, 4) != 4 ||
- write(auth->fd, buffer_ptr(&buffer), buffer_len(&buffer)) !=
- buffer_len(&buffer)) {
+ if (atomicio(write, auth->fd, buf, 4) != 4 ||
+ atomicio(write, auth->fd, buffer_ptr(&buffer),
+ buffer_len(&buffer)) != buffer_len(&buffer)) {
error("Error writing to authentication socket.");
error_cleanup:
buffer_free(&buffer);
* be used by normal applications.
*/
-int
+int
ssh_add_identity(AuthenticationConnection *auth,
RSA * key, const char *comment)
{
PUT_32BIT(buf, len);
/* Send the length and then the packet to the agent. */
- if (write(auth->fd, buf, 4) != 4 ||
- write(auth->fd, buffer_ptr(&buffer), buffer_len(&buffer)) !=
- buffer_len(&buffer)) {
+ if (atomicio(write, auth->fd, buf, 4) != 4 ||
+ atomicio(write, auth->fd, buffer_ptr(&buffer),
+ buffer_len(&buffer)) != buffer_len(&buffer)) {
error("Error writing to authentication socket.");
error_cleanup:
buffer_free(&buffer);
* meant to be used by normal applications.
*/
-int
+int
ssh_remove_identity(AuthenticationConnection *auth, RSA *key)
{
Buffer buffer;
PUT_32BIT(buf, len);
/* Send the length and then the packet to the agent. */
- if (write(auth->fd, buf, 4) != 4 ||
- write(auth->fd, buffer_ptr(&buffer), buffer_len(&buffer)) !=
- buffer_len(&buffer)) {
+ if (atomicio(write, auth->fd, buf, 4) != 4 ||
+ atomicio(write, auth->fd, buffer_ptr(&buffer),
+ buffer_len(&buffer)) != buffer_len(&buffer)) {
error("Error writing to authentication socket.");
error_cleanup:
buffer_free(&buffer);
* by normal applications.
*/
-int
+int
ssh_remove_all_identities(AuthenticationConnection *auth)
{
Buffer buffer;
buf[4] = SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES;
/* Send the length and then the packet to the agent. */
- if (write(auth->fd, buf, 5) != 5) {
+ if (atomicio(write, auth->fd, buf, 5) != 5) {
error("Error writing to authentication socket.");
return 0;
}