summaryrefslogtreecommitdiff
path: root/hostfile.h
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2015-03-30 14:49:51 -0700
committerAdam Langley <agl@google.com>2015-04-07 17:50:50 -0700
commitd059297112922cabb0c674840589be8db821fd9a (patch)
tree9c2045d28ec1c8594090f38bc32e9f523dc6c68d /hostfile.h
parentf5c67b478bef9992de9e9ec91ce10af4f6205e0d (diff)
external/openssh: update to 6.8p1.
In preparation for some updates to external/openssh to make it work with BoringSSL, this change updates the code to a recent version. The current version (5.9p1) is coming up on four years old now. * Confirmed that f5c67b478bef9992de9e9ec91ce10af4f6205e0d matches OpenSSH 5.9p1 exactly (save for the removal of the scard subdirectory). * Downloaded openssh-6.8p1.tar.gz (SHA256: 3ff64ce73ee124480b5bf767b9830d7d3c03bbcb6abe716b78f0192c37ce160e) and verified with PGP signature. (I've verified Damien's key in person previously.) * Applied changes between f5c67b478bef9992de9e9ec91ce10af4f6205e0d and OpenSSH 5.9p1 to 6.8p1 and updated the build as best I can. The ugliest change is probably the duplication of umac.c to umac128.c because Android conditionally compiles that file twice. See the comment in those files. Change-Id: I63cb07a8118afb5a377f116087a0882914cea486
Diffstat (limited to 'hostfile.h')
-rw-r--r--hostfile.h64
1 files changed, 59 insertions, 5 deletions
diff --git a/hostfile.h b/hostfile.h
index d84d422f..bd210437 100644
--- a/hostfile.h
+++ b/hostfile.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hostfile.h,v 1.19 2010/11/29 23:45:51 djm Exp $ */
+/* $OpenBSD: hostfile.h,v 1.24 2015/02/16 22:08:57 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -26,7 +26,7 @@ struct hostkey_entry {
char *host;
char *file;
u_long line;
- Key *key;
+ struct sshkey *key;
HostkeyMarker marker;
};
struct hostkeys;
@@ -35,13 +35,18 @@ struct hostkeys *init_hostkeys(void);
void load_hostkeys(struct hostkeys *, const char *, const char *);
void free_hostkeys(struct hostkeys *);
-HostStatus check_key_in_hostkeys(struct hostkeys *, Key *,
+HostStatus check_key_in_hostkeys(struct hostkeys *, struct sshkey *,
const struct hostkey_entry **);
int lookup_key_in_hostkeys_by_type(struct hostkeys *, int,
const struct hostkey_entry **);
-int hostfile_read_key(char **, u_int *, Key *);
-int add_host_to_hostfile(const char *, const char *, const Key *, int);
+int hostfile_read_key(char **, u_int *, struct sshkey *);
+int add_host_to_hostfile(const char *, const char *,
+ const struct sshkey *, int);
+
+int hostfile_replace_entries(const char *filename,
+ const char *host, const char *ip, struct sshkey **keys, size_t nkeys,
+ int store_hash, int quiet, int hash_alg);
#define HASH_MAGIC "|1|"
#define HASH_DELIM '|'
@@ -51,4 +56,53 @@ int add_host_to_hostfile(const char *, const char *, const Key *, int);
char *host_hash(const char *, const char *, u_int);
+/*
+ * Iterate through a hostkeys file, optionally parsing keys and matching
+ * hostnames. Allows access to the raw keyfile lines to allow
+ * streaming edits to the file to take place.
+ */
+#define HKF_WANT_MATCH (1) /* return only matching hosts/addrs */
+#define HKF_WANT_PARSE_KEY (1<<1) /* need key parsed */
+
+#define HKF_STATUS_OK 0 /* Line parsed, didn't match host */
+#define HKF_STATUS_INVALID 1 /* line had parse error */
+#define HKF_STATUS_COMMENT 2 /* valid line contained no key */
+#define HKF_STATUS_MATCHED 3 /* hostname or IP matched */
+
+#define HKF_MATCH_HOST (1) /* hostname matched */
+#define HKF_MATCH_IP (1<<1) /* address matched */
+#define HKF_MATCH_HOST_HASHED (1<<2) /* hostname was hashed */
+#define HKF_MATCH_IP_HASHED (1<<3) /* address was hashed */
+/* XXX HKF_MATCH_KEY_TYPE? */
+
+/*
+ * The callback function receives this as an argument for each matching
+ * hostkey line. The callback may "steal" the 'key' field by setting it to NULL.
+ * If a parse error occurred, then "hosts" and subsequent options may be NULL.
+ */
+struct hostkey_foreach_line {
+ const char *path; /* Path of file */
+ u_long linenum; /* Line number */
+ u_int status; /* One of HKF_STATUS_* */
+ u_int match; /* Zero or more of HKF_MATCH_* OR'd together */
+ char *line; /* Entire key line; mutable by callback */
+ int marker; /* CA/revocation markers; indicated by MRK_* value */
+ const char *hosts; /* Raw hosts text, may be hashed or list multiple */
+ const char *rawkey; /* Text of key and any comment following it */
+ int keytype; /* Type of key; KEY_UNSPEC for invalid/comment lines */
+ struct sshkey *key; /* Key, if parsed ok and HKF_WANT_MATCH_HOST set */
+ const char *comment; /* Any comment following the key */
+};
+
+/*
+ * Callback fires for each line (or matching line if a HKF_WANT_* option
+ * is set). The foreach loop will terminate if the callback returns a non-
+ * zero exit status.
+ */
+typedef int hostkeys_foreach_fn(struct hostkey_foreach_line *l, void *ctx);
+
+/* Iterate over a hostkeys file */
+int hostkeys_foreach(const char *path, hostkeys_foreach_fn *callback, void *ctx,
+ const char *host, const char *ip, u_int options);
+
#endif