comparison svr-session.c @ 5:bc6477a6c393

syntactical fixups - it compiles, but channel handling code requires fixing.
author Matt Johnston <matt@ucc.asn.au>
date Tue, 01 Jun 2004 04:20:12 +0000
parents fe6bca95afa7
children ab00ef513e97
comparison
equal deleted inserted replaced
4:fe6bca95afa7 5:bc6477a6c393
35 #include "channel.h" 35 #include "channel.h"
36 #include "chansession.h" 36 #include "chansession.h"
37 #include "atomicio.h" 37 #include "atomicio.h"
38 38
39 static void svr_remoteclosed(); 39 static void svr_remoteclosed();
40 static void svr_dropbear_exit(int exitcode, const char* format, va_list param);
41 static void svr_dropbear_log(int priority, const char* format, va_list param);
42 40
43 struct serversession svr_ses; 41 struct serversession svr_ses;
44 42
45 void svr_session(int sock, runopts *opts, int childpipe, 43 void svr_session(int sock, runopts *opts, int childpipe,
46 struct sockaddr* remoteaddr) { 44 struct sockaddr* remoteaddr) {
66 64
67 ses.connecttimeout = timeout.tv_sec + AUTH_TIMEOUT; 65 ses.connecttimeout = timeout.tv_sec + AUTH_TIMEOUT;
68 66
69 /* set up messages etc */ 67 /* set up messages etc */
70 session_remoteclosed = svr_remoteclosed; 68 session_remoteclosed = svr_remoteclosed;
71 _dropbear_exit = svr_dropbear_exit;
72 _dropbear_log = svr_dropbear_log;
73 69
74 /* We're ready to go now */ 70 /* We're ready to go now */
75 sessinitdone = 1; 71 sessinitdone = 1;
76 72
77 /* exchange identification, version etc */ 73 /* exchange identification, version etc */
151 } 147 }
152 148
153 } /* for(;;) */ 149 } /* for(;;) */
154 } 150 }
155 151
156
157
158 /* called when the remote side closes the connection */
159 static void svr_remoteclosed() {
160
161 close(ses.sock);
162 ses.sock = -1;
163 dropbear_close("Exited normally");
164
165 }
166
167 /* failure exit - format must be <= 100 chars */ 152 /* failure exit - format must be <= 100 chars */
168 static void svr_dropbear_exit(int exitcode, const char* format, va_list param) { 153 void svr_dropbear_exit(int exitcode, const char* format, va_list param) {
169 154
170 char fmtbuf[300]; 155 char fmtbuf[300];
171 156
172 if (!sessinitdone) { 157 if (!sessinitdone) {
173 /* before session init */ 158 /* before session init */
203 exit(exitcode); 188 exit(exitcode);
204 189
205 } 190 }
206 191
207 /* priority is priority as with syslog() */ 192 /* priority is priority as with syslog() */
208 static void svr_dropbear_log(int priority, const char* format, va_list param) { 193 void svr_dropbear_log(int priority, const char* format, va_list param) {
209 194
210 char printbuf[1024]; 195 char printbuf[1024];
211 char datestr[20]; 196 char datestr[20];
212 time_t timesec; 197 time_t timesec;
213 int havetrace = 0; 198 int havetrace = 0;
234 datestr[0] = '?'; datestr[1] = '\0'; 219 datestr[0] = '?'; datestr[1] = '\0';
235 } 220 }
236 fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf); 221 fprintf(stderr, "[%d] %s %s\n", getpid(), datestr, printbuf);
237 } 222 }
238 } 223 }
224
225 /* called when the remote side closes the connection */
226 static void svr_remoteclosed() {
227
228 close(ses.sock);
229 ses.sock = -1;
230 dropbear_close("Exited normally");
231
232 }
233