summaryrefslogtreecommitdiff
path: root/ssh-agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-agent.c')
-rw-r--r--ssh-agent.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/ssh-agent.c b/ssh-agent.c
index c05c61468..a936134fe 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -35,7 +35,7 @@
35 35
36#include "includes.h" 36#include "includes.h"
37#include "openbsd-compat/sys-queue.h" 37#include "openbsd-compat/sys-queue.h"
38RCSID("$OpenBSD: ssh-agent.c,v 1.111 2003/06/12 19:12:03 markus Exp $"); 38RCSID("$OpenBSD: ssh-agent.c,v 1.108 2003/03/13 11:44:50 markus Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41#include <openssl/md5.h> 41#include <openssl/md5.h>
@@ -261,7 +261,7 @@ process_authentication_challenge1(SocketEntry *e)
261 /* The response is MD5 of decrypted challenge plus session id. */ 261 /* The response is MD5 of decrypted challenge plus session id. */
262 len = BN_num_bytes(challenge); 262 len = BN_num_bytes(challenge);
263 if (len <= 0 || len > 32) { 263 if (len <= 0 || len > 32) {
264 logit("process_authentication_challenge: bad challenge length %d", len); 264 log("process_authentication_challenge: bad challenge length %d", len);
265 goto failure; 265 goto failure;
266 } 266 }
267 memset(buf, 0, 32); 267 memset(buf, 0, 32);
@@ -350,7 +350,7 @@ process_remove_identity(SocketEntry *e, int version)
350 buffer_get_bignum(&e->request, key->rsa->n); 350 buffer_get_bignum(&e->request, key->rsa->n);
351 351
352 if (bits != key_size(key)) 352 if (bits != key_size(key))
353 logit("Warning: identity keysize mismatch: actual %u, announced %u", 353 log("Warning: identity keysize mismatch: actual %u, announced %u",
354 key_size(key), bits); 354 key_size(key), bits);
355 break; 355 break;
356 case 2: 356 case 2:
@@ -580,29 +580,13 @@ static void
580process_add_smartcard_key (SocketEntry *e) 580process_add_smartcard_key (SocketEntry *e)
581{ 581{
582 char *sc_reader_id = NULL, *pin; 582 char *sc_reader_id = NULL, *pin;
583 int i, version, success = 0, death = 0, confirm = 0; 583 int i, version, success = 0;
584 Key **keys, *k; 584 Key **keys, *k;
585 Identity *id; 585 Identity *id;
586 Idtab *tab; 586 Idtab *tab;
587 587
588 sc_reader_id = buffer_get_string(&e->request, NULL); 588 sc_reader_id = buffer_get_string(&e->request, NULL);
589 pin = buffer_get_string(&e->request, NULL); 589 pin = buffer_get_string(&e->request, NULL);
590
591 while (buffer_len(&e->request)) {
592 switch (buffer_get_char(&e->request)) {
593 case SSH_AGENT_CONSTRAIN_LIFETIME:
594 death = time(NULL) + buffer_get_int(&e->request);
595 break;
596 case SSH_AGENT_CONSTRAIN_CONFIRM:
597 confirm = 1;
598 break;
599 default:
600 break;
601 }
602 }
603 if (lifetime && !death)
604 death = time(NULL) + lifetime;
605
606 keys = sc_get_keys(sc_reader_id, pin); 590 keys = sc_get_keys(sc_reader_id, pin);
607 xfree(sc_reader_id); 591 xfree(sc_reader_id);
608 xfree(pin); 592 xfree(pin);
@@ -618,9 +602,9 @@ process_add_smartcard_key (SocketEntry *e)
618 if (lookup_identity(k, version) == NULL) { 602 if (lookup_identity(k, version) == NULL) {
619 id = xmalloc(sizeof(Identity)); 603 id = xmalloc(sizeof(Identity));
620 id->key = k; 604 id->key = k;
621 id->comment = sc_get_key_label(k); 605 id->comment = xstrdup("smartcard key");
622 id->death = death; 606 id->death = 0;
623 id->confirm = confirm; 607 id->confirm = 0;
624 TAILQ_INSERT_TAIL(&tab->idlist, id, next); 608 TAILQ_INSERT_TAIL(&tab->idlist, id, next);
625 tab->nentries++; 609 tab->nentries++;
626 success = 1; 610 success = 1;
@@ -764,7 +748,6 @@ process_message(SocketEntry *e)
764 break; 748 break;
765#ifdef SMARTCARD 749#ifdef SMARTCARD
766 case SSH_AGENTC_ADD_SMARTCARD_KEY: 750 case SSH_AGENTC_ADD_SMARTCARD_KEY:
767 case SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED:
768 process_add_smartcard_key(e); 751 process_add_smartcard_key(e);
769 break; 752 break;
770 case SSH_AGENTC_REMOVE_SMARTCARD_KEY: 753 case SSH_AGENTC_REMOVE_SMARTCARD_KEY:
@@ -784,7 +767,7 @@ process_message(SocketEntry *e)
784static void 767static void
785new_socket(sock_type type, int fd) 768new_socket(sock_type type, int fd)
786{ 769{
787 u_int i, old_alloc; 770 u_int i, old_alloc, new_alloc;
788 771
789 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) 772 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
790 error("fcntl O_NONBLOCK: %s", strerror(errno)); 773 error("fcntl O_NONBLOCK: %s", strerror(errno));
@@ -795,25 +778,26 @@ new_socket(sock_type type, int fd)
795 for (i = 0; i < sockets_alloc; i++) 778 for (i = 0; i < sockets_alloc; i++)
796 if (sockets[i].type == AUTH_UNUSED) { 779 if (sockets[i].type == AUTH_UNUSED) {
797 sockets[i].fd = fd; 780 sockets[i].fd = fd;
798 sockets[i].type = type;
799 buffer_init(&sockets[i].input); 781 buffer_init(&sockets[i].input);
800 buffer_init(&sockets[i].output); 782 buffer_init(&sockets[i].output);
801 buffer_init(&sockets[i].request); 783 buffer_init(&sockets[i].request);
784 sockets[i].type = type;
802 return; 785 return;
803 } 786 }
804 old_alloc = sockets_alloc; 787 old_alloc = sockets_alloc;
805 sockets_alloc += 10; 788 new_alloc = sockets_alloc + 10;
806 if (sockets) 789 if (sockets)
807 sockets = xrealloc(sockets, sockets_alloc * sizeof(sockets[0])); 790 sockets = xrealloc(sockets, new_alloc * sizeof(sockets[0]));
808 else 791 else
809 sockets = xmalloc(sockets_alloc * sizeof(sockets[0])); 792 sockets = xmalloc(new_alloc * sizeof(sockets[0]));
810 for (i = old_alloc; i < sockets_alloc; i++) 793 for (i = old_alloc; i < new_alloc; i++)
811 sockets[i].type = AUTH_UNUSED; 794 sockets[i].type = AUTH_UNUSED;
812 sockets[old_alloc].type = type; 795 sockets_alloc = new_alloc;
813 sockets[old_alloc].fd = fd; 796 sockets[old_alloc].fd = fd;
814 buffer_init(&sockets[old_alloc].input); 797 buffer_init(&sockets[old_alloc].input);
815 buffer_init(&sockets[old_alloc].output); 798 buffer_init(&sockets[old_alloc].output);
816 buffer_init(&sockets[old_alloc].request); 799 buffer_init(&sockets[old_alloc].request);
800 sockets[old_alloc].type = type;
817} 801}
818 802
819static int 803static int
@@ -979,7 +963,7 @@ check_parent_exists(int sig)
979 /* printf("Parent has died - Authentication agent exiting.\n"); */ 963 /* printf("Parent has died - Authentication agent exiting.\n"); */
980 cleanup_handler(sig); /* safe */ 964 cleanup_handler(sig); /* safe */
981 } 965 }
982 mysignal(SIGALRM, check_parent_exists); 966 signal(SIGALRM, check_parent_exists);
983 alarm(10); 967 alarm(10);
984 errno = save_errno; 968 errno = save_errno;
985} 969}
@@ -1024,7 +1008,7 @@ main(int ac, char **av)
1024 1008
1025 SSLeay_add_all_algorithms(); 1009 SSLeay_add_all_algorithms();
1026 1010
1027 __progname = ssh_get_progname(av[0]); 1011 __progname = get_progname(av[0]);
1028 init_rng(); 1012 init_rng();
1029 seed_rng(); 1013 seed_rng();
1030 1014
@@ -1211,7 +1195,7 @@ skip:
1211 fatal_add_cleanup(cleanup_socket, NULL); 1195 fatal_add_cleanup(cleanup_socket, NULL);
1212 new_socket(AUTH_SOCKET, sock); 1196 new_socket(AUTH_SOCKET, sock);
1213 if (ac > 0) { 1197 if (ac > 0) {
1214 mysignal(SIGALRM, check_parent_exists); 1198 signal(SIGALRM, check_parent_exists);
1215 alarm(10); 1199 alarm(10);
1216 } 1200 }
1217 idtab_init(); 1201 idtab_init();