On 07/20/2009 08:27 PM, Ian Ward Comfort wrote:
In attempting an "auxiliary use" of template_files (as
suggested in the wiki
under BuiltinConfigManagement) I discovered that non-absolute paths are not
served correctly -- the relative destination is rewritten to a path under
rendered/, and subsequently lost to the calling code in api.py. I'm using
1.6.6, but it looks like the problem persists in master, so attached is a
patch against that.
Feel free to ignore if ongoing refactoring will make this irrelevant; I
haven't been paying sufficient attention to recent development(s).
IWC.
I think the behavior should be that non-absolute paths should not be
supported, yes.
If we have a key without a value (i.e. the value is None), then we can
serve them up but not try to write them anywhere.
Any code that attempts to write templates to the server itself needs to
be taken out back and shot, which I think it tried to do early on in the
development
of that feature.
So what you have looks good, will look into merging this shortly, and
removing other things around that as neccessary if need be.
---
cobbler/pxegen.py | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/cobbler/pxegen.py b/cobbler/pxegen.py
index dbc13a2..96e6b10 100644
--- a/cobbler/pxegen.py
+++ b/cobbler/pxegen.py
@@ -682,11 +682,10 @@ class PXEGen:
# configs into the rendered directory to ensure that a user
# granted cobbler privileges via sudo can't overwrite
# arbitrary system files (This also makes cleanup easier).
- if os.path.isabs(dest_dir):
- if write_file:
- raise CX(" warning: template destination (%s) is an absolute
path, skipping." % dest_dir)
- continue
- else:
+ if write_file:
+ if os.path.isabs(dest_dir):
+ raise CX(" warning: template destination (%s) is an absolute
path, skipping." % dest_dir)
+ continue
dest_dir = os.path.join(self.settings.webdir, "rendered",
dest_dir)
dest = os.path.join(dest_dir, os.path.basename(dest))
if not os.path.exists(dest_dir):