| ︙ | | | ︙ | |
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
static char *savedhost;
static int savedport;
static int ssh_send_ok;
static int ssh_echoing, ssh_editing;
static tree234 *ssh_channels; /* indexed by local id */
static struct ssh_channel *mainchan; /* primary session channel */
static tree234 *ssh_rportfwds;
static enum {
SSH_STATE_PREPACKET,
SSH_STATE_BEFORE_SIZE,
SSH_STATE_INTERMED,
|
>
|
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
|
static char *savedhost;
static int savedport;
static int ssh_send_ok;
static int ssh_echoing, ssh_editing;
static tree234 *ssh_channels; /* indexed by local id */
static struct ssh_channel *mainchan; /* primary session channel */
static int ssh_exitcode = -1;
static tree234 *ssh_rportfwds;
static enum {
SSH_STATE_PREPACKET,
SSH_STATE_BEFORE_SIZE,
SSH_STATE_INTERMED,
|
| ︙ | | | ︙ | |
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
|
}
} else if (pktin.type == SSH1_SMSG_SUCCESS) {
/* may be from EXEC_SHELL on some servers */
} else if (pktin.type == SSH1_SMSG_FAILURE) {
/* may be from EXEC_SHELL on some servers
* if no pty is available or in other odd cases. Ignore */
} else if (pktin.type == SSH1_SMSG_EXIT_STATUS) {
send_packet(SSH1_CMSG_EXIT_CONFIRMATION, PKT_END);
/*
* In case `helpful' firewalls or proxies tack
* extra human-readable text on the end of the
* session which we might mistake for another
* encrypted packet, we close the session once
* we've sent EXIT_CONFIRMATION.
|
>
>
>
>
>
|
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
|
}
} else if (pktin.type == SSH1_SMSG_SUCCESS) {
/* may be from EXEC_SHELL on some servers */
} else if (pktin.type == SSH1_SMSG_FAILURE) {
/* may be from EXEC_SHELL on some servers
* if no pty is available or in other odd cases. Ignore */
} else if (pktin.type == SSH1_SMSG_EXIT_STATUS) {
char buf[100];
ssh_exitcode = GET_32BIT(pktin.body);
sprintf(buf, "Server sent command exit status %d",
ssh_exitcode);
logevent(buf);
send_packet(SSH1_CMSG_EXIT_CONFIRMATION, PKT_END);
/*
* In case `helpful' firewalls or proxies tack
* extra human-readable text on the end of the
* session which we might mistake for another
* encrypted packet, we close the session once
* we've sent EXIT_CONFIRMATION.
|
| ︙ | | | ︙ | |
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
|
ssh2_pkt_send();
connection_fatal(buf);
ssh_state = SSH_STATE_CLOSED;
crReturnV;
}
/*
* We don't recognise any form of channel request,
* so we now either ignore the request or respond
* with CHANNEL_FAILURE, depending on want_reply.
*/
if (want_reply) {
ssh2_pkt_init(SSH2_MSG_CHANNEL_FAILURE);
ssh2_pkt_adduint32(c->remoteid);
ssh2_pkt_send();
}
} else if (pktin.type == SSH2_MSG_CHANNEL_OPEN) {
char *type;
int typelen;
char *error = NULL;
struct ssh_channel *c;
unsigned remid, winsize, pktsize;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
>
|
|
|
|
|
>
|
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
|
ssh2_pkt_send();
connection_fatal(buf);
ssh_state = SSH_STATE_CLOSED;
crReturnV;
}
/*
* Having got the channel number, we now look at
* the request type string to see if it's something
* we recognise.
*/
if (typelen == 11 && !memcmp(type, "exit-status", 11) &&
c == mainchan) {
/* We recognise "exit-status" on the primary channel. */
char buf[100];
ssh_exitcode = ssh2_pkt_getuint32();
sprintf(buf, "Server sent command exit status %d",
ssh_exitcode);
logevent(buf);
if (want_reply) {
ssh2_pkt_init(SSH2_MSG_CHANNEL_SUCCESS);
ssh2_pkt_adduint32(c->remoteid);
ssh2_pkt_send();
}
} else {
/*
* This is a channel request we don't know
* about, so we now either ignore the request
* or respond with CHANNEL_FAILURE, depending
* on want_reply.
*/
if (want_reply) {
ssh2_pkt_init(SSH2_MSG_CHANNEL_FAILURE);
ssh2_pkt_adduint32(c->remoteid);
ssh2_pkt_send();
}
}
} else if (pktin.type == SSH2_MSG_CHANNEL_OPEN) {
char *type;
int typelen;
char *error = NULL;
struct ssh_channel *c;
unsigned remid, winsize, pktsize;
|
| ︙ | | | ︙ | |
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
|
{
if (option == LD_ECHO)
return ssh_echoing;
if (option == LD_EDIT)
return ssh_editing;
return FALSE;
}
Backend ssh_backend = {
ssh_init,
ssh_send,
ssh_sendbuffer,
ssh_size,
ssh_special,
ssh_socket,
ssh_sendok,
ssh_ldisc,
ssh_unthrottle,
22
};
|
>
>
>
>
>
>
|
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
|
{
if (option == LD_ECHO)
return ssh_echoing;
if (option == LD_EDIT)
return ssh_editing;
return FALSE;
}
static int ssh_return_exitcode(void)
{
return ssh_exitcode;
}
Backend ssh_backend = {
ssh_init,
ssh_send,
ssh_sendbuffer,
ssh_size,
ssh_special,
ssh_socket,
ssh_return_exitcode,
ssh_sendok,
ssh_ldisc,
ssh_unthrottle,
22
};
|