=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/ssh-agent.c,v retrieving revision 1.111.2.2 retrieving revision 1.112 diff -u -r1.111.2.2 -r1.112 --- src/usr.bin/ssh/ssh-agent.c 2004/08/19 22:37:32 1.111.2.2 +++ src/usr.bin/ssh/ssh-agent.c 2003/09/18 08:49:45 1.112 @@ -35,7 +35,7 @@ #include "includes.h" #include -RCSID("$OpenBSD: ssh-agent.c,v 1.111.2.2 2004/08/19 22:37:32 brad Exp $"); +RCSID("$OpenBSD: ssh-agent.c,v 1.112 2003/09/18 08:49:45 markus Exp $"); #include #include @@ -50,6 +50,7 @@ #include "authfd.h" #include "compat.h" #include "log.h" +#include "readpass.h" #include "misc.h" #ifdef SMARTCARD @@ -174,7 +175,7 @@ p = read_passphrase(prompt, RP_ALLOW_EOF); if (p != NULL) { /* - * Accept empty responses and responses consisting + * Accept empty responses and responses consisting * of the word "yes" as affirmative. */ if (*p == '\0' || *p == '\n' || strcasecmp(p, "yes") == 0) @@ -781,7 +782,8 @@ { u_int i, old_alloc, new_alloc; - set_nonblock(fd); + if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) + error("fcntl O_NONBLOCK: %s", strerror(errno)); if (fd > max_fd) max_fd = fd; @@ -812,7 +814,7 @@ } static int -prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl, u_int *nallocp) +prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl, int *nallocp) { u_int i, sz; int n = 0; @@ -943,7 +945,7 @@ } static void -cleanup_socket(void) +cleanup_socket(void *p) { if (socket_name[0]) unlink(socket_name); @@ -951,17 +953,17 @@ rmdir(socket_dir); } -void +static void cleanup_exit(int i) { - cleanup_socket(); - _exit(i); + cleanup_socket(NULL); + exit(i); } static void cleanup_handler(int sig) { - cleanup_socket(); + cleanup_socket(NULL); _exit(2); } @@ -998,8 +1000,7 @@ main(int ac, char **av) { int c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0; - int sock, fd, ch; - u_int nalloc; + int sock, fd, ch, nalloc; char *shell, *format, *pidstr, *agentsocket = NULL; fd_set *readsetp = NULL, *writesetp = NULL; struct sockaddr_un sunaddr; @@ -1086,7 +1087,7 @@ if (agentsocket == NULL) { /* Create private directory for agent socket */ - strlcpy(socket_dir, "/tmp/ssh-XXXXXXXXXX", sizeof socket_dir); + strlcpy(socket_dir, "/tmp/ssh-XXXXXXXX", sizeof socket_dir); if (mkdtemp(socket_dir) == NULL) { perror("mkdtemp: private socket dir"); exit(1); @@ -1115,7 +1116,7 @@ perror("bind"); cleanup_exit(1); } - if (listen(sock, SSH_LISTEN_BACKLOG) < 0) { + if (listen(sock, 128) < 0) { perror("listen"); cleanup_exit(1); } @@ -1184,6 +1185,7 @@ } skip: + fatal_add_cleanup(cleanup_socket, NULL); new_socket(AUTH_SOCKET, sock); if (ac > 0) { signal(SIGALRM, check_parent_exists);