summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@vyatta.com>2008-07-01 17:12:07 -0700
committerStig Thormodsrud <stig@vyatta.com>2008-07-01 17:12:07 -0700
commit23c2cf67eda71cd15a94f1a28a9e699ea45cbc3e (patch)
treea6fb6a7f2a5a2bc1177a24547176087786cf32dd /scripts
parent4fd96a54d3c4c523ee9df1d6999f95142c68c5f4 (diff)
downloadvyatta-cfg-23c2cf67eda71cd15a94f1a28a9e699ea45cbc3e.tar.gz
vyatta-cfg-23c2cf67eda71cd15a94f1a28a9e699ea45cbc3e.zip
Partial fix for 3383: check for vyatta-config-version, warn/prompt that it appears to be invalid config.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-load-config.pl34
1 files changed, 27 insertions, 7 deletions
diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl
index 29d4dec..ee4a9c4 100755
--- a/scripts/vyatta-load-config.pl
+++ b/scripts/vyatta-load-config.pl
@@ -23,6 +23,9 @@
use strict;
use lib "/opt/vyatta/share/perl5/";
+use POSIX;
+use IO::Prompt;
+use Sys::Syslog qw(:standard :macros);
use VyattaConfigLoad;
my $etcdir = $ENV{vyatta_sysconfdir};
@@ -42,6 +45,7 @@ my $proto;
if (defined($ARGV[0])) {
$load_file = $ARGV[0];
}
+my $orig_load_file = $load_file;
if ($load_file =~ /^[^\/]\w+:\//) {
if ($load_file =~ /^(\w+):\/\/\w/) {
@@ -107,20 +111,36 @@ if ($mode eq 'local') {
}
$load_file = $url_tmp_file;
}
+
+my $xorp_cfg = 0;
+my $valid_cfg = 0;
while (<CFG>) {
if (/\/\*XORP Configuration File, v1.0\*\//) {
- print "Warning: Loading a pre-Glendale configuration.\n";
- print "Do you want to continue? [no] ";
- my $resp = <STDIN>;
- if (!($resp =~ /^yes$/i)) {
- print "Configuration not loaded\n";
- exit 1;
- }
+ $xorp_cfg = 1;
+ last;
+ } elsif (/vyatta-config-version/) {
+ $valid_cfg = 1;
last;
}
}
+if ($xorp_cfg or ! $valid_cfg) {
+ if ($xorp_cfg) {
+ print "Warning: Loading a pre-Glendale configuration.\n";
+ } else {
+ print "Warning: file does NOT appear to be a valid config file.\n";
+ }
+ if (!prompt("Do you want to continue? ", -tty, -Yes, -default=>'no')) {
+ print "Configuration not loaded\n";
+ exit 1;
+ }
+}
close CFG;
+# log it
+openlog($0, "", LOG_USER);
+my $login = getlogin() || getpwuid($<) || "unknown";
+syslog("warning", "Load config [$orig_load_file] by $login");
+
# do config migration
system("$sbindir/vyatta_config_migrate.pl $load_file");