|
Lines 561-625
Link Here
|
| 561 |
comment = NULL; |
561 |
comment = NULL; |
| 562 |
} |
562 |
} |
| 563 |
|
563 |
|
| 564 |
f = fopen(identity_file, "r"); |
564 |
if ((f = fopen(identity_file, "r")) == NULL) |
| 565 |
if (f != NULL) { |
565 |
fatal("%s: %s", identity_file, strerror(errno)); |
| 566 |
while (fgets(line, sizeof(line), f)) { |
|
|
| 567 |
if ((cp = strchr(line, '\n')) == NULL) { |
| 568 |
error("line %d too long: %.40s...", |
| 569 |
num + 1, line); |
| 570 |
skip = 1; |
| 571 |
continue; |
| 572 |
} |
| 573 |
num++; |
| 574 |
if (skip) { |
| 575 |
skip = 0; |
| 576 |
continue; |
| 577 |
} |
| 578 |
*cp = '\0'; |
| 579 |
|
566 |
|
| 580 |
/* Skip leading whitespace, empty and comment lines. */ |
567 |
while (fgets(line, sizeof(line), f)) { |
| 581 |
for (cp = line; *cp == ' ' || *cp == '\t'; cp++) |
568 |
if ((cp = strchr(line, '\n')) == NULL) { |
| 582 |
; |
569 |
error("line %d too long: %.40s...", |
| 583 |
if (!*cp || *cp == '\n' || *cp == '#') |
570 |
num + 1, line); |
| 584 |
continue; |
571 |
skip = 1; |
| 585 |
i = strtol(cp, &ep, 10); |
572 |
continue; |
| 586 |
if (i == 0 || ep == NULL || (*ep != ' ' && *ep != '\t')) { |
573 |
} |
| 587 |
int quoted = 0; |
574 |
num++; |
| 588 |
comment = cp; |
575 |
if (skip) { |
| 589 |
for (; *cp && (quoted || (*cp != ' ' && |
576 |
skip = 0; |
| 590 |
*cp != '\t')); cp++) { |
577 |
continue; |
| 591 |
if (*cp == '\\' && cp[1] == '"') |
578 |
} |
| 592 |
cp++; /* Skip both */ |
579 |
*cp = '\0'; |
| 593 |
else if (*cp == '"') |
580 |
|
| 594 |
quoted = !quoted; |
581 |
/* Skip leading whitespace, empty and comment lines. */ |
| 595 |
} |
582 |
for (cp = line; *cp == ' ' || *cp == '\t'; cp++) |
| 596 |
if (!*cp) |
583 |
; |
| 597 |
continue; |
584 |
if (!*cp || *cp == '\n' || *cp == '#') |
| 598 |
*cp++ = '\0'; |
585 |
continue; |
|
|
586 |
i = strtol(cp, &ep, 10); |
| 587 |
if (i == 0 || ep == NULL || (*ep != ' ' && *ep != '\t')) { |
| 588 |
int quoted = 0; |
| 589 |
comment = cp; |
| 590 |
for (; *cp && (quoted || (*cp != ' ' && |
| 591 |
*cp != '\t')); cp++) { |
| 592 |
if (*cp == '\\' && cp[1] == '"') |
| 593 |
cp++; /* Skip both */ |
| 594 |
else if (*cp == '"') |
| 595 |
quoted = !quoted; |
| 599 |
} |
596 |
} |
| 600 |
ep = cp; |
597 |
if (!*cp) |
| 601 |
public = key_new(KEY_RSA1); |
598 |
continue; |
|
|
599 |
*cp++ = '\0'; |
| 600 |
} |
| 601 |
ep = cp; |
| 602 |
public = key_new(KEY_RSA1); |
| 603 |
if (key_read(public, &cp) != 1) { |
| 604 |
cp = ep; |
| 605 |
key_free(public); |
| 606 |
public = key_new(KEY_UNSPEC); |
| 602 |
if (key_read(public, &cp) != 1) { |
607 |
if (key_read(public, &cp) != 1) { |
| 603 |
cp = ep; |
|
|
| 604 |
key_free(public); |
608 |
key_free(public); |
| 605 |
public = key_new(KEY_UNSPEC); |
609 |
continue; |
| 606 |
if (key_read(public, &cp) != 1) { |
|
|
| 607 |
key_free(public); |
| 608 |
continue; |
| 609 |
} |
| 610 |
} |
610 |
} |
| 611 |
comment = *cp ? cp : comment; |
|
|
| 612 |
fp = key_fingerprint(public, fptype, rep); |
| 613 |
ra = key_fingerprint(public, SSH_FP_MD5, SSH_FP_RANDOMART); |
| 614 |
printf("%u %s %s (%s)\n", key_size(public), fp, |
| 615 |
comment ? comment : "no comment", key_type(public)); |
| 616 |
if (log_level >= SYSLOG_LEVEL_VERBOSE) |
| 617 |
printf("%s\n", ra); |
| 618 |
xfree(ra); |
| 619 |
xfree(fp); |
| 620 |
key_free(public); |
| 621 |
invalid = 0; |
| 622 |
} |
611 |
} |
|
|
612 |
comment = *cp ? cp : comment; |
| 613 |
fp = key_fingerprint(public, fptype, rep); |
| 614 |
ra = key_fingerprint(public, SSH_FP_MD5, SSH_FP_RANDOMART); |
| 615 |
printf("%u %s %s (%s)\n", key_size(public), fp, |
| 616 |
comment ? comment : "no comment", key_type(public)); |
| 617 |
if (log_level >= SYSLOG_LEVEL_VERBOSE) |
| 618 |
printf("%s\n", ra); |
| 619 |
xfree(ra); |
| 620 |
xfree(fp); |
| 621 |
key_free(public); |
| 622 |
invalid = 0; |
| 623 |
|
| 623 |
fclose(f); |
624 |
fclose(f); |
| 624 |
} |
625 |
} |
| 625 |
if (invalid) { |
626 |
if (invalid) { |
|
Lines 1418-1432
Link Here
|
| 1418 |
struct stat st; |
1419 |
struct stat st; |
| 1419 |
char *key_fp, *ca_fp; |
1420 |
char *key_fp, *ca_fp; |
| 1420 |
Buffer options, option; |
1421 |
Buffer options, option; |
|
|
1422 |
FILE *f; |
| 1421 |
u_char *name, *data; |
1423 |
u_char *name, *data; |
| 1422 |
u_int i, dlen, v00; |
1424 |
u_int i, dlen, v00; |
| 1423 |
|
1425 |
|
| 1424 |
if (!have_identity) |
1426 |
if (!have_identity) |
| 1425 |
ask_filename(pw, "Enter file in which the key is"); |
1427 |
ask_filename(pw, "Enter file in which the key is"); |
| 1426 |
if (stat(identity_file, &st) < 0) { |
1428 |
if ((f = fopen(identity_file, "r")) == NULL) |
| 1427 |
perror(identity_file); |
1429 |
fatal("%s: %s", identity_file, strerror(errno)); |
| 1428 |
exit(1); |
1430 |
fclose(f); |
| 1429 |
} |
1431 |
|
|
|
1432 |
if ((key = key_load_public(identity_file, NULL)) == NULL) |
| 1430 |
if ((key = key_load_public(identity_file, NULL)) == NULL) |
1433 |
if ((key = key_load_public(identity_file, NULL)) == NULL) |
| 1431 |
fatal("%s is not a public key", identity_file); |
1434 |
fatal("%s is not a public key", identity_file); |
| 1432 |
if (!key_is_cert(key)) |
1435 |
if (!key_is_cert(key)) |