Mercurial > dropbear
comparison svr-session.c @ 579:8c737cd7c1af
merge of '48fdaa8706d1acda35e9d564adc9a1fbc96c18c8'
and '658fd03abd21e0da7c4c89b9fff9dc693c72daae'
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 27 Feb 2010 11:53:18 +0000 |
parents | 8fd0ac8c8cab |
children | a98a2138364a |
comparison
equal
deleted
inserted
replaced
577:69e98c45db7c | 579:8c737cd7c1af |
---|---|
72 &svr_chan_tcpdirect, | 72 &svr_chan_tcpdirect, |
73 #endif | 73 #endif |
74 NULL /* Null termination is mandatory. */ | 74 NULL /* Null termination is mandatory. */ |
75 }; | 75 }; |
76 | 76 |
77 void svr_session(int sock, int childpipe, | 77 void svr_session(int sock, int childpipe) { |
78 char* remotehost, char *addrstring) { | 78 char *host, *port; |
79 | 79 size_t len; |
80 reseedrandom(); | 80 reseedrandom(); |
81 | 81 |
82 crypto_init(); | 82 crypto_init(); |
83 common_session_init(sock, sock, remotehost); | 83 common_session_init(sock, sock); |
84 | 84 |
85 /* Initialise server specific parts of the session */ | 85 /* Initialise server specific parts of the session */ |
86 svr_ses.childpipe = childpipe; | 86 svr_ses.childpipe = childpipe; |
87 svr_ses.addrstring = addrstring; | 87 #ifdef __uClinux__ |
88 svr_ses.server_pid = getpid(); | |
89 #endif | |
88 svr_authinitialise(); | 90 svr_authinitialise(); |
89 chaninitialise(svr_chantypes); | 91 chaninitialise(svr_chantypes); |
90 svr_chansessinitialise(); | 92 svr_chansessinitialise(); |
91 | 93 |
92 ses.connect_time = time(NULL); | 94 ses.connect_time = time(NULL); |
95 | |
96 /* for logging the remote address */ | |
97 get_socket_address(ses.sock_in, NULL, NULL, &host, &port, 0); | |
98 len = strlen(host) + strlen(port) + 2; | |
99 svr_ses.addrstring = m_malloc(len); | |
100 snprintf(svr_ses.addrstring, len, "%s:%s", host, port); | |
101 m_free(host); | |
102 m_free(port); | |
103 | |
104 get_socket_address(ses.sock_in, NULL, NULL, | |
105 &svr_ses.remotehost, NULL, 1); | |
93 | 106 |
94 /* set up messages etc */ | 107 /* set up messages etc */ |
95 ses.remoteclosed = svr_remoteclosed; | 108 ses.remoteclosed = svr_remoteclosed; |
96 | 109 |
97 /* packet handlers */ | 110 /* packet handlers */ |
142 "exit before auth: %s", format); | 155 "exit before auth: %s", format); |
143 } | 156 } |
144 | 157 |
145 _dropbear_log(LOG_INFO, fmtbuf, param); | 158 _dropbear_log(LOG_INFO, fmtbuf, param); |
146 | 159 |
147 /* free potential public key options */ | 160 #ifdef __uClinux__ |
148 svr_pubkey_options_cleanup(); | 161 /* only the main server process should cleanup - we don't want |
149 | 162 * forked children doing that */ |
150 /* must be after we've done with username etc */ | 163 if (svr_ses.server_pid == getpid()) |
151 common_session_cleanup(); | 164 #else |
165 if (1) | |
166 #endif | |
167 { | |
168 /* free potential public key options */ | |
169 svr_pubkey_options_cleanup(); | |
170 | |
171 /* must be after we've done with username etc */ | |
172 common_session_cleanup(); | |
173 } | |
152 | 174 |
153 exit(exitcode); | 175 exit(exitcode); |
154 | 176 |
155 } | 177 } |
156 | 178 |