summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAn-Cheng Huang <ancheng@vyatta.com>2010-06-08 16:18:23 -0700
committerAn-Cheng Huang <ancheng@vyatta.com>2010-06-08 16:18:23 -0700
commita102e2b878bc334efbf0ea250d8e8e8ec170ca58 (patch)
tree2f4848678122e1dac4fc066615560d89c12cd381
parent1f784903ec79a37185cd5b961491843138b263e9 (diff)
downloadvyatta-cfg-a102e2b878bc334efbf0ea250d8e8e8ec170ca58.tar.gz
vyatta-cfg-a102e2b878bc334efbf0ea250d8e8e8ec170ca58.zip
fix for bug 5213
* handle absolute variable references correctly.
-rw-r--r--src/cli_new.c3
-rw-r--r--src/cli_val_engine.c31
-rw-r--r--src/cli_val_engine.h1
3 files changed, 15 insertions, 20 deletions
diff --git a/src/cli_new.c b/src/cli_new.c
index 06bd4bf..842a4a2 100644
--- a/src/cli_new.c
+++ b/src/cli_new.c
@@ -1133,7 +1133,6 @@ static int change_var_value(const char* var_reference,const char* value, int act
n_cmd_path,
FALSE,
&cv,
- get_cdirp(),
get_tdirp(),
TRUE)==0) {
var_path=cv.value;
@@ -1403,7 +1402,6 @@ static int eval_va(valstruct *res, vtw_node *node)
n_cmd_path,
TRUE,
&cv,
- get_cdirp(),
get_tdirp(),
FALSE);
@@ -1562,7 +1560,6 @@ static int expand_string(char *stringp)
n_cmd_path,
TRUE,
&cv,
- get_cdirp(),
get_tdirp(),
FALSE)==0) {
cp=cv.value;
diff --git a/src/cli_val_engine.c b/src/cli_val_engine.c
index f43b521..72155d8 100644
--- a/src/cli_val_engine.c
+++ b/src/cli_val_engine.c
@@ -602,6 +602,14 @@ static clind_path_ref* clind_config_engine_apply_command(clind_path_ref cfg_path
* cfg_path - absolute configuration path,
* tmpl_path - logical template path,
* cmd_path - variable command path.
+ *
+ * note: root_cfg_path should not be necessary as absolute paths are already
+ * handled before this is called (see set_reference_environment() in
+ * cli_new.c). cli_new.c was passing the wrong path (changes only)
+ * anyway, causing problems with absolute paths (bug 5213).
+ * root_tmpl_path should not be necessary either but it's
+ * used in one place in clind_get_current_value() (it's not clear
+ * if that case is ever reached), so keep it for now.
*/
int clind_config_engine_apply_command_path(clind_path_ref cfg_path_orig,
@@ -609,7 +617,6 @@ int clind_config_engine_apply_command_path(clind_path_ref cfg_path_orig,
clind_path_ref cmd_path,
int check_existence,
clind_val* res,
- const char* root_cfg_path,
const char* root_tmpl_path,
int return_value_file_name) {
@@ -623,11 +630,11 @@ int clind_config_engine_apply_command_path(clind_path_ref cfg_path_orig,
root_tmpl_path);
*/
DPRINT("eng_apply_cmd_path cfg=[%s] tmpl=[%s] cmd=[%s] "
- "rcfg=[%s] rtmpl=[%s]\n",
+ "rtmpl=[%s]\n",
clind_path_get_path_string(cfg_path_orig),
clind_path_get_path_string(tmpl_path_orig),
clind_path_get_path_string(cmd_path),
- root_cfg_path, root_tmpl_path);
+ root_tmpl_path);
if(cfg_path_orig && tmpl_path_orig && cmd_path && res) {
@@ -646,19 +653,11 @@ int clind_config_engine_apply_command_path(clind_path_ref cfg_path_orig,
clind_path_ref tmpl_path=NULL;
clind_path_ref cfg_path=NULL;
- if(clind_path_is_absolute(cmd_path)) {
- tmpl_path=clind_path_construct(root_tmpl_path);
- if(!tmpl_path) {
- return -1;
- }
- cfg_path=clind_path_construct(root_cfg_path);
- if(!cfg_path) {
- return -1;
- }
- } else {
- cfg_path=clind_path_clone(cfg_path_orig);
- tmpl_path=clind_path_clone(tmpl_path_orig);
- }
+ /* absolute paths have already been handled, i.e., the _orig paths
+ * can be used directly.
+ */
+ cfg_path=clind_path_clone(cfg_path_orig);
+ tmpl_path=clind_path_clone(tmpl_path_orig);
res->value=NULL;
res->val_type=TEXT_TYPE;
diff --git a/src/cli_val_engine.h b/src/cli_val_engine.h
index 6315dac..a0c1fe3 100644
--- a/src/cli_val_engine.h
+++ b/src/cli_val_engine.h
@@ -80,7 +80,6 @@ int clind_config_engine_apply_command_path(clind_path_ref cfg_path,
clind_path_ref cmd_path,
int check_existence,
clind_val *res,
- const char* root_cfg_path,
const char* root_tmpl_path,
int return_value_file_name);