diff options
Diffstat (limited to 'hostfile.h')
-rw-r--r-- | hostfile.h | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/hostfile.h b/hostfile.h index 679c034f3..bd2104373 100644 --- a/hostfile.h +++ b/hostfile.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: hostfile.h,v 1.20 2013/07/12 00:19:58 djm Exp $ */ | 1 | /* $OpenBSD: hostfile.h,v 1.24 2015/02/16 22:08:57 djm Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -26,7 +26,7 @@ struct hostkey_entry { | |||
26 | char *host; | 26 | char *host; |
27 | char *file; | 27 | char *file; |
28 | u_long line; | 28 | u_long line; |
29 | Key *key; | 29 | struct sshkey *key; |
30 | HostkeyMarker marker; | 30 | HostkeyMarker marker; |
31 | }; | 31 | }; |
32 | struct hostkeys; | 32 | struct hostkeys; |
@@ -35,13 +35,18 @@ struct hostkeys *init_hostkeys(void); | |||
35 | void load_hostkeys(struct hostkeys *, const char *, const char *); | 35 | void load_hostkeys(struct hostkeys *, const char *, const char *); |
36 | void free_hostkeys(struct hostkeys *); | 36 | void free_hostkeys(struct hostkeys *); |
37 | 37 | ||
38 | HostStatus check_key_in_hostkeys(struct hostkeys *, Key *, | 38 | HostStatus check_key_in_hostkeys(struct hostkeys *, struct sshkey *, |
39 | const struct hostkey_entry **); | 39 | const struct hostkey_entry **); |
40 | int lookup_key_in_hostkeys_by_type(struct hostkeys *, int, | 40 | int lookup_key_in_hostkeys_by_type(struct hostkeys *, int, |
41 | const struct hostkey_entry **); | 41 | const struct hostkey_entry **); |
42 | 42 | ||
43 | int hostfile_read_key(char **, int *, Key *); | 43 | int hostfile_read_key(char **, u_int *, struct sshkey *); |
44 | int add_host_to_hostfile(const char *, const char *, const Key *, int); | 44 | int add_host_to_hostfile(const char *, const char *, |
45 | const struct sshkey *, int); | ||
46 | |||
47 | int hostfile_replace_entries(const char *filename, | ||
48 | const char *host, const char *ip, struct sshkey **keys, size_t nkeys, | ||
49 | int store_hash, int quiet, int hash_alg); | ||
45 | 50 | ||
46 | #define HASH_MAGIC "|1|" | 51 | #define HASH_MAGIC "|1|" |
47 | #define HASH_DELIM '|' | 52 | #define HASH_DELIM '|' |
@@ -51,4 +56,53 @@ int add_host_to_hostfile(const char *, const char *, const Key *, int); | |||
51 | 56 | ||
52 | char *host_hash(const char *, const char *, u_int); | 57 | char *host_hash(const char *, const char *, u_int); |
53 | 58 | ||
59 | /* | ||
60 | * Iterate through a hostkeys file, optionally parsing keys and matching | ||
61 | * hostnames. Allows access to the raw keyfile lines to allow | ||
62 | * streaming edits to the file to take place. | ||
63 | */ | ||
64 | #define HKF_WANT_MATCH (1) /* return only matching hosts/addrs */ | ||
65 | #define HKF_WANT_PARSE_KEY (1<<1) /* need key parsed */ | ||
66 | |||
67 | #define HKF_STATUS_OK 0 /* Line parsed, didn't match host */ | ||
68 | #define HKF_STATUS_INVALID 1 /* line had parse error */ | ||
69 | #define HKF_STATUS_COMMENT 2 /* valid line contained no key */ | ||
70 | #define HKF_STATUS_MATCHED 3 /* hostname or IP matched */ | ||
71 | |||
72 | #define HKF_MATCH_HOST (1) /* hostname matched */ | ||
73 | #define HKF_MATCH_IP (1<<1) /* address matched */ | ||
74 | #define HKF_MATCH_HOST_HASHED (1<<2) /* hostname was hashed */ | ||
75 | #define HKF_MATCH_IP_HASHED (1<<3) /* address was hashed */ | ||
76 | /* XXX HKF_MATCH_KEY_TYPE? */ | ||
77 | |||
78 | /* | ||
79 | * The callback function receives this as an argument for each matching | ||
80 | * hostkey line. The callback may "steal" the 'key' field by setting it to NULL. | ||
81 | * If a parse error occurred, then "hosts" and subsequent options may be NULL. | ||
82 | */ | ||
83 | struct hostkey_foreach_line { | ||
84 | const char *path; /* Path of file */ | ||
85 | u_long linenum; /* Line number */ | ||
86 | u_int status; /* One of HKF_STATUS_* */ | ||
87 | u_int match; /* Zero or more of HKF_MATCH_* OR'd together */ | ||
88 | char *line; /* Entire key line; mutable by callback */ | ||
89 | int marker; /* CA/revocation markers; indicated by MRK_* value */ | ||
90 | const char *hosts; /* Raw hosts text, may be hashed or list multiple */ | ||
91 | const char *rawkey; /* Text of key and any comment following it */ | ||
92 | int keytype; /* Type of key; KEY_UNSPEC for invalid/comment lines */ | ||
93 | struct sshkey *key; /* Key, if parsed ok and HKF_WANT_MATCH_HOST set */ | ||
94 | const char *comment; /* Any comment following the key */ | ||
95 | }; | ||
96 | |||
97 | /* | ||
98 | * Callback fires for each line (or matching line if a HKF_WANT_* option | ||
99 | * is set). The foreach loop will terminate if the callback returns a non- | ||
100 | * zero exit status. | ||
101 | */ | ||
102 | typedef int hostkeys_foreach_fn(struct hostkey_foreach_line *l, void *ctx); | ||
103 | |||
104 | /* Iterate over a hostkeys file */ | ||
105 | int hostkeys_foreach(const char *path, hostkeys_foreach_fn *callback, void *ctx, | ||
106 | const char *host, const char *ip, u_int options); | ||
107 | |||
54 | #endif | 108 | #endif |