summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDmitriyEshenko <snooppy@mail.ua>2019-10-16 18:32:33 +0000
committerDaniil Baturin <daniil@baturin.org>2019-11-05 13:44:32 +0100
commit2a1e08a617d7d6bbc6aa8c4f53be3412f7e47dfd (patch)
treed7af1b61ad63fccc3555d63671772b6001397ce2 /scripts
parentfd46d4cfd23783899dd0af370b2fa281126e1fb8 (diff)
downloadvyatta-op-2a1e08a617d7d6bbc6aa8c4f53be3412f7e47dfd.tar.gz
vyatta-op-2a1e08a617d7d6bbc6aa8c4f53be3412f7e47dfd.zip
T1401 fixing copy command, protocol FTP. Using hexdecimal for # and @ chars in password.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-image-tools.pl28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/vyatta-image-tools.pl b/scripts/vyatta-image-tools.pl
index 2dd95df..092cbf7 100755
--- a/scripts/vyatta-image-tools.pl
+++ b/scripts/vyatta-image-tools.pl
@@ -215,8 +215,35 @@ sub rsync {
return $?;
}
+sub conv_spec_char {
+ my ($inpt_data) = @_;
+ #replace #
+ $inpt_data =~ s/\#/%23/g;
+ #replace @
+ $inpt_data =~ s/\@/%40/g;
+ return $inpt_data;
+}
+
+sub prepare_login_data {
+ my ($uri_data) = @_;
+ # Parse protocol
+ if ($uri_data =~ /ftp\:\/\//){
+ $uri_data = reverse($');
+ # Separate host and username login data
+ $uri_data =~ m/@/;
+ my $host_data = reverse($`);
+ my $login_data = reverse($');
+ $login_data =~ /\:/;
+ my $username = $`;
+ my $password = conv_spec_char($');
+ return "ftp://".$username.":".$password."@".$host_data;
+ }
+ return $uri_data;
+}
+
sub curl_to {
my ($from, $to) = @_;
+ $to = prepare_login_data($to);
my $rc = system("curl -# -T $from $to");
if ($to =~ /scp/ && ($rc >> 8) == 51){
$to =~ m/scp:\/\/(.*?)\//;
@@ -246,6 +273,7 @@ sub curl_to {
sub curl_from {
my ($from, $to) = @_;
+ $from = prepare_login_data($from);
my $rc = system("curl -# $from > $to");
if ($from =~ /scp/ && ($rc >> 8) == 51){
$from =~ m/scp:\/\/(.*?)\//;