summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/channels.c b/channels.c
index 18b6c468e..35edff6dc 100644
--- a/channels.c
+++ b/channels.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: channels.c,v 1.130 2001/06/30 18:08:39 stevesk Exp $"); 42RCSID("$OpenBSD: channels.c,v 1.131 2001/07/02 22:52:56 markus Exp $");
43 43
44#include "ssh.h" 44#include "ssh.h"
45#include "ssh1.h" 45#include "ssh1.h"
@@ -260,7 +260,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
260 c->cb_fn = NULL; 260 c->cb_fn = NULL;
261 c->cb_arg = NULL; 261 c->cb_arg = NULL;
262 c->cb_event = 0; 262 c->cb_event = 0;
263 c->dettach_user = NULL; 263 c->detach_user = NULL;
264 c->input_filter = NULL; 264 c->input_filter = NULL;
265 debug("channel %d: new [%s]", found, remote_name); 265 debug("channel %d: new [%s]", found, remote_name);
266 return c; 266 return c;
@@ -310,9 +310,9 @@ channel_free(Channel *c)
310 debug3("channel_free: status: %s", s); 310 debug3("channel_free: status: %s", s);
311 xfree(s); 311 xfree(s);
312 312
313 if (c->dettach_user != NULL) { 313 if (c->detach_user != NULL) {
314 debug("channel_free: channel %d: dettaching channel user", c->self); 314 debug("channel_free: channel %d: detaching channel user", c->self);
315 c->dettach_user(c->self, NULL); 315 c->detach_user(c->self, NULL);
316 } 316 }
317 if (c->sock != -1) 317 if (c->sock != -1)
318 shutdown(c->sock, SHUT_RDWR); 318 shutdown(c->sock, SHUT_RDWR);
@@ -338,6 +338,22 @@ channel_free_all(void)
338 channel_free(channels[i]); 338 channel_free(channels[i]);
339} 339}
340 340
341void
342channel_detach_all(void)
343{
344 int i;
345 Channel *c;
346
347 for (i = 0; i < channels_alloc; i++) {
348 c = channels[i];
349 if (c != NULL && c->detach_user != NULL) {
350 debug("channel_detach_all: channel %d", c->self);
351 c->detach_user(c->self, NULL);
352 c->detach_user = NULL;
353 }
354 }
355}
356
341/* 357/*
342 * Closes the sockets/fds of all channels. This is used to close extra file 358 * Closes the sockets/fds of all channels. This is used to close extra file
343 * descriptors after a fork. 359 * descriptors after a fork.
@@ -354,6 +370,32 @@ channel_close_all()
354} 370}
355 371
356/* 372/*
373 * Stop listening to channels.
374 */
375
376void
377channel_stop_listening(void)
378{
379 int i;
380 Channel *c;
381
382 for (i = 0; i < channels_alloc; i++) {
383 c = channels[i];
384 if (c != NULL) {
385 switch (c->type) {
386 case SSH_CHANNEL_AUTH_SOCKET:
387 case SSH_CHANNEL_PORT_LISTENER:
388 case SSH_CHANNEL_RPORT_LISTENER:
389 case SSH_CHANNEL_X11_LISTENER:
390 close(c->sock);
391 channel_free(c);
392 break;
393 }
394 }
395 }
396}
397
398/*
357 * Returns true if no channel has too much buffered data, and false if one or 399 * Returns true if no channel has too much buffered data, and false if one or
358 * more channel is overfull. 400 * more channel is overfull.
359 */ 401 */
@@ -579,7 +621,7 @@ channel_register_cleanup(int id, channel_callback_fn *fn)
579 log("channel_register_cleanup: %d: bad id", id); 621 log("channel_register_cleanup: %d: bad id", id);
580 return; 622 return;
581 } 623 }
582 c->dettach_user = fn; 624 c->detach_user = fn;
583} 625}
584void 626void
585channel_cancel_cleanup(int id) 627channel_cancel_cleanup(int id)
@@ -589,7 +631,7 @@ channel_cancel_cleanup(int id)
589 log("channel_cancel_cleanup: %d: bad id", id); 631 log("channel_cancel_cleanup: %d: bad id", id);
590 return; 632 return;
591 } 633 }
592 c->dettach_user = NULL; 634 c->detach_user = NULL;
593} 635}
594void 636void
595channel_register_filter(int id, channel_filter_fn *fn) 637channel_register_filter(int id, channel_filter_fn *fn)