From libssh2-devel-bounces@cool.haxx.se Tue Jan 3 22:37:20 2012 Return-Path: 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 q03LaxYe027550; Tue, 3 Jan 2012 22:37:17 +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 q03LZLS0026923 for ; Tue, 3 Jan 2012 22:35:21 +0100 Received: (qmail 7863 invoked from network); 3 Jan 2012 21:35:17 -0000 Received: from unknown (HELO earth.stuge.se) (127.0.0.1) by localhost with SMTP; 3 Jan 2012 21:35:17 -0000 MIME-Version: 1.0 From: "libssh2 Trac" 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, 03 Jan 2012 21:35:17 -0000 X-URL: http://trac.libssh2.org/ Subject: [libssh2] #233: libssh2 _libssh2_packet_add() in packet.c not responding properly to SSH_MSG_CHANNEL_REQUEST for openssh keepalive X-Trac-Ticket-URL: http://trac.libssh2.org/ticket/233 Message-ID: <044.66311e4933791f7566e3c1ea80fa5175@libssh2.stuge.se> X-Trac-Ticket-ID: 233 X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id q03LZLS0026923 X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Reply-To: trac@libssh2.stuge.se, libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 #233: libssh2 _libssh2_packet_add() in packet.c not responding properly to SSH_MSG_CHANNEL_REQUEST for openssh keepalive ----------------------+-------------------- Reporter: engstrom | Owner: Type: defect | Status: new Priority: normal | Milestone: 1.4.0 Component: protocol | Version: 1.3.0 Keywords: | Blocked By: Blocks: | ----------------------+-------------------- Line 750 of packet.c is handling case SSH_MSG_CHANNEL_REQUEST: When keepalives are configured on an OpenSSH sshd there is no want_reply being sent. According to RFC 4254 a channel request has a default want reply of TRUE but line 754 of packet.c defaults the want reply to FALSE. I changing 754 from: unsigned char want_reply = 0; to: unsigned char want_reply = 1; Fixes the problem. Since the OpenSSH daemon is a very common ssh server then regardless of whether it's correctly interpreting the RFC the libssh2 client library should support the way it send keepalives. Here's the section of the RFC dealing with channel requests - NOTE how it says "If 'want reply' is FALSE, no response will be sent to the request. Otherwise, the recipient responds with either SSH_MSG_CHANNEL_SUCCESS, SSH_MSG_CHANNEL_FAILURE, or request-specific continuation messages" implying that if the want reply isn't sent then the client should respond. : From 5.4. Channel-Specific Requests All channel-specific requests use the following format. byte SSH_MSG_CHANNEL_REQUEST uint32 recipient channel string request type in US-ASCII characters only boolean want reply .... type-specific data follows If 'want reply' is FALSE, no response will be sent to the request. Otherwise, the recipient responds with either SSH_MSG_CHANNEL_SUCCESS, SSH_MSG_CHANNEL_FAILURE, or request-specific continuation messages. If the request is not recognized or is not supported for the channel, SSH_MSG_CHANNEL_FAILURE is returned. -- Ticket URL: libssh2 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 Sat Jan 7 02:38:34 2012 Return-Path: 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 q071aAa8018753; Sat, 7 Jan 2012 02:38:30 +0100 Received: from mail.panic.com (posh.panic.com [38.103.165.4]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q071a8u7018708 for ; Sat, 7 Jan 2012 02:36:09 +0100 Received: from [10.0.0.171] (unknown [38.103.165.36]) by mail.panic.com (Postfix) with ESMTPSA id 2568E31249C9 for ; Fri, 6 Jan 2012 17:36:04 -0800 (PST) From: Dave Hayden Subject: Unable to exchange encryption keys Date: Fri, 6 Jan 2012 17:36:03 -0800 Message-Id: <0D3E2331-3CC0-4D80-9050-5113E4A815DB@panic.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 q071a8u7018708 X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 there! We're using libssh2 in an iOS SSH app and it's been working great--I rarely find myself diving into libssh2 to sort out problems and even more rarely find anything wrong inside libssh2. (I've got a couple of small bugs I've been meaning to file for ages.. Sorry about that, I'll get to it soon!) One odd one popped up yesterday, and it's easy to reproduce: libssh2 can't get past key exchange with the (public) server dante.u.washington.edu. Should I file that in the bug tracker, or would y'all rather have a look at it first? In general, would you rather have patches and bugs here or in the tracker? Also, our top feature request for the app is authentication forwarding. If any of the libssh2 devs knows how that works and wants a consulting gig, please send me an email! Thanks! -Dave _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Sat Jan 7 06:15:47 2012 Return-Path: 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 q075DP92024343; Sat, 7 Jan 2012 06:15:44 +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 q075DNg3024330 for ; Sat, 7 Jan 2012 06:13:23 +0100 Received: (qmail 15328 invoked by uid 501); 7 Jan 2012 05:13:23 -0000 Message-ID: <20120107051323.15327.qmail@stuge.se> Date: Sat, 7 Jan 2012 06:13:23 +0100 From: Peter Stuge To: libssh2-devel@cool.haxx.se Subject: Re: Unable to exchange encryption keys Mail-Followup-To: libssh2-devel@cool.haxx.se References: <0D3E2331-3CC0-4D80-9050-5113E4A815DB@panic.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <0D3E2331-3CC0-4D80-9050-5113E4A815DB@panic.com> X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Dave Hayden wrote: > We're using libssh2 in an iOS SSH app and it's been working > great--I rarely find myself diving into libssh2 to sort out > problems and even more rarely find anything wrong inside libssh2. > (I've got a couple of small bugs I've been meaning to file for > ages.. Sorry about that, I'll get to it soon!) One odd one popped > up yesterday, and it's easy to reproduce: libssh2 can't get past > key exchange with the (public) server dante.u.washington.edu. I'm analyzing this now.. It's strange. One datum I've found is that if the client sends it's identification string too quickly after the TCP connection has been opened, the server will never send anything back. I have also seen stop after KEX. Network tracing in addition disagrees with library tracing. I'm still looking. > Should I file that in the bug tracker, or would y'all rather have a > look at it first? A ping on the list is not a bad start, and if no solution surfaces in a little while, two three days or so, then a ticket is a good way to make sure that nothing gets forgotten. > In general, would you rather have patches and bugs here or in the > tracker? Personally I prefer patches on the mailing list or even better in a git repository that can be pulled from. > Also, our top feature request for the app is authentication > forwarding. If any of the libssh2 devs knows how that works and > wants a consulting gig, please send me an email! Hm, clarify what you need exactly? I guess you want SSH agent forwarding? Do you know if there already exists an SSH agent for iOS? On Linux, Windows and Mac OS X the agent runs as a separate process in the background.. Are you using libssh2 with public key authentication, or always only password? //Peter _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Sat Jan 7 06:57:28 2012 Return-Path: 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 q075tHeC015160; Sat, 7 Jan 2012 06:57:27 +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 q075tFnE015155 for ; Sat, 7 Jan 2012 06:55:15 +0100 Received: (qmail 20891 invoked by uid 501); 7 Jan 2012 05:55:15 -0000 Message-ID: <20120107055515.20890.qmail@stuge.se> Date: Sat, 7 Jan 2012 06:55:15 +0100 From: Peter Stuge To: libssh2-devel@cool.haxx.se Subject: Re: Unable to exchange encryption keys Mail-Followup-To: libssh2-devel@cool.haxx.se References: <0D3E2331-3CC0-4D80-9050-5113E4A815DB@panic.com> <20120107051323.15327.qmail@stuge.se> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120107051323.15327.qmail@stuge.se> X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Peter Stuge wrote: > > libssh2 can't get past key exchange with the (public) server > > dante.u.washington.edu. > > I'm analyzing this now.. It's strange. libssh2 thinks it has sent KEX, but TCP has not yet gotten an ACK for the client identification string. Gut feeling is that the problem is in TCP on the server end.. Not sure if libssh2 should send KEX before the client identification has been ACKed. //Peter _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Sat Jan 7 09:18:07 2012 Return-Path: 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 q078G180026768; Sat, 7 Jan 2012 09:18: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 q078FxZD026760 for ; Sat, 7 Jan 2012 09:15:59 +0100 Received: (qmail 6751 invoked by uid 501); 7 Jan 2012 08:15:59 -0000 Message-ID: <20120107081559.6750.qmail@stuge.se> Date: Sat, 7 Jan 2012 09:15:59 +0100 From: Peter Stuge To: libssh2-devel@cool.haxx.se Subject: Re: Unable to exchange encryption keys Mail-Followup-To: libssh2-devel@cool.haxx.se References: <0D3E2331-3CC0-4D80-9050-5113E4A815DB@panic.com> <20120107051323.15327.qmail@stuge.se> <20120107055515.20890.qmail@stuge.se> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120107055515.20890.qmail@stuge.se> X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Peter Stuge wrote: > > > libssh2 can't get past key exchange with the (public) server > > > dante.u.washington.edu. > > > > I'm analyzing this now.. It's strange. > > libssh2 thinks it has sent KEX, but TCP has not yet gotten an ACK for > the client identification string. > > Gut feeling is that the problem is in TCP on the server end.. > > Not sure if libssh2 should send KEX before the client identification > has been ACKed. I've been comparing TCP packets for a while now, and the only difference I've seen is the client identification string. And indeed: session = libssh2_session_init(); + libssh2_session_banner_set(session, "SSH-2.0-OpenSSH_5.4"); if (libssh2_session_handshake(session, sock)) { ..allows libssh2 to speak with dante without problems. //Peter _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Fri Jan 13 15:08:50 2012 Return-Path: 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 q0DE8MpL025949; Fri, 13 Jan 2012 15:08:45 +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 q0DE8Kj3025939 for ; Fri, 13 Jan 2012 15:08:21 +0100 Received: (qmail 13511 invoked from network); 13 Jan 2012 14:08:18 -0000 Received: from unknown (HELO earth.stuge.se) (127.0.0.1) by localhost with SMTP; 13 Jan 2012 14:08:18 -0000 MIME-Version: 1.0 From: "libssh2 Trac" 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: Fri, 13 Jan 2012 14:08:18 -0000 X-URL: http://trac.libssh2.org/ Subject: [libssh2] #234: Unable to read more than 65536 bytes with libssh2_channel_read function X-Trac-Ticket-URL: http://trac.libssh2.org/ticket/234 Message-ID: <048.ebacebd132aad3e0c12b1fd897cc82b8@libssh2.stuge.se> X-Trac-Ticket-ID: 234 X-MIME-Autoconverted: from base64 to 8bit by giant.haxx.se id q0DE8Kj3025939 X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Reply-To: trac@libssh2.stuge.se, libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 #234: Unable to read more than 65536 bytes with libssh2_channel_read function ----------------------------------+-------------------- Reporter: jagadish0911 | Owner: Type: defect | Status: new Priority: blocker | Milestone: 1.4.0 Component: API | Version: 1.3.0 Keywords: libssh2_channel_read | Blocked By: Blocks: | ----------------------------------+-------------------- Hi, I am using libssh2_channel_read function to read some data into a buffer from SSH channel. I have more than 3 lakhs bytes of data in my buffer. But using the channel I could able to store only 65,536 bytes to the buffer in a single call of the same function. As a result, I am loosing the data from 65,537th byte to the end. How can we solve this issue. Any quick response will be highly appreciated. Thank you, Regards, Jagadish -- Ticket URL: libssh2 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 Sun Jan 15 21:10:06 2012 Return-Path: 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 q0FK9gSb018927; Sun, 15 Jan 2012 21:10:02 +0100 Received: from mail-ww0-f54.google.com (mail-ww0-f54.google.com [74.125.82.54]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0FK9f1F018898 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sun, 15 Jan 2012 21:09:41 +0100 Received: by wgbdy1 with SMTP id dy1so322360wgb.11 for ; Sun, 15 Jan 2012 12:09:36 -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=rIzkYJqmi/h0X3yJm+myTMpfYHSOwWi5S+GDkHn+FUc=; b=vn5llqmWiw0JQlneCrs3hvyIYCNXTseKGC3SDYth9ZElJyYvJbmoekBgObE/XA1U5J u/zugQTWDweLYSCKEtrZCilj//NJ7xjLCtaWuQVcASzrTjmGGUfhsanXeScc2sX/RP7L XTM0ati0pNcELNi0nic6UhSzx7VuSviFuSOsU= MIME-Version: 1.0 Received: by 10.180.86.5 with SMTP id l5mr14980519wiz.17.1326658176507; Sun, 15 Jan 2012 12:09:36 -0800 (PST) Received: by 10.180.81.68 with HTTP; Sun, 15 Jan 2012 12:09:36 -0800 (PST) Date: Mon, 16 Jan 2012 00:09:36 +0400 Message-ID: Subject: How to get about command execution finished on remote side From: Ivan Tretyakov To: libssh2-devel@cool.haxx.se Content-Type: multipart/mixed; boundary=f46d0443068659605e04b696ad59 X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libssh2-devel-bounces@cool.haxx.se Sender: libssh2-devel-bounces@cool.haxx.se --f46d0443068659605e04b696ad59 Content-Type: multipart/alternative; boundary=f46d0443068659605b04b696ad57 --f46d0443068659605b04b696ad57 Content-Type: text/plain; charset=ISO-8859-1 Hello! I try to write a small simple ssh client program to learn how to work with libssh2. I have the next code: ... /* Request a shell */ channel = libssh2_channel_open_session(session); if (!channel) { fprintf(stderr, "Unable to open a session\n"); return (EXIT_FAILURE); } /* Request a terminal with 'vanilla' terminal emulation */ rc = libssh2_channel_request_pty(channel, "vanilla"); if (rc) { fprintf(stderr, "Failed requesting pty\n"); return (EXIT_FAILURE); } /* Open a SHELL on that pty */ rc = libssh2_channel_shell(channel); if (rc) { fprintf(stderr, "Unable to request shell on allocated pty\n"); return (EXIT_FAILURE); } /* Main loop starts here. * In it you will be requested to input a command * command will be executed at remote side * an you will get output from it */ do { /* Request for command input */ printf("$ "); fgets(command, BUFSIZ, stdin); printf("Command is %s", command); if (strcmp(command, "\n") == 0) { printf("Empty command\n"); continue; } /* Write command to stdin of remote shell */ rc = libssh2_channel_write(channel, command, strlen(command)); printf("Channel write return value is %d\n", rc); /* Read output from remote side */ rc = libssh2_channel_read(channel, inputbuf, BUFSIZ); printf("Channel write return value is %d\n", rc); printf("Remote side output:\n %s\n", inputbuf); } while (strcmp(command, EXIT_COMMAND) != 0); /* Main loop ends here */ ... The problem is that I get the output of the current command only when executing the next one. How should I know that execution of the current command is finished on remote side and I can use lbssh2_channel_read to read it? The whole program it attachment. Thank you BR Ivan Tretyakov --f46d0443068659605b04b696ad57 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello!

I try to write a small simple ssh client program = to learn how to work with libssh2.
I have the next code:

...
/* Request a shell */
chann= el =3D libssh2_channel_open_session(session);
if (!channel) {
fprintf(stde= rr, "Unable to open a session\n");
retu= rn (EXIT_FAILURE);
}

/* Request a terminal with 'vanilla= ' terminal emulation */
rc = =3D libssh2_channel_request_pty(channel, "vanilla");
if (rc) {
fprintf(s= tderr, "Failed requesting pty\n");
return (EXIT_FAILURE);
<= div> }

= /* Open a SHELL on that pty */
rc =3D libssh2_channel_shell(channel)= ;
if (r= c) {
<= /span>fprintf(stderr, "Unable to request shell on allocated pty\n"= ;);
retu= rn (EXIT_FAILURE);
}

/* Main loop starts here.
* In= it you will be requested to input a command
* command will be executed at= remote side
* an= you will get output from it */
do {
/* Request for command input */
prin= tf("$ ");
fgets(command, BUFSIZ, stdin);
printf("Command= is %s", command);
if (= strcmp(command, "\n") =3D=3D 0) {
printf("Empty command\n&= quot;);
con= tinue;
= }

/* Write command to stdin of remote shell */
rc = =3D libssh2_channel_write(channel, command, strlen(command));
printf("= ;Channel write return value is %d\n", rc);

/* Read output from remote side */
rc =3D libssh2_channel_read(= channel, inputbuf, BUFSIZ);
prin= tf("Channel write return value is %d\n", rc);
printf("Remot= e side output:\n %s\n", inputbuf);

} while (strcmp(command, EXIT_COMMAND) !=3D 0);
/* Main loop ends= here */
...

The problem is that I get the outpu= t of the current command only when executing the next one. How should I kno= w that execution of the current command is finished on remote side and I ca= n use lbssh2_channel_read to read it?

The whole program it attachment.

Thank you

BR
Ivan Tretyakov

--f46d0443068659605b04b696ad57-- --f46d0443068659605e04b696ad59 Content-Type: text/x-csrc; charset=US-ASCII; name="SmallSimpleSSH.c" Content-Disposition: attachment; filename="SmallSimpleSSH.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gxghyxzr0 LyoKID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT0KIE5hbWUJCSA6IFNtYWxsU2ltcGxlU1NILmMKIEF1dGhv cgkJIDogS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UgKHN0cmNtcChjb21tYW5kLCBFWElUX0NP TU1BTkQpICE9IDApOwoJLyogTWFpbiBsb29wIGVuZHMgaGVyZSAqLwoKCS8qIERlLWluaXQgYW5k IHByZS1leGl0IGFjdGlvbnMgKi8KCWlmIChjaGFubmVsKSB7CgkJbGlic3NoMl9jaGFubmVsX2Zy ZWUoY2hhbm5lbCk7CgkJY2hhbm5lbCA9IE5VTEw7Cgl9CgoJcmMgPSBsaWJzc2gyX3Nlc3Npb25f ZGlzY29ubmVjdChzZXNzaW9uLCAiTm9ybWFsIFNodXRkb3duIik7CglpZiAocmMpIHsKCQlmcHJp bnRmKHN0ZGVyciwgIlNlc3Npb24gZGlzY29ubmVjdCBlcnJvclxuIik7CgkJcmV0dXJuIChFWElU X0ZBSUxVUkUpOwoJfSBlbHNlCgkJcHJpbnRmKCJTZXNzaW9uIGZpbmlzaGVkIHN1Y2Nlc3NmdWxc biIpOwoKCWxpYnNzaDJfc2Vzc2lvbl9mcmVlKHNlc3Npb24pOwoKCWNsb3NlKHNvY2spOwoKCWxp YnNzaDJfZXhpdCgpOwoKCXJldHVybiAoRVhJVF9TVUNDRVNTKTsKfQo= --f46d0443068659605e04b696ad59 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 --f46d0443068659605e04b696ad59-- From libssh2-devel-bounces@cool.haxx.se Sun Jan 15 21:23:35 2012 Return-Path: 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 q0FKNVDF030257; Sun, 15 Jan 2012 21:23:34 +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 q0FKNTwM030239 for ; Sun, 15 Jan 2012 21:23:29 +0100 Received: (qmail 17977 invoked by uid 501); 15 Jan 2012 20:23:31 -0000 Message-ID: <20120115202331.17976.qmail@stuge.se> Date: Sun, 15 Jan 2012 21:23:31 +0100 From: Peter Stuge To: libssh2-devel@cool.haxx.se Subject: Re: How to get about command execution finished on remote side Mail-Followup-To: libssh2-devel@cool.haxx.se References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Ivan Tretyakov wrote: > How should I know that execution of the current command is finished > on remote side and I can use lbssh2_channel_read to read it? You don't know. SSH channels are full duplex, not half duplex. You must deal with that in your application, if the particular channel you are working with does not by policy use only half duplex. //Peter _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Sun Jan 15 21:57:59 2012 Return-Path: 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 q0FKvpRW026414; Sun, 15 Jan 2012 21:57:58 +0100 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0FKvnaV026346 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sun, 15 Jan 2012 21:57:50 +0100 Received: by wibhq12 with SMTP id hq12so415787wib.41 for ; Sun, 15 Jan 2012 12:57:46 -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=GSZ/vlY3+HCjDz9lFaaMHQUO1YuhGMRdpCd1i2TGGkk=; b=nfcDAlJ/fMJWuo0V6/KpFmUVea+Ay+VIBaZEcXH8TctTjZEDtOso30eniULHoe4JwS SnpuH1eGOF05DUU4R8pQNyt/XtQGUQBpRWdMGMw/9NKK4IIKNLaU5yAOq7/J98eP/9Gz iio4pJEWSvW03WzC59Xl133wyBs8k4fRtl16w= MIME-Version: 1.0 Received: by 10.180.103.97 with SMTP id fv1mr8862577wib.17.1326661066205; Sun, 15 Jan 2012 12:57:46 -0800 (PST) Received: by 10.180.81.68 with HTTP; Sun, 15 Jan 2012 12:57:45 -0800 (PST) In-Reply-To: <20120115202331.17976.qmail@stuge.se> References: <20120115202331.17976.qmail@stuge.se> Date: Mon, 16 Jan 2012 00:57:45 +0400 Message-ID: Subject: Re: How to get about command execution finished on remote side From: Ivan Tretyakov To: libssh2 development X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0882218616==" Errors-To: libssh2-devel-bounces@cool.haxx.se Sender: libssh2-devel-bounces@cool.haxx.se --===============0882218616== Content-Type: multipart/alternative; boundary=f46d0444eab796a9d304b69759cc --f46d0444eab796a9d304b69759cc Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable Thank you! I'll think about it, but at the moment it's not clear to me how do I implement a simple ssh client. It's clear how to execute a separate command (using libssh2_channel_exec and it's possible to use it to implement a shell), but not clear how to interact with a remote shell when I use libssh2_channel_shell and want to execute commands remotely. In my mind it's a good to have such example at web-site example section. //Ivan 2012/1/16 Peter Stuge > Ivan Tretyakov wrote: > > How should I know that execution of the current command is finished > > on remote side and I can use lbssh2_channel_read to read it? > > You don't know. SSH channels are full duplex, not half duplex. You > must deal with that in your application, if the particular channel > you are working with does not by policy use only half duplex. > > > //Peter > _______________________________________________ > libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel > --=20 =F3 =D5=D7=C1=D6=C5=CE=C9=C5=CD, =F4=D2=C5=D4=D8=D1=CB=CF=D7 =E9.=F7. --f46d0444eab796a9d304b69759cc Content-Type: text/html; charset=KOI8-R Content-Transfer-Encoding: quoted-printable Thank you!

I'll think about it, but at the moment it= 's not clear to me how do I implement a simple ssh client.
It= 's clear how to execute a separate command (using libssh2_channel_exec = and it's possible to use it to implement a shell), but not clear how to= interact with a remote shell when I use libssh2_channel_shell and want to = execute commands remotely.
In my mind it's a good to have such example at web-site example se= ction.

//Ivan


2012/1/16 Peter Stuge <peter@stuge.se>
Ivan Tretyakov wrote:
> How should I know that execution of the current command is finished > on remote side and I can use lbssh2_channel_read to read it?

You don't know. SSH channels are full duplex, not half duplex. You
must deal with that in your application, if the particular channel
you are working with does not by policy use only half duplex.


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



--
=F3 =D5=D7= =C1=D6=C5=CE=C9=C5=CD,
=F4=D2=C5=D4=D8=D1=CB=CF=D7 =E9.=F7.

--f46d0444eab796a9d304b69759cc-- --===============0882218616== 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 --===============0882218616==-- From libssh2-devel-bounces@cool.haxx.se Sun Jan 15 22:31:00 2012 Return-Path: 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 q0FLUkmG023117; Sun, 15 Jan 2012 22:30:58 +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 q0FLUiM0023109 for ; Sun, 15 Jan 2012 22:30:44 +0100 Received: (qmail 22924 invoked by uid 501); 15 Jan 2012 21:30:46 -0000 Message-ID: <20120115213046.22923.qmail@stuge.se> Date: Sun, 15 Jan 2012 22:30:46 +0100 From: Peter Stuge To: libssh2-devel@cool.haxx.se Subject: Re: How to get about command execution finished on remote side Mail-Followup-To: libssh2-devel@cool.haxx.se References: <20120115202331.17976.qmail@stuge.se> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Ivan Tretyakov wrote: > I'll think about it, but at the moment it's not clear to me how do I > implement a simple ssh client. Maybe doing that is not so simple. > how to interact with a remote shell when I use libssh2_channel_shell > and want to execute commands remotely. So you need to study how to do full duplex communication in C. > In my mind it's a good to have such example at web-site example section. Feel free to send a perfect patch with such an example. I don't think anyone would be against adding it to the repo! There is already at least one example demonstrating the same concept however; look at examples/direct-tcpip.c //Peter _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Sun Jan 15 22:40:33 2012 Return-Path: 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 q0FLeUjo029979; Sun, 15 Jan 2012 22:40:33 +0100 Received: from mail-ww0-f54.google.com (mail-ww0-f54.google.com [74.125.82.54]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0FLeS1F029937 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sun, 15 Jan 2012 22:40:29 +0100 Received: by wgbdy1 with SMTP id dy1so361039wgb.11 for ; Sun, 15 Jan 2012 13:40:25 -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=+bn4aIGmKxyRjGvsvi1UbZGlwDLumY+lGZ1JoBZHls0=; b=ZQ03BoBwKe6UIrvKR8eMIV+KQbeoNDW/VOvVJsyMAR5Hih4w92TNegbkUnKLEtsyXW A/lY75QzW4EVruQ+nb3R+UaOA3BYqUaik+sFqD7WtZ4l7ZTiZSh8s1gY0iqGcYOvATOW xX8lYLSXL2xvokNhCOAvRb2qZC1rX8uf+UcrA= MIME-Version: 1.0 Received: by 10.180.104.4 with SMTP id ga4mr1843433wib.17.1326663625278; Sun, 15 Jan 2012 13:40:25 -0800 (PST) Received: by 10.180.81.68 with HTTP; Sun, 15 Jan 2012 13:40:25 -0800 (PST) In-Reply-To: <20120115213046.22923.qmail@stuge.se> References: <20120115202331.17976.qmail@stuge.se> <20120115213046.22923.qmail@stuge.se> Date: Mon, 16 Jan 2012 01:40:25 +0400 Message-ID: Subject: Re: How to get about command execution finished on remote side From: Ivan Tretyakov To: libssh2 development X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0338580192==" Errors-To: libssh2-devel-bounces@cool.haxx.se Sender: libssh2-devel-bounces@cool.haxx.se --===============0338580192== Content-Type: multipart/alternative; boundary=f46d044271821f067604b697f220 --f46d044271821f067604b697f220 Content-Type: text/plain; charset=ISO-8859-1 2012/1/16 Peter Stuge > Ivan Tretyakov wrote: > > I'll think about it, but at the moment it's not clear to me how do I > > implement a simple ssh client. > > Maybe doing that is not so simple. > > > > how to interact with a remote shell when I use libssh2_channel_shell > > and want to execute commands remotely. > > So you need to study how to do full duplex communication in C. > > > > In my mind it's a good to have such example at web-site example section. > > Feel free to send a perfect patch with such an example. I don't think > anyone would be against adding it to the repo! > > There is already at least one example demonstrating the same concept > however; look at examples/direct-tcpip.c > > > //Peter > _______________________________________________ > libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel > Thank you again! If I'll get success with that I'll send you my example. //Ivan --f46d044271821f067604b697f220 Content-Type: text/html; charset=ISO-8859-1
2012/1/16 Peter Stuge <peter@stuge.se>
Ivan Tretyakov wrote:
> I'll think about it, but at the moment it's not clear to me how do I
> implement a simple ssh client.

Maybe doing that is not so simple.


> how to interact with a remote shell when I use libssh2_channel_shell
> and want to execute commands remotely.

So you need to study how to do full duplex communication in C.


> In my mind it's a good to have such example at web-site example section.

Feel free to send a perfect patch with such an example. I don't think
anyone would be against adding it to the repo!

There is already at least one example demonstrating the same concept
however; look at examples/direct-tcpip.c


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

Thank you again! If I'll get success with that I'll send you my example.

//Ivan

--f46d044271821f067604b697f220-- --===============0338580192== 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 --===============0338580192==-- From libssh2-devel-bounces@cool.haxx.se Tue Jan 17 22:35:35 2012 Return-Path: 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 q0HLZ7Q9003750; Tue, 17 Jan 2012 22:35:30 +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 q0HLZ4Nb003135 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Tue, 17 Jan 2012 22:35:05 +0100 Received: by iagz16 with SMTP id z16so7327550iag.41 for ; Tue, 17 Jan 2012 13:34:59 -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=PiVflZ/ihTODZeAhiJImPHiz8I/xOTfjE4YhYSBkg8A=; b=CqmfuQXQjS8HObWYtjhAOWCnG3mWVgm6sfQhjDulozsLSkK6uxkIwZn77qS/WgwSSC ZHsHBTaDOOl51LiU9ZHq2OAR1S5zY+ChSEDFYheBZQV6odlKM8nfg71LeHB5mvBiwXYu 3C4PW0X2t+kufvquceDnCYp4NkZ/htvsbnKq8= MIME-Version: 1.0 Received: by 10.50.17.195 with SMTP id q3mr19442094igd.11.1326836099317; Tue, 17 Jan 2012 13:34:59 -0800 (PST) Received: by 10.42.239.198 with HTTP; Tue, 17 Jan 2012 13:34:59 -0800 (PST) Date: Tue, 17 Jan 2012 16:34:59 -0500 Message-ID: Subject: PK authentication from memory From: Joe Turpin 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 List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 all, I'm trying to do what this poster describes here: http://www.libssh2.org/mail/libssh2-devel-archive-2011-04/0004.shtml I don't see a solution in that thread and was wondering if there has been any progress on that front? Thanks, Joe _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Wed Jan 18 17:47:07 2012 Return-Path: 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 q0IGkeRQ011138; Wed, 18 Jan 2012 17:47:01 +0100 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0IGkdW7011086 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 18 Jan 2012 17:46:39 +0100 Received: by wibhq12 with SMTP id hq12so3372431wib.41 for ; Wed, 18 Jan 2012 08:46:33 -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=N53LRbjHQd0iB6OJYcUhKmNV1IRZF+VIO9m8T9hM21Y=; b=U4LyhTm2L3E8lLC4COetFgoOEv9xgaQcfqOd2t7yM6m0RKHauCQhRpIzP91fknv3mG AzBxHeQB4ufCNeOAwofNN5HpfJMQdWg9Yjli4OhX0fpX9CI/UmPW+DaPpxPoKQVo0lUT 2PNiWIAiKHQ/Gq4P1yri8GZmE4hNaN0J7hfe8= MIME-Version: 1.0 Received: by 10.180.81.72 with SMTP id y8mr37930158wix.14.1326905193851; Wed, 18 Jan 2012 08:46:33 -0800 (PST) Received: by 10.180.81.68 with HTTP; Wed, 18 Jan 2012 08:46:33 -0800 (PST) In-Reply-To: <20120115213046.22923.qmail@stuge.se> References: <20120115202331.17976.qmail@stuge.se> <20120115213046.22923.qmail@stuge.se> Date: Wed, 18 Jan 2012 20:46:33 +0400 Message-ID: Subject: Re: How to get about command execution finished on remote side From: Ivan Tretyakov To: libssh2 development Content-Type: multipart/mixed; boundary=f46d04428cf4baec5804b6d030af X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libssh2-devel-bounces@cool.haxx.se Sender: libssh2-devel-bounces@cool.haxx.se --f46d04428cf4baec5804b6d030af Content-Type: multipart/alternative; boundary=f46d04428cf4baec5504b6d030ad --f46d04428cf4baec5504b6d030ad Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: quoted-printable Hello again! I've finished my small simple ssh client. The source code is attached. Of course it's not perfect and printing command two times, but it still simple and working. Do you want me to send it in another format like patch for example? Or, I suppose, the part of it can be added into current examples replacing words: "At this point the shell can be interacted with using * libssh2_channel_read() ..." I will be happy to see your comments and fix anything accordingly. Another question, what is the best way to send signals to remote side? Thank you! //Ivan 2012/1/16 Peter Stuge > Ivan Tretyakov wrote: > > I'll think about it, but at the moment it's not clear to me how do I > > implement a simple ssh client. > > Maybe doing that is not so simple. > > > > how to interact with a remote shell when I use libssh2_channel_shell > > and want to execute commands remotely. > > So you need to study how to do full duplex communication in C. > > > > In my mind it's a good to have such example at web-site example section= . > > Feel free to send a perfect patch with such an example. I don't think > anyone would be against adding it to the repo! > > There is already at least one example demonstrating the same concept > however; look at examples/direct-tcpip.c > > > //Peter > _______________________________________________ > libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel > --=20 =F3 =D5=D7=C1=D6=C5=CE=C9=C5=CD, =F4=D2=C5=D4=D8=D1=CB=CF=D7 =E9.=F7. --f46d04428cf4baec5504b6d030ad Content-Type: text/html; charset=KOI8-R Content-Transfer-Encoding: quoted-printable Hello again!

I've finished my small simple ssh clien= t. The source code is attached.
Of course it's not perfect an= d printing command two times, but it still simple and working.=9A
Do you want me to send it in another format like patch for example?=9A
Or, I suppose, the part of it can be added into current examples repl= acing words:=9A
"At this point the shell can be interacted w= ith using=9A =9A* libssh2_channel_read() ..."
I will be happy to see your comments and fix anything=9Aaccordingly.

Another question, what is the best way to send sign= als to remote side?

Thank you!

//Ivan

2012/1/16 Peter Stuge <peter@stuge.se>
Ivan Tretyakov wrote:
> I'll think about it, but at the moment it's not clear to me ho= w do I
> implement a simple ssh client.

Maybe doing that is not so simple.


> how to interact with a remote shell when I use libssh2_channel_shell > and want to execute commands remotely.

So you need to study how to do full duplex communication in C.


> In my mind it's a good to have such example at web-site example se= ction.

Feel free to send a perfect patch with such an example. I don't think anyone would be against adding it to the repo!

There is already at least one example demonstrating the same concept
however; look at examples/direct-tcpip.c


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



--
=F3 =D5=D7= =C1=D6=C5=CE=C9=C5=CD,
=F4=D2=C5=D4=D8=D1=CB=CF=D7 =E9.=F7.

--f46d04428cf4baec5504b6d030ad-- --f46d04428cf4baec5804b6d030af Content-Type: text/x-csrc; charset=US-ASCII; name="SmallSimpleSSH.c" Content-Disposition: attachment; filename="SmallSimpleSSH.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gxkkvt8h0 LyoKID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT0KIE5hbWUgICAgICAgIDogU21hbGxTaW1wbGVTU0guYwog QXV0aG9yICAgICAgOiBJdmFuIFRyZXR5YWtvdgogVmVyc2lvbiAgICAgOiAwLjEKIENvcHlyaWdo dCAgIDogR1BMdjMKIERlc2NyaXB0aW9uIDogTGlic3NoMiBzc2ggY2xpZW50IGV4YW1wbGUKID09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT0KICovCgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxp Yi5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDxsaWJzc2gyLmg+CiNpbmNsdWRlIDxz eXMvdHlwZXMuaD4KI2luY2x1ZGUgPHN5cy9zb2NrZXQuaD4KI2luY2x1ZGUgPGFycGEvaW5ldC5o PgojaW5jbHVkZSA8cG9sbC5oPgojaW5jbHVkZSA8ZmNudGwuaD4KCiNkZWZpbmUgRVhJVF9DT01N QU5ECSJleGl0XG4iCgovKiBNYWluIGZ1bmN0aW9uICovCmludCBtYWluKGludCBhcmdjLCBjaGFy ICphcmd2W10pIHsKCgljb25zdCBjaGFyICp1c2VybmFtZTsKCWNvbnN0IGNoYXIgKnBhc3N3b3Jk OwoJY29uc3QgY2hhciAqaG9zdGFkZHI7CglpbnQgcmM7CglpbnQgc29jazsKCWludCB3cml0dGVu OwoJc3RydWN0IHNvY2thZGRyX2luIHNpbjsKCUxJQlNTSDJfU0VTU0lPTiAqc2Vzc2lvb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lZShzZXNzaW9uKTsKCglj bG9zZShzb2NrKTsKCglsaWJzc2gyX2V4aXQoKTsKCglyZXR1cm4gKEVYSVRfU1VDQ0VTUyk7Cn0K --f46d04428cf4baec5804b6d030af 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 --f46d04428cf4baec5804b6d030af-- From libssh2-devel-bounces@cool.haxx.se Wed Jan 18 23:55:33 2012 Return-Path: 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 q0IMtC9R012184; Wed, 18 Jan 2012 23:55:30 +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 q0IMt9Us012155 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 18 Jan 2012 23:55:10 +0100 Received: by iagz16 with SMTP id z16so9514510iag.41 for ; Wed, 18 Jan 2012 14:55:05 -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=QvKdTbQknIZOCh2+DQBMm+KFDzJHHrsoip0hPpJhEzY=; b=GbZfd1ekNKNa1JCF42fOFpP9Y+pzI0UWukmevZMBZRDPdGT+MWJUMyV5ChZczoop87 xJlosf6axtQzN4ZUtXWUhAb+kBbkzpHdA2p7QGnNDgLqtVVG81F3a0KPCNsAB6JOba9i GpcsyeACAjTk1+fd2+tqDvrZBu21AADDD0VkQ= MIME-Version: 1.0 Received: by 10.50.180.233 with SMTP id dr9mr21917495igc.11.1326927305588; Wed, 18 Jan 2012 14:55:05 -0800 (PST) Received: by 10.42.239.198 with HTTP; Wed, 18 Jan 2012 14:55:05 -0800 (PST) In-Reply-To: References: Date: Wed, 18 Jan 2012 17:55:05 -0500 Message-ID: Subject: Re: PK authentication from memory From: Joe Turpin 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 List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Tue, Jan 17, 2012 at 4:34 PM, Joe Turpin wrote: > Hi all, > I'm trying to do what this poster describes here: > http://www.libssh2.org/mail/libssh2-devel-archive-2011-04/0004.shtml > > I don't see a solution in that thread and was wondering if there has > been any progress on that front? > > Thanks, > Joe Okay, since I didn't hear from anyone I decided to code something up. I exported another function called libssh2_userauth_publickey_frommemory. If anyone's interested, here's a patch that should apply cleanly against libssh2 1.3.0. I may have missed some things in my haste, but I tested and it works. Comments and criticism are welcome. Index: libssh2-1.3.0/include/libssh2.h =================================================================== --- libssh2-1.3.0/include/libssh2.h +++ libssh2-1.3.0/include/libssh2.h @@ -513,6 +513,16 @@ const char *privatekey, const char *passphrase); +LIBSSH2_API int +libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session, + const char *username, + unsigned int username_len, + const char *publickeyfiledata, + size_t publickeyfiledata_len, + const char *privatekeyfiledata, + size_t privatekeyfiledata_len, + const char *passphrase); + #define libssh2_userauth_publickey_fromfile(session, username, publickey, \ privatekey, passphrase) \ libssh2_userauth_publickey_fromfile_ex((session), (username), \ Index: libssh2-1.3.0/src/hostkey.c =================================================================== --- libssh2-1.3.0/src/hostkey.c +++ libssh2-1.3.0/src/hostkey.c @@ -131,6 +131,36 @@ } /* + * hostkey_method_ssh_rsa_initPEMFromMemory + * + * Load a Private Key from a memory + */ +static int +hostkey_method_ssh_rsa_initPEMFromMemory(LIBSSH2_SESSION * session, + const char *privkeyfiledata, + size_t privkeyfiledata_len, + unsigned const char *passphrase, + void **abstract) +{ + libssh2_rsa_ctx *rsactx; + int ret; + + if (*abstract) { + hostkey_method_ssh_rsa_dtor(session, abstract); + *abstract = NULL; + } + + ret = _libssh2_rsa_new_private_frommemory(&rsactx, session, privkeyfiledata, privkeyfiledata_len, passphrase); + if (ret) { + return -1; + } + + *abstract = rsactx; + + return 0; +} + +/* * hostkey_method_ssh_rsa_sign * * Verify signature created by remote @@ -208,6 +238,7 @@ MD5_DIGEST_LENGTH, hostkey_method_ssh_rsa_init, hostkey_method_ssh_rsa_initPEM, + hostkey_method_ssh_rsa_initPEMFromMemory, hostkey_method_ssh_rsa_sig_verify, hostkey_method_ssh_rsa_signv, NULL, /* encrypt */ @@ -306,6 +337,36 @@ } /* + * hostkey_method_ssh_dss_initPEMFromMemory + * + * Load a Private Key from memory + */ +static int +hostkey_method_ssh_dss_initPEMFromMemory(LIBSSH2_SESSION * session, + const char *privkeyfiledata, + size_t privkeyfiledata_len, + unsigned const char *passphrase, + void **abstract) +{ + libssh2_dsa_ctx *dsactx; + int ret; + + if (*abstract) { + hostkey_method_ssh_dss_dtor(session, abstract); + *abstract = NULL; + } + + ret = _libssh2_dsa_new_private_frommemory(&dsactx, session, privkeyfiledata, privkeyfiledata_len, passphrase); + if (ret) { + return -1; + } + + *abstract = dsactx; + + return 0; +} + +/* * libssh2_hostkey_method_ssh_dss_sign * * Verify signature created by remote @@ -392,6 +453,7 @@ MD5_DIGEST_LENGTH, hostkey_method_ssh_dss_init, hostkey_method_ssh_dss_initPEM, + hostkey_method_ssh_dss_initPEMFromMemory, hostkey_method_ssh_dss_sig_verify, hostkey_method_ssh_dss_signv, NULL, /* encrypt */ Index: libssh2-1.3.0/src/userauth.c =================================================================== --- libssh2-1.3.0/src/userauth.c +++ libssh2-1.3.0/src/userauth.c @@ -441,6 +441,79 @@ return rc; } +static int +memory_read_publickey(LIBSSH2_SESSION * session, unsigned char **method, + size_t *method_len, + unsigned char **pubkeydata, + size_t *pubkeydata_len, + const char *pubkeyfiledata, + size_t pubkeyfiledata_len) +{ + char c; + unsigned char *pubkey = NULL, *sp1, *sp2, *tmp; + size_t pubkey_len = pubkeyfiledata_len; + unsigned int tmp_len; + + if (pubkeyfiledata_len <= 1) { + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Invalid data in public key file"); + } + + pubkey = LIBSSH2_ALLOC(session, pubkeyfiledata_len); + if (!pubkey) { + return _libssh2_error(session, LIBSSH2_ERROR_ALLOC, + "Unable to allocate memory for public key data"); + } + if (memcpy_s(pubkey, pubkeyfiledata_len, pubkeyfiledata, pubkeyfiledata_len) != 0) { + LIBSSH2_FREE(session, pubkey); + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Unable to read public key from file"); + } + + /* + * Remove trailing whitespace + */ + while (pubkey_len && isspace(pubkey[pubkey_len - 1])) + pubkey_len--; + + if (!pubkey_len) { + LIBSSH2_FREE(session, pubkey); + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Missing public key data"); + } + + if ((sp1 = memchr(pubkey, ' ', pubkey_len)) == NULL) { + LIBSSH2_FREE(session, pubkey); + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Invalid public key data"); + } + + sp1++; + + if ((sp2 = memchr(sp1, ' ', pubkey_len - (sp1 - pubkey - 1))) == NULL) { + /* Assume that the id string is missing, but that it's okay */ + sp2 = pubkey + pubkey_len; + } + + if (libssh2_base64_decode(session, (char **) &tmp, &tmp_len, + (char *) sp1, sp2 - sp1)) { + LIBSSH2_FREE(session, pubkey); + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Invalid key data, not base64 encoded"); + } + + /* Wasting some bytes here (okay, more than some), but since it's likely + * to be freed soon anyway, we'll just avoid the extra free/alloc and call + * it a wash */ + *method = pubkey; + *method_len = sp1 - pubkey - 1; + + *pubkeydata = tmp; + *pubkeydata_len = tmp_len; + + return 0; +} + /* * file_read_publickey * @@ -543,8 +616,43 @@ return 0; } +static int +memory_read_privatekey(LIBSSH2_SESSION * session, + const LIBSSH2_HOSTKEY_METHOD ** hostkey_method, + void **hostkey_abstract, + const unsigned char *method, int method_len, + const char *privkeyfiledata, size_t privkeyfiledata_len, + const char *passphrase) +{ + const LIBSSH2_HOSTKEY_METHOD **hostkey_methods_avail = + libssh2_hostkey_methods(); + *hostkey_method = NULL; + *hostkey_abstract = NULL; + while (*hostkey_methods_avail && (*hostkey_methods_avail)->name) { + if ((*hostkey_methods_avail)->initPEMFromMemory + && strncmp((*hostkey_methods_avail)->name, (const char *) method, + method_len) == 0) { + *hostkey_method = *hostkey_methods_avail; + break; + } + hostkey_methods_avail++; + } + if (!*hostkey_method) { + return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE, + "No handler for specified private key"); + } + if ((*hostkey_method)-> + initPEMFromMemory(session, privkeyfiledata, privkeyfiledata_len, (unsigned char *) passphrase, + hostkey_abstract)) { + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Unable to initialize private key from file"); + } + + return 0; +} + /* libssh2_file_read_privatekey * Read a PEM encoded private key from an id_??? style file */ @@ -586,12 +694,49 @@ return 0; } + struct privkey_file { const char *filename; const char *passphrase; }; static int +sign_frommemory(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, + const unsigned char *data, size_t data_len, void **abstract) +{ + struct privkey_file *pk_file = (struct privkey_file *) (*abstract); + const LIBSSH2_HOSTKEY_METHOD *privkeyobj; + void *hostkey_abstract; + struct iovec datavec; + int rc; + + rc = memory_read_privatekey(session, &privkeyobj, &hostkey_abstract, + session->userauth_pblc_method, + session->userauth_pblc_method_len, + pk_file->filename, + strlen(pk_file->filename), + pk_file->passphrase); + if(rc) + return rc; + + datavec.iov_base = (void *)data; + datavec.iov_len = data_len; + + if (privkeyobj->signv(session, sig, sig_len, 1, &datavec, + &hostkey_abstract)) { + if (privkeyobj->dtor) { + privkeyobj->dtor(session, abstract); + } + return -1; + } + + if (privkeyobj->dtor) { + privkeyobj->dtor(session, &hostkey_abstract); + } + return 0; +} + +static int sign_fromfile(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, const unsigned char *data, size_t data_len, void **abstract) { @@ -1212,6 +1357,59 @@ } /* + * userauth_publickey_frommemory + * Authenticate using a keypair from memory + */ +static int +userauth_publickey_frommemory(LIBSSH2_SESSION *session, + const char *username, + size_t username_len, + const char *publickey, + size_t publickey_len, + const char *privatekey, + size_t privatekey_len, + const char *passphrase) +{ + unsigned char *pubkeydata = NULL; + size_t pubkeydata_len = 0; + struct privkey_file privkey_file; + void *abstract = &privkey_file; + int rc; + + privkey_file.filename = privatekey; + privkey_file.passphrase = passphrase; + + if (session->userauth_pblc_state == libssh2_NB_state_idle) { + if (publickey) { + rc = memory_read_publickey(session, &session->userauth_pblc_method, + &session->userauth_pblc_method_len, + &pubkeydata, &pubkeydata_len, publickey, publickey_len); + 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_userauth_publickey(session, username, username_len, + pubkeydata, pubkeydata_len, + sign_frommemory, &abstract); + if(pubkeydata) + LIBSSH2_FREE(session, pubkeydata); + + return rc; +} + +/* * userauth_publickey_fromfile * Authenticate using a keypair found in the named files */ @@ -1262,6 +1460,34 @@ return rc; } +/* libssh2_userauth_publickey_frommemory + * Authenticate using a keypair from memory + */ +LIBSSH2_API int +libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session, + const char *user, + unsigned int user_len, + const char *publickeyfiledata, + size_t publickeyfiledata_len, + const char *privatekeyfiledata, + size_t privatekeyfiledata_len, + const char *passphrase) +{ + int rc; + + if(NULL == passphrase) + /* if given a NULL pointer, make it point to a zero-length + string to save us from having to check this all over */ + passphrase=""; + + BLOCK_ADJUST(rc, session, + userauth_publickey_frommemory(session, user, user_len, + publickeyfiledata, publickeyfiledata_len, + privatekeyfiledata, privatekeyfiledata_len, + passphrase)); + return rc; +} + /* libssh2_userauth_publickey_fromfile_ex * Authenticate using a keypair found in the named files */ Index: libssh2-1.3.0/src/libssh2_priv.h =================================================================== --- libssh2-1.3.0/src/libssh2_priv.h +++ libssh2-1.3.0/src/libssh2_priv.h @@ -849,6 +849,9 @@ size_t hostkey_data_len, void **abstract); int (*initPEM) (LIBSSH2_SESSION * session, const char *privkeyfile, unsigned const char *passphrase, void **abstract); + int (*initPEMFromMemory) (LIBSSH2_SESSION * session, + const char *privkeyfiledata, size_t privkeyfiledata_len, + unsigned const char *passphrase, void **abstract); int (*sig_verify) (LIBSSH2_SESSION * session, const unsigned char *sig, size_t sig_len, const unsigned char *m, size_t m_len, void **abstract); Index: libssh2-1.3.0/src/openssl.c =================================================================== --- libssh2-1.3.0/src/openssl.c +++ libssh2-1.3.0/src/openssl.c @@ -370,7 +370,27 @@ typedef void * (*pem_read_bio_func)(BIO *, void **, pem_password_cb *, void * u); +static int +read_private_key_from_memory(void ** key_ctx, + pem_read_bio_func read_private_key, + const char * filedata, + size_t filedata_len, + unsigned const char *passphrase) +{ + BIO * bp; + *key_ctx = NULL; + + bp = BIO_new_mem_buf(filedata, filedata_len); + if (!bp) { + return -1; + } + *key_ctx = read_private_key(bp, NULL, (pem_password_cb *) passphrase_cb, (void *) passphrase); + + BIO_free(bp); + return (*key_ctx) ? 0 : -1; +} + static int read_private_key_from_file(void ** key_ctx, pem_read_bio_func read_private_key, @@ -394,6 +414,22 @@ } int +_libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx ** rsa, + LIBSSH2_SESSION * session, + const char *filedata, size_t filedata_len, + unsigned const char *passphrase) +{ + pem_read_bio_func read_rsa = + (pem_read_bio_func) &PEM_read_bio_RSAPrivateKey; + (void) session; + + _libssh2_init_if_needed (); + + return read_private_key_from_memory((void **) rsa, read_rsa, + filedata, filedata_len, passphrase); +} + +int _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa, LIBSSH2_SESSION * session, const char *filename, unsigned const char *passphrase) @@ -410,6 +446,22 @@ #if LIBSSH2_DSA int +_libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx ** dsa, + LIBSSH2_SESSION * session, + const char *filedata, size_t filedata_len, + unsigned const char *passphrase) +{ + pem_read_bio_func read_dsa = + (pem_read_bio_func) &PEM_read_bio_DSAPrivateKey; + (void) session; + + _libssh2_init_if_needed (); + + return read_private_key_from_memory((void **) dsa, read_dsa, + filedata, filedata_len, passphrase); +} + +int _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa, LIBSSH2_SESSION * session, const char *filename, unsigned const char *passphrase) _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Thu Jan 19 09:52:30 2012 Return-Path: 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 q0J8q7e4022272; Thu, 19 Jan 2012 09:52:26 +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 q0J8q6Um022247 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 19 Jan 2012 09:52:06 +0100 Received: from localhost (dast@localhost) by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id q0J8q5Qk022243 for ; Thu, 19 Jan 2012 09:52:05 +0100 X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs Date: Thu, 19 Jan 2012 09:52:05 +0100 (CET) From: Daniel Stenberg X-X-Sender: dast@giant.haxx.se To: libssh2 development Subject: Re: PK authentication from memory In-Reply-To: Message-ID: References: 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 List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Wed, 18 Jan 2012, Joe Turpin wrote: > Okay, since I didn't hear from anyone I decided to code something up. I > exported another function called libssh2_userauth_publickey_frommemory. If > anyone's interested, here's a patch that should apply cleanly against > libssh2 1.3.0. > > I may have missed some things in my haste, but I tested and it works. > Comments and criticism are welcome. Lovely! My nits: o - it would be nicer if you commit your change in your local git and enter a proper commit message and then 'git format-patch' and send that here as that makes it even simpler for us to merge... o - there are C99/C++ comments in there, we aim for C89 portability so they need to be fixed - I don't see the point in providing a chunk of commented code anyway. o - there's no documentation for the new function, please also provide a man page for it. You should be able to find lots of inspiration and syntax to copy from the already existing ones. -- / daniel.haxx.se _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Thu Jan 19 19:01:55 2012 Return-Path: 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 q0JI1bja009287; Thu, 19 Jan 2012 19:01:51 +0100 Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0JI1Y8i009005 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Thu, 19 Jan 2012 19:01:35 +0100 Received: by qcse1 with SMTP id e1so134465qcs.41 for ; Thu, 19 Jan 2012 10:01:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=XAjbffIeCif1XoPy1XW/aZQtSU7olPFGftaQ5XkxbbI=; b=m95IUVbR8VmA0TR5oc1P6p5yTEuqb3KCVI7RXwLgEaLxOtnVloG7F0gUOt0a2xSBC7 oqneWrKtX9V31A2ei6OZp9VLjrguViaa02g9yRWce9t5ZyWfGhKBLCe0+y7en/XuA2sN KfM1l4xFQKCYkury767frr8nsDvDh8OFt7Brg= Received: by 10.229.78.209 with SMTP id m17mr11091740qck.80.1326996089957; Thu, 19 Jan 2012 10:01:29 -0800 (PST) Received: from localhost (41333086.cst.lightpath.net. [65.51.48.134]) by mx.google.com with ESMTPS id q14sm1201776qap.4.2012.01.19.10.01.27 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Jan 2012 10:01:28 -0800 (PST) From: Joe Turpin To: libssh2-devel@cool.haxx.se Subject: [PATCH] userauth: Allow authentication keys to be passed in memory Date: Thu, 19 Jan 2012 13:00:07 -0500 Message-Id: <1326996007-1220-1-git-send-email-joe.turpin@gmail.com> X-Mailer: git-send-email 1.7.8.msysgit.0 In-Reply-To: References: Cc: Joe Turpin X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Add a new user authentication API function that allows the client to pass a buffer containting the contents of the authentication key files. --- docs/libssh2_userauth_publickey_frommemory.3 | 55 ++++++ include/libssh2.h | 10 + src/hostkey.c | 62 +++++++ src/libssh2_priv.h | 3 + src/openssl.c | 119 +++++++++++++ src/userauth.c | 230 ++++++++++++++++++++++++++ 6 files changed, 479 insertions(+), 0 deletions(-) create mode 100644 docs/libssh2_userauth_publickey_frommemory.3 diff --git a/docs/libssh2_userauth_publickey_frommemory.3 b/docs/libssh2_userauth_publickey_frommemory.3 new file mode 100644 index 0000000..02e2601 --- /dev/null +++ b/docs/libssh2_userauth_publickey_frommemory.3 @@ -0,0 +1,55 @@ +.TH libssh2_userauth_publickey_frommemory 3 "18 Jan 2012" "libssh2 1.3" "libssh2 manual" +.SH NAME +libssh2_userauth_publickey_frommemory - authenticate a session with a public key, read from memory +.SH SYNOPSIS +#include + +.nf +int libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session, + const char *username, + unsigned int username_len, + const char *publickeydata, + size_t publickeydata_len + const char *privatekeydata, + size_t privatekeydata_len + const char *passphrase); +.SH DESCRIPTION +\fIsession\fP - Session instance as returned by +.BR libssh2_session_init_ex(3) + +\fIusername\fP - Remote user name to authenticate as. + +\fIusername_len\fP - Length of username. + +\fIpublickeydata\fP - Buffer containing the contents of a public key file. + +\fIpublickeydata_len\fP - Length of public key data. + +\fIprivatekeydata\fP - Buffer containing the contents of a private key file. + +\fIprivatekeydata_len\fP - Length of private key data. + +\fIpassphrase\fP - Passphrase to use when decoding private key file. + +Attempt public key authentication using a PEM encoded private key file stored in memory + +.SH RETURN VALUE +Return 0 on success or negative on failure. It returns +LIBSSH2_ERROR_EAGAIN when it would otherwise block. While +LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se. + +.SH ERRORS +\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed. + +\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket. + +\fILIBSSH2_ERROR_SOCKET_TIMEOUT\fP - + +\fILIBSSH2_ERROR_PUBLICKEY_UNVERIFIED\fP - The username/public key +combination was invalid. + +\fILIBSSH2_ERROR_AUTHENTICATION_FAILED\fP - Authentication using the supplied +public key was not accepted. + +.SH SEE ALSO +.BR libssh2_session_init_ex(3) diff --git a/include/libssh2.h b/include/libssh2.h index 3395e6a..8190ac4 100644 --- a/include/libssh2.h +++ b/include/libssh2.h @@ -528,6 +528,16 @@ libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session, const char *privatekey, const char *passphrase); +LIBSSH2_API int +libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session, + const char *username, + unsigned int username_len, + const char *publickeyfiledata, + size_t publickeyfiledata_len, + const char *privatekeyfiledata, + size_t privatekeyfiledata_len, + const char *passphrase); + #define libssh2_userauth_publickey_fromfile(session, username, publickey, \ privatekey, passphrase) \ libssh2_userauth_publickey_fromfile_ex((session), (username), \ diff --git a/src/hostkey.c b/src/hostkey.c index 53f7479..7da7ade 100644 --- a/src/hostkey.c +++ b/src/hostkey.c @@ -131,6 +131,36 @@ hostkey_method_ssh_rsa_initPEM(LIBSSH2_SESSION * session, } /* + * hostkey_method_ssh_rsa_initPEMFromMemory + * + * Load a Private Key from a memory + */ +static int +hostkey_method_ssh_rsa_initPEMFromMemory(LIBSSH2_SESSION * session, + const char *privkeyfiledata, + size_t privkeyfiledata_len, + unsigned const char *passphrase, + void **abstract) +{ + libssh2_rsa_ctx *rsactx; + int ret; + + if (*abstract) { + hostkey_method_ssh_rsa_dtor(session, abstract); + *abstract = NULL; + } + + ret = _libssh2_rsa_new_private_frommemory(&rsactx, session, privkeyfiledata, privkeyfiledata_len, passphrase); + if (ret) { + return -1; + } + + *abstract = rsactx; + + return 0; +} + +/* * hostkey_method_ssh_rsa_sign * * Verify signature created by remote @@ -208,6 +238,7 @@ static const LIBSSH2_HOSTKEY_METHOD hostkey_method_ssh_rsa = { MD5_DIGEST_LENGTH, hostkey_method_ssh_rsa_init, hostkey_method_ssh_rsa_initPEM, + hostkey_method_ssh_rsa_initPEMFromMemory, hostkey_method_ssh_rsa_sig_verify, hostkey_method_ssh_rsa_signv, NULL, /* encrypt */ @@ -306,6 +337,36 @@ hostkey_method_ssh_dss_initPEM(LIBSSH2_SESSION * session, } /* + * hostkey_method_ssh_dss_initPEMFromMemory + * + * Load a Private Key from memory + */ +static int +hostkey_method_ssh_dss_initPEMFromMemory(LIBSSH2_SESSION * session, + const char *privkeyfiledata, + size_t privkeyfiledata_len, + unsigned const char *passphrase, + void **abstract) +{ + libssh2_dsa_ctx *dsactx; + int ret; + + if (*abstract) { + hostkey_method_ssh_dss_dtor(session, abstract); + *abstract = NULL; + } + + ret = _libssh2_dsa_new_private_frommemory(&dsactx, session, privkeyfiledata, privkeyfiledata_len, passphrase); + if (ret) { + return -1; + } + + *abstract = dsactx; + + return 0; +} + +/* * libssh2_hostkey_method_ssh_dss_sign * * Verify signature created by remote @@ -392,6 +453,7 @@ static const LIBSSH2_HOSTKEY_METHOD hostkey_method_ssh_dss = { MD5_DIGEST_LENGTH, hostkey_method_ssh_dss_init, hostkey_method_ssh_dss_initPEM, + hostkey_method_ssh_dss_initPEMFromMemory, hostkey_method_ssh_dss_sig_verify, hostkey_method_ssh_dss_signv, NULL, /* encrypt */ diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index c670a16..059b9b7 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -853,6 +853,9 @@ struct _LIBSSH2_HOSTKEY_METHOD size_t hostkey_data_len, void **abstract); int (*initPEM) (LIBSSH2_SESSION * session, const char *privkeyfile, unsigned const char *passphrase, void **abstract); + int (*initPEMFromMemory) (LIBSSH2_SESSION * session, + const char *privkeyfiledata, size_t privkeyfiledata_len, + unsigned const char *passphrase, void **abstract); int (*sig_verify) (LIBSSH2_SESSION * session, const unsigned char *sig, size_t sig_len, const unsigned char *m, size_t m_len, void **abstract); diff --git a/src/openssl.c b/src/openssl.c index db95b12..96a62fb 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -380,6 +380,26 @@ passphrase_cb(char *buf, int size, int rwflag, char *passphrase) typedef void * (*pem_read_bio_func)(BIO *, void **, pem_password_cb *, void * u); +static int +read_private_key_from_memory(void ** key_ctx, + pem_read_bio_func read_private_key, + const char * filedata, + size_t filedata_len, + unsigned const char *passphrase) +{ + BIO * bp; + + *key_ctx = NULL; + + bp = BIO_new_mem_buf(filedata, filedata_len); + if (!bp) { + return -1; + } + *key_ctx = read_private_key(bp, NULL, (pem_password_cb *) passphrase_cb, (void *) passphrase); + + BIO_free(bp); + return (*key_ctx) ? 0 : -1; +} static int read_private_key_from_file(void ** key_ctx, @@ -404,6 +424,22 @@ read_private_key_from_file(void ** key_ctx, } int +_libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx ** rsa, + LIBSSH2_SESSION * session, + const char *filedata, size_t filedata_len, + unsigned const char *passphrase) +{ + pem_read_bio_func read_rsa = + (pem_read_bio_func) &PEM_read_bio_RSAPrivateKey; + (void) session; + + _libssh2_init_if_needed (); + + return read_private_key_from_memory((void **) rsa, read_rsa, + filedata, filedata_len, passphrase); +} + +int _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa, LIBSSH2_SESSION * session, const char *filename, unsigned const char *passphrase) @@ -420,6 +456,22 @@ _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa, #if LIBSSH2_DSA int +_libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx ** dsa, + LIBSSH2_SESSION * session, + const char *filedata, size_t filedata_len, + unsigned const char *passphrase) +{ + pem_read_bio_func read_dsa = + (pem_read_bio_func) &PEM_read_bio_DSAPrivateKey; + (void) session; + + _libssh2_init_if_needed (); + + return read_private_key_from_memory((void **) dsa, read_dsa, + filedata, filedata_len, passphrase); +} + +int _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa, LIBSSH2_SESSION * session, const char *filename, unsigned const char *passphrase) @@ -795,4 +847,71 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session, return st; } +int +_libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session, + unsigned char **method, + size_t *method_len, + unsigned char **pubkeydata, + size_t *pubkeydata_len, + const char *privatekeydata, + size_t privatekeydata_len, + const char *passphrase) +{ + int st; + BIO* bp; + EVP_PKEY* pk; + + _libssh2_debug(session, + LIBSSH2_TRACE_AUTH, + "Computing public key from private key."); + + bp = BIO_new_mem_buf(privatekeydata, privatekeydata_len); + if (!bp) { + return -1; + } + if (!EVP_get_cipherbyname("des")) { + /* If this cipher isn't loaded it's a pretty good indication that none + * are. I have *NO DOUBT* that there's a better way to deal with this + * ($#&%#$(%$#( Someone buy me an OpenSSL manual and I'll read up on + * it. + */ + OpenSSL_add_all_ciphers(); + } + BIO_reset(bp); + pk = PEM_read_bio_PrivateKey(bp, NULL, NULL, (void*)passphrase); + BIO_free(bp); + + if (pk == NULL) { + 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) { + case EVP_PKEY_RSA : + st = gen_publickey_from_rsa_evp( + session, method, method_len, pubkeydata, pubkeydata_len, pk); + break; + + case EVP_PKEY_DSA : + st = gen_publickey_from_dsa_evp( + session, method, method_len, pubkeydata, pubkeydata_len, pk); + break; + + default : + st = _libssh2_error(session, + LIBSSH2_ERROR_FILE, + "Unable to extract public key " + "from private key file: " + "Unsupported private key file format"); + break; + } + + EVP_PKEY_free(pk); + return st; +} + #endif /* !LIBSSH2_LIBGCRYPT */ diff --git a/src/userauth.c b/src/userauth.c index 3fcb200..7c5a91e 100644 --- a/src/userauth.c +++ b/src/userauth.c @@ -441,6 +441,79 @@ libssh2_userauth_password_ex(LIBSSH2_SESSION *session, const char *username, return rc; } +static int +memory_read_publickey(LIBSSH2_SESSION * session, unsigned char **method, + size_t *method_len, + unsigned char **pubkeydata, + size_t *pubkeydata_len, + const char *pubkeyfiledata, + size_t pubkeyfiledata_len) +{ + char c; + unsigned char *pubkey = NULL, *sp1, *sp2, *tmp; + size_t pubkey_len = pubkeyfiledata_len; + unsigned int tmp_len; + + if (pubkeyfiledata_len <= 1) { + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Invalid data in public key file"); + } + + pubkey = LIBSSH2_ALLOC(session, pubkeyfiledata_len); + if (!pubkey) { + return _libssh2_error(session, LIBSSH2_ERROR_ALLOC, + "Unable to allocate memory for public key data"); + } + if (memcpy_s(pubkey, pubkeyfiledata_len, pubkeyfiledata, pubkeyfiledata_len) != 0) { + LIBSSH2_FREE(session, pubkey); + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Unable to read public key from file"); + } + + /* + * Remove trailing whitespace + */ + while (pubkey_len && isspace(pubkey[pubkey_len - 1])) + pubkey_len--; + + if (!pubkey_len) { + LIBSSH2_FREE(session, pubkey); + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Missing public key data"); + } + + if ((sp1 = memchr(pubkey, ' ', pubkey_len)) == NULL) { + LIBSSH2_FREE(session, pubkey); + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Invalid public key data"); + } + + sp1++; + + if ((sp2 = memchr(sp1, ' ', pubkey_len - (sp1 - pubkey - 1))) == NULL) { + /* Assume that the id string is missing, but that it's okay */ + sp2 = pubkey + pubkey_len; + } + + if (libssh2_base64_decode(session, (char **) &tmp, &tmp_len, + (char *) sp1, sp2 - sp1)) { + LIBSSH2_FREE(session, pubkey); + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Invalid key data, not base64 encoded"); + } + + /* Wasting some bytes here (okay, more than some), but since it's likely + * to be freed soon anyway, we'll just avoid the extra free/alloc and call + * it a wash */ + *method = pubkey; + *method_len = sp1 - pubkey - 1; + + *pubkeydata = tmp; + *pubkeydata_len = tmp_len; + + return 0; +} + /* * file_read_publickey * @@ -543,7 +616,42 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method, return 0; } +static int +memory_read_privatekey(LIBSSH2_SESSION * session, + const LIBSSH2_HOSTKEY_METHOD ** hostkey_method, + void **hostkey_abstract, + const unsigned char *method, int method_len, + const char *privkeyfiledata, size_t privkeyfiledata_len, + const char *passphrase) +{ + const LIBSSH2_HOSTKEY_METHOD **hostkey_methods_avail = + libssh2_hostkey_methods(); + + *hostkey_method = NULL; + *hostkey_abstract = NULL; + while (*hostkey_methods_avail && (*hostkey_methods_avail)->name) { + if ((*hostkey_methods_avail)->initPEMFromMemory + && strncmp((*hostkey_methods_avail)->name, (const char *) method, + method_len) == 0) { + *hostkey_method = *hostkey_methods_avail; + break; + } + hostkey_methods_avail++; + } + if (!*hostkey_method) { + return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NONE, + "No handler for specified private key"); + } + + if ((*hostkey_method)-> + initPEMFromMemory(session, privkeyfiledata, privkeyfiledata_len, (unsigned char *) passphrase, + hostkey_abstract)) { + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Unable to initialize private key from file"); + } + return 0; +} /* libssh2_file_read_privatekey * Read a PEM encoded private key from an id_??? style file @@ -586,12 +694,49 @@ file_read_privatekey(LIBSSH2_SESSION * session, return 0; } + struct privkey_file { const char *filename; const char *passphrase; }; static int +sign_frommemory(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, + const unsigned char *data, size_t data_len, void **abstract) +{ + struct privkey_file *pk_file = (struct privkey_file *) (*abstract); + const LIBSSH2_HOSTKEY_METHOD *privkeyobj; + void *hostkey_abstract; + struct iovec datavec; + int rc; + + rc = memory_read_privatekey(session, &privkeyobj, &hostkey_abstract, + session->userauth_pblc_method, + session->userauth_pblc_method_len, + pk_file->filename, + strlen(pk_file->filename), + pk_file->passphrase); + if(rc) + return rc; + + datavec.iov_base = (void *)data; + datavec.iov_len = data_len; + + if (privkeyobj->signv(session, sig, sig_len, 1, &datavec, + &hostkey_abstract)) { + if (privkeyobj->dtor) { + privkeyobj->dtor(session, abstract); + } + return -1; + } + + if (privkeyobj->dtor) { + privkeyobj->dtor(session, &hostkey_abstract); + } + return 0; +} + +static int sign_fromfile(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, const unsigned char *data, size_t data_len, void **abstract) { @@ -1212,6 +1357,63 @@ _libssh2_userauth_publickey(LIBSSH2_SESSION *session, } /* + * userauth_publickey_frommemory + * Authenticate using a keypair from memory + */ +static int +userauth_publickey_frommemory(LIBSSH2_SESSION *session, + const char *username, + size_t username_len, + const char *publickeydata, + size_t publickeydata_len, + const char *privatekeydata, + size_t privatekeydata_len, + const char *passphrase) +{ + unsigned char *pubkeydata = NULL; + size_t pubkeydata_len = 0; + struct privkey_file privkey_file; + void *abstract = &privkey_file; + int rc; + + privkey_file.filename = privatekeydata; + privkey_file.passphrase = passphrase; + + if (session->userauth_pblc_state == libssh2_NB_state_idle) { + if (publickeydata_len && publickeydata) { + rc = memory_read_publickey(session, &session->userauth_pblc_method, + &session->userauth_pblc_method_len, + &pubkeydata, &pubkeydata_len, publickeydata, publickeydata_len); + if(rc) + return rc; + } + else if (privatekeydata_len && privatekeydata) { + /* Compute public key from private key. */ + if (_libssh2_pub_priv_keyfilememory(session, + &session->userauth_pblc_method, + &session->userauth_pblc_method_len, + &pubkeydata, &pubkeydata_len, + privatekeydata, privatekeydata_len, + passphrase)) + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Unable to extract public key " + "from private key."); + } + else + return _libssh2_error(session, LIBSSH2_ERROR_FILE, + "Invalid data in public and private key."); + } + + rc = _libssh2_userauth_publickey(session, username, username_len, + pubkeydata, pubkeydata_len, + sign_frommemory, &abstract); + if(pubkeydata) + LIBSSH2_FREE(session, pubkeydata); + + return rc; +} + +/* * userauth_publickey_fromfile * Authenticate using a keypair found in the named files */ @@ -1263,6 +1465,34 @@ userauth_publickey_fromfile(LIBSSH2_SESSION *session, return rc; } +/* libssh2_userauth_publickey_frommemory + * Authenticate using a keypair from memory + */ +LIBSSH2_API int +libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session, + const char *user, + unsigned int user_len, + const char *publickeyfiledata, + size_t publickeyfiledata_len, + const char *privatekeyfiledata, + size_t privatekeyfiledata_len, + const char *passphrase) +{ + int rc; + + if(NULL == passphrase) + /* if given a NULL pointer, make it point to a zero-length + string to save us from having to check this all over */ + passphrase=""; + + BLOCK_ADJUST(rc, session, + userauth_publickey_frommemory(session, user, user_len, + publickeyfiledata, publickeyfiledata_len, + privatekeyfiledata, privatekeyfiledata_len, + passphrase)); + return rc; +} + /* libssh2_userauth_publickey_fromfile_ex * Authenticate using a keypair found in the named files */ -- 1.7.6.msysgit.0 _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Sat Jan 21 23:24:07 2012 Return-Path: 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 q0LMNePM023696; Sat, 21 Jan 2012 23:24:01 +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 q0LMNcZr023683 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 21 Jan 2012 23:23:38 +0100 Received: from localhost (dast@localhost) by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id q0LMNc8M023677; Sat, 21 Jan 2012 23:23:38 +0100 X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs Date: Sat, 21 Jan 2012 23:23:38 +0100 (CET) From: Daniel Stenberg X-X-Sender: dast@giant.haxx.se To: libssh2 development Subject: Re: [PATCH] userauth: Allow authentication keys to be passed in memory In-Reply-To: <1326996007-1220-1-git-send-email-joe.turpin@gmail.com> Message-ID: References: <1326996007-1220-1-git-send-email-joe.turpin@gmail.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) X-fromdanielhimself: yes MIME-Version: 1.0 Cc: Joe Turpin X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Hello, Thanks for the updated patch! This time I applied it, had a look and here are my comments: - memcpy_s() is not a function that exists portably, don't use it. I also think you can skip checking memcpy()'s return code. - your new code produces lots of warnings and we're trying hard to not have warnings (some are still there but lets not add new ones). ./configure --enable-debug helps us see them. - also, where it is possible please keep the source lines shorter than 80 columns -- / daniel.haxx.se _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Sun Jan 22 02:33:55 2012 Return-Path: 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 q0M1XRW4028859; Sun, 22 Jan 2012 02:33:49 +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 q0M1XN1Y028804 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sun, 22 Jan 2012 02:33:24 +0100 Received: by iagz16 with SMTP id z16so3723648iag.41 for ; Sat, 21 Jan 2012 17:33:19 -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 :cc:content-type; bh=uTMoKJURP/XXacCdlD9OOZbQZftMmEYIMdpaIN/Fc04=; b=GULkh9IXlQqUZpjuRjBaDNiA2th0JYTqnCNIeV0blGUPsfbLa4aygA0pkefzK//dKI kWziBih2Pgbbye2b30nRarGLjldwI7Pi2jPGssrQoNUKl7QzT5nuHtyOsGGNU30J9DqG dEz29MXFbKtUZiZysffhuBciA8BGwHqqDjSWY= MIME-Version: 1.0 Received: by 10.50.178.106 with SMTP id cx10mr4076652igc.15.1327195999416; Sat, 21 Jan 2012 17:33:19 -0800 (PST) Received: by 10.42.239.198 with HTTP; Sat, 21 Jan 2012 17:33:19 -0800 (PST) In-Reply-To: References: <1326996007-1220-1-git-send-email-joe.turpin@gmail.com> Date: Sat, 21 Jan 2012 20:33:19 -0500 Message-ID: Subject: Re: [PATCH] userauth: Allow authentication keys to be passed in memory From: Joe Turpin To: libssh2 development Cc: Daniel Stenberg X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Daniel, No problem. I'll clean up the items you mentioned and submit a new patch sometime next week. --Joe _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Wed Jan 25 00:07:10 2012 Return-Path: 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 q0ON6mO9014959; Wed, 25 Jan 2012 00:07: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 q0ON6jXW014935 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 25 Jan 2012 00:06:46 +0100 Received: from localhost (dast@localhost) by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id q0ON6jZ9014928 for ; Wed, 25 Jan 2012 00:06:45 +0100 X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs Date: Wed, 25 Jan 2012 00:06:45 +0100 (CET) From: Daniel Stenberg X-X-Sender: dast@giant.haxx.se To: libssh2 development Subject: Re: A release In-Reply-To: Message-ID: References: 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 List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Fri, 18 Nov 2011, Daniel Stenberg wrote: > Alexander's point that we have some decent fixes in git that aren't included > in a release made me realize we should do... a release. Now over two months later, my new plan is: Release in 7 days, on January 31st 2012. Please speak up and provide patch if you have anything pending you want merged before then! -- / daniel.haxx.se _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Wed Jan 25 00:13:07 2012 Return-Path: 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 q0OND3LD018333; Wed, 25 Jan 2012 00:13:06 +0100 Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0OND0A6018210 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Wed, 25 Jan 2012 00:13:01 +0100 Received: by qaea17 with SMTP id a17so2868753qae.20 for ; Tue, 24 Jan 2012 15:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=uYiS0z3qgPeHWXYgLTVEthCfDPEpE/+c0sLp8mGb0Aw=; b=K65jY8oMVUR9zMCNHR8ecGFTs/Bqu1odfIN6dcLfaGj8BgUlrFPo3MjQdFFghJc9p+ O1l8h73tky394WJi+YhasW2wLVGEbApiqWAO8Kl/wOD4Ssk3dlpqB4YWyp20SQS/HLAD gg3xkVRzGefLpXc+dJq4LwskXZMOY1IbQo5FE= MIME-Version: 1.0 Received: by 10.224.218.4 with SMTP id ho4mr556790qab.77.1327446776439; Tue, 24 Jan 2012 15:12:56 -0800 (PST) Received: by 10.229.144.211 with HTTP; Tue, 24 Jan 2012 15:12:56 -0800 (PST) In-Reply-To: References: Date: Tue, 24 Jan 2012 23:12:56 +0000 X-Google-Sender-Auth: 6iBqrgENrSuB_7q5fBj6c-i_xl8 Message-ID: Subject: Re: A release From: Alexander Lamaison To: libssh2 development X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 24 January 2012 23:06, Daniel Stenberg wrote: > On Fri, 18 Nov 2011, Daniel Stenberg wrote: > >> Alexander's point that we have some decent fixes in git that aren't >> included in a release made me realize we should do... a release. > > Now over two months later, my new plan is: > > Release in 7 days, on January 31st 2012. Please speak up and provide patch > if you have anything pending you want merged before then! No patches. But a while ago we (you - I was mostly watching) were playing around with the way SFTP reconstructed a file from packets that didn't necessarily arrive in order. You fixed a major flaw but there was still an issue that IIRC could, in theory, leave a gap in a file. Have you looked at this at all since? If not, I'm sure it can wait for a future release. Alex -- Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org) _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Wed Jan 25 13:10:46 2012 Return-Path: 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 q0PCABId027776; Wed, 25 Jan 2012 13:10:33 +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 q0PCA9bG027765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 25 Jan 2012 13:10:09 +0100 Received: from localhost (dast@localhost) by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id q0PCA9mN027759 for ; Wed, 25 Jan 2012 13:10:09 +0100 X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs Date: Wed, 25 Jan 2012 13:10:09 +0100 (CET) From: Daniel Stenberg X-X-Sender: dast@giant.haxx.se To: libssh2 development Subject: Re: A release In-Reply-To: Message-ID: References: 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 List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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, 24 Jan 2012, Alexander Lamaison wrote: > No patches. But a while ago we (you - I was mostly watching) were playing > around with the way SFTP reconstructed a file from packets that didn't > necessarily arrive in order. You fixed a major flaw but there was still an > issue that IIRC could, in theory, leave a gap in a file. Have you looked at > this at all since? If not, I'm sure it can wait for a future release. No, I dropped the ball there and unfortunately I haven't picked it up since. I think we should try to come up with a way to force short packages to get sent by a server to help us write better code that handles this situation. But I think we can release anyway as this bug has been present for a while and doesn't seem to hurt that many people - I'm guessing blindly based on nothing but lack of bug reports. -- / daniel.haxx.se _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Thu Jan 26 20:40:52 2012 Return-Path: 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 q0QJeT0Y032111; Thu, 26 Jan 2012 20:40:48 +0100 Received: from mx1.polytechnique.org (mx1.polytechnique.org [129.104.30.34]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0QJeSiS032085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 26 Jan 2012 20:40:28 +0100 Received: from mac-jwoillez.local (unknown [128.171.100.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id 6B0AB140000B5 for ; Thu, 26 Jan 2012 20:40:28 +0100 (CET) Message-ID: <4F21ACF1.8030506@free.fr> Date: Thu, 26 Jan 2012 09:43:45 -1000 From: Gellule Xg User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: libssh2-devel@cool.haxx.se Subject: EOF and seek64 bug? X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Thu Jan 26 20:40:29 2012 +0100 (CET)) X-Spam-Flag: No, tests=bogofilter, spamicity=0.007257, queueID=0CEAB14000D83 X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Dear libssh2-devel mailing list, While interleaving some sftp_seek64 with sftp_read to read different section of a file, all stays fine until I reach EOF. After that, I can never get anything back from sftp_read after using sftp_seek64 to get away from EOF. I've tried with the following patch, and at least for me, things seem to work better. Cheers, -Gellule PS: I sent an E-mail to this list before registering, and this one after. Hopefully, I am not double-posting. ============================================= diff --git a/src/sftp.c b/src/sftp.c index 32b215a..48da9f2 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -1933,6 +1933,9 @@ libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset) handle->u.file.data_left = handle->u.file.data_len = 0; handle->u.file.data = NULL; } + + /* reset EOF to False */ + handle->u.file.eof = FALSE; } } ============================================= _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Thu Jan 26 20:52:20 2012 Return-Path: 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 q0QJqEnL011399; Thu, 26 Jan 2012 20:52:19 +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 q0QJqCX7011383 for ; Thu, 26 Jan 2012 20:52:12 +0100 Received: (qmail 10597 invoked by uid 501); 26 Jan 2012 19:52:14 -0000 Message-ID: <20120126195214.10596.qmail@stuge.se> Date: Thu, 26 Jan 2012 20:52:14 +0100 From: Peter Stuge To: libssh2-devel@cool.haxx.se Subject: Re: EOF and seek64 bug? Mail-Followup-To: libssh2-devel@cool.haxx.se References: <4F21ACF1.8030506@free.fr> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4F21ACF1.8030506@free.fr> X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Gellule Xg wrote: > I can never get anything back from sftp_read after using sftp_seek64 > to get away from EOF. I've tried with the following patch, and at > least for me, things seem to work better. .. > +++ b/src/sftp.c > @@ -1933,6 +1933,9 @@ libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, > libssh2_uint64_t offset) > handle->u.file.data_left = handle->u.file.data_len = 0; > handle->u.file.data = NULL; > } > + > + /* reset EOF to False */ > + handle->u.file.eof = FALSE; > } > } Does this also work correctly for the case of seek64:ing to EOF? If yes, then please re-send a patch created by git format-patch after you have created a clean commit locally. If you are not familiar enough with git then please say so, and we can make the commit for you. In that case, please mention what name and email address you would like the patch to have as author. Thanks! //Peter _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Thu Jan 26 23:21:21 2012 Return-Path: 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 q0QML8Y5025940; Thu, 26 Jan 2012 23:21:20 +0100 Received: from mx1.polytechnique.org (mx1.polytechnique.org [129.104.30.34]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0QML6EJ025913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 26 Jan 2012 23:21:06 +0100 Received: from mac-jwoillez.local (unknown [128.171.100.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id D680D14059827 for ; Thu, 26 Jan 2012 23:21:06 +0100 (CET) Message-ID: <4F21D294.3060705@free.fr> Date: Thu, 26 Jan 2012 12:24:20 -1000 From: Gellule Xg User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: libssh2-devel@cool.haxx.se Subject: Re: EOF and seek64 bug? References: <4F21ACF1.8030506@free.fr> <20120126195214.10596.qmail@stuge.se> In-Reply-To: <20120126195214.10596.qmail@stuge.se> Content-Type: multipart/mixed; boundary="------------000607040009030504000308" X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Thu Jan 26 23:21:07 2012 +0100 (CET)) X-Spam-Flag: No, tests=bogofilter, spamicity=0.000011, queueID=878791405982B X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libssh2-devel-bounces@cool.haxx.se Sender: libssh2-devel-bounces@cool.haxx.se This is a multi-part message in MIME format. --------------000607040009030504000308 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > Does this also work correctly for the case of seek64:ing to EOF? Looks like it does. I did the following tests: seek64 to filesize read 1024, got 0 seek64 to filesize-100 read 1024, got 100 seek64 to filesize read 1024, got 0 Also, seek64 to filesize-100 read 1024, got 100 seek64 to filesize-100 read 1024, got 100 Gives the exact same returned buffer twice. Finally, seeking past the size also seems to yield the correct behavior. > If yes, then please re-send a patch created by git format-patch after > you have created a clean commit locally. If you are not familiar > enough with git then please say so, and we can make the commit for > you. In that case, please mention what name and email address you > would like the patch to have as author. Attached! -Gellule --------------000607040009030504000308 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="0001-Reverting-the-EOF-flag-to-False-when-calling-seek64-.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Reverting-the-EOF-flag-to-False-when-calling-seek64-.pa"; filename*1="tch" From 1f21dd1df652c8086e7c5d835b5b5a38c7147e56 Mon Sep 17 00:00:00 2001 From: Gellule Xg Date: Thu, 26 Jan 2012 12:21:12 -1000 Subject: [PATCH] Reverting the EOF flag to False when calling seek64 to be able to get some data back on a following read. --- src/sftp.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/sftp.c b/src/sftp.c index 32b215a..48da9f2 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -1933,6 +1933,9 @@ libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset) handle->u.file.data_left = handle->u.file.data_len = 0; handle->u.file.data = NULL; } + + /* reset EOF to False */ + handle->u.file.eof = FALSE; } } -- 1.7.7.4 --------------000607040009030504000308 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 --------------000607040009030504000308-- From libssh2-devel-bounces@cool.haxx.se Fri Jan 27 11:04:44 2012 Return-Path: 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 q0RA4OC0001007; Fri, 27 Jan 2012 11:04:41 +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 q0RA4Nbg000985 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 27 Jan 2012 11:04:23 +0100 Received: from localhost (dast@localhost) by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id q0RA4MZY000980 for ; Fri, 27 Jan 2012 11:04:22 +0100 X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs Date: Fri, 27 Jan 2012 11:04:22 +0100 (CET) From: Daniel Stenberg X-X-Sender: dast@giant.haxx.se To: libssh2 development Subject: Re: EOF and seek64 bug? In-Reply-To: <4F21D294.3060705@free.fr> Message-ID: References: <4F21ACF1.8030506@free.fr> <20120126195214.10596.qmail@stuge.se> <4F21D294.3060705@free.fr> 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 List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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, 26 Jan 2012, Gellule Xg wrote: > Attached! Thanks, pushed just now! -- / daniel.haxx.se _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Sat Jan 28 22:45:14 2012 Return-Path: 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 q0SLihYo019237; Sat, 28 Jan 2012 22:45:08 +0100 Received: from mail-ee0-f54.google.com (mail-ee0-f54.google.com [74.125.83.54]) by giant.haxx.se (8.14.4/8.14.4/Debian-2) with ESMTP id q0SLigXr019205 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Sat, 28 Jan 2012 22:44:42 +0100 Received: by eekb47 with SMTP id b47so1032182eek.41 for ; Sat, 28 Jan 2012 13:44:38 -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:content-transfer-encoding; bh=wGLEVq8hgQscZDYQ+9zPwABBCn0MHV1Ql3TfO0sV4bA=; b=iocD3DgFup6G8+fwHMofAnE9f7g+klczuh6iL1Ne4u+ReJkGcqqH1hpZQgy7KR0xY5 BIghjiDvcJmvKvCWJCA/v8KN0m9DilakKFUJz8Msw4QZ9TFyn6TlnSxL3J86lntHiXYt F+JoTFYIB/XLDl0v1iXYBIm5pghl6XX0smwH8= MIME-Version: 1.0 Received: by 10.14.99.76 with SMTP id w52mr3685217eef.85.1327787077621; Sat, 28 Jan 2012 13:44:37 -0800 (PST) Received: by 10.213.96.134 with HTTP; Sat, 28 Jan 2012 13:44:37 -0800 (PST) In-Reply-To: References: Date: Sat, 28 Jan 2012 22:44:37 +0100 Message-ID: Subject: Re: A release From: Jernej Kovacic To: libssh2 development X-MIME-Autoconverted: from quoted-printable to 8bit by giant.haxx.se id q0SLigXr019205 X-BeenThere: libssh2-devel@cool.haxx.se X-Mailman-Version: 2.1.14 Precedence: list Reply-To: libssh2 development List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 q0SLihYo019237 Hello I think a few patches from the thread "Patch to ticket 228" (from October and November 2011) are still waiting to be committed. If I am correct, the ones, whose names start with 0001 and 0002, have already been committed, then I prepared another patch (its name starting with 0003) and sent in on 19 November (improvement of a manpage as advised; available at http://www.libssh2.org/mail/libssh2-devel-archive-2011-11/0033.shtml). The last minor improvement (just one cast added to fix a Visual Studio warning) is described in the very last message of this thread, published on 23 November (http://www.libssh2.org/mail/libssh2-devel-archive-2011-11/0040.shtml). This time without a patch. I hope this is enough information to find the patches as right now I don't have git installed. Best regards, Jernej On Wed, Jan 25, 2012 at 12:06 AM, Daniel Stenberg wrote: > On Fri, 18 Nov 2011, Daniel Stenberg wrote: > >> Alexander's point that we have some decent fixes in git that aren't >> included in a release made me realize we should do... a release. > > > Now over two months later, my new plan is: > > Release in 7 days, on January 31st 2012. Please speak up and provide patch > if you have anything pending you want merged before then! > > -- > >  / daniel.haxx.se > _______________________________________________ > 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 Tue Jan 31 23:09:15 2012 Return-Path: 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 q0VM8qGx014343; Tue, 31 Jan 2012 23:09:11 +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 q0VM8oxt014319 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 31 Jan 2012 23:08:50 +0100 Received: from localhost (dast@localhost) by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id q0VM8os7014314 for ; Tue, 31 Jan 2012 23:08:50 +0100 X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs Date: Tue, 31 Jan 2012 23:08:50 +0100 (CET) From: Daniel Stenberg X-X-Sender: dast@giant.haxx.se To: libssh2 development Subject: Re: A release In-Reply-To: Message-ID: References: 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 List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Sat, 28 Jan 2012, Jernej Kovacic wrote: > I hope this is enough information to find the patches as right now I don't > have git installed. Thanks for this, I've merged those and pushed! -- / daniel.haxx.se _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel From libssh2-devel-bounces@cool.haxx.se Tue Jan 31 23:31:05 2012 Return-Path: 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 q0VMUved029646; Tue, 31 Jan 2012 23:31:03 +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 q0VMUutC029637 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 31 Jan 2012 23:30:56 +0100 Received: from localhost (dast@localhost) by giant.haxx.se (8.14.4/8.14.4/Submit) with ESMTP id q0VMUuBH029633 for ; Tue, 31 Jan 2012 23:30:56 +0100 X-Authentication-Warning: giant.haxx.se: dast owned process doing -bs Date: Tue, 31 Jan 2012 23:30:56 +0100 (CET) From: Daniel Stenberg X-X-Sender: dast@giant.haxx.se To: libssh2 development Subject: ANNOUNCE: libssh2 1.4.0 Message-ID: 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 List-Id: libssh2 development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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 Hi friends, I'm happy to be able to ship yet another libssh2 release. Get it like always from http://www.libssh2.org/ The release notes this times look like below: libssh2 1.4.0 This release includes the following changes: o Added libssh2_session_supported_algs() o Added libssh2_session_banner_get() o Added libssh2_sftp_get_channel() o libssh2.h: bump the default window size to 256K This release includes the following bugfixes: o sftp-seek: clear EOF flag o userauth: Provide more informations if ssh pub key extraction fails o ssh2_exec: skip error outputs for EAGAIN o LIBSSH2_SFTP_PACKET_MAXLEN: increase to 80000 o knownhost_check(): Don't dereference ext if NULL is passed o knownhost_add: Avoid dereferencing uninitialized memory on error path o OpenSSL EVP: fix threaded use of structs o _libssh2_channel_read: react on errors from receive_window_adjust o sftp_read: cap the read ahead maximum amount o _libssh2_channel_read: fix non-blocking window adjusting This release would not have looked like this without help, code, reports and advice from friends like these: Gellule Xg, Jernej Kovacic, Peter Krempa, Vincent Torri, Kamil Dudka, Peter Stuge, Guenter Knauf, John Engstrom, Alexander Lamaison, Mikhail Gusarov Thanks! (and sorry if I forgot to mention someone) -- / daniel.haxx.se _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel