=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/channels.c,v retrieving revision 1.121 retrieving revision 1.122 diff -u -r1.121 -r1.122 --- src/usr.bin/ssh/channels.c 2001/05/31 10:30:14 1.121 +++ src/usr.bin/ssh/channels.c 2001/06/03 14:55:38 1.122 @@ -40,7 +40,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: channels.c,v 1.121 2001/05/31 10:30:14 markus Exp $"); +RCSID("$OpenBSD: channels.c,v 1.122 2001/06/03 14:55:38 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -2720,10 +2720,13 @@ /* removes the agent forwarding socket */ void -cleanup_socket(void) +auth_sock_cleanup_proc(void *ignored) { - unlink(auth_sock_name); - rmdir(auth_sock_dir); + if (auth_sock_name) { + unlink(auth_sock_name); + rmdir(auth_sock_dir); + auth_sock_name = NULL; + } } /* @@ -2765,11 +2768,9 @@ snprintf(auth_sock_name, MAXPATHLEN, "%s/agent.%d", auth_sock_dir, (int) getpid()); - if (atexit(cleanup_socket) < 0) { - int saved = errno; - cleanup_socket(); - packet_disconnect("socket: %.100s", strerror(saved)); - } + /* delete agent socket on fatal() */ + fatal_add_cleanup(auth_sock_cleanup_proc, NULL); + /* Create the socket. */ sock = socket(AF_UNIX, SOCK_STREAM, 0); if (sock < 0) @@ -2798,6 +2799,7 @@ 0, xstrdup("auth socket"), 1); if (nc == NULL) { error("auth_input_request_forwarding: channel_new failed"); + auth_sock_cleanup_proc(NULL); close(sock); return 0; }