diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-12-20 23:36:51 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-12-21 10:52:28 +1100 |
commit | b4c7cd1185c5dc0593d47eafcc1a34fda569dd1d (patch) | |
tree | efcf7641caaa015124a7b5cfd6622a0791ed0c32 /hostfile.h | |
parent | 06fbb386bed666581095cb9cbc7a900e02bfe1b7 (diff) | |
download | openssh-git-b4c7cd1185c5dc0593d47eafcc1a34fda569dd1d.tar.gz |
upstream: load_hostkeys()/hostkeys_foreach() variants for FILE*
Add load_hostkeys_file() and hostkeys_foreach_file() that accept a
FILE* argument instead of opening the file directly.
Original load_hostkeys() and hostkeys_foreach() are implemented using
these new interfaces.
Add a u_int note field to the hostkey_entry and hostkey_foreach_line
structs that is passed directly from the load_hostkeys() and
hostkeys_foreach() call. This is a lightweight way to annotate results
between different invocations of load_hostkeys().
ok markus@
OpenBSD-Commit-ID: 6ff6db13ec9ee4edfa658b2c38baad0f505d8c20
Diffstat (limited to 'hostfile.h')
-rw-r--r-- | hostfile.h | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: hostfile.h,v 1.27 2020/10/04 09:45:01 djm Exp $ */ +/* $OpenBSD: hostfile.h,v 1.28 2020/12/20 23:36:51 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -28,11 +28,15 @@ struct hostkey_entry { u_long line; struct sshkey *key; HostkeyMarker marker; + u_int note; /* caller-specific note/flag */ }; struct hostkeys; struct hostkeys *init_hostkeys(void); -void load_hostkeys(struct hostkeys *, const char *, const char *); +void load_hostkeys(struct hostkeys *, const char *, + const char *, u_int); +void load_hostkeys_file(struct hostkeys *, const char *, + const char *, FILE *, u_int note); void free_hostkeys(struct hostkeys *); HostStatus check_key_in_hostkeys(struct hostkeys *, struct sshkey *, @@ -93,6 +97,7 @@ struct hostkey_foreach_line { 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 */ + u_int note; /* caller-specified note copied from arguments */ }; /* @@ -103,8 +108,12 @@ struct hostkey_foreach_line { 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); +int hostkeys_foreach(const char *path, + hostkeys_foreach_fn *callback, void *ctx, + const char *host, const char *ip, u_int options, u_int note); +int hostkeys_foreach_file(const char *path, FILE *f, + hostkeys_foreach_fn *callback, void *ctx, + const char *host, const char *ip, u_int options, u_int note); void hostfile_create_user_ssh_dir(const char *, int); |