Mercurial > dropbear
comparison svr-session.c @ 989:73ea0dce9a57 pam
Merge up to date
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 23 Jan 2015 21:38:47 +0800 |
parents | bae0b34bc059 0bb16232e7c4 |
children | 2fa71c3b2827 |
comparison
equal
deleted
inserted
replaced
925:bae0b34bc059 | 989:73ea0dce9a57 |
---|---|
56 {SSH_MSG_GLOBAL_REQUEST, recv_msg_global_request_remotetcp}, | 56 {SSH_MSG_GLOBAL_REQUEST, recv_msg_global_request_remotetcp}, |
57 {SSH_MSG_CHANNEL_REQUEST, recv_msg_channel_request}, | 57 {SSH_MSG_CHANNEL_REQUEST, recv_msg_channel_request}, |
58 {SSH_MSG_CHANNEL_OPEN, recv_msg_channel_open}, | 58 {SSH_MSG_CHANNEL_OPEN, recv_msg_channel_open}, |
59 {SSH_MSG_CHANNEL_EOF, recv_msg_channel_eof}, | 59 {SSH_MSG_CHANNEL_EOF, recv_msg_channel_eof}, |
60 {SSH_MSG_CHANNEL_CLOSE, recv_msg_channel_close}, | 60 {SSH_MSG_CHANNEL_CLOSE, recv_msg_channel_close}, |
61 {SSH_MSG_CHANNEL_SUCCESS, ignore_recv_response}, | |
62 {SSH_MSG_CHANNEL_FAILURE, ignore_recv_response}, | |
63 {SSH_MSG_REQUEST_FAILURE, ignore_recv_response}, /* for keepalive */ | |
64 {SSH_MSG_REQUEST_SUCCESS, ignore_recv_response}, /* client */ | |
61 #ifdef USING_LISTENERS | 65 #ifdef USING_LISTENERS |
62 {SSH_MSG_CHANNEL_OPEN_CONFIRMATION, recv_msg_channel_open_confirmation}, | 66 {SSH_MSG_CHANNEL_OPEN_CONFIRMATION, recv_msg_channel_open_confirmation}, |
63 {SSH_MSG_CHANNEL_OPEN_FAILURE, recv_msg_channel_open_failure}, | 67 {SSH_MSG_CHANNEL_OPEN_FAILURE, recv_msg_channel_open_failure}, |
64 #endif | 68 #endif |
65 #ifdef ENABLE_SVR_PAM_AUTH | 69 #ifdef ENABLE_SVR_PAM_AUTH |
81 { | 85 { |
82 /* free potential public key options */ | 86 /* free potential public key options */ |
83 svr_pubkey_options_cleanup(); | 87 svr_pubkey_options_cleanup(); |
84 } | 88 } |
85 | 89 |
90 static void | |
91 svr_sessionloop() { | |
92 if (svr_ses.connect_time != 0 | |
93 && monotonic_now() - svr_ses.connect_time >= AUTH_TIMEOUT) { | |
94 dropbear_close("Timeout before auth"); | |
95 } | |
96 } | |
97 | |
86 void svr_session(int sock, int childpipe) { | 98 void svr_session(int sock, int childpipe) { |
87 char *host, *port; | 99 char *host, *port; |
88 size_t len; | 100 size_t len; |
89 | 101 |
90 common_session_init(sock, sock); | 102 common_session_init(sock, sock); |
103 | |
104 svr_ses.connect_time = monotonic_now();; | |
91 | 105 |
92 /* Initialise server specific parts of the session */ | 106 /* Initialise server specific parts of the session */ |
93 svr_ses.childpipe = childpipe; | 107 svr_ses.childpipe = childpipe; |
94 #ifdef USE_VFORK | 108 #ifdef USE_VFORK |
95 svr_ses.server_pid = getpid(); | 109 svr_ses.server_pid = getpid(); |
96 #endif | 110 #endif |
97 svr_authinitialise(); | 111 svr_authinitialise(); |
98 chaninitialise(svr_chantypes); | 112 chaninitialise(svr_chantypes); |
99 svr_chansessinitialise(); | 113 svr_chansessinitialise(); |
100 | |
101 ses.connect_time = time(NULL); | |
102 | 114 |
103 /* for logging the remote address */ | 115 /* for logging the remote address */ |
104 get_socket_address(ses.sock_in, NULL, NULL, &host, &port, 0); | 116 get_socket_address(ses.sock_in, NULL, NULL, &host, &port, 0); |
105 len = strlen(host) + strlen(port) + 2; | 117 len = strlen(host) + strlen(port) + 2; |
106 svr_ses.addrstring = m_malloc(len); | 118 svr_ses.addrstring = m_malloc(len); |
129 /* start off with key exchange */ | 141 /* start off with key exchange */ |
130 send_msg_kexinit(); | 142 send_msg_kexinit(); |
131 | 143 |
132 /* Run the main for loop. NULL is for the dispatcher - only the client | 144 /* Run the main for loop. NULL is for the dispatcher - only the client |
133 * code makes use of it */ | 145 * code makes use of it */ |
134 session_loop(NULL); | 146 session_loop(svr_sessionloop); |
135 | 147 |
136 /* Not reached */ | 148 /* Not reached */ |
137 | 149 |
138 } | 150 } |
139 | 151 |