diff options
author | Michael Larson <slioch@slioch.vyatta.com> | 2010-06-08 17:05:44 -0700 |
---|---|---|
committer | Michael Larson <slioch@slioch.vyatta.com> | 2010-06-08 17:05:44 -0700 |
commit | 137a9d8c3944819791f045cf7491e59017a71c80 (patch) | |
tree | 2e038098ca50b56bdbc068c4f24bb0f5d1312080 | |
parent | 6ec3c03e294c15ce7a4a746468424a96efdb380e (diff) | |
download | vyatta-cfg-137a9d8c3944819791f045cf7491e59017a71c80.tar.gz vyatta-cfg-137a9d8c3944819791f045cf7491e59017a71c80.zip |
fix for bug 5667. Moved the location of the deactivate check.
-rw-r--r-- | src/cli_new.c | 33 | ||||
-rw-r--r-- | src/cli_val_engine.c | 64 |
2 files changed, 74 insertions, 23 deletions
diff --git a/src/cli_new.c b/src/cli_new.c index 842a4a2..b5d7add 100644 --- a/src/cli_new.c +++ b/src/cli_new.c @@ -98,9 +98,6 @@ static int set_reference_environment(const char* var_reference, clind_path_ref *n_tmpl_path, clind_path_ref *n_cmd_path, int active); -static boolean -is_deactivated(const clind_path_ref *path,const char *symbol) ; - /************************************************* GLOBAL FUNCTIONS ***************************************************/ @@ -1553,18 +1550,15 @@ static int expand_string(char *stringp) memset(&cv,0,sizeof(cv)); - if (is_deactivated(&n_cfg_path,scanp) == FALSE) { - - if(clind_config_engine_apply_command_path(n_cfg_path, - n_tmpl_path, - n_cmd_path, - TRUE, - &cv, - get_tdirp(), - FALSE)==0) { - cp=cv.value; - - } + if(clind_config_engine_apply_command_path(n_cfg_path, + n_tmpl_path, + n_cmd_path, + TRUE, + &cv, + get_tdirp(), + FALSE)==0) { + cp=cv.value; + } } @@ -2402,7 +2396,7 @@ system_out(const char *command) boolean -is_deactivated(const clind_path_ref *path,const char *symbol) +is_deactivated(const clind_path_ref *path) { if (path == NULL) { return FALSE; @@ -2413,13 +2407,6 @@ is_deactivated(const clind_path_ref *path,const char *symbol) char buf[1024]; //ALSO USED AS LIMIT IN UNIONFS path length strcpy(buf,path_string); - //now append symbol - if (symbol != NULL && strlen(symbol) > 2) { - strcat(buf,"/"); - strncat(buf,symbol,strlen(symbol)-2); - } - - //first we'll check the current directory char file[1024]; sprintf(file,"%s/.disable",buf); diff --git a/src/cli_val_engine.c b/src/cli_val_engine.c index 72155d8..3ac1735 100644 --- a/src/cli_val_engine.c +++ b/src/cli_val_engine.c @@ -59,6 +59,9 @@ static int is_multi_node(clind_path_ref tmpl_path); +static boolean +is_deactivated(const clind_path_ref *path); + /********************* * Data definitions * @@ -595,6 +598,11 @@ static clind_path_ref* clind_config_engine_apply_command(clind_path_ref cfg_path } } + + if (is_deactivated(&cfg_path) == TRUE) { + return NULL; + } + return ret; } @@ -916,3 +924,59 @@ static int clind_path_shift_cmd(clind_path_ref path,clind_cmd *cmd) { return ret; } + +boolean +is_deactivated(const clind_path_ref *path) +{ + if (path == NULL) { + return FALSE; + } + + const char* path_string = clind_path_get_path_string(*path); + + char buf[1024]; //ALSO USED AS LIMIT IN UNIONFS path length + strcpy(buf,path_string); + + //first we'll check the current directory + char file[1024]; + sprintf(file,"%s/.disable",buf); + struct stat s; + if (lstat(file,&s) == 0) { + return TRUE; + } + + long min_len = strlen("/opt/vyatta/config/tmp/new_config_"); + + //now walk back up tree looking for disable flag..... + while (TRUE) { + int index = strlen(buf)-1; + if (index < min_len) { + return FALSE; + } + if (buf[index] == '/') { + while (TRUE) { + if (buf[--index] != '/') { + buf[index] = '\0'; + break; + } + } + } + + char *ptr = rindex(buf,'/'); + if (ptr != NULL) { + *ptr = '\0'; + } + + char file[1024]; + sprintf(file,"%s/.disable",buf); + + // fprintf(out_stream,"checking file for disable: %s\n",file); + + struct stat s; + if (lstat(file,&s) == 0) { + return TRUE; + } + } + + return FALSE; +} |