From ce7b72eb71af9c5f7bf9ab0f423ec44c955a4b9a Mon Sep 17 00:00:00 2001 From: John Southworth Date: Sat, 23 Jul 2011 21:00:10 -0700 Subject: Bugfix 7362: Make reset_paths reset to root level when resolving varrefs --- src/cstore/cstore-varref.cpp | 2 +- src/cstore/cstore.hpp | 2 +- src/cstore/unionfs/cstore-unionfs.hpp | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/cstore/cstore-varref.cpp b/src/cstore/cstore-varref.cpp index f4a6918..4ece3b0 100644 --- a/src/cstore/cstore-varref.cpp +++ b/src/cstore/cstore-varref.cpp @@ -47,7 +47,7 @@ Cstore::VarRef::VarRef(Cstore *cstore, const string& ref_str, bool active) _orig_path_comps.push(tmp.back()); tmp.pop_back(); } - _cstore->reset_paths(); + _cstore->reset_paths(true); /* at this point, cstore paths are at root. _orig_path_comps contains * the path originally in cstore (or empty if _absolute). */ diff --git a/src/cstore/cstore.hpp b/src/cstore/cstore.hpp index d6f6d67..228a6c3 100644 --- a/src/cstore/cstore.hpp +++ b/src/cstore/cstore.hpp @@ -339,7 +339,7 @@ private: virtual void pop_cfg_path() = 0; virtual void pop_cfg_path(string& last) = 0; virtual void append_cfg_path(const Cpath& path_comps) = 0; - virtual void reset_paths() = 0; + virtual void reset_paths(bool to_root = true) = 0; virtual auto_ptr create_save_paths() = 0; virtual bool cfg_path_at_root() = 0; virtual bool tmpl_path_at_root() = 0; diff --git a/src/cstore/unionfs/cstore-unionfs.hpp b/src/cstore/unionfs/cstore-unionfs.hpp index 1240488..c56f060 100644 --- a/src/cstore/unionfs/cstore-unionfs.hpp +++ b/src/cstore/unionfs/cstore-unionfs.hpp @@ -154,7 +154,17 @@ private: push_cfg_path(path_comps[i]); } }; - void reset_paths() { + void reset_paths(bool to_root=false) { + if (to_root){ + char *val; + if ((val = getenv(C_ENV_TMPL_ROOT.c_str()))) { + tmpl_path = val; + } else { + tmpl_path = C_DEF_TMPL_ROOT; + } + orig_tmpl_path = val; + orig_mutable_cfg_path = "/"; + } tmpl_path = orig_tmpl_path; mutable_cfg_path = orig_mutable_cfg_path; }; -- cgit v1.2.3