summaryrefslogtreecommitdiff
path: root/hostfile.h
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-02-16 22:08:57 +0000
committerDamien Miller <djm@mindrot.org>2015-02-17 09:32:31 +1100
commit6c5c949782d86a6e7d58006599c7685bfcd01685 (patch)
tree7a3f58c507d8aacaefae9880bcfcc924aa2b891b /hostfile.h
parent51b082ccbe633dc970df1d1f4c9c0497115fe721 (diff)
upstream commit
Refactor hostkeys_foreach() and dependent code Deal with IP addresses (i.e. CheckHostIP) Don't clobber known_hosts when nothing changed ok markus@ as part of larger commit
Diffstat (limited to 'hostfile.h')
-rw-r--r--hostfile.h31
1 files changed, 20 insertions, 11 deletions
diff --git a/hostfile.h b/hostfile.h
index 9080b5edb..bd2104373 100644
--- a/hostfile.h
+++ b/hostfile.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: hostfile.h,v 1.23 2015/01/26 03:04:45 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>
@@ -44,8 +44,9 @@ int hostfile_read_key(char **, u_int *, struct sshkey *);
44int add_host_to_hostfile(const char *, const char *, 44int add_host_to_hostfile(const char *, const char *,
45 const struct sshkey *, int); 45 const struct sshkey *, int);
46 46
47int hostfile_replace_entries(const char *filename, const char *host, 47int hostfile_replace_entries(const char *filename,
48 struct sshkey **keys, size_t nkeys, int store_hash, int quiet); 48 const char *host, const char *ip, struct sshkey **keys, size_t nkeys,
49 int store_hash, int quiet, int hash_alg);
49 50
50#define HASH_MAGIC "|1|" 51#define HASH_MAGIC "|1|"
51#define HASH_DELIM '|' 52#define HASH_DELIM '|'
@@ -60,13 +61,19 @@ char *host_hash(const char *, const char *, u_int);
60 * hostnames. Allows access to the raw keyfile lines to allow 61 * hostnames. Allows access to the raw keyfile lines to allow
61 * streaming edits to the file to take place. 62 * streaming edits to the file to take place.
62 */ 63 */
63#define HKF_WANT_MATCH_HOST (1) /* return only matching hosts */ 64#define HKF_WANT_MATCH (1) /* return only matching hosts/addrs */
64#define HKF_WANT_PARSE_KEY (1<<1) /* need key parsed */ 65#define HKF_WANT_PARSE_KEY (1<<1) /* need key parsed */
65 66
66#define HKF_STATUS_OK 1 /* Line parsed, didn't match host */ 67#define HKF_STATUS_OK 0 /* Line parsed, didn't match host */
67#define HKF_STATUS_INVALID 2 /* line had parse error */ 68#define HKF_STATUS_INVALID 1 /* line had parse error */
68#define HKF_STATUS_COMMENT 3 /* valid line contained no key */ 69#define HKF_STATUS_COMMENT 2 /* valid line contained no key */
69#define HKF_STATUS_HOST_MATCHED 4 /* hostname matched */ 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? */
70 77
71/* 78/*
72 * The callback function receives this as an argument for each matching 79 * The callback function receives this as an argument for each matching
@@ -76,12 +83,13 @@ char *host_hash(const char *, const char *, u_int);
76struct hostkey_foreach_line { 83struct hostkey_foreach_line {
77 const char *path; /* Path of file */ 84 const char *path; /* Path of file */
78 u_long linenum; /* Line number */ 85 u_long linenum; /* Line number */
79 int status; /* One of HKF_STATUS_* */ 86 u_int status; /* One of HKF_STATUS_* */
87 u_int match; /* Zero or more of HKF_MATCH_* OR'd together */
80 char *line; /* Entire key line; mutable by callback */ 88 char *line; /* Entire key line; mutable by callback */
81 int marker; /* CA/revocation markers; indicated by MRK_* value */ 89 int marker; /* CA/revocation markers; indicated by MRK_* value */
82 const char *hosts; /* Raw hosts text, may be hashed or list multiple */ 90 const char *hosts; /* Raw hosts text, may be hashed or list multiple */
83 int was_hashed; /* Non-zero if hostname was hashed */
84 const char *rawkey; /* Text of key and any comment following it */ 91 const char *rawkey; /* Text of key and any comment following it */
92 int keytype; /* Type of key; KEY_UNSPEC for invalid/comment lines */
85 struct sshkey *key; /* Key, if parsed ok and HKF_WANT_MATCH_HOST set */ 93 struct sshkey *key; /* Key, if parsed ok and HKF_WANT_MATCH_HOST set */
86 const char *comment; /* Any comment following the key */ 94 const char *comment; /* Any comment following the key */
87}; 95};
@@ -93,7 +101,8 @@ struct hostkey_foreach_line {
93 */ 101 */
94typedef int hostkeys_foreach_fn(struct hostkey_foreach_line *l, void *ctx); 102typedef int hostkeys_foreach_fn(struct hostkey_foreach_line *l, void *ctx);
95 103
104/* Iterate over a hostkeys file */
96int hostkeys_foreach(const char *path, hostkeys_foreach_fn *callback, void *ctx, 105int hostkeys_foreach(const char *path, hostkeys_foreach_fn *callback, void *ctx,
97 const char *host, u_int options); 106 const char *host, const char *ip, u_int options);
98 107
99#endif 108#endif