comparison svr-agentfwd.c @ 62:20563735e8b5

just checkpointing
author Matt Johnston <matt@ucc.asn.au>
date Tue, 10 Aug 2004 17:09:52 +0000
parents f789045062e6
children b0316ce64e4b
comparison
equal deleted inserted replaced
61:3a4f0ef1e8c3 62:20563735e8b5
42 42
43 #define AGENTDIRPREFIX "/tmp/dropbear-" 43 #define AGENTDIRPREFIX "/tmp/dropbear-"
44 44
45 static int send_msg_channel_open_agent(int fd); 45 static int send_msg_channel_open_agent(int fd);
46 static int bindagent(int fd, struct ChanSess * chansess); 46 static int bindagent(int fd, struct ChanSess * chansess);
47 static void agentaccept(struct Listener * listener); 47 static void agentaccept(struct Listener * listener, int sock);
48 48
49 /* Handles client requests to start agent forwarding, sets up listening socket. 49 /* Handles client requests to start agent forwarding, sets up listening socket.
50 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 50 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
51 int agentreq(struct ChanSess * chansess) { 51 int agentreq(struct ChanSess * chansess) {
52 52
76 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { 76 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
77 goto fail; 77 goto fail;
78 } 78 }
79 79
80 /* pass if off to listener */ 80 /* pass if off to listener */
81 chansess->agentlistener = new_listener( fd, 0, chansess, 81 chansess->agentlistener = new_listener( &fd, 1, 0, chansess,
82 agentaccept, NULL); 82 agentaccept, NULL);
83 83
84 if (chansess->agentlistener == NULL) { 84 if (chansess->agentlistener == NULL) {
85 goto fail; 85 goto fail;
86 } 86 }
95 } 95 }
96 96
97 /* accepts a connection on the forwarded socket and opens a new channel for it 97 /* accepts a connection on the forwarded socket and opens a new channel for it
98 * back to the client */ 98 * back to the client */
99 /* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 99 /* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
100 static void agentaccept(struct Listener * listener) { 100 static void agentaccept(struct Listener * listener, int sock) {
101 101
102 int fd; 102 int fd;
103 103
104 fd = accept(listener->sock, NULL, NULL); 104 fd = accept(sock, NULL, NULL);
105 if (fd < 0) { 105 if (fd < 0) {
106 TRACE(("accept failed")); 106 TRACE(("accept failed"));
107 return; 107 return;
108 } 108 }
109 109