summaryrefslogtreecommitdiff
path: root/serverloop.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-04-16 11:18:38 +1000
committerDamien Miller <djm@mindrot.org>2000-04-16 11:18:38 +1000
commit4af51306d9a51459a5bef922df1037f876ae51fe (patch)
tree09ecfc215fce82345a3259f8a0f384b9a67906f0 /serverloop.c
parent5d1705ecf9bd3216dc99a84242bcdf2e7297d307 (diff)
- OpenBSD CVS updates.
[ssh.1 ssh.c] - ssh -2 [auth.c channels.c clientloop.c packet.c packet.h serverloop.c] [session.c sshconnect.c] - check payload for (illegal) extra data [ALL] - whitespace cleanup
Diffstat (limited to 'serverloop.c')
-rw-r--r--serverloop.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/serverloop.c b/serverloop.c
index 0ea57faa0..a7abbe404 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -59,7 +59,7 @@ static volatile int child_wait_status; /* Status from wait(). */
59 59
60void server_init_dispatch(void); 60void server_init_dispatch(void);
61 61
62void 62void
63sigchld_handler(int sig) 63sigchld_handler(int sig)
64{ 64{
65 int save_errno = errno; 65 int save_errno = errno;
@@ -78,7 +78,7 @@ sigchld_handler(int sig)
78 signal(SIGCHLD, sigchld_handler); 78 signal(SIGCHLD, sigchld_handler);
79 errno = save_errno; 79 errno = save_errno;
80} 80}
81void 81void
82sigchld_handler2(int sig) 82sigchld_handler2(int sig)
83{ 83{
84 int save_errno = errno; 84 int save_errno = errno;
@@ -92,7 +92,7 @@ sigchld_handler2(int sig)
92 * Make packets from buffered stderr data, and buffer it for sending 92 * Make packets from buffered stderr data, and buffer it for sending
93 * to the client. 93 * to the client.
94 */ 94 */
95void 95void
96make_packets_from_stderr_data() 96make_packets_from_stderr_data()
97{ 97{
98 int len; 98 int len;
@@ -121,7 +121,7 @@ make_packets_from_stderr_data()
121 * Make packets from buffered stdout data, and buffer it for sending to the 121 * Make packets from buffered stdout data, and buffer it for sending to the
122 * client. 122 * client.
123 */ 123 */
124void 124void
125make_packets_from_stdout_data() 125make_packets_from_stdout_data()
126{ 126{
127 int len; 127 int len;
@@ -152,7 +152,7 @@ make_packets_from_stdout_data()
152 * have data or can accept data. Optionally, a maximum time can be specified 152 * have data or can accept data. Optionally, a maximum time can be specified
153 * for the duration of the wait (0 = infinite). 153 * for the duration of the wait (0 = infinite).
154 */ 154 */
155void 155void
156wait_until_can_do_something(fd_set * readset, fd_set * writeset, 156wait_until_can_do_something(fd_set * readset, fd_set * writeset,
157 unsigned int max_time_milliseconds) 157 unsigned int max_time_milliseconds)
158{ 158{
@@ -246,7 +246,7 @@ retry_select:
246 * Processes input from the client and the program. Input data is stored 246 * Processes input from the client and the program. Input data is stored
247 * in buffers and processed later. 247 * in buffers and processed later.
248 */ 248 */
249void 249void
250process_input(fd_set * readset) 250process_input(fd_set * readset)
251{ 251{
252 int len; 252 int len;
@@ -299,7 +299,7 @@ process_input(fd_set * readset)
299/* 299/*
300 * Sends data from internal buffers to client program stdin. 300 * Sends data from internal buffers to client program stdin.
301 */ 301 */
302void 302void
303process_output(fd_set * writeset) 303process_output(fd_set * writeset)
304{ 304{
305 int len; 305 int len;
@@ -334,7 +334,7 @@ process_output(fd_set * writeset)
334 * Wait until all buffered output has been sent to the client. 334 * Wait until all buffered output has been sent to the client.
335 * This is used when the program terminates. 335 * This is used when the program terminates.
336 */ 336 */
337void 337void
338drain_output() 338drain_output()
339{ 339{
340 /* Send any buffered stdout data to the client. */ 340 /* Send any buffered stdout data to the client. */
@@ -359,7 +359,7 @@ drain_output()
359 packet_write_wait(); 359 packet_write_wait();
360} 360}
361 361
362void 362void
363process_buffered_input_packets() 363process_buffered_input_packets()
364{ 364{
365 dispatch_run(DISPATCH_NONBLOCK, NULL); 365 dispatch_run(DISPATCH_NONBLOCK, NULL);
@@ -372,7 +372,7 @@ process_buffered_input_packets()
372 * stdin (of the child program), and reads from stdout and stderr (of the 372 * stdin (of the child program), and reads from stdout and stderr (of the
373 * child program). 373 * child program).
374 */ 374 */
375void 375void
376server_loop(int pid, int fdin_arg, int fdout_arg, int fderr_arg) 376server_loop(int pid, int fdin_arg, int fdout_arg, int fderr_arg)
377{ 377{
378 int wait_status, wait_pid; /* Status and pid returned by wait(). */ 378 int wait_status, wait_pid; /* Status and pid returned by wait(). */
@@ -604,7 +604,7 @@ server_loop(int pid, int fdin_arg, int fdout_arg, int fderr_arg)
604 /* NOTREACHED */ 604 /* NOTREACHED */
605} 605}
606 606
607void 607void
608server_loop2(void) 608server_loop2(void)
609{ 609{
610 fd_set readset, writeset; 610 fd_set readset, writeset;
@@ -697,16 +697,17 @@ int
697input_direct_tcpip(void) 697input_direct_tcpip(void)
698{ 698{
699 int sock; 699 int sock;
700 char *host, *originator; 700 char *target, *originator;
701 int host_port, originator_port; 701 int target_port, originator_port;
702 702
703 host = packet_get_string(NULL); 703 target = packet_get_string(NULL);
704 host_port = packet_get_int(); 704 target_port = packet_get_int();
705 originator = packet_get_string(NULL); 705 originator = packet_get_string(NULL);
706 originator_port = packet_get_int(); 706 originator_port = packet_get_int();
707 packet_done();
707 /* XXX check permission */ 708 /* XXX check permission */
708 sock = channel_connect_to(host, host_port); 709 sock = channel_connect_to(target, target_port);
709 xfree(host); 710 xfree(target);
710 xfree(originator); 711 xfree(originator);
711 if (sock < 0) 712 if (sock < 0)
712 return -1; 713 return -1;
@@ -714,7 +715,7 @@ input_direct_tcpip(void)
714 sock, sock, -1, 4*1024, 32*1024, 0, xstrdup("direct-tcpip")); 715 sock, sock, -1, 4*1024, 32*1024, 0, xstrdup("direct-tcpip"));
715} 716}
716 717
717void 718void
718server_input_channel_open(int type, int plen) 719server_input_channel_open(int type, int plen)
719{ 720{
720 Channel *c = NULL; 721 Channel *c = NULL;
@@ -735,6 +736,7 @@ server_input_channel_open(int type, int plen)
735 736
736 if (strcmp(ctype, "session") == 0) { 737 if (strcmp(ctype, "session") == 0) {
737 debug("open session"); 738 debug("open session");
739 packet_done();
738 /* 740 /*
739 * A server session has no fd to read or write 741 * A server session has no fd to read or write
740 * until a CHANNEL_REQUEST for a shell is made, 742 * until a CHANNEL_REQUEST for a shell is made,
@@ -783,7 +785,7 @@ server_input_channel_open(int type, int plen)
783 xfree(ctype); 785 xfree(ctype);
784} 786}
785 787
786void 788void
787server_init_dispatch_20() 789server_init_dispatch_20()
788{ 790{
789 debug("server_init_dispatch_20"); 791 debug("server_init_dispatch_20");
@@ -798,7 +800,7 @@ server_init_dispatch_20()
798 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request); 800 dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request);
799 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust); 801 dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
800} 802}
801void 803void
802server_init_dispatch_13() 804server_init_dispatch_13()
803{ 805{
804 debug("server_init_dispatch_13"); 806 debug("server_init_dispatch_13");
@@ -813,7 +815,7 @@ server_init_dispatch_13()
813 dispatch_set(SSH_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure); 815 dispatch_set(SSH_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure);
814 dispatch_set(SSH_MSG_PORT_OPEN, &channel_input_port_open); 816 dispatch_set(SSH_MSG_PORT_OPEN, &channel_input_port_open);
815} 817}
816void 818void
817server_init_dispatch_15() 819server_init_dispatch_15()
818{ 820{
819 server_init_dispatch_13(); 821 server_init_dispatch_13();
@@ -821,7 +823,7 @@ server_init_dispatch_15()
821 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof); 823 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof);
822 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, &channel_input_oclose); 824 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, &channel_input_oclose);
823} 825}
824void 826void
825server_init_dispatch() 827server_init_dispatch()
826{ 828{
827 if (compat20) 829 if (compat20)