4 * Copyright (c) 2002,2003 Matt Johnston
5 * Copyright (c) 2004 by Mihnea Stoenescu
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 void send_msg_service_request(char* servicename
) {
36 TRACE(("enter send_msg_service_request: servicename='%s'", servicename
))
40 buf_putbyte(ses
.writepayload
, SSH_MSG_SERVICE_REQUEST
);
41 buf_putstring(ses
.writepayload
, servicename
, strlen(servicename
));
44 TRACE(("leave send_msg_service_request"))
47 /* This just sets up the state variables right for the main client session loop
49 void recv_msg_service_accept() {
51 unsigned char* servicename
;
54 TRACE(("enter recv_msg_service_accept"))
56 servicename
= buf_getstring(ses
.payload
, &len
);
59 if (cli_ses
.state
== SERVICE_AUTH_REQ_SENT
60 && len
== SSH_SERVICE_USERAUTH_LEN
61 && strncmp(SSH_SERVICE_USERAUTH
, servicename
, len
) == 0) {
63 cli_ses
.state
= SERVICE_AUTH_ACCEPT_RCVD
;
65 TRACE(("leave recv_msg_service_accept: done ssh-userauth"))
70 if (cli_ses
.state
== SERVICE_CONN_REQ_SENT
71 && len
== SSH_SERVICE_CONNECTION_LEN
72 && strncmp(SSH_SERVICE_CONNECTION
, servicename
, len
) == 0) {
74 if (ses
.authstate
.authdone
!= 1) {
75 dropbear_exit("Request for connection before auth");
78 cli_ses
.state
= SERVICE_CONN_ACCEPT_RCVD
;
80 TRACE(("leave recv_msg_service_accept: done ssh-connection"))
84 dropbear_exit("Unrecognised service accept");