summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-06-21 03:19:23 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-06-21 03:19:23 +0000
commit601e43638e9e7889127634c3ba0949ba9fb917aa (patch)
treecf47af3b86f9260589980db64440cea4cd2d8dbd
parent0a7ca6c7baf13265e86b98a40bfd00714d67c84e (diff)
- markus@cvs.openbsd.org 2001/06/20 13:56:39
[channels.c channels.h clientloop.c packet.c serverloop.c] move from channel_stop_listening to channel_free_all, call channel_free_all before calling waitpid() in serverloop. fixes the utmp handling; report from Lutz.Jaenicke@aet.TU-Cottbus.DE
-rw-r--r--ChangeLog7
-rw-r--r--channels.c40
-rw-r--r--channels.h5
-rw-r--r--clientloop.c7
-rw-r--r--packet.c4
-rw-r--r--serverloop.c8
6 files changed, 24 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index f2dc8c5aa..2360bbe74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,11 @@
21 - markus@cvs.openbsd.org 2001/06/19 15:40:45 21 - markus@cvs.openbsd.org 2001/06/19 15:40:45
22 [session.c] 22 [session.c]
23 allocate and free at the same level. 23 allocate and free at the same level.
24 - markus@cvs.openbsd.org 2001/06/20 13:56:39
25 [channels.c channels.h clientloop.c packet.c serverloop.c]
26 move from channel_stop_listening to channel_free_all,
27 call channel_free_all before calling waitpid() in serverloop.
28 fixes the utmp handling; report from Lutz.Jaenicke@aet.TU-Cottbus.DE
24 29
2520010615 3020010615
26 - (stevesk) don't set SA_RESTART and set SIGCHLD to SIG_DFL 31 - (stevesk) don't set SA_RESTART and set SIGCHLD to SIG_DFL
@@ -5673,4 +5678,4 @@
5673 - Wrote replacements for strlcpy and mkdtemp 5678 - Wrote replacements for strlcpy and mkdtemp
5674 - Released 1.0pre1 5679 - Released 1.0pre1
5675 5680
5676$Id: ChangeLog,v 1.1295 2001/06/21 03:17:42 mouring Exp $ 5681$Id: ChangeLog,v 1.1296 2001/06/21 03:19:23 mouring Exp $
diff --git a/channels.c b/channels.c
index 283a70323..d9513fada 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.125 2001/06/07 20:23:04 markus Exp $"); 43RCSID("$OpenBSD: channels.c,v 1.126 2001/06/20 13:56:39 markus Exp $");
44 44
45#include "ssh.h" 45#include "ssh.h"
46#include "ssh1.h" 46#include "ssh1.h"
@@ -223,11 +223,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
223 channels = xmalloc(channels_alloc * sizeof(Channel *)); 223 channels = xmalloc(channels_alloc * sizeof(Channel *));
224 for (i = 0; i < channels_alloc; i++) 224 for (i = 0; i < channels_alloc; i++)
225 channels[i] = NULL; 225 channels[i] = NULL;
226 /* 226 fatal_add_cleanup((void (*) (void *)) channel_free_all, NULL);
227 * Kludge: arrange a call to channel_stop_listening if we
228 * terminate with fatal().
229 */
230 fatal_add_cleanup((void (*) (void *)) channel_stop_listening, NULL);
231 } 227 }
232 /* Try to find a free slot where to put the new channel. */ 228 /* Try to find a free slot where to put the new channel. */
233 for (found = -1, i = 0; i < channels_alloc; i++) 229 for (found = -1, i = 0; i < channels_alloc; i++)
@@ -334,38 +330,14 @@ channel_free(Channel *c)
334 xfree(c); 330 xfree(c);
335} 331}
336 332
337
338/*
339 * Stops listening for channels, and removes any unix domain sockets that we
340 * might have.
341 */
342
343void 333void
344channel_stop_listening() 334channel_free_all(void)
345{ 335{
346 int i; 336 int i;
347 Channel *c;
348 337
349 for (i = 0; i < channels_alloc; i++) { 338 for (i = 0; i < channels_alloc; i++)
350 c = channels[i]; 339 if (channels[i] != NULL)
351 if (c != NULL) { 340 channel_free(channels[i]);
352 switch (c->type) {
353 case SSH_CHANNEL_AUTH_SOCKET:
354 close(c->sock);
355 /* auth_sock_cleanup_proc deletes the socket */
356 channel_free(c);
357 break;
358 case SSH_CHANNEL_PORT_LISTENER:
359 case SSH_CHANNEL_RPORT_LISTENER:
360 case SSH_CHANNEL_X11_LISTENER:
361 close(c->sock);
362 channel_free(c);
363 break;
364 default:
365 break;
366 }
367 }
368 }
369} 341}
370 342
371/* 343/*
diff --git a/channels.h b/channels.h
index 53c914e0f..419b63623 100644
--- a/channels.h
+++ b/channels.h
@@ -32,7 +32,7 @@
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35/* RCSID("$OpenBSD: channels.h,v 1.38 2001/06/16 08:50:39 markus Exp $"); */ 35/* RCSID("$OpenBSD: channels.h,v 1.39 2001/06/20 13:56:39 markus Exp $"); */
36 36
37#ifndef CHANNEL_H 37#ifndef CHANNEL_H
38#define CHANNEL_H 38#define CHANNEL_H
@@ -150,6 +150,7 @@ void
150channel_set_fds(int id, int rfd, int wfd, int efd, 150channel_set_fds(int id, int rfd, int wfd, int efd,
151 int extusage, int nonblock); 151 int extusage, int nonblock);
152void channel_free(Channel *c); 152void channel_free(Channel *c);
153void channel_free_all(void);
153 154
154void channel_send_open(int id); 155void channel_send_open(int id);
155void channel_request(int id, char *service, int wantconfirm); 156void channel_request(int id, char *service, int wantconfirm);
@@ -182,8 +183,8 @@ void channel_after_select(fd_set * readset, fd_set * writeset);
182void channel_output_poll(void); 183void channel_output_poll(void);
183 184
184int channel_not_very_much_buffered_data(void); 185int channel_not_very_much_buffered_data(void);
185void channel_stop_listening(void);
186void channel_close_all(void); 186void channel_close_all(void);
187void channel_free_all(void);
187int channel_still_open(void); 188int channel_still_open(void);
188char *channel_open_message(void); 189char *channel_open_message(void);
189int channel_find_open(void); 190int channel_find_open(void);
diff --git a/clientloop.c b/clientloop.c
index 3a1b43dda..a62a71131 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.75 2001/06/04 23:07:20 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.76 2001/06/20 13:56:39 markus Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -546,7 +546,7 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
546 leave_raw_mode(); 546 leave_raw_mode();
547 547
548 /* Stop listening for new connections. */ 548 /* Stop listening for new connections. */
549 channel_stop_listening(); 549 channel_close_all(); /* proto1 only XXXX */
550 550
551 printf("%c& [backgrounded]\n", escape_char); 551 printf("%c& [backgrounded]\n", escape_char);
552 552
@@ -926,8 +926,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
926 if (have_pty) 926 if (have_pty)
927 signal(SIGWINCH, SIG_DFL); 927 signal(SIGWINCH, SIG_DFL);
928 928
929 /* Stop listening for connections. */ 929 channel_free_all();
930 channel_stop_listening();
931 930
932 if (have_pty) 931 if (have_pty)
933 leave_raw_mode(); 932 leave_raw_mode();
diff --git a/packet.c b/packet.c
index e24b2e87e..64aabb3b0 100644
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: packet.c,v 1.66 2001/06/12 16:11:26 markus Exp $"); 40RCSID("$OpenBSD: packet.c,v 1.67 2001/06/20 13:56:39 markus Exp $");
41 41
42#include "xmalloc.h" 42#include "xmalloc.h"
43#include "buffer.h" 43#include "buffer.h"
@@ -1085,7 +1085,7 @@ packet_disconnect(const char *fmt,...)
1085 packet_write_wait(); 1085 packet_write_wait();
1086 1086
1087 /* Stop listening for connections. */ 1087 /* Stop listening for connections. */
1088 channel_stop_listening(); 1088 channel_close_all();
1089 1089
1090 /* Close the connection. */ 1090 /* Close the connection. */
1091 packet_close(); 1091 packet_close();
diff --git a/serverloop.c b/serverloop.c
index bafbfb0ac..1ce6c9106 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: serverloop.c,v 1.68 2001/06/04 23:07:20 markus Exp $"); 38RCSID("$OpenBSD: serverloop.c,v 1.69 2001/06/20 13:56:39 markus Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "packet.h" 41#include "packet.h"
@@ -608,8 +608,7 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
608 close(fdin); 608 close(fdin);
609 fdin = -1; 609 fdin = -1;
610 610
611 /* Stop listening for channels; this removes unix domain sockets. */ 611 channel_free_all();
612 channel_stop_listening();
613 612
614 /* We no longer want our SIGCHLD handler to be called. */ 613 /* We no longer want our SIGCHLD handler to be called. */
615 signal(SIGCHLD, SIG_DFL); 614 signal(SIGCHLD, SIG_DFL);
@@ -700,10 +699,11 @@ server_loop2(void)
700 if (writeset) 699 if (writeset)
701 xfree(writeset); 700 xfree(writeset);
702 701
702 channel_free_all();
703
703 signal(SIGCHLD, SIG_DFL); 704 signal(SIGCHLD, SIG_DFL);
704 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) 705 while ((pid = waitpid(-1, &status, WNOHANG)) > 0)
705 session_close_by_pid(pid, status); 706 session_close_by_pid(pid, status);
706 channel_stop_listening();
707} 707}
708 708
709void 709void