comparison dbutil.c @ 51:095d689fed16

- Hostkey checking is mostly there, just aren't appending yet. - Rearranged various bits of the fingerprint/base64 type code, so it can be shared between versions
author Matt Johnston <matt@ucc.asn.au>
date Sun, 08 Aug 2004 16:17:05 +0000
parents 9ee8996a375f
children 20563735e8b5
comparison
equal deleted inserted replaced
49:cc59bfcdee17 51:095d689fed16
318 318
319 close(fd); 319 close(fd);
320 return DROPBEAR_SUCCESS; 320 return DROPBEAR_SUCCESS;
321 } 321 }
322 322
323 /* get a line from the file into buffer in the style expected for an
324 * authkeys file.
325 * Will return DROPBEAR_SUCCESS if data is read, or DROPBEAR_FAILURE on EOF.*/
326 /* Only used for ~/.ssh/known_hosts and ~/.ssh/authorized_keys */
327 #if defined(DROPBEAR_CLIENT) || defined(DROPBEAR_PUBKEY_AUTH)
328 int buf_getline(buffer * line, FILE * authfile) {
329
330 int c = EOF;
331
332 TRACE(("enter buf_getline"));
333
334 buf_setpos(line, 0);
335 buf_setlen(line, 0);
336
337 while (line->pos < line->size) {
338
339 c = fgetc(authfile); /*getc() is weird with some uClibc systems*/
340 if (c == EOF || c == '\n' || c == '\r') {
341 goto out;
342 }
343
344 buf_putbyte(line, (unsigned char)c);
345 }
346
347 TRACE(("leave getauthline: line too long"));
348 /* We return success, but the line length will be zeroed - ie we just
349 * ignore that line */
350 buf_setlen(line, 0);
351
352 out:
353
354 buf_setpos(line, 0);
355
356 /* if we didn't read anything before EOF or error, exit */
357 if (c == EOF && line->pos == 0) {
358 TRACE(("leave getauthline: failure"));
359 return DROPBEAR_FAILURE;
360 } else {
361 TRACE(("leave getauthline: success"));
362 return DROPBEAR_SUCCESS;
363 }
364
365 TRACE(("leave buf_getline"));
366 }
367 #endif
368
323 /* loop until the socket is closed (in case of EINTR) or 369 /* loop until the socket is closed (in case of EINTR) or
324 * we get and error. 370 * we get and error.
325 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 371 * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
326 int m_close(int fd) { 372 int m_close(int fd) {
327 373