summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-save-config.pl9
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl
index 79cda88..e8220c0 100755
--- a/scripts/vyatta-save-config.pl
+++ b/scripts/vyatta-save-config.pl
@@ -68,6 +68,15 @@ print "Saving configuration to '$save_file'...\n";
my $save;
if ($mode eq 'local') {
+ # first check if this file exists, and if so ensure this is a config file.
+ if (-e $save_file) {
+ my $result = `grep ' === vyatta-config-version:' $save_file`;
+ if (!defined $result || length($result) == 0) {
+ print "File exists and is not a Vyatta configuration file, aborting save!\n";
+ exit 1;
+ }
+ }
+
# this overwrites the file if it exists. we could create a backup first.
open $save, '>', $save_file
or die "Can not open file '$save_file': $!\n";