summaryrefslogtreecommitdiff
path: root/ssh-agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-agent.c')
-rw-r--r--ssh-agent.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/ssh-agent.c b/ssh-agent.c
index c05c61468..e5232fc9b 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.117 2003/12/02 17:01:15 markus Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41#include <openssl/md5.h> 41#include <openssl/md5.h>
@@ -179,7 +179,7 @@ confirm_key(Identity *id)
179 p = read_passphrase(prompt, RP_ALLOW_EOF); 179 p = read_passphrase(prompt, RP_ALLOW_EOF);
180 if (p != NULL) { 180 if (p != NULL) {
181 /* 181 /*
182 * Accept empty responses and responses consisting 182 * Accept empty responses and responses consisting
183 * of the word "yes" as affirmative. 183 * of the word "yes" as affirmative.
184 */ 184 */
185 if (*p == '\0' || *p == '\n' || strcasecmp(p, "yes") == 0) 185 if (*p == '\0' || *p == '\n' || strcasecmp(p, "yes") == 0)
@@ -784,7 +784,7 @@ process_message(SocketEntry *e)
784static void 784static void
785new_socket(sock_type type, int fd) 785new_socket(sock_type type, int fd)
786{ 786{
787 u_int i, old_alloc; 787 u_int i, old_alloc, new_alloc;
788 788
789 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) 789 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
790 error("fcntl O_NONBLOCK: %s", strerror(errno)); 790 error("fcntl O_NONBLOCK: %s", strerror(errno));
@@ -795,25 +795,26 @@ new_socket(sock_type type, int fd)
795 for (i = 0; i < sockets_alloc; i++) 795 for (i = 0; i < sockets_alloc; i++)
796 if (sockets[i].type == AUTH_UNUSED) { 796 if (sockets[i].type == AUTH_UNUSED) {
797 sockets[i].fd = fd; 797 sockets[i].fd = fd;
798 sockets[i].type = type;
799 buffer_init(&sockets[i].input); 798 buffer_init(&sockets[i].input);
800 buffer_init(&sockets[i].output); 799 buffer_init(&sockets[i].output);
801 buffer_init(&sockets[i].request); 800 buffer_init(&sockets[i].request);
801 sockets[i].type = type;
802 return; 802 return;
803 } 803 }
804 old_alloc = sockets_alloc; 804 old_alloc = sockets_alloc;
805 sockets_alloc += 10; 805 new_alloc = sockets_alloc + 10;
806 if (sockets) 806 if (sockets)
807 sockets = xrealloc(sockets, sockets_alloc * sizeof(sockets[0])); 807 sockets = xrealloc(sockets, new_alloc * sizeof(sockets[0]));
808 else 808 else
809 sockets = xmalloc(sockets_alloc * sizeof(sockets[0])); 809 sockets = xmalloc(new_alloc * sizeof(sockets[0]));
810 for (i = old_alloc; i < sockets_alloc; i++) 810 for (i = old_alloc; i < new_alloc; i++)
811 sockets[i].type = AUTH_UNUSED; 811 sockets[i].type = AUTH_UNUSED;
812 sockets[old_alloc].type = type; 812 sockets_alloc = new_alloc;
813 sockets[old_alloc].fd = fd; 813 sockets[old_alloc].fd = fd;
814 buffer_init(&sockets[old_alloc].input); 814 buffer_init(&sockets[old_alloc].input);
815 buffer_init(&sockets[old_alloc].output); 815 buffer_init(&sockets[old_alloc].output);
816 buffer_init(&sockets[old_alloc].request); 816 buffer_init(&sockets[old_alloc].request);
817 sockets[old_alloc].type = type;
817} 818}
818 819
819static int 820static int
@@ -948,7 +949,7 @@ after_select(fd_set *readset, fd_set *writeset)
948} 949}
949 950
950static void 951static void
951cleanup_socket(void *p) 952cleanup_socket(void)
952{ 953{
953 if (socket_name[0]) 954 if (socket_name[0])
954 unlink(socket_name); 955 unlink(socket_name);
@@ -956,17 +957,17 @@ cleanup_socket(void *p)
956 rmdir(socket_dir); 957 rmdir(socket_dir);
957} 958}
958 959
959static void 960void
960cleanup_exit(int i) 961cleanup_exit(int i)
961{ 962{
962 cleanup_socket(NULL); 963 cleanup_socket();
963 exit(i); 964 _exit(i);
964} 965}
965 966
966static void 967static void
967cleanup_handler(int sig) 968cleanup_handler(int sig)
968{ 969{
969 cleanup_socket(NULL); 970 cleanup_socket();
970 _exit(2); 971 _exit(2);
971} 972}
972 973
@@ -1099,7 +1100,7 @@ main(int ac, char **av)
1099 1100
1100 if (agentsocket == NULL) { 1101 if (agentsocket == NULL) {
1101 /* Create private directory for agent socket */ 1102 /* Create private directory for agent socket */
1102 strlcpy(socket_dir, "/tmp/ssh-XXXXXXXX", sizeof socket_dir); 1103 strlcpy(socket_dir, "/tmp/ssh-XXXXXXXXXX", sizeof socket_dir);
1103 if (mkdtemp(socket_dir) == NULL) { 1104 if (mkdtemp(socket_dir) == NULL) {
1104 perror("mkdtemp: private socket dir"); 1105 perror("mkdtemp: private socket dir");
1105 exit(1); 1106 exit(1);
@@ -1137,7 +1138,7 @@ main(int ac, char **av)
1137#ifdef HAVE_CYGWIN 1138#ifdef HAVE_CYGWIN
1138 umask(prev_mask); 1139 umask(prev_mask);
1139#endif 1140#endif
1140 if (listen(sock, 128) < 0) { 1141 if (listen(sock, SSH_LISTEN_BACKLOG) < 0) {
1141 perror("listen"); 1142 perror("listen");
1142 cleanup_exit(1); 1143 cleanup_exit(1);
1143 } 1144 }
@@ -1208,7 +1209,6 @@ main(int ac, char **av)
1208#endif 1209#endif
1209 1210
1210skip: 1211skip:
1211 fatal_add_cleanup(cleanup_socket, NULL);
1212 new_socket(AUTH_SOCKET, sock); 1212 new_socket(AUTH_SOCKET, sock);
1213 if (ac > 0) { 1213 if (ac > 0) {
1214 mysignal(SIGALRM, check_parent_exists); 1214 mysignal(SIGALRM, check_parent_exists);