From 5a67b5f11976a24d4c4fe40b91ff4fc0f55a0429 Mon Sep 17 00:00:00 2001 From: Leon Messner Date: Sun, 25 Oct 2015 15:57:59 +0100 Subject: Bug 584 - Allow sftp as copy and commit-archive location destination. --- scripts/vyatta-load-config.pl | 7 ++++--- scripts/vyatta-save-config.pl | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl index dc9ad6e..f6dfba3 100755 --- a/scripts/vyatta-load-config.pl +++ b/scripts/vyatta-load-config.pl @@ -78,7 +78,8 @@ if ( $load_file =~ /^[^\/]\w+:\// ) { unless( $proto eq 'tftp' || $proto eq 'ftp' || $proto eq 'http' || - $proto eq 'scp' ) { + $proto eq 'scp' || + $proto eq 'sftp' ) { die "Invalid url protocol [$proto]\n"; } } else { @@ -127,8 +128,8 @@ elsif ( $mode eq 'url' ) { } } my $rc = system("curl -# -o $url_tmp_file $load_file"); - if ($proto eq 'scp' && ($rc >> 8) == 51){ - $load_file =~ m/scp:\/\/(.*?)\//; + if ($proto =~ /^(scp|sftp)$/ && ($rc >> 8) == 51){ + $load_file =~ m/(scp|sftp):\/\/(.*?)\//; my $host = $1; if ($host =~ m/.*@(.*)/) { $host = $1; diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl index 96dd4b1..439e873 100755 --- a/scripts/vyatta-save-config.pl +++ b/scripts/vyatta-save-config.pl @@ -60,6 +60,7 @@ if ($save_file =~ /^[^\/]\w+:\//) { if ($proto eq 'tftp') { } elsif ($proto eq 'ftp') { } elsif ($proto eq 'scp') { + } elsif ($proto eq 'sftp') { } else { print "Invalid url protocol [$proto]\n"; exit 1; @@ -123,8 +124,8 @@ close $save; if ($mode eq 'url') { my $rc = 0; - if ($proto eq 'scp'){ - $save_file =~ m/scp:\/\/(.*?)\//; + if ($proto =~ /^(scp|sftp)$/){ + $save_file =~ m/(scp|sftp):\/\/(.*?)\//; my $host = $1; my $user = getpwuid($<); if ($host =~ m/(.*)@(.*)/) { -- cgit v1.2.3 From a04116d13ea5968403259c37fc55e618a98b9dd9 Mon Sep 17 00:00:00 2001 From: Leon Messner Date: Sun, 25 Oct 2015 19:01:44 +0100 Subject: Prevent grouping from capturing --- scripts/vyatta-load-config.pl | 2 +- scripts/vyatta-save-config.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl index f6dfba3..517b7ff 100755 --- a/scripts/vyatta-load-config.pl +++ b/scripts/vyatta-load-config.pl @@ -129,7 +129,7 @@ elsif ( $mode eq 'url' ) { } my $rc = system("curl -# -o $url_tmp_file $load_file"); if ($proto =~ /^(scp|sftp)$/ && ($rc >> 8) == 51){ - $load_file =~ m/(scp|sftp):\/\/(.*?)\//; + $load_file =~ m/(?:scp|sftp):\/\/(.*?)\//; my $host = $1; if ($host =~ m/.*@(.*)/) { $host = $1; diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl index 439e873..0799dd4 100755 --- a/scripts/vyatta-save-config.pl +++ b/scripts/vyatta-save-config.pl @@ -125,7 +125,7 @@ if ($mode eq 'url') { my $rc = 0; if ($proto =~ /^(scp|sftp)$/){ - $save_file =~ m/(scp|sftp):\/\/(.*?)\//; + $save_file =~ m/(?:scp|sftp):\/\/(.*?)\//; my $host = $1; my $user = getpwuid($<); if ($host =~ m/(.*)@(.*)/) { -- cgit v1.2.3