Will Cosgrove | 25 May 21:42
Favicon

Permissions problem with mod_sftp

Hi Guys,
We've run into a curious problem with libssh2 (1.4.1) with users using proFTPD (1.3.4) and mod_sftp.  What
is happening is when we open a remote handle for *reading* like so:

remoteHandle = libssh2_sftp_open(session, file, LIBSSH2_FXF_READ, 0);

The server wipes out the file permissions.  I.e., sets them to 000.  According to the docs, if the file exists
on disk it should ignore the mode bits.  But it seems not to be the case.

We've tracked it back to the server config setting IgnoreSFTPUploadPerms, if this is set to yes,
everything is fine.  This seems like an pretty obvious server-side issue; *however* it works correctly
using openssh's sftp client.  

Before I continue tracking this down, do you guys have any ideas what the differences would be between
openssh's sftp implementation and libssh2 which would be causing this?

Thanks,
Will

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

Jamie Lahowetz | 24 May 17:46
Picon

example ssh2: failed to connect

I have tried running the example ssh2. When I do I get a failed to connect error which is triggered by the connect() method. How can I fix this? thank you.

--
Jamie Ryan Lahowetz
University of Nebraska - Lincoln
Graduate Student - Geosciences
402.304.0766
jlahowetz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Thabelo Mmbengeni | 24 May 10:21
Picon

Invitation to connect on LinkedIn

 
 
 
 
From Thabelo Mmbengeni
 
zapop web developer at zapop
Cape Town Area, South Africa
 
 
 

I'd like to add you to my professional network on LinkedIn.

- Thabelo

 
 
 
 
 
 
You are receiving Invitation to Connect emails. Unsubscribe
© 2012, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA
 
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Barry Fawthrop | 23 May 14:09

Error Receiving a File SCP

I am able to connect     But Unable to receive a File
Using the same code as   example/scp.c   (tried even the scp_nonblock.c)

Trace taken  from  the working  example/scp.c

Read B  lines come from  my trace additions to   transport.c       _libssh2_transport_read    Function

Read B 2  just before   if (session->state & LIBSSH2_STATE_NEWKEYS) {
Read B 3  just after   remainbuf = p->writeidx - p->readied;   prints  writeidx  and readidx   values
Read B 3 just before   if (remainbuf < blocksize) {            prints  remainbuf and blocksize values
Read B 3 A inside       if (remainbuf < blocksize) {            prints  remainbuf value
Read B 3 B  just before  nread = LIBSSH2_RECV(session, &p->buf[remainbuf], PACKETBUFSIZE - remainbuf,  ...
Read B 3 C  right after the    nread = LIBSSH2_RECV(session, 

=====  ….   ====  sections  appear during scp.c  execution which works
but NOT during my execution

Code STOPS in the LIBSSH2_RECV  function  

Any Help Please !  !

Thanks in advance

::  [libssh2] 0.919596 Transport: Packet type 91 received, length=17
::  [libssh2] 0.919603 Transport: Looking for packet of type: 91
::  [libssh2] 0.919608 Conn: Connection Established - ID: 0/0 win: 0/262144 pack: 140381006102528/4295000064
::  [libssh2] 0.919622 Conn: starting request(exec) on channel 0/0, message=scp -pf 'code.xml'
::  [libssh2] 0.919658 Socket: Sent 84/84 bytes at 0x7fadb9005658
::  [libssh2] 0.919711 Transport: Looking for packet of type: 99
::  [libssh2] 0.919719 Transport: Looking for packet of type: 100
Read B     
Read B   1   
Read B   2   
Read B  3   52   52  
Read B  3   (0)   (16)   
Read B  3   A      (0)   
Read B  3   B        

====================================================================
THIS INDENTED BLOCK DOES NOT APPEAR  DURING      MY        CODE EXECUTION
              Read B  3   C      (-35)   
              ::  [libssh2] 0.919747 Failure Event: -37 - Would block requesting SCP startup
              ::  [libssh2] 0.925962 Transport: Looking for packet of type: 99
              ::  [libssh2] 0.925990 Transport: Looking for packet of type: 100
              Read B     
              Read B   1   
              Read B   2   
              Read B  3   0   0  
              Read B  3   (0)   (16)   
              Read B  3   A      (0)   
              Read B  3   B        
====================================================================

Read B  3   C      (88)   
::  [libssh2] 0.926056 Socket: Recved 88/16384 bytes to 0x7fadb9001618+0
Read B  4          (88)   
Read B  5   (36)    (72)  
Read B  6             
Read B  6   A         
Read B  6   B    
Read B  7      (16)   
Read B  8    (20)   
Read B  9          (0)    (47)   (47)    
::  [libssh2] 0.926135 Transport: Packet type 93 received, length=9
::  [libssh2] 0.926148 Conn: Window adjust for channel 0/0, adding 2097152 bytes, new window_size=2097152
Read B     
Read B   1   
Read B   2   
Read B  3   88   52  
Read B  3   (36)   (16)   
Read B  4          (36)   
Read B  5   (20)    (20)  
Read B  6             
Read B  6   A         
Read B  6   B    
Read B  7      (0)   
Read B  8    (20)   
Read B  9          (0)    (31)   (31)    
::  [libssh2] 0.926243 Transport: Packet type 99 received, length=5
::  [libssh2] 0.926256 Transport: Looking for packet of type: 99
::  [libssh2] 0.926267 SCP: Sending initial wakeup
write     1  
::  [libssh2] 0.926298 Conn: Writing 1 bytes on channel 0/0, stream #0
write     2  
write     3  
write     4  Read B     
Read B   1   
Read B   2   
Read B  3   88   88  
Read B  3   (0)   (16)   



====================================================================
THIS INDENTED BLOCK DOES NOT APPEAR  DURING      MY        CODE EXECUTION
              Read B  3   A      (0)   
              Read B  3   B      
              Read B  3   C      (-35)   
              ::  [libssh2] 0.926377 Conn: Sending 1 bytes on channel 0/0, stream_id=0
              ::  [libssh2] 0.926444 Socket: Sent 52/52 bytes at 0x7fadb9005658
              ::  [libssh2] 0.926460 Conn: channel_read() wants 1 bytes from channel 0/0 stream #0
              Read B     
              Read B   1   
              Read B   2   
              Read B  3   0   0  
              Read B  3   (0)   (16)   
              Read B  3   A      (0)   
              Read B  3   B        
              Read B  3   C      (-35)   
              ::  [libssh2] 0.926519 Failure Event: -37 - would block
              ::  [libssh2] 0.926528 Failure Event: -37 - Would block waiting for SCP response
              ::  [libssh2] 0.927204 Conn: channel_read() wants 1 bytes from channel 0/0 stream #0
              Read B     
              Read B   1   
              Read B   2   
              Read B  3   0   0  
              Read B  3   (0)   (16)   
              Read B  3   A      (0)   
              Read B  3   B        
              Read B  3   C      (452)   
              ::  [libssh2] 0.927288 Socket: Recved 452/16384 bytes to 0x7fadb9001618+0
====================================================================

Read B  4          (452)   
Read B  5   (436)    (436)  
Read B  6             
Read B  6   A         
Read B  6   B    
Read B  7      (416)   
Read B  8    (20)   
Read B  9          (0)    (447)   (447)    
::  [libssh2] 0.927389 Transport: Packet type 95 received, length=415
PACKET    Extended  Data  
PACKET    Data  Channel   
::  [libssh2] 0.927410 Conn: 402 bytes packet_add() for 0/0/1
Read B     
Read B   1   
Read B   2   
Read B  3   452   452  
Read B  3   (0)   (16)   
Read B  3   A      (0)   
Read B  3   B        
 
<=====  STOPS Here  Just waits  Thus is Hung Up in the   LIBSSH2_RECV   function ?

              Read B  3   C      (-35)   
              ::  [libssh2] 0.927694 Failure Event: -37 - would block
              ::  [libssh2] 0.927705 Failure Event: -37 - Would block waiting for SCP response
              ::  [libssh2] 0.931757 Conn: channel_read() wants 1 bytes from channel 0/0 stream #0
              Read B     
              Read B   1   
              Read B   2   
              Read B  3   0   0  
              Read B  3   (0)   (16)   
              Read B  3   A      (0)   
              Read B  3   B        
              Read B  3   C      (68)   
              ::  [libssh2] 0.931842 Socket: Recved 68/16384 bytes to 0x7fadb9001618+0
              Read B  4          (68)   
              ……
              …….



Thanks in advance
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Paulo Caetano | 23 May 13:43
Picon

[PATCH] Corrected error checking on socket creation

From dd644ca2526e8e5cf64121f53664d2804600b325 Mon Sep 17 00:00:00 2001
From: Paulo Caetano <paulo.a.o.caetano@...>
Date: Wed, 23 May 2012 12:03:19 +0100
Subject: [PATCH] Corrected error checking on socket creation

---
 ssh2_multiexec.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ssh2_multiexec.c b/ssh2_multiexec.c
index 18fe79b..5bc341f 100644
--- a/ssh2_multiexec.c
+++ b/ssh2_multiexec.c
@@ -218,7 +218,7 @@ int main(int argc, char *argv[])
      */
     sock = socket(AF_INET, SOCK_STREAM, 0);
 	
-	if (socket == -1)
+	if (sock == -1)
 		perror("Create socket");

     sin.sin_family = AF_INET;
--

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

Barry Fawthrop | 22 May 19:13

Understanding Key Orders

Trying to understand where (which file(s) )  on the client side   sets the Key order

::   [libssh2] 0.245000 Key Ex: Sent KEX: diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
::   [libssh2] 0.245000 Key Ex: Sent HOSTKEY: ssh-rsa,ssh-dss
::   [libssh2] 0.245000 Key Ex: Sent CRYPT_CS: aes128-ctr,aes192-ctr,aes256-ctr,aes256-cbc,rijndael-cbc-SamgB31n2u5IcsJQ0EH25Q@public.gmane.org,aes192-cbc,aes128-cbc,blowfish-cbc,arcfour128,arcfour,cast128-cbc,3des-cbc
::   [libssh2] 0.245000 Key Ex: Sent CRYPT_SC: aes128-ctr,aes192-ctr,aes256-ctr,aes256-cbc,rijndael-cbc-SamgB31n2u5IcsJQ0EH25Q@public.gmane.org,aes192-cbc,aes128-cbc,blowfish-cbc,arcfour128,arcfour,cast128-cbc,3des-cbc
::   [libssh2] 0.245000 Key Ex: Sent MAC_CS: hmac-sha1,hmac-sha1-96,hmac-md5,hmac-md5-96,hmac-ripemd160,hmac-ripemd160-ZT/51Pfwho1BDgjK7y7TUQ@public.gmane.org


How can I change or re-order the  CRYPT_CS  and CRYPT_SC  Order   
Also to add or remove ones


Thanks  in advance
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Marta | 22 May 12:40
Picon
Gravatar

[PATCH] Added LIBSSH2_ERROR_EAGAIN tests to nonblocking examples.

Hi again,

I've made the patch for all the nonblocking examples. Basically, I've
checked the libssh2 calls on each program and, if they can return
EAGAIN, make it loop until the return code is other than EAGAIN.

This is my first patch so please tell me if I did something wrong :)

Thanks.

--
Marta
Attachment (nonblock_examples_fixes.patch): application/octet-stream, 6784 bytes
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Mark Brand | 19 May 10:54
Picon

[PATCH] libgcrypt does not provide pkg-config support

 From 6b8a3edae23dc93cc02e6c9572d0796e338ddc4f Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@...>
Date: Sat, 19 May 2012 10:40:36 +0200
Subject: [PATCH] libgcrypt does not provide pkg-config support

Commits 04692445d4a32430610ccf8c256e18245cbb3e06
and e887a8bd0f043fd49e9119756858e75e82dee504 add
'libgcrypt' to Requires.private of libssh2.pc
file, but libgcrypt does not provide a .pc file, so
this does not work.
---
  configure.ac |    1 -
  1 file changed, 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index aa9d397..0d35a27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,7 +102,6 @@ fi
  # Look for libgcrypt
  if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
    AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
-  LIBSREQUIRED=libgcrypt
  fi

  AC_SUBST(LIBSREQUIRED)
-- 
1.7.9.2
From 6b8a3edae23dc93cc02e6c9572d0796e338ddc4f Mon Sep 17 00:00:00 2001
From: Mark Brand <mabrand@...>
Date: Sat, 19 May 2012 10:40:36 +0200
Subject: [PATCH] libgcrypt does not provide pkg-config support

Commits 04692445d4a32430610ccf8c256e18245cbb3e06
and e887a8bd0f043fd49e9119756858e75e82dee504 add
'libgcrypt' to Requires.private of libssh2.pc
file, but libgcrypt does not provide a .pc file, so
this does not work.
---
 configure.ac |    1 -
 1 file changed, 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index aa9d397..0d35a27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,7 +102,6 @@ fi
 # Look for libgcrypt
 if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
   AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
-  LIBSREQUIRED=libgcrypt
 fi

 AC_SUBST(LIBSREQUIRED)
--

-- 
1.7.9.2

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Daniel Stenberg | 18 May 23:37
Picon
Favicon
Gravatar

ANNOUNCE: libssh2 1.4.2 is out!

Hi friends,

I just uploaded the 1.4.2 release, go get it from http://www.libssh2.org/

This release includes the following bugfixes:

  o Return LIBSSH2_ERROR_SOCKET_DISCONNECT on EOF when reading banner
  o userauth.c: fread() from public key file to correctly detect any errors
  o configure.ac: Add option to disable build of the example applications
  o Added 'Requires.private:' line to libssh2.pc
  o SFTP: filter off incoming "zombie" responses
  o gettimeofday: no need for a replacement under cygwin
  o SSH_MSG_CHANNEL_REQUEST: default to want_reply
  o win32/libssh2_config.h: Remove hardcoded #define LIBSSH2_HAVE_ZLIB

This release would not have looked like this without help, code, reports and
advice from friends like these:

  Alexander Lamaison, Rafael Kitover, Guenter Knauf, Peter Stuge,
  Oleksiy Zagorskyi

         Thanks! (and sorry if I forgot to mention someone)

--

-- 

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

Marta | 18 May 12:34
Picon
Gravatar

sftp functions leaking memory?

Hi,

Let's see if you can enlighten my day :)

A bit of background: I'm working with an embedded system[1] and I
needed a library to manage sftp transfers that need to be done
periodically, so I used libssh2. Everything was going smooth until I
realized the process was eating memory, around 2 MB a day. That's not
a big deal on a bigger system, but having only 64 MB of RAM, in my
case that is a problem.

I reviewed my code, and having not found any error, I tried to make
some measurements with one of the examples. I modified the non
blocking sftp example to operate in a loop (see attachment, if you
want to compile it you will have to change the pmemlog string to match
your system, and include the right libssh2_config.h). After 433
iterations, I made a graph of the heap size. The heap growth is almost
linear, and it does not seem to stabilize. Another interesting thing
is that the heap does not grow on each iteration. You can see the
details on the attached spreadsheet.

More data:
- I've already searched the list for something similar to this...
without success.
- I've tested this in libssh2-1.3.0, libssh2-1.4.1 and libssh2-1.4.2
(yesterdays' morning snapshot, the zombies thing gave me hope... )
- Compiled with libgcrypt 1.5.0 (also tried with openssl, the leak was
also present).
- My cross-compiler is a bit old, but I'm not allowed to use another
for now (In my paranoia I'm tempted to blame the compiler)
# arm-linux-gcc --v
Reading specs from /usr/local/lib/gcc-lib/arm-linux/3.3.2/specs
Configured with: ../configure --target=arm-linux --disable-shared
--with-headers=/home/gerg/new-wave.xscale/linux-2.4.x/include
--with-gnu-as --with-gnu-ld --enable-multilib
Thread model: posix
gcc version 3.3.2

If you have any idea on this, I will be very happy to read it. If not,
I will have to dive into the code to find an explanation for this...

Thank you very much!
--
Marta

[1] - http://www.artila.com/p_matrix.html#Matrix-500
Attachment (sftp_test.c): text/x-csrc, 7738 bytes
Attachment (heap growth test.ods): application/vnd.oasis.opendocument.spreadsheet, 25 KiB
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Alex Rolfe | 18 May 04:29
Picon

Unable to link with OpenSSL libraries under Cygwin

Hello,

I'm having trouble building the library. I'm using libssh2-1.4.1 and openssl-1.0.1c, and gcc v4.5.3 using Cygwin
I built the SSL library the other day, and it passed all its self-tests, and links/runs fine with a basic test program.
When libssh2 tries to link with it, I get the following errors.

/bin/sh ../libtool --tag=CC --mode=link gcc  -DLIBSSH2_WIN32    -o libssh2.la -rpath /usr/local/ssh2/lib -version-info 1:1:0 -no-undefined  -export-symbols-regex '^libssh2_.*'   -L/usr/local/ssl/lib -lssl -L/usr/local/ssl/lib -lcrypto  channel.lo comp.lo crypt.lo hostkey.lo kex.lo mac.lo  misc.lo packet.lo publickey.lo scp.lo session.lo sftp.lo  userauth.lo transport.lo version.lo knownhost.lo agent.lo  openssl.lo libgcrypt.lo pem.lo keepalive.lo global.lo

*** Warning: linker path does not have real file for library -lssl.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have
*** because I did check the linker path looking for a file starting
*** with libssl and none of the candidates passed a file format test
*** using a file magic. Last file checked: /usr/local/ssl/lib/libssl.a

*** Warning: linker path does not have real file for library -lcrypto.
......
*** using a file magic. Last file checked: /usr/local/ssl/lib/libcrypto.a
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.

*** Since this library must not contain undefined symbols,
*** because either the platform does not support them or
*** it was explicitly requested with -no-undefined,
*** libtool will only create a static version of it.

Shortly afterwards, the following errors appear. I'm only assuming this is a result of the above linking failure.

libtool: link: gcc -DLIBSSH2_WIN32 -o .libs/direct_tcpip.exe direct_tcpip.o  ../src/.libs/libssh2.a -L/usr/local/ssl/lib -lssl -lcrypto
direct_tcpip.o:direct_tcpip.c:(.text+0xec): undefined reference to `__imp__libssh2_init'
direct_tcpip.o:direct_tcpip.c:(.text+0x21f): undefined reference to `__imp__libssh2_session_init_ex'
...

I defined /usr/local/ssl as the ssl prefix when I configured the makefile, which is the correct location.. The part that confuses me is "Last file checked: /usr/local/ssl/lib/libssl.a" It appears to be finding the real file for the library just fine?
I'm not sure why -DLIBSSH2_WIN32 is defined with cygwin, but I don't believe its the problem. I already fixed the make errors I was running in to because of it, in misc.c. The other people on the mailing list with the same define with cygwin weren't having the problem I'm having with linking.

When I try make without -no-undefined, I don't get the errors about not being able to link with ssl and crypto, but I still get the later undefined references.
I'd appreciate any information, I'm not sure what the problem is.

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

Gmane