Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It was a bit of a mess. Much of the code was unnecessary, dating from before 2.0 when it used Net::SFTP instead of Net::SSH2. As a result, the error handling was all wrong. While at it, remove the file name escaping, as with newer versions of Net::SSH2 at least (or perhaps newer versions of libssh2), it was leaving the backslashes in the file names on the destination server. So bump up the minimum version of Net::SSH2. For sanity, also add tests to make sure that Net::Util::Trans::SFTP and Net::Util::Trans::SFTP compile and have apprpropriate interfaces.
- Loading branch information
Showing
5 changed files
with
152 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package Bric::Util::Trans::FTP::Test; | ||
use strict; | ||
use warnings; | ||
use base qw(Bric::Test::Base); | ||
use Test::More; | ||
use Bric::Util::ApacheUtil qw(unescape_uri escape_uri); | ||
use File::Spec::Functions qw(catdir); | ||
use File::Spec::Unix; | ||
|
||
############################################################################## | ||
# Test class loading. | ||
############################################################################## | ||
sub _test_load : Test(3) { | ||
use_ok('Bric::Util::Trans::FTP'); | ||
isa_ok 'Bric::Util::Trans::FTP', 'Bric'; | ||
|
||
can_ok 'Bric::Util::Trans::FTP', qw( | ||
new | ||
put_res | ||
del_res | ||
); | ||
} | ||
|
||
1; | ||
__END__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package Bric::Util::Trans::SFTP::Test; | ||
use strict; | ||
use warnings; | ||
use base qw(Bric::Test::Base); | ||
use Test::More; | ||
use Bric::Util::ApacheUtil qw(unescape_uri escape_uri); | ||
use File::Spec::Functions qw(catdir); | ||
use File::Spec::Unix; | ||
|
||
############################################################################## | ||
# Test class loading. | ||
############################################################################## | ||
sub _test_load : Test(3) { | ||
use_ok('Bric::Util::Trans::SFTP'); | ||
isa_ok 'Bric::Util::Trans::SFTP', 'Bric'; | ||
|
||
can_ok 'Bric::Util::Trans::SFTP', qw( | ||
new | ||
put_res | ||
del_res | ||
_connect_to | ||
); | ||
} | ||
|
||
1; | ||
__END__ |
256e550
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi David,
I tried it out, but no luck, I'm afraid. That may be because of something particular to my system, but I'm not sure.
There were a couple of typos that I fixed when trying it out, but I didn't get it to work, so it feels a little pointless to file a patch. Here they are:
Line 269: method name should be "_connect", not "_connect_to" (github is hiding the initial underscores here)
Line 275: "trow_gen" should be "throw_gen".
Now, the errors:
Attempting a preview to an SFTP destination, using key authentication yields this error:
Error authenticating to 'arse.ca' via SSH2
-37 LIBSSH2_ERROR_EAGAIN Would block requesting userauth list
View Error Details
Error Details (hide)
Fault Class
Bric::Util::Fault::Exception::GEN
Description
General Exception
Timestamp
2010-07-09 07:44:22.000000
Package
Bric::Util::Trans::SFTP
Filename
/usr/local/bricolage/lib/Bric/Util/Trans/SFTP.pm
Line
298
Stack:
Trace begun at /usr/local/bricolage/lib/Bric/Util/Trans/SFTP.pm line 298
Bric::Util::Trans::SFTP::_connect('Bric::Dist::Server=HASH(0x23c86d38)') called at /usr/local/bricolage/lib/Bric/Util/Trans/SFTP.pm line 132
Bric::Util::Trans::SFTP::put_res('Bric::Util::Trans::SFTP', 'ARRAY(0x23c87248)', 'Bric::Dist::ServerType=HASH(0x23c2f580)') called at /usr/local/bricolage/lib/Bric/Dist/Action/Mover.pm line 160
Bric::Dist::Action::Mover::do_it('Bric::Dist::Action::Mover=HASH(0x23bfd0d0)', 'ARRAY(0x23c87248)', 'Bric::Dist::ServerType=HASH(0x23c2f580)') called at /usr/local/bricolage/lib/Bric/Util/Job/Dist.pm line 227
Bric::Util::Job::Dist::_do_it('Bric::Util::Job::Dist=HASH(0x23c2cd30)') called at /usr/local/bricolage/lib/Bric/Util/Job.pm line 1881
eval {...} at /usr/local/bricolage/lib/Bric/Util/Job.pm line 1879
Bric::Util::Job::execute_me('Bric::Util::Job::Dist=HASH(0x23c2cd30)') called at /usr/local/bricolage/lib/Bric/Util/Job.pm line 1800
Bric::Util::Job::save('Bric::Util::Job::Dist=HASH(0x23c2cd30)') called at /usr/local/bricolage/lib/Bric/Util/Burner.pm line 1036
eval {...} at /usr/local/bricolage/lib/Bric/Util/Burner.pm line 974
Bric::Util::Burner::preview('Bric::Util::Burner=HASH(0x23bb23b0)', 'Bric::Biz::Asset::Business::Story=HASH(0x23b86008)', 'story', 0, undef) called at /usr/local/bricolage/lib/Bric/App/Callback/Publish.pm line 117
Bric::App::Callback::Publish::preview('Bric::App::Callback::Publish=HASH(0x23a8ee08)') called at /usr/local/bricolage/comp/workflow/profile/preview/dhandler line 32
HTML::Mason::Commands::ANON('checkout', 1, 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Component.pm line 135
HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x23bf90c0)', 'checkout', 1, 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Request.pm line 1278
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 1268
HTML::Mason::Request::comp(undef, undef, undef, 'checkout', 1, 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Request.pm line 937
HTML::Mason::Request::call_next('HTML::Mason::Request::ApacheHandler=HASH(0x23a81408)', 'checkout', 1) called at /usr/local/bricolage/comp/autohandler line 7
HTML::Mason::Commands::ANON('checkout', 1) called at /usr/share/perl5/HTML/Mason/Component.pm line 135
HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x23a8e918)', 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Request.pm line 1273
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 1268
HTML::Mason::Request::comp(undef, undef, undef, 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Request.pm line 467
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 467
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 419
HTML::Mason::Request::exec('HTML::Mason::Request::ApacheHandler=HASH(0x23a81408)') called at /usr/share/perl5/HTML/Mason/ApacheHandler.pm line 165
HTML::Mason::Request::ApacheHandler::exec('HTML::Mason::Request::ApacheHandler=HASH(0x23a81408)') called at /usr/share/perl5/HTML/Mason/ApacheHandler.pm line 831
HTML::Mason::ApacheHandler::handle_request('HTML::Mason::ApacheHandler=HASH(0x230c5720)', 'Apache2::RequestRec=SCALAR(0x23bbeb98)') called at /usr/local/bricolage/lib/Bric/App/Handler.pm line 307
eval {...} at /usr/local/bricolage/lib/Bric/App/Handler.pm line 296
Bric::App::Handler::handler('Apache2::RequestRec=SCALAR(0x23bbeb98)') called at -e line 0
eval {...} at -e line 0
Attempting the same preview with password does this:
Error renaming '/usr/www/users/smell/arse/2010/07/06/yes/index.html.tmp' to '/usr/www/users/smell/arse/2010/07/06/yes/index.html' on 'arse.ca'
4 SSH_FX_FAILURE
View Error Details
Error Details (hide)
Fault Class
Bric::Util::Fault::Exception::GEN
Description
General Exception
Timestamp
2010-07-09 07:45:42.000000
Package
Bric::Util::Trans::SFTP
Filename
/usr/local/bricolage/lib/Bric/Util/Trans/SFTP.pm
Line
177
Stack:
Trace begun at /usr/local/bricolage/lib/Bric/Util/Trans/SFTP.pm line 177
Bric::Util::Trans::SFTP::put_res('Bric::Util::Trans::SFTP', 'ARRAY(0x23cf7be0)', 'Bric::Dist::ServerType=HASH(0x23c4a908)') called at /usr/local/bricolage/lib/Bric/Dist/Action/Mover.pm line 160
Bric::Dist::Action::Mover::do_it('Bric::Dist::Action::Mover=HASH(0x23c3f9e8)', 'ARRAY(0x23cf7be0)', 'Bric::Dist::ServerType=HASH(0x23c4a908)') called at /usr/local/bricolage/lib/Bric/Util/Job/Dist.pm line 227
Bric::Util::Job::Dist::_do_it('Bric::Util::Job::Dist=HASH(0x23c0a480)') called at /usr/local/bricolage/lib/Bric/Util/Job.pm line 1881
eval {...} at /usr/local/bricolage/lib/Bric/Util/Job.pm line 1879
Bric::Util::Job::execute_me('Bric::Util::Job::Dist=HASH(0x23c0a480)') called at /usr/local/bricolage/lib/Bric/Util/Job.pm line 1800
Bric::Util::Job::save('Bric::Util::Job::Dist=HASH(0x23c0a480)') called at /usr/local/bricolage/lib/Bric/Util/Burner.pm line 1036
eval {...} at /usr/local/bricolage/lib/Bric/Util/Burner.pm line 974
Bric::Util::Burner::preview('Bric::Util::Burner=HASH(0x23c16258)', 'Bric::Biz::Asset::Business::Story=HASH(0x23c3fb68)', 'story', 0, undef) called at /usr/local/bricolage/lib/Bric/App/Callback/Publish.pm line 117
Bric::App::Callback::Publish::preview('Bric::App::Callback::Publish=HASH(0x23c3f788)') called at /usr/local/bricolage/comp/workflow/profile/preview/dhandler line 32
HTML::Mason::Commands::ANON('checkout', 1, 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Component.pm line 135
HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x23c398c8)', 'checkout', 1, 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Request.pm line 1278
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 1268
HTML::Mason::Request::comp(undef, undef, undef, 'checkout', 1, 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Request.pm line 937
HTML::Mason::Request::call_next('HTML::Mason::Request::ApacheHandler=HASH(0x22adcae8)', 'checkout', 1) called at /usr/local/bricolage/comp/autohandler line 7
HTML::Mason::Commands::ANON('checkout', 1) called at /usr/share/perl5/HTML/Mason/Component.pm line 135
HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x23aa4760)', 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Request.pm line 1273
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 1268
HTML::Mason::Request::comp(undef, undef, undef, 'checkout', 1) called at /usr/share/perl5/HTML/Mason/Request.pm line 467
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 467
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 419
HTML::Mason::Request::exec('HTML::Mason::Request::ApacheHandler=HASH(0x22adcae8)') called at /usr/share/perl5/HTML/Mason/ApacheHandler.pm line 165
HTML::Mason::Request::ApacheHandler::exec('HTML::Mason::Request::ApacheHandler=HASH(0x22adcae8)') called at /usr/share/perl5/HTML/Mason/ApacheHandler.pm line 831
HTML::Mason::ApacheHandler::handle_request('HTML::Mason::ApacheHandler=HASH(0x230c5720)', 'Apache2::RequestRec=SCALAR(0x23be5508)') called at /usr/local/bricolage/lib/Bric/App/Handler.pm line 307
eval {...} at /usr/local/bricolage/lib/Bric/App/Handler.pm line 296
Bric::App::Handler::handler('Apache2::RequestRec=SCALAR(0x23be5508)') called at -e line 0
eval {...} at -e line 0
This may be particular to my system. I haven't got SFTP working with the old SFTP.pm either.
256e550
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Bret. For the first error, you try this patch, please?
I'm not sure about the second error. Was the file in fact renamed before the exception was thrown?
A million thanks for the testing!
David