summaryrefslogtreecommitdiff
path: root/src/cli_val_engine.c
diff options
context:
space:
mode:
authorMichael Larson <slioch@slioch.vyatta.com>2010-06-08 17:05:44 -0700
committerMichael Larson <slioch@slioch.vyatta.com>2010-06-08 17:05:44 -0700
commit137a9d8c3944819791f045cf7491e59017a71c80 (patch)
tree2e038098ca50b56bdbc068c4f24bb0f5d1312080 /src/cli_val_engine.c
parent6ec3c03e294c15ce7a4a746468424a96efdb380e (diff)
downloadvyatta-cfg-137a9d8c3944819791f045cf7491e59017a71c80.tar.gz
vyatta-cfg-137a9d8c3944819791f045cf7491e59017a71c80.zip
fix for bug 5667. Moved the location of the deactivate check.
Diffstat (limited to 'src/cli_val_engine.c')
-rw-r--r--src/cli_val_engine.c64
1 files changed, 64 insertions, 0 deletions
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;
+}