ssh: Improve key lookup for many keys.
authorWerner Koch <wk@gnupg.org>
Mon, 10 Dec 2012 17:27:23 +0000 (18:27 +0100)
committerWerner Koch <wk@gnupg.org>
Mon, 1 Jul 2013 18:31:11 +0000 (20:31 +0200)
commit901162579119585ebd3df9001b0370e6d32934ab
tree6a4501391b780d8e102d4c9c9f38828ba1c2363c
parent336112e519079f43278a8ca8c2937417bc667d8f
ssh: Improve key lookup for many keys.

* agent/command-ssh.c: Remove dirent.h.
(control_file_s): Add struct item.
(rewind_control_file): New.
(search_control_file): Factor code out to ...
(read_control_file_item): New.
(ssh_handler_request_identities): Change to iterate over entries in
sshcontrol.
--

Formerly we scanned the private key directory for matches of entries
in sshcontrol.  This patch changes it to scan the sshcontrol file and
thus considers only keys configured there.  The rationale for this is
that it is common to have only a few ssh keys but many private keys.
Even if that assumption does not hold true, the scanning of the
sshcontrol file is faster than reading the directory and only then
scanning the ssh control for each directory entry.

(cherry picked from commit d2777f84be0ded5906a9bec3bc23cfed0a9be02f)
agent/command-ssh.c