Skip Menu |

This queue is for tickets about the Net-SCP CPAN distribution.

Report information
The Basics
Id: 38008
Status: open
Priority: 0/
Queue: Net-SCP

People
Owner: Nobody in particular
Requestors: gbjk [...] thermeon.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Net-SCP Patch
Date: Tue, 29 Jul 2008 08:34:56 +0100
To: ivan-pause [...] 420.am
From: Gareth Kirwan <gbjk [...] thermeon.com>
I may be wrong, but it seemed that the scp sub could not handle a defined user, only the get and put subs. Since they both use scp, I moved the user/dest concatination up to there and removed it from both of them. Additionally I had a need to use a different identity file from the default. I've added it as identity_file in new and in a accessor. Let me know what you think. Thanks Gareth
On Tue Jul 29 03:35:08 2008, gbjk@thermeon.com wrote: Show quoted text
> I may be wrong, but it seemed that the scp sub could not handle a > defined user, only the get and put subs. > Since they both use scp, I moved the user/dest concatination up to there > and removed it from both of them. > > Additionally I had a need to use a different identity file from the > default. > I've added it as identity_file in new and in a accessor. > > Let me know what you think.
No patch was attached to your message.
Subject: Re: [rt.cpan.org #38008] Net-SCP Patch
Date: Tue, 29 Jul 2008 19:29:18 +0100 (BST)
To: bug-Net-SCP [...] rt.cpan.org
From: gbjk [...] mx1.thermeon.eu
I have double checked and the patch was attached both times. I've checked the MIME in the Maildir file for sent items and evolution seems to have done everything sane. Therefore here it is inline: diff -Naur Net-SCP-0.08/SCP.pm Net-SCP-new/SCP.pm --- Net-SCP-0.08/SCP.pm 2008-07-25 10:52:16.000000000 +0100 +++ Net-SCP-new/SCP.pm 2008-07-25 10:53:25.000000000 +0100 @@ -71,20 +71,22 @@ sub scp { my $self = ref($_[0]) ? shift : {}; my($src, $dest, $interact) = @_; - my $flags = '-p'; - $flags .= 'r' unless &_islocal($src) && ! -d $src; + $dest = $self->{'user'}. '@'. $dest if $self->{'user'}; + my @flags = ('-p'); + push @flags, '-r' unless &_islocal($src) && ! -d $src; + push @flags, '-i', $self->{identity_file} if $self->{identity_file}; my @cmd; if ( ( defined($interact) && $interact ) || ( defined($self->{interactive}) && $self->{interactive} ) ) { - @cmd = ( $scp, $flags, $src, $dest ); + @cmd = ( $scp, @flags, $src, $dest ); print join(' ', @cmd), "\n"; unless ( &_yesno ) { $self->{errstr} = "User declined"; return 0; } } else { - $flags .= 'qB'; - @cmd = ( $scp, $flags, $src, $dest ); + push @flags, '-qB'; + @cmd = ( $scp, @flags, $src, $dest ); } my($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); @@ -150,6 +152,7 @@ user - username interactive - bool cwd - current working directory on remote server + identity_file - identity file to be used for public key authentication =cut @@ -166,6 +169,7 @@ 'interactive' => 0, 'cwd' => '', }; + $self->{identity_file} = shift if scalar @_; } bless($self, $class); } @@ -181,6 +185,17 @@ $self->{'user'} = $user if $user; } +=item identity_file [IDENTITY_FILE] + +Sets the identity file used for public key authentication. + +=cut + +sub identity_file { + my($self, $identity_file) = @_; + $self->{'identity_file'} = $identity_file if $identity_file; +} + =item cwd CWD Sets the cwd (used for a subsequent get or put request without a full pathname). @@ -204,7 +219,6 @@ $remote = $self->{'cwd'}. "/$remote" if $self->{'cwd'} && $remote !~ /^\//; $local ||= basename($remote); my $source = $self->{'host'}. ":$remote"; - $source = $self->{'user'}. '@'. $source if $self->{'user'}; $self->scp($source,$local); } @@ -289,7 +303,6 @@ $remote ||= basename($local); $remote = $self->{'cwd'}. "/$remote" if $self->{'cwd'} && $remote !~ /^\//; my $dest = $self->{'host'}. ":$remote"; - $dest = $self->{'user'}. '@'. $dest if $self->{'user'}; warn "scp $local $dest\n" if $DEBUG; $self->scp($local, $dest); }