summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2011-07-14 18:49:09 -0500
committerJohn Southworth <john.southworth@vyatta.com>2011-07-14 18:49:09 -0500
commit9f1ff5427e0f72f2bded287be6e1d4cf442945cb (patch)
treec41d95dab7229423062c465d3bec530c0fe1a7ea
parent037df4c460075b74a8e2c16b2d62a65807b293d9 (diff)
downloadvyatta-cfg-9f1ff5427e0f72f2bded287be6e1d4cf442945cb.tar.gz
vyatta-cfg-9f1ff5427e0f72f2bded287be6e1d4cf442945cb.zip
Don't allow users to set migration comments
-rwxr-xr-xetc/bash_completion.d/vyatta-cfg4
-rwxr-xr-xscripts/vyatta-save-config.pl1
-rw-r--r--src/cstore/cstore.cpp10
3 files changed, 13 insertions, 2 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg
index 776c56b..8626342 100755
--- a/etc/bash_completion.d/vyatta-cfg
+++ b/etc/bash_completion.d/vyatta-cfg
@@ -97,9 +97,9 @@ show ()
args+=("$arg")
fi
done
+ # Note: the sed command below is to fix bug 7331
cli-shell-api "${opts[@]}" -- showCfg "${args[@]}" \
- | sed -e '/--- CONFIGURATION COMMENTED OUT DURING MIGRATION BELOW ---/\
- ,/--- CONFIGURATION COMMENTED OUT DURING MIGRATION ABOVE ---/d'\
+ | sed -e '/--- CONFIGURATION COMMENTED OUT DURING MIGRATION BELOW ---/,/--- CONFIGURATION COMMENTED OUT DURING MIGRATION ABOVE ---/d'\
| eval "${VYATTA_PAGER:-cat}"
}
diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl
index 51417b6..6dc833c 100755
--- a/scripts/vyatta-save-config.pl
+++ b/scripts/vyatta-save-config.pl
@@ -107,6 +107,7 @@ my $show_cmd = 'cli-shell-api showConfig --show-active-only --show-ignore-edit';
if ($show_default) {
$show_cmd .= ' --show-show-defaults';
}
+# add a sed command to remove unwanted configuration comments.
$show_cmd .= "| sed -e \'/--- CONFIGURATION COMMENTED OUT DURING MIGRATION BELOW ---/";
$show_cmd .= ",/--- CONFIGURATION COMMENTED OUT DURING MIGRATION ABOVE ---/d\'";
open(my $show_fd, '-|', $show_cmd) or die 'Cannot execute config output';
diff --git a/src/cstore/cstore.cpp b/src/cstore/cstore.cpp
index 9a5961f..c86631b 100644
--- a/src/cstore/cstore.cpp
+++ b/src/cstore/cstore.cpp
@@ -997,6 +997,16 @@ Cstore::commentCfgPath(const Cpath& args)
output_user("Cannot use the '*' character in a comment\n");
return false;
}
+ if (comment.find("CONFIGURATION COMMENTED OUT DURING MIGRATION BELOW") != string::npos){
+ // Don't allow users to set configuration migration comments
+ output_user("Cannot use the string 'CONFIGURATION COMMENTED OUT DURING MIGRATION BELOW' in a comment\n");
+ return false;
+ }
+ if (comment.find("CONFIGURATION COMMENTED OUT DURING MIGRATION ABOVE") != string::npos){
+ // Don't allow users to set configuration migration comments
+ output_user("Cannot use the string 'CONFIGURATION COMMENTED OUT DURING MIGRATION ABOVE' in a comment\n");
+ return false;
+ }
bool ret = false;
{