comparison cli-session.c @ 34:e2a1eaa19f22

Client mostly works up to password auth Need to rework algo-choosing etc, since server is now broken.
author Matt Johnston <matt@ucc.asn.au>
date Wed, 28 Jul 2004 16:44:16 +0000
parents f789045062e6
children 0ad5fb979f42
comparison
equal deleted inserted replaced
33:f789045062e6 34:e2a1eaa19f22
19 static const packettype cli_packettypes[] = { 19 static const packettype cli_packettypes[] = {
20 /* TYPE, AUTHREQUIRED, FUNCTION */ 20 /* TYPE, AUTHREQUIRED, FUNCTION */
21 {SSH_MSG_KEXINIT, recv_msg_kexinit}, 21 {SSH_MSG_KEXINIT, recv_msg_kexinit},
22 {SSH_MSG_KEXDH_REPLY, recv_msg_kexdh_reply}, // client 22 {SSH_MSG_KEXDH_REPLY, recv_msg_kexdh_reply}, // client
23 {SSH_MSG_NEWKEYS, recv_msg_newkeys}, 23 {SSH_MSG_NEWKEYS, recv_msg_newkeys},
24 {SSH_MSG_SERVICE_ACCEPT, recv_msg_service_accept}, // client
24 {SSH_MSG_CHANNEL_DATA, recv_msg_channel_data}, 25 {SSH_MSG_CHANNEL_DATA, recv_msg_channel_data},
25 {SSH_MSG_CHANNEL_WINDOW_ADJUST, recv_msg_channel_window_adjust}, 26 {SSH_MSG_CHANNEL_WINDOW_ADJUST, recv_msg_channel_window_adjust},
26 {SSH_MSG_GLOBAL_REQUEST, recv_msg_global_request_remotetcp}, 27 {SSH_MSG_GLOBAL_REQUEST, recv_msg_global_request_remotetcp},
27 {SSH_MSG_CHANNEL_REQUEST, recv_msg_channel_request}, 28 {SSH_MSG_CHANNEL_REQUEST, recv_msg_channel_request},
28 {SSH_MSG_CHANNEL_OPEN, recv_msg_channel_open}, 29 {SSH_MSG_CHANNEL_OPEN, recv_msg_channel_open},
29 {SSH_MSG_CHANNEL_EOF, recv_msg_channel_eof}, 30 {SSH_MSG_CHANNEL_EOF, recv_msg_channel_eof},
30 {SSH_MSG_CHANNEL_CLOSE, recv_msg_channel_close}, 31 {SSH_MSG_CHANNEL_CLOSE, recv_msg_channel_close},
31 {SSH_MSG_CHANNEL_OPEN_CONFIRMATION, recv_msg_channel_open_confirmation}, 32 {SSH_MSG_CHANNEL_OPEN_CONFIRMATION, recv_msg_channel_open_confirmation},
32 {SSH_MSG_CHANNEL_OPEN_FAILURE, recv_msg_channel_open_failure}, 33 {SSH_MSG_CHANNEL_OPEN_FAILURE, recv_msg_channel_open_failure},
33 {SSH_MSG_USERAUTH_FAILURE, recv_msg_userauth_failure}, 34 {SSH_MSG_USERAUTH_FAILURE, recv_msg_userauth_failure}, // client
34 {SSH_MSG_USERAUTH_SUCCESS, recv_msg_userauth_success}, 35 {SSH_MSG_USERAUTH_SUCCESS, recv_msg_userauth_success}, // client
35 {0, 0} /* End */ 36 {0, 0} /* End */
36 }; 37 };
37 38
38 static const struct ChanType *cli_chantypes[] = { 39 static const struct ChanType *cli_chantypes[] = {
39 // &clichansess, 40 // &clichansess,
88 * service, userauth and channel requests */ 89 * service, userauth and channel requests */
89 static void cli_sessionloop() { 90 static void cli_sessionloop() {
90 91
91 TRACE(("enter cli_sessionloop")); 92 TRACE(("enter cli_sessionloop"));
92 93
93 if (cli_ses.kex_state == KEX_NOTHING && ses.kexstate.recvkexinit) { 94 if (ses.lastpacket == SSH_MSG_KEXINIT && cli_ses.kex_state == KEX_NOTHING) {
94 cli_ses.state = KEXINIT_RCVD; 95 cli_ses.kex_state = KEXINIT_RCVD;
95 } 96 }
96 97
97 if (cli_ses.state == KEXINIT_RCVD) { 98 if (cli_ses.kex_state == KEXINIT_RCVD) {
98 99
99 /* We initiate the KEXDH. If DH wasn't the correct type, the KEXINIT 100 /* We initiate the KEXDH. If DH wasn't the correct type, the KEXINIT
100 * negotiation would have failed. */ 101 * negotiation would have failed. */
101 send_msg_kexdh_init(); 102 send_msg_kexdh_init();
102 cli_ses.kex_state = KEXDH_INIT_SENT; 103 cli_ses.kex_state = KEXDH_INIT_SENT;
118 119
119 /* We should exit if we haven't donefirstkex: we shouldn't reach here 120 /* We should exit if we haven't donefirstkex: we shouldn't reach here
120 * in normal operation */ 121 * in normal operation */
121 if (ses.kexstate.donefirstkex == 0) { 122 if (ses.kexstate.donefirstkex == 0) {
122 TRACE(("XXX XXX might be bad! leave cli_sessionloop: haven't donefirstkex")); 123 TRACE(("XXX XXX might be bad! leave cli_sessionloop: haven't donefirstkex"));
124 return;
123 } 125 }
124 126
125 switch (cli_ses.state) { 127 switch (cli_ses.state) {
126 128
127 case STATE_NOTHING: 129 case STATE_NOTHING:
128 /* We've got the transport layer sorted, we now need to request 130 /* We've got the transport layer sorted, we now need to request
129 * userauth */ 131 * userauth */
130 send_msg_service_request(SSH_SERVICE_USERAUTH); 132 send_msg_service_request(SSH_SERVICE_USERAUTH);
131 cli_ses.state = SERVICE_AUTH_REQ_SENT; 133 cli_ses.state = SERVICE_AUTH_REQ_SENT;
134 TRACE(("leave cli_sessionloop: sent userauth service req"));
132 return; 135 return;
133 136
134 /* userauth code */ 137 /* userauth code */
135 case SERVICE_AUTH_ACCEPT_RCVD: 138 case SERVICE_AUTH_ACCEPT_RCVD:
136 cli_get_user(); 139 cli_get_user();
137 cli_auth_getmethods(); 140 cli_auth_getmethods();
138 cli_ses.state = USERAUTH_METHODS_SENT; 141 cli_ses.state = USERAUTH_METHODS_SENT;
142 TRACE(("leave cli_sessionloop: sent userauth methods req"));
139 return; 143 return;
140 144
141 case USERAUTH_FAIL_RCVD: 145 case USERAUTH_FAIL_RCVD:
142 cli_auth_try(); 146 cli_auth_try();
147 TRACE(("leave cli_sessionloop: cli_auth_try"));
143 return; 148 return;
144 149
145 /* XXX more here needed */ 150 /* XXX more here needed */
146 151
147 152
148 default: 153 default:
149 break; 154 break;
150 } 155 }
151 156
157 TRACE(("leave cli_sessionloop: fell out"));
152 158
153 } 159 }
154 160
155 /* called when the remote side closes the connection */ 161 /* called when the remote side closes the connection */
156 static void cli_remoteclosed() { 162 static void cli_remoteclosed() {