Diff

Differences From Artifact [37599cae0e]:

To Artifact [19563b5310]:


6604
6605
6606
6607
6608
6609
6610





















6611
6612
6613
6614
6615
6616
6617
    ocr->next = NULL;
    if (!c->v.v2.chanreq_head)
	c->v.v2.chanreq_head = ocr;
    else
	c->v.v2.chanreq_tail->next = ocr;
    c->v.v2.chanreq_tail = ocr;
}






















/*
 * Potentially enlarge the window on an SSH-2 channel.
 */
static void ssh2_handle_winadj_response(struct ssh_channel *, struct Packet *,
					void *);
static void ssh2_set_window(struct ssh_channel *c, int newwin)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
    ocr->next = NULL;
    if (!c->v.v2.chanreq_head)
	c->v.v2.chanreq_head = ocr;
    else
	c->v.v2.chanreq_tail->next = ocr;
    c->v.v2.chanreq_tail = ocr;
}

/*
 * Construct the common parts of a CHANNEL_REQUEST.  If handler is not
 * NULL then a reply will be requested and the handler will be called
 * when it arrives.  The returned packet is ready to have any
 * request-specific data added and be sent.  Note that if a handler is
 * provided, it's essential that the request actually be sent.
 */
static struct Packet *ssh2_chanreq_init(struct ssh_channel *c, char *type,
					cchandler_fn_t handler, void *ctx)
{
    struct Packet *pktout;

    pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
    ssh2_pkt_adduint32(pktout, c->remoteid);
    ssh2_pkt_addstring(pktout, type);
    ssh2_pkt_addbool(pktout, handler != NULL);
    if (handler != NULL)
	ssh2_queue_chanreq_handler(c, handler, ctx);
    return pktout;
}

/*
 * Potentially enlarge the window on an SSH-2 channel.
 */
static void ssh2_handle_winadj_response(struct ssh_channel *, struct Packet *,
					void *);
static void ssh2_set_window(struct ssh_channel *c, int newwin)
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
	 *
	 * This is only necessary if we're opening the window wide.
	 * If we're not, then throughput is being constrained by
	 * something other than the maximum window size anyway.
	 */
	if (newwin == c->v.v2.locmaxwin &&
            !(ssh->remote_bugs & BUG_CHOKES_ON_WINADJ)) {
	    pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
	    ssh2_pkt_adduint32(pktout, c->remoteid);
	    ssh2_pkt_addstring(pktout, "winadj@putty.projects.tartarus.org");
	    ssh2_pkt_addbool(pktout, TRUE);
	    ssh2_pkt_send(ssh, pktout);

	    up = snew(unsigned);
	    *up = newwin - c->v.v2.locwindow;
	    ssh2_queue_chanreq_handler(c, ssh2_handle_winadj_response, up);
	    if (c->v.v2.throttle_state != UNTHROTTLED)
		c->v.v2.throttle_state = UNTHROTTLING;
	} else {
	    /* Pretend the WINDOW_ADJUST was acked immediately. */
	    c->v.v2.remlocwin = newwin;
	    c->v.v2.throttle_state = THROTTLED;
	}







|
|
|
|


<
<
<







6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687



6688
6689
6690
6691
6692
6693
6694
	 *
	 * This is only necessary if we're opening the window wide.
	 * If we're not, then throughput is being constrained by
	 * something other than the maximum window size anyway.
	 */
	if (newwin == c->v.v2.locmaxwin &&
            !(ssh->remote_bugs & BUG_CHOKES_ON_WINADJ)) {
	    up = snew(unsigned);
	    *up = newwin - c->v.v2.locwindow;
	    pktout = ssh2_chanreq_init(c, "winadj@putty.projects.tartarus.org",
				       ssh2_handle_winadj_response, up);
	    ssh2_pkt_send(ssh, pktout);




	    if (c->v.v2.throttle_state != UNTHROTTLED)
		c->v.v2.throttle_state = UNTHROTTLING;
	} else {
	    /* Pretend the WINDOW_ADJUST was acked immediately. */
	    c->v.v2.remlocwin = newwin;
	    c->v.v2.throttle_state = THROTTLED;
	}
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
    Ssh ssh = c->ssh;
    struct Packet *pktout;

    if ((c->closes & (CLOSES_SENT_EOF | CLOSES_RCVD_EOF | CLOSES_SENT_CLOSE))
        == (CLOSES_SENT_EOF | CLOSES_RCVD_EOF) && !c->v.v2.chanreq_head) {
        /*
         * We have both sent and received EOF, and we have no
         * outstanding winadj channel requests, which means the
         * channel is in final wind-up. But we haven't sent CLOSE, so
         * let's do so now.
         */
	pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_CLOSE);
	ssh2_pkt_adduint32(pktout, c->remoteid);
	ssh2_pkt_send(ssh, pktout);
        c->closes |= CLOSES_SENT_CLOSE;







|







6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
    Ssh ssh = c->ssh;
    struct Packet *pktout;

    if ((c->closes & (CLOSES_SENT_EOF | CLOSES_RCVD_EOF | CLOSES_SENT_CLOSE))
        == (CLOSES_SENT_EOF | CLOSES_RCVD_EOF) && !c->v.v2.chanreq_head) {
        /*
         * We have both sent and received EOF, and we have no
         * outstanding channel requests, which means the
         * channel is in final wind-up. But we haven't sent CLOSE, so
         * let's do so now.
         */
	pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_CLOSE);
	ssh2_pkt_adduint32(pktout, c->remoteid);
	ssh2_pkt_send(ssh, pktout);
        c->closes |= CLOSES_SENT_CLOSE;
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
    /*
     * Potentially enable X11 forwarding.
     */
    if (ssh->mainchan && !ssh->ncmode && conf_get_int(ssh->conf, CONF_x11_forward) &&
	(ssh->x11disp = x11_setup_display(conf_get_str(ssh->conf, CONF_x11_display),
					  conf_get_int(ssh->conf, CONF_x11_auth), ssh->conf))) {
	logevent("Requesting X11 forwarding");
	pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
	ssh2_pkt_adduint32(pktout, ssh->mainchan->remoteid);
	ssh2_pkt_addstring(pktout, "x11-req");
	ssh2_pkt_addbool(pktout, 1);	       /* want reply */
	ssh2_pkt_addbool(pktout, 0);	       /* many connections */
	ssh2_pkt_addstring(pktout, ssh->x11disp->remoteauthprotoname);
	/*
	 * Note that while we blank the X authentication data here, we don't
	 * take any special action to blank the start of an X11 channel,
	 * so using MIT-MAGIC-COOKIE-1 and actually opening an X connection
	 * without having session blanking enabled is likely to leak your
	 * cookie into the log.
	 */
	dont_log_password(ssh, pktout, PKTLOG_BLANK);
	ssh2_pkt_addstring(pktout, ssh->x11disp->remoteauthdatastring);
	end_log_omission(ssh, pktout);
	ssh2_pkt_adduint32(pktout, ssh->x11disp->screennum);
	ssh2_pkt_send(ssh, pktout);

	ssh2_queue_chanreq_handler(ssh->mainchan, ssh2_maybe_setup_x11, s);

	crWaitUntilV(pktin);

	if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
	    logevent("X11 forwarding enabled");
	    ssh->X11_fwd_enabled = TRUE;
	} else
	    logevent("X11 forwarding refused");







|
<
|
<















<
<







7481
7482
7483
7484
7485
7486
7487
7488

7489

7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504


7505
7506
7507
7508
7509
7510
7511
    /*
     * Potentially enable X11 forwarding.
     */
    if (ssh->mainchan && !ssh->ncmode && conf_get_int(ssh->conf, CONF_x11_forward) &&
	(ssh->x11disp = x11_setup_display(conf_get_str(ssh->conf, CONF_x11_display),
					  conf_get_int(ssh->conf, CONF_x11_auth), ssh->conf))) {
	logevent("Requesting X11 forwarding");
	pktout = ssh2_chanreq_init(ssh->mainchan, "x11-req",

				   ssh2_maybe_setup_x11, s);

	ssh2_pkt_addbool(pktout, 0);	       /* many connections */
	ssh2_pkt_addstring(pktout, ssh->x11disp->remoteauthprotoname);
	/*
	 * Note that while we blank the X authentication data here, we don't
	 * take any special action to blank the start of an X11 channel,
	 * so using MIT-MAGIC-COOKIE-1 and actually opening an X connection
	 * without having session blanking enabled is likely to leak your
	 * cookie into the log.
	 */
	dont_log_password(ssh, pktout, PKTLOG_BLANK);
	ssh2_pkt_addstring(pktout, ssh->x11disp->remoteauthdatastring);
	end_log_omission(ssh, pktout);
	ssh2_pkt_adduint32(pktout, ssh->x11disp->screennum);
	ssh2_pkt_send(ssh, pktout);



	crWaitUntilV(pktin);

	if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
	    logevent("X11 forwarding enabled");
	    ssh->X11_fwd_enabled = TRUE;
	} else
	    logevent("X11 forwarding refused");
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
    struct Packet *pktout;
    crStateP(ssh2_maybe_setup_agent_state, ctx);

    crBeginState;

    if (ssh->mainchan && !ssh->ncmode && conf_get_int(ssh->conf, CONF_agentfwd) && agent_exists()) {
	logevent("Requesting OpenSSH-style agent forwarding");
	pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
	ssh2_pkt_adduint32(pktout, ssh->mainchan->remoteid);
	ssh2_pkt_addstring(pktout, "auth-agent-req@openssh.com");
	ssh2_pkt_addbool(pktout, 1);	       /* want reply */
	ssh2_pkt_send(ssh, pktout);

	ssh2_queue_chanreq_handler(ssh->mainchan, ssh2_maybe_setup_agent, s);

	crWaitUntilV(pktin);

	if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
	    logevent("Agent forwarding enabled");
	    ssh->agentfwd_enabled = TRUE;
	} else
	    logevent("Agent forwarding refused");







<
<
|
|


<
<







7524
7525
7526
7527
7528
7529
7530


7531
7532
7533
7534


7535
7536
7537
7538
7539
7540
7541
    struct Packet *pktout;
    crStateP(ssh2_maybe_setup_agent_state, ctx);

    crBeginState;

    if (ssh->mainchan && !ssh->ncmode && conf_get_int(ssh->conf, CONF_agentfwd) && agent_exists()) {
	logevent("Requesting OpenSSH-style agent forwarding");


	pktout = ssh2_chanreq_init(ssh->mainchan, "auth-agent-req@openssh.com",
				   ssh2_maybe_setup_agent, s);
	ssh2_pkt_send(ssh, pktout);



	crWaitUntilV(pktin);

	if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
	    logevent("Agent forwarding enabled");
	    ssh->agentfwd_enabled = TRUE;
	} else
	    logevent("Agent forwarding refused");
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582

    if (ssh->mainchan && !ssh->ncmode && !conf_get_int(ssh->conf, CONF_nopty)) {
	/* Unpick the terminal-speed string. */
	/* XXX perhaps we should allow no speeds to be sent. */
        ssh->ospeed = 38400; ssh->ispeed = 38400; /* last-resort defaults */
	sscanf(conf_get_str(ssh->conf, CONF_termspeed), "%d,%d", &ssh->ospeed, &ssh->ispeed);
	/* Build the pty request. */
	pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
	ssh2_pkt_adduint32(pktout, ssh->mainchan->remoteid);	/* recipient channel */
	ssh2_pkt_addstring(pktout, "pty-req");
	ssh2_pkt_addbool(pktout, 1);	       /* want reply */
	ssh2_pkt_addstring(pktout, conf_get_str(ssh->conf, CONF_termtype));
	ssh2_pkt_adduint32(pktout, ssh->term_width);
	ssh2_pkt_adduint32(pktout, ssh->term_height);
	ssh2_pkt_adduint32(pktout, 0);	       /* pixel width */
	ssh2_pkt_adduint32(pktout, 0);	       /* pixel height */
	ssh2_pkt_addstring_start(pktout);
	parse_ttymodes(ssh, ssh2_send_ttymode, (void *)pktout);
	ssh2_pkt_addbyte(pktout, SSH2_TTY_OP_ISPEED);
	ssh2_pkt_adduint32(pktout, ssh->ispeed);
	ssh2_pkt_addbyte(pktout, SSH2_TTY_OP_OSPEED);
	ssh2_pkt_adduint32(pktout, ssh->ospeed);
	ssh2_pkt_addstring_data(pktout, "\0", 1); /* TTY_OP_END */
	ssh2_pkt_send(ssh, pktout);
	ssh->state = SSH_STATE_INTERMED;

	ssh2_queue_chanreq_handler(ssh->mainchan, ssh2_maybe_setup_pty, s);

	crWaitUntilV(pktin);

	if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
	    logeventf(ssh, "Allocated pty (ospeed %dbps, ispeed %dbps)",
		      ssh->ospeed, ssh->ispeed);
            ssh->got_pty = TRUE;
	} else {







|
<
|
<















<
<







7558
7559
7560
7561
7562
7563
7564
7565

7566

7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581


7582
7583
7584
7585
7586
7587
7588

    if (ssh->mainchan && !ssh->ncmode && !conf_get_int(ssh->conf, CONF_nopty)) {
	/* Unpick the terminal-speed string. */
	/* XXX perhaps we should allow no speeds to be sent. */
        ssh->ospeed = 38400; ssh->ispeed = 38400; /* last-resort defaults */
	sscanf(conf_get_str(ssh->conf, CONF_termspeed), "%d,%d", &ssh->ospeed, &ssh->ispeed);
	/* Build the pty request. */
	pktout = ssh2_chanreq_init(ssh->mainchan, "pty-req",

				   ssh2_maybe_setup_pty, s);

	ssh2_pkt_addstring(pktout, conf_get_str(ssh->conf, CONF_termtype));
	ssh2_pkt_adduint32(pktout, ssh->term_width);
	ssh2_pkt_adduint32(pktout, ssh->term_height);
	ssh2_pkt_adduint32(pktout, 0);	       /* pixel width */
	ssh2_pkt_adduint32(pktout, 0);	       /* pixel height */
	ssh2_pkt_addstring_start(pktout);
	parse_ttymodes(ssh, ssh2_send_ttymode, (void *)pktout);
	ssh2_pkt_addbyte(pktout, SSH2_TTY_OP_ISPEED);
	ssh2_pkt_adduint32(pktout, ssh->ispeed);
	ssh2_pkt_addbyte(pktout, SSH2_TTY_OP_OSPEED);
	ssh2_pkt_adduint32(pktout, ssh->ospeed);
	ssh2_pkt_addstring_data(pktout, "\0", 1); /* TTY_OP_END */
	ssh2_pkt_send(ssh, pktout);
	ssh->state = SSH_STATE_INTERMED;



	crWaitUntilV(pktin);

	if (pktin->type == SSH2_MSG_CHANNEL_SUCCESS) {
	    logeventf(ssh, "Allocated pty (ospeed %dbps, ispeed %dbps)",
		      ssh->ospeed, ssh->ispeed);
            ssh->got_pty = TRUE;
	} else {
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
    s->num_env = 0;
    if (ssh->mainchan && !ssh->ncmode) {
	char *key, *val;

	for (val = conf_get_str_strs(ssh->conf, CONF_environmt, NULL, &key);
	     val != NULL;
	     val = conf_get_str_strs(ssh->conf, CONF_environmt, key, &key)) {
	    pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
	    ssh2_pkt_adduint32(pktout, ssh->mainchan->remoteid);
	    ssh2_pkt_addstring(pktout, "env");
	    ssh2_pkt_addbool(pktout, 1);	       /* want reply */
	    ssh2_pkt_addstring(pktout, key);
	    ssh2_pkt_addstring(pktout, val);
	    ssh2_pkt_send(ssh, pktout);
	    ssh2_queue_chanreq_handler(ssh->mainchan, ssh2_setup_env, s);

	    s->num_env++;
	}
	if (s->num_env)
	    logeventf(ssh, "Sent %d environment variables", s->num_env);
    }








|
<
<
<



<







7618
7619
7620
7621
7622
7623
7624
7625



7626
7627
7628

7629
7630
7631
7632
7633
7634
7635
    s->num_env = 0;
    if (ssh->mainchan && !ssh->ncmode) {
	char *key, *val;

	for (val = conf_get_str_strs(ssh->conf, CONF_environmt, NULL, &key);
	     val != NULL;
	     val = conf_get_str_strs(ssh->conf, CONF_environmt, key, &key)) {
	    pktout = ssh2_chanreq_init(ssh->mainchan, "env", ssh2_setup_env, s);



	    ssh2_pkt_addstring(pktout, key);
	    ssh2_pkt_addstring(pktout, val);
	    ssh2_pkt_send(ssh, pktout);


	    s->num_env++;
	}
	if (s->num_env)
	    logeventf(ssh, "Sent %d environment variables", s->num_env);
    }

9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223

9224
9225
9226
9227
9228
9229
9230
    if (ssh->mainchan && conf_get_int(ssh->conf, CONF_ssh_simple)) {
	/*
	 * This message indicates to the server that we promise
	 * not to try to run any other channel in parallel with
	 * this one, so it's safe for it to advertise a very large
	 * window and leave the flow control to TCP.
	 */
	s->pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
	ssh2_pkt_adduint32(s->pktout, ssh->mainchan->remoteid);
	ssh2_pkt_addstring(s->pktout, "simple@putty.projects.tartarus.org");
	ssh2_pkt_addbool(s->pktout, 0); /* no reply */

	ssh2_pkt_send(ssh, s->pktout);
    }

    /*
     * Enable port forwardings.
     */
    ssh_setup_portfwd(ssh, ssh->conf);







|
<
|
<
>







9215
9216
9217
9218
9219
9220
9221
9222

9223

9224
9225
9226
9227
9228
9229
9230
9231
    if (ssh->mainchan && conf_get_int(ssh->conf, CONF_ssh_simple)) {
	/*
	 * This message indicates to the server that we promise
	 * not to try to run any other channel in parallel with
	 * this one, so it's safe for it to advertise a very large
	 * window and leave the flow control to TCP.
	 */
	s->pktout = ssh2_chanreq_init(ssh->mainchan,

				      "simple@putty.projects.tartarus.org",

				      NULL, NULL);
	ssh2_pkt_send(ssh, s->pktout);
    }

    /*
     * Enable port forwardings.
     */
    ssh_setup_portfwd(ssh, ssh->conf);
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
	    subsys = conf_get_int(ssh->conf, CONF_ssh_subsys2);
	    cmd = conf_get_str(ssh->conf, CONF_remote_cmd2);
	} else {
	    subsys = conf_get_int(ssh->conf, CONF_ssh_subsys);
	    cmd = conf_get_str(ssh->conf, CONF_remote_cmd);
	}

	s->pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
	ssh2_pkt_adduint32(s->pktout, ssh->mainchan->remoteid);	/* recipient channel */
	if (subsys) {
	    ssh2_pkt_addstring(s->pktout, "subsystem");
	    ssh2_pkt_addbool(s->pktout, 1);	       /* want reply */
	    ssh2_pkt_addstring(s->pktout, cmd);
	} else if (*cmd) {
	    ssh2_pkt_addstring(s->pktout, "exec");
	    ssh2_pkt_addbool(s->pktout, 1);	       /* want reply */
	    ssh2_pkt_addstring(s->pktout, cmd);
	} else {
	    ssh2_pkt_addstring(s->pktout, "shell");
	    ssh2_pkt_addbool(s->pktout, 1);	       /* want reply */
	}
	ssh2_pkt_send(ssh, s->pktout);
	ssh2_queue_chanreq_handler(ssh->mainchan, ssh2_response_authconn, NULL);

	crWaitUntilV(pktin);

	if (pktin->type != SSH2_MSG_CHANNEL_SUCCESS) {
	    if (pktin->type != SSH2_MSG_CHANNEL_FAILURE) {
		bombout(("Unexpected response to shell/command request:"
			 " packet type %d", pktin->type));







<
<

|
|


|
|


|
|


<







9268
9269
9270
9271
9272
9273
9274


9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287

9288
9289
9290
9291
9292
9293
9294
	    subsys = conf_get_int(ssh->conf, CONF_ssh_subsys2);
	    cmd = conf_get_str(ssh->conf, CONF_remote_cmd2);
	} else {
	    subsys = conf_get_int(ssh->conf, CONF_ssh_subsys);
	    cmd = conf_get_str(ssh->conf, CONF_remote_cmd);
	}



	if (subsys) {
	    s->pktout = ssh2_chanreq_init(ssh->mainchan, "subsystem",
					  ssh2_response_authconn, NULL);
	    ssh2_pkt_addstring(s->pktout, cmd);
	} else if (*cmd) {
	    s->pktout = ssh2_chanreq_init(ssh->mainchan, "exec",
					  ssh2_response_authconn, NULL);
	    ssh2_pkt_addstring(s->pktout, cmd);
	} else {
	    s->pktout = ssh2_chanreq_init(ssh->mainchan, "shell",
					  ssh2_response_authconn, NULL);
	}
	ssh2_pkt_send(ssh, s->pktout);


	crWaitUntilV(pktin);

	if (pktin->type != SSH2_MSG_CHANNEL_SUCCESS) {
	    if (pktin->type != SSH2_MSG_CHANNEL_FAILURE) {
		bombout(("Unexpected response to shell/command request:"
			 " packet type %d", pktin->type));
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
	if (!conf_get_int(ssh->conf, CONF_nopty)) {
	    if (ssh->version == 1) {
		send_packet(ssh, SSH1_CMSG_WINDOW_SIZE,
			    PKT_INT, ssh->term_height,
			    PKT_INT, ssh->term_width,
			    PKT_INT, 0, PKT_INT, 0, PKT_END);
	    } else if (ssh->mainchan) {
		pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
		ssh2_pkt_adduint32(pktout, ssh->mainchan->remoteid);
		ssh2_pkt_addstring(pktout, "window-change");
		ssh2_pkt_addbool(pktout, 0);
		ssh2_pkt_adduint32(pktout, ssh->term_width);
		ssh2_pkt_adduint32(pktout, ssh->term_height);
		ssh2_pkt_adduint32(pktout, 0);
		ssh2_pkt_adduint32(pktout, 0);
		ssh2_pkt_send(ssh, pktout);
	    }
	}







<
<
|
|







9906
9907
9908
9909
9910
9911
9912


9913
9914
9915
9916
9917
9918
9919
9920
9921
	if (!conf_get_int(ssh->conf, CONF_nopty)) {
	    if (ssh->version == 1) {
		send_packet(ssh, SSH1_CMSG_WINDOW_SIZE,
			    PKT_INT, ssh->term_height,
			    PKT_INT, ssh->term_width,
			    PKT_INT, 0, PKT_INT, 0, PKT_END);
	    } else if (ssh->mainchan) {


		pktout = ssh2_chanreq_init(ssh->mainchan, "window-change",
					   NULL, NULL);
		ssh2_pkt_adduint32(pktout, ssh->term_width);
		ssh2_pkt_adduint32(pktout, ssh->term_height);
		ssh2_pkt_adduint32(pktout, 0);
		ssh2_pkt_adduint32(pktout, 0);
		ssh2_pkt_send(ssh, pktout);
	    }
	}
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
	}
    } else if (code == TS_BRK) {
	if (ssh->state == SSH_STATE_CLOSED
	    || ssh->state == SSH_STATE_PREPACKET) return;
	if (ssh->version == 1) {
	    logevent("Unable to send BREAK signal in SSH-1");
	} else if (ssh->mainchan) {
	    pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
	    ssh2_pkt_adduint32(pktout, ssh->mainchan->remoteid);
	    ssh2_pkt_addstring(pktout, "break");
	    ssh2_pkt_addbool(pktout, 0);
	    ssh2_pkt_adduint32(pktout, 0);   /* default break length */
	    ssh2_pkt_send(ssh, pktout);
	}
    } else {
	/* Is is a POSIX signal? */
	char *signame = NULL;
	if (code == TS_SIGABRT) signame = "ABRT";







|
<
<
<







10043
10044
10045
10046
10047
10048
10049
10050



10051
10052
10053
10054
10055
10056
10057
	}
    } else if (code == TS_BRK) {
	if (ssh->state == SSH_STATE_CLOSED
	    || ssh->state == SSH_STATE_PREPACKET) return;
	if (ssh->version == 1) {
	    logevent("Unable to send BREAK signal in SSH-1");
	} else if (ssh->mainchan) {
	    pktout = ssh2_chanreq_init(ssh->mainchan, "break", NULL, NULL);



	    ssh2_pkt_adduint32(pktout, 0);   /* default break length */
	    ssh2_pkt_send(ssh, pktout);
	}
    } else {
	/* Is is a POSIX signal? */
	char *signame = NULL;
	if (code == TS_SIGABRT) signame = "ABRT";
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
	if (code == TS_SIGUSR1) signame = "USR1";
	if (code == TS_SIGUSR2) signame = "USR2";
	/* The SSH-2 protocol does in principle support arbitrary named
	 * signals, including signame@domain, but we don't support those. */
	if (signame) {
	    /* It's a signal. */
	    if (ssh->version == 2 && ssh->mainchan) {
		pktout = ssh2_pkt_init(SSH2_MSG_CHANNEL_REQUEST);
		ssh2_pkt_adduint32(pktout, ssh->mainchan->remoteid);
		ssh2_pkt_addstring(pktout, "signal");
		ssh2_pkt_addbool(pktout, 0);
		ssh2_pkt_addstring(pktout, signame);
		ssh2_pkt_send(ssh, pktout);
		logeventf(ssh, "Sent signal SIG%s", signame);
	    }
	} else {
	    /* Never heard of it. Do nothing */
	}







|
<
<
<







10068
10069
10070
10071
10072
10073
10074
10075



10076
10077
10078
10079
10080
10081
10082
	if (code == TS_SIGUSR1) signame = "USR1";
	if (code == TS_SIGUSR2) signame = "USR2";
	/* The SSH-2 protocol does in principle support arbitrary named
	 * signals, including signame@domain, but we don't support those. */
	if (signame) {
	    /* It's a signal. */
	    if (ssh->version == 2 && ssh->mainchan) {
		pktout = ssh2_chanreq_init(ssh->mainchan, "signal", NULL, NULL);



		ssh2_pkt_addstring(pktout, signame);
		ssh2_pkt_send(ssh, pktout);
		logeventf(ssh, "Sent signal SIG%s", signame);
	    }
	} else {
	    /* Never heard of it. Do nothing */
	}