summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriyEshenko <snooppy@mail.ua>2019-10-16 18:32:33 +0000
committerDmitriyEshenko <snooppy@mail.ua>2019-10-16 18:32:33 +0000
commit2c93b4079c9dec03f49ab4299e2dc1d568b0c35b (patch)
tree94f9410cc8fcff811f94c75bccb679e97a3e9f41
parent735ff86dbf6a00c08bdf0077eb91e6ce9367191d (diff)
downloadvyatta-op-2c93b4079c9dec03f49ab4299e2dc1d568b0c35b.tar.gz
vyatta-op-2c93b4079c9dec03f49ab4299e2dc1d568b0c35b.zip
T1401 fixing copy command, protocol FTP. Using hexdecimal for # and @ chars in password.
-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:\/\/(.*?)\//;