diff options
author | alex <alex@builder.localdomain> | 2007-12-11 15:12:36 -0800 |
---|---|---|
committer | alex <alex@builder.localdomain> | 2007-12-11 15:12:36 -0800 |
commit | fb9450551d5757a45806a062d7457a761e6dd295 (patch) | |
tree | cda8e28bdf2c1bc23d98de6de9437b1c90c5f654 /src/commit.c | |
parent | 1d78b0c336c8d3ae62f65983098584a6e2e613ce (diff) | |
download | vyatta-cfg-fb9450551d5757a45806a062d7457a761e6dd295.tar.gz vyatta-cfg-fb9450551d5757a45806a062d7457a761e6dd295.zip |
Bug #2509
Multivalue nodes are diffed with previous value for validation before
commit.
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/commit.c b/src/commit.c index 4820094..2eedf6f 100644 --- a/src/commit.c +++ b/src/commit.c @@ -91,7 +91,7 @@ static boolean validate_dir_for_commit() def_present = TRUE; memset(&def, 0, sizeof(def)); #ifdef DEBUG1 - printf("Parsing definition\n"); + printf("Parsing definition %s\n", t_path.path); #endif if ((status = parse_def(&def, t_path.path, @@ -102,7 +102,7 @@ static boolean validate_dir_for_commit() } #ifdef DEBUG1 else - printf("No definition\n"); + printf("No definition %s\n", t_path.path); #endif pop_path(&t_path); /* for PUSH 1 */ @@ -156,11 +156,27 @@ static boolean validate_dir_for_commit() /* read it */ cp = NULL; status = get_value(&cp, &m_path); - if (status == VTWERR_OK){ + if (status == VTWERR_OK) { #ifdef DEBUG1 printf("Validating value |%s|\n" "for path %s\n", cp, m_path.path); #endif + + // multivalue has to be diff-ed with the pre-existing value. + // only the difference should be ran through the validation. + // Bug #2509 + if (def.multi) { + char *old_value = NULL; + switch_path(APATH); // temporarily switching to the active config path + status = get_value(&old_value, &m_path); + if (status == VTWERR_OK) { + subtract_values(&cp, old_value); + } + switch_path(CPATH); + if (old_value) + my_free(old_value); + } + status = validate_value(&def, cp); ret = ret && status; } @@ -232,7 +248,7 @@ static boolean validate_dir_for_commit() } if (def_present && def.tag) - pop_path(&t_path); /* for PUSH 3a */ + pop_path(&t_path); /* for PUSH 2a */ if (def_present) free_def(&def); #ifdef DEBUG |