diff options
author | slioch <slioch@eng-140.vyatta.com> | 2009-10-19 15:42:46 -0700 |
---|---|---|
committer | slioch <slioch@eng-140.vyatta.com> | 2009-10-19 15:42:46 -0700 |
commit | f7f90ef2c60c493c58378a13ce77b74443ec8796 (patch) | |
tree | 066cba923645d772ed7aa962d83bbd0c01c3af49 /scripts | |
parent | 0437ad64813fb30beb05dcd76b50a1d95c1e3f00 (diff) | |
download | vyatta-cfg-f7f90ef2c60c493c58378a13ce77b74443ec8796.tar.gz vyatta-cfg-f7f90ef2c60c493c58378a13ce77b74443ec8796.zip |
add sudo back to save command, and add check to save script that validates vyatta config token at end of file. this will prevent the
accidental overwrite of non vyatta config files. check on prevent existing files that don't contain ' === vyatta-config-version:'
from being saved to.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-save-config.pl | 9 |
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"; |