summaryrefslogtreecommitdiff
path: root/src/set.c
diff options
context:
space:
mode:
authorMichael Larson <slioch@eng-140.vyatta.com>2008-04-22 17:28:00 -0700
committerMichael Larson <slioch@eng-140.vyatta.com>2008-04-22 17:28:00 -0700
commit52b1e7ee61b6ce0e046371260dc13e333e3f62ca (patch)
tree0374f8070b74327be47f2dd7b0efc8bd117bfb7e /src/set.c
parent6ec19ddffc7ff6d8806a913314ceee6565d132c9 (diff)
downloadvyatta-cfg-52b1e7ee61b6ce0e046371260dc13e333e3f62ca.tar.gz
vyatta-cfg-52b1e7ee61b6ce0e046371260dc13e333e3f62ca.zip
create def file to mark configuration nodes that are created by default, rather than a node with a default value created by a
user. partial fix for bug 1219. Allows system to differentiate between active def nodes versus user created nodes with def values.
Diffstat (limited to 'src/set.c')
-rw-r--r--src/set.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/set.c b/src/set.c
index d961fb8..ed43267 100644
--- a/src/set.c
+++ b/src/set.c
@@ -245,6 +245,16 @@ int main(int argc, char **argv)
pop_path(&m_path);
}
make_dir();
+
+
+ if (!def.multi) {
+ char *path;
+ path= malloc(strlen(m_path.path)+5);
+ sprintf(path, "%s/def",m_path.path);
+ unlink(path);
+ free(path);
+ }
+
push_path(&m_path, VAL_NAME);
if(not_new && !def.multi) {
/* it is not multi and seen from M */
@@ -341,11 +351,22 @@ handle_default(vtw_path *mpath, vtw_path *tpath, char *exclude)
}
if (def.def_default) {
push_path(mpath, uename);
+
push_path(mpath, VAL_NAME);
if (lstat(mpath->path, &statbuf) < 0) {
/* no value. add the default */
pop_path(mpath);
touch_dir(mpath->path); /* make sure directory exist */
+
+ //create def marker
+ char *def_file;
+ def_file = malloc(strlen(mpath->path)+22);
+ sprintf(def_file,"touch %s/def",mpath->path);
+ system(def_file);
+ sprintf(def_file,"echo 'empty' > %s/def",mpath->path);
+ system(def_file);
+ free(def_file);
+
push_path(mpath, VAL_NAME);
fp = fopen(mpath->path, "w");
if (fp == NULL) {
@@ -356,6 +377,7 @@ handle_default(vtw_path *mpath, vtw_path *tpath, char *exclude)
bye("Error writing file %s", mpath->path);
}
fclose(fp);
+
}
pop_path(mpath); /* value */
pop_path(mpath); /* child */