version 1.46, 2009/10/11 23:03:15 |
version 1.47, 2010/02/26 20:29:54 |
|
|
{ |
{ |
FILE *f; |
FILE *f; |
char line[8192]; |
char line[8192]; |
int linenum = 0; |
int linenum = 0, want_cert = key_is_cert(key); |
u_int kbits; |
u_int kbits; |
char *cp, *cp2, *hashed_host; |
char *cp, *cp2, *hashed_host; |
HostStatus end_return; |
HostStatus end_return; |
|
|
if (!*cp || *cp == '#' || *cp == '\n') |
if (!*cp || *cp == '#' || *cp == '\n') |
continue; |
continue; |
|
|
|
/* |
|
* Ignore CA keys when looking for raw keys. |
|
* Ignore raw keys when looking for CA keys. |
|
*/ |
|
if (strncasecmp(cp, CA_MARKER, sizeof(CA_MARKER) - 1) == 0 && |
|
(cp[sizeof(CA_MARKER) - 1] == ' ' || |
|
cp[sizeof(CA_MARKER) - 1] == '\t')) { |
|
if (want_cert) { |
|
/* Skip the marker and following whitespace */ |
|
cp += sizeof(CA_MARKER); |
|
for (; *cp == ' ' || *cp == '\t'; cp++) |
|
; |
|
} else |
|
continue; |
|
} else if (want_cert) |
|
continue; |
|
|
/* Find the end of the host name portion. */ |
/* Find the end of the host name portion. */ |
for (cp2 = cp; *cp2 && *cp2 != ' ' && *cp2 != '\t'; cp2++) |
for (cp2 = cp; *cp2 && *cp2 != ' ' && *cp2 != '\t'; cp2++) |
; |
; |
|
|
continue; |
continue; |
|
|
/* Check if the current key is the same as the given key. */ |
/* Check if the current key is the same as the given key. */ |
if (key_equal(key, found)) { |
if (want_cert && key_equal(key->cert->signature_key, found)) { |
/* Ok, they match. */ |
/* Found CA cert for key */ |
|
debug3("check_host_in_hostfile: CA match line %d", |
|
linenum); |
|
fclose(f); |
|
return HOST_OK; |
|
} else if (!want_cert && key_equal(key, found)) { |
|
/* Found identical key */ |
debug3("check_host_in_hostfile: match line %d", linenum); |
debug3("check_host_in_hostfile: match line %d", linenum); |
fclose(f); |
fclose(f); |
return HOST_OK; |
return HOST_OK; |