Thread

Posted on Sun Jul 1 02:55:26 2007 by jmarshll
64-bit code won't compile and can't connect to sftp server
Hi, Perl/SSH/SFTP noob here. I really want to use this package, but I'm having a couple of problems +. 1) I get "Invalid type Q" errors in Buffer.pm due to the use of the Q template in pack statements, +like: use constant HAS_QUADS => eval { no warnings; pack(Q => 0x1122334455667788) eq "\x11\x22\x33\x44\x55\x66\x77\x88" }; If I comment out all the code that references quads, it compiles. But, I'd rather figure out why I +can't use it as it is. 2) Running with the quad code commented out of Buffer.pm as described above, I am not able to conne +ct to my sftp server. I can use the same values at the command line to connect just fine using SFT +P (not SSH), but using this module I get the not-so-enlightening error msg "SSH connection failed: + bad remote message received". This error comes back very quickly, much more quickly than the serv +er responds when I connect at the cmd line via SFTP. The code looks like this: my $sftp = Net::SFTP::Foreign->new(host => $host, user => $user, port => $port, more => [qw(-i +/home/me/.ssh/priv_key_filename)]); One thing I should mention that may be related, when I try to connect to the server using SSH at th +e cmd line (as opposed to SFTP which works fine), I get the response "Shell access has been disabl +ed by the system administrator." I have no control over the server configuration. I'd very much like to use this package, so if there is any advice out there on these issues, I'd ve +ry much like to hear it. Thanks in advance for the help. James
Direct Responses: 5595 | Write a response
Posted on Sun Jul 1 12:57:43 2007 by salva in response to 5593
Re: 64-bit code won't compile and can't connect to sftp server
Hi James,

First, to report bugs on Net::SFTP::Foreign it's better to send an email directly to me (the author) or use the CPAN bug tracking system. Also, PerlMonks is a better place to get help on any Perl topic.

Regarding your problems, which perl version are you using? can you send me the output from the "perl -V" command so I can reproduce it myself?

And from the connection failing problem, try passing "-v" inside the "more" optional arg:

my $sftp = Net::SFTP::Foreign->new(host => $host, user => $user, port => $port, more => [qw(-v -i /home/me/.ssh/priv_key_filename)]);

You will see why the SSH command is failing.

Cheers,

Salva
Direct Responses: 5602 | Write a response
Posted on Mon Jul 2 00:17:11 2007 by jmarshll in response to 5595
Re: 64-bit code won't compile and can't connect to sftp server
Hi Salva. Thanks for the quick reply. Sorry, but I don't know how to find your email address, or I +would have sent this reply to you directly. If you'll tell me how to reach you I'll do that in the + future. I'm afraid I'll have to refrain from declaring anything in Perl to be a bug until I get e +nough experience with Perl to know a problem is not my fault, so I probably won't be using the bug + tracking system just yet. But thanks for the tips. Anyway, the output from perl -V is shown below. Also, I added the -v option to the more arg, but th +e error message did not change...same as before, no additional info. Thanks again for the help! James Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.15.4, archname=i486-linux-gnu-thread-multi uname='linux ninsei 2.6.15.4 #1 smp preempt mon feb 20 09:48:53 pst 2006 i686 gnulinux ' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i486 +-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix= +/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/u +sr/local/share/perl/5.8.8 -Dsitearch=/usr/local/lib/perl/5.8.8 -Dman1dir=/usr/share/man/man1 -Dman +3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman +1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrpli +b -Dlibperl=libperl.so.5.8.8 -Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing + -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -pipe -I +/usr/local/include' ccversion='', gccversion='4.0.3 (Debian 4.0.3-1)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt perllibs=-ldl -lm -lpthread -lc -lcrypt libc=/lib/libc-2.3.6.so, so=so, useshrplib=true, libperl=libperl.so.5.8.8 gnulibc_version='2.3.6' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Built under linux Compiled at Apr 4 2006 22:23:52 @INC: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl /usr/local/lib/perl/5.8.4 /usr/local/share/perl/5.8.4 .
Direct Responses: 5605 | 5606 | Write a response
Posted on Mon Jul 2 14:48:10 2007 by salva in response to 5602
Re: 64-bit code won't compile and can't connect to sftp server
Hi!

Oops, you are right, I forgot to include my e-mail address on the module documentation, it is sfandino@yahoo.com. Anyway, every CPAN author have the e-mail address $CPAN_ID@cpan.org, mine is salva@cpan.org

Regarding your problem, I can't still reproduce it. Can you post here your script (or better, a minimal version that still triggers the error), the command line you are using to run it, and its output?

Regards
Write a response
Posted on Mon Jul 2 14:48:29 2007 by salva in response to 5602
Re: 64-bit code won't compile and can't connect to sftp server
Hi!

Oops, you are right, I forgot to include my e-mail address on the module documentation, it is sfandino@yahoo.com. Anyway, every CPAN author has the e-mail address $CPAN_ID@cpan.org, mine is salva@cpan.org

Regarding your problem, I can't still reproduce it. Can you post here your script (or better, a minimal version that still triggers the error), the command line you are using to run it, and its output?

Regards
Direct Responses: 5621 | 5622 | Write a response
Posted on Wed Jul 4 02:43:06 2007 by jmarshll in response to 5606
Re: 64-bit code won't compile and can't connect to sftp server
Hi again. After stripping out some other code that my prog uses that did something to alter the err +or msg, I still get an error, but the msg is a little different from what I originally told you. F +or the server I'm testing, I can connect using the keys just fine from the command line, like... sftp -o IdentityFile=/home/myuser/.ssh/my_priv_key_file myuserid@sftp.myhost.com This is the script that's failing, along with the other info you asked for... use Net::SFTP::Foreign; my $host = 'sftp.myhost.com'; my $user = 'myuserid'; my $port = '22'; # the server is actually listening on port 22 my $sftp = Net::SFTP::Foreign->new( host => $host, user => $user, port => $port, more => [qw(-v -i /home/myuser/.ssh/my_priv_key_file)] ); $sftp->error and die "SSH connection failed: " . $sftp->error; The cmd to execute is... perl -T SFTPTest.pl The error msg I get is... SSH connection failed: Connection to remote server is broken at SFTPTest.pl line 15 Sorry I can't be more helpful. Thanks for your assistance...
Write a response
Posted on Wed Jul 4 02:57:09 2007 by jmarshll in response to 5606
Re: 64-bit code won't compile and can't connect to sftp server
Your request for the cmd I used to execute the script caused me to look at it again, and it appears the taint checking is what's causing the problem. I removed the -T from the cmd and everything worked. My shop wants us to use taint checking for everything, so is there hope I might be able to use this in the near future? Please??
Direct Responses: 5640 | Write a response
Posted on Thu Jul 5 12:40:26 2007 by salva in response to 5622
Re: 64-bit code won't compile and can't connect to sftp server
I have uploaded a new version of the module with (experimental!) support for running under taint mode. Please, report any bugs you could find.

Cheers

Direct Responses: 5644 | 5646 | Write a response
Posted on Thu Jul 5 20:07:14 2007 by jmarshll in response to 5640
Re: 64-bit code won't compile and can't connect to sftp server
Using the code I sent previously, I got this err msg when running in taint mode: FATAL ERROR: Can't coerce array into hash at /usr/local/share/perl/5.8.8/Net/SFTP/Foreign/Helpers.pm line 162. STACK: &(eval) in /usr/local/share/perl/5.8.8/Net/SFTP/Foreign/Helpers.pm +162 &Net::SFTP::Foreign::Helpers::_catch_tainted_args in /usr/local/share/perl/5.8.8/Net/SFTP/Foreign.pm +215 &Net::SFTP::Foreign::new in /tmp/goperl_17282.pl +12
Write a response
Posted on Fri Jul 6 04:36:26 2007 by jmarshll in response to 5640
Re: 64-bit code won't compile and can't connect to sftp server
Using the code I sent previously, I got this err msg when running in taint mode: FATAL ERROR: Can't coerce array into hash at /usr/local/share/perl/5.8.8/Net/SFTP/Foreign/Helpers.pm line 162. STACK: &(eval) in /usr/local/share/perl/5.8.8/Net/SFTP/Foreign/Helpers.pm +162 &Net::SFTP::Foreign::Helpers::_catch_tainted_args in /usr/local/share/perl/5.8.8/Net/SFTP/Foreign.pm +215 &Net::SFTP::Foreign::new in /tmp/goperl_17282.pl +12
Direct Responses: 5647 | Write a response
Posted on Fri Jul 6 09:57:03 2007 by salva in response to 5646
Re: 64-bit code won't compile and can't connect to sftp server
FATAL ERROR? Have you installed a custom DIE handler? The failing code is wrapped by an eval {} statement, the error should be caught and ignored!

I can't reproduce the error on my system (and it seems very similar to yours: perl 5.8.8 on Debian). Please, post again the full source code for your script, the command line you are using to run it and its exact output.

Direct Responses: 5649 | 5657 | Write a response
Posted on Fri Jul 6 18:53:24 2007 by jmarshll in response to 5647
Re: 64-bit code won't compile and can't connect to sftp server
Sorry about that. For the fatal error I ran it in a place that had some other die handler running I + didn't know about. The following is from a standard environment. I execute this code... use Net::SFTP::Foreign; my $sftp = Net::SFTP::Foreign->new( host => 'sftp.myhost.com', user => 'user', more => [qw(-v -i /home/user/.ssh/my_priv_key)] ); $sftp->error and die "SSH connection failed: " . $sftp->error; using this command... perl -T SFTPTest.pl and I get this error msg... SSH connection failed: Connection to remote server is broken at SFTPTest.pl line 9. When I use this command... perl SFTPTest.pl it works fine. Sorry for the confusion! Thanks.
Write a response
Posted on Sat Jul 7 03:47:52 2007 by jmarshll in response to 5647
Re: 64-bit code won't compile and can't connect to sftp server
Sorry about that. For the fatal error I ran it in a place that had some other die handler running I + didn't know about. The following is from a standard environment. I execute this code... use Net::SFTP::Foreign; my $sftp = Net::SFTP::Foreign->new( host => 'sftp.myhost.com', user => 'user', more => [qw(-v -i /home/user/.ssh/my_priv_key)] ); $sftp->error and die "SSH connection failed: " . $sftp->error; using this command... perl -T SFTPTest.pl and I get this error msg... SSH connection failed: Connection to remote server is broken at SFTPTest.pl line 9. When I use this command... perl SFTPTest.pl it works fine. Sorry for the confusion! Thanks.
Direct Responses: 5660 | Write a response
Posted on Sat Jul 7 15:02:42 2007 by salva in response to 5657
Re: 64-bit code won't compile and can't connect to sftp server
It fails because $ENV{PATH} is tainted.

Try adding...

$ENV{PATH} = '/usr/bin:/bin';

at the begining of your script, and it should work.

I have also uploaded a new version of the module to CPAN that catches this error.

Direct Responses: 5669 | Write a response
Posted on Mon Jul 9 20:52:34 2007 by jmarshll in response to 5660
Re: 64-bit code won't compile and can't connect to sftp server
Beautiful! Works great, good job. Thanks very much for your help and quick responses!
Direct Responses: 5673 | Write a response
Posted on Tue Jul 10 11:26:38 2007 by salva in response to 5669
Re: 64-bit code won't compile and can't connect to sftp server
I'm glad to see it is working now.

If you find any other problems (I am sure several taint mode bugs still remain), report then by e-mail, please

Write a response