summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-06-09 01:11:59 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-06-09 01:11:59 +0000
commit838394ca26ff175e7f2d1729112f3f2605de4096 (patch)
tree5bd1822927d6a6af8ad46d27eccac8c103b12e70 /channels.c
parentc4b7225b8ddbc4932d5d4a63183b911a9f2a1d73 (diff)
- markus@cvs.openbsd.org 2001/06/03 14:55:39
[channels.c channels.h session.c] use fatal_register_cleanup instead of atexit, sync with x11 authdir handling
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/channels.c b/channels.c
index 518a071b8..110613896 100644
--- a/channels.c
+++ b/channels.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: channels.c,v 1.121 2001/05/31 10:30:14 markus Exp $"); 43RCSID("$OpenBSD: channels.c,v 1.122 2001/06/03 14:55:38 markus Exp $");
44 44
45#include "ssh.h" 45#include "ssh.h"
46#include "ssh1.h" 46#include "ssh1.h"
@@ -2777,10 +2777,13 @@ auth_get_socket_name()
2777/* removes the agent forwarding socket */ 2777/* removes the agent forwarding socket */
2778 2778
2779void 2779void
2780cleanup_socket(void) 2780auth_sock_cleanup_proc(void *ignored)
2781{ 2781{
2782 unlink(auth_sock_name); 2782 if (auth_sock_name) {
2783 rmdir(auth_sock_dir); 2783 unlink(auth_sock_name);
2784 rmdir(auth_sock_dir);
2785 auth_sock_name = NULL;
2786 }
2784} 2787}
2785 2788
2786/* 2789/*
@@ -2822,11 +2825,9 @@ auth_input_request_forwarding(struct passwd * pw)
2822 snprintf(auth_sock_name, MAXPATHLEN, "%s/agent.%d", 2825 snprintf(auth_sock_name, MAXPATHLEN, "%s/agent.%d",
2823 auth_sock_dir, (int) getpid()); 2826 auth_sock_dir, (int) getpid());
2824 2827
2825 if (atexit(cleanup_socket) < 0) { 2828 /* delete agent socket on fatal() */
2826 int saved = errno; 2829 fatal_add_cleanup(auth_sock_cleanup_proc, NULL);
2827 cleanup_socket(); 2830
2828 packet_disconnect("socket: %.100s", strerror(saved));
2829 }
2830 /* Create the socket. */ 2831 /* Create the socket. */
2831 sock = socket(AF_UNIX, SOCK_STREAM, 0); 2832 sock = socket(AF_UNIX, SOCK_STREAM, 0);
2832 if (sock < 0) 2833 if (sock < 0)
@@ -2855,6 +2856,7 @@ auth_input_request_forwarding(struct passwd * pw)
2855 0, xstrdup("auth socket"), 1); 2856 0, xstrdup("auth socket"), 1);
2856 if (nc == NULL) { 2857 if (nc == NULL) {
2857 error("auth_input_request_forwarding: channel_new failed"); 2858 error("auth_input_request_forwarding: channel_new failed");
2859 auth_sock_cleanup_proc(NULL);
2858 close(sock); 2860 close(sock);
2859 return 0; 2861 return 0;
2860 } 2862 }