summaryrefslogtreecommitdiff
path: root/src/cstore
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2011-10-24 15:21:41 -0500
committerJohn Southworth <john.southworth@vyatta.com>2011-10-24 15:21:41 -0500
commit0afc8b03a892d426dcc4bc943beec5fb595c5800 (patch)
treeabc1b573870748a45574d34791fc33f4f1b895de /src/cstore
parent75b9812996b62d0d307d5b3b5cd9a5eb0fec61ac (diff)
downloadvyatta-cfg-0afc8b03a892d426dcc4bc943beec5fb595c5800.tar.gz
vyatta-cfg-0afc8b03a892d426dcc4bc943beec5fb595c5800.zip
Add VarRef translation to the allowed field for config mode
Diffstat (limited to 'src/cstore')
-rw-r--r--src/cstore/cstore.cpp29
-rw-r--r--src/cstore/cstore.hpp1
2 files changed, 30 insertions, 0 deletions
diff --git a/src/cstore/cstore.cpp b/src/cstore/cstore.cpp
index 5f2eb79..aacd15a 100644
--- a/src/cstore/cstore.cpp
+++ b/src/cstore/cstore.cpp
@@ -527,6 +527,34 @@ Cstore::getEditResetEnv(string& env)
return true;
}
+void
+Cstore::getAllowedVarRef(string& astr){
+ size_t varloc = 0;
+ size_t strloc = 0;
+ vtw_type_e vtype = ERROR_TYPE;
+ string exe_string = "";
+ string varref = "";
+ size_t first_paren, second_paren;
+ while(true) {
+ varloc = astr.find("$VAR", strloc);
+ if (varloc == string::npos){
+ varloc = astr.size();
+ exe_string += astr.substr(strloc, (varloc-strloc+1));
+ break;
+ }
+ exe_string += astr.substr(strloc, (varloc-strloc));
+ strloc = varloc;
+ first_paren = astr.find('(', strloc);
+ second_paren = astr.find(')', strloc);
+ varref = astr.substr((first_paren+1), (second_paren-first_paren-1));
+ varref = string(getVarRef(varref.c_str(), vtype, false));
+ strloc = second_paren+1;
+ exe_string += varref;
+ }
+ astr = exe_string;
+ return;
+}
+
/* set "env" arg to the environment string needed for "completion".
* return true if successful.
*
@@ -688,6 +716,7 @@ Cstore::getCompletionEnv(const Cpath& comps, string& env)
} else {
string astr = def->getAllowed();
shell_escape_squotes(astr);
+ getAllowedVarRef(astr);
cmd_str += "_cstore_internal_allowed () { eval '";
cmd_str += astr;
cmd_str += "'; }; _cstore_internal_allowed";
diff --git a/src/cstore/cstore.hpp b/src/cstore/cstore.hpp
index 69da796..741d9f1 100644
--- a/src/cstore/cstore.hpp
+++ b/src/cstore/cstore.hpp
@@ -504,6 +504,7 @@ private:
va_list alist);
static void voutput_internal(const char *fmt, va_list alist);
static void vexit_internal(const char *fmt, va_list alist);
+ void getAllowedVarRef(string& astr);
};
} // end namespace cstore