HomePhabricator

knownhosts: Use ssh_mkdirs() instead of ssh_mkdir()

Authored by Anderson Toshiyuki Sasaki <ansasaki@redhat.com> on Wed, Jul 31, 3:48 PM.

Description

knownhosts: Use ssh_mkdirs() instead of ssh_mkdir()

Previously, if the path to known_hosts file set through
SSH_OPTIONS_KNOWNHOSTS included missing directories,
ssh_session_update_known_hosts() would fail. The added test case checks
that this is not the case anymore.

The logic of checking if the directory is accessible before creating it
was replaced by creating the directory if opening the file failed. This
is to minimize the risk of TOCTOU race conditions.

Fixes: T166

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 5b18bcb0ac39c3c366dd769e893af381ddb5deb2)

Details

Committed
JakujeThu, Aug 8, 9:45 AM
Parents
rLIBSSH80c1dbdb6188: misc: Introduce internal function ssh_mkdirs()
Branches
Unknown
Tags
Unknown