From b5b1c71bc95bdaea24f45e5738e9a3a7f8740a4f Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Mon, 30 Jun 2008 10:18:44 -0700 Subject: set load-balancing load order after interfaces are configured on load. --- scripts/VyattaConfigLoad.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index f1339c3..936a9cf 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -49,7 +49,7 @@ my %config_rank = ( 'protocols ospf' => 780, 'protocols rip' => 770, 'vpn' => 600, - + 'load-balancing' => 500, ); my %regex_rank = ( -- cgit v1.2.3 From e6e7dc57dc71495c40ee6937bff703c2c4a7f3ed Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Mon, 30 Jun 2008 11:28:55 -0700 Subject: fix for bug 3400. user vyatta needed modification to discard command. --- etc/bash_completion.d/20vyatta-cfg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index f1d100e..a034937 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -75,9 +75,10 @@ discard () changes=0 fi - sudo umount ${VYATTA_TEMP_CONFIG_DIR}; - sudo rm -fr ${VYATTA_CHANGES_ONLY_DIR}; - sudo mkdir -p ${VYATTA_CHANGES_ONLY_DIR}; + sudo umount $VYATTA_TEMP_CONFIG_DIR + sudo rm -fr $VYATTA_CHANGES_ONLY_DIR $VYATTA_TEMP_CONFIG_DIR + make_vyatta_config_dir $VYATTA_CHANGES_ONLY_DIR + make_vyatta_config_dir $VYATTA_TEMP_CONFIG_DIR sudo mount -t unionfs -o dirs=${VYATTA_CHANGES_ONLY_DIR}=rw:${VYATTA_ACTIVE_CONFIGURATION_DIR}=ro unionfs ${VYATTA_TEMP_CONFIG_DIR}; if (( changes )); then -- cgit v1.2.3 From c90fc08925d58c10d0a462751d8ed51b90253eed Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 30 Jun 2008 14:33:50 -0700 Subject: add help string for "copy" and "rename" --- etc/bash_completion.d/20vyatta-cfg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index a034937..3b523bd 100755 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -814,22 +814,26 @@ vyatta_config_complete () if (( ${#COMP_WORDS[@]} < 2 )); then declare -a hitems=( "commit" \ + "copy" \ "delete" \ - "discard" \ + "discard" \ "edit" \ "exit" \ "load" \ + "rename" \ "run" \ "save" \ "set" \ "show" ) declare -a hstrs=( \ "Commit the current set of changes" \ + "Copy a configuration element" \ "Delete a configuration element" \ "Discard uncommitted changes" \ "Edit a sub-element" \ "Exit from this configuration level" \ "Load configuration from a file" \ + "Rename a configuration element" \ "Run an operational-mode command" \ "Save configuration to a file" \ "Set the value of a parameter or create a new element" \ -- cgit v1.2.3 From 7800d646eb6af2a41b82f25bd2961bfaf1dd202e Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Mon, 30 Jun 2008 15:31:24 -0700 Subject: Fix 3396: "commit failed at rank 800" while booting with bgp peer-group. --- scripts/VyattaConfigLoad.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index 936a9cf..0e0c658 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -56,7 +56,8 @@ my %regex_rank = ( 'interfaces ethernet \S* vrrp' => 500, 'interfaces ethernet \S* vif \S* vrrp' => 500, 'protocols bgp \d+ parameters' => 810, - 'protocols bgp \d+ neighbor \S*[^\d.]\S*' => 800, + 'protocols bgp \d+ neighbor \d+\.\d+\.\d+\.\d+' => 800, + 'protocols bgp \d+ neighbor \w+' => 801, ); my @all_nodes = (); -- cgit v1.2.3 From 2eb529344218114f29d34e60f8485d18e49508ce Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Mon, 30 Jun 2008 17:11:10 -0700 Subject: Revert "set load-balancing load order after interfaces are configured on load." This reverts commit b5b1c71bc95bdaea24f45e5738e9a3a7f8740a4f. --- scripts/VyattaConfigLoad.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index 936a9cf..f1339c3 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -49,7 +49,7 @@ my %config_rank = ( 'protocols ospf' => 780, 'protocols rip' => 770, 'vpn' => 600, - 'load-balancing' => 500, + ); my %regex_rank = ( -- cgit v1.2.3 From 4fd96a54d3c4c523ee9df1d6999f95142c68c5f4 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 30 Jun 2008 19:38:21 -0700 Subject: fix for bug 3403: allocate correct amount of memory for multi-valued nodes. --- src/cli_new.c | 33 ++++++++++++++++++++++++++++++--- src/cli_val.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/cli_new.c b/src/cli_new.c index 26cc719..b66d83c 100644 --- a/src/cli_new.c +++ b/src/cli_new.c @@ -1926,24 +1926,51 @@ void subtract_values(char **lhs, const char *rhs) if (lhs == NULL || *lhs == NULL || **lhs == '\0' || rhs == NULL || *rhs == '\0') return; + /* calculate number of rhs entries */ rhs_copy = strdup(rhs); - length = strlen(rhs) / 2; + line = strtok(rhs_copy, "\n\r"); + while (line != NULL && *line != '\0') { + rhs_cnt++; + line = strtok(NULL, "\n\r"); + } + + /* strtok destroys the string. dup again. */ + free(rhs_copy); + rhs_copy = strdup(rhs); + + /* allocate enough space for all old entries (to be subtracted) */ + length = rhs_cnt * sizeof(char *); head = ptr = my_malloc(length, "subtract_values list1"); memset(head, 0, length); + /* parse the entries and put them in head[] */ line = strtok(rhs_copy, "\n\r"); while (line != NULL && *line != '\0') { *ptr = line; ptr++; - rhs_cnt++; line = strtok(NULL, "\n\r"); } - length = strlen(*lhs) / 2; + /* calculate number of lhs entries */ + { + char *lhs_copy = strdup(*lhs); + line = strtok(lhs_copy, "\n\r"); + while (line != NULL && *line != '\0') { + lhs_cnt++; + line = strtok(NULL, "\n\r"); + } + free(lhs_copy); + } + + /* allocate enough space for all new entries */ + length = lhs_cnt * sizeof(char *); new_head = new_ptr = my_malloc(length, "subtract_values list2"); memset(new_head, 0, length); + /* reset length and lhs_cnt. they are now used for the "new" array (i.e., + * after subtraction). */ length = 0; + lhs_cnt = 0; line = strtok(*lhs, "\n\r"); while (line != NULL && *line != '\0') { for (i = 0; i < rhs_cnt; i++) { diff --git a/src/cli_val.h b/src/cli_val.h index 520fa8e..56f6cee 100644 --- a/src/cli_val.h +++ b/src/cli_val.h @@ -214,6 +214,7 @@ extern int get_config_lock(); extern int out_fd; extern FILE *out_stream; +extern FILE *err_stream; extern int initialize_output(); -- cgit v1.2.3 From 89690fab7e1b49ab8a97a5c9907982bec45e85d5 Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Tue, 1 Jul 2008 13:56:24 -0700 Subject: fix for bug 3377. --- src/delete.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/delete.c b/src/delete.c index 9bdb3ed..bb2c987 100644 --- a/src/delete.c +++ b/src/delete.c @@ -291,8 +291,10 @@ int main(int argc, char **argv) if (status != VTWERR_OK) bye("Corrupted old value ---- \n%s\n-----\n", cp); res = val_cmp(&new_value, &old_value, IN_COND); - if (!res) + if (!res) { + fprintf(out_stream, "%s is not a configured value\n", new_value.val); bye("Not in multivalue"); + } touch(); if (old_value.cnt) { push_path(&m_path, VAL_NAME); -- cgit v1.2.3 From 23c2cf67eda71cd15a94f1a28a9e699ea45cbc3e Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Tue, 1 Jul 2008 17:12:07 -0700 Subject: Partial fix for 3383: check for vyatta-config-version, warn/prompt that it appears to be invalid config. --- scripts/vyatta-load-config.pl | 34 +++++++++++++++++++++++++++------- 1 file 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 () { if (/\/\*XORP Configuration File, v1.0\*\//) { - print "Warning: Loading a pre-Glendale configuration.\n"; - print "Do you want to continue? [no] "; - my $resp = ; - 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"); -- cgit v1.2.3 From 93a148a78b577ced2cfaebdbe1659e3ecc58c4aa Mon Sep 17 00:00:00 2001 From: Michael Larson Date: Mon, 7 Jul 2008 12:05:27 -0700 Subject: fix for bug 3216. added no escape option to push path for environmental path variable. note this is appied to all c code access to the edit env variable. --- src/cli_new.c | 28 ++++++++++++++++++++++++++++ src/cli_objects.c | 2 +- src/cli_val.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/cli_new.c b/src/cli_new.c index b66d83c..0b50ccb 100644 --- a/src/cli_new.c +++ b/src/cli_new.c @@ -1774,7 +1774,35 @@ void push_path(vtw_path *path, char *segm) }else *pp = *cp; *pp = 0; + path->path_len += len; + if (path->path_lev == path->path_ends_alloc){ + path->path_ends_alloc += ENDS_ALLOC; + path->path_ends = (int *)my_realloc(path->path_ends, + sizeof(int *)*path->path_ends_alloc, "puhs_path 2"); + } + path->path_ends[path->path_lev++] = path->path_len; + // push_path_no_escape(); +} +/** + * Version of above that doesn't escape value before stuffing. + * + **/ +void push_path_no_escape(vtw_path *path, char *segm) +{ + int len; + char *cp; + char *pp; + + for(cp=segm, len=0;*cp;++cp, ++len); + warrant_path(path, len + 1); + path->path_buf[path->path_len] = '/'; + path->path_buf[++path->path_len] = 0; + for(pp=path->path_buf + path->path_len,cp=segm; + *cp;++cp, ++pp) { + *pp = *cp; + } + *pp = 0; path->path_len += len; if (path->path_lev == path->path_ends_alloc){ path->path_ends_alloc += ENDS_ALLOC; diff --git a/src/cli_objects.c b/src/cli_objects.c index 8f0f6fe..8685c6a 100644 --- a/src/cli_objects.c +++ b/src/cli_objects.c @@ -243,7 +243,7 @@ void init_edit() slashp = strchr(scanp, '/'); if (slashp) *slashp = 0; - push_path(&m_path, scanp); + push_path_no_escape(&m_path, scanp); if (slashp) { *slashp = '/'; scanp = slashp+1; diff --git a/src/cli_val.h b/src/cli_val.h index 56f6cee..c9d59a6 100644 --- a/src/cli_val.h +++ b/src/cli_val.h @@ -153,6 +153,7 @@ extern void cli_val_done(void); extern void init_path(vtw_path *path, const char *root); extern void pop_path(vtw_path *path); extern void push_path(vtw_path *path, char *segm); +extern void push_path_no_escape(vtw_path *path, char *segm); extern void free_def(vtw_def *defp); extern void free_sorted(vtw_sorted *sortp); extern void *my_malloc(size_t size, const char *name); -- cgit v1.2.3 From 9178dcb68c092976f9bed29c13dbd70cb26de3a1 Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Mon, 7 Jul 2008 14:35:36 -0700 Subject: fix for bug 3323: skip deletions of nodes with default values when loading a config file. --- scripts/VyattaConfigLoad.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index 6f8a451..1a7f26e 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -397,8 +397,19 @@ sub getConfigDiff { # everything together anyway. @delete_list = sort { ${$a}[1] <=> ${$b}[1] } @delete_list; @set_list = sort { ${$b}[1] <=> ${$a}[1] } @set_list; + + # need to filter out deletions of nodes with default values + my @new_delete_list = (); + foreach my $del (@delete_list) { + my @comps = map { s/^'(.*)'$/$1/; $_; } @{${$del}[0]}; + my ($is_multi, $is_text, $default) = $active_cfg->parseTmpl(\@comps); + if (!defined($default)) { + push @new_delete_list, $del; + } + } + my %diff = ( - 'delete' => \@delete_list, + 'delete' => \@new_delete_list, 'set' => \@set_list, ); return %diff; -- cgit v1.2.3 From 1277a4a911cf39e0e2200eea8ecbd483d1610f2f Mon Sep 17 00:00:00 2001 From: rbalocca Date: Mon, 7 Jul 2008 17:00:55 -0700 Subject: Fix for bug http://bugzilla.vyatta.com/show_bug.cgi?id=3427 --- etc/init.d/vyatta-ofr | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etc/init.d/vyatta-ofr b/etc/init.d/vyatta-ofr index 104903e..92acf45 100755 --- a/etc/init.d/vyatta-ofr +++ b/etc/init.d/vyatta-ofr @@ -118,6 +118,12 @@ start () done load_bootfile chmod g-w,o-w / + + ( [ -s /boot/grub/menu.lst ] && + upgrade-from-grub-legacy && + rm -f /boot/grub/menu.lst* + ) || true + log_end_msg $? } -- cgit v1.2.3 From 42d6c942800e2273b77ea92371ffdcb3f183163f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 9 Jul 2008 11:50:17 -0700 Subject: fix for bug 3441. Removed def from listOutputNodes(), which allowed other code that filters out def file to be removed. --- scripts/VyattaConfig.pm | 4 +++- scripts/VyattaConfigLoad.pm | 3 --- scripts/VyattaConfigOutput.pm | 6 ++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/scripts/VyattaConfig.pm b/scripts/VyattaConfig.pm index 3c4b51f..1c0eaf3 100755 --- a/scripts/VyattaConfig.pm +++ b/scripts/VyattaConfig.pm @@ -130,7 +130,9 @@ sub listOrigNodes { $tmp =~ s/\n//g; $tmp =~ s/%2F/\//g; #print "DEBUG VyattaConfig->listNodes(): node = $tmp\n"; - push @nodes_modified, $tmp; + if ($tmp ne 'def') { + push @nodes_modified, $tmp; + } } return @nodes_modified; diff --git a/scripts/VyattaConfigLoad.pm b/scripts/VyattaConfigLoad.pm index 1a7f26e..c8563bb 100755 --- a/scripts/VyattaConfigLoad.pm +++ b/scripts/VyattaConfigLoad.pm @@ -297,9 +297,6 @@ sub findDeletedNodes { $active_cfg->setLevel(join ' ', @active_path); my @active_nodes = $active_cfg->listOrigNodes(); foreach (@active_nodes) { - if ($_ eq 'def') { - next; - } if ($_ eq 'node.val') { findDeletedValues($new_ref, \@active_path); next; diff --git a/scripts/VyattaConfigOutput.pm b/scripts/VyattaConfigOutput.pm index 5358c21..ab7068f 100755 --- a/scripts/VyattaConfigOutput.pm +++ b/scripts/VyattaConfigOutput.pm @@ -138,7 +138,7 @@ sub displayValues { my @cnames = sort keys %cnodes; if (defined($simple_show)) { - if (!$cnodes{'def'} || $show_all) { + if ($show_all) { if ($is_password && $hide_password) { $oval = $HIDE_PASSWORD; } @@ -159,7 +159,7 @@ sub displayValues { $diff = '>'; } } - if (!$cnodes{'def'} || $show_all) { + if ($show_all) { if ($is_password && $hide_password) { $value = $HIDE_PASSWORD; } @@ -194,8 +194,6 @@ sub displayDeletedOrigChildren { if ($cnames[0] eq 'node.val') { displayValues([ @cur_path, $child ], $prefix, $child, $dont_show_as_deleted); - } elsif ($cnames[0] eq 'def') { - #ignore } elsif (scalar($#cnames) >= 0) { if ($is_tag) { @cnames = sort versioncmp @cnames; -- cgit v1.2.3