From libssh2-devel-bounces@cool.haxx.se  Mon Dec  5 01:14:42 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB50EGSO029052;
	Mon, 5 Dec 2011 01:14:36 +0100
Received: from rs136.luxsci.com (rs136.luxsci.com [72.32.115.28])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB50EDPP029037
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Mon, 5 Dec 2011 01:14:15 +0100
Received: from rs136.luxsci.com (localhost.localdomain [127.0.0.1])
	by rs136.luxsci.com (8.13.8/8.13.8) with ESMTP id pB50E9CR006995
	for <libssh2-devel@cool.haxx.se>; Sun, 4 Dec 2011 18:14:09 -0600
Received: (from root@localhost)
	by rs136.luxsci.com (8.13.8/8.13.8/Submit) id pB50E2Pf006907
	for libssh2-devel@cool.haxx.se; Mon, 5 Dec 2011 00:14:02 GMT
Message-Id: <201112050014.pB50E2Pf006907@rs136.luxsci.com>
Received: (from sender 30582) by Lux Scientiae SP;
	Mon, 05 Dec 2011 00:14:02 +0000
Date: Sun, 4 Dec 2011 19:13:39 -0500
From: Ben Kibbey <bjk@luxsci.net>
To: libssh2-devel@cool.haxx.se
Subject: ssh-agent and keys
Content-Disposition: inline
X-Lux-Comment: Message pB50Dg3u006790 sent by user #30582
MIME-Version: 1.0
X-Comment: Lux Scientiae SP Message ID - 1323044042-891795.204410301
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

Hello folks,

I have a question about how to implement ssh-agent support in my
program. Am I supposed to iterate over libssh2_agent_get_identity() and
libssh2_agent_userauth() until a valid/correct key is found from the
agent? It seems insecure if the remote host was somehow compromised
since the SSH server may collect private keys for others hosts from the
client.

Or maybe there is a way to obtain the public portion of the key from the
agent's private key and compare it with the remotes public key identity
before sending any private key data?

Thanks for any help,

-- 
Ben Kibbey
[XMPP: bjk AT jabber DOT org] - [IRC: (bjk) FreeNode/OFTC]
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Mon Dec  5 01:47:08 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB50kwXW020536;
	Mon, 5 Dec 2011 01:47:07 +0100
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB50kuXk020491
	for <libssh2-devel@cool.haxx.se>; Mon, 5 Dec 2011 01:46:56 +0100
Received: from int-mx01.intmail.prod.int.phx2.redhat.com
	(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB50kqUk004358
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Sun, 4 Dec 2011 19:46:52 -0500
Received: from ashe.local. (vpn1-5-220.ams2.redhat.com [10.36.5.220])
	by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
	id pB50koWA022785; Sun, 4 Dec 2011 19:46:51 -0500
Message-ID: <4EDC147A.2000502@redhat.com>
Date: Mon, 05 Dec 2011 01:46:50 +0100
From: Peter Krempa <pkrempa@redhat.com>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:8.0) Gecko/20111105 Thunderbird/8.0
MIME-Version: 1.0
To: libssh2 development <libssh2-devel@cool.haxx.se>
Subject: Re: ssh-agent and keys
References: <201112050014.pB50E2Pf006907@rs136.luxsci.com>
In-Reply-To: <201112050014.pB50E2Pf006907@rs136.luxsci.com>
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11
Cc: Ben Kibbey <bjk@luxsci.net>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pB50kwXW020536

DÅˆa 5.12.2011 1:13, Ben Kibbey  wrote / napÃ­sal(a):
> Hello folks,
>
> I have a question about how to implement ssh-agent support in my
> program. Am I supposed to iterate over libssh2_agent_get_identity() and
> libssh2_agent_userauth() until a valid/correct key is found from the
> agent?
Yes, that's probably the correct approach. I'm going to implement 
agent-based auth soon, so if you don't figure it out by yourself, then 
ask again in some time :)

It seems insecure if the remote host was somehow compromised
> since the SSH server may collect private keys for others hosts from the
> client.

The private SSH keys are _NOT_ sent to the server in any case. The 
authenitcation is done in a following way (simplified):

1) The server creates a random message.
2) The server encrypts the message using the client's public key
3) The server sends the encrypted challenge to the client
4) The client decrypts the message using his private key and replies to 
the server using plaintext of the message
5) The server verifies, that the client is in posession of the private 
key, as he was able to decrypt the message. (In ideal world) Only the 
rightful owner is in posession of the private key and thus able to 
decrypt the message.
6) Authentication succeeds.

The private key is named private, as you never ever tell it anyone.
This is the beauty of asymetric cryptography.

> Or maybe there is a way to obtain the public portion of the key from the
> agent's private key and compare it with the remotes public key identity
> before sending any private key data?
Private key is NEVER sent :). You have to add your public key to 
"authorised_keys" to tell the server, that it should try this key, as 
you hold the private part to it. This cannot be determined on the fly, 
as an attacker could specify, his own public key, he has a private key 
for. (The keys always come in pairs: public-private.).
>
> Thanks for any help,
>

I hope this clarified it somewhat.

Regards,

Peter

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Mon Dec  5 02:14:45 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB51EXWw032666;
	Mon, 5 Dec 2011 02:14:43 +0100
Received: from vps1.henriknordstrom.net (vps1.henriknordstrom.net
	[IPv6:2a02:750:7::d0a])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB51EW5S032659
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Mon, 5 Dec 2011 02:14:32 +0100
Received: from henriknordstrom.net (183.159.216.81.static.tb.siw.siwnet.net
	[81.216.159.183])
	by vps1.henriknordstrom.net (8.14.2/8.14.2/Debian-2build1) with ESMTP
	id pB51EXlM032262
	for <libssh2-devel@cool.haxx.se>; Mon, 5 Dec 2011 01:14:33 GMT
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by henriknordstrom.net (8.12.11.20060308/8.12.8) with ESMTP id
	pB51EFD6020746
	for <libssh2-devel@cool.haxx.se>; Mon, 5 Dec 2011 02:14:15 +0100
Message-ID: <1323047655.5224.138.camel@henriknordstrom.net>
Subject: Re: ssh-agent and keys
From: Henrik =?ISO-8859-1?Q?Nordstr=F6m?= <henrik@henriknordstrom.net>
To: libssh2 development <libssh2-devel@cool.haxx.se>
Date: Mon, 05 Dec 2011 02:14:15 +0100
In-Reply-To: <201112050014.pB50E2Pf006907@rs136.luxsci.com>
References: <201112050014.pB50E2Pf006907@rs136.luxsci.com>
X-Mailer: Evolution 3.2.2 (3.2.2-1.fc16) 
Mime-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0
	(vps1.henriknordstrom.net [195.20.207.177]);
	Mon, 05 Dec 2011 01:14:33 +0000 (UTC)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pB51EXWw032666

sÃ¶n 2011-12-04 klockan 19:13 -0500 skrev Ben Kibbey:

> I have a question about how to implement ssh-agent support in my
> program. Am I supposed to iterate over libssh2_agent_get_identity() and
> libssh2_agent_userauth() until a valid/correct key is found from the
> agent? It seems insecure if the remote host was somehow compromised
> since the SSH server may collect private keys for others hosts from the
> client.

You can not collect private keys from the agent. Only public keys. And
SSH servers never get the private key at all in any mode of operation,
only a signature which can be verified by using the public component of
the key.

A malicious server MAY collect the public component of any key you
advertise to them, no matter if this is from file or agent. But it is
your choice to select which keys you want to advertise of the available
ones.

Normal mode of operation is to iterate over all the available keys until
one is accepted. You can find an example of this in
example/ssh2_agent.c.

On the wire publickey authentication consists of two steps per key,
first the key fingerprint is sent to the server, and if it's
acceptable(known) to the server then a one-time signature is generated
and sent to the server together with the public key component.

Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Mon Dec  5 02:31:28 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB51VL1x011467;
	Mon, 5 Dec 2011 02:31:27 +0100
Received: from vps1.henriknordstrom.net (vps1.henriknordstrom.net
	[IPv6:2a02:750:7::d0a])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB51VKUc011462
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Mon, 5 Dec 2011 02:31:20 +0100
Received: from henriknordstrom.net (183.159.216.81.static.tb.siw.siwnet.net
	[81.216.159.183])
	by vps1.henriknordstrom.net (8.14.2/8.14.2/Debian-2build1) with ESMTP
	id pB51VLKV007298
	for <libssh2-devel@cool.haxx.se>; Mon, 5 Dec 2011 01:31:21 GMT
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by henriknordstrom.net (8.12.11.20060308/8.12.8) with ESMTP id
	pB51V3jk021969
	for <libssh2-devel@cool.haxx.se>; Mon, 5 Dec 2011 02:31:03 +0100
Message-ID: <1323048663.5224.148.camel@henriknordstrom.net>
Subject: Re: ssh-agent and keys
From: Henrik =?ISO-8859-1?Q?Nordstr=F6m?= <henrik@henriknordstrom.net>
To: libssh2-devel@cool.haxx.se
Date: Mon, 05 Dec 2011 02:31:03 +0100
In-Reply-To: <4EDC147A.2000502@redhat.com>
References: <201112050014.pB50E2Pf006907@rs136.luxsci.com>
	<4EDC147A.2000502@redhat.com>
X-Mailer: Evolution 3.2.2 (3.2.2-1.fc16) 
Mime-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0
	(vps1.henriknordstrom.net [195.20.207.177]);
	Mon, 05 Dec 2011 01:31:21 +0000 (UTC)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pB51VL1x011467

mÃ¥n 2011-12-05 klockan 01:46 +0100 skrev Peter Krempa:

> The private SSH keys are _NOT_ sent to the server in any case. The 
> authenitcation is done in a following way (simplified):
> 
> 1) The server creates a random message.
> 2) The server encrypts the message using the client's public key
> 3) The server sends the encrypted challenge to the client
> 4) The client decrypts the message using his private key and replies to 
> the server using plaintext of the message
> 5) The server verifies, that the client is in posession of the private 
> key, as he was able to decrypt the message. (In ideal world) Only the 
> rightful owner is in posession of the private key and thus able to 
> decrypt the message.
> 6) Authentication succeeds.

SSH2 public key user authentication is not really that complex. It
builds on the session identifier established earlier condensing the
sequence to

0. client optinally asks if a given public key may be used
1. client generates a session unique signature of the session identifier
+ static data (SSH_MSG_USERAUTH_REQUEST minus the signature component),
signed with the private key.
2. server verifies the signature using the public key

libssh2 always performs step 0, and so do most other ssh clients as
well.

Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Thu Dec  8 09:38:06 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB88beJw003098;
	Thu, 8 Dec 2011 09:38:00 +0100
Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com
	[209.85.213.182])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB88bbtu003074
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 09:37:38 +0100
Received: by yenl9 with SMTP id l9so1234213yen.41
	for <libssh2-devel@cool.haxx.se>; Thu, 08 Dec 2011 00:37:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=93PYR26QySSu0ZVCZ431PJ5SM7PTuciPOhJIeuDbck8=;
	b=Wl7GZF3NgasXhlNiPeXInyiYgG/j3jibOIGV1Zs2HHAOVrQprBdqSfUjg+6T69zh2B
	txy9GCqpAs/RhJiMzif8OruPuNOX2S7B9v8TyChqsfDIXZI5QGMXUmulkdHOlXs1Rr2l
	/GH8klu5d5qR6oXRsZXYhHf/NCrlYKnQi2+dA=
MIME-Version: 1.0
Received: by 10.236.175.65 with SMTP id y41mr1032074yhl.26.1323333452848; Thu,
	08 Dec 2011 00:37:32 -0800 (PST)
Received: by 10.236.189.2 with HTTP; Thu, 8 Dec 2011 00:37:32 -0800 (PST)
Date: Thu, 8 Dec 2011 14:07:32 +0530
Message-ID: <CAEKYpER2CmqmDdH6M2-Xj5iq5VBP2XOxkPvXZ36vXEdmK28TcQ@mail.gmail.com>
Subject: libssh2_channel_read() blocking in case of a background process
From: anirudh nair <anirudh.anu01@gmail.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1039815899=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============1039815899==
Content-Type: multipart/alternative; boundary=20cf305b0e12605d2204b3909492

--20cf305b0e12605d2204b3909492
Content-Type: text/plain; charset=ISO-8859-1

Hi all,

I need to execute a remote script as below

//script begins- only psuedo_code

some_process &(as a background process)
if (some_process is up)
echo "Application is running"
exit 1
else
echo "Application not started"
exit 2
endif

//script ends


But I see that  libssh2_channel_read() blocks while waiting for
some_process to return.

But If I make it non blocking i.e
libssh2_session_set_blocking(session, 0);

the below code always returns 0
nReturnCode = libssh2_channel_get_exit_status( channel );

Ideally I want the read not to block and at the same time return the
correct return code i.e 1

Hope my problem statement is clear.

How can I go about achieving this requirement?

Thanks
Anirudh

--20cf305b0e12605d2204b3909492
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi all,<div><br></div><div>I need to execute a remote script as below</div>=
<div><br></div><div>//script begins- only psuedo_code</div><div><br></div><=
div>some_process &amp;(as a background process)</div><div>if (some_process=
=A0is up)</div>
<div>echo &quot;Application is running&quot;</div><div>exit 1</div><div>els=
e</div><div>echo &quot;Application not started&quot;</div><div>exit 2</div>=
<div>endif</div><div><br></div><div>//script ends</div><div><br></div><div>
<br></div><div>But I see that =A0libssh2_channel_read() blocks while waitin=
g for some_process to return.</div><div><br></div><div>But If I make it non=
 blocking i.e</div><div>libssh2_session_set_blocking(session, 0);</div><div=
>
<br></div><div>the below code always returns 0</div><div>nReturnCode =3D li=
bssh2_channel_get_exit_status( channel );</div><div><br></div><div>Ideally =
I want the read not to block and at the same time return the correct return=
 code i.e 1</div>
<div><br></div><div>Hope my problem statement is clear.</div><div><br></div=
><div>How can I go about achieving this requirement?</div><div><br></div><d=
iv>Thanks</div><div>Anirudh=A0</div>

--20cf305b0e12605d2204b3909492--

--===============1039815899==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1039815899==--

From libssh2-devel-bounces@cool.haxx.se  Thu Dec  8 10:20:08 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB89Jva2006220;
	Thu, 8 Dec 2011 10:20:06 +0100
Received: from m13-7.163.com (m13-7.163.com [220.181.13.7])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB89JpFi006145
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 10:19:53 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;
	s=s110527; h=Received:Date:From:To:Message-ID:Subject:
	MIME-Version:Content-Type; bh=0Yu/j6xaB57th83xjnILMm2K6y+ao5hCW0
	ohYbpnrsA=; b=FhMKLBmtgwQ11SWUIIjJNX+5MOTQCWRbJ1RJr8bGDZ7VoktwSW
	CfKTfTJ0gQ8rvGDAApi/MhUhiEE79fIT8u0GdksE3fpnh6NwGaPBhRDMaZ/WD9sG
	onngM7L5CoJwTLXEyLn2tMgWjucCiTIZ7FCO89lAFaGPfHBsu7Ru5x4rw=
Received: from shengqi158 ( [218.249.91.198] ) by ajax-webmail-wmsvr7
	(Coremail) ; Thu, 8 Dec 2011 17:19:45 +0800 (CST)
Date: Thu, 8 Dec 2011 17:19:45 +0800 (CST)
From: shengqi158 <shengqi158@163.com>
To: libssh2-devel@cool.haxx.se
Message-ID: <4be71adc.1a71b.1341cf8aa86.Coremail.shengqi158@163.com>
Subject: cannot execute cmd at cisco pix
MIME-Version: 1.0
X-Originating-IP: [218.249.91.198]
X-Priority: 3
X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build
	111110(15680.4167.4075) Copyright (c) 2002-2011 www.mailtech.cn 163com
X-CM-CTRLDATA: rwDS5GZvb3Rlcl9odG09OTc5NDo4MQ==
X-CM-TRANSID: B8GowGCZP0EygeBOAWoTAA--.8804W
X-CM-SenderInfo: xvkh0wltlrkmi6rwjhhfrp/1tbiERYQLki7blWqEQAAsK
X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1758729231=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============1758729231==
Content-Type: multipart/alternative; 
	boundary="----=_Part_333903_468166110.1323335985798"

------=_Part_333903_468166110.1323335985798
Content-Type: text/plain; charset=GBK
Content-Transfer-Encoding: 7bit

hello folks,
OS: ubuntu 10.10
libssh2 version :1.3.0
remote host'os : cisco pix


when I execute the cmd "./ssh2_exec 10.18.209.205 pix nsfocus 'show version'",the ssh2_exec is the example code from libssh2.
I get info is:
xxx/libssh2-1.3.0/example$ ./ssh2_exec 10.18.209.205 pix nsfocus 'show version'
Host check: 2, key: <none>
libssh2_channel_read returned -37
We read:
Type help or '?' for a list of available commands.
pix> show version
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -37
libssh2_channel_read returned -43


Got signal: none
all done


From the info I know it has login the remote host but cannot read the channel. I can login the remote host by ssh command and excute cmd which can be 'show version' and get the right info. I can use the ssh2_exec to login remote cisco router except pix. here are the infos of login remote pix:


libssh2-1.3.0/example$ ssh pix@10.18.209.205
pix@10.18.209.205's password: 
Type help or '?' for a list of available commands.
pix> show version


Cisco PIX Security Appliance Software Version 7.2(2) 


Compiled on Wed 22-Nov-06 14:16 by builders
System image file is "Unknown, monitor mode tftp booted image"
Config file at boot was "startup-config"


pix up 8 hours 52 mins
.......


by the way, I can use the example code ssh2 to login the remote host.
Under the debug command of strace'help ,I think the 'show version' may not be send out,here are infos:
recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)
recv(3, "(\230Q\254\25\2242zs-\365\375_\313\263Dj\3015\f\212\237\224sDZ\27&\245\304\243j"..., 16384, MSG_NOSIGNAL) = 36
send(3, "\220X\f@\305\21\234\276<\5t\377\373\376\31n\37\224\222\215\216\356'\272\256\230Y&\5\353h\315"..., 68, MSG_NOSIGNAL) = 68
recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)
recv(3, "\224\311e+\23\17\356\254\206\255D\241\376\375\357\224\247\205*\237\0229S\2117\1\223w3I\347\36"..., 16384, MSG_NOSIGNAL) = 52
send(3, ")\230K\356\275Ene \0\33\f\300\205\30A\17\312g\272\5\201\f\337\253\266\233\206\234\344\215F"..., 68, MSG_NOSIGNAL) = 68
recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)
recv(3, "vS\372\2777m\211\326\341\204\31Cv\240G\342\325\222\261\f\245\321\0104\0\25\337\0337\6$\243"..., 16384, MSG_NOSIGNAL) = 36
recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)
libssh2_channel_read returned -37
recv(3, "\251\307\342\205\30x\204\243\226*\302\366\5\354\366\322\266\333\251\316x\247\267\243Cl\265b\205\307n\t"..., 16384, MSG_NOSIGNAL) = 776
recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)
We read:
Type help or '?' for a list of available commands.
pix> show version
recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)
libssh2_channel_read returned -37






Thanks for any help
------=_Part_333903_468166110.1323335985798
Content-Type: text/html; charset=GBK
Content-Transfer-Encoding: 7bit

<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial">hello folks,<div>OS: ubuntu 10.10</div><div>libssh2 version :1.3.0</div><div>remote host'os : cisco pix</div><div><br></div><div><div>when I execute the cmd "./ssh2_exec 10.18.209.205 pix nsfocus 'show version'",the ssh2_exec is the example code from libssh2.</div><div>I get info is:</div><div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">xxx/libssh2-1.3.0/example$ ./ssh2_exec 10.18.209.205 pix nsfocus 'show version'</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">Host check: 2, key: &lt;none&gt;</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">We read:</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">Type help or '?' for a list of available commands.</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">pix&gt; show version</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -43</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);"><br></span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">Got signal: none</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">all done</span></div></div><div><br></div><div>From the info I know it has login the remote host but cannot read the channel. I can login the remote host by ssh command and excute cmd which can be 'show version' and get the right info. I can use the ssh2_exec to login remote cisco router except pix. here are the infos of login remote pix:</div><div><br></div><div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2-1.3.0/example$ ssh pix@10.18.209.205</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">pix@10.18.209.205's password:&nbsp;</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">Type help or '?' for a list of available commands.</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">pix&gt; show version</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);"><br></span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">Cisco PIX Security Appliance Software Version 7.2(2)&nbsp;</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);"><br></span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">Compiled on Wed 22-Nov-06 14:16 by builders</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">System image file is "Unknown, monitor mode tftp booted image"</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">Config file at boot was "startup-config"</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);"><br></span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">pix up 8 hours 52 mins</span></div></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">.......</span></div><div><br></div><div>by the way, I can use the example code ssh2 to login the remote host.</div><div>Under the debug command of strace'help ,I think the 'show version' may not be send out,here are infos:</div><div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, "(\230Q\254\25\2242zs-\365\375_\313\263Dj\3015\f\212\237\224sDZ\27&amp;\245\304\243j"..., 16384, MSG_NOSIGNAL) = 36</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">send(3, "\220X\f@\305\21\234\276&lt;\5t\377\373\376\31n\37\224\222\215\216\356'\272\256\230Y&amp;\5\353h\315"..., 68, MSG_NOSIGNAL) = 68</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, "\224\311e+\23\17\356\254\206\255D\241\376\375\357\224\247\205*\237\0229S\2117\1\223w3I\347\36"..., 16384, MSG_NOSIGNAL) = 52</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">send(3, ")\230K\356\275Ene \0\33\f\300\205\30A\17\312g\272\5\201\f\337\253\266\233\206\234\344\215F"..., 68, MSG_NOSIGNAL) = 68</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, "vS\372\2777m\211\326\341\204\31Cv\240G\342\325\222\261\f\245\321\0104\0\25\337\0337\6$\243"..., 16384, MSG_NOSIGNAL) = 36</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, "\251\307\342\205\30x\204\243\226*\302\366\5\354\366\322\266\333\251\316x\247\267\243Cl\265b\205\307n\t"..., 16384, MSG_NOSIGNAL) = 776</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">We read:</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">Type help or '?' for a list of available commands.</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">pix&gt; show version</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">recv(3, 0x95c30a0, 16384, MSG_NOSIGNAL) = -1 EAGAIN (Resource temporarily unavailable)</span></div><div><span class="Apple-style-span" style="background-color: rgb(192, 192, 192);">libssh2_channel_read returned -37</span></div></div><div><br></div><div><br></div><div><br></div><div><div><div>Thanks for any help</div></div></div></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>
------=_Part_333903_468166110.1323335985798--


--===============1758729231==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1758729231==--

From libssh2-devel-bounces@cool.haxx.se  Thu Dec  8 17:21:01 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB8GKKVM000595;
	Thu, 8 Dec 2011 17:20:57 +0100
Received: from zeus.promailserver.com (zeus.promailserver.com [74.200.236.204])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB8GJR5A031609
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 17:19:28 +0100
Received: from Pippin ([86.212.194.8])
	by zeus.promailserver.com (Merak 8.3.6) with ASMTP id RCB35923
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 16:19:23 -0000
Message-ID: <91EB79A7A2B84C41A12E4F0BB94A75E7@Pippin>
From: =?iso-8859-1?Q?Elli=E9_Computing_Open_Source_Program?=
	<opensource@elliecomputing.com>
To: <libssh2-devel@cool.haxx.se>
Subject: is libssh2_agent_userauth blocking?
Date: Thu, 8 Dec 2011 17:19:24 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Mailer: Microsoft Windows Live Mail 15.4.3538.513
X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3538.513
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1701456130=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

Ce message est composi et au format MIME.

--===============1701456130==
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_0289_01CCB5CD.8827E1E0"

Ce message est composi et au format MIME.

------=_NextPart_000_0289_01CCB5CD.8827E1E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I am having a look at the libssh2 and wonder how to potentially use =
ssh-agent in a project using libcurl.
In order to work correctly, libcurl requires all the API to be non =
blocking or at least to have some short bounded time, however I suspect =
that libssh2_agent_??? APIs may have no bounded time (if the user gets a =
password box).

is the libssh2_agent_userauth API non blocking when the session is =
non-blocking?

Best regards
Armel
------=_NextPart_000_0289_01CCB5CD.8827E1E0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<HTML><HEAD></HEAD>
<BODY dir=3Dltr>
<DIV dir=3Dltr>
<DIV style=3D"FONT-FAMILY: 'Arial'; COLOR: #000000; FONT-SIZE: 10pt">
<DIV>Hi,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I am having a look at the libssh2 and wonder how to potentially use =

ssh-agent in a project using libcurl.</DIV>
<DIV>In order to work correctly, libcurl requires all the API to be non =
blocking=20
or at least to have some short bounded time, however I suspect that=20
libssh2_agent_??? APIs may have no bounded time (if the user gets a =
password=20
box).</DIV>
<DIV>&nbsp;</DIV>
<DIV>is the libssh2_agent_userauth API non blocking when the session is=20
non-blocking?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Best regards</DIV>
<DIV>Armel</DIV></DIV></DIV></BODY></HTML>

------=_NextPart_000_0289_01CCB5CD.8827E1E0--


--===============1701456130==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1701456130==--

From libssh2-devel-bounces@cool.haxx.se  Thu Dec  8 21:30:11 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB8KTqcT006250;
	Thu, 8 Dec 2011 21:30:08 +0100
Received: from vps1.henriknordstrom.net (vps1.henriknordstrom.net
	[IPv6:2a02:750:7::d0a])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB8KTpkE006167
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 21:29:51 +0100
Received: from henriknordstrom.net (183.159.216.81.static.tb.siw.siwnet.net
	[81.216.159.183])
	by vps1.henriknordstrom.net (8.14.2/8.14.2/Debian-2build1) with ESMTP
	id pB8KTpZm030272
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 20:29:51 GMT
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by henriknordstrom.net (8.12.11.20060308/8.12.8) with ESMTP id
	pB8KTm0K027396
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 21:29:48 +0100
Message-ID: <1323376188.24330.22.camel@henriknordstrom.net>
Subject: Re: is libssh2_agent_userauth blocking?
From: Henrik =?ISO-8859-1?Q?Nordstr=F6m?= <henrik@henriknordstrom.net>
To: libssh2-devel@cool.haxx.se
Date: Thu, 08 Dec 2011 21:29:48 +0100
In-Reply-To: <91EB79A7A2B84C41A12E4F0BB94A75E7@Pippin>
References: <91EB79A7A2B84C41A12E4F0BB94A75E7@Pippin>
X-Mailer: Evolution 3.2.2 (3.2.2-1.fc16) 
Mime-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0
	(vps1.henriknordstrom.net [195.20.207.177]);
	Thu, 08 Dec 2011 20:29:52 +0000 (UTC)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pB8KTqcT006250

tor 2011-12-08 klockan 17:19 +0100 skrev ElliÃ© Computing Open Source
Program:

> In order to work correctly, libcurl requires all the API to be non
> blocking or at least to have some short bounded time, however I
> suspect that libssh2_agent_??? APIs may have no bounded time (if the
> user gets a password box).

Not sure, but probably not supported (yet).

agent_transact_unix looks like there is some kind of support for
optimistic non-blocking mode, but it also looks like there is nothing
that actually sets the agent connection non-blocking.

agent_transact_pageant (windows) do not look like it's prepared for
non-blocking use at all.

Regards
Henrik


_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Thu Dec  8 21:38:21 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB8KcHUh011871;
	Thu, 8 Dec 2011 21:38:21 +0100
Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com
	[209.85.214.54])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB8KcFKC011819
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 21:38:15 +0100
Received: by bkbzv15 with SMTP id zv15so2406354bkb.41
	for <libssh2-devel@cool.haxx.se>; Thu, 08 Dec 2011 12:38:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:reply-to:date:message-id:subject:from:to:content-type;
	bh=m0w3l+ZBiTZmRH4vsVBBctiVdbMUBGzsTF+H7o0q4CU=;
	b=qD/t916dHcBWdEjX+4Ra3GqJmzNkZedl7OTtxevpEQrv2XCYWEy6n+3RjnE/b35AqO
	/uS7rz/D7SxKTKNtSqpmdbMOqybtOTIxeUF71aLAE2oNMmEcvdL9cRJzNFUTkMvsQUvM
	S0BltIUC3tV+ddt8qSIeg1eTFGeYWHAIADs64=
MIME-Version: 1.0
Received: by 10.204.149.212 with SMTP id u20mr2178501bkv.120.1323376690181;
	Thu, 08 Dec 2011 12:38:10 -0800 (PST)
Received: by 10.204.200.79 with HTTP; Thu, 8 Dec 2011 12:38:10 -0800 (PST)
Date: Thu, 8 Dec 2011 12:38:10 -0800
Message-ID: <CAJMfbAEbMeXn1-kFQkg4cuhoV5vQry_SHy9C+C3A0ovcC52uCw@mail.gmail.com>
Subject: Windows linking problem with multithreaded libssh2
From: Jeremy Friesner <jfriesne@gmail.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: jaf@meyersound.com, libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1795617698=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============1795617698==
Content-Type: multipart/alternative; boundary=0015175d040c85b7a704b39aa5b1

--0015175d040c85b7a704b39aa5b1
Content-Type: text/plain; charset=ISO-8859-1

Hi all,

I'm working on a multithreaded Qt-based program that uses libssh2.  The
program crashes inside crypt_encrypt() sometimes when there are a several
SSH-using threads running at once, so I googled around and found some pages
saying that for multithreaded libssh2 to work reliably, I need to call
CRYPTO_set_locking_callback(), etc, before using libssh2.

Okay, so I did that and got it to compile under MacOS/X, but under Windows
I get link errors from these calls:

Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation.  All rights reserved.
Linking...
main.obj : error LNK2019: unresolved external symbol
_CRYPTO_set_locking_callback referenced in function "void __cdecl
do_crypto_locks_setup(void)" (?do_crypto_locks_setup@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol _CRYPTO_malloc
referenced in function "void __cdecl do_crypto_locks_setup(void)"
(?do_crypto_locks_setup@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol _CRYPTO_num_locks
referenced in function "void __cdecl do_crypto_locks_setup(void)"
(?do_crypto_locks_setup@@YAXXZ)
main.obj : error LNK2019: unresolved external symbol _CRYPTO_free
referenced in function "void __cdecl do_crypto_locks_cleanup(void)"
(?do_crypto_locks_cleanup@@YAXXZ)

Does anyone have an idea about what I might need to do in order to link
these calls under Windows?  Is there some other .lib file I need to link
in, or do I need to pass a particular flag to the "perl Configure VC-WIN32"
command to enable these functions, or ???

Thanks,
Jeremy

--0015175d040c85b7a704b39aa5b1
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<span class=3D"Apple-style-span" style=3D"font-family: Helvetica; font-size=
: medium; ">Hi all,</span><span class=3D"Apple-style-span" style=3D"font-fa=
mily: Helvetica; font-size: medium; "><br></span><span class=3D"Apple-style=
-span" style=3D"font-family: Helvetica; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; ">I&#39;m working on a multithreaded Qt-based program that=
 uses libssh2. =A0The program crashes inside crypt_encrypt() sometimes when=
 there are a several SSH-using threads running at once, so I googled around=
 and found some pages saying that for multithreaded libssh2 to work reliabl=
y, I need to call CRYPTO_set_locking_callback(), etc, before using libssh2.=
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; "><br></span><span class=3D"Apple-style-span" style=3D"fon=
t-family: Helvetica; font-size: medium; ">Okay, so I did that and got it to=
 compile under MacOS/X, but under Windows I get link errors from these call=
s:</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; =
font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; "><br></span><span class=3D"Apple-style-span" style=3D"fon=
t-family: Helvetica; font-size: medium; ">Microsoft (R) Windows (R) Resourc=
e Compiler Version 6.1.6723.1</span><span class=3D"Apple-style-span" style=
=3D"font-family: Helvetica; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; ">Copyright (C) Microsoft Corporation. =A0All rights reser=
ved.</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica=
; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; ">Linking...</span><span class=3D"Apple-style-span" style=
=3D"font-family: Helvetica; font-size: medium; "><br></span><span class=3D"=
Apple-style-span" style=3D"font-family: Helvetica; font-size: medium; ">mai=
n.obj : error LNK2019: unresolved external symbol _CRYPTO_set_locking_callb=
ack referenced in function &quot;void __cdecl do_crypto_locks_setup(void)&q=
uot; (?do_crypto_locks_setup@@YAXXZ)</span><span class=3D"Apple-style-span"=
 style=3D"font-family: Helvetica; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; ">main.obj : error LNK2019: unresolved external symbol _CR=
YPTO_malloc referenced in function &quot;void __cdecl do_crypto_locks_setup=
(void)&quot; (?do_crypto_locks_setup@@YAXXZ)</span><span class=3D"Apple-sty=
le-span" style=3D"font-family: Helvetica; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; ">main.obj : error LNK2019: unresolved external symbol _CR=
YPTO_num_locks referenced in function &quot;void __cdecl do_crypto_locks_se=
tup(void)&quot; (?do_crypto_locks_setup@@YAXXZ)</span><span class=3D"Apple-=
style-span" style=3D"font-family: Helvetica; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; ">main.obj : error LNK2019: unresolved external symbol _CR=
YPTO_free referenced in function &quot;void __cdecl do_crypto_locks_cleanup=
(void)&quot; (?do_crypto_locks_cleanup@@YAXXZ)</span><span class=3D"Apple-s=
tyle-span" style=3D"font-family: Helvetica; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; "><br></span><span class=3D"Apple-style-span" style=3D"fon=
t-family: Helvetica; font-size: medium; ">Does anyone have an idea about wh=
at I might need to do in order to link these calls under Windows? =A0Is the=
re some other .lib file I need to link in, or do I need to pass a particula=
r flag to the &quot;perl Configure VC-WIN32&quot; command to enable these f=
unctions, or ???</span><span class=3D"Apple-style-span" style=3D"font-famil=
y: Helvetica; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; "><br></span><span class=3D"Apple-style-span" style=3D"fon=
t-family: Helvetica; font-size: medium; ">Thanks,</span><span class=3D"Appl=
e-style-span" style=3D"font-family: Helvetica; font-size: medium; "><br>
</span><span class=3D"Apple-style-span" style=3D"font-family: Helvetica; fo=
nt-size: medium; ">Jeremy</span><span class=3D"Apple-style-span" style=3D"f=
ont-family: Helvetica; font-size: medium; "><br></span>

--0015175d040c85b7a704b39aa5b1--

--===============1795617698==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1795617698==--

From libssh2-devel-bounces@cool.haxx.se  Thu Dec  8 21:52:23 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB8KqFsZ026156;
	Thu, 8 Dec 2011 21:52:22 +0100
Received: from ponderosa.fch.wimsey.bc.ca (zz201111.cipherkey.net
	[209.53.201.111])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB8KqDmG026084
	for <libssh2-devel@cool.haxx.se>; Thu, 8 Dec 2011 21:52:13 +0100
Received: by coneharvesters.com
	via sendmail with stdio id <m1RYkwr-000l6IC@ponderosa.fch.wimsey.bc.ca>
	for libssh2-devel@cool.haxx.se; Thu, 8 Dec 2011 12:52:09 -0800 (PST)
Date: Thu, 8 Dec 2011 12:52:08 -0800
From: Dan Fandrich <dan@coneharvesters.com>
To: libssh2-devel@cool.haxx.se
Subject: Re: libssh2_channel_read() blocking in case of a background process
Message-ID: <20111208205207.GA29826@coneharvesters.com>
Mail-Followup-To: libssh2-devel@cool.haxx.se
References: <CAEKYpER2CmqmDdH6M2-Xj5iq5VBP2XOxkPvXZ36vXEdmK28TcQ@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CAEKYpER2CmqmDdH6M2-Xj5iq5VBP2XOxkPvXZ36vXEdmK28TcQ@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="iso-8859-1"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by giant.haxx.se id pB8KqFsZ026156

On Thu, Dec 08, 2011 at 02:07:32PM +0530, anirudh nair wrote:
> Hi all,
> 
> I need to execute a remote script as below
> 
> //script begins- only psuedo_code
> 
> some_process &(as a background process)
> if (some_process is up)
> echo "Application is running"
> exit 1
> else
> echo "Application not started"
> exit 2
> endif
> 
> //script ends
> 
> 
> But I see that  libssh2_channel_read() blocks while waiting for some_process to
> return.

You're requesting data to be read, so, naturally, it can't return until it
comes in.

> But If I make it non blocking i.e
> libssh2_session_set_blocking(session, 0);

If it's made nonblocking, then libssh2_channel_read() is just going to
return LIBSSH2_ERROR_EAGAIN until data does come in. If your program doesn't
explicitly poll to wait for a response from the server, then there's no way
to know what that remote script is doing.

> the below code always returns 0
> nReturnCode = libssh2_channel_get_exit_status( channel );
>
> Ideally I want the read not to block and at the same time return the correct
> return code i.e 1

I don't understand what you want here. It sounds like you magically want to
know what the return code of the process is going to be without waiting for
that process to run and the response to be returned.

> Hope my problem statement is clear.

Not unless it involves breaking the laws of physics. Are you just trying to
get some work done in the program while the remote script is running?  i.e.
rather than blocking while waiting for the response, you want to do something
else while waiting?  If that's what you want, then you should set the session
to nonblocking then keep calling libssh2_channel_read() until it stops
returning LIBSSH2_ERROR_EAGAIN, interleaving those calls with whatever else
you're trying to do.

>>> Dan
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Dec  9 09:42:07 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB98fd6J028513;
	Fri, 9 Dec 2011 09:42:02 +0100
Received: from mail-gy0-f182.google.com (mail-gy0-f182.google.com
	[209.85.160.182])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB98fbIH028301
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 09:41:37 +0100
Received: by ghbg20 with SMTP id g20so2417131ghb.41
	for <libssh2-devel@cool.haxx.se>; Fri, 09 Dec 2011 00:41:31 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:in-reply-to:references:date:message-id:subject:from:to
	:content-type; bh=bxEm3sbmmvz7UlfRgCNdM8oquqVwrb03MQUA8A4jPX0=;
	b=bRd8x+s82sbeyUse+jNAFa6N6wZejXXfbk23jwPD7xJPmhwdxNWZPxVaL9cFjYlDYC
	hhc5VBo8+UlGEnlomS0UzkjmARaUupFp5mzMXaP+vKcuxS4mrHd+qv1wIIXXWaD/x+Ak
	1blU1Aw6d72IA5Ls+esS5jeCK8gosDGlRTLlo=
MIME-Version: 1.0
Received: by 10.236.192.233 with SMTP id i69mr9980441yhn.60.1323420091663;
	Fri, 09 Dec 2011 00:41:31 -0800 (PST)
Received: by 10.236.189.2 with HTTP; Fri, 9 Dec 2011 00:41:31 -0800 (PST)
In-Reply-To: <20111208205207.GA29826@coneharvesters.com>
References: <CAEKYpER2CmqmDdH6M2-Xj5iq5VBP2XOxkPvXZ36vXEdmK28TcQ@mail.gmail.com>
	<20111208205207.GA29826@coneharvesters.com>
Date: Fri, 9 Dec 2011 14:11:31 +0530
Message-ID: <CAEKYpETNttBP9Q0vPgM4ccch9paxOW-Ube31gxzGsYT0Y42zbw@mail.gmail.com>
Subject: Re: libssh2_channel_read() blocking in case of a background process
From: anirudh nair <anirudh.anu01@gmail.com>
To: libssh2 development <libssh2-devel@cool.haxx.se>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1290548521=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============1290548521==
Content-Type: multipart/alternative; boundary=20cf3056431f73c51e04b3a4c08d

--20cf3056431f73c51e04b3a4c08d
Content-Type: text/plain; charset=ISO-8859-1

Hi Dan,

Thanks a lot for the reply.


> I need to execute a remote script as below
> >
> > //script begins- only psuedo_code
> >
> > some_process &(as a background process)
> > if (some_process is up)
> > echo "Application is running"
> > exit 1
> > else
> > echo "Application not started"
> > exit 2
> > endif
> >
> > //script ends
> >
> >
> > But I see that  libssh2_channel_read() blocks while waiting for
> some_process to
> > return.
>
> You're requesting data to be read, so, naturally, it can't return until it
> comes in.
>

 My only question is why is does libssh2_channel_read() wait even though
the script has returned?
 The primary goal of the  script is to start an application(service) and to
return the status of the startup.
 The script checks if the application is up by greping through the output
of ps and finally return the status.




>
> > But If I make it non blocking i.e
> > libssh2_session_set_blocking(session, 0);
>
> If it's made nonblocking, then libssh2_channel_read() is just going to
> return LIBSSH2_ERROR_EAGAIN until data does come in. If your program
> doesn't
> explicitly poll to wait for a response from the server, then there's no way
> to know what that remote script is doing.
>
> > the below code always returns 0
> > nReturnCode = libssh2_channel_get_exit_status( channel );
> >
> > Ideally I want the read not to block and at the same time return the
> correct
> > return code i.e 1
>
> I don't understand what you want here. It sounds like you magically want to
> know what the return code of the process is going to be without waiting for
> that process to run and the response to be returned.
>

As I said, I'm expecting the return code of the script and not that of the
process.



> > Hope my problem statement is clear.
>
> Not unless it involves breaking the laws of physics. Are you just trying to
> get some work done in the program while the remote script is running?  i.e.
> rather than blocking while waiting for the response, you want to do
> something
> else while waiting?  If that's what you want, then you should set the
> session
> to nonblocking then keep calling libssh2_channel_read() until it stops
> returning LIBSSH2_ERROR_EAGAIN, interleaving those calls with whatever else
> you're trying to do.
>
> >>> Dan
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
>

--20cf3056431f73c51e04b3a4c08d
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Dan,<br><br>Thanks a lot for the reply.<div><br></div><div><br><div clas=
s=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class=3D"im">
&gt; I need to execute a remote script as below<br>
&gt;<br>
&gt; //script begins- only psuedo_code<br>
&gt;<br>
&gt; some_process &amp;(as a background process)<br>
&gt; if (some_process=A0is up)<br>
&gt; echo &quot;Application is running&quot;<br>
&gt; exit 1<br>
&gt; else<br>
&gt; echo &quot;Application not started&quot;<br>
&gt; exit 2<br>
&gt; endif<br>
&gt;<br>
&gt; //script ends<br>
&gt;<br>
&gt;<br>
&gt; But I see that =A0libssh2_channel_read() blocks while waiting for some=
_process to<br>
&gt; return.<br>
<br>
</div>You&#39;re requesting data to be read, so, naturally, it can&#39;t re=
turn until it<br>
comes in.<br></blockquote><div><br></div><div>=A0My only question is why is=
 does=A0libssh2_channel_read() wait even though the script has returned?</d=
iv><div>=A0The primary goal of the =A0script is to start an application(ser=
vice) and to return the status of the startup.</div>
<div>=A0The script checks if the application is up by greping through the o=
utput of ps and finally return the status.</div><div><br></div><div><br></d=
iv><div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class=3D"im"><br>
&gt; But If I make it non blocking i.e<br>
&gt; libssh2_session_set_blocking(session, 0);<br>
<br>
</div>If it&#39;s made nonblocking, then libssh2_channel_read() is just goi=
ng to<br>
return LIBSSH2_ERROR_EAGAIN until data does come in. If your program doesn&=
#39;t<br>
explicitly poll to wait for a response from the server, then there&#39;s no=
 way<br>
to know what that remote script is doing.<br>
<div class=3D"im"><br>
&gt; the below code always returns 0<br>
&gt; nReturnCode =3D libssh2_channel_get_exit_status( channel );<br>
&gt;<br>
&gt; Ideally I want the read not to block and at the same time return the c=
orrect<br>
&gt; return code i.e 1<br>
<br>
</div>I don&#39;t understand what you want here. It sounds like you magical=
ly want to<br>
know what the return code of the process is going to be without waiting for=
<br>
that process to run and the response to be returned.<br></blockquote><div><=
br></div><div>As I said, I&#39;m expecting the return code of the script an=
d not that of the process.=A0</div><div><br></div><div><br></div><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex;">

<div class=3D"im"><br>
&gt; Hope my problem statement is clear.<br>
<br>
</div>Not unless it involves breaking the laws of physics. Are you just try=
ing to<br>
get some work done in the program while the remote script is running? =A0i.=
e.<br>
rather than blocking while waiting for the response, you want to do somethi=
ng<br>
else while waiting? =A0If that&#39;s what you want, then you should set the=
 session<br>
to nonblocking then keep calling libssh2_channel_read() until it stops<br>
returning LIBSSH2_ERROR_EAGAIN, interleaving those calls with whatever else=
<br>
you&#39;re trying to do.<br>
<br>
&gt;&gt;&gt; Dan<br>
_______________________________________________<br>
libssh2-devel <a href=3D"http://cool.haxx.se/cgi-bin/mailman/listinfo/libss=
h2-devel" target=3D"_blank">http://cool.haxx.se/cgi-bin/mailman/listinfo/li=
bssh2-devel</a><br>
</blockquote></div><br></div>

--20cf3056431f73c51e04b3a4c08d--

--===============1290548521==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1290548521==--

From libssh2-devel-bounces@cool.haxx.se  Fri Dec  9 10:38:19 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB99cAbj001596;
	Fri, 9 Dec 2011 10:38:18 +0100
Received: from zeus.promailserver.com (zeus.promailserver.com [74.200.236.204])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB99c89u001558
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 10:38:09 +0100
Received: from Pippin ([86.212.194.8])
	by zeus.promailserver.com (Merak 8.3.6) with ASMTP id SVV37403
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 09:38:03 -0000
Message-ID: <A7A756DF47FD4772983F44532D3782E6@Pippin>
From: =?UTF-8?Q?Elli=C3=A9_Computing_Open_Source_Prog?=
	=?UTF-8?Q?ram?= <opensource@elliecomputing.com>
To: "libssh2 development" <libssh2-devel@cool.haxx.se>
References: <91EB79A7A2B84C41A12E4F0BB94A75E7@Pippin>
	<1323376188.24330.22.camel@henriknordstrom.net>
In-Reply-To: <1323376188.24330.22.camel@henriknordstrom.net>
Subject: Re: is libssh2_agent_userauth blocking?
Date: Fri, 9 Dec 2011 10:38:07 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Mailer: Microsoft Windows Live Mail 15.4.3538.513
X-MimeOLE: Produced By Microsoft MimeOLE V15.4.3538.513
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pB99cAbj001596

>From: HenrikNordstrÃ¶m
>tor 2011-12-08 klockan 17:19 +0100 skrev ElliÃ© Computing Open Source
>Program:
>
>> In order to work correctly, libcurl requires all the API to be non
>> blocking or at least to have some short bounded time, however I
>> suspect that libssh2_agent_??? APIs may have no bounded time (if the
>> user gets a password box).
>
>Not sure, but probably not supported (yet).
>
>agent_transact_unix looks like there is some kind of support for
>optimistic non-blocking mode, but it also looks like there is nothing
>that actually sets the agent connection non-blocking.
>
>agent_transact_pageant (windows) do not look like it's prepared for
>non-blocking use at all.

from what I could read putty/futty sources codes, there is no way to make 
SendMessage non blocking, using a win32 thread could do the job.

I am not terribly in a hurry on that subject, any idea if it might be 
implemented sooner or later?

Best regards
Armel

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Dec  9 10:45:43 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB99jZK2010513;
	Fri, 9 Dec 2011 10:45:42 +0100
Received: from vps1.henriknordstrom.net (vps1.henriknordstrom.net
	[IPv6:2a02:750:7::d0a])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB99jYrt010507
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 10:45:34 +0100
Received: from henriknordstrom.net (183.159.216.81.static.tb.siw.siwnet.net
	[81.216.159.183])
	by vps1.henriknordstrom.net (8.14.2/8.14.2/Debian-2build1) with ESMTP
	id pB99jZF6011561
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 09:45:35 GMT
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by henriknordstrom.net (8.12.11.20060308/8.12.8) with ESMTP id
	pB99jXD6017237
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 10:45:33 +0100
Message-ID: <1323423933.10108.7.camel@henriknordstrom.net>
Subject: Re: libssh2_channel_read() blocking in case of a background process
From: Henrik =?ISO-8859-1?Q?Nordstr=F6m?= <henrik@henriknordstrom.net>
To: libssh2 development <libssh2-devel@cool.haxx.se>
Date: Fri, 09 Dec 2011 10:45:33 +0100
In-Reply-To: <CAEKYpETNttBP9Q0vPgM4ccch9paxOW-Ube31gxzGsYT0Y42zbw@mail.gmail.com>
References: <CAEKYpER2CmqmDdH6M2-Xj5iq5VBP2XOxkPvXZ36vXEdmK28TcQ@mail.gmail.com>
	<20111208205207.GA29826@coneharvesters.com>
	<CAEKYpETNttBP9Q0vPgM4ccch9paxOW-Ube31gxzGsYT0Y42zbw@mail.gmail.com>
X-Mailer: Evolution 3.2.2 (3.2.2-1.fc16) 
Mime-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0
	(vps1.henriknordstrom.net [195.20.207.177]);
	Fri, 09 Dec 2011 09:45:35 +0000 (UTC)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

fre 2011-12-09 klockan 14:11 +0530 skrev anirudh nair:


>  My only question is why is does libssh2_channel_read() wait even
> though the script has returned?

Did you see my response earlier?

The server only closes the channel when it is no longer in use. Your
background started application keeps the channel open as it's attached
to stdin/stdout/stderr of the application.

You need to adjust how you start the background application to make sure
to detach it from stdin/stdout/stderr.

   some_program </dev/null >/dev/null 2>&1 &


Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Dec  9 10:50:21 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB99oHSN012869;
	Fri, 9 Dec 2011 10:50:21 +0100
Received: from vps1.henriknordstrom.net (vps1.henriknordstrom.net
	[IPv6:2a02:750:7::d0a])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB99oHOs012856
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 10:50:17 +0100
Received: from henriknordstrom.net (183.159.216.81.static.tb.siw.siwnet.net
	[81.216.159.183])
	by vps1.henriknordstrom.net (8.14.2/8.14.2/Debian-2build1) with ESMTP
	id pB99oHii024172
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 09:50:17 GMT
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by henriknordstrom.net (8.12.11.20060308/8.12.8) with ESMTP id
	pB99oFUw017591
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 10:50:15 +0100
Message-ID: <1323424215.10108.8.camel@henriknordstrom.net>
Subject: Re: is libssh2_agent_userauth blocking?
From: Henrik =?ISO-8859-1?Q?Nordstr=F6m?= <henrik@henriknordstrom.net>
To: libssh2-devel@cool.haxx.se
Date: Fri, 09 Dec 2011 10:50:15 +0100
In-Reply-To: <A7A756DF47FD4772983F44532D3782E6@Pippin>
References: <91EB79A7A2B84C41A12E4F0BB94A75E7@Pippin>
	<1323376188.24330.22.camel@henriknordstrom.net>
	<A7A756DF47FD4772983F44532D3782E6@Pippin>
X-Mailer: Evolution 3.2.2 (3.2.2-1.fc16) 
Mime-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0
	(vps1.henriknordstrom.net [195.20.207.177]);
	Fri, 09 Dec 2011 09:50:18 +0000 (UTC)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pB99oHSN012869

fre 2011-12-09 klockan 10:38 +0100 skrev ElliÃ© Computing Open Source
Program:

> from what I could read putty/futty sources codes, there is no way to make 
> SendMessage non blocking, using a win32 thread could do the job.
> 
> I am not terribly in a hurry on that subject, any idea if it might be 
> implemented sooner or later?

later unless you or someone else who needs it finds a way of doing it.

Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Dec  9 14:11:26 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB9DAcwJ013041;
	Fri, 9 Dec 2011 14:11:21 +0100
Received: from giant.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pB9DAbvK013037
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 14:10:37 +0100
Received: from localhost (dast@localhost)
	by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id pB9DAbtW013033
	for <libssh2-devel@cool.haxx.se>; Fri, 9 Dec 2011 14:10:37 +0100
X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs
Date: Fri, 9 Dec 2011 14:10:37 +0100 (CET)
From: Daniel Stenberg <daniel@haxx.se>
X-X-Sender: dast@giant.haxx.se
To: libssh2 development <libssh2-devel@cool.haxx.se>
Subject: Re: cannot execute cmd at cisco pix
In-Reply-To: <4be71adc.1a71b.1341cf8aa86.Coremail.shengqi158@163.com>
Message-ID: <alpine.DEB.2.00.1112091407520.31790@tvnag.unkk.fr>
References: <4be71adc.1a71b.1341cf8aa86.Coremail.shengqi158@163.com>
User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
X-fromdanielhimself: yes
MIME-Version: 1.0
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

On Thu, 8 Dec 2011, shengqi158 wrote:

> hello folks,
> OS: ubuntu 10.10
> libssh2 version :1.3.0
> remote host'os : cisco pix

> libssh2_channel_read returned -37

That's just EAGAIN and not interesting.

> libssh2_channel_read returned -43

This is LIBSSH2_ERROR_SOCKET_RECV but doesn't say a lot on its own. Can you 
enable debug/trace and see if all the extra info reveals something?

> by the way, I can use the example code ssh2 to login the remote host.

Yes, that example logs in and runs a command on a host.

-- 

  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sat Dec 10 05:37:18 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBA4ax9t004797;
	Sat, 10 Dec 2011 05:37:14 +0100
Received: from m13-83.163.com (m13-83.163.com [220.181.13.83])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBA4amrk004737
	for <libssh2-devel@cool.haxx.se>; Sat, 10 Dec 2011 05:36:52 +0100
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;
	s=s110527; h=Received:Date:From:To:Message-ID:In-Reply-To:
	References:Subject:MIME-Version:Content-Type; bh=85vM5DT2ftNAk7w
	9M9MRqowM9HpSsVmQ+kmoAoP0cYU=; b=P2EhJAar3Y7PZMBg+XCS/cZfN8KBWWM
	tVgNhl8xD5bIraS0e0RuoaBvdsxTM+TGd/Dp+bwQ1DJ2NlFgayVDJGfe44k11EPU
	p6HfFJ3K4VIjfIpC6q4I4S4BbROjDuXiXzFJ3+PJTbIH91cYnmOyMnrFD8yJconE
	hN/8iUNgRdOs=
Received: from shengqi158 ( [118.186.207.97] ) by ajax-webmail-wmsvr83
	(Coremail) ; Sat, 10 Dec 2011 12:36:03 +0800 (CST)
Date: Sat, 10 Dec 2011 12:36:03 +0800 (CST)
From: shengqi158  <shengqi158@163.com>
To: "libssh2 development" <libssh2-devel@cool.haxx.se>
Message-ID: <13857f6a.11a28.1342641a47f.Coremail.shengqi158@163.com>
In-Reply-To: <alpine.DEB.2.00.1112091407520.31790@tvnag.unkk.fr>
References: <alpine.DEB.2.00.1112091407520.31790@tvnag.unkk.fr>
	<4be71adc.1a71b.1341cf8aa86.Coremail.shengqi158@163.com>
Subject: Re:Re: cannot execute cmd at cisco pix
MIME-Version: 1.0
X-Originating-IP: [118.186.207.97]
X-Priority: 3
X-Mailer: Coremail Webmail Server Version SP_ntes V3.5 build
	111110(15680.4167.4075) Copyright (c) 2002-2011 www.mailtech.cn 163com
X-CM-CTRLDATA: P+035mZvb3Rlcl9odG09MTkxNzo4MQ==
X-CM-TRANSID: U8GowECp_0LV4eJOlXcXAA--.1083W
X-CM-SenderInfo: xvkh0wltlrkmi6rwjhhfrp/1tbiLw0SLklyv2R6IAABsl
X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============2118452488=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============2118452488==
Content-Type: multipart/alternative; 
	boundary="----=_Part_261829_347115508.1323491763327"

------=_Part_261829_347115508.1323491763327
Content-Type: text/plain; charset=GBK
Content-Transfer-Encoding: 7bit




Thanks for your reply.
In my tests,I found a funny thing thing. When I use the example code ssh2_exec to login the remote pix host,the pix's terminal is still exist and I can input other command likes "enable","show version" and so.However,when I use the example code ssh2_exec to login other host(not pix system), the remote host's terminal disappeared.So I think the pix's implemention of ssh2's channel is different from standard ssh2's channel.
At 2011-12-09 21:10:37,"Daniel Stenberg" <daniel@haxx.se> wrote:
>On Thu, 8 Dec 2011, shengqi158 wrote:
>
>> hello folks,
>> OS: ubuntu 10.10
>> libssh2 version :1.3.0
>> remote host'os : cisco pix
>
>> libssh2_channel_read returned -37
>
>That's just EAGAIN and not interesting.
>
>> libssh2_channel_read returned -43
>
>This is LIBSSH2_ERROR_SOCKET_RECV but doesn't say a lot on its own. Can you 
>enable debug/trace and see if all the extra info reveals something?
>
>> by the way, I can use the example code ssh2 to login the remote host.
>
>Yes, that example logs in and runs a command on a host.
>
>-- 
>
>  / daniel.haxx.se
>_______________________________________________
>libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

------=_Part_261829_347115508.1323491763327
Content-Type: text/html; charset=GBK
Content-Transfer-Encoding: 7bit

<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><br><br><div></div><div id="divNeteaseMailCard"></div>Thanks for your reply.<div>In my tests,I found a funny thing thing. When I use the example code ssh2_exec to login the remote pix host,the pix's terminal is still exist and I can input other command likes "enable","show version" and so.However,when I use the example code ssh2_exec to login other host(not pix system), the remote host's terminal disappeared.So I think the pix's implemention of ssh2's channel is different from standard ssh2's channel.<div><pre>At&nbsp;2011-12-09&nbsp;21:10:37,"Daniel&nbsp;Stenberg"&nbsp;&lt;daniel@haxx.se&gt;&nbsp;wrote:
&gt;On&nbsp;Thu,&nbsp;8&nbsp;Dec&nbsp;2011,&nbsp;shengqi158&nbsp;wrote:
&gt;
&gt;&gt;&nbsp;hello&nbsp;folks,
&gt;&gt;&nbsp;OS:&nbsp;ubuntu&nbsp;10.10
&gt;&gt;&nbsp;libssh2&nbsp;version&nbsp;:1.3.0
&gt;&gt;&nbsp;remote&nbsp;host'os&nbsp;:&nbsp;cisco&nbsp;pix
&gt;
&gt;&gt;&nbsp;libssh2_channel_read&nbsp;returned&nbsp;-37
&gt;
&gt;That's&nbsp;just&nbsp;EAGAIN&nbsp;and&nbsp;not&nbsp;interesting.
&gt;
&gt;&gt;&nbsp;libssh2_channel_read&nbsp;returned&nbsp;-43
&gt;
&gt;This&nbsp;is&nbsp;LIBSSH2_ERROR_SOCKET_RECV&nbsp;but&nbsp;doesn't&nbsp;say&nbsp;a&nbsp;lot&nbsp;on&nbsp;its&nbsp;own.&nbsp;Can&nbsp;you&nbsp;
&gt;enable&nbsp;debug/trace&nbsp;and&nbsp;see&nbsp;if&nbsp;all&nbsp;the&nbsp;extra&nbsp;info&nbsp;reveals&nbsp;something?
&gt;
&gt;&gt;&nbsp;by&nbsp;the&nbsp;way,&nbsp;I&nbsp;can&nbsp;use&nbsp;the&nbsp;example&nbsp;code&nbsp;ssh2&nbsp;to&nbsp;login&nbsp;the&nbsp;remote&nbsp;host.
&gt;
&gt;Yes,&nbsp;that&nbsp;example&nbsp;logs&nbsp;in&nbsp;and&nbsp;runs&nbsp;a&nbsp;command&nbsp;on&nbsp;a&nbsp;host.
&gt;
&gt;--&nbsp;
&gt;
&gt;&nbsp;&nbsp;/&nbsp;daniel.haxx.se
&gt;_______________________________________________
&gt;libssh2-devel&nbsp;http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
</pre></div></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>
------=_Part_261829_347115508.1323491763327--


--===============2118452488==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============2118452488==--

From libssh2-devel-bounces@cool.haxx.se  Sat Dec 10 09:26:13 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBA8Pfqo002822;
	Sat, 10 Dec 2011 09:26:10 +0100
Received: from foo.stuge.se (qmailr@foo.stuge.se [212.116.89.98])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with SMTP id pBA8Pdif002812
	for <libssh2-devel@cool.haxx.se>; Sat, 10 Dec 2011 09:25:39 +0100
Received: (qmail 18546 invoked by uid 501); 10 Dec 2011 08:25:39 -0000
Message-ID: <20111210082539.18545.qmail@stuge.se>
Date: Sat, 10 Dec 2011 09:25:39 +0100
From: Peter Stuge <peter@stuge.se>
To: libssh2-devel@cool.haxx.se
Subject: Re: cannot execute cmd at cisco pix
Mail-Followup-To: libssh2-devel@cool.haxx.se
References: <alpine.DEB.2.00.1112091407520.31790@tvnag.unkk.fr>
	<4be71adc.1a71b.1341cf8aa86.Coremail.shengqi158@163.com>
	<13857f6a.11a28.1342641a47f.Coremail.shengqi158@163.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <13857f6a.11a28.1342641a47f.Coremail.shengqi158@163.com>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

shengqi158 wrote:
> When I use the example code ssh2_exec to login the remote pix host,
> the pix's terminal is still exist and I can input other command
> likes "enable","show version" and so. However,when I use the
> example code ssh2_exec to login other host(not pix system), the
> remote host's terminal disappeared. So I think the pix's
> implemention of ssh2's channel is different from standard ssh2's
> channel.

No. All problems you are experiencing with the ssh2_exec.c example
are because the file is a simple example with the purpose of
demonstrating how to use libssh2.

In particular, ssh2_exec.c is NOT a terminal emulator, so it is
impossible to use it successfully when a terminal emulator is
expected, such as with all interactive CLIs which use SSH.

libssh2 has nothing to do with terminals and terminal emulation. If
you need those features then you must combine libssh2 with software
which will provide them. libssh2 only handles the lowlevel SSH
protocol itself and is not concerned about what data is transferred
in the session.

I recommend reading the SSH RFCs. They are short and readable. Please
see http://trac.libssh2.org/wiki/FAQ#WhatistheSSH-2protocol


//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Tue Dec 13 23:02:37 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBDM1w2E026188;
	Tue, 13 Dec 2011 23:02:30 +0100
Received: from na3sys009aog123.obsmtp.com (na3sys009aog123.obsmtp.com
	[74.125.149.149])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with SMTP id pBDM1t8P026068
	for <libssh2-devel@cool.haxx.se>; Tue, 13 Dec 2011 23:01:55 +0100
Received: from mail-fx0-f43.google.com ([209.85.161.43]) (using TLSv1) by
	na3sys009aob123.postini.com ([74.125.148.12]) with SMTP
	ID DSNKTufLUyHhTKh0g+7RCiC410mOdVET/G25@postini.com;
	Tue, 13 Dec 2011 14:01:57 PST
Received: by mail-fx0-f43.google.com with SMTP id p21so882972faa.2
	for <libssh2-devel@cool.haxx.se>; Tue, 13 Dec 2011 14:01:55 -0800 (PST)
MIME-Version: 1.0
Received: by 10.180.88.66 with SMTP id be2mr477226wib.54.1323813714932; Tue,
	13 Dec 2011 14:01:54 -0800 (PST)
Received: by 10.180.96.129 with HTTP; Tue, 13 Dec 2011 14:01:54 -0800 (PST)
Date: Tue, 13 Dec 2011 17:01:54 -0500
Message-ID: <CAG-Za1NaJ7anUr2UHWNyRTbCYde_HEnfOZKm0egyUe_gutHUoQ@mail.gmail.com>
Subject: libssh2_sftp_stat_ex returns zero filesize
From: Dan Hayes <dhayes@capmarktech.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============0747513950=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============0747513950==
Content-Type: multipart/alternative; boundary=f46d04428f2c3a349804b4006694

--f46d04428f2c3a349804b4006694
Content-Type: text/plain; charset=ISO-8859-1

I am using the most recent version of libssh2 and am having a problem
trying to retrieve the file size of a remote file via the
libssh2_sftp_stat_ex function.  I can successfully read the file using the
sftp.c example program; however, when I attempt to retrieve the file stats
I receive a file size of zero in the LIBSSH2_SFTP_ATTRIBUTES argument.  The
return code from the libssh2_sftp_stat_ex function indicates success.

The remote server I am hitting is running SFTP version 3.  I am running
libssh2 on ubuntu maverick.

Any insight would be most appreciated.

--f46d04428f2c3a349804b4006694
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I am using the most recent version of libssh2 and am having a problem tryin=
g to retrieve the file size of a remote file via the libssh2_sftp_stat_ex f=
unction.=A0 I can successfully read the file using the sftp.c example progr=
am; however, when I attempt to retrieve the file stats I receive a file siz=
e of zero in the LIBSSH2_SFTP_ATTRIBUTES argument.=A0 The return code from =
the libssh2_sftp_stat_ex function indicates success.<br>
<br>The remote server I am hitting is running SFTP version 3.=A0 I am runni=
ng libssh2 on ubuntu maverick.<br><br>Any insight would be most appreciated=
.<br>

--f46d04428f2c3a349804b4006694--

--===============0747513950==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============0747513950==--

From libssh2-devel-bounces@cool.haxx.se  Wed Dec 14 00:50:12 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBDNnv3X018870;
	Wed, 14 Dec 2011 00:50:09 +0100
Received: from giant.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBDNntwI018861
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Wed, 14 Dec 2011 00:49:55 +0100
Received: from localhost (dast@localhost)
	by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id pBDNnsvv018857
	for <libssh2-devel@cool.haxx.se>; Wed, 14 Dec 2011 00:49:55 +0100
X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs
Date: Wed, 14 Dec 2011 00:49:54 +0100 (CET)
From: Daniel Stenberg <daniel@haxx.se>
X-X-Sender: dast@giant.haxx.se
To: libssh2 development <libssh2-devel@cool.haxx.se>
Subject: Re: libssh2_sftp_stat_ex returns zero filesize
In-Reply-To: <CAG-Za1NaJ7anUr2UHWNyRTbCYde_HEnfOZKm0egyUe_gutHUoQ@mail.gmail.com>
Message-ID: <alpine.DEB.2.00.1112140048150.12989@tvnag.unkk.fr>
References: <CAG-Za1NaJ7anUr2UHWNyRTbCYde_HEnfOZKm0egyUe_gutHUoQ@mail.gmail.com>
User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
X-fromdanielhimself: yes
MIME-Version: 1.0
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

On Tue, 13 Dec 2011, Dan Hayes wrote:

> Any insight would be most appreciated.

Two ideas:

1 - provide trace oututs showing what the protocol is doing:

     libssh2_trace(session, ~0);

2 - provide us source code to an example that repeats the problem for you, as
     then it'll be easier for us to test and see how the same thing works for
     us!

-- 

  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Wed Dec 14 03:44:58 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBE2iViY016985;
	Wed, 14 Dec 2011 03:44:53 +0100
Received: from na3sys009aog104.obsmtp.com (na3sys009aog104.obsmtp.com
	[74.125.149.73])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with SMTP id pBE2iSH7016979
	for <libssh2-devel@cool.haxx.se>; Wed, 14 Dec 2011 03:44:29 +0100
Received: from mail-ww0-f46.google.com ([74.125.82.46]) (using TLSv1) by
	na3sys009aob104.postini.com ([74.125.148.12]) with SMTP
	ID DSNKTugNjBEhzorTjmf8EI+Yfq41zWr+0+iY@postini.com;
	Tue, 13 Dec 2011 18:44:31 PST
Received: by wgbdq10 with SMTP id dq10so483498wgb.27
	for <libssh2-devel@cool.haxx.se>; Tue, 13 Dec 2011 18:44:27 -0800 (PST)
MIME-Version: 1.0
Received: by 10.216.132.139 with SMTP id o11mr308042wei.33.1323830667024; Tue,
	13 Dec 2011 18:44:27 -0800 (PST)
Received: by 10.180.96.129 with HTTP; Tue, 13 Dec 2011 18:44:26 -0800 (PST)
In-Reply-To: <alpine.DEB.2.00.1112140048150.12989@tvnag.unkk.fr>
References: <CAG-Za1NaJ7anUr2UHWNyRTbCYde_HEnfOZKm0egyUe_gutHUoQ@mail.gmail.com>
	<alpine.DEB.2.00.1112140048150.12989@tvnag.unkk.fr>
Date: Tue, 13 Dec 2011 21:44:26 -0500
Message-ID: <CAG-Za1Nfz8DXWCgEv5JcGrw1px7AqoaOrLSJW5yVB+VwKLmJYQ@mail.gmail.com>
Subject: Re: libssh2_sftp_stat_ex returns zero filesize
From: Dan Hayes <dhayes@capmarktech.com>
To: libssh2 development <libssh2-devel@cool.haxx.se>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============0543875192=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============0543875192==
Content-Type: multipart/alternative; boundary=0016e6de0407a697e604b40458e2

--0016e6de0407a697e604b40458e2
Content-Type: text/plain; charset=ISO-8859-1

Below is the trace excerpt picking up where I successfully executed
libssh2_sftp_open() command and then issued the stat command.  You'll
notice the file name is:

/ADT00359/%25ADT00359%25ADT00359%25null%25DONE%25dmh_65l1h3006gntl7mu00027jpn

The file name has embedded % which I have expanded to their hexadecimal
representation (%25).  The program has not problem with opening this file
and successfully reading the contents.  For some reason it cannot return
the actual file size.

<-------------BEGIN EXCERPT ---------------------->
[libssh2] 1.948061 SFTP: Open command successful
libssh2_sftp_open() is done, get file information
[libssh2] 1.948083 SFTP: LStatting
/ADT00359/%25ADT00359%25ADT00359%25null%25DONE%25dmh_65l1h3006gntl7mu00027jpn
[libssh2] 1.948089 Conn: Writing 90 bytes on channel 0/0, stream #0
[libssh2] 1.948096 Conn: Sending 90 bytes on channel 0/0, stream_id=0
=> libssh2_transport_write plain (9 bytes)
0000: 5E 00 00 00 00 00 00 00  5A                      : ^.......Z
=> libssh2_transport_write plain2 (90 bytes)
0000: 00 00 00 56 07 00 00 00  01 00 00 00 4D 2F 41 44 : ...V........M/AD
0010: 54 30 30 33 35 39 2F 25  32 35 41 44 54 30 30 33 : T00359/%25ADT003
0020: 35 39 25 32 35 41 44 54  30 30 33 35 39 25 32 35 : 59%25ADT00359%25
0030: 6E 75 6C 6C 25 32 35 44  4F 4E 45 25 32 35 64 6D : null%25DONE%25dm
0040: 68 5F 36 35 6C 31 68 33  30 30 36 67 6E 74 6C 37 : h_65l1h3006gntl7
0050: 6D 75 30 30 30 32 37 6A  70 6E                   : mu00027jpn
[libssh2] 1.948284 Socket: Sent 132/132 bytes at 0x91f2600
=> libssh2_transport_write send() (132 bytes)
0000: 78 7A A1 29 B2 EB 2B 59  14 AA 64 C5 B3 5A 6F E0 : xz.)..+Y..d..Zo.
0010: 9E 08 AB BB 4B 29 E9 FE  47 55 FA 76 94 EE 26 F6 : ....K)..GU.v..&.
0020: 57 75 85 9C 91 A4 81 E6  09 C2 2F 25 0E B4 2E 9A : Wu......../%....
0030: ED 21 7B 18 19 46 24 7C  BF A5 32 0E C2 06 42 BA : .!{..F$|..2...B.
0040: 4A 7A B9 CD 9E 2A 4B E6  62 77 9D 38 1B D2 73 1E : Jz...*K.bw.8..s.
0050: 2A 78 E9 59 12 4D C4 95  34 FE 5B 05 60 CB 07 6A : *x.Y.M..4.[.`..j
0060: B7 12 91 76 E4 BA AB 8F  20 D0 C1 3A F8 1C 3A E3 : ...v.... ..:..:.
0070: 14 7E C5 F2 3D 5F 37 FD  5C 17 7B 62 92 5D D9 62 : .~..=_7.\.{b.].b
0080: 26 8F 58 D2                                      : &.X.
[libssh2] 1.948322 SFTP: recv packet
[libssh2] 1.948328 Failure Event: -37 - would block
[libssh2] 2.065154 SFTP: recv packet
[libssh2] 2.065196 Conn: channel_read() wants 4 bytes from channel 0/0
stream #0
[libssh2] 2.065228 Socket: Recved 68/16384 bytes to 0x91ee5d8+0
=> libssh2_transport_read() raw (68 bytes)
0000: 51 46 78 B8 43 3B B0 F0  1D F5 C2 1F 36 1F 98 38 : QFx.C;......6..8
0010: B1 9E 6A 11 49 07 27 D2  32 A4 6B 9B 4B DF F3 C4 : ..j.I.'.2.k.K...
0020: 29 AA B6 35 C2 81 0C 5D  E9 AE 39 68 87 35 1F AE : )..5...]..9h.5..
0030: F1 46 A5 5C 93 F5 A7 19  F9 5C CE 4A 66 60 16 CE : .F.\.....\.Jf`..
0040: B5 A6 FA 0E                                      : ....
=> libssh2_transport_read() plain (34 bytes)
0000: 5E 00 00 00 00 00 00 00  19 00 00 00 15 69 00 00 : ^............i..
0010: 00 01 00 00 00 0C 00 00  81 80 4E E8 0A 95 4E E8 : ..........N...N.
0020: 0A 95                                            : ..
[libssh2] 2.065325 Transport: Packet type 94 received, length=34
[libssh2] 2.065334 Conn: 25 bytes packet_add() for 0/0/0
[libssh2] 2.065345 Conn: channel_read() got 4 of data from 0/0/0
[libssh2] 2.065352 SFTP: Data begin - Packet Length: 21
[libssh2] 2.065360 Conn: channel_read() got 21 of data from 0/0/0 [ul]
[libssh2] 2.065367 SFTP: Received packet 105 (len 21)
Stat Data: RetCode=0
Stat Data: Size=0
Stat Data: Perm=8180
Stat Data: mtime=1323829909
Stat Data: mtime=Wed Dec 14 02:31:49 2011

libssh2_sftp_read()!

<------END EXCERPT--------------->


The interesting lines of the program (basically example/sftp.c) which are
generating this output are:

    sftp_handle =
        libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);

    if (!sftp_handle) {
        fprintf(stderr, "Unable to open file with SFTP: %ld\n",
                libssh2_sftp_last_error(sftp_session));
        goto shutdown;
    }
    fprintf(stderr, "libssh2_sftp_open() is done, get file information\n");
    LIBSSH2_SFTP_ATTRIBUTES attrs;
    rc = libssh2_sftp_stat_ex(sftp_session, sftppath, strlen(sftppath),
LIBSSH2_SFTP_LSTAT, &attrs );
    if (rc<0)
    {
        fprintf(stderr, "error trying to fstat_ex, returned %d\n", rc);
    }
    else
    {
        fprintf(stderr, "Stat Data: RetCode=%d\n", rc);
        fprintf(stderr, "Stat Data: Size=%llu\n", attrs.filesize);
        fprintf(stderr, "Stat Data: Perm=%lx\n",  attrs.permissions);
        fprintf(stderr, "Stat Data: mtime=%lu\n",  attrs.mtime);
        fprintf(stderr, "Stat Data: mtime=%s\n",
 asctime(localtime(&attrs.mtime)));
    }



On Tue, Dec 13, 2011 at 6:49 PM, Daniel Stenberg <daniel@haxx.se> wrote:

> On Tue, 13 Dec 2011, Dan Hayes wrote:
>
>  Any insight would be most appreciated.
>>
>
> Two ideas:
>
> 1 - provide trace oututs showing what the protocol is doing:
>
>    libssh2_trace(session, ~0);
>
> 2 - provide us source code to an example that repeats the problem for you,
> as
>    then it'll be easier for us to test and see how the same thing works for
>    us!
>
> --
>
>  / daniel.haxx.se
> ______________________________**_________________
> libssh2-devel http://cool.haxx.se/cgi-bin/**mailman/listinfo/libssh2-devel<http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>
>

--0016e6de0407a697e604b40458e2
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Below is the trace excerpt picking up where I successfully executed libssh2=
_sftp_open() command and then issued the stat command. =A0You&#39;ll notice=
 the file name is:<div><br></div><div>/ADT00359/%25ADT00359%25ADT00359%25nu=
ll%25DONE%25dmh_65l1h3006gntl7mu00027jpn</div>
<div><br></div><div>The file name has embedded % which I have expanded to t=
heir hexadecimal representation (%25). =A0The program has not problem with =
opening this file and successfully reading the contents. =A0For some reason=
 it cannot return the actual file size.</div>
<div><br></div><div>&lt;-------------BEGIN EXCERPT ----------------------&g=
t;</div><div><div>[libssh2] 1.948061 SFTP: Open command successful</div><di=
v>libssh2_sftp_open() is done, get file information</div><div>[libssh2] 1.9=
48083 SFTP: LStatting /ADT00359/%25ADT00359%25ADT00359%25null%25DONE%25dmh_=
65l1h3006gntl7mu00027jpn</div>
<div>[libssh2] 1.948089 Conn: Writing 90 bytes on channel 0/0, stream #0</d=
iv><div>[libssh2] 1.948096 Conn: Sending 90 bytes on channel 0/0, stream_id=
=3D0</div><div>=3D&gt; libssh2_transport_write plain (9 bytes)</div><div>00=
00: 5E 00 00 00 00 00 00 00 =A05A =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0: ^.......Z</div>
<div>=3D&gt; libssh2_transport_write plain2 (90 bytes)</div><div>0000: 00 0=
0 00 56 07 00 00 00 =A001 00 00 00 4D 2F 41 44 : ...V........M/AD</div><div=
>0010: 54 30 30 33 35 39 2F 25 =A032 35 41 44 54 30 30 33 : T00359/%25ADT00=
3</div>
<div>0020: 35 39 25 32 35 41 44 54 =A030 30 33 35 39 25 32 35 : 59%25ADT003=
59%25</div><div>0030: 6E 75 6C 6C 25 32 35 44 =A04F 4E 45 25 32 35 64 6D : =
null%25DONE%25dm</div><div>0040: 68 5F 36 35 6C 31 68 33 =A030 30 36 67 6E =
74 6C 37 : h_65l1h3006gntl7</div>
<div>0050: 6D 75 30 30 30 32 37 6A =A070 6E =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 : mu00027jpn</div><div>[libssh2] 1.948284 Socket: Sent 132/132 bytes a=
t 0x91f2600</div><div>=3D&gt; libssh2_transport_write send() (132 bytes)</d=
iv><div>0000: 78 7A A1 29 B2 EB 2B 59 =A014 AA 64 C5 B3 5A 6F E0 : xz.)..+Y=
..d..Zo.</div>
<div>0010: 9E 08 AB BB 4B 29 E9 FE =A047 55 FA 76 94 EE 26 F6 : ....K)..GU.=
v..&amp;.</div><div>0020: 57 75 85 9C 91 A4 81 E6 =A009 C2 2F 25 0E B4 2E 9=
A : Wu......../%....</div><div>0030: ED 21 7B 18 19 46 24 7C =A0BF A5 32 0E=
 C2 06 42 BA : .!{..F$|..2...B.</div>
<div>0040: 4A 7A B9 CD 9E 2A 4B E6 =A062 77 9D 38 1B D2 73 1E : Jz...*K.bw.=
8..s.</div><div>0050: 2A 78 E9 59 12 4D C4 95 =A034 FE 5B 05 60 CB 07 6A : =
*x.Y.M..4.[.`..j</div><div>0060: B7 12 91 76 E4 BA AB 8F =A020 D0 C1 3A F8 =
1C 3A E3 : ...v.... ..:..:.</div>
<div>0070: 14 7E C5 F2 3D 5F 37 FD =A05C 17 7B 62 92 5D D9 62 : .~..=3D_7.\=
.{b.].b</div><div>0080: 26 8F 58 D2 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0: &amp;.X.</div><div>[libssh2] 1.948322=
 SFTP: recv packet</div><div>[libssh2] 1.948328 Failure Event: -37 - would =
block</div>
<div>[libssh2] 2.065154 SFTP: recv packet</div><div>[libssh2] 2.065196 Conn=
: channel_read() wants 4 bytes from channel 0/0 stream #0</div><div>[libssh=
2] 2.065228 Socket: Recved 68/16384 bytes to 0x91ee5d8+0</div><div>=3D&gt; =
libssh2_transport_read() raw (68 bytes)</div>
<div>0000: 51 46 78 B8 43 3B B0 F0 =A01D F5 C2 1F 36 1F 98 38 : QFx.C;.....=
.6..8</div><div>0010: B1 9E 6A 11 49 07 27 D2 =A032 A4 6B 9B 4B DF F3 C4 : =
..j.I.&#39;.2.k.K...</div><div>0020: 29 AA B6 35 C2 81 0C 5D =A0E9 AE 39 68=
 87 35 1F AE : )..5...]..9h.5..</div>
<div>0030: F1 46 A5 5C 93 F5 A7 19 =A0F9 5C CE 4A 66 60 16 CE : .F.\.....\.=
Jf`..</div><div>0040: B5 A6 FA 0E =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0: ....</div><div>=3D&gt; libssh2_transpo=
rt_read() plain (34 bytes)</div><div>0000: 5E 00 00 00 00 00 00 00 =A019 00=
 00 00 15 69 00 00 : ^............i..</div>
<div>0010: 00 01 00 00 00 0C 00 00 =A081 80 4E E8 0A 95 4E E8 : ..........N=
...N.</div><div>0020: 0A 95 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0: ..</div><div>[libssh2] 2.065325 T=
ransport: Packet type 94 received, length=3D34</div>
<div>[libssh2] 2.065334 Conn: 25 bytes packet_add() for 0/0/0</div><div>[li=
bssh2] 2.065345 Conn: channel_read() got 4 of data from 0/0/0</div><div>[li=
bssh2] 2.065352 SFTP: Data begin - Packet Length: 21</div><div>[libssh2] 2.=
065360 Conn: channel_read() got 21 of data from 0/0/0 [ul]</div>
<div>[libssh2] 2.065367 SFTP: Received packet 105 (len 21)</div><div>Stat D=
ata: RetCode=3D0</div><div>Stat Data: Size=3D0</div><div>Stat Data: Perm=3D=
8180</div><div>Stat Data: mtime=3D1323829909</div><div>Stat Data: mtime=3DW=
ed Dec 14 02:31:49 2011</div>
<div><br></div><div>libssh2_sftp_read()!</div><div><br></div><div>&lt;-----=
-END EXCERPT---------------&gt;</div><div><br></div><div><br></div><div>The=
 interesting lines of the program (basically example/sftp.c) which are gene=
rating this output are:</div>
<div><br></div><div><div>=A0 =A0 sftp_handle =3D</div><div>=A0 =A0 =A0 =A0 =
libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);</div><div><=
br></div><div>=A0 =A0 if (!sftp_handle) {</div><div>=A0 =A0 =A0 =A0 fprintf=
(stderr, &quot;Unable to open file with SFTP: %ld\n&quot;,</div>
<div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 libssh2_sftp_last_error(sftp_session))=
;</div><div>=A0 =A0 =A0 =A0 goto shutdown;</div><div>=A0 =A0 }</div><div>=
=A0 =A0 fprintf(stderr, &quot;libssh2_sftp_open() is done, get file informa=
tion\n&quot;);</div><div>=A0 =A0 LIBSSH2_SFTP_ATTRIBUTES attrs;</div>
<div>=A0 =A0 rc =3D libssh2_sftp_stat_ex(sftp_session, sftppath, strlen(sft=
ppath), LIBSSH2_SFTP_LSTAT, &amp;attrs );</div><div>=A0 =A0 if (rc&lt;0)</d=
iv><div>=A0 =A0 {</div><div>=A0 =A0 =A0 =A0 fprintf(stderr, &quot;error try=
ing to fstat_ex, returned %d\n&quot;, rc);</div>
<div>=A0 =A0 }</div><div>=A0 =A0 else</div><div>=A0 =A0 {</div><div>=A0 =A0=
 =A0 =A0 fprintf(stderr, &quot;Stat Data: RetCode=3D%d\n&quot;, rc);</div><=
div>=A0 =A0 =A0 =A0 fprintf(stderr, &quot;Stat Data: Size=3D%llu\n&quot;, a=
ttrs.filesize);</div><div>=A0 =A0 =A0 =A0 fprintf(stderr, &quot;Stat Data: =
Perm=3D%lx\n&quot;, =A0attrs.permissions);</div>
<div>=A0 =A0 =A0 =A0 fprintf(stderr, &quot;Stat Data: mtime=3D%lu\n&quot;, =
=A0attrs.mtime);</div><div>=A0 =A0 =A0 =A0 fprintf(stderr, &quot;Stat Data:=
 mtime=3D%s\n&quot;, =A0asctime(localtime(&amp;attrs.mtime)));</div><div>=
=A0 =A0 }</div><div><br></div>
</div><div><br></div><br><div class=3D"gmail_quote">On Tue, Dec 13, 2011 at=
 6:49 PM, Daniel Stenberg <span dir=3D"ltr">&lt;<a href=3D"mailto:daniel@ha=
xx.se">daniel@haxx.se</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x">
<div class=3D"im">On Tue, 13 Dec 2011, Dan Hayes wrote:<br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Any insight would be most appreciated.<br>
</blockquote>
<br></div>
Two ideas:<br>
<br>
1 - provide trace oututs showing what the protocol is doing:<br>
<br>
 =A0 =A0libssh2_trace(session, ~0);<br>
<br>
2 - provide us source code to an example that repeats the problem for you, =
as<br>
 =A0 =A0then it&#39;ll be easier for us to test and see how the same thing =
works for<br>
 =A0 =A0us!<br><font color=3D"#888888">
<br>
-- <br>
<br>
=A0/ <a href=3D"http://daniel.haxx.se" target=3D"_blank">daniel.haxx.se</a>=
<br>
______________________________<u></u>_________________<br>
libssh2-devel <a href=3D"http://cool.haxx.se/cgi-bin/mailman/listinfo/libss=
h2-devel" target=3D"_blank">http://cool.haxx.se/cgi-bin/<u></u>mailman/list=
info/libssh2-devel</a><br>
</font></blockquote></div><br></div>

--0016e6de0407a697e604b40458e2--

--===============0543875192==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============0543875192==--

From libssh2-devel-bounces@cool.haxx.se  Wed Dec 14 05:32:04 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBE4VlOS019966;
	Wed, 14 Dec 2011 05:32:02 +0100
Received: from foo.stuge.se (qmailr@foo.stuge.se [212.116.89.98])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with SMTP id pBE4ViLU019952
	for <libssh2-devel@cool.haxx.se>; Wed, 14 Dec 2011 05:31:44 +0100
Received: (qmail 20310 invoked by uid 501); 14 Dec 2011 04:31:44 -0000
Message-ID: <20111214043144.20309.qmail@stuge.se>
Date: Wed, 14 Dec 2011 05:31:44 +0100
From: Peter Stuge <peter@stuge.se>
To: libssh2-devel@cool.haxx.se
Subject: Re: libssh2_sftp_stat_ex returns zero filesize
Mail-Followup-To: libssh2-devel@cool.haxx.se
References: <CAG-Za1NaJ7anUr2UHWNyRTbCYde_HEnfOZKm0egyUe_gutHUoQ@mail.gmail.com>
	<alpine.DEB.2.00.1112140048150.12989@tvnag.unkk.fr>
	<CAG-Za1Nfz8DXWCgEv5JcGrw1px7AqoaOrLSJW5yVB+VwKLmJYQ@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CAG-Za1Nfz8DXWCgEv5JcGrw1px7AqoaOrLSJW5yVB+VwKLmJYQ@mail.gmail.com>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

Dan Hayes wrote:
> Below is the trace excerpt picking up where I successfully executed
> libssh2_sftp_open() command and then issued the stat command. 
> You'll notice the file name is:
> 
> /ADT00359/%25ADT00359%25ADT00359%25null%25DONE%25dmh_65l1h3006gntl7mu00027jpn
> 
> The file name has embedded % which I have expanded to their
> hexadecimal representation (%25).

Why?


> <-------------BEGIN EXCERPT ---------------------->
> [libssh2] 1.948061 SFTP: Open command successful

Please do not ever send abbreivated logs. You have excluded parts
that are interesting and important for diagnosing the problem.


> The interesting lines of the program (basically example/sftp.c) which
> are generating this output are:

Again, this is not an example that anyone else can test. Please make
a minimal program which demonstrates the problem, and share it in
it's entirety, to allow others to reproduce.

But - perhaps this problem is because of the server side. You said
SFTP version 3, but it would also be interesting to know what the
server software is, and on which operating system it is running.

And please do explain why you introduced URI encoding in SSH.


//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Dec 16 15:04:58 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBGE4WAB014738;
	Fri, 16 Dec 2011 15:04:52 +0100
Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com
	[209.85.215.182])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBGE4V4O014709
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 16 Dec 2011 15:04:31 +0100
Received: by eaaf13 with SMTP id f13so3819164eaa.41
	for <libssh2-devel@cool.haxx.se>; Fri, 16 Dec 2011 06:04:27 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=hq5LqRHu0NiBUMki4jkY0ZG48j00vwJe1/Ca7yxve0Q=;
	b=IBW8oNi7zzgPPCUzEEdsAjyy1QvcoKQnCWtFIEmZlmErpG7PzZoPQNsp5OVW2AQdqZ
	QGyLJp+xEGuPQEeczMpmJQOx8XK7DDkeAkPvwJojJtKlUjV7KV/Gtw2Tm8R5KlGBko3s
	kDKMXABLgEyWhc2LfpAWFshwIP3VqtheyUtCY=
MIME-Version: 1.0
Received: by 10.205.139.76 with SMTP id iv12mr3009621bkc.100.1324044267323;
	Fri, 16 Dec 2011 06:04:27 -0800 (PST)
Received: by 10.204.37.144 with HTTP; Fri, 16 Dec 2011 06:04:27 -0800 (PST)
Date: Fri, 16 Dec 2011 22:04:27 +0800
Message-ID: <CAC11QN88WndByuArT+ZivrKR1_r0yvOOg80HO0FaNvvZU4NMXA@mail.gmail.com>
Subject: core dump when calling libssh2_session_disconnect when sftp server
	timeout
From: Ahmad Zaidee Abu <zaideeabu@gmail.com>
To: libssh2-devel@cool.haxx.se
Content-Type: multipart/mixed; boundary=0015173fe6b23881e704b43614da
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--0015173fe6b23881e704b43614da
Content-Type: multipart/alternative; boundary=0015173fe6b23881e104b43614d8

--0015173fe6b23881e104b43614d8
Content-Type: text/plain; charset=ISO-8859-1

Hi expert,

We have a daemon application on HP-UX 11iv3 which uses libssh2 to connect
to sftp server for file transfer.
The application works well with cc: HP C/aC++ B3910B A.06.20 but core dump
due to SIGPIPE error when compiled with another machine with cc: HP C/aC++
B3910B A.06.25.

From stack trace, the problem seems to be due to libssh2_session_disconnect
which eventually called libc read() function which is causing SIGPIPE and
core dump.

The scenario is as below:

1. Client create an sftp connection to sftp-server with idle timeout set.
2. During idle time, sftp server disconnect the connection.
3. When client has file to send, it check connection and reconnect if
connection already gone (by checking handle with opendir() ).
4. Prior to reconnect, it will need to clean up existing connection and
part of it is calling the libssh2_session_disconnect which then causing
SIGPIPE error.

This can be reproduce by using libssh2 example code with a bit of change to
wait for timeout (also attached here):
In this case, I set my sftpserver to timeout within 30sec idle time.

int main()
{

// initialization and so on...
. . .

// server timeout set to 30 sec.
fprintf(stderr, "Wait 60 sec for server timeout\n");
sleep(60);


    fprintf(stderr, "libssh2_sftp_open()!\n");
    /* Request a file via SFTP */
    sftp_handle =
        libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);

    if (!sftp_handle) {
        fprintf(stderr, "Unable to open file with SFTP\n");
        goto check_status;
    }
    fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
    do {
        char mem[1024];

        /* loop until we fail */
        fprintf(stderr, "libssh2_sftp_read()!\n");
        rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
        if (rc > 0) {
            write(1, mem, rc);
        } else {
            break;
        }
    } while (1);

check_status:
fprintf(stderr, "Check SFTP conn status\n");
connection_status(sock);

fprintf(stderr, "Shutting down sftp_session...\n");

    libssh2_sftp_shutdown(sftp_session);

  shutdown:

fprintf(stderr, "Session disconect...\n");
    libssh2_session_disconnect(session, "Normal Shutdown, Thank you for
playing");

fprintf(stderr, "Session free...\n");
    libssh2_session_free(session);

. . .

==============================

The result is:
libssh2_sftp_read()!
Wait 60 sec for server timeout
libssh2_sftp_opendir()!
Unable to open dir "." with SFTP
Check SFTP conn status
Connection seems to be alive (fcntl: 0), continuing check..Connection is
lost (recv -1, 232, Connection reset by peer)Shutting down sftp_session...
Session disconect...
test_sftp> $

** There's no "Session free" test as it core dump.

gdb output:
---------------
Program received signal SIGPIPE, Broken pipe
  si_code: 0 - .
0xc000000000436810:0 in _send_sys+0x30 () from /usr/lib/hpux64/libc.so.1
(gdb) bt
#0  0xc000000000436810:0 in _send_sys+0x30 () from /usr/lib/hpux64/libc.so.1
#1  0xc00000000044ccc0:0 in send+0xe0 () from /usr/lib/hpux64/libc.so.1
#2  0xc0000000014bee90:0 in _libssh2_transport_write+0x8d0 ()
   from /home/xxxx/bin/libssh2.so.1
#3  0xc0000000014a2ef0:0 in session_disconnect+0x3c0 ()
   from /home/xxxx/bin/libssh2.so.1
#4  0xc0000000014a3030:0 in libssh2_session_disconnect_ex+0x50 ()
. . .

Now, the main question, should libssh2 actually handle this kind of
behaviour when libssh2_session_disconnect is called (a bug?) or should
client application skip calling libssh2_session_disconnect if the session
already timed out by the server? Will it be safe for client to skip calling
this function if it detected connection already unavailable in a sense that
will this cause any other issues such as memory leak etc?

This is tested for 1.2.7 & 1.2.8 with the same behavior... and this seems
to happen with SunOS cc: Sun C 5.9 SunOS_sparc Patch 124867-01 2007/07/12
as well.

Hope to get some advice soon...

Thanks & Regards,
zaideeabu

--0015173fe6b23881e104b43614d8
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi expert,<br><br>We have a daemon application on HP-UX 11iv3 which uses li=
bssh2 to connect to sftp server for file transfer.<br>The application works=
 well with cc: HP C/aC++ B3910B A.06.20 but core dump due to SIGPIPE error =
when compiled with another machine with cc: HP C/aC++ B3910B A.06.25.<br>
<br>From stack trace, the problem seems to be due to libssh2_session_discon=
nect which eventually called libc read() function which is causing SIGPIPE =
and core dump.<br><br>The scenario is as below:<br><br>1. Client create an =
sftp connection to sftp-server with idle timeout set.<br>
2. During idle time, sftp server disconnect the connection.<br>3. When clie=
nt has file to send, it check connection and reconnect if connection alread=
y gone (by checking handle with opendir() ).<br>4. Prior to reconnect, it w=
ill need to clean up existing connection and part of it is calling the libs=
sh2_session_disconnect which then causing SIGPIPE error.<br>
<br>This can be reproduce by using libssh2 example code with a bit of chang=
e to wait for timeout (also attached here):<br>In this case, I set my sftps=
erver to timeout within 30sec idle time.<br><br>int main()<br>{<br><br>
// initialization and so on...<br>. . .<br><br>// server timeout set to 30 =
sec.<br>fprintf(stderr, &quot;Wait 60 sec for server timeout\n&quot;);<br>s=
leep(60);<br><br><br>=A0=A0=A0 fprintf(stderr, &quot;libssh2_sftp_open()!\n=
&quot;);<br>
=A0=A0=A0 /* Request a file via SFTP */<br>=A0=A0=A0 sftp_handle =3D<br>=A0=
=A0=A0=A0=A0=A0=A0 libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_RE=
AD, 0);<br><br>=A0=A0=A0 if (!sftp_handle) {<br>=A0=A0=A0=A0=A0=A0=A0 fprin=
tf(stderr, &quot;Unable to open file with SFTP\n&quot;);<br>
=A0=A0=A0=A0=A0=A0=A0 goto check_status;<br>=A0=A0=A0 }<br>=A0=A0=A0 fprint=
f(stderr, &quot;libssh2_sftp_open() is done, now receive data!\n&quot;);<br=
>=A0=A0=A0 do {<br>=A0=A0=A0=A0=A0=A0=A0 char mem[1024];<br><br>=A0=A0=A0=
=A0=A0=A0=A0 /* loop until we fail */<br>=A0=A0=A0=A0=A0=A0=A0 fprintf(stde=
rr, &quot;libssh2_sftp_read()!\n&quot;);<br>
=A0=A0=A0=A0=A0=A0=A0 rc =3D libssh2_sftp_read(sftp_handle, mem, sizeof(mem=
));<br>=A0=A0=A0=A0=A0=A0=A0 if (rc &gt; 0) {<br>=A0=A0=A0=A0=A0=A0=A0=A0=
=A0=A0=A0 write(1, mem, rc);<br>=A0=A0=A0=A0=A0=A0=A0 } else {<br>=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0 break;<br>=A0=A0=A0=A0=A0=A0=A0 }<br>=A0=A0=A0 } w=
hile (1);<br><br>check_status:<br>
fprintf(stderr, &quot;Check SFTP conn status\n&quot;);<br>connection_status=
(sock);<br><br>fprintf(stderr, &quot;Shutting down sftp_session...\n&quot;)=
;<br><br>=A0=A0=A0 libssh2_sftp_shutdown(sftp_session);<br><br>=A0 shutdown=
:<br>
<br>fprintf(stderr, &quot;Session disconect...\n&quot;);<br>=A0=A0=A0 libss=
h2_session_disconnect(session, &quot;Normal Shutdown, Thank you for playing=
&quot;);<br><br>fprintf(stderr, &quot;Session free...\n&quot;);<br>=A0=A0=
=A0 libssh2_session_free(session);<br>
<br>. . .<br><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br><br>The result is:<br>libssh2_sftp_rea=
d()!<br>Wait 60 sec for server timeout<br>libssh2_sftp_opendir()!<br>Unable=
 to open dir &quot;.&quot; with SFTP<br>Check SFTP conn status<br>
Connection seems to be alive (fcntl: 0), continuing check..Connection is lo=
st (recv -1, 232, Connection reset by peer)Shutting down sftp_session...<br=
>Session disconect...<br>test_sftp&gt; $<br><br>** There&#39;s no &quot;Ses=
sion free&quot; test as it core dump.<br>
<br>gdb output:<br>---------------<br>Program received signal SIGPIPE, Brok=
en pipe<br>=A0 si_code: 0 - .<br>0xc000000000436810:0 in _send_sys+0x30 () =
from /usr/lib/hpux64/libc.so.1<br>(gdb) bt<br>#0=A0 0xc000000000436810:0 in=
 _send_sys+0x30 () from /usr/lib/hpux64/libc.so.1<br>
#1=A0 0xc00000000044ccc0:0 in send+0xe0 () from /usr/lib/hpux64/libc.so.1<b=
r>#2=A0 0xc0000000014bee90:0 in _libssh2_transport_write+0x8d0 ()<br>=A0=A0=
 from /home/xxxx/bin/libssh2.so.1<br>#3=A0 0xc0000000014a2ef0:0 in session_=
disconnect+0x3c0 ()<br>
=A0=A0 from /home/xxxx/bin/libssh2.so.1<br>#4=A0 0xc0000000014a3030:0 in li=
bssh2_session_disconnect_ex+0x50 ()<br>. . .<br><br>Now, the main question,=
 should libssh2 actually handle this kind of behaviour when libssh2_session=
_disconnect is called (a bug?) or should client application skip calling li=
bssh2_session_disconnect if the session already timed out by the server? Wi=
ll it be safe for client to skip calling this function if it detected conne=
ction already unavailable in a sense that will this cause any other issues =
such as memory leak etc?<br>
<br>This is tested for 1.2.7 &amp; 1.2.8 with the same behavior... and this=
 seems to happen with SunOS cc: Sun C 5.9 SunOS_sparc Patch 124867-01 2007/=
07/12 as well.<br><br>Hope to get some advice soon...<br><br>Thanks &amp; R=
egards,<br>
zaideeabu<br><br>

--0015173fe6b23881e104b43614d8--
--0015173fe6b23881e704b43614da
Content-Type: text/x-csrc; charset=US-ASCII; name="sftp.c"
Content-Disposition: attachment; filename="sftp.c"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gw999r2m0

LyoKICogJElkOiBzZnRwLmMsdiAxLjE3IDIwMDkvMDQvMjggMTA6MzU6MzAgYmFnZGVyIEV4cCAk
CiAqCiAqIFNhbXBsZSBzaG93aW5nIGhvdyB0byBkbyBTRlRQIHRyYW5zZmVycy4KICoKICogVGhl
IHNhbXBsZSBjb2RlIGhhcyBkZWZhdWx0IHZhbHVlcyBmb3IgaG9zdCBuYW1lLCB1c2VyIG5hbWUs
IHBhc3N3b3JkCiAqIGFuZCBwYXRoIHRvIGNvcHksIGJ1dCB5b3UgY2FuIHNwZWNpZnkgdGhlbSBv
biB0aGUgY29tbWFuZCBsaW5lIGxpa2U6CiAqCiAqICJzZnRwIDE5Mi4xNjguMC4xIHVzZXIgcGFz
c3dvcmQgL3RtcC9zZWNyZXRzIC1wfC1pfC1rIgogKi8KCiNpbmNsdWRlICJsaWJzc2gyX2NvbmZp
Zy5oIgojaW5jbHVkZSA8bGlic3NoMi5oPgojaW5jbHVkZSA8bGlic3NoMl9zZnRwLmg+CgojaWZk
ZWYgSEFWRV9XSU5TT0NLMl9ICiMgaW5jbHVkZSA8d2luc29jazIuaD4KI2VuZGlmCiNpZmRlZiBI
QVZFX1NZU19TT0NLRVRfSAojIGluY2x1ZGUgPHN5cy9zb2NrZXQuaD4KI2VuZGlmCiNpZmRlZiBI
QVZFX05FVElORVRfSU5fSAojIGluY2x1ZGUgPG5ldGluZXQvaW4uaD4KI2VuZGlmCiMgaWZkZWYg
SEFWRV9VTklTVERfSAojaW5jbHVkZSA8dW5pc3RkLmg+CiNlbmRpZgojaWZkZWYgSEFWRV9BUlBB
X0lORVRfSAojIGluY2x1ZGUgPGFycGEvaW5ldC5oPgojZW5kaWYKI2lmZGVmIEhBVkVfU1lTX1RJ
TUVfSAojIGluY2x1ZGUgPHN5cy90aW1lLmg+CiNlbmRpZgoKI2luY2x1ZGUgPHN5cy90eXBlcy5o
PgojaW5jbHVkZSA8ZmNudGwuaD4KI2luY2x1ZGUgPGVycm5vLmg+CiNpbmNsdWRlIDxzdGRpby5o
PgojaW5jbHVkZSA8Y3R5cGUuaD4KCgpjb25zdCBjaGFyICprZXlmaWxlMT0ifi8uc3NoL2lkX3Jz
YS5wdWIiOwpjb25zdCBjaGFyICprZXlmaWxlMj0ifi8uc3NoL2lkX3JzYSI7CmNvbnN0IGNoYXIg
KnVzZXJuYW1lPSJ1c2VybmFtZSI7CmNvbnN0IGNoYXIgKnBhc3N3b3JkPSJwYXNzd29yZCI7CmNv
bnN0IGNoYXIgKnNmdHBwYXRoPSIvdG1wL1RFU1QiOwoKCnN0YXRpYyB2b2lkIGtiZF9jYWxsYmFj
ayhjb25zdCBjaGFyICpuYW1lLCBpbnQgbmFtZV9sZW4sIAogICAgICAgICAgICAgY29uc3QgY2hh
ciAqaW5zdHJ1Y3Rpb24sIGludCBpbnN0cnVjdGlvbl9sZW4sIGludCBudW1fcHJvbXB0cywKICAg
ICAgICAgICAgIGNvbnN0IExJQlNTSDJfVVNFUkFVVEhfS0JESU5UX1BST01QVCAqcHJvbXB0cywK
ICAgICAgICAgICAgIExJQlNTSDJfVVNFUkFVVEhfS0JESU5UX1JFU1BPTlNFICpyZXNwb25zZXMs
CiAgICAgICAgICAgICB2b2lkICoqYWJzdHJhY3QpCnsKICAgIGludCBpOwogICAgc2l6ZV90IG47
CiAgICBjaGFyIGJ1ZlsxMDI0XTsKICAgICh2b2lkKWFic3RyYWN0OwoKICAgIHByaW50ZigiUGVy
Zm9ybWluZyBrZXlib2FyZC1pbnRlcmFjdGl2ZSBhdXRoZW50aWNhdGlvbi5cbiIpOwoKICAgIHBy
aW50ZigiQXV0aGVudGljYXRpb24gbmFtZTogJyIpOwogICAgZndyaXRlKG5hbWUsIDEsIG5hbWVf
bGVuLCBzdGRvdXQpOwogICAgcHJpbnRmKCInXG4iKTsKCiAgICBwcmludGYoIkF1dGhlbnRpY2F0
aW9uIGluc3RydWN0aW9uOiAnIik7CiAgICBmd3JpdGUoaW5zdHJ1Y3Rpb24sIDEsIGluc3RydWN0
aW9uX2xlbiwgc3Rkb3V0KTsKICAgIHByaW50ZigiJ1xuIik7CgogICAgcHJpbnRmKCJOdW1iZXIg
b2YgcHJvbXB0czogJWRcblxuIiwgbnVtX3Byb21wdHMpOwoKICAgIGZvciAoaSA9IDA7IGkgPCBu
dW1fcHJvbXB0czsgaSsrKSB7CiAgICAgICAgcHJpbnRmKCJQcm9tcHQgJWQgZnJvbSBzZXJ2ZXI6
ICciLCBpKTsKICAgICAgICBmd3JpdGUocHJvbXB0c1tpXS50ZXh0LCAxLCBwcm9tcHRzW2ldLmxl
bmd0aCwgc3Rkb3V0KTsKICAgICAgICBwcmludGYoIidcbiIpOwoKICAgICAgICBwcmludGYoIlBs
ZWFzZSB0eXBlIHJlc3BvbnNlOiAiKTsKICAgICAgICBmZ2V0cyhidWYsIHNpemVvZihidWYpLCBz
dGRpbik7CiAgICAgICAgbiA9IHN0cmxlbihidWYpOwogICAgICAgIHdoaWxlIChuID4gMCAmJiBz
dHJjaHIoIlxyXG4iLCBidWZbbiAtIDFdKSkKICAgICAgICAgIG4tLTsKICAgICAgICBidWZbbl0g
PSAwOwoKICAgICAgICByZXNwb25zZXNbaV0udGV4dCA9IHN0cmR1cChidWYpOwogICAgICAgIHJl
c3BvbnNlc1tpXS5sZW5ndGggPSBuOwoKICAgICAgICBwcmludGYoIlJlc3BvbnNlICVkIGZyb20g
dXNlciBpcyAnIiwgaSk7CiAgICAgICAgZndyaXRlKHJlc3BvbnNlc1tpXS50ZXh0LCAxLCByZXNw
b25zZXNbaV0ubGVuZ3RoLCBzdGRvdXQpOwogICAgICAgIHByaW50ZigiJ1xuXG4iKTsKICAgIH0K
CiAgICBwcmludGYoIkRvbmUuIFNlbmRpbmcga2V5Ym9hcmQtaW50ZXJhY3RpdmUgcmVzcG9uc2Vz
IHRvIHNlcnZlciBub3cuXG4iKTsKfQoKaW50IGNvbm5lY3Rpb25fc3RhdHVzKGludCBzb2NrZXQp
IHsKCiAgICBpbnQgcmV0OwogICAgY2hhciBidWZbMTBdOwogICAgaW50IG9sZGZsYWdzOwoKICAg
IG9sZGZsYWdzID0gZmNudGwoc29ja2V0LCBGX0dFVEZMKTsKICAgIHJldCA9IGZjbnRsKHNvY2tl
dCwgRl9TRVRGTCwgb2xkZmxhZ3MgfCBPX05PTkJMT0NLKTsKICAgIGlmKCByZXQgPT0gLTEgKSB7
CiAgICAgICAgZnByaW50ZihzdGRlcnIsICJDb25uZWN0aW9uIGlzIGxvc3QgKGZjbnRsOiAtMSwg
JWQsICVzKSIsIGVycm5vLCBzdHJlcnJvcihlcnJubykpOwogICAgICAgIC8qX3NldF9lcnJvcihz
ZXNzaW9uX2luZm8sIFNGVFBfT0ssICJDb25uZWN0aW9uIGlzIGxvc3QgKGZjbnRsOiAtMSwgJWQs
ICVzKSIsIGVycm5vLCBzdHJlcnJvcihlcnJubykpOyAqLwogICAgICAgIGZjbnRsKHNvY2tldCwg
Rl9TRVRGTCwgb2xkZmxhZ3MpOwogICAgICAgIHJldHVybiAwOwogICAgfQoKICAgIGZwcmludGYo
c3RkZXJyLCAiQ29ubmVjdGlvbiBzZWVtcyB0byBiZSBhbGl2ZSAoZmNudGw6ICVkKSwgY29udGlu
dWluZyBjaGVjay4uIiwgcmV0KTsKCiAgICAvKiBVcG9uIHN1Y2Nlc3NmdWwgY29tcGxldGlvbiwg
cmVjdigpIHNoYWxsIHJldHVybiB0aGUgbGVuZ3RoIG9mIHRoZSBtZXNzYWdlIGluIGJ5dGVzLgog
ICAgICogSWYgbm8gbWVzc2FnZXMgYXJlIGF2YWlsYWJsZSB0byBiZSByZWNlaXZlZCBhbmQgdGhl
IHBlZXIgaGFzIHBlcmZvcm1lZCBhbiBvcmRlcmx5IHNodXRkb3duLCByZWN2KCkgc2hhbGwgcmV0
dXJuIDAuCiAgICAgKiBPdGhlcndpc2UsIC0xIHNoYWxsIGJlIHJldHVybmVkIGFuZCBlcnJubyBz
ZXQgdG8gaW5kaWNhdGUgdGhlIGVycm9yLgogICAgICovCiAgICByZXQgPSByZWN2KHNvY2tldCwg
YnVmLCA5LCBNU0dfUEVFSyk7CiAgICBpZiggcmV0ID09IC0xICkgewogICAgICAgIGlmKCBlcnJu
byA9PSBFV09VTERCTE9DSyB8fCBlcnJubyA9PSBFQUdBSU4gKSB7CiAgICAgICAgICAgIGZwcmlu
dGYoc3RkZXJyLCAiQ29ubmVjdGlvbiBpcyBhbGl2ZSAocmVjdjogLTEsIEVXT1VMREJMT0NLL0VB
R0FJTikiKTsKICAgICAgICAgICAgZmNudGwoc29ja2V0LCBGX1NFVEZMLCBvbGRmbGFncyk7CiAg
ICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgZnByaW50ZihzdGRlcnIsICJDb25uZWN0aW9uIGlz
IGxvc3QgKHJlY3YgLTEsICVkLCAlcykiLCBlcnJubywgc3RyZXJyb3IoZXJybm8pKTsKIC8qICAg
ICAgICAgICBfc2V0X2Vycm9yKHNlc3Npb25faW5mbywgU0ZUUF9PSywgIkNvbm5lY3Rpb24gaXMg
bG9zdCAocmVjdiAtMSwgJWQsICVzKSIsIGVycm5vLCBzdHJlcnJvcihlcnJubykpOyAqLwogICAg
ICAgICAgICBmY250bChzb2NrZXQsIEZfU0VURkwsIG9sZGZsYWdzKTsKICAgICAgICAgICAgcmV0
dXJuIDA7CiAgICAgICAgfQogICAgfSBlbHNlIGlmICggcmV0ID09IDAgKSB7CiAgICAgICAgZnBy
aW50ZihzdGRlcnIsICJDb25uZWN0aW9uIGlzIGxvc3QgKHJlY3Y6IDApIik7CiAgLyogICAgIF9z
ZXRfZXJyb3Ioc2Vzc2lvbl9pbmZvLCBTRlRQX09LLCAiUGVlciBoYXMgcGVyZm9ybWVkIGFuIG9y
ZGVybHkgc2h1dGRvd24gKHJlY3YgMCkiKTsgKi8KICAgICAgICBmY250bChzb2NrZXQsIEZfU0VU
RkwsIG9sZGZsYWdzKTsKICAgICAgICByZXR1cm4gMDsKICAgIH0gZWxzZSB7CiAgICAgICAgZnBy
aW50ZihzdGRlcnIsICJDb25uZWN0aW9uIGlzIGFsaXZlIChyZWN2OiAlZCkiLCByZXQpOwogICAg
ICAgIGZjbnRsKHNvY2tldCwgRl9TRVRGTCwgb2xkZmxhZ3MpOwogICAgfQogICAgcmV0dXJuIDE7
Cn0KCgppbnQgbWFpbihpbnQgYXJnYywgY2hhciAqYXJndltdKQp7CiAgICB1bnNpZ25lZCBsb25n
IGhvc3RhZGRyOwogICAgaW50IHNvY2ssIGksIGF1dGhfcHcgPSAwOwogICAgc3RydWN0IHNvY2th
ZGRyX2luIHNpbjsKICAgIGNvbnN0IGNoYXIgKmZpbmdlcnByaW50OwogICAgY2hhciAqdXNlcmF1
dGhsaXN0OwogICAgTElCU1NIMl9TRVNTSU9OICpzZXNzaW9uOwogICAgaW50IHJjOwogICAgTElC
U1NIMl9TRlRQICpzZnRwX3Nlc3Npb247CiAgICBMSUJTU0gyX1NGVFBfSEFORExFICpzZnRwX2hh
bmRsZTsKCiNpZmRlZiBXSU4zMgogICAgV1NBREFUQSB3c2FkYXRhOwoKICAgIFdTQVN0YXJ0dXAo
TUFLRVdPUkQoMiwwKSwgJndzYWRhdGEpOwojZW5kaWYKCiAgICBpZiAoYXJnYyA+IDEpIHsKICAg
ICAgICBob3N0YWRkciA9IGluZXRfYWRkcihhcmd2WzFdKTsKICAgIH0gZWxzZSB7CiAgICAgICAg
aG9zdGFkZHIgPSBodG9ubCgweDdGMDAwMDAxKTsKICAgIH0KCiAgICBpZihhcmdjID4gMikgewog
ICAgICAgIHVzZXJuYW1lID0gYXJndlsyXTsKICAgIH0KICAgIGlmKGFyZ2MgPiAzKSB7CiAgICAg
ICAgcGFzc3dvcmQgPSBhcmd2WzNdOwogICAgfQogICAgaWYoYXJnYyA+IDQpIHsKICAgICAgICBz
ZnRwcGF0aCA9IGFyZ3ZbNF07CiAgICB9CgogICAgcmMgPSBsaWJzc2gyX2luaXQgKDApOwogICAg
aWYgKHJjICE9IDApIHsKICAgICAgICBmcHJpbnRmIChzdGRlcnIsICJsaWJzc2gyIGluaXRpYWxp
emF0aW9uIGZhaWxlZCAoJWQpXG4iLCByYyk7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CgogICAg
LyoKICAgICAqIFRoZSBhcHBsaWNhdGlvbiBjb2RlIGlzIHJlc3BvbnNpYmxlIGZvciBjcmVhdGlu
ZyB0aGUgc29ja2V0CiAgICAgKiBhbmQgZXN0YWJsaXNoaW5nIHRoZSBjb25uZWN0aW9uCiAgICAg
Ki8KICAgIHNvY2sgPSBzb2NrZXQoQUZfSU5FVCwgU09DS19TVFJFQU0sIDApOwoKICAgIHNpbi5z
aW5fZmFtaWx5ID0gQUZfSU5FVDsKICAgIHNpbi5zaW5fcG9ydCA9IGh0b25zKDIyKTsKICAgIHNp
bi5zaW5fYWRkci5zX2FkZHIgPSBob3N0YWRkcjsKICAgIGlmIChjb25uZWN0KHNvY2ssIChzdHJ1
Y3Qgc29ja2FkZHIqKSgmc2luKSwKICAgICAgICAgICAgICAgIHNpemVvZihzdHJ1Y3Qgc29ja2Fk
ZHJfaW4pKSAhPSAwKSB7CiAgICAgICAgZnByaW50ZihzdGRlcnIsICJmYWlsZWQgdG8gY29ubmVj
dCFcbiIpOwogICAgICAgIHJldHVybiAtMTsKICAgIH0KCiAgICAvKiBDcmVhdGUgYSBzZXNzaW9u
IGluc3RhbmNlCiAgICAgKi8KICAgIHNlc3Npb24gPSBsaWJzc2gyX3Nlc3Npb25faW5pdCgpOwog
ICAgaWYoIXNlc3Npb24pCiAgICAgICAgcmV0dXJuIC0xOwoKICAgIC8qIFNpbmNlIHdlIGhhdmUg
c2V0IG5vbi1ibG9ja2luZywgdGVsbCBsaWJzc2gyIHdlIGFyZSBibG9ja2luZyAqLwogICAgbGli
c3NoMl9zZXNzaW9uX3NldF9ibG9ja2luZyhzZXNzaW9uLCAxKTsKCiAgICAvKiAuLi4gc3RhcnQg
aXQgdXAuIFRoaXMgd2lsbCB0cmFkZSB3ZWxjb21lIGJhbm5lcnMsIGV4Y2hhbmdlIGtleXMsCiAg
ICAgKiBhbmQgc2V0dXAgY3J5cHRvLCBjb21wcmVzc2lvbiwgYW5kIE1BQyBsYXllcnMKICAgICAq
LwogICAgcmMgPSBsaWJzc2gyX3Nlc3Npb25fc3RhcnR1cChzZXNzaW9uLCBzb2NrKTsKICAgIGlm
KHJjKSB7CiAgICAgICAgZnByaW50ZihzdGRlcnIsICJGYWlsdXJlIGVzdGFibGlzaGluZyBTU0gg
c2Vzc2lvbjogJWRcbiIsIHJjKTsKICAgICAgICByZXR1cm4gLTE7CiAgICB9CgogICAgLyogQXQg
dGhpcyBwb2ludCB3ZSBoYXZuJ3QgeWV0IGF1dGhlbnRpY2F0ZWQuICBUaGUgZmlyc3QgdGhpbmcg
dG8gZG8KICAgICAqIGlzIGNoZWNrIHRoZSBob3N0a2V5J3MgZmluZ2VycHJpbnQgYWdhaW5zdCBv
dXIga25vd24gaG9zdHMgWW91ciBhcHAKICAgICAqIG1heSBoYXZlIGl0IGhhcmQgY29kZWQsIG1h
eSBnbyB0byBhIGZpbGUsIG1heSBwcmVzZW50IGl0IHRvIHRoZQogICAgICogdXNlciwgdGhhdCdz
IHlvdXIgY2FsbAogICAgICovCiAgICBmaW5nZXJwcmludCA9IGxpYnNzaDJfaG9zdGtleV9oYXNo
KHNlc3Npb24sIExJQlNTSDJfSE9TVEtFWV9IQVNIX1NIQTEpOwogICAgZnByaW50ZihzdGRlcnIs
ICJGaW5nZXJwcmludDogIik7CiAgICBmb3IoaSA9IDA7IGkgPCAyMDsgaSsrKSB7CiAgICAgICAg
ZnByaW50ZihzdGRlcnIsICIlMDJYICIsICh1bnNpZ25lZCBjaGFyKWZpbmdlcnByaW50W2ldKTsK
ICAgIH0KICAgIGZwcmludGYoc3RkZXJyLCAiXG4iKTsKCiAgICAvKiBjaGVjayB3aGF0IGF1dGhl
bnRpY2F0aW9uIG1ldGhvZHMgYXJlIGF2YWlsYWJsZSAqLwogICAgdXNlcmF1dGhsaXN0ID0gbGli
c3NoMl91c2VyYXV0aF9saXN0KHNlc3Npb24sIHVzZXJuYW1lLCBzdHJsZW4odXNlcm5hbWUpKTsK
ICAgIHByaW50ZigiQXV0aGVudGljYXRpb24gbWV0aG9kczogJXNcbiIsIHVzZXJhdXRobGlzdCk7
CiAgICBpZiAoc3Ryc3RyKHVzZXJhdXRobGlzdCwgInBhc3N3b3JkIikgIT0gTlVMTCkgewogICAg
ICAgIGF1dGhfcHcgfD0gMTsKICAgIH0KICAgIGlmIChzdHJzdHIodXNlcmF1dGhsaXN0LCAia2V5
Ym9hcmQtaW50ZXJhY3RpdmUiKSAhPSBOVUxMKSB7CiAgICAgICAgYXV0aF9wdyB8PSAyOwogICAg
fQogICAgaWYgKHN0cnN0cih1c2VyYXV0aGxpc3QsICJwdWJsaWNrZXkiKSAhPSBOVUxMKSB7CiAg
ICAgICAgYXV0aF9wdyB8PSA0OwogICAgfQoKICAgIC8qIGlmIHdlIGdvdCBhbiA0LiBhcmd1bWVu
dCB3ZSBzZXQgdGhpcyBvcHRpb24gaWYgc3VwcG9ydGVkICovIAogICAgaWYoYXJnYyA+IDUpIHsK
ICAgICAgICBpZiAoKGF1dGhfcHcgJiAxKSAmJiAhc3RyY2FzZWNtcChhcmd2WzVdLCAiLXAiKSkg
ewogICAgICAgICAgICBhdXRoX3B3ID0gMTsKICAgICAgICB9CiAgICAgICAgaWYgKChhdXRoX3B3
ICYgMikgJiYgIXN0cmNhc2VjbXAoYXJndls1XSwgIi1pIikpIHsKICAgICAgICAgICAgYXV0aF9w
dyA9IDI7CiAgICAgICAgfQogICAgICAgIGlmICgoYXV0aF9wdyAmIDQpICYmICFzdHJjYXNlY21w
KGFyZ3ZbNV0sICItayIpKSB7CiAgICAgICAgICAgIGF1dGhfcHcgPSA0OwogICAgICAgIH0KICAg
IH0KCiAgICBpZiAoYXV0aF9wdyAmIDEpIHsKICAgICAgICAvKiBXZSBjb3VsZCBhdXRoZW50aWNh
dGUgdmlhIHBhc3N3b3JkICovCiAgICAgICAgaWYgKGxpYnNzaDJfdXNlcmF1dGhfcGFzc3dvcmQo
c2Vzc2lvbiwgdXNlcm5hbWUsIHBhc3N3b3JkKSkgewogICAgICAgICAgICBmcHJpbnRmKHN0ZGVy
ciwgIkF1dGhlbnRpY2F0aW9uIGJ5IHBhc3N3b3JkIGZhaWxlZC5cbiIpOwogICAgICAgICAgICBn
b3RvIHNodXRkb3duOwogICAgICAgIH0KICAgIH0gZWxzZSBpZiAoYXV0aF9wdyAmIDIpIHsKICAg
ICAgICAvKiBPciB2aWEga2V5Ym9hcmQtaW50ZXJhY3RpdmUgKi8KICAgICAgICBpZiAobGlic3No
Ml91c2VyYXV0aF9rZXlib2FyZF9pbnRlcmFjdGl2ZShzZXNzaW9uLCB1c2VybmFtZSwgJmtiZF9j
YWxsYmFjaykgKSB7CiAgICAgICAgICAgIHByaW50ZigiXHRBdXRoZW50aWNhdGlvbiBieSBrZXli
b2FyZC1pbnRlcmFjdGl2ZSBmYWlsZWQhXG4iKTsKICAgICAgICAgICAgZ290byBzaHV0ZG93bjsK
ICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBwcmludGYoIlx0QXV0aGVudGljYXRpb24gYnkg
a2V5Ym9hcmQtaW50ZXJhY3RpdmUgc3VjY2VlZGVkLlxuIik7CiAgICAgICAgfQogICAgfSBlbHNl
IGlmIChhdXRoX3B3ICYgNCkgewogICAgICAgIC8qIE9yIGJ5IHB1YmxpYyBrZXkgKi8KICAgICAg
ICBpZiAobGlic3NoMl91c2VyYXV0aF9wdWJsaWNrZXlfZnJvbWZpbGUoc2Vzc2lvbiwgdXNlcm5h
bWUsIGtleWZpbGUxLCBrZXlmaWxlMiwgcGFzc3dvcmQpKSB7CiAgICAgICAgICAgIHByaW50Zigi
XHRBdXRoZW50aWNhdGlvbiBieSBwdWJsaWMga2V5IGZhaWxlZCFcbiIpOwogICAgICAgICAgICBn
b3RvIHNodXRkb3duOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHByaW50ZigiXHRBdXRo
ZW50aWNhdGlvbiBieSBwdWJsaWMga2V5IHN1Y2NlZWRlZC5cbiIpOwogICAgICAgIH0KICAgIH0g
ZWxzZSB7CiAgICAgICAgcHJpbnRmKCJObyBzdXBwb3J0ZWQgYXV0aGVudGljYXRpb24gbWV0aG9k
cyBmb3VuZCFcbiIpOwogICAgICAgIGdvdG8gc2h1dGRvd247CiAgICB9CgogICAgZnByaW50Zihz
dGRlcnIsICJsaWJzc2gyX3NmdHBfaW5pdCgpIVxuIik7CiAgICBzZnRwX3Nlc3Npb24gPSBsaWJz
c2gyX3NmdHBfaW5pdChzZXNzaW9uKTsKCiAgICBpZiAoIXNmdHBfc2Vzc2lvbikgewogICAgICAg
IGZwcmludGYoc3RkZXJyLCAiVW5hYmxlIHRvIGluaXQgU0ZUUCBzZXNzaW9uXG4iKTsKICAgICAg
ICBnb3RvIHNodXRkb3duOwogICAgfQoKICAgIGZwcmludGYoc3RkZXJyLCAibGlic3NoMl9zZnRw
X29wZW4oKSFcbiIpOwogICAgLyogUmVxdWVzdCBhIGZpbGUgdmlhIFNGVFAgKi8KICAgIHNmdHBf
aGFuZGxlID0KICAgICAgICBsaWJzc2gyX3NmdHBfb3BlbihzZnRwX3Nlc3Npb24sIHNmdHBwYXRo
LCBMSUJTU0gyX0ZYRl9SRUFELCAwKTsKCiAgICBpZiAoIXNmdHBfaGFuZGxlKSB7CiAgICAgICAg
ZnByaW50ZihzdGRlcnIsICJVbmFibGUgdG8gb3BlbiBmaWxlIHdpdGggU0ZUUDogJWxkXG4iLAog
ICAgICAgICAgICAgICAgbGlic3NoMl9zZnRwX2xhc3RfZXJyb3Ioc2Z0cF9zZXNzaW9uKSk7CiAg
ICAgICAgZ290byBzaHV0ZG93bjsKICAgIH0KICAgIGZwcmludGYoc3RkZXJyLCAibGlic3NoMl9z
ZnRwX29wZW4oKSBpcyBkb25lLCBub3cgcmVjZWl2ZSBkYXRhIVxuIik7CiAgICBkbyB7CiAgICAg
ICAgY2hhciBtZW1bMTAyNF07CgogICAgICAgIC8qIGxvb3AgdW50aWwgd2UgZmFpbCAqLwogICAg
ICAgIGZwcmludGYoc3RkZXJyLCAibGlic3NoMl9zZnRwX3JlYWQoKSFcbiIpOwogICAgICAgIHJj
ID0gbGlic3NoMl9zZnRwX3JlYWQoc2Z0cF9oYW5kbGUsIG1lbSwgc2l6ZW9mKG1lbSkpOwogICAg
ICAgIGlmIChyYyA+IDApIHsKICAgICAgICAgICAgd3JpdGUoMSwgbWVtLCByYyk7CiAgICAgICAg
fSBlbHNlIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfSB3aGlsZSAoMSk7Cgog
ICAgbGlic3NoMl9zZnRwX2Nsb3NlKHNmdHBfaGFuZGxlKTsKCmZwcmludGYoc3RkZXJyLCAiV2Fp
dCA2MCBzZWMgZm9yIHNlcnZlciB0aW1lb3V0XG4iKTsKc2xlZXAoNjApOwoKCiAgICBmcHJpbnRm
KHN0ZGVyciwgImxpYnNzaDJfc2Z0cF9vcGVuKCkhXG4iKTsKICAgIC8qIFJlcXVlc3QgYSBmaWxl
IHZpYSBTRlRQICovCiAgICBzZnRwX2hhbmRsZSA9CiAgICAgICAgbGlic3NoMl9zZnRwX29wZW4o
c2Z0cF9zZXNzaW9uLCBzZnRwcGF0aCwgTElCU1NIMl9GWEZfUkVBRCwgMCk7CgogICAgaWYgKCFz
ZnRwX2hhbmRsZSkgewogICAgICAgIGZwcmludGYoc3RkZXJyLCAiVW5hYmxlIHRvIG9wZW4gZmls
ZSB3aXRoIFNGVFBcbiIpOwogICAgICAgIGdvdG8gY2hlY2tfc3RhdHVzOwogICAgfQogICAgZnBy
aW50ZihzdGRlcnIsICJsaWJzc2gyX3NmdHBfb3BlbigpIGlzIGRvbmUsIG5vdyByZWNlaXZlIGRh
dGEhXG4iKTsKICAgIGRvIHsKICAgICAgICBjaGFyIG1lbVsxMDI0XTsKCiAgICAgICAgLyogbG9v
cCB1bnRpbCB3ZSBmYWlsICovCiAgICAgICAgZnByaW50ZihzdGRlcnIsICJsaWJzc2gyX3NmdHBf
cmVhZCgpIVxuIik7CiAgICAgICAgcmMgPSBsaWJzc2gyX3NmdHBfcmVhZChzZnRwX2hhbmRsZSwg
bWVtLCBzaXplb2YobWVtKSk7CiAgICAgICAgaWYgKHJjID4gMCkgewogICAgICAgICAgICB3cml0
ZSgxLCBtZW0sIHJjKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBicmVhazsKICAgICAg
ICB9CiAgICB9IHdoaWxlICgxKTsKCmNoZWNrX3N0YXR1czoKZnByaW50ZihzdGRlcnIsICJDaGVj
ayBTRlRQIGNvbm4gc3RhdHVzXG4iKTsKY29ubmVjdGlvbl9zdGF0dXMoc29jayk7CgpmcHJpbnRm
KHN0ZGVyciwgIlNodXR0aW5nIGRvd24gc2Z0cF9zZXNzaW9uLi4uXG4iKTsKCiAgICBsaWJzc2gy
X3NmdHBfc2h1dGRvd24oc2Z0cF9zZXNzaW9uKTsKCiAgc2h1dGRvd246CgpmcHJpbnRmKHN0ZGVy
ciwgIlNlc3Npb24gZGlzY29uZWN0Li4uXG4iKTsKICAgIGxpYnNzaDJfc2Vzc2lvbl9kaXNjb25u
ZWN0KHNlc3Npb24sICJOb3JtYWwgU2h1dGRvd24sIFRoYW5rIHlvdSBmb3IgcGxheWluZyIpOwoK
ZnByaW50ZihzdGRlcnIsICJTZXNzaW9uIGZyZWUuLi5cbiIpOwogICAgbGlic3NoMl9zZXNzaW9u
X2ZyZWUoc2Vzc2lvbik7CgojaWZkZWYgV0lOMzIKICAgIGNsb3Nlc29ja2V0KHNvY2spOwojZWxz
ZQogICAgY2xvc2Uoc29jayk7CiNlbmRpZgogICAgZnByaW50ZihzdGRlcnIsICJhbGwgZG9uZVxu
Iik7CgogICAgbGlic3NoMl9leGl0KCk7CgogICAgcmV0dXJuIDA7Cn0K
--0015173fe6b23881e704b43614da
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--0015173fe6b23881e704b43614da--

From libssh2-devel-bounces@cool.haxx.se  Fri Dec 16 17:42:59 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBGGglRm026249;
	Fri, 16 Dec 2011 17:42:57 +0100
Received: from vps1.henriknordstrom.net (vps1.henriknordstrom.net
	[IPv6:2a02:750:7::d0a])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBGGgj73026187
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 16 Dec 2011 17:42:46 +0100
Received: from henriknordstrom.net (183.159.216.81.static.tb.siw.siwnet.net
	[81.216.159.183])
	by vps1.henriknordstrom.net (8.14.2/8.14.2/Debian-2build1) with ESMTP
	id pBGGgjFf017813
	for <libssh2-devel@cool.haxx.se>; Fri, 16 Dec 2011 16:42:46 GMT
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by henriknordstrom.net (8.12.11.20060308/8.12.8) with ESMTP id
	pBGGgVpZ026477
	for <libssh2-devel@cool.haxx.se>; Fri, 16 Dec 2011 17:42:31 +0100
Message-ID: <1324053751.17270.24.camel@henriknordstrom.net>
Subject: Re: core dump when calling libssh2_session_disconnect when sftp
	server timeout
From: Henrik =?ISO-8859-1?Q?Nordstr=F6m?= <henrik@henriknordstrom.net>
To: libssh2 development <libssh2-devel@cool.haxx.se>
Date: Fri, 16 Dec 2011 17:42:31 +0100
In-Reply-To: <CAC11QN88WndByuArT+ZivrKR1_r0yvOOg80HO0FaNvvZU4NMXA@mail.gmail.com>
References: <CAC11QN88WndByuArT+ZivrKR1_r0yvOOg80HO0FaNvvZU4NMXA@mail.gmail.com>
X-Mailer: Evolution 3.2.2 (3.2.2-1.fc16) 
Mime-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0
	(vps1.henriknordstrom.net [195.20.207.177]);
	Fri, 16 Dec 2011 16:42:46 +0000 (UTC)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

fre 2011-12-16 klockan 22:04 +0800 skrev Ahmad Zaidee Abu:

> The application works well with cc: HP C/aC++ B3910B A.06.20 but core
> dump due to SIGPIPE error when compiled with another machine with cc:
> HP C/aC++ B3910B A.06.25.

SIGPIPE is a generic UNIX signal, received when an application tries to
write to a no longer existing pipe/socket connection.

To avoid this crashing your application, set the signal as ignored.

#include <signal.h>

[...]

  signal(SIGPIPE, SIG_IGN);

Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 18 13:37:15 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBICanE0020324;
	Sun, 18 Dec 2011 13:37:10 +0100
Received: from secure.karelia.com (secure.karelia.com [173.45.238.25])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBICalE7020306
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 13:36:47 +0100
Received: from unknown-28-37-37-24-f1-f6.home
	(host86-178-209-114.range86-178.btcentralplus.com [86.178.209.114])
	by secure.karelia.com (Postfix) with ESMTPSA id E527B47C015
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 04:36:46 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=karelia.com;
	s=default; t=1324211807; bh=BNqYejMqg3UW353WZVrXJFUbRBGFVUYZ7M/5Dxf
	1y58=; h=From:Content-Type:Content-Transfer-Encoding:Subject:Date:
	Message-Id:To:Mime-Version; b=WaDwHcGfoIMKeoFpn+hiStc/uxmqeUllBZL0
	tY/hRB7jvC+ZyADCxNLx/7+Z8Mgt93B83AOQ5b1xEChtFrBbV3by2FI/b6pUk/m6yCW
	cfwK6lPUf2xA9S3BquP2+JbsbrRSrWA1FUTYv9u7a3Yqtglds7CoHQpkhWTf79s7E6G
	s=
From: Mike Abdullah <mabdullah@karelia.com>
Subject: Handling disconnection from too many authentication failures
Date: Sun, 18 Dec 2011 12:36:44 +0000
Message-Id: <777AC95C-E31E-4EDD-BC02-621BB551E84D@karelia.com>
To: libssh2-devel@cool.haxx.se
Mime-Version: 1.0 (Apple Message framework v1251.1)
X-Mailer: Apple Mail (2.1251.1)
X-MIME-Autoconverted: from quoted-printable to 8bit by giant.haxx.se id
	pBICalE7020306
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

Hello, I'm trying to figure out how to best to handle an authentication problem in our code which is using libssh2. Our code does this:

1. Start up libssh2 session
2. Look to see if username/password has been saved. If not, jump straight to step 4.
3. Try to authenticate. If successful, then start up an SFTP session. Otherwise:
4. Bring up a dialog asking for username and password. When provided, jump back to step 3.

This is working great except for when the user has several failed attempts at authentication in a row. After too many, trying to authenticate returns LIBSSH2_ERROR_SOCKET_SEND or LIBSSH2_ERROR_TIMEOUT, with an error message of "Would block waiting". I take this to be the result of the server having disconnected us for too many failed attempts. Unfortunately that isn't a helpful message to display to the user!

So, I reason I need to install a callback for disconnects. Having done so, the callback is indeed being called as I'd expect, however, when it's called:

void disconnect_callback(LIBSSH2_SESSION *session, int reason, const char *message, int message_len, const char *language, int language_len, void **abstract)

message, message_len, language, and language_len are all NULL/0! I expected to receive a message along the lines of "Too many authentication failures". (the disconnect code is SSH_DISCONNECT_PROTOCOL_ERROR, which makes sense to me).

If I try the command line ssh program, I get this:

Received disconnect from 207.7.108.244: 2: Too many authentication failures for username

Am I doing something wrong which means the message comes through empty? Or is it that in this case I am expected to infer the real error reason and supply a message myself?

Thanks,
Mike.
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 18 14:28:29 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBIDSJlg024256;
	Sun, 18 Dec 2011 14:28:27 +0100
Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com
	[209.85.215.182])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBIDSH8o024139
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 14:28:17 +0100
Received: by eaaf13 with SMTP id f13so5388285eaa.41
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 05:28:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=nOp8gX72+/Ngu5iXIGpQQ/292qak683xaRcDveEcX/o=;
	b=i7/8aMR+6i0fdWas5v6XQrOrZRDri4y+aw5Ys6VDwTTPOTjNORENt48ucaHmJvn8Jo
	LFCX0bD1McNFCsARd18/BBiMIgSYAdowRShzgVfOk5pY8K9JOzwuOuLoR/ufHo3rutG3
	9ffTHNEK/p5ZSeSANMRy2JmrWC943Xh4UY/eY=
MIME-Version: 1.0
Received: by 10.204.130.6 with SMTP id q6mr594447bks.10.1324214893169; Sun, 18
	Dec 2011 05:28:13 -0800 (PST)
Received: by 10.204.102.10 with HTTP; Sun, 18 Dec 2011 05:28:13 -0800 (PST)
Date: Sun, 18 Dec 2011 21:28:13 +0800
Message-ID: <CAC11QN-78RBVqKptH8QrbMnA5kYz6qc3o1iAww-a3fXudOJgdA@mail.gmail.com>
Subject: Re: Re: core dump when calling libssh2_session_disconnect when sftp
	server timeout
From: Ahmad Zaidee Abu <zaideeabu@gmail.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============0718270694=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============0718270694==
Content-Type: multipart/alternative; boundary=00151744817c504a9104b45dcec2

--00151744817c504a9104b45dcec2
Content-Type: text/plain; charset=ISO-8859-1

> SIGPIPE is a generic UNIX signal, received when an application tries to
> write to a no longer existing pipe/socket connection.
>
> To avoid this crashing your application, set the signal as ignored.
>
> #include <signal.h>
>
> [...]
>
>  signal(SIGPIPE, SIG_IGN);
>
> Regards
> Henrik
>
>
Hi Henrik/ experts,

Thanks for the quick response. I've tried your suggestion, but it still
doesn't help. Instead this is giving additional error, see gdb:
 si_code: 1 - SEGV_MAPERR - Address not mapped to object.
0xc00000001e83c3d0:0 in EVP_DigestInit_ex () at digest.c:211
211     digest.c: No such file or directory.
        in digest.c
(gdb) bt
#0  0xc00000001e83c3d0:0 in EVP_DigestInit_ex () at digest.c:211
#1  0xc00000001eabaf60:0 in HMAC_Init () at hmac.c:107
#2  0xc000000009020e00:0 in mac_method_hmac_sha1_hash+0xa0 ()
   from
/home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin/libssh2.so.1
#3  0xc000000009052cf0:0 in _libssh2_transport_write+0x730 ()
   from
/home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin/libssh2.so.1
#4  0xc000000009036ef0:0 in session_disconnect+0x3c0 ()
   from
/home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin/libssh2.so.1
#5  0xc000000009037030:0 in libssh2_session_disconnect_ex+0x50 ()
. . .

Any idea?

BTW, if you don't mind me asking what would be the impact if we're not
calling the libssh2_session_disconnect when we already know it's already
disconnected by the server side? From the function itself, I see that it
only used to send disconnect data to server "rc =
_libssh2_transport_write(session, session->disconnect_data,
session->disconnect_data_len);" and I don't see any other special handling
for releasing memory etc...

Any comments on this?


Thanks & Best Regards,
zaidee

--00151744817c504a9104b45dcec2
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
SIGPIPE is a generic UNIX signal, received when an application tries to<br>
write to a no longer existing pipe/socket connection.<br>
<br>
To avoid this crashing your application, set the signal as ignored.<br>
<br>
#include &lt;signal.h&gt;<br>
<br>
[...]<br>
<br>
 =A0signal(SIGPIPE, SIG_IGN);<br>
<br>
Regards<br>
Henrik<br>
<br></blockquote><div><br>Hi Henrik/ experts,<br><br>Thanks for the quick r=
esponse. I&#39;ve tried your suggestion, but it still doesn&#39;t help. Ins=
tead this is giving additional error, see gdb:<br>=A0si_code: 1 - SEGV_MAPE=
RR - Address not mapped to object.<br>
0xc00000001e83c3d0:0 in EVP_DigestInit_ex () at digest.c:211<br>211=A0=A0=
=A0=A0 digest.c: No such file or directory.<br>=A0=A0=A0=A0=A0=A0=A0 in dig=
est.c<br>(gdb) bt<br>#0=A0 0xc00000001e83c3d0:0 in EVP_DigestInit_ex () at =
digest.c:211<br>#1=A0 0xc00000001eabaf60:0 in HMAC_Init () at hmac.c:107<br=
>
#2=A0 0xc000000009020e00:0 in mac_method_hmac_sha1_hash+0xa0 ()<br>=A0=A0 f=
rom /home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin/=
libssh2.so.1<br>#3=A0 0xc000000009052cf0:0 in _libssh2_transport_write+0x73=
0 ()<br>
=A0=A0 from /home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/=
2/9/bin/libssh2.so.1<br>#4=A0 0xc000000009036ef0:0 in session_disconnect+0x=
3c0 ()<br>=A0=A0 from /home/cpt2a3a/elink_home_hpux/elink622p/EventLink/bas=
e/control/2/9/bin/libssh2.so.1<br>
#5=A0 0xc000000009037030:0 in libssh2_session_disconnect_ex+0x50 ()<br>. . =
.<br><br>Any idea? <br><br>BTW, if you don&#39;t mind me asking what would =
be the impact if we&#39;re not calling the libssh2_session_disconnect when =
we already know it&#39;s already disconnected by the server side? From the =
function itself, I see that it only used to send disconnect data to server =
&quot;rc =3D _libssh2_transport_write(session, session-&gt;disconnect_data,=
 session-&gt;disconnect_data_len);&quot; and I don&#39;t see any other spec=
ial handling for releasing memory etc... <br>
<br>Any comments on this?<br><br><br>Thanks &amp; Best Regards,<br>zaidee<b=
r><br></div></div>

--00151744817c504a9104b45dcec2--

--===============0718270694==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============0718270694==--

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 18 16:42:45 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBIFgMTS015799;
	Sun, 18 Dec 2011 16:42:41 +0100
Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com
	[209.85.215.182])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBIFgKNU015582
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 16:42:20 +0100
Received: by eaaf13 with SMTP id f13so5463644eaa.41
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 07:42:16 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=g2EkJW07m7lyH39sS2MlIHtLjq/FIsMSf01MnCxT2LI=;
	b=rqD4vjWwELWg1PZV04tw1zbDVNqXB1RtDqm9C1+p3BqN8j7XcB/OPNdRZTQ/6/zCIy
	OktVfrk99hVna2WTQCJSSo4Q/zeTdLaDsrWKN8KDol2m5qy4tinmbdz6MP/5RTXHc0tV
	KNLc77n/xjOkwB6+kOYfBbyp7VUIMmLa2eA1g=
MIME-Version: 1.0
Received: by 10.204.130.90 with SMTP id r26mr4298143bks.46.1324222936264; Sun,
	18 Dec 2011 07:42:16 -0800 (PST)
Received: by 10.204.102.10 with HTTP; Sun, 18 Dec 2011 07:42:16 -0800 (PST)
Date: Sun, 18 Dec 2011 23:42:16 +0800
Message-ID: <CAC11QN-H49h8REsStKtK01kQbB=9+_L1psNyx9pQT=XKLgWsjA@mail.gmail.com>
Subject: Re: Re: Re: core dump when calling libssh2_session_disconnect when
	sftp server timeout
From: Ahmad Zaidee Abu <zaideeabu@gmail.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1968302581=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============1968302581==
Content-Type: multipart/alternative; boundary=001517447eb6b82e7a04b45fad08

--001517447eb6b82e7a04b45fad08
Content-Type: text/plain; charset=ISO-8859-1

> si_code: 1 - SEGV_MAPERR - Address not mapped to object.

> 0xc00000001e83c3d0:0 in EVP_DigestInit_ex () at digest.c:211
> 211 digest.c: No such file or directory.
>        in digest.c
> (gdb) bt
>  #0 0xc00000001e83c3d0:0 in EVP_DigestInit_ex () at digest.c:211
> #1 0xc00000001eabaf60:0 in HMAC_Init () at hmac.c:107
> #2 0xc000000009020e00:0 in mac_method_hmac_sha1_hash+0xa0 ()
>   from
>
/home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin/libssh2.so.1

> #3 0xc000000009052cf0:0 in _libssh2_transport_write+0x730 ()
>    from
>
/home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin/libssh2.so.1

> #4 0xc000000009036ef0:0 in session_disconnect+0x3c0 ()
>    from
>
/home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin/libssh2.so.1

> #5 0xc000000009037030:0 in libssh2_session_disconnect_ex+0x50 ()
. . .
Hi expert,

Please ignore the issue "EVP_DigestInit_ex" above. That was my mistake
somehow the code actually calls libssh2_session_disconnect twice...
The signal(SIGPIPE, SIG_IGN) does work. :)

Thanks & Best Regards,
zaidee

--001517447eb6b82e7a04b45fad08
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

&gt; si_code: 1 - SEGV_MAPERR - Address not mapped to object.
<br><p>
&gt; 0xc00000001e83c3d0:0 in EVP_DigestInit_ex () at digest.c:211
<br>
&gt; 211     digest.c: No such file or directory.
<br>
&gt;=A0=A0=A0=A0=A0=A0=A0 in digest.c
<br>
&gt; (gdb) bt
<br>&gt;=A0
#0  0xc00000001e83c3d0:0 in EVP_DigestInit_ex () at digest.c:211
<br>
&gt; #1  0xc00000001eabaf60:0 in HMAC_Init () at hmac.c:107
<br>
&gt; #2  0xc000000009020e00:0 in mac_method_hmac_sha1_hash+0xa0 ()
<br>
&gt;=A0=A0 from
<br>
&gt; /home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin=
/libssh2.so.1
<br>
&gt; #3  0xc000000009052cf0:0 in _libssh2_transport_write+0x730 ()
<br>
&gt; =A0=A0 from
<br>
&gt; /home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin=
/libssh2.so.1
<br>
&gt; #4  0xc000000009036ef0:0 in session_disconnect+0x3c0 ()
<br>
&gt; =A0=A0 from
<br>&gt;=20
/home/cpt2a3a/elink_home_hpux/elink622p/EventLink/base/control/2/9/bin/libs=
sh2.so.1
<br>&gt;=20
#5  0xc000000009037030:0 in libssh2_session_disconnect_ex+0x50 ()
<br>
. . .
<br>
</p>Hi expert,<br><br>Please ignore the issue &quot;EVP_DigestInit_ex&quot;=
 above. That was my mistake somehow the code actually calls libssh2_session=
_disconnect twice... <br>The signal(SIGPIPE, SIG_IGN) does work. :)<br>
<br>Thanks &amp; Best Regards,
<br>
zaidee

--001517447eb6b82e7a04b45fad08--

--===============1968302581==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============1968302581==--

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 18 18:58:44 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBIHwVwj006279;
	Sun, 18 Dec 2011 18:58:41 +0100
Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com
	[209.85.210.182])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBIHwSVM006245
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 18:58:29 +0100
Received: by iadj38 with SMTP id j38so3761426iad.41
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 09:58:23 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=A127AoVDh7vlleKJgb7JGZzXVTFazlQNianQ62hkDQI=;
	b=LScdxA1FoZb0T9cWzny2jusfLsAWTuXQqap3O1kdXL6tGAETtcJIpKSTbdAx0o1WAv
	K9n5Gab5Gy3q2b6Qfm3D36nyrnzlgg6oKD3NnuCpm5XC/ZVn0rtVGizMpcVPHHuFZrUL
	u9BPk5IGjOjrj48ATcRNqlFkhxKSABJd9Ov+w=
MIME-Version: 1.0
Received: by 10.50.156.133 with SMTP id we5mr21795152igb.74.1324231102981;
	Sun, 18 Dec 2011 09:58:22 -0800 (PST)
Received: by 10.42.169.66 with HTTP; Sun, 18 Dec 2011 09:58:22 -0800 (PST)
Date: Sun, 18 Dec 2011 18:58:22 +0100
Message-ID: <CALfKU6N1q4Yq8NiaUhJ3nSqAyJnyani9=njiFT8-VR0CDMRqtQ@mail.gmail.com>
Subject: Problem writting output to a file
From: vicent roca daniel <saptah@gmail.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============0510024272=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============0510024272==
Content-Type: multipart/alternative; boundary=e89a8f2350097e66fc04b461945a

--e89a8f2350097e66fc04b461945a
Content-Type: text/plain; charset=ISO-8859-1

Hi Guys,
First of all, I'm sorry if this is not a libssh2 related question, but I'm
stuck on this error for two day and I'm desperate :(

I'm trying to write the output of a command exectution using libssh2 to a
file: Some code:


/*** definitions, etc...***/

sprintf(filename, "/tmp/.aom/%d-%s.json", epoch, host);
filefinal = fopen(filename, "w");

/* execute the command...*/

char buffer2[1024*4];

    while( (read = libssh2_channel_read( channel, buffer2,
sizeof(buffer2))) != 0 )
    {

        //buffer2[read-1] = '\0';
        fwrite(buffer2, sizeof(char), read, filefinal);

    }

/* closing the file ,etc...*/


The problem here is tha if this loop iterates only one time, I get some
extra data at the end of the file.
I've check that I read and write the same amount of bytes.+

I'm totally lost... any pointers?
Thank you :)

--e89a8f2350097e66fc04b461945a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi Guys,<br>First of all, I&#39;m sorry if this is not a libssh2 related qu=
estion, but I&#39;m stuck on this error for two day and I&#39;m desperate :=
(<br><br>I&#39;m trying to write the output of a command exectution using l=
ibssh2 to a file: Some code:<br>
<br><br>/*** definitions, etc...***/<br><br>sprintf(filename, &quot;/tmp/.a=
om/%d-%s.json&quot;, epoch, host);<br>filefinal =3D fopen(filename, &quot;w=
&quot;);<br><br>/* execute the command...*/<br><br>char buffer2[1024*4];<br=
>
=A0=A0 <br>=A0=A0=A0 while( (read =3D libssh2_channel_read( channel, buffer=
2, sizeof(buffer2))) !=3D 0 )<br>=A0=A0=A0 {<br>=A0=A0=A0 =A0=A0 <br>=A0=A0=
=A0 =A0=A0=A0 //buffer2[read-1] =3D &#39;\0&#39;;<br>=A0=A0=A0 =A0=A0=A0 fw=
rite(buffer2, sizeof(char), read, filefinal);<br>=A0=A0=A0 =A0=A0=A0 <br>
=A0=A0=A0 }<br><br>/* closing the file ,etc...*/<br><br><br>The problem her=
e is tha if this loop iterates only one time, I get some extra data at the =
end of the file.<br>I&#39;ve check that I read and write the same amount of=
 bytes.+<br>
<br>I&#39;m totally lost... any pointers?<br>Thank you :)<br><br>

--e89a8f2350097e66fc04b461945a--

--===============0510024272==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============0510024272==--

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 18 22:07:35 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBIL7D5Q014835;
	Sun, 18 Dec 2011 22:07:28 +0100
Received: from ponderosa.fch.wimsey.bc.ca (zz201111.cipherkey.net
	[209.53.201.111])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBIL7Ag3014820
	for <libssh2-devel@cool.haxx.se>; Sun, 18 Dec 2011 22:07:11 +0100
Received: by coneharvesters.com
	via sendmail with stdio id <m1RcNwo-000l6IC@ponderosa.fch.wimsey.bc.ca>
	for libssh2-devel@cool.haxx.se; Sun, 18 Dec 2011 13:07:06 -0800 (PST)
Date: Sun, 18 Dec 2011 13:07:05 -0800
From: Dan Fandrich <dan@coneharvesters.com>
To: libssh2-devel@cool.haxx.se
Subject: Re: Problem writting output to a file
Message-ID: <20111218210703.GB21852@coneharvesters.com>
Mail-Followup-To: libssh2-devel@cool.haxx.se
References: <CALfKU6N1q4Yq8NiaUhJ3nSqAyJnyani9=njiFT8-VR0CDMRqtQ@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CALfKU6N1q4Yq8NiaUhJ3nSqAyJnyani9=njiFT8-VR0CDMRqtQ@mail.gmail.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="iso-8859-1"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by giant.haxx.se id pBIL7D5Q014835

On Sun, Dec 18, 2011 at 06:58:22PM +0100, vicent roca daniel wrote:
> I'm trying to write the output of a command exectution using libssh2 to a file:
> Some code:
> 
> 
> /*** definitions, etc...***/
> 
> sprintf(filename, "/tmp/.aom/%d-%s.json", epoch, host);
> filefinal = fopen(filename, "w");
> 
> /* execute the command...*/
> 
> char buffer2[1024*4];
>   
>     while( (read = libssh2_channel_read( channel, buffer2, sizeof(buffer2))) !=
> 0 )
>     {
>       
>         //buffer2[read-1] = '\0';
>         fwrite(buffer2, sizeof(char), read, filefinal);
>        
>     }
> 
> /* closing the file ,etc...*/
> 
> 
> The problem here is tha if this loop iterates only one time, I get some extra
> data at the end of the file.
> I've check that I read and write the same amount of bytes.+
> 
> I'm totally lost... any pointers?
> Thank you :)

Note that libssh2_channel_read() can return something other than a size,
namely an error code. I'm not sure what fwrite will do when presented with
a negative size, but it could very well write garbage.

>>> Dan
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Mon Dec 19 15:02:57 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBJE2Wvv011732;
	Mon, 19 Dec 2011 15:02:52 +0100
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBJE2Uhj011547
	for <libssh2-devel@cool.haxx.se>; Mon, 19 Dec 2011 15:02:31 +0100
Received: from int-mx02.intmail.prod.int.phx2.redhat.com
	(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBJE2PVm006490
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <libssh2-devel@cool.haxx.se>; Mon, 19 Dec 2011 09:02:26 -0500
Received: from angien.brq.redhat.com (dhcp-26-234.brq.redhat.com
	[10.34.26.234])
	by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP
	id pBJE2O3v004127; Mon, 19 Dec 2011 09:02:25 -0500
From: Peter Krempa <pkrempa@redhat.com>
To: libssh2-devel@cool.haxx.se
Subject: [PATCH] userauth: Provide more informations if ssh pub key extraction
	fails
Date: Mon, 19 Dec 2011 15:02:15 +0100
Message-Id: <65e59aa2f418490e1f1f834494af3dba4767183d.1324303276.git.pkrempa@redhat.com>
X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12
Cc: Peter Krempa <pkrempa@redhat.com>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

If the function that extracts/computes the public key from a private key
fails the errors it reports were masked by the function calling it. This
patch modifies the key extraction function to return errors using
_libssh_error() function.  The error messages are tweaked to contain
reference to the failed operaton in addition to the reason.

 * AUTHORS: - add my name
 * libgcrypt.c: _libssh2_pub_priv_keyfile(): - return a more verbose
                                               error using
                                               _libssh2_error() func.
 * openssl.c: - modify call graph of _libssh2_pub_priv_keyfile() to use
                _libssh2_error for error reporting();
 * userauth.c: - tweak functions calling _libssh2_pub_priv_keyfile() not
                 to shadow error messages
---
 AUTHORS         |    1 +
 src/libgcrypt.c |    5 +++--
 src/openssl.c   |   42 +++++++++++++++++++++---------------------
 src/userauth.c  |   35 ++++++++++++++++++-----------------
 4 files changed, 43 insertions(+), 40 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 6c4e057..214fca9 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -29,6 +29,7 @@ Mikhail Gusarov
 Neil Gierman
 Olivier Hervieu
 Paul Veldkamp
+Peter Krempa
 Peter O'Gorman
 Peter Stuge
 Romain Bondue
diff --git a/src/libgcrypt.c b/src/libgcrypt.c
index c3be56c..1bda5ee 100644
--- a/src/libgcrypt.c
+++ b/src/libgcrypt.c
@@ -581,8 +581,9 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
                           const char *privatekey,
                           const char *passphrase)
 {
-    return -1; /* not yet supported; interpreted by userauth.c to call
-                  libssh2_error */
+    return _libssh_error(session, LIBSSH2_ERROR_FILE,
+                         "Unable to extract public key from private key file: "
+                         "Method unimplemented in libgcrypt backend");
 }

 void _libssh2_init_aes_ctr(void)
diff --git a/src/openssl.c b/src/openssl.c
index 5fec511..db95b12 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -666,10 +666,9 @@ gen_publickey_from_rsa_evp(LIBSSH2_SESSION *session,
         LIBSSH2_FREE(session, method_buf);
     }

-    _libssh2_error(session,
-                   LIBSSH2_ERROR_ALLOC,
-                   "Unable to allocate memory for private key data");
-    return -1;
+    return _libssh2_error(session,
+                          LIBSSH2_ERROR_ALLOC,
+                          "Unable to allocate memory for private key data");
 }

 static int
@@ -721,10 +720,9 @@ gen_publickey_from_dsa_evp(LIBSSH2_SESSION *session,
         LIBSSH2_FREE(session, method_buf);
     }

-    _libssh2_error(session,
-                   LIBSSH2_ERROR_ALLOC,
-                   "Unable to allocate memory for private key data");
-    return -1;
+    return _libssh2_error(session,
+                          LIBSSH2_ERROR_ALLOC,
+                          "Unable to allocate memory for private key data");
 }

 int
@@ -747,10 +745,10 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,

     bp = BIO_new_file(privatekey, "r");
     if (bp == NULL) {
-        _libssh2_error(session,
-                       LIBSSH2_ERROR_FILE,
-                       "Unable to open private key file");
-        return -1;
+        return _libssh2_error(session,
+                              LIBSSH2_ERROR_FILE,
+                              "Unable to extract public key from private key "
+                              "file: Unable to open private key file");
     }
     if (!EVP_get_cipherbyname("des")) {
         /* If this cipher isn't loaded it's a pretty good indication that none
@@ -765,11 +763,12 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
     BIO_free(bp);

     if (pk == NULL) {
-        _libssh2_error(session,
-                       LIBSSH2_ERROR_FILE,
-                       "Wrong passphrase or invalid/unrecognized "
-                       "private key file format");
-        return -1;
+        return _libssh2_error(session,
+                              LIBSSH2_ERROR_FILE,
+                              "Unable to extract public key "
+                              "from private key file: "
+                              "Wrong passphrase or invalid/unrecognized "
+                              "private key file format");
     }

     switch (pk->type) {
@@ -784,10 +783,11 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
         break;

     default :
-        st = -1;
-        _libssh2_error(session,
-                       LIBSSH2_ERROR_FILE,
-                       "Unsupported private key file format");
+        st = _libssh2_error(session,
+                            LIBSSH2_ERROR_FILE,
+                            "Unable to extract public key "
+                            "from private key file: "
+                            "Unsupported private key file format");
         break;
     }

diff --git a/src/userauth.c b/src/userauth.c
index d74c0c8..3fcb200 100644
--- a/src/userauth.c
+++ b/src/userauth.c
@@ -665,14 +665,14 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
         }
         else {
             /* Compute public key from private key. */
-            if (_libssh2_pub_priv_keyfile(session,
-                                          &session->userauth_host_method,
-                                          &session->userauth_host_method_len,
-                                          &pubkeydata, &pubkeydata_len,
-                                          privatekey, passphrase))
-                return _libssh2_error(session, LIBSSH2_ERROR_FILE,
-                                      "Unable to extract public key "
-                                      "from private key file");
+            rc = _libssh2_pub_priv_keyfile(session,
+                                           &session->userauth_host_method,
+                                           &session->userauth_host_method_len,
+                                           &pubkeydata, &pubkeydata_len,
+                                           privatekey, passphrase);
+            if (rc)
+                /* libssh2_pub_priv_keyfile calls _libssh2_error() */
+                return rc;
         }

         /*
@@ -1237,19 +1237,20 @@ userauth_publickey_fromfile(LIBSSH2_SESSION *session,
             rc = file_read_publickey(session, &session->userauth_pblc_method,
                                      &session->userauth_pblc_method_len,
                                      &pubkeydata, &pubkeydata_len,publickey);
-            if(rc)
+            if (rc)
                 return rc;
         }
         else {
             /* Compute public key from private key. */
-            if (_libssh2_pub_priv_keyfile(session,
-                                          &session->userauth_pblc_method,
-                                          &session->userauth_pblc_method_len,
-                                          &pubkeydata, &pubkeydata_len,
-                                          privatekey, passphrase))
-                return _libssh2_error(session, LIBSSH2_ERROR_FILE,
-                                      "Unable to extract public key "
-                                      "from private key file");
+            rc = _libssh2_pub_priv_keyfile(session,
+                                           &session->userauth_pblc_method,
+                                           &session->userauth_pblc_method_len,
+                                           &pubkeydata, &pubkeydata_len,
+                                           privatekey, passphrase);
+
+            /* _libssh2_pub_priv_keyfile calls _libssh2_error() */
+            if (rc)
+                return rc;
         }
     }

-- 
1.7.3.4

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Mon Dec 19 23:20:10 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBJMJk80021461;
	Mon, 19 Dec 2011 23:20:06 +0100
Received: from giant.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBJMJiOr021454
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT);
	Mon, 19 Dec 2011 23:19:44 +0100
Received: from localhost (dast@localhost)
	by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id pBJMJiS9021450;
	Mon, 19 Dec 2011 23:19:44 +0100
X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs
Date: Mon, 19 Dec 2011 23:19:44 +0100 (CET)
From: Daniel Stenberg <daniel@haxx.se>
X-X-Sender: dast@giant.haxx.se
To: libssh2 development <libssh2-devel@cool.haxx.se>
Subject: Re: [PATCH] userauth: Provide more informations if ssh pub key
	extraction fails
In-Reply-To: <65e59aa2f418490e1f1f834494af3dba4767183d.1324303276.git.pkrempa@redhat.com>
Message-ID: <alpine.DEB.2.00.1112192319200.14095@tvnag.unkk.fr>
References: <65e59aa2f418490e1f1f834494af3dba4767183d.1324303276.git.pkrempa@redhat.com>
User-Agent: Alpine 2.00 (DEB 1167 2008-08-23)
X-fromdanielhimself: yes
MIME-Version: 1.0
Cc: Peter Krempa <pkrempa@redhat.com>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

On Mon, 19 Dec 2011, Peter Krempa wrote:

> If the function that extracts/computes the public key from a private key 
> fails the errors it reports were masked by the function calling it. This 
> patch modifies the key extraction function to return errors using 
> _libssh_error() function.  The error messages are tweaked to contain 
> reference to the failed operaton in addition to the reason.

Great! Pushed now.

-- 

  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Mon Dec 19 23:20:55 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBJMKs1V023413;
	Mon, 19 Dec 2011 23:20:55 +0100
Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBJMKqao023344
	for <libssh2-devel@cool.haxx.se>; Mon, 19 Dec 2011 23:20:53 +0100
Received: from int-mx10.intmail.prod.int.phx2.redhat.com
	(int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBJMKqXM002178
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
	Mon, 19 Dec 2011 17:20:53 -0500
Received: from ashe.local. (vpn1-7-27.ams2.redhat.com [10.36.7.27])
	by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP
	id pBJMKpeR015203; Mon, 19 Dec 2011 17:20:52 -0500
Message-ID: <4EEFB8C3.2070407@redhat.com>
Date: Mon, 19 Dec 2011 23:20:51 +0100
From: Peter Krempa <pkrempa@redhat.com>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:8.0) Gecko/20111105 Thunderbird/8.0
MIME-Version: 1.0
To: Daniel Stenberg <daniel@haxx.se>
Subject: Re: [PATCH] userauth: Provide more informations if ssh pub key
	extraction fails
References: <65e59aa2f418490e1f1f834494af3dba4767183d.1324303276.git.pkrempa@redhat.com>
	<alpine.DEB.2.00.1112192319200.14095@tvnag.unkk.fr>
In-Reply-To: <alpine.DEB.2.00.1112192319200.14095@tvnag.unkk.fr>
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
Cc: libssh2 development <libssh2-devel@cool.haxx.se>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pBJMKs1V023413

DÅˆa 19.12.2011 23:19, Daniel Stenberg  wrote / napÃ­sal(a):
> On Mon, 19 Dec 2011, Peter Krempa wrote:
>
>> If the function that extracts/computes the public key from a private
>> key fails the errors it reports were masked by the function calling
>> it. This patch modifies the key extraction function to return errors
>> using _libssh_error() function. The error messages are tweaked to
>> contain reference to the failed operaton in addition to the reason.
>
> Great! Pushed now.
>
Thanks
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Tue Dec 20 12:07:21 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBKB701A012549;
	Tue, 20 Dec 2011 12:07:17 +0100
Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com
	[209.85.213.182])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBKB6wA6012516
	(version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Tue, 20 Dec 2011 12:06:59 +0100
Received: by yenl9 with SMTP id l9so4621716yen.41
	for <libssh2-devel@cool.haxx.se>; Tue, 20 Dec 2011 03:06:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=mime-version:date:message-id:subject:from:to:content-type;
	bh=iIHptTQ9LGjypleu4egslPKJMVLZwlWdemFe55N8mL0=;
	b=PXyvbj5c1zdA7x9tyZm1+iTeIw02Ikwl+CFQHiaQukerEHp/P34atD+5hE1johGU4A
	AMameSymhsNxbCp8x9/S8w2XvJbYZhg2sgbYuK5GU1euU3erm7xEqiDSMzOW1bLJ9c2H
	kQlIifFwEF4HJ8nfXw8Eyu74BvG4Nm9C0jOZg=
MIME-Version: 1.0
Received: by 10.236.128.138 with SMTP id f10mr2849438yhi.2.1324379213778; Tue,
	20 Dec 2011 03:06:53 -0800 (PST)
Received: by 10.236.173.225 with HTTP; Tue, 20 Dec 2011 03:06:53 -0800 (PST)
Date: Tue, 20 Dec 2011 16:36:53 +0530
Message-ID: <CAEKYpER2Y0JT19XZodxiwFVVcJqQeX3mhdL9NFWgP1hT4uwTTg@mail.gmail.com>
Subject: Muliple libssh2_channel_exec() on the same channel fails
From: anirudh nair <anirudh.anu01@gmail.com>
To: libssh2-devel@cool.haxx.se
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============0346364818=="
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

--===============0346364818==
Content-Type: multipart/alternative; boundary=20cf3005dd9095ce6604b484106c

--20cf3005dd9095ce6604b484106c
Content-Type: text/plain; charset=ISO-8859-1

Hi all,

I'm unable to do multiple libssh2_channel_exec() on the same channel.
The second time I try to execute libssh2_channel_exec() it fails with
error LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED.

Here is the method that does the command execution, it fails on the second
attempt:

http://pastebin.com/LqDcd4eB

Thanks
Anirudh

--20cf3005dd9095ce6604b484106c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi all,<div><br></div><div>I&#39;m unable to do multiple=A0libssh2_channel_=
exec() on the same channel.</div><div>The second time I try to execute=A0li=
bssh2_channel_exec() it fails with error=A0LIBSSH2_ERROR_CHANNEL_REQUEST_DE=
NIED.</div>
<div><br></div><div>Here is the method that does the command execution, it =
fails on the second attempt:=A0</div><div><br></div><div><a href=3D"http://=
pastebin.com/LqDcd4eB">http://pastebin.com/LqDcd4eB</a>
</div><div><br></div><div>Thanks</div><div>Anirudh</div>

--20cf3005dd9095ce6604b484106c--

--===============0346364818==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

--===============0346364818==--

From libssh2-devel-bounces@cool.haxx.se  Tue Dec 20 13:07:04 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBKC6vsW018070;
	Tue, 20 Dec 2011 13:07:03 +0100
Received: from foo.stuge.se (qmailr@foo.stuge.se [212.116.89.98])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with SMTP id pBKC6tHW018061
	for <libssh2-devel@cool.haxx.se>; Tue, 20 Dec 2011 13:06:55 +0100
Received: (qmail 3533 invoked by uid 501); 20 Dec 2011 12:06:55 -0000
Message-ID: <20111220120655.3532.qmail@stuge.se>
Date: Tue, 20 Dec 2011 13:06:55 +0100
From: Peter Stuge <peter@stuge.se>
To: libssh2-devel@cool.haxx.se
Subject: Re: Muliple libssh2_channel_exec() on the same channel fails
Mail-Followup-To: libssh2-devel@cool.haxx.se
References: <CAEKYpER2Y0JT19XZodxiwFVVcJqQeX3mhdL9NFWgP1hT4uwTTg@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CAEKYpER2Y0JT19XZodxiwFVVcJqQeX3mhdL9NFWgP1hT4uwTTg@mail.gmail.com>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

anirudh nair wrote:
> I'm unable to do multiple libssh2_channel_exec() on the same channel.

You can only use a channel one time. Open a new one.


//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Dec 23 04:43:51 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBN3hRdd025705;
	Fri, 23 Dec 2011 04:43:46 +0100
Received: from listserv.isdn4linux.de (listserv.isdn4linux.de [87.106.208.227])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBN3hPqr025700
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 04:43:25 +0100
Received: from fsun.fe.think
	(HSI-KBW-149-172-205-199.hsi13.kabel-badenwuerttemberg.de
	[149.172.205.199]) (authenticated bits=128)
	by listserv.isdn4linux.de (8.14.4/8.14.4) with ESMTP id pBN3hKlF031619
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 04:43:21 +0100
X-Virus-Status: Clean
X-Virus-Scanned: clamav-milter 0.97 at listserv.isdn4linux.de
Received: from [192.168.2.25] (fritz.fe.think [192.168.2.25])
	(authenticated bits=0)
	by fsun.fe.think (8.14.1/8.14.1) with ESMTP id pBN3hKPa013338
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 04:43:20 +0100
Message-ID: <4EF3F8D7.8010608@fritz-elfert.de>
Date: Fri, 23 Dec 2011 04:43:19 +0100
From: Fritz Elfert <fritz@fritz-elfert.de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:8.0) Gecko/20111115 Thunderbird/8.0
MIME-Version: 1.0
To: libssh2-devel@cool.haxx.se
Subject: [PATCH 1/2]  - Added silent build rules
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.3
	(listserv.isdn4linux.de [87.106.208.227]);
	Fri, 23 Dec 2011 04:43:21 +0100 (CET)
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY
	autolearn=ham version=3.3.1-i4l
X-Spam-Checker-Version: SpamAssassin 3.3.1-i4l (2010-03-16) on
	listserv.isdn4linux.de
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

Hi *,
The following adds silent build rules which IMHO make compiler warnings stand-out much better.

Cheers
 -Fritz
---
 configure.ac |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5f94099..37d3f1b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,7 @@ AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_SRCDIR([src])
 AM_CONFIG_HEADER([src/libssh2_config.h example/libssh2_config.h])
 AM_MAINTAINER_MODE
+m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
  dnl SED is needed by some of the tools
 AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
-- 
1.7.6.4

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Dec 23 05:11:59 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBN4BrMK018111;
	Fri, 23 Dec 2011 05:11:59 +0100
Received: from listserv.isdn4linux.de (listserv.isdn4linux.de [87.106.208.227])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBN4Bp8m018102
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 05:11:52 +0100
Received: from fsun.fe.think
	(HSI-KBW-149-172-205-199.hsi13.kabel-badenwuerttemberg.de
	[149.172.205.199]) (authenticated bits=128)
	by listserv.isdn4linux.de (8.14.4/8.14.4) with ESMTP id pBN4BoqT031985
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 05:11:50 +0100
X-Virus-Status: Clean
X-Virus-Scanned: clamav-milter 0.97 at listserv.isdn4linux.de
Received: from [192.168.2.25] (fritz.fe.think [192.168.2.25])
	(authenticated bits=0)
	by fsun.fe.think (8.14.1/8.14.1) with ESMTP id pBN4Bo3b013962
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 05:11:50 +0100
Message-ID: <4EF3FF86.3010501@fritz-elfert.de>
Date: Fri, 23 Dec 2011 05:11:50 +0100
From: Fritz Elfert <fritz@fritz-elfert.de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:8.0) Gecko/20111115 Thunderbird/8.0
MIME-Version: 1.0
To: libssh2-devel@cool.haxx.se
Subject: [PATCH 2/2]  - Expose line number from known_hosts file for better
	error reporting
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.3
	(listserv.isdn4linux.de [87.106.208.227]);
	Fri, 23 Dec 2011 05:11:50 +0100 (CET)
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY
	autolearn=ham version=3.3.1-i4l
X-Spam-Checker-Version: SpamAssassin 3.3.1-i4l (2010-03-16) on
	listserv.isdn4linux.de
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

Hi guys. me again ;)

Here's a patch to expose the line number from reading the known_hosts file.
With this applied, you now can write something like this (like openssh):

int check = libssh2_knownhost_checkp(...., &host);
switch (check) {
    case LIBSSH2_KNOWNHOST_CHECK_MISMATCH:
        ...
      	fprintf(stderr, "Offending key in %s:%d\n", knownhostsfilename, host.linenr + 1);
	...
}

Background:
Im the maintainer of OpenNX (an OSS GUI frontend for nxssh, which is based on openssh) and
currently trying to write a stripped-down replacement for nxssh using libssh2 - mainly
because libssh2's excellent portability. My GUI uses pipes to communicate with the
underlying ssh and if some key mismatch happens, it offers a dialog where the user has
the option to delete the offending line from the known_hosts file. In order to accomplish
that, my GUI needs the line number from the error message...

Cheers
 -Fritz

---
 include/libssh2.h |    3 ++-
 src/knownhost.c   |   29 ++++++++++++++++-------------
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/include/libssh2.h b/include/libssh2.h
index 3395e6a..2aa1830 100644
--- a/include/libssh2.h
+++ b/include/libssh2.h
@@ -807,6 +807,7 @@ struct libssh2_knownhost {
     char *name; /* this is NULL if no plain text host name exists */
     char *key;  /* key in base64/printable format */
     int typemask;
+    int linenr; /* zero-based line number, if read from known_hosts file, -1 otherwise */
 };
  /*
@@ -969,7 +970,7 @@ libssh2_knownhost_free(LIBSSH2_KNOWNHOSTS *hosts);
  */
 LIBSSH2_API int
 libssh2_knownhost_readline(LIBSSH2_KNOWNHOSTS *hosts,
-                           const char *line, size_t len, int type);
+                           const char *line, size_t len, int type, int linenr);
  /*
  * libssh2_knownhost_readfile
diff --git a/src/knownhost.c b/src/knownhost.c
index 193bda3..3952345 100644
--- a/src/knownhost.c
+++ b/src/knownhost.c
@@ -54,6 +54,7 @@ struct known_host {
      /* this is the struct we expose externally */
     struct libssh2_knownhost external;
+    int linenr;      /* line number in known_hosts file */
 };
  struct _LIBSSH2_KNOWNHOSTS
@@ -120,6 +121,7 @@ static struct libssh2_knownhost *knownhost_to_external(struct known_host *node)
                  LIBSSH2_KNOWNHOST_TYPE_PLAIN)? node->name:NULL;
     ext->key = node->key;
     ext->typemask = node->typemask;
+    ext->linenr = node->linenr;
      return ext;
 }
@@ -129,7 +131,7 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
               const char *host, const char *salt,
               const char *key, size_t keylen,
               const char *comment, size_t commentlen,
-              int typemask, struct libssh2_knownhost **store)
+              int typemask, struct libssh2_knownhost **store, int linenr)
 {
     struct known_host *entry;
     size_t hostlen = strlen(host);
@@ -225,6 +227,7 @@ knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
     }
      /* add this new host to the big list of known hosts */
+    entry->linenr = linenr;
     _libssh2_list_add(&hosts->head, &entry->node);
      if(store)
@@ -265,7 +268,7 @@ libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
                       int typemask, struct libssh2_knownhost **store)
 {
     return knownhost_add(hosts, host, salt, key, keylen, NULL, 0, typemask,
-                         store);
+                         store, -1);
 }
  @@ -304,7 +307,7 @@ libssh2_knownhost_addc(LIBSSH2_KNOWNHOSTS *hosts,
                        int typemask, struct libssh2_knownhost **store)
 {
     return knownhost_add(hosts, host, salt, key, keylen, comment, commentlen,
-                         typemask, store);
+                         typemask, store, 1);
 }
  /*
@@ -574,7 +577,7 @@ libssh2_knownhost_free(LIBSSH2_KNOWNHOSTS *hosts)
 static int oldstyle_hostline(LIBSSH2_KNOWNHOSTS *hosts,
                              const char *host, size_t hostlen,
                              const char *key, size_t keylen, int key_type,
-                             const char *comment, size_t commentlen)
+                             const char *comment, size_t commentlen, int linenr)
 {
     int rc = 0;
     size_t namelen = 0;
@@ -610,7 +613,7 @@ static int oldstyle_hostline(LIBSSH2_KNOWNHOSTS *hosts,
             rc = knownhost_add(hosts, hostbuf, NULL, key, keylen,
                                comment, commentlen,
                                key_type | LIBSSH2_KNOWNHOST_TYPE_PLAIN |
-                               LIBSSH2_KNOWNHOST_KEYENC_BASE64, NULL);
+                               LIBSSH2_KNOWNHOST_KEYENC_BASE64, NULL, linenr);
             if(rc)
                 return rc;
 @@ -628,7 +631,7 @@ static int oldstyle_hostline(LIBSSH2_KNOWNHOSTS *hosts,
 static int hashed_hostline(LIBSSH2_KNOWNHOSTS *hosts,
                            const char *host, size_t hostlen,
                            const char *key, size_t keylen, int key_type,
-                           const char *comment, size_t commentlen)
+                           const char *comment, size_t commentlen, int linenr)
 {
     const char *p;
     char saltbuf[32];
@@ -673,7 +676,7 @@ static int hashed_hostline(LIBSSH2_KNOWNHOSTS *hosts,
         return knownhost_add(hosts, hostbuf, salt, key, keylen, comment,
                              commentlen,
                              key_type | LIBSSH2_KNOWNHOST_TYPE_SHA1 |
-                             LIBSSH2_KNOWNHOST_KEYENC_BASE64, NULL);
+                             LIBSSH2_KNOWNHOST_KEYENC_BASE64, NULL, linenr);
     }
     else
         return 0; /* XXX: This should be an error, shouldn't it? */
@@ -691,7 +694,7 @@ static int hashed_hostline(LIBSSH2_KNOWNHOSTS *hosts,
  */
 static int hostline(LIBSSH2_KNOWNHOSTS *hosts,
                     const char *host, size_t hostlen,
-                    const char *key, size_t keylen)
+                    const char *key, size_t keylen, int linenr)
 {
     const char *comment = NULL;
     size_t commentlen = 0;
@@ -775,12 +778,12 @@ static int hostline(LIBSSH2_KNOWNHOSTS *hosts,
            same key
         */
         return oldstyle_hostline(hosts, host, hostlen, key, keylen, key_type,
-                                 comment, commentlen);
+                                 comment, commentlen, linenr);
     }
     else {
         /* |1|[salt]|[hash] */
         return hashed_hostline(hosts, host, hostlen, key, keylen, key_type,
-                               comment, commentlen);
+                               comment, commentlen, linenr);
     }
 }
 @@ -814,7 +817,7 @@ static int hostline(LIBSSH2_KNOWNHOSTS *hosts,
  */
 LIBSSH2_API int
 libssh2_knownhost_readline(LIBSSH2_KNOWNHOSTS *hosts,
-                           const char *line, size_t len, int type)
+                           const char *line, size_t len, int type, int linenr)
 {
     const char *cp;
     const char *hostp;
@@ -877,7 +880,7 @@ libssh2_knownhost_readline(LIBSSH2_KNOWNHOSTS *hosts,
         keylen--; /* don't include this in the count */
      /* deal with this one host+key line */
-    rc = hostline(hosts, hostp, hostlen, keyp, keylen);
+    rc = hostline(hosts, hostp, hostlen, keyp, keylen, linenr);
     if(rc)
         return rc; /* failed */
 @@ -910,7 +913,7 @@ libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts,
     file = fopen(filename, "r");
     if(file) {
         while(fgets(buf, sizeof(buf), file)) {
-            if(libssh2_knownhost_readline(hosts, buf, strlen(buf), type))
+            if(libssh2_knownhost_readline(hosts, buf, strlen(buf), type, num))
                 break;
             num++;
         }
-- 
1.7.6.4

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Fri Dec 23 05:27:32 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBN4RQ4t027672;
	Fri, 23 Dec 2011 05:27:31 +0100
Received: from listserv.isdn4linux.de (listserv.isdn4linux.de [87.106.208.227])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBN4RO6q027669
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 05:27:24 +0100
Received: from fsun.fe.think
	(HSI-KBW-149-172-205-199.hsi13.kabel-badenwuerttemberg.de
	[149.172.205.199]) (authenticated bits=128)
	by listserv.isdn4linux.de (8.14.4/8.14.4) with ESMTP id pBN4RMmq032179
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 05:27:22 +0100
X-Virus-Status: Clean
X-Virus-Scanned: clamav-milter 0.97 at listserv.isdn4linux.de
Received: from [192.168.2.25] (fritz.fe.think [192.168.2.25])
	(authenticated bits=0)
	by fsun.fe.think (8.14.1/8.14.1) with ESMTP id pBN4RMmG014282
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <libssh2-devel@cool.haxx.se>; Fri, 23 Dec 2011 05:27:22 +0100
Message-ID: <4EF4032A.9020008@fritz-elfert.de>
Date: Fri, 23 Dec 2011 05:27:22 +0100
From: Fritz Elfert <fritz@fritz-elfert.de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:8.0) Gecko/20111115 Thunderbird/8.0
MIME-Version: 1.0
To: libssh2 development <libssh2-devel@cool.haxx.se>
Subject: Re: [PATCH 2/2] - Expose line number from known_hosts file for better
	error reporting
References: <4EF3FF86.3010501@fritz-elfert.de>
In-Reply-To: <4EF3FF86.3010501@fritz-elfert.de>
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.3
	(listserv.isdn4linux.de [87.106.208.227]);
	Fri, 23 Dec 2011 05:27:23 +0100 (CET)
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY
	autolearn=ham version=3.3.1-i4l
X-Spam-Checker-Version: SpamAssassin 3.3.1-i4l (2010-03-16) on
	listserv.isdn4linux.de
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

On 12/23/2011 05:11 AM, Fritz Elfert wrote:
> Hi guys. me again ;)
> 
> Here's a patch to expose the line number from reading the known_hosts file.
> With this applied, you now can write something like this (like openssh):
> 
[...]
Just forgot to mention:
This patch changes the API in an incompatible way. If that's undesired,
I probably can come up with a some wrapper macro named
libssh2_knownhost_readline (renaming libssh2_knownhost_readline to
libssh2_knownhost_readline_ex). Not shure, what to do about the
added int in struct libssh2_knownhost though...

Cheers
 -Fritz
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 25 03:10:00 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBP29Vc8021974;
	Sun, 25 Dec 2011 03:09:56 +0100
Received: from listserv.isdn4linux.de (listserv.isdn4linux.de [87.106.208.227])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBP29Tq8021967
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 03:09:29 +0100
Received: from fsun.fe.think
	(HSI-KBW-149-172-205-199.hsi13.kabel-badenwuerttemberg.de
	[149.172.205.199]) (authenticated bits=128)
	by listserv.isdn4linux.de (8.14.4/8.14.4) with ESMTP id pBP29Q1H031783
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 03:09:28 +0100
X-Virus-Status: Clean
X-Virus-Scanned: clamav-milter 0.97 at listserv.isdn4linux.de
Received: from [192.168.2.25] (fritz.fe.think [192.168.2.25])
	(authenticated bits=0)
	by fsun.fe.think (8.14.1/8.14.1) with ESMTP id pBP29Q16009333
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 03:09:26 +0100
Message-ID: <4EF685D6.4070805@fritz-elfert.de>
Date: Sun, 25 Dec 2011 03:09:26 +0100
From: Fritz Elfert <fritz@fritz-elfert.de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:9.0) Gecko/20111222 Thunderbird/9.0
MIME-Version: 1.0
To: libssh2-devel@cool.haxx.se
Subject: Trying to understand keepalive
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.3
	(listserv.isdn4linux.de [87.106.208.227]);
	Sun, 25 Dec 2011 03:09:28 +0100 (CET)
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY
	autolearn=ham version=3.3.1-i4l
X-Spam-Checker-Version: SpamAssassin 3.3.1-i4l (2010-03-16) on
	listserv.isdn4linux.de
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

Hi guys,

Studying the source of libssh2 (current git), I noticed, that while
libssh2 supports sending keepalive messages as well as replying to
keepalives sent from the server, it apparently does *not* act on the
responses from the server even when want_reply is set while invoking
libssh2_keepalive_send(). Searching the ML-archives, I even stumbled
over a Ticket, containing a patch which implements this functionality.
(At least to some degree - compared to openssh).

http://trac.libssh2.org/ticket/183

However that ticket was closed as "outdated".

So am I missing something here?
Or: How am I (as a user of libssh2) supposed to find out, if the server
has properly responded to the keepalive that I just sent?

Please enlighten me...
 -Fritz

PS: Just in case I'm right and libssh2 is missing the necessary code,
I'll be happy to provide another patch (against current git).
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 25 12:59:28 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBPBx3Ju032157;
	Sun, 25 Dec 2011 12:59:24 +0100
Received: from vps1.henriknordstrom.net (vps1.henriknordstrom.net
	[IPv6:2a02:750:7::d0a])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBPBx2qu032133
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 12:59:02 +0100
Received: from henriknordstrom.net (183.159.216.81.static.tb.siw.siwnet.net
	[81.216.159.183])
	by vps1.henriknordstrom.net (8.14.2/8.14.2/Debian-2build1) with ESMTP
	id pBPBx3c0013808
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 11:59:03 GMT
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by henriknordstrom.net (8.12.11.20060308/8.12.8) with ESMTP id
	pBPBwYIa021735
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 12:58:35 +0100
Message-ID: <1324814314.16449.21.camel@henriknordstrom.net>
Subject: Re: Trying to understand keepalive
From: Henrik =?ISO-8859-1?Q?Nordstr=F6m?= <henrik@henriknordstrom.net>
To: libssh2 development <libssh2-devel@cool.haxx.se>
Date: Sun, 25 Dec 2011 12:58:34 +0100
In-Reply-To: <4EF685D6.4070805@fritz-elfert.de>
References: <4EF685D6.4070805@fritz-elfert.de>
X-Mailer: Evolution 3.2.2 (3.2.2-1.fc16) 
Mime-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0
	(vps1.henriknordstrom.net [195.20.207.177]);
	Sun, 25 Dec 2011 11:59:03 +0000 (UTC)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pBPBx3Ju032157

sÃ¶n 2011-12-25 klockan 03:09 +0100 skrev Fritz Elfert:

> Studying the source of libssh2 (current git), I noticed, that while
> libssh2 supports sending keepalive messages as well as replying to
> keepalives sent from the server, it apparently does *not* act on the
> responses from the server even when want_reply is set while invoking
> libssh2_keepalive_send().

The keep-alive implementation in libssh2 is very rudimentary, and not
without problems. Currently it helps keeping an idle connection alive,
but not good for detecting communication issues, and may even cause
additional communication issues if EAGAIN is seen when sending the
keep-alive message.
 
> So am I missing something here?
> Or: How am I (as a user of libssh2) supposed to find out, if the server
> has properly responded to the keepalive that I just sent?

From what I can tell you can't.

There really should be timestamps recording time of last sent, last sent
with want_reply set and last received packet, and keepalive adjusted to
monitor these both for determining if keep-alive is needed and for
detecting session timeout. Technically just one of the last sent
timestamps is sufficient, but to keep the logics of which time to track
for keep-alive isolated within keepalive it's easier if both are
recorded in the session.

It's not really important to track if the received (or sent) packets are
in reply to keep-alive or not. It's sufficient to note that there is
traffic.

I don't know why ticket #183 was closed (Daniel?). Does not look
outdated to me. May even work to some degree. But needs to be improved
slightly to handle want_reply == 0 without timing out the session, and
do not solve a couple of other keep-alive issues.

Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 25 14:48:33 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBPDmGUw015305;
	Sun, 25 Dec 2011 14:48:31 +0100
Received: from listserv.isdn4linux.de (listserv.isdn4linux.de [87.106.208.227])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBPDmENx015288
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 14:48:15 +0100
Received: from fsun.fe.think
	(HSI-KBW-149-172-205-199.hsi13.kabel-badenwuerttemberg.de
	[149.172.205.199]) (authenticated bits=128)
	by listserv.isdn4linux.de (8.14.4/8.14.4) with ESMTP id pBPDmCXC006011
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 14:48:14 +0100
X-Virus-Status: Clean
X-Virus-Scanned: clamav-milter 0.97 at listserv.isdn4linux.de
Received: from [192.168.2.25] (fritz.fe.think [192.168.2.25])
	(authenticated bits=0)
	by fsun.fe.think (8.14.1/8.14.1) with ESMTP id pBPDmCjL018422
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO)
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 14:48:12 +0100
Message-ID: <4EF7299C.7060400@fritz-elfert.de>
Date: Sun, 25 Dec 2011 14:48:12 +0100
From: Fritz Elfert <fritz@fritz-elfert.de>
User-Agent: Mozilla/5.0 (X11; Linux x86_64;
	rv:9.0) Gecko/20111222 Thunderbird/9.0
MIME-Version: 1.0
To: libssh2 development <libssh2-devel@cool.haxx.se>
Subject: Re: Trying to understand keepalive
References: <4EF685D6.4070805@fritz-elfert.de>
	<1324814314.16449.21.camel@henriknordstrom.net>
In-Reply-To: <1324814314.16449.21.camel@henriknordstrom.net>
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.3
	(listserv.isdn4linux.de [87.106.208.227]);
	Sun, 25 Dec 2011 14:48:14 +0100 (CET)
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY
	autolearn=ham version=3.3.1-i4l
X-Spam-Checker-Version: SpamAssassin 3.3.1-i4l (2010-03-16) on
	listserv.isdn4linux.de
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pBPDmGUw015305

On 12/25/2011 12:58 PM, Henrik NordstrÃ¶m wrote:
> sÃ¶n 2011-12-25 klockan 03:09 +0100 skrev Fritz Elfert:
> 
>> Studying the source of libssh2 (current git), I noticed, that while
>> libssh2 supports sending keepalive messages as well as replying to
>> keepalives sent from the server, it apparently does *not* act on the
>> responses from the server even when want_reply is set while invoking
>> libssh2_keepalive_send().
> 
> The keep-alive implementation in libssh2 is very rudimentary, and not
> without problems. Currently it helps keeping an idle connection alive,
> but not good for detecting communication issues, and may even cause
> additional communication issues if EAGAIN is seen when sending the
> keep-alive message.

EAGAIN is silently ignored in libssh2_keepalive_send(). Isn't that correct?

>  
>> So am I missing something here?
>> Or: How am I (as a user of libssh2) supposed to find out, if the server
>> has properly responded to the keepalive that I just sent?
> 
> From what I can tell you can't.
> 
> There really should be timestamps recording time of last sent, last sent
> with want_reply set and last received packet, and keepalive adjusted to
> monitor these both for determining if keep-alive is needed and for
> detecting session timeout. Technically just one of the last sent
> timestamps is sufficient, but to keep the logics of which time to track
> for keep-alive isolated within keepalive it's easier if both are
> recorded in the session.
> 

I see.
Well if you take a look at openssh, they simply maintain a counter
(server_alive_timeouts) which gets incremented when sending a keepalive
and reset to 0 whenever a SSH_MSG_REQUEST_SUCCESS or
SSH_MSG_REQUEST_FAILURE is received. Before sending the keepalive
request, they check this counter against their configurable
server_alive_count_max. Also: They *always* set want_reply to 1 -
Wouldn't make much sense otherwise.

From that, my understanding is that the current implementation of
libssh2 (regrding maintaining a single timestamp of last sent) is
sufficient. The only thing that's missing is the timeouts-counter. Of
course - since want_reply is optional in libssh2 - the counter should
only be incremented if want_reply is set.

> It's not really important to track if the received (or sent) packets are
> in reply to keep-alive or not. It's sufficient to note that there is
> traffic.

Agreed.

Cheers
 -Fritz

> 
> I don't know why ticket #183 was closed (Daniel?). Does not look
> outdated to me. May even work to some degree. But needs to be improved
> slightly to handle want_reply == 0 without timing out the session, and
> do not solve a couple of other keep-alive issues.
> 
> Regards
> Henrik
> 
> _______________________________________________
> libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 25 15:29:21 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBPETCEk008001;
	Sun, 25 Dec 2011 15:29:20 +0100
Received: from foo.stuge.se (qmailr@foo.stuge.se [212.116.89.98])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with SMTP id pBPETBKe007986
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 15:29:11 +0100
Received: (qmail 22006 invoked by uid 501); 25 Dec 2011 14:29:12 -0000
Message-ID: <20111225142912.22005.qmail@stuge.se>
Date: Sun, 25 Dec 2011 15:29:12 +0100
From: Peter Stuge <peter@stuge.se>
To: libssh2-devel@cool.haxx.se
Subject: Re: Trying to understand keepalive
Mail-Followup-To: libssh2-devel@cool.haxx.se
References: <4EF685D6.4070805@fritz-elfert.de>
	<1324814314.16449.21.camel@henriknordstrom.net>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <1324814314.16449.21.camel@henriknordstrom.net>
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pBPETCEk008001

Henrik NordstrÃ¶m wrote:
> I don't know why ticket #183 was closed (Daniel?).

Reopen it.


//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Sun Dec 25 16:57:44 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBPFvOtm029112;
	Sun, 25 Dec 2011 16:57:40 +0100
Received: from vps1.henriknordstrom.net (vps1.henriknordstrom.net
	[IPv6:2a02:750:7::d0a])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBPFvM9x029100
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT)
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 16:57:22 +0100
Received: from henriknordstrom.net (183.159.216.81.static.tb.siw.siwnet.net
	[81.216.159.183])
	by vps1.henriknordstrom.net (8.14.2/8.14.2/Debian-2build1) with ESMTP
	id pBPFvMHe007775
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 15:57:23 GMT
Received: from [127.0.0.1] (localhost [127.0.0.1])
	by henriknordstrom.net (8.12.11.20060308/8.12.8) with ESMTP id
	pBPFurKx015156
	for <libssh2-devel@cool.haxx.se>; Sun, 25 Dec 2011 16:56:54 +0100
Message-ID: <1324828613.7025.9.camel@henriknordstrom.net>
Subject: Re: Trying to understand keepalive
From: Henrik =?ISO-8859-1?Q?Nordstr=F6m?= <henrik@henriknordstrom.net>
To: libssh2 development <libssh2-devel@cool.haxx.se>
Date: Sun, 25 Dec 2011 16:56:53 +0100
In-Reply-To: <4EF7299C.7060400@fritz-elfert.de>
References: <4EF685D6.4070805@fritz-elfert.de>
	<1324814314.16449.21.camel@henriknordstrom.net>
	<4EF7299C.7060400@fritz-elfert.de>
X-Mailer: Evolution 3.2.2 (3.2.2-1.fc16) 
Mime-Version: 1.0
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0
	(vps1.henriknordstrom.net [195.20.207.177]);
	Sun, 25 Dec 2011 15:57:23 +0000 (UTC)
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="utf-8"
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pBPFvOtm029112

sÃ¶n 2011-12-25 klockan 14:48 +0100 skrev Fritz Elfert:

> EAGAIN is silently ignored in libssh2_keepalive_send(). Isn't that correct?

Correct, which fails badly if the keep alive packet itself was what
filled up the last available bits in the transport connection.

> Also: They *always* set want_reply to 1 -
> Wouldn't make much sense otherwise.

Well, we discussed this some time ago. There is some odd use cases for
keep-alive without want_reply.

> From that, my understanding is that the current implementation of
> libssh2 (regrding maintaining a single timestamp of last sent) is
> sufficient. The only thing that's missing is the timeouts-counter. Of
> course - since want_reply is optional in libssh2 - the counter should
> only be incremented if want_reply is set.

I don't really like counter based timeouts, but sure.

Regards
Henrik

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Tue Dec 27 12:20:47 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBRBKMi5015821;
	Tue, 27 Dec 2011 12:20:44 +0100
Received: from earth.stuge.se (earth.stuge.se [212.116.89.126])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBRBKLbD015767
	for <libssh2-devel@cool.haxx.se>; Tue, 27 Dec 2011 12:20:21 +0100
Received: (qmail 15502 invoked from network); 27 Dec 2011 11:20:18 -0000
Received: from unknown (HELO earth.stuge.se) (127.0.0.1)
	by localhost with SMTP; 27 Dec 2011 11:20:18 -0000
MIME-Version: 1.0
From: "libssh2 Trac" <trac@libssh2.stuge.se>
X-Trac-Version: 0.12.3dev
Precedence: bulk
Cc: libssh2-devel@cool.haxx.se
Auto-Submitted: auto-generated
X-Mailer: Trac 0.12.3dev, by Edgewall Software
X-Trac-Project: libssh2
Date: Tue, 27 Dec 2011 11:20:18 -0000
X-URL: http://trac.libssh2.org/
Subject: Re: [libssh2] #183: Check if keepalive reply came in if want_reply
	== 1, set error if not
X-Trac-Ticket-URL: http://trac.libssh2.org/ticket/183#comment:2
Message-ID: <060.52d0af23e5669cf0175aad07842ad713@libssh2.stuge.se>
References: <045.a61a7448b95d2c73c1349ea57071c1a7@libssh2.stuge.se>
X-Trac-Ticket-ID: 183
In-Reply-To: <045.a61a7448b95d2c73c1349ea57071c1a7@libssh2.stuge.se>
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pBRBKLbD015767
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Reply-To: trac@libssh2.stuge.se,
        libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

#183: Check if keepalive reply came in if want_reply == 1, set error if not
--------------------------+----------------------------------
  Reporter:  dringdahl    |      Owner:
      Type:  enhancement  |     Status:  reopened
  Priority:  normal       |  Milestone:  1.2.6
 Component:  misc         |    Version:  1.2.6
Resolution:               |   Keywords:  keepalive want_reply
Blocked By:               |     Blocks:
--------------------------+----------------------------------
Changes (by hno):

 * status:  closed => reopened
 * resolution:  outdated =>


Comment:

 Do not look outdated to me.

-- 
Ticket URL: <http://trac.libssh2.org/ticket/183#comment:2>
libssh2 <http://trac.libssh2.org/>
C library for writing portable SSH2 clients

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

From libssh2-devel-bounces@cool.haxx.se  Thu Dec 29 12:22:52 2011
Return-Path: <libssh2-devel-bounces@cool.haxx.se>
Received: from www.haxx.se (localhost.localdomain [127.0.0.1])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBTBMRgP017539;
	Thu, 29 Dec 2011 12:22:48 +0100
Received: from earth.stuge.se (earth.stuge.se [212.116.89.126])
	by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id pBTBMO2r017404
	for <libssh2-devel@cool.haxx.se>; Thu, 29 Dec 2011 12:22:25 +0100
Received: (qmail 20929 invoked from network); 29 Dec 2011 11:22:22 -0000
Received: from unknown (HELO earth.stuge.se) (127.0.0.1)
	by localhost with SMTP; 29 Dec 2011 11:22:22 -0000
MIME-Version: 1.0
From: "libssh2 Trac" <trac@libssh2.stuge.se>
X-Trac-Version: 0.12.3dev
Precedence: bulk
Cc: libssh2-devel@cool.haxx.se
Auto-Submitted: auto-generated
X-Mailer: Trac 0.12.3dev, by Edgewall Software
X-Trac-Project: libssh2
Date: Thu, 29 Dec 2011 11:22:22 -0000
X-URL: http://trac.libssh2.org/
Subject: Re: [libssh2] #183: Check if keepalive reply came in if want_reply
	== 1, set error if not
X-Trac-Ticket-URL: http://trac.libssh2.org/ticket/183#comment:3
Message-ID: <060.8ac61fa2132de72db85a6949a093d1ef@libssh2.stuge.se>
References: <045.a61a7448b95d2c73c1349ea57071c1a7@libssh2.stuge.se>
X-Trac-Ticket-ID: 183
In-Reply-To: <045.a61a7448b95d2c73c1349ea57071c1a7@libssh2.stuge.se>
X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id pBTBMO2r017404
X-BeenThere: libssh2-devel@cool.haxx.se
X-Mailman-Version: 2.1.14
Reply-To: trac@libssh2.stuge.se,
        libssh2 development <libssh2-devel@cool.haxx.se>
List-Id: libssh2 development <libssh2-devel.cool.haxx.se>
List-Unsubscribe: <http://cool.haxx.se/cgi-bin/mailman/options/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=unsubscribe>
List-Archive: <http://cool.haxx.se/pipermail/libssh2-devel>
List-Post: <mailto:libssh2-devel@cool.haxx.se>
List-Help: <mailto:libssh2-devel-request@cool.haxx.se?subject=help>
List-Subscribe: <http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>, 
	<mailto:libssh2-devel-request@cool.haxx.se?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: libssh2-devel-bounces@cool.haxx.se
Sender: libssh2-devel-bounces@cool.haxx.se

#183: Check if keepalive reply came in if want_reply == 1, set error if not
--------------------------+----------------------------------
  Reporter:  dringdahl    |      Owner:
      Type:  enhancement  |     Status:  reopened
  Priority:  normal       |  Milestone:  1.4.0
 Component:  misc         |    Version:  1.2.6
Resolution:               |   Keywords:  keepalive want_reply
Blocked By:               |     Blocks:
--------------------------+----------------------------------
Changes (by felfert):

 * milestone:  1.2.6 => 1.4.0


Comment:

 I just have attached a patch against current (as of 2011-12-28) GIT which
 resembles openssh's behavior. It adds libssh2_keepalive_config_ex() and
 changes libssh2_keepalive_config() into a macro in order to maintain
 source compatibility. It also contains a man page for the new function.

-- 
Ticket URL: <http://trac.libssh2.org/ticket/183#comment:3>
libssh2 <http://trac.libssh2.org/>
C library for writing portable SSH2 clients

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

