Skip Menu |

This queue is for tickets about the Net-SSH2 CPAN distribution.

Report information
The Basics
Id: 131936
Status: open
Priority: 0/
Queue: Net-SSH2

People
Owner: Nobody in particular
Requestors: LSTEVENS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Hi I know that Net::SSH2::KnownHosts is marked as experimental. I make very good use of it and I have a suggestion for an enhancement to it. My Perl application code acts as an SSH terminal and I can spawn many instances of it. The way I deal with unknown SSH hosts is that I automatically add them to the known_hosts file the 1st time, and this is done with a call to: $kh->add(...) $kh->writefile($known_hosts_path) But if multiple instances of my application code do it at the same time, the known_hosts file can get corrupted. It would be nice if these methods could accept a filehandle as well as a filename. $kh->readfile($file_or_filehandle) $kh->writefile($file_or_filehandle) Then one could use flock() on the filehandle before handing it over to the above methods. This would prevent simultaneous writes to the same file as well as reading the file while it is being modified. I have a workaround in place, but thought I'd ask anyway. Thanks for writing the module. Best regards Ludovico Stevens
Unfortunately this is not trivial. libssh2_knownhosts_wsritefile() maps directly to a libssh2 API: https://libssh2.org/libssh2_knownhost_writefile.html There is no corresponding API for writing to a handle, it would have to be implemented in libssh2 first.