Bug 826511

Summary: libssh2 returns LIBSSH2_ERROR_EAGAIN in blocking mode
Product: Red Hat Enterprise Linux 6 Reporter: Harald Klein <hklein>
Component: libssh2Assignee: Kamil Dudka <kdudka>
Status: CLOSED ERRATA QA Contact: Karel Srot <ksrot>
Severity: high Docs Contact:
Priority: high    
Version: 6.2CC: jpallich, ksrot, mvadkert, ovasik, plyons, syeghiay
Target Milestone: rcKeywords: EasyFix, Patch, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libssh2-1.2.2-11.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 08:42:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 834211    
Attachments:
Description Flags
successful run with libssh2-1.2.7
none
unsuccessful attempt with libsssh2-1.2.2
none
Net::SSH2 test script
none
backport of upstream commit 697b4e8 none

Description Harald Klein 2012-05-30 11:41:50 UTC
Description of problem:

libssh2 returns LIBSSH2_ERROR_EAGAIN in blocking mode when trying to connect with a Perl script using Net::SSH2

Version-Release number of selected component (if applicable):

libssh2-1.2.2-7

How reproducible:

Run the provided script

Steps to Reproduce:
1. Install Net::SSH2 (e.g. via CPAN)
2. Run the provided perl script
  
Actual results:

LIBSSH2_ERROR_EAGAIN
Unable to exchange encryption keys
Net::SSH2::DESTROY object 0x20474b0

Expected results:

no LIBSSH2_ERROR_EAGAIN

Additional info:

Weird enough the script still works when one would remove the error handling from the connect() call. So even after returning the EAGAIN, the other library calls work fine (auth_publickey(), scp_put()). The script works without flaws on libssh2-1.2.7. Just removing the error handling after connect or ignoring the EAGAIN is not an option as this would affect too many scripts from a 3rd party software, so this is not suitable as a workaround.

I did try to enable tracing but was not able to gather more information from the traces. They're attached.

Comment 1 Harald Klein 2012-05-30 11:44:20 UTC
Created attachment 587702 [details]
successful run with libssh2-1.2.7

this is a trace of libssh2 and the output of the script from a successful run with libssh2-1.2.7

Comment 2 Harald Klein 2012-05-30 11:45:33 UTC
Created attachment 587703 [details]
unsuccessful attempt with libsssh2-1.2.2

this is a trace of libssh2 and the output of the script failing with libssh2-1.2.2

Comment 3 Harald Klein 2012-05-30 11:50:59 UTC
Created attachment 587704 [details]
Net::SSH2 test script

Comment 5 Kamil Dudka 2012-05-30 12:25:39 UTC
Thanks for the reproducer.  git-bisect points to this upstream commit as the fix:

http://git.libssh2.org/?p=libssh2.git;a=commitdiff;h=697b4e8

I will need to check whether the fix is applicable on RHEL-6 libssh2 on its own.

Comment 6 Kamil Dudka 2012-05-30 12:44:21 UTC
Created attachment 587718 [details]
backport of upstream commit 697b4e8

Comment 7 Kamil Dudka 2012-05-30 12:46:56 UTC
The attached one-line patch fixes the issue and does not seem to break anything at first glance.  I was able to pass 43 SCP/SFTP tests from rawhide curl against the patched libssh2 library.

Comment 8 Suzanne Logcher 2012-05-30 14:19:16 UTC
This request was evaluated by Red Hat Product Management for inclusion in the
current release of Red Hat Enterprise Linux. Because the affected component is
not scheduled to be updated in the current release, Red Hat is unfortunately
unable to address this request at this time.  It has been proposed for the next
release.

Comment 18 errata-xmlrpc 2013-02-21 08:42:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0329.html